Skip to content

Commit

Permalink
Improved literal string code style
Browse files Browse the repository at this point in the history
  • Loading branch information
fboes committed Nov 2, 2024
1 parent 9a11bf4 commit e706198
Show file tree
Hide file tree
Showing 16 changed files with 55 additions and 29 deletions.
11 changes: 7 additions & 4 deletions dist/Aerofly/Mission.js
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,9 @@ export class Mission {
}
toString() {
var _a, _b;
const finish = (_b = (_a = this.finish) === null || _a === void 0 ? void 0 : _a.toStringTargetPlane('finish')) !== null && _b !== void 0 ? _b : '';
let string = ` // Exported by Aerofly Missionsgerät
const finish = (_b = (_a = this.finish) === null || _a === void 0 ? void 0 : _a.toStringTargetPlane("finish")) !== null && _b !== void 0 ? _b : "";
let string = `\
// Exported by Aerofly Missionsgerät
<[tmmission_definition][mission][]
<[string8][title][${Quote.tmc(this.title)}]>
<[string8][description][${Quote.tmc(this.description)}]>
Expand All @@ -809,12 +810,14 @@ export class Mission {
<[float64] [destination_dir] [${this.destination_dir}]>
//<[float64] [cruise_altitude] [${this.cruise_altitude}]>
//<[float64] [cruise_speed] [${this.cruise_speed}]>
${this.conditions + finish} <[list_tmmission_checkpoint][checkpoints][]
${this.conditions + finish}\
<[list_tmmission_checkpoint][checkpoints][]
`;
this.checkpoints.forEach((c, i) => {
string += c.toString(i);
});
string += ` >
string += `\
>
>
// -----------------------------------------------------------------------------
`;
Expand Down
14 changes: 9 additions & 5 deletions dist/Aerofly/MissionCheckpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,12 @@ export class MissionCheckpoint {
toString(index) {
let flyOver = "";
if (this.type === MissionCheckpoint.TYPE_WAYPOINT) {
flyOver = ` <[bool][FlyOver][${this.flyOver ? "true" : "false"}]>
`;
flyOver = `\
<[bool][FlyOver][${this.flyOver ? "true" : "false"}]>
`;
}
return ` <[tmmission_checkpoint][element][${index}]
return `\
<[tmmission_checkpoint][element][${index}]
<[string8u][type][${Quote.tmc(this.type)}]>
<[string8u][name][${Quote.tmc(this.name)}]>
<[vector2_float64][lon_lat][${this.lon_lat}]>
Expand All @@ -208,11 +210,13 @@ export class MissionCheckpoint {
<[float64][slope][${this.slope}]> // ${this.slope_deg.toFixed(1)} deg
<[float64][length][${this.length}]>
<[float64][frequency][${this.frequency.toFixed()}]>
${flyOver} >
${flyOver}\
>
`;
}
toStringTargetPlane(name = "finish") {
return ` <[tmmission_target_plane][${name}][]
return `\
<[tmmission_target_plane][${name}][]
<[vector2_float64][lon_lat][${this.lon_lat.lon} ${this.lon_lat.lat}]>
<[float64][direction][${this.direction}]>
>
Expand Down
3 changes: 2 additions & 1 deletion dist/Aerofly/MissionConditions.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,8 @@ export class MissionConditions {
this.turbulence_strength = Math.min(1, this.wind_speed / 80 + this.wind_gusts / 20);
}
toString() {
return ` <[tmmission_conditions][conditions][]
return `\
<[tmmission_conditions][conditions][]
<[tm_time_utc][time][]
<[int32][time_year][${this.time.time_year.toFixed()}]>
<[int32][time_month][${this.time.time_month.toFixed()}]>
Expand Down
6 changes: 4 additions & 2 deletions dist/Aerofly/MissionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export class MissionsList {
this.missions = [];
}
toString() {
return `<[file][][]
return `\
<[file][][]
<[tmmissions_list][][]
<[list_tmmission_definition][missions][]
// -----------------------------------------------------------------------------
${this.missions.join("")} >
${this.missions.join("")}\
>
>
>
`;
Expand Down
3 changes: 2 additions & 1 deletion dist/Cli/Arguments.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ export class Arguments {
return asciify(filename).substring(0, 32);
}
helpText(c) {
return `${c.lightBlue}Usage: nodejs index.js [PARAMETERS...]${c.reset}
return `\
${c.lightBlue}Usage: nodejs index.js [PARAMETERS...]${c.reset}
Convert Aerofly FS 4 main.mcf file into a custom_missions_user.tmc file.
Parameters:
Expand Down
3 changes: 2 additions & 1 deletion dist/Export/Markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ export class Markdown extends Outputtable {
const zoomLevel = this.lonLatArea.getZoomLevel();
const center = this.lonLatArea.center;
const hasFrequencies = m.hasFrequencies;
let markdown = `# ${m.title}
let markdown = `\
# ${m.title}
${m.description}
Expand Down
1 change: 1 addition & 0 deletions dist/Tests/MissionTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class MissionTest extends Test {
this.assertEquals(mission.checkpoints.length, 5);
this.assertEquals(mission.checkpoints[4].name, "KBLI");
this.assertEquals(mission.checkpoints[1].lon_lat.altitude_m, 1676.3999463552018);
//console.log(mission.toString());
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"prettier": "npx prettier --cache --write .",
"prettier-check": "npx prettier --cache --check .",
"serve": "npx http-server ./dist -o -c-1",
"build": "tsc --build"
"build": "npm run prettier && tsc --build"
},
"main": "index.js",
"repository": {
Expand Down
9 changes: 6 additions & 3 deletions src/Aerofly/Mission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,8 @@ export class Mission {

toString(): string {
const finish = this.finish?.toStringTargetPlane("finish") ?? "";
let string = ` // Exported by Aerofly Missionsgerät
let string = `\
// Exported by Aerofly Missionsgerät
<[tmmission_definition][mission][]
<[string8][title][${Quote.tmc(this.title)}]>
<[string8][description][${Quote.tmc(this.description)}]>
Expand All @@ -920,12 +921,14 @@ export class Mission {
<[float64] [destination_dir] [${this.destination_dir}]>
//<[float64] [cruise_altitude] [${this.cruise_altitude}]>
//<[float64] [cruise_speed] [${this.cruise_speed}]>
${this.conditions + finish} <[list_tmmission_checkpoint][checkpoints][]
${this.conditions + finish}\
<[list_tmmission_checkpoint][checkpoints][]
`;
this.checkpoints.forEach((c, i) => {
string += c.toString(i);
});
string += ` >
string += `\
>
>
// -----------------------------------------------------------------------------
`;
Expand Down
14 changes: 9 additions & 5 deletions src/Aerofly/MissionCheckpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,12 @@ export class MissionCheckpoint {
toString(index: number): string {
let flyOver = "";
if (this.type === MissionCheckpoint.TYPE_WAYPOINT) {
flyOver = ` <[bool][FlyOver][${this.flyOver ? "true" : "false"}]>
`;
flyOver = `\
<[bool][FlyOver][${this.flyOver ? "true" : "false"}]>
`;
}
return ` <[tmmission_checkpoint][element][${index}]
return `\
<[tmmission_checkpoint][element][${index}]
<[string8u][type][${Quote.tmc(this.type)}]>
<[string8u][name][${Quote.tmc(this.name)}]>
<[vector2_float64][lon_lat][${this.lon_lat}]>
Expand All @@ -253,12 +255,14 @@ export class MissionCheckpoint {
<[float64][slope][${this.slope}]> // ${this.slope_deg.toFixed(1)} deg
<[float64][length][${this.length}]>
<[float64][frequency][${this.frequency.toFixed()}]>
${flyOver} >
${flyOver}\
>
`;
}

toStringTargetPlane(name: string = "finish"): string {
return ` <[tmmission_target_plane][${name}][]
return `\
<[tmmission_target_plane][${name}][]
<[vector2_float64][lon_lat][${this.lon_lat.lon} ${this.lon_lat.lat}]>
<[float64][direction][${this.direction}]>
>
Expand Down
3 changes: 2 additions & 1 deletion src/Aerofly/MissionConditions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ export class MissionConditions {
}

toString(): string {
return ` <[tmmission_conditions][conditions][]
return `\
<[tmmission_conditions][conditions][]
<[tm_time_utc][time][]
<[int32][time_year][${this.time.time_year.toFixed()}]>
<[int32][time_month][${this.time.time_month.toFixed()}]>
Expand Down
6 changes: 4 additions & 2 deletions src/Aerofly/MissionsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export class MissionsList {
constructor(public title: string) {}

toString(): string {
return `<[file][][]
return `\
<[file][][]
<[tmmissions_list][][]
<[list_tmmission_definition][missions][]
// -----------------------------------------------------------------------------
${this.missions.join("")} >
${this.missions.join("")}\
>
>
>
`;
Expand Down
3 changes: 2 additions & 1 deletion src/Cli/Arguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ export class Arguments {
}

helpText(c: BashColors): string {
return `${c.lightBlue}Usage: nodejs index.js [PARAMETERS...]${c.reset}
return `\
${c.lightBlue}Usage: nodejs index.js [PARAMETERS...]${c.reset}
Convert Aerofly FS 4 main.mcf file into a custom_missions_user.tmc file.
Parameters:
Expand Down
3 changes: 2 additions & 1 deletion src/Export/Markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export class Markdown extends Outputtable {
const zoomLevel = this.lonLatArea.getZoomLevel();
const center = this.lonLatArea.center;
const hasFrequencies = m.hasFrequencies;
let markdown = `# ${m.title}
let markdown = `\
# ${m.title}
${m.description}
Expand Down
1 change: 0 additions & 1 deletion src/Export/Outputtable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Mission } from "../Aerofly/Mission.js";
import { MissionCheckpoint } from "../Aerofly/MissionCheckpoint.js";
import { MissionConditions } from "../Aerofly/MissionConditions.js";
import { LonLatDate, LonLateDateSunState } from "../World/LonLatDate.js";

Expand Down
2 changes: 2 additions & 0 deletions src/Tests/MissionTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export class MissionTest extends Test {
this.assertEquals(mission.checkpoints.length, 5);
this.assertEquals(mission.checkpoints[4].name, "KBLI");
this.assertEquals(mission.checkpoints[1].lon_lat.altitude_m, 1676.3999463552018);

//console.log(mission.toString());
}
}
}

0 comments on commit e706198

Please sign in to comment.