Merge branch 'main' into 747-improve-configurator-for-automatic-saved-games-folder-detection

This commit is contained in:
Pax1601 2023-12-20 16:58:24 +01:00 committed by GitHub
commit 0ac632cc9b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50487 additions and 46162 deletions

View File

@ -1,7 +1,10 @@
# ci.yml file for GitHub Actions
name: Documentation
on: [push]
on:
push:
branches:
- main
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:

View File

@ -12,10 +12,10 @@ var app = express();
app.use(logger('dev'));
const aircraftDatabase = require('./public/databases/units/aircraftDatabase.json');
const helicopterDatabase = require('./public/databases/units/helicopterDatabase.json');
const groundUnitDatabase = require('./public/databases/units/groundUnitDatabase.json');
const navyUnitDatabase = require('./public/databases/units/navyUnitDatabase.json');
const aircraftDatabase = require('./public/databases/units/aircraftdatabase.json');
const helicopterDatabase = require('./public/databases/units/helicopterdatabase.json');
const groundUnitDatabase = require('./public/databases/units/groundunitdatabase.json');
const navyUnitDatabase = require('./public/databases/units/navyunitdatabase.json');
const DEMO_UNIT_DATA = {}

File diff suppressed because it is too large Load Diff

View File

@ -985,7 +985,7 @@ nav.ol-panel> :last-child {
#login-status[data-status="failed"]::before {
color: var(--primary-red);
content: "Incorrect username/password!";
content: "Incorrect password!";
}
@keyframes blinker {

View File

@ -104,6 +104,14 @@ export function reciprocalHeading(heading: number): number {
return heading > 180? heading - 180: heading + 180;
}
/**
* Prepend numbers to the start of a string
*
* @param num <number> subject number
* @param places <number> places to pad
* @param decimal <boolean> whether this is a decimal number or not
*
* */
export const zeroAppend = function (num: number, places: number, decimal: boolean = false) {
var string = decimal? num.toFixed(2): String(num);
while (string.length < places) {

View File

@ -1,6 +1,6 @@
import { Marker, LatLng, Polyline, Icon, DivIcon, CircleMarker, Map, Point } from 'leaflet';
import { getApp } from '..';
import { enumToCoalition, enumToEmissioNCountermeasure, enumToROE, enumToReactionToThreat, enumToState, getUnitDatabaseByCategory, mToFt, msToKnots, rad2deg, bearing, deg2rad, ftToM, getGroundElevation, coalitionToEnum, nmToFt, nmToM } from '../other/utils';
import { enumToCoalition, enumToEmissioNCountermeasure, enumToROE, enumToReactionToThreat, enumToState, getUnitDatabaseByCategory, mToFt, msToKnots, rad2deg, bearing, deg2rad, ftToM, getGroundElevation, coalitionToEnum, nmToFt, nmToM, zeroAppend } from '../other/utils';
import { CustomMarker } from '../map/markers/custommarker';
import { SVGInjector } from '@tanem/svg-injector';
import { UnitDatabase } from './databases/unitdatabase';
@ -1184,7 +1184,7 @@ export abstract class Unit extends CustomMarker {
/* Set altitude and speed */
if (element.querySelector(".unit-altitude"))
(<HTMLElement>element.querySelector(".unit-altitude")).innerText = "FL" + String(Math.floor(mToFt(this.#position.alt as number) / 100));
(<HTMLElement>element.querySelector(".unit-altitude")).innerText = "FL" + zeroAppend(Math.floor(mToFt(this.#position.alt as number) / 100), 3);
if (element.querySelector(".unit-speed"))
(<HTMLElement>element.querySelector(".unit-speed")).innerText = String(Math.floor(msToKnots(this.#speed))) + "GS";

View File

@ -1,6 +1,6 @@
import { LatLng, DivIcon, Map } from 'leaflet';
import { getApp } from '..';
import { enumToCoalition, mToFt, msToKnots, rad2deg } from '../other/utils';
import { enumToCoalition, mToFt, msToKnots, rad2deg, zeroAppend } from '../other/utils';
import { CustomMarker } from '../map/markers/custommarker';
import { SVGInjector } from '@tanem/svg-injector';
import { DLINK, DataIndexes, GAME_MASTER, IRST, OPTIC, RADAR, VISUAL } from '../constants/constants';
@ -230,7 +230,7 @@ export class Weapon extends CustomMarker {
/* Set altitude and speed */
if (element.querySelector(".unit-altitude"))
(<HTMLElement>element.querySelector(".unit-altitude")).innerText = "FL" + String(Math.floor(mToFt(this.#position.alt as number) / 100));
(<HTMLElement>element.querySelector(".unit-altitude")).innerText = "FL" + zeroAppend(Math.floor(mToFt(this.#position.alt as number) / 100), 3);
if (element.querySelector(".unit-speed"))
(<HTMLElement>element.querySelector(".unit-speed")).innerText = String(Math.floor(msToKnots(this.#speed))) + "GS";

View File

@ -8,8 +8,8 @@
</div>
<form id="authentication-form">
<div><h5>Name</h5> <input type="text" id="username" name="username" required autocomplete="username" placeholder="Enter name..."></div>
<div><h5>Server password</h5> <input type="password" id="password" name="password" required autocomplete="current-password" placeholder="Enter server password..."></div>
<div><h5>Display Name</h5> <input type="text" id="username" name="username" required autocomplete="username" placeholder="Enter display name..."></div>
<div><h5>Password</h5> <input type="password" id="password" name="password" required autocomplete="current-password" placeholder="Enter game master/commander password..."></div>
<button type="submit" id="connection-button" class="ol-button-apply">Connect</button>
</form>

View File

@ -0,0 +1,69 @@
import os
# save DCS.openbeta\\mods\\aircraft path as variable
path = f"{os.environ['UserProfile']}\\Saved Games\\DCS.openbeta\\Mods\\aircraft"
# write everything to a working file - to be deleted after getting rid of unnecessary trailing commas
with open('working_file.lua', mode='w') as payload_file:
payload_file.write('Olympus.unitPayloads = {\n')
# iterate through everything in mod aircraft path
for f in os.listdir(path):
# modders are inconsistent with the lua filename, so grab that first file in the correct directory
try:
unitpayload_lua_dir = f"{path}\\{f}\\UnitPayloads"
try:
lua_filename = os.listdir(unitpayload_lua_dir)[0]
except IndexError:
pass
unitpayload_lua_path = f"{unitpayload_lua_dir}\\{lua_filename}"
# read the aircraft's payloads and write the relevant material into the working file
with open(unitpayload_lua_path) as payload_lua_file:
lines = payload_lua_file.readlines()
for line in lines:
if line.startswith(' ["name"]'):
ac_type = line.replace(' ["name"] = "', '').replace('",', '').rstrip()
ac_type = f'["{ac_type}"] =' + r' {'
payload_file.write(ac_type + '\n')
elif line.startswith(' ["name"]'):
loadout_name = line.replace(' ["name"] = "', '').replace('",', '').rstrip()
loadout_name = f'["{loadout_name}"] =' + r' {'
payload_file.write(loadout_name + '\n')
elif line.startswith(' ["CLSID"]'):
clsid = line.replace(' ', '').replace(',', '').rstrip()
clsid = r'{' + f'{clsid}' + r'}' + ','
elif line.startswith(' ["num"]'):
pylon = line.replace(' ["num"] = ', '').replace(',', '').rstrip()
pylon = f'[{pylon}] = '
payload_file.write(pylon + clsid + '\n')
elif line.startswith(' },'):
payload_file.write('},\n')
elif line.startswith('}'):
payload_file.write('},\n')
# skip directory if no directory or no file in directory
except FileNotFoundError:
pass
payload_file.write('}')
# parse the working file, get rid of trailing commas when next line starts with a '}'.
with open("working_file.lua") as working_file:
lines = working_file.readlines()
prev_line = ''
with open("payloads.lua", mode="w") as payload_file:
for ind, line in enumerate(lines):
try:
if lines[ind + 1].startswith('}') and line.endswith('},\n'):
new_line = line.replace(',', '')
payload_file.write(f'{new_line}')
else:
payload_file.write(line)
except IndexError:
payload_file.write(line)
# delete the working file
os.remove("working_file.lua")

File diff suppressed because it is too large Load Diff