Show how long this program has been used

This commit is contained in:
fgnm
2020-09-08 19:00:58 +02:00
parent 8410b8ce6e
commit 396a7bc8bd
5 changed files with 31 additions and 2 deletions
@@ -30,6 +30,8 @@ public class EditorConfigVO {
public String lastOpenedSystemPath = "";
public String lastImportedSystemPath = "";
public long totalSpentTime = 0;
public boolean disableAmbientComposite = true;
public boolean autoSave = false;
public boolean enablePlugins = true;
@@ -33,6 +33,7 @@ import com.badlogic.gdx.utils.Align;
import com.badlogic.gdx.utils.ObjectMap;
import games.rednblack.editor.proxy.CommandManager;
import games.rednblack.editor.proxy.ProjectManager;
import games.rednblack.editor.proxy.SettingsManager;
import games.rednblack.editor.splash.SplashScreenAdapter;
import games.rednblack.editor.view.frame.FileDropListener;
import games.rednblack.editor.view.ui.panel.ImportPanel;
@@ -62,6 +63,8 @@ public class HyperLap2D implements IProxy, ApplicationListener, Lwjgl3WindowList
private final Sync sync = new Sync();
private long startTime = 0;
public HyperLap2D() {
renderNotification = new Notification(MsgAPI.RENDER, null, null);
}
@@ -121,6 +124,8 @@ public class HyperLap2D implements IProxy, ApplicationListener, Lwjgl3WindowList
int height = h.get(0);
sendNotification(MsgAPI.RESIZE, new int[]{width, height});
startTime = System.currentTimeMillis();
}
@Override
@@ -226,6 +231,11 @@ public class HyperLap2D implements IProxy, ApplicationListener, Lwjgl3WindowList
facade.sendNotification(MsgAPI.CHECK_EDITS_ACTION, (Runnable) () -> {
sendNotification(MsgAPI.DISPOSE);
VisUI.dispose();
SettingsManager settingsManager = facade.retrieveProxy(SettingsManager.NAME);
settingsManager.editorConfigVO.totalSpentTime += System.currentTimeMillis() - startTime;
settingsManager.saveEditorConfig();
Gdx.app.exit();
});
return false;
@@ -29,6 +29,7 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import games.rednblack.editor.HyperLap2DApp;
import games.rednblack.editor.proxy.ProjectManager;
import games.rednblack.editor.proxy.SettingsManager;
import games.rednblack.editor.view.menu.FileMenu;
@@ -186,7 +187,7 @@ public class HyperLap2DScreen implements Screen, InputProcessor {
}
if (Gdx.input.isKeyPressed(Input.Keys.SYM) && keycode == Input.Keys.Q) {
facade.sendNotification(MsgAPI.CHECK_EDITS_ACTION, (Runnable) () -> Gdx.app.exit());
HyperLap2DApp.getInstance().hyperlap2D.closeRequested();
}
return false;
}
@@ -22,6 +22,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.files.FileHandle;
import com.badlogic.gdx.utils.Array;
import com.kotcrab.vis.ui.widget.file.FileTypeFilter;
import games.rednblack.editor.HyperLap2DApp;
import games.rednblack.editor.proxy.SettingsManager;
import games.rednblack.h2d.common.view.ui.widget.HyperLapFileChooser;
import games.rednblack.h2d.common.MsgAPI;
@@ -162,7 +163,7 @@ public class HyperLap2DMenuBarMediator extends Mediator<HyperLap2DMenuBar> {
facade.sendNotification(MsgAPI.ACTION_EXPORT_PROJECT);
break;
case FileMenu.EXIT:
facade.sendNotification(MsgAPI.CHECK_EDITS_ACTION, (Runnable) () -> Gdx.app.exit());
HyperLap2DApp.getInstance().hyperlap2D.closeRequested();
break;
}
}
@@ -18,6 +18,10 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class AboutDialog extends H2DDialog {
@@ -25,6 +29,13 @@ public class AboutDialog extends H2DDialog {
super("About HyperLap2D");
addCloseButton();
SettingsManager settingsManager = HyperLap2DFacade.getInstance().retrieveProxy(SettingsManager.NAME);
Date date = new Date(settingsManager.editorConfigVO.totalSpentTime);
DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
formatter.setTimeZone(TimeZone.getTimeZone("UTC"));
String totalTimeSpent = formatter.format(date);
VisTable mainTable = new VisTable();
VisTable leftTable = new VisTable();
VisTable contentTable = new VisTable();
@@ -38,6 +49,10 @@ public class AboutDialog extends H2DDialog {
leftTable.add(new VisImage(VisUI.getSkin().getDrawable("splash_logo"))).pad(5).row();
leftTable.add("HyperLap2D").padLeft(5).padRight(5).row();
leftTable.add("Release " + AppConfig.getInstance().version).row();
leftTable.add("Total Time").padTop(20).row();
leftTable.add(totalTimeSpent).row();
contentTable.add("Copyright \u00A9 2020 Red & Black Games").left().row();
contentTable.add("").row();
contentTable.add("Dedicated to game lovers. Create something awesome!").left().row();