Control FPS Limit in editor settings
This commit is contained in:
+1
-1
Submodule hyperlap2d-common-api updated: 4d2862b4c5...763acfa9a6
@@ -48,7 +48,7 @@ public class HyperLap2DApp extends ApplicationAdapter {
|
||||
config2.setResizable(false);
|
||||
config2.setDecorated(false);
|
||||
config2.setIdleFPS(60);
|
||||
config2.setForegroundFPS(60);
|
||||
config2.setForegroundFPS(settingsManager.editorConfigVO.fpsLimit);
|
||||
config2.useVsync(false);
|
||||
config2.setWindowIcon("hyperlap_icon_96.png");
|
||||
|
||||
@@ -64,7 +64,7 @@ public class HyperLap2DApp extends ApplicationAdapter {
|
||||
config.setResizable(true);
|
||||
config.setWindowedMode((int) (windowWidth), (int) (windowHeight));
|
||||
config.setIdleFPS(60);
|
||||
config.setForegroundFPS(60);
|
||||
config.setForegroundFPS(settingsManager.editorConfigVO.fpsLimit);
|
||||
config.useVsync(false);
|
||||
config.setInitialVisible(false);
|
||||
config.setMaximized(true);
|
||||
@@ -90,7 +90,7 @@ public class HyperLap2DApp extends ApplicationAdapter {
|
||||
config2.setResizable(false);
|
||||
config2.setDecorated(false);
|
||||
config2.setIdleFPS(60);
|
||||
config2.setForegroundFPS(60);
|
||||
config2.setForegroundFPS(settingsManager.editorConfigVO.fpsLimit);
|
||||
config2.useVsync(false);
|
||||
config2.setWindowIcon("hyperlap_icon_96.png");
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class Main {
|
||||
config.setDecorated(false);
|
||||
config.setInitialVisible(false);
|
||||
config.setIdleFPS(60);
|
||||
config.setForegroundFPS(60);
|
||||
config.setForegroundFPS(settingsManager.editorConfigVO.fpsLimit);
|
||||
config.useVsync(false);
|
||||
config.setTitle("HyperLap2D");
|
||||
config.setWindowIcon("hyperlap_icon_96.png");
|
||||
|
||||
@@ -17,7 +17,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
private final VisCheckBox autoSaving, useOpenGL3;
|
||||
private final VisCheckBox enablePlugins;
|
||||
private VisSelectBox<String> filterKeyMapping;
|
||||
private VisSlider uiScaleDensity, msaaSamples;
|
||||
private VisSlider uiScaleDensity, msaaSamples, fpsLimit;
|
||||
|
||||
public GeneralSettings() {
|
||||
super("General", HyperLap2DFacade.getInstance());
|
||||
@@ -39,6 +39,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
getContentTable().add("Performance").left().padTop(10).row();
|
||||
getContentTable().addSeparator();
|
||||
getContentTable().add(getMassSamplesTable()).left().padTop(5).row();
|
||||
getContentTable().add(getFPSLimitTable()).left().padTop(5).row();
|
||||
|
||||
useOpenGL3 = StandardWidgetsFactory.createCheckBox("Use OpenGL 3 API [Require restart]");
|
||||
getContentTable().add(useOpenGL3).left().padTop(5).padLeft(8).row();
|
||||
@@ -65,6 +66,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
scaleTable.add(uiScaleDensity).padLeft(8);
|
||||
VisLabel labelFactor = StandardWidgetsFactory.createLabel("", "default", Align.left);
|
||||
scaleTable.add(labelFactor).padLeft(8);
|
||||
labelFactor.setText(getUIScaleDensity() + "x");
|
||||
uiScaleDensity.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@@ -83,6 +85,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
msaaTable.add(msaaSamples).padLeft(8);
|
||||
VisLabel labelFactor = StandardWidgetsFactory.createLabel("", "default", Align.left);
|
||||
msaaTable.add(labelFactor).padLeft(8);
|
||||
labelFactor.setText(getMsaaSamples());
|
||||
msaaSamples.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
@@ -93,6 +96,28 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
return msaaTable;
|
||||
}
|
||||
|
||||
private Actor getFPSLimitTable() {
|
||||
VisTable fpsLimitTable = new VisTable();
|
||||
|
||||
fpsLimitTable.add("FPS Limit:").padLeft(8);
|
||||
fpsLimit = StandardWidgetsFactory.createSlider(0, 240, 10);
|
||||
fpsLimitTable.add(fpsLimit).padLeft(8);
|
||||
VisLabel labelFactor = StandardWidgetsFactory.createLabel("", "default", Align.left);
|
||||
fpsLimitTable.add(labelFactor).padLeft(8);
|
||||
labelFactor.setText("Unlimited");
|
||||
fpsLimit.addListener(new ChangeListener() {
|
||||
@Override
|
||||
public void changed(ChangeEvent event, Actor actor) {
|
||||
if (getFPSLimit() == 0)
|
||||
labelFactor.setText("Unlimited");
|
||||
else
|
||||
labelFactor.setText(getFPSLimit() + " [Require restart]");
|
||||
}
|
||||
});
|
||||
|
||||
return fpsLimitTable;
|
||||
}
|
||||
|
||||
private float getUIScaleDensity() {
|
||||
return RoundUtils.round(uiScaleDensity.getValue(), 2);
|
||||
}
|
||||
@@ -101,6 +126,10 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
return (int) msaaSamples.getValue();
|
||||
}
|
||||
|
||||
private int getFPSLimit() {
|
||||
return (int) fpsLimit.getValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void translateSettingsToView() {
|
||||
autoSaving.setChecked(getSettings().autoSave);
|
||||
@@ -109,6 +138,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
filterKeyMapping.setSelected(getSettings().keyBindingLayout);
|
||||
uiScaleDensity.setValue(getSettings().uiScaleDensity);
|
||||
msaaSamples.setValue(getSettings().msaaSamples);
|
||||
fpsLimit.setValue(getSettings().fpsLimit);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,6 +149,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
getSettings().keyBindingLayout = filterKeyMapping.getSelected();
|
||||
getSettings().uiScaleDensity = getUIScaleDensity();
|
||||
getSettings().msaaSamples = getMsaaSamples();
|
||||
getSettings().fpsLimit = getFPSLimit();
|
||||
facade.sendNotification(MsgAPI.SAVE_EDITOR_CONFIG);
|
||||
}
|
||||
|
||||
@@ -129,6 +160,7 @@ public class GeneralSettings extends SettingsNodeValue<EditorConfigVO> {
|
||||
|| getSettings().enablePlugins != enablePlugins.isChecked()
|
||||
|| !getSettings().keyBindingLayout.equals(filterKeyMapping.getSelected())
|
||||
|| getSettings().uiScaleDensity != getUIScaleDensity()
|
||||
|| getSettings().msaaSamples != getMsaaSamples();
|
||||
|| getSettings().msaaSamples != getMsaaSamples()
|
||||
|| getSettings().fpsLimit != getFPSLimit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user