Skip to content

Commit a0086ea

Browse files
committed
Save last instance to load it automatically on instance page
1 parent ac2a2d4 commit a0086ea

File tree

4 files changed

+33
-6
lines changed

4 files changed

+33
-6
lines changed

application-main/src/main/java/com/zyneonstudios/application/Application.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class Application {
3636
public static String version;
3737
public static String theme;
3838
public static boolean logOutput;
39+
public static String lastInstance;
3940

4041
public Application(String ver) {
4142
version = ver;
@@ -57,11 +58,17 @@ private void initConfig() {
5758
config.checkEntry("settings.memory.default", 1024);
5859
config.checkEntry("settings.logger.debug", false);
5960
config.checkEntry("settings.appearance.theme","default.dark");
61+
config.checkEntry("settings.lastInstance","zyneon::overview");
6062

6163
logOutput = config.getBool("settings.logOutput");
6264
theme = config.getString("settings.appearance.theme");
6365
memory = config.getInteger("settings.memory.default");
6466
startTab = config.getString("settings.starttab");
67+
if(config.getString("settings.lastInstance").equalsIgnoreCase("zyneon::overview")) {
68+
lastInstance = null;
69+
} else {
70+
lastInstance = config.getString("settings.lastInstance");
71+
}
6572
if(!Main.getLogger().isDebugEnabled()) {
6673
Main.getLogger().setDebugEnabled(config.getBool("settings.logger.debug"));
6774
ShadeMeBaby.getLogger().setDebugEnabled(Main.getLogger().isDebugEnabled());
@@ -198,15 +205,20 @@ public static String getStartURL() {
198205
} else {
199206
url = getNewsURL();
200207
}
201-
return url+"?theme="+theme;
208+
if(url.contains("?")) {
209+
url=url+"&theme="+theme;
210+
} else {
211+
url=url+"?theme="+theme;
212+
}
213+
return url;
202214
}
203215

204216
public static String getNewsURL() {
205217
return "file://" + Main.getDirectoryPath() + "libs/zyneon/" + Main.version + "/" + "start.html";
206218
}
207219

208220
public static String getInstancesURL() {
209-
return "file://" + Main.getDirectoryPath() + "libs/zyneon/" + Main.version + "/" + "instances.html";
221+
return "file://" + Main.getDirectoryPath() + "libs/zyneon/" + Main.version + "/" + "instances.html";
210222
}
211223

212224
public static String getSettingsURL() {

application-main/src/main/java/com/zyneonstudios/application/backend/utils/backend/Connector.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public void resolveRequest(String request) {
116116
} catch (IOException e) {
117117
Main.getLogger().error(e.getMessage());
118118
}
119-
frame.executeJavaScript("loadTab();");
119+
frame.executeJavaScript("loadTab('"+Application.lastInstance+"');");
120120
} else if (request.contains("sync.login")) {
121121
try {
122122
if (Application.auth.isLoggedIn()) {
@@ -219,6 +219,9 @@ public void resolveRequest(String request) {
219219
String command = "syncSettings(\"" + id + "\",\"" + ram + " MB\",\"" + name + "\",\"" + version + "\",\"" + description + "\",\"" + minecraft + "\",\"" + modloader + "\",\"" + mlversion + "\",\"" + icon_ + "\",\"" + logo_ + "\",\"" + background_ + "\");";
220220
Main.getLogger().debug("[CONNECTOR] Sending command: "+command);
221221
frame.executeJavaScript(command);
222+
223+
Application.lastInstance = id;
224+
Application.config.set("settings.lastInstance",Application.lastInstance);
222225
}
223226
} else if (request.contains("button.delete.")) {
224227
request = request.replace("button.delete.", "");

application-ui/content/assets/zyneon/js/instances.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,22 @@ function syncInstanceList() {
2626
callJavaMethod("sync.instances.list");
2727
}
2828

29-
function loadTab() {
29+
function loadTab(tab) {
3030
const urlParams = new URLSearchParams(window.location.search);
31+
let tab_ = "zyneon::overview";
3132
if(urlParams.get("tab")!=null) {
32-
syncInstance(urlParams.get("tab"));
33+
tab_ = urlParams.get("tab");
34+
} else {
35+
if(tab!==null) {
36+
if(tab!==undefined) {
37+
if(tab!=="null") {
38+
tab_ = tab;
39+
}
40+
}
41+
}
42+
}
43+
if(document.getElementById(tab)!==null) {
44+
syncInstance(tab_);
3345
}
3446
}
3547

application-ui/content/start.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
<img alt="Zyneon Logo" src="assets/zyneon/images/abstract.png">
9797
<div>
9898
<h2>Zyneon Application</h2>
99-
<h3>Manage, create and share beloved Minecraft instances, mod packs, resources and more!</h3>
99+
<h3>Manage, create and share beloved Minecraft instances, mod packs, resource pack and much more!</h3>
100100
</div>
101101
</div>
102102
</div>

0 commit comments

Comments
 (0)