mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Bugfixing on manager
This commit is contained in:
@@ -41,15 +41,18 @@ class DCSInstance {
|
||||
if (result[shellFoldersKey] !== undefined && result[shellFoldersKey]["exists"] && result[shellFoldersKey]['values'][saveGamesKey] !== undefined && result[shellFoldersKey]['values'][saveGamesKey]['value'] !== undefined) {
|
||||
/* Read all the folders in Saved Games */
|
||||
const searchpath = result[shellFoldersKey]['values'][saveGamesKey]['value'];
|
||||
const folders = fs.readdirSync(searchpath);
|
||||
var folders = fs.readdirSync(searchpath).map((folder) => {return path.join(searchpath, folder);});
|
||||
console.log(folders);
|
||||
var instances = [];
|
||||
folders = folders.concat(getManager().options.additionalDCSInstances);
|
||||
console.log(folders);
|
||||
|
||||
/* A DCS Instance is created if either the appsettings.lua or serversettings.lua file is detected */
|
||||
for (let i = 0; i < folders.length; i++) {
|
||||
const folder = folders[i];
|
||||
if (fs.existsSync(path.join(searchpath, folder, "Config", "appsettings.lua")) ||fs.existsSync(path.join(searchpath, folder, "Config", "serversettings.lua"))) {
|
||||
if (fs.existsSync(path.join(folder, "Config", "appsettings.lua")) || fs.existsSync(path.join(folder, "Config", "serversettings.lua")) || getManager().options.additionalDCSInstances.includes(folder)) {
|
||||
logger.log(`Found instance in ${folder}, checking for Olympus`)
|
||||
var newInstance = new DCSInstance(path.join(searchpath, folder));
|
||||
var newInstance = new DCSInstance(path.join(folder));
|
||||
|
||||
/* Check if Olympus is already installed */
|
||||
getManager().setLoadingProgress(`Found instance in ${folder}, checking for Olympus...`, (i + 1) / folders.length * 100);
|
||||
@@ -471,11 +474,11 @@ class DCSInstance {
|
||||
logger.log(`Editing completed successfully`);
|
||||
hidePopup();
|
||||
|
||||
this.options.mode === "basic"? getManager().menuPage.show(): getManager().instancesPage.show();
|
||||
getManager().options.mode === "basic"? getManager().menuPage.show(): getManager().instancesPage.show();
|
||||
} catch (err) {
|
||||
logger.log(`An error occurred during editing: ${err}`);
|
||||
hidePopup();
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
showErrorPopup(`A critical error occurred, check ${getManager().options.logLocation} for more info.`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -167,9 +167,10 @@ class Manager {
|
||||
*/
|
||||
createOptionsFile(mode) {
|
||||
try {
|
||||
fs.writeFileSync("options.json", JSON.stringify({ mode: mode }));
|
||||
fs.writeFileSync("options.json", JSON.stringify({ mode: mode, additionalDCSInstances: [] }, null, 2));
|
||||
location.reload();
|
||||
} catch (e) {
|
||||
} catch (err) {
|
||||
logger.log(err);
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
}
|
||||
}
|
||||
@@ -182,7 +183,7 @@ class Manager {
|
||||
/* Change the mode in the options.json and reload the page */
|
||||
var options = JSON.parse(fs.readFileSync("options.json"));
|
||||
options.mode = newMode;
|
||||
fs.writeFileSync("options.json", JSON.stringify(options));
|
||||
fs.writeFileSync("options.json", JSON.stringify(options, null, 2));
|
||||
location.reload();
|
||||
}
|
||||
|
||||
@@ -240,13 +241,7 @@ class Manager {
|
||||
onEditMenuClicked() {
|
||||
this.activePage.hide()
|
||||
this.options.install = false;
|
||||
|
||||
if (this.options.singleInstance) {
|
||||
this.options.activeInstance = this.options.instances[0];
|
||||
this.connectionsTypePage.show();
|
||||
} else {
|
||||
this.settingsPage.show();
|
||||
}
|
||||
this.settingsPage.show();
|
||||
}
|
||||
|
||||
/** When a folder is selected, find what instance was clicked to set as active
|
||||
@@ -271,8 +266,9 @@ class Manager {
|
||||
this.typePage.getElement().querySelector(`.multiplayer`).classList.toggle("selected", type === 'multiplayer');
|
||||
if (this.options.activeInstance)
|
||||
this.options.activeInstance.installationType = type;
|
||||
else
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
else {
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
|
||||
}
|
||||
}
|
||||
|
||||
/* When the connections type is selected */
|
||||
@@ -281,8 +277,9 @@ class Manager {
|
||||
this.connectionsTypePage.getElement().querySelector(`.manual`).classList.toggle("selected", type === 'manual');
|
||||
if (this.options.activeInstance)
|
||||
this.options.activeInstance.connectionsType = type;
|
||||
else
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
else {
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
|
||||
}
|
||||
}
|
||||
|
||||
/* When the next button of a wizard page is clicked */
|
||||
@@ -340,7 +337,7 @@ class Manager {
|
||||
if (this.options.activeInstance) {
|
||||
if (this.options.activeInstance.installed && !this.options.activeInstance.arePasswordsEdited()) {
|
||||
this.activePage.hide();
|
||||
this.options.install? this.options.activeInstance.install(): this.options.activeInstance.edit();
|
||||
this.options.install ? this.options.activeInstance.install() : this.options.activeInstance.edit();
|
||||
}
|
||||
else {
|
||||
if (!this.options.activeInstance.arePasswordsSet()) {
|
||||
@@ -349,7 +346,7 @@ class Manager {
|
||||
showErrorPopup('Please, set different passwords for the Game Master, Blue Commander, and Red Commander roles!');
|
||||
} else {
|
||||
this.activePage.hide();
|
||||
this.options.install? this.options.activeInstance.install(): this.options.activeInstance.edit();
|
||||
this.options.install ? this.options.activeInstance.install() : this.options.activeInstance.edit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -377,8 +374,9 @@ class Manager {
|
||||
if (!this.options.activeInstance.redCommanderPasswordEdited)
|
||||
this.passwordsPage.getElement().querySelector(".red-commander input").value = "";
|
||||
}
|
||||
else
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
else {
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
|
||||
}
|
||||
}
|
||||
|
||||
onBlueCommanderPasswordChanged(value) {
|
||||
@@ -389,8 +387,9 @@ class Manager {
|
||||
if (!this.options.activeInstance.redCommanderPasswordEdited)
|
||||
this.passwordsPage.getElement().querySelector(".red-commander input").value = "";
|
||||
}
|
||||
else
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
else {
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
|
||||
}
|
||||
}
|
||||
|
||||
onRedCommanderPasswordChanged(value) {
|
||||
@@ -401,8 +400,9 @@ class Manager {
|
||||
if (!this.options.activeInstance.blueCommanderPasswordEdited)
|
||||
this.passwordsPage.getElement().querySelector(".blue-commander input").value = "";
|
||||
}
|
||||
else
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`)
|
||||
else {
|
||||
showErrorPopup(`A critical error occurred, check ${this.options.logLocation} for more info.`);
|
||||
}
|
||||
}
|
||||
|
||||
/* When the client port input value is changed */
|
||||
@@ -472,7 +472,7 @@ class Manager {
|
||||
this.options.activeInstance = instance;
|
||||
this.options.install = false;
|
||||
this.activePage.hide();
|
||||
this.connectionsTypePage.show();
|
||||
this.typePage.show();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -494,6 +494,14 @@ class Manager {
|
||||
await instance.uninstall();
|
||||
}
|
||||
|
||||
onLinkClicked(url) {
|
||||
exec(`start ${url}`);
|
||||
}
|
||||
|
||||
onTextFileClicked(path) {
|
||||
exec(`notepad "${path}"`);
|
||||
}
|
||||
|
||||
async getClickedInstance(name) {
|
||||
var instances = await DCSInstance.getInstances()
|
||||
return instances.find((instance) => { return instance.name === name; });
|
||||
@@ -556,7 +564,7 @@ class Manager {
|
||||
instanceDiv.querySelector(".backend.online").classList.toggle("hide", !instance.backendOnline);
|
||||
instanceDiv.querySelector(".backend.offline").classList.toggle("hide", instance.backendOnline);
|
||||
|
||||
if (this.backendOnline) {
|
||||
if (instance.backendOnline) {
|
||||
instanceDiv.querySelector(".fps .data").innerText = instance.fps;
|
||||
instanceDiv.querySelector(".load .data").innerText = instance.load;
|
||||
}
|
||||
@@ -567,7 +575,7 @@ class Manager {
|
||||
instanceDiv.querySelector(".button.open-browser").classList.toggle("hide", !instance.webserverOnline);
|
||||
instanceDiv.querySelector(".button.stop").classList.toggle("hide", !instance.webserverOnline);
|
||||
|
||||
if (this.webserverOnline)
|
||||
if (instance.webserverOnline)
|
||||
instanceDiv.querySelector(".button.start").classList.remove("loading");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,9 @@ async function updateOlympusBeta() {
|
||||
var artifact = artifacts.find((artifact) => { return artifact.name = "development_build_not_a_release" });
|
||||
|
||||
const date1 = new Date(artifact.updated_at);
|
||||
const date2 = fs.statSync(path.join("package.json")).birthtime;
|
||||
const date2 = fs.statSync(".").mtime;
|
||||
if (date1 > date2) {
|
||||
showConfirmPopup(`<span>Latest beta artifact has a timestamp of <i style="color: orange">${artifact.updated_at}</i>, while your installation was created on <i style="color: orange">${date2.toISOString()}</i>. Do you want to update to the newest beta version?</span>`, () => {
|
||||
showConfirmPopup(`<span style="font-size: 18px; max-width: 100%; margin-bottom: 15px;">Looks like you are running a beta version of Olympus!</span><span>Latest beta artifact timestamp of: <i style="color: orange">${date1.toLocaleString()}</i> <br> Your installation timestamp: <i style="color: orange">${date2.toLocaleString()}</i> <br><br> Do you want to update to the newest beta version?</span>`, () => {
|
||||
/* Run the browser and download the artifact */ //TODO: try and directly download the file from code rather than using the browser
|
||||
exec(`start https://github.com/Pax1601/DCSOlympus/actions/runs/${artifact.workflow_run.id}/artifacts/${artifact.id}`)
|
||||
showConfirmPopup('A browser window was opened to download the beta artifact. Please wait for the download to complete, then press "Accept" and select the downloaded beta artifact.',
|
||||
@@ -262,17 +262,6 @@ contextBridge.exposeInMainWorld(
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
document.getElementById("loader").classList.remove("hide");
|
||||
await getManager().start();
|
||||
|
||||
/* Create event listeners for the hyperlinks */
|
||||
var links = document.querySelectorAll(".link");
|
||||
for (let i = 0; i < links.length; i++) {
|
||||
if (links[i].dataset.link) {
|
||||
links[i].addEventListener("click", (e) => {
|
||||
if (e.target.dataset.link)
|
||||
exec("start " + e.target.dataset.link);
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
window.addEventListener('resize', () => {
|
||||
|
||||
Reference in New Issue
Block a user