Skip to content

Commit

Permalink
move modals to seperate folder, update run scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
SonnyX committed Jan 3, 2022
1 parent b79ae14 commit cea6313
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 67 deletions.
2 changes: 1 addition & 1 deletion compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ cd backend
cross +nightly update
cross +nightly build --release --target=i686-pc-windows-gnu
cd ..
echo F|xcopy /Y backend\target\i686-pc-windows-gnu\release\RenegadeX-Launcher.exe RenegadeX-Launcher.exe
echo F|xcopy /Y backend\target\i686-pc-windows-gnu\release\renegade-x-launcher.exe RenegadeX-Launcher.exe
pause
12 changes: 6 additions & 6 deletions dom/app.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { News } from "./news.mjs";
import { RenegadeXDashboard } from "./renegadex-dashboard.mjs";
import { SettingsModal } from "./settings-modal.mjs";
import { ConfirmationModal } from "./confirmation-modal.mjs";
import { ProgressModal } from "./progress-modal.mjs";
import { SettingsModal } from "./modals/settings-modal.mjs";
import { ConfirmationModal } from "./modals/confirmation-modal.mjs";
import { ProgressModal } from "./modals/progress-modal.mjs";
import { Progress } from "./progress.mjs";
import { CallbackService } from "./callback-service.mjs";
import { InputModal } from "./input-modal.mjs";
import { InputModal } from "./modals/input-modal.mjs";
import * as debug from "@debug";
import { LauncherProgressModal } from "./launcher-progress-modal.mjs";
import { LauncherProgressModal } from "./modals/launcher-progress-modal.mjs";

globalThis.callback_service = new CallbackService();

Expand Down Expand Up @@ -118,7 +118,7 @@ class App extends Element {
overlay.style["visibility"] = "visible";
globalThis.document.$("div.menuEntries").state.disabled = true;
};
Window.this.xcall("start_download", globalThis.progress.callback, globalThis.success_callback, globalThis.failure_callback)
Window.this.xcall("start_download", globalThis.progress.callback, globalThis.progress.success_callback, globalThis.progress.failure_callback)
console.log("Oh no, he wants to update!");
}

Expand Down
8 changes: 4 additions & 4 deletions dom/footer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ export class Footer extends Element {
}

componentDidMount() {
if (globalThis.progress.data != undefined) {
this.process_progress(globalThis.progress.data);
if (globalThis.progress != undefined) {
this.callback(globalThis.progress);
}
globalThis.callback_service.subscribe("progress", this, this.callback);
}

callback(progress) {
this.componentUpdate({
progress: Object.create({}, progress),
progress: Object.assign({}, progress),
});
}

Expand All @@ -62,6 +62,6 @@ export class Footer extends Element {
}

["on click at button#update"](evt, target) {
Window.this.xcall("start_download", globalThis.progress.callback, globalThis.progress.on_done, globalThis.progress.on_error);
Window.this.xcall("start_download", globalThis.progress.callback, globalThis.progress.success_callback, globalThis.progress.failure_callback);
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 4 additions & 33 deletions dom/progress-modal.mjs → dom/modals/progress-modal.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ export class ProgressModal extends Element

componentDidMount() {
if (globalThis.progress.data != undefined) {
this.callback(globalThis.progress.data);
this.callback(globalThis.progress);
}
globalThis.callback_service.subscribe("progress", this, this.callback);
}

callback(progress) {
callback(progress_service) {
var progress = progress_service.data;

var download_progress = (progress["download"][1] != 0) ? progress["download"][0] * 100 / progress["download"][1] : 0.0;

Expand All @@ -83,36 +84,6 @@ export class ProgressModal extends Element
globalThis.callback_service.unsubscribe("progress", this, this.callback);
}

progress_callback(progress) {
var download_progress = (progress["download"][1] != 0) ? progress["download"][0] * 100 / progress["download"][1] : 0.0;

if (progress["download"][1] != 0 && progress["hash"][1] == 0) {
var processed_instructions = 100;
} else {
var processed_instructions = (progress["hash"][1] != 0) ? progress["hash"][0] * 100 / progress["hash"][1] : 0;
}

document.$("div#progress").componentUpdate({
current_state: progress["action"],
hash_progress: processed_instructions,
hash_progress_done: progress["hash"][0],
hash_progress_total: progress["hash"][1],
download_progress: printf("%.1f", download_progress),
download_speed: progress["download_speed"],
patch_progress: (progress["patch"][1] != 0) ? progress["patch"][0] * 100 / progress["patch"][1] : 0,
patch_progress_done: progress["patch"][0],
patch_progress_total: progress["patch"][1]
});
}

failure_callback(error) {
document.$("div#progress").componentUpdate({current_state: error});
}

success_callback() {
document.$("div#progress").componentUpdate({current_state: "Done"});
}

["on click at button#left"](evt, input) {
console.log("cancelling download");
Window.this.xcall("cancel_patcher");
Expand All @@ -121,7 +92,7 @@ export class ProgressModal extends Element
["on click at button#right"](evt, input) {
if (!this.in_progress) {
console.log("starting download");
Window.this.xcall("start_download", globalThis.progress.callback, this.success_callback, this.failure_callback);
Window.this.xcall("start_download", globalThis.progress.callback, globalThis.progress.success_callback, globalThis.progress.failure_callback);
this.in_progress = true;
evt.target.content(<p>Pause</p>);
} else if (this.paused) {
Expand Down
File renamed without changes.
37 changes: 18 additions & 19 deletions dom/progress.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,35 @@ export class Progress extends Object {
super(props);
}
failure_callback() {

globalThis.progress.is_in_progress = false;
globalThis.callback_service.publish("progress", globalThis.progress);
}

success_callback() {

globalThis.progress.is_in_progress = false;
globalThis.callback_service.publish("progress", globalThis.progress);
}

callback(progress) {
globalThis.progress.data = progress;
process_progress(progress);
globalThis.progress.process_progress(progress);
globalThis.callback_service.publish("progress", globalThis.progress);
}

process_progress(progress) {
if(Object.keys(progress).length == 5) {
var download_progress = (progress["download"][1] != 0) ? progress["download"][0] * 100 / progress["download"][1] : 0.0;

if (progress["download"][1] != 0 && progress["hash"][1] == 0) {
var processed_instructions = 100;
} else {
var processed_instructions = (progress["hash"][1] != 0) ? progress["hash"][0] * 100 / progress["hash"][1] : 0;
}
var patch_progress = (progress["patch"][1] != 0) ? progress["patch"][0] * 100 / progress["patch"][1] : 0;
var current_state = progress["action"];
var total_progress = (processed_instructions + download_progress + patch_progress) / 3;

this.componentUpdate({
current_action: current_state,
progress_percentage: total_progress
});
var download_progress = (progress["download"][1] != 0) ? progress["download"][0] * 100 / progress["download"][1] : 0.0;

if (progress["download"][1] != 0 && progress["hash"][1] == 0) {
var processed_instructions = 100;
} else {
var processed_instructions = (progress["hash"][1] != 0) ? progress["hash"][0] * 100 / progress["hash"][1] : 0;
}
var patch_progress = (progress["patch"][1] != 0) ? progress["patch"][0] * 100 / progress["patch"][1] : 0;

this.is_in_progress = true;
this.current_action = progress["action"];
this.total_progress_done = (processed_instructions + download_progress + patch_progress) / 3;
}
}
}
}
2 changes: 1 addition & 1 deletion package-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ cd installer && \
cross +nightly update && \
cross +nightly build --target=i686-pc-windows-gnu --release && \
cd .. && \
cp ./installer/target/i686-pc-windows-gnu/release/Launcher-Installer.exe "./Launcher-Installer.exe"
cp ./installer/target/i686-pc-windows-gnu/release/launcher-installer.exe "./Launcher-Installer.exe"
6 changes: 3 additions & 3 deletions package-windows.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh
cd backend && \
cross +nightly update && \
cross +nightly build --target=i686-pc-windows-gnu --release && \
cross update && \
cross build --target=i686-pc-windows-gnu --release && \
cd ..
cp ./backend/target/i686-pc-windows-gnu/release/RenegadeX-Launcher.exe "./Renegade X Launcher.exe" && \
cp ./backend/target/i686-pc-windows-gnu/release/renegade-x-launcher.exe "./Renegade X Launcher.exe" && \
(rm RenX-Launcher.zip || true) && \
zip -j9 RenX-Launcher "Renegade X Launcher.exe" "RenegadeX-folder-permissions.exe" "sciter.dll" "SelfUpdateExecutor.exe" && \
zip -9 RenX-Launcher -r "dom"

0 comments on commit cea6313

Please sign in to comment.