fix: Fixed manager not respecting autoconnectwhentrue and srsport settings

This commit is contained in:
Davide Passoni 2025-03-26 11:40:02 +01:00
parent 3d61b7e1a7
commit 49990e01ee
8 changed files with 102 additions and 62 deletions

View File

@ -19,13 +19,17 @@ export function OlUnitListEntry(props: {
if (["aircraft", "helicopter"].includes(props.blueprint.category)) {
let roles = props.blueprint.loadouts?.flatMap((loadout) => loadout.roles).filter((role) => role !== "No task");
if (roles !== undefined) {
let uniqueRoles = roles?.reduce((acc, current) => {if (!acc.includes(current)) {acc.push(current)} return acc}, [] as string[])
let uniqueRoles = roles?.reduce((acc, current) => {
if (!acc.includes(current)) {
acc.push(current);
}
return acc;
}, [] as string[]);
let mainRole = mode(roles);
pillString = uniqueRoles.length > 6 ? "Multirole" : mainRole;
}
} else {
if (props.blueprint.category)
pillString = props.blueprint.type;
if (props.blueprint.category) pillString = props.blueprint.type;
}
}
return (
@ -39,14 +43,15 @@ export function OlUnitListEntry(props: {
>
{props.icon && <FontAwesomeIcon icon={props.icon} className="text-sm"></FontAwesomeIcon>}
{props.silhouette && (
<div className={`
mr-2 flex h-6 w-6 rotate-90 content-center justify-center opacity-50
invert
`}>
<img
src={`./images/units/${props.silhouette}`}
className="my-auto max-h-full max-w-full"
/>
<div
className={`
mr-2 flex h-6 w-6 rotate-90 content-center justify-center opacity-50
invert
`}
>
<img src={`./images/units/${props.silhouette}`} className={`
my-auto max-h-full max-w-full
`} />
</div>
)}
<div className="flex-1 px-2 text-left font-normal">{props.blueprint.label}</div>

View File

@ -81,18 +81,18 @@ export function OlUnitSummary(props: { blueprint: UnitBlueprint; coalition: Coal
</p>
</div>
<div className="flex flex-row gap-1 px-2">
{props.blueprint.abilities?.split(" ").map((tag) => {
return (
{props.blueprint.abilities?.split(" ").map((ability) => {
return <>{ ability.replaceAll(" ", "") !== "" &&
<div
key={tag}
key={ability}
className={`
rounded-full bg-olympus-800 px-2 py-0.5 text-xs font-bold
dark:text-olympus-50
`}
>
{tag}
{ability}
</div>
);
}</>
})}
<div

View File

@ -66,6 +66,7 @@ export function SpawnContextMenu(props: {}) {
const [blueprints, setBlueprints] = useState([] as UnitBlueprint[]);
const [roles, setRoles] = useState({ aircraft: [] as string[], helicopter: [] as string[] });
const [types, setTypes] = useState({ groundunit: [] as string[], navyunit: [] as string[] });
const [tags, setTags] = useState({ aircraft: [] as string[], helicopter: [] as string[], groundunit: [] as string[], navyunit: [] as string[] });
const [commandModeOptions, setCommandModeOptions] = useState(COMMAND_MODE_OPTIONS_DEFAULTS);
const [showCost, setShowCost] = useState(false);
const [spawnCoalition, setSpawnCoalition] = useState("blue" as Coalition);
@ -102,6 +103,25 @@ export function SpawnContextMenu(props: {}) {
.getDatabase()
.getTypes((unit) => unit.category === "navyunit"),
});
setTags({
aircraft: getApp()
?.getUnitsManager()
.getDatabase()
.getTags((unit) => unit.category === "aircraft"),
helicopter: getApp()
?.getUnitsManager()
.getDatabase()
.getTags((unit) => unit.category === "helicopter"),
groundunit: getApp()
?.getUnitsManager()
.getDatabase()
.getTags((unit) => unit.category === "groundunit"),
navyunit: getApp()
?.getUnitsManager()
.getDatabase()
.getTags((unit) => unit.category === "navyunit"),
});
});
CommandModeOptionsChangedEvent.on((commandModeOptions) => {
@ -314,15 +334,9 @@ export function SpawnContextMenu(props: {}) {
/>
);
})}
{blueprints?.length === 0 && (
<span
className={`
{blueprints?.length === 0 && <span className={`
text-gray-200
`}
>
No aircraft available
</span>
)}
`}>No aircraft available</span>}
</div>
</>
)}
@ -370,15 +384,9 @@ export function SpawnContextMenu(props: {}) {
/>
);
})}
{blueprints?.length === 0 && (
<span
className={`
{blueprints?.length === 0 && <span className={`
text-gray-200
`}
>
No helicopter available
</span>
)}
`}>No helicopter available</span>}
</div>
</>
)}
@ -429,15 +437,9 @@ export function SpawnContextMenu(props: {}) {
/>
);
})}
{blueprints?.length === 0 && (
<span
className={`
{blueprints?.length === 0 && <span className={`
text-gray-200
`}
>
No air defence unit available
</span>
)}
`}>No air defence unit available</span>}
</div>
</>
)}
@ -467,6 +469,29 @@ export function SpawnContextMenu(props: {}) {
);
})}
</div>
<div className="flex flex-wrap gap-1">
{tags.groundunit
.sort()
.map((type) => {
return (
<div
key={type}
data-selected={selectedType === type}
className={`
cursor-pointer rounded-full bg-olympus-900
px-2 py-0.5 text-xs font-bold text-olympus-50
data-[selected='true']:bg-blue-500
data-[selected='true']:text-gray-200
`}
onClick={() => {
selectedType === type ? setSelectedType(null) : setSelectedType(type);
}}
>
{type}
</div>
);
})}
</div>
<div
className={`
flex max-h-[350px] flex-col gap-1 overflow-y-scroll
@ -502,15 +527,9 @@ export function SpawnContextMenu(props: {}) {
/>
);
})}
{blueprints?.length === 0 && (
<span
className={`
{blueprints?.length === 0 && <span className={`
text-gray-200
`}
>
No ground unit available
</span>
)}
`}>No ground unit available</span>}
</div>
</>
)}
@ -558,15 +577,9 @@ export function SpawnContextMenu(props: {}) {
/>
);
})}
{blueprints?.length === 0 && (
<span
className={`
{blueprints?.length === 0 && <span className={`
text-gray-200
`}
>
No navy unit available
</span>
)}
`}>No navy unit available</span>}
</div>
</>
)}

View File

@ -110,6 +110,22 @@ export class UnitDatabase {
return types;
}
/* Returns a list of all tags in a database */
getTags(unitFilter?: (unit: UnitBlueprint) => boolean) {
var filteredBlueprints = this.getBlueprints();
var tags: string[] = [];
for (let unit of filteredBlueprints) {
if (typeof unitFilter === "function" && !unitFilter(unit)) continue;
let unitTags = unit.tags?.split(" ");
if (unitTags) {
for (let tag of unitTags) {
if (tag.replaceAll(" ", "") !== "" && !tags.includes(tag)) tags.push(tag);
}
}
}
return tags;
}
/* Returns a list of all possible eras in a database */
getEras(unitFilter?: (unit: UnitBlueprint) => boolean) {
var filteredBlueprints = this.getBlueprints();

View File

@ -53,7 +53,7 @@
</div>
<div class="input-group autoconnect">
<span onclick="signal('onEnableAutoconnectClicked')">
<div class="checkbox <%= activeInstance['installationType'] === 'multiplayer'? '': 'checked' %>"></div> Autoconnect when local
<div class="checkbox <%= activeInstance['autoconnectWhenLocal'] ? 'checked': '' %>"></div> Autoconnect when local
<img src="./icons/circle-info-solid.svg"
title="Autoconnect as Game Master when running Olympus on the same computer as DCS.">
</span>

View File

@ -192,7 +192,7 @@ class DCSInstance {
/* Read the new configurations added in v2.0.0 */
if (config["frontend"]["autoconnectWhenLocal"] !== undefined)
this.autoconnectWhenLocal = config["frontend"]["autoconnectWhenLocal"];
if (config["frontend"]["audio"] !== undefined && config["frontend"]["audio"]["SRSPort"] !== undefined)
if (config["audio"] !== undefined && config["audio"]["SRSPort"] !== undefined)
this.SRSPort = config["audio"]["SRSPort"];
this.gameMasterPasswordEdited = false;

View File

@ -175,8 +175,10 @@ class Manager {
/* Reset default radio buttons */
this.typePage.options.onShow = () => {
if (this.getActiveInstance())
if (this.getActiveInstance()) {
this.getActiveInstance().installationType = 'singleplayer';
this.getActiveInstance().autoconnectWhenLocal = true;
}
else {
showErrorPopup(`<div class='main-message'>A critical error occurred! </div><div class='sub-message'> Check ${this.getLogLocation()} for more info. </div>`);
}
@ -335,7 +337,7 @@ class Manager {
this.typePage.getElement().querySelector(`.multiplayer`).classList.toggle("selected", type === 'multiplayer');
if (this.getActiveInstance()) {
this.getActiveInstance().installationType = type;
this.getActiveInstance().autoconnectWhenLocal = type === 'singleplayer';
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>`);
@ -570,7 +572,11 @@ class Manager {
} else {
this.getActiveInstance().autoconnectWhenLocal = true;
}
this.expertSettingsPage.getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal)
if (this.getMode() === 'basic') {
this.passwordsPage.getElement().querySelector(".autoconnect .checkbox").classList.toggle("checked", this.getActiveInstance().autoconnectWhenLocal);
} else {
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>`)
}

View File

@ -13,7 +13,7 @@
"gameMasterPassword": "",
"blueCommanderPassword": "",
"redCommanderPassword": "",
"admin": ""
"adminPassword": ""
},
"_comment6": "These are the settings for the frontend server, i.e. the server which hosts the Olympus GUI web interface.",