Refactor Option GUI
This commit is contained in:
parent
78bddd9956
commit
b3a8b7c57d
@ -49,7 +49,6 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
//Video Controls
|
//Video Controls
|
||||||
private ComboBox cboResolution;
|
private ComboBox cboResolution;
|
||||||
private ComboBox cboFrequency;
|
private ComboBox cboFrequency;
|
||||||
private ComboBox cboDepthBits;
|
|
||||||
private CheckBox chkFullscreen;
|
private CheckBox chkFullscreen;
|
||||||
private CheckBox chkVSync;
|
private CheckBox chkVSync;
|
||||||
private CheckBox chkPostProcessing;
|
private CheckBox chkPostProcessing;
|
||||||
@ -81,23 +80,15 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
private void create() {
|
private void create() {
|
||||||
float tabControlStartPointx = screenHelper.calcX(32f);
|
float tabControlStartPointx = screenHelper.calcX(32f);
|
||||||
float tabControlStartPointy = screenHelper.calcY(18f);
|
float tabControlStartPointy = screenHelper.calcY(18f);
|
||||||
float witdhTabControl = screenHelper.calcX(1216f);
|
|
||||||
float heightTabControl = screenHelper.calcY(612f);
|
|
||||||
|
|
||||||
float buttonWidth = screenHelper.calcX(153.6f);
|
float buttonWidth = screenHelper.calcX(153.6f);
|
||||||
float buttonHeight = screenHelper.calcY(40f);
|
float buttonHeight = screenHelper.calcY(40f);
|
||||||
|
|
||||||
float labelFontSize = screenHelper.calcX(20f);
|
float labelFontSize = screenHelper.calcX(20f);
|
||||||
|
|
||||||
TabControl tcOptions = new TabControl(screen, "tcOptions", new Vector2f(tabControlStartPointx, tabControlStartPointy), new Vector2f(witdhTabControl, heightTabControl));
|
createGeneral(labelFontSize);
|
||||||
tcOptions.setUseSlideEffect(true);
|
createVideo(labelFontSize);
|
||||||
tcOptions.addTab("General");
|
createAudio(labelFontSize);
|
||||||
tcOptions.addTab("Video");
|
|
||||||
tcOptions.addTab("Audio");
|
|
||||||
|
|
||||||
createGeneralTab(tcOptions,labelFontSize);
|
|
||||||
createVideoTab(tcOptions,labelFontSize);
|
|
||||||
createAudioTab(tcOptions,labelFontSize);
|
|
||||||
|
|
||||||
float differnceTabControlButtons = screenHelper.calcY(622.8f);
|
float differnceTabControlButtons = screenHelper.calcY(622.8f);
|
||||||
|
|
||||||
@ -120,12 +111,11 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
btnCancel.setText("Cancel");
|
btnCancel.setText("Cancel");
|
||||||
btnCancel.setFontSize(labelFontSize);
|
btnCancel.setFontSize(labelFontSize);
|
||||||
|
|
||||||
this.addChild(tcOptions);
|
|
||||||
this.addChild(btnSave);
|
this.addChild(btnSave);
|
||||||
this.addChild(btnCancel);
|
this.addChild(btnCancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGeneralTab(TabControl tcOptions, float labelFontSize) {
|
private void createGeneral(float labelFontSize) {
|
||||||
float startPointx = screenHelper.calcX(64f);
|
float startPointx = screenHelper.calcX(64f);
|
||||||
float startPointy = screenHelper.calcY(36f);
|
float startPointy = screenHelper.calcY(36f);
|
||||||
float marginLeftControls = screenHelper.calcX(115.8f);
|
float marginLeftControls = screenHelper.calcX(115.8f);
|
||||||
@ -137,14 +127,14 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
txtPlayerName = new TextField(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f)));
|
txtPlayerName = new TextField(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(screenHelper.calcX(200f), screenHelper.calcY(30f)));
|
||||||
txtPlayerName.setFontSize(labelFontSize);
|
txtPlayerName.setFontSize(labelFontSize);
|
||||||
|
|
||||||
tcOptions.addTabChild(0, lblPlayerName);
|
this.addChild(lblPlayerName);
|
||||||
tcOptions.addTabChild(0, txtPlayerName);
|
this.addChild(txtPlayerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createVideoTab(TabControl tcOptions, float labelFontSize) {
|
private void createVideo(float labelFontSize) {
|
||||||
|
|
||||||
float startPointx = screenHelper.calcX(64f);
|
float startPointx = screenHelper.calcX(64f);
|
||||||
float startPointy = screenHelper.calcY(36f);
|
float startPointy = screenHelper.calcY(90f);
|
||||||
float marginLeftControls = screenHelper.calcX(115.8f);
|
float marginLeftControls = screenHelper.calcX(115.8f);
|
||||||
float labelWitdh = screenHelper.calcX(120f);
|
float labelWitdh = screenHelper.calcX(120f);
|
||||||
float labelHeight = screenHelper.calcY(40f);
|
float labelHeight = screenHelper.calcY(40f);
|
||||||
@ -158,11 +148,29 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
float sliderWitdh = screenHelper.calcX(200f);
|
float sliderWitdh = screenHelper.calcX(200f);
|
||||||
float sliderHeight = screenHelper.calcY(30f);
|
float sliderHeight = screenHelper.calcY(30f);
|
||||||
|
|
||||||
Label lblResolution = new Label(screen, "lblResolution", new Vector2f(startPointx, startPointy), new Vector2f(labelWitdh, labelHeight));
|
Label lblFullscreen = new Label(screen, "lblFullscreen", new Vector2f(startPointx, startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||||
|
lblFullscreen.setText("Fullscreen");
|
||||||
|
lblFullscreen.setFontSize(labelFontSize);
|
||||||
|
|
||||||
|
chkFullscreen = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||||
|
|
||||||
|
Label lblVSync = new Label(screen, "lblVSync", new Vector2f(startPointx + screenHelper.calcX(400f), startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||||
|
lblVSync.setText("VSync");
|
||||||
|
lblVSync.setFontSize(labelFontSize);
|
||||||
|
|
||||||
|
chkVSync = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||||
|
|
||||||
|
Label lblPostProcessing = new Label(screen, "lblPostProcessing", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||||
|
lblPostProcessing.setText("PostProcessing");
|
||||||
|
lblPostProcessing.setFontSize(labelFontSize);
|
||||||
|
|
||||||
|
chkPostProcessing = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(12f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
||||||
|
|
||||||
|
Label lblResolution = new Label(screen, "lblResolution", new Vector2f(startPointx, startPointy + screenHelper.calcY(50f)), new Vector2f(labelWitdh, labelHeight));
|
||||||
lblResolution.setText("Resolution");
|
lblResolution.setText("Resolution");
|
||||||
lblResolution.setFontSize(labelFontSize);
|
lblResolution.setFontSize(labelFontSize);
|
||||||
|
|
||||||
cboResolution = new ComboBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(7f)), new Vector2f(comboBoxWidth, comboBoxHeight)) {
|
cboResolution = new ComboBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(57f)), new Vector2f(comboBoxWidth, comboBoxHeight)) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(int selectedIndex, Object value) {
|
public void onChange(int selectedIndex, Object value) {
|
||||||
}
|
}
|
||||||
@ -172,11 +180,11 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
cboResolution.addListItem(s, s);
|
cboResolution.addListItem(s, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Label lblFrequency = new Label(screen, "lblFrequency", new Vector2f(startPointx, startPointy + screenHelper.calcY(40f)), new Vector2f(labelWitdh, labelHeight));
|
Label lblFrequency = new Label(screen, "lblFrequency", new Vector2f(startPointx + screenHelper.calcX(400f), startPointy + screenHelper.calcY(50f)), new Vector2f(labelWitdh, labelHeight));
|
||||||
lblFrequency.setText("Frequency");
|
lblFrequency.setText("Frequency");
|
||||||
lblFrequency.setFontSize(labelFontSize);
|
lblFrequency.setFontSize(labelFontSize);
|
||||||
|
|
||||||
cboFrequency = new ComboBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(47f)), new Vector2f(comboBoxWidth, comboBoxHeight)) {
|
cboFrequency = new ComboBox(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(57f)), new Vector2f(comboBoxWidth, comboBoxHeight)) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(int selectedIndex, Object value) {
|
public void onChange(int selectedIndex, Object value) {
|
||||||
}
|
}
|
||||||
@ -184,45 +192,13 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
cboFrequency.setFontSize(labelFontSize);
|
cboFrequency.setFontSize(labelFontSize);
|
||||||
for (String s : DisplayHelper.getFrequencys()) {
|
for (String s : DisplayHelper.getFrequencys()) {
|
||||||
cboFrequency.addListItem(s, s);
|
cboFrequency.addListItem(s, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
Label lblDepthBits = new Label(screen, "lblDepthBits", new Vector2f(startPointx, startPointy + screenHelper.calcY(80f)), new Vector2f(labelWitdh, labelHeight));
|
Label lblParticleDensity = new Label(screen, "lblParticleDensity", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy +screenHelper.calcY(50f)), new Vector2f(labelWitdh, labelHeight));
|
||||||
lblDepthBits.setText("DepthBits");
|
|
||||||
lblDepthBits.setFontSize(labelFontSize);
|
|
||||||
|
|
||||||
cboDepthBits = new ComboBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(87f)), new Vector2f(comboBoxWidth, comboBoxHeight)) {
|
|
||||||
@Override
|
|
||||||
public void onChange(int selectedIndex, Object value) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
cboDepthBits.setFontSize(labelFontSize);
|
|
||||||
for (String s : DisplayHelper.getDepthBits()) {
|
|
||||||
cboDepthBits.addListItem(s, s);
|
|
||||||
}
|
|
||||||
|
|
||||||
Label lblFullscreen = new Label(screen, "lblFullscreen", new Vector2f(startPointx, startPointy + screenHelper.calcY(120f)), new Vector2f(labelWitdh, labelHeight));
|
|
||||||
lblFullscreen.setText("Fullscreen");
|
|
||||||
lblFullscreen.setFontSize(labelFontSize);
|
|
||||||
|
|
||||||
chkFullscreen = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(132f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
|
||||||
|
|
||||||
Label lblVSync = new Label(screen, "lblVSync", new Vector2f(startPointx, startPointy + screenHelper.calcY(160f)), new Vector2f(labelWitdh, labelHeight));
|
|
||||||
lblVSync.setText("VSync");
|
|
||||||
lblVSync.setFontSize(labelFontSize);
|
|
||||||
|
|
||||||
chkVSync = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(172f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
|
||||||
|
|
||||||
Label lblPostProcessing = new Label(screen, "lblPostProcessing", new Vector2f(startPointx, startPointy + screenHelper.calcY(200f)), new Vector2f(labelWitdh, labelHeight));
|
|
||||||
lblPostProcessing.setText("PostProcessing");
|
|
||||||
lblPostProcessing.setFontSize(labelFontSize);
|
|
||||||
|
|
||||||
chkPostProcessing = new CheckBox(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(212f)), new Vector2f(checkBoxWitdh, checkBoxHeight));
|
|
||||||
|
|
||||||
Label lblParticleDensity = new Label(screen, "lblParticleDensity", new Vector2f(startPointx, startPointy +screenHelper.calcY(240f)), new Vector2f(labelWitdh, labelHeight));
|
|
||||||
lblParticleDensity.setText("ParticleDensity");
|
lblParticleDensity.setText("ParticleDensity");
|
||||||
lblParticleDensity.setFontSize(labelFontSize);
|
lblParticleDensity.setFontSize(labelFontSize);
|
||||||
|
|
||||||
sldParticleDensity = new Slider(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(247f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
sldParticleDensity = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(57f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(int selectedIndex, Object value) {
|
public void onChange(int selectedIndex, Object value) {
|
||||||
}
|
}
|
||||||
@ -230,25 +206,23 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
sldParticleDensity.setStepIntegerRange(0, 3, 1);
|
sldParticleDensity.setStepIntegerRange(0, 3, 1);
|
||||||
|
|
||||||
|
|
||||||
tcOptions.addTabChild(1, lblVSync);
|
this.addChild(lblVSync);
|
||||||
tcOptions.addTabChild(1, chkVSync);
|
this.addChild(chkVSync);
|
||||||
tcOptions.addTabChild(1, lblFullscreen);
|
this.addChild(lblFullscreen);
|
||||||
tcOptions.addTabChild(1, chkFullscreen);
|
this.addChild(chkFullscreen);
|
||||||
tcOptions.addTabChild(1, lblDepthBits);
|
this.addChild(lblFrequency);
|
||||||
tcOptions.addTabChild(1, cboDepthBits);
|
this.addChild(cboFrequency);
|
||||||
tcOptions.addTabChild(1, lblFrequency);
|
this.addChild(lblResolution);
|
||||||
tcOptions.addTabChild(1, cboFrequency);
|
this.addChild(cboResolution);
|
||||||
tcOptions.addTabChild(1, lblResolution);
|
this.addChild(lblPostProcessing);
|
||||||
tcOptions.addTabChild(1, cboResolution);
|
this.addChild(chkPostProcessing);
|
||||||
tcOptions.addTabChild(1, lblPostProcessing);
|
this.addChild(lblParticleDensity);
|
||||||
tcOptions.addTabChild(1, chkPostProcessing);
|
this.addChild(sldParticleDensity);
|
||||||
tcOptions.addTabChild(1, lblParticleDensity);
|
|
||||||
tcOptions.addTabChild(1, sldParticleDensity);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createAudioTab(TabControl tcOptions, float labelFontSize) {
|
private void createAudio(float labelFontSize) {
|
||||||
float startPointx = screenHelper.calcX(64f);
|
float startPointx = screenHelper.calcX(64f);
|
||||||
float startPointy = screenHelper.calcY(36f);
|
float startPointy = screenHelper.calcY(290f);
|
||||||
float marginLeftControls = screenHelper.calcX(115.8f);
|
float marginLeftControls = screenHelper.calcX(115.8f);
|
||||||
|
|
||||||
float labelWitdh = screenHelper.calcX(120f);
|
float labelWitdh = screenHelper.calcX(120f);
|
||||||
@ -268,34 +242,34 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
};
|
};
|
||||||
sldMasterVolume.setStepIntegerRange(0, 100, 1);
|
sldMasterVolume.setStepIntegerRange(0, 100, 1);
|
||||||
|
|
||||||
Label lblFXVolume = new Label(screen, "lblFXVolume", new Vector2f(startPointx, startPointy + screenHelper.calcY(40f)), new Vector2f(labelWitdh, labelHeight));
|
Label lblFXVolume = new Label(screen, "lblFXVolume", new Vector2f(startPointx + screenHelper.calcX(400f), startPointy), new Vector2f(labelWitdh, labelHeight));
|
||||||
lblFXVolume.setText("FXVolume");
|
lblFXVolume.setText("FXVolume");
|
||||||
lblFXVolume.setFontSize(labelFontSize);
|
lblFXVolume.setFontSize(labelFontSize);
|
||||||
|
|
||||||
sldFXVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(47f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
sldFXVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(400f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(int selectedIndex, Object value) {
|
public void onChange(int selectedIndex, Object value) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sldFXVolume.setStepIntegerRange(0, 100, 1);
|
sldFXVolume.setStepIntegerRange(0, 100, 1);
|
||||||
|
|
||||||
Label lblSoundVolume = new Label(screen, "lblSoundVolume", new Vector2f(startPointx, startPointy + screenHelper.calcY(80f)), new Vector2f(labelWitdh, labelHeight));
|
Label lblSoundVolume = new Label(screen, "lblSoundVolume", new Vector2f(startPointx + screenHelper.calcX(800f), startPointy + screenHelper.calcY(0f)), new Vector2f(labelWitdh, labelHeight));
|
||||||
lblSoundVolume.setText("SoundVolume");
|
lblSoundVolume.setText("SoundVolume");
|
||||||
lblSoundVolume.setFontSize(labelFontSize);
|
lblSoundVolume.setFontSize(labelFontSize);
|
||||||
|
|
||||||
sldSoundVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls, startPointy + screenHelper.calcY(87f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
sldSoundVolume = new Slider(screen, new Vector2f(startPointx + marginLeftControls + screenHelper.calcX(800f), startPointy + screenHelper.calcY(7f)), new Vector2f(sliderWitdh, sliderHeight), Slider.Orientation.HORIZONTAL, false) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(int selectedIndex, Object value) {
|
public void onChange(int selectedIndex, Object value) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
sldSoundVolume.setStepIntegerRange(0, 100, 1);
|
sldSoundVolume.setStepIntegerRange(0, 100, 1);
|
||||||
|
|
||||||
tcOptions.addTabChild(2, lblMasterVolume);
|
this.addChild(lblMasterVolume);
|
||||||
tcOptions.addTabChild(2, sldMasterVolume);
|
this.addChild(sldMasterVolume);
|
||||||
tcOptions.addTabChild(2, lblFXVolume);
|
this.addChild(lblFXVolume);
|
||||||
tcOptions.addTabChild(2, sldFXVolume);
|
this.addChild(sldFXVolume);
|
||||||
tcOptions.addTabChild(2, lblSoundVolume);
|
this.addChild(lblSoundVolume);
|
||||||
tcOptions.addTabChild(2, sldSoundVolume);
|
this.addChild(sldSoundVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readControlValues() {
|
private void readControlValues() {
|
||||||
@ -307,7 +281,6 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
//Video
|
//Video
|
||||||
setComboBoxValue(cboResolution, resolution);
|
setComboBoxValue(cboResolution, resolution);
|
||||||
setComboBoxValue(cboFrequency, String.valueOf(settings.getFrequency()));
|
setComboBoxValue(cboFrequency, String.valueOf(settings.getFrequency()));
|
||||||
setComboBoxValue(cboDepthBits, String.valueOf(settings.getDepthBits()));
|
|
||||||
chkFullscreen.setIsChecked(settings.isFullscreenEnabled());
|
chkFullscreen.setIsChecked(settings.isFullscreenEnabled());
|
||||||
chkVSync.setIsChecked(settings.isVSyncEnabled());
|
chkVSync.setIsChecked(settings.isVSyncEnabled());
|
||||||
chkPostProcessing.setIsChecked(settings.isPostprocessingEnabled());
|
chkPostProcessing.setIsChecked(settings.isPostprocessingEnabled());
|
||||||
@ -336,7 +309,6 @@ public class OptionsGUI extends Panel implements Gui {
|
|||||||
settings.setWidth(Integer.parseInt(resolution[0]));
|
settings.setWidth(Integer.parseInt(resolution[0]));
|
||||||
settings.setHeight(Integer.parseInt(resolution[1]));
|
settings.setHeight(Integer.parseInt(resolution[1]));
|
||||||
settings.setFrequency(Integer.parseInt(cboFrequency.getSelectedListItem().getValue().toString()));
|
settings.setFrequency(Integer.parseInt(cboFrequency.getSelectedListItem().getValue().toString()));
|
||||||
settings.setDepthBits(Integer.parseInt(cboDepthBits.getSelectedListItem().getValue().toString()));
|
|
||||||
settings.setFullscreen(chkFullscreen.getIsChecked());
|
settings.setFullscreen(chkFullscreen.getIsChecked());
|
||||||
settings.setVSync(chkVSync.getIsChecked());
|
settings.setVSync(chkVSync.getIsChecked());
|
||||||
settings.setPostProcessing(chkPostProcessing.getIsChecked());
|
settings.setPostProcessing(chkPostProcessing.getIsChecked());
|
||||||
|
|||||||
@ -64,6 +64,7 @@ public class OptionSettings {
|
|||||||
setUsername("Player");
|
setUsername("Player");
|
||||||
setPostProcessing(true);
|
setPostProcessing(true);
|
||||||
setParticleDensity(3);
|
setParticleDensity(3);
|
||||||
|
setDepthBits(24);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user