Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

Commit

Permalink
Add update channel switcher for new updater
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldieeins committed Apr 28, 2024
1 parent a84915a commit 82fe18c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class Application {
public static boolean thirdPartyWarn;
public static String lastInstance;
public static ArrayList<String> args;
public static String updateChannel = "stable";

public static final Runner runner = new Runner();
public static ArrayList<String> running = new ArrayList<>();
Expand All @@ -69,6 +70,11 @@ private void init() {
}

private void initConfig() {
Config updaterConfig = new Config(new File(Main.getDirectoryPath() + "libs/zyneon/updater.json"));
if(updaterConfig.getString("updater.settings.updateChannel")!=null) {
updateChannel = updaterConfig.getString("updater.settings.updateChannel");
}

config = new Config(new File(Main.getDirectoryPath() + "config.json"));
config.checkEntry("settings.starttab","start");
config.checkEntry("settings.language","auto");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private void syncSettings(String type) {
if (Application.getStartURL().toLowerCase().contains("instances.html")) {
tab = "instances";
}
frame.executeJavaScript("syncGeneral('" + tab + "');");
frame.executeJavaScript("syncGeneral('" + tab + "','"+Application.updateChannel+"');");
}
case "global" ->
frame.executeJavaScript("syncGlobal('" + Application.config.getString("settings.memory.default").replace(".0", "") + " MB','" + Application.getInstancePath() + "','"+Application.logOutput+"')");
Expand All @@ -78,7 +78,7 @@ private void syncSettings(String type) {
}
frame.executeJavaScript("logout();");
}
case "version" -> frame.executeJavaScript("syncApp('" + Application.version + "');");
case "version" -> frame.executeJavaScript("syncApp('"+Application.updateChannel+" ▪ "+Application.version+"');");
}
}

Expand All @@ -90,6 +90,9 @@ public void resolveRequest(String request) {
clipboard.setContents(uuid, uuid);
} else if (request.startsWith("button.notification.remove.")) {
frame.removeNotification(request.replace("button.notification.remove.",""));
} else if (request.startsWith("button.updateChannel.")) {
Application.updateChannel = request.replace("button.updateChannel.","");
new Config(Main.getDirectoryPath()+"libs/zyneon/updater.json").set("updater.settings.updateChannel",Application.updateChannel);
} else if (request.equals("button.online")) {
frame.getBrowser().loadURL(Application.getOnlineStartURL());
} else if(request.equals("sync.notifications")) {
Expand Down
Binary file modified application-main/src/main/resources/ui.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,20 @@ h3 a.button {
border-radius: 0.5rem 0 0 0.5rem;
}

#channel {
background: var(--background4);
color: var(--color);
border: none;
border-radius: 0.5rem;
padding: 0.3rem;
width: fit-content;
font-size: 1.1rem;
}

#updater-settings {
display: none;
}

h3 a.text,h3 a.text-link {
position: absolute !important;
left: 17rem !important;
Expand Down
9 changes: 8 additions & 1 deletion application-ui/content/assets/zyneon/js/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function syncApp(ver) {
document.getElementById("startTitle").style.display = "inherit";
}

function syncGeneral(start) {
function syncGeneral(start,channel) {
const news = document.getElementById("general-tab-start");
const instances = document.getElementById("general-tab-instances");
if(start==="start") {
Expand All @@ -144,6 +144,13 @@ function syncGeneral(start) {
}
document.getElementById("settings_general").style.display = "inherit";
document.getElementById("title_general").innerText = "Settings > General";

if(channel===undefined) {
channel = "stable";
}

document.getElementById("channel").value = channel;
document.getElementById("updater-settings").style.display = "inherit";
}

function syncGlobal(memory,instance_path,log) {
Expand Down
16 changes: 16 additions & 0 deletions application-ui/content/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,22 @@ <h3 id="startTitle">
<a class="button" id="general-tab-start" onclick="callJavaMethod('button.starttab.start');">Start</a>
<a class="button" id="general-tab-instances" onclick="callJavaMethod('button.starttab.instances');">Instances</a>
</h3>
<br>
<div id="updater-settings">
<h3 class="background"><span class="highlight">Updater</span></h3>
<h3>
Update channel:
<label>
<select id="channel" onchange="callJavaMethod('button.updateChannel.'+document.getElementById('channel').value);">
<option value="stable">Stable (recommended)</option>
<option value="experimental">Experimental (could be unstable)</option>
<option disabled></option>
<option value="shervann">Shervann (unstable rewrite)</option>
</select>
</label>
</h3>
<br>
</div>
<h3 class="background"><span class="highlight">Appearance</span></h3>
<h3>Theme:
<a class="button" id="appearance-theme-light" onclick="setTheme('default.light'); link('settings.html');">Light</a>
Expand Down

0 comments on commit 82fe18c

Please sign in to comment.