Added checkbox for autoconnection when local

This commit is contained in:
Davide Passoni
2025-03-07 14:45:01 +01:00
parent 16e77087f5
commit 42cfb36c04
6 changed files with 38 additions and 2 deletions

View File

@@ -149,6 +149,7 @@ class DCSInstance {
gameMasterPasswordEdited = false;
blueCommanderPasswordEdited = false;
redCommanderPasswordEdited = false;
autoconnectWhenLocal = false;
constructor(folder) {
this.folder = folder;
@@ -184,6 +185,7 @@ class DCSInstance {
this.backendPort = config["backend"]["port"];
this.backendAddress = config["backend"]["address"];
this.gameMasterPasswordHash = config["authentication"]["gameMasterPassword"];
this.autoconnectWhenLocal = config["frontend"]["autoconnectWhenLocal"];
this.gameMasterPasswordEdited = false;
this.blueCommanderPasswordEdited = false;

View File

@@ -161,6 +161,7 @@ async function applyConfiguration(folder, instance) {
/* Apply the configuration */
config["frontend"]["port"] = instance.frontendPort;
config["frontend"]["autoconnectWhenLocal"] = instance.autoconnectWhenLocal;
config["backend"]["port"] = instance.backendPort;
config["backend"]["address"] = instance.backendAddress;

View File

@@ -332,8 +332,10 @@ class Manager {
async onInstallTypeClicked(type) {
this.typePage.getElement().querySelector(`.singleplayer`).classList.toggle("selected", type === 'singleplayer');
this.typePage.getElement().querySelector(`.multiplayer`).classList.toggle("selected", type === 'multiplayer');
if (this.getActiveInstance())
if (this.getActiveInstance()) {
this.getActiveInstance().installationType = type;
this.getActiveInstance().autoconnectWhenLocal = type === 'singleplayer';
}
else {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`);
}
@@ -399,6 +401,7 @@ class Manager {
this.activePage.hide();
this.connectionsPage.show();
(this.getMode() === 'basic' ? this.connectionsPage : this.expertSettingsPage).getElement().querySelector(".backend-address .checkbox").classList.toggle("checked", this.getActiveInstance().backendAddress === '*')
(this.getMode() === 'basic' ? this.passwordsPage : this.expertSettingsPage).getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal)
}
} else {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`)
@@ -547,6 +550,19 @@ class Manager {
}
}
async onEnableAutoconnectClicked() {
if (this.getActiveInstance()) {
if (this.getActiveInstance().autoconnectWhenLocal) {
this.getActiveInstance().autoconnectWhenLocal = false;
} else {
this.getActiveInstance().autoconnectWhenLocal = true;
}
this.expertSettingsPage.getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal)
} else {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`)
}
}
/* When the "Return to manager" button is pressed */
async onReturnClicked() {
await this.reload();