Migrate to react proper

This commit is contained in:
Kilian Hofmann 2025-02-22 15:02:34 +01:00
parent 2604fbb75d
commit eb3c96361a
117 changed files with 647 additions and 5774 deletions

View File

@ -1,83 +0,0 @@
import {
ComponentProps,
ComputedSubject,
DisplayComponent,
FSComponent,
NodeReference,
Subscribable,
VNode,
} from '@microsoft/msfs-sdk';
import './controls.scss';
interface ControlsProps extends ComponentProps {
containerRef: NodeReference<HTMLDivElement>;
reload: () => void;
position: Subscribable<number>;
page: number;
}
export class Controls extends DisplayComponent<ControlsProps> {
private cycleRef = FSComponent.createRef<HTMLDivElement>();
private toTopRef = FSComponent.createRef<HTMLDivElement>();
private reloadRef = FSComponent.createRef<HTMLDivElement>();
private switchPosRef = FSComponent.createRef<HTMLDivElement>();
private buttonName = ComputedSubject.create<number, string>(0, (val) => {
if (val === 1) return '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/compass.png';
else if (val === 2) return '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/wrench.png';
return '';
});
constructor(props: ControlsProps) {
super(props);
props.position.sub((p) => this.buttonName.set(p));
}
private cycle = (): void => {
if (this.props.page === 0) SimVar.SetSimVarValue('L:KH_FE_FPLAN_P1', 'bool', true);
else if (this.props.page === 1) SimVar.SetSimVarValue('L:KH_FE_FPLAN_P1', 'bool', false);
};
private toTop = (): void => {
if (!this.props.containerRef.instance) return;
this.props.containerRef.instance.scrollTop = 0;
};
private switchPosition = (): void => {
if (this.props.position.get() === 1) SimVar.SetSimVarValue('L:KH_FE_FPLAN_BOARD', 'number', 2);
else if (this.props.position.get() === 2) SimVar.SetSimVarValue('L:KH_FE_FPLAN_BOARD', 'number', 1);
};
public render = (): VNode => (
<div id="KH_CTRL">
{this.props.page === 1 && (
<div ref={this.cycleRef} class="button">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
<div ref={this.toTopRef} class="button d90">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
<div ref={this.reloadRef} class="button">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/cloud.png" />
</div>
<div ref={this.switchPosRef} class="button">
<img class="icon" src={this.buttonName} />
</div>
{this.props.page === 0 && (
<div ref={this.cycleRef} class="button d180">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
</div>
);
public onAfterRender = (): void => {
this.cycleRef.instance.onclick = this.cycle;
this.toTopRef.instance.onclick = this.toTop;
this.reloadRef.instance.onclick = this.props.reload;
this.switchPosRef.instance.onclick = this.switchPosition;
};
}

View File

@ -1,72 +0,0 @@
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Controls } from '../controls/controls';
interface OFPProps extends ComponentProps {
content: Subscribable<string>;
reload: () => void;
position: Subscribable<number>;
}
export class OFP extends DisplayComponent<OFPProps> {
private containerRef = FSComponent.createRef<HTMLDivElement>();
private ofpRef = FSComponent.createRef<HTMLDivElement>();
constructor(props: OFPProps) {
super(props);
}
private defineDragScroll = (horizontalScroll = true, verticalScroll = true): void => {
if (!this.containerRef.instance) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
pos = {
left: this.containerRef.instance.scrollLeft,
top: this.containerRef.instance.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
this.containerRef.instance.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
this.containerRef.instance.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
this.containerRef.instance.addEventListener('mousedown', mouseDownHandler);
};
public render = (): VNode => (
<>
<div ref={this.containerRef} id="KH_FE_FPLAN">
<div ref={this.ofpRef} id="OFP" />
</div>
<Controls containerRef={this.containerRef} position={this.props.position} reload={this.props.reload} page={0} />
</>
);
public onAfterRender = (): void => {
this.defineDragScroll();
this.props.content.sub((content) => {
this.ofpRef.instance.innerHTML = content;
});
};
}

View File

@ -1,71 +0,0 @@
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Controls } from '../controls/controls';
interface TLRProps extends ComponentProps {
content: Subscribable<string>;
reload: () => void;
position: Subscribable<number>;
}
export class TLR extends DisplayComponent<TLRProps> {
private containerRef = FSComponent.createRef<HTMLDivElement>();
constructor(props: TLRProps) {
super(props);
}
private defineDragScroll = (horizontalScroll = true, verticalScroll = true): void => {
if (!this.containerRef.instance) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
pos = {
left: this.containerRef.instance.scrollLeft,
top: this.containerRef.instance.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.addEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
this.containerRef.instance.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
this.containerRef.instance.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
this.containerRef.instance.addEventListener('mousedown', mouseDownHandler);
};
public render = (): VNode => (
<>
<div ref={this.containerRef} id="KH_FE_FPLAN" class="p2">
<div id="TLR">
<div>
<pre>{this.props.content}</pre>
</div>
</div>
</div>
<Controls containerRef={this.containerRef} position={this.props.position} reload={this.props.reload} page={1} />
</>
);
public onAfterRender = (): void => {
this.defineDragScroll();
};
}

View File

@ -1,107 +0,0 @@
/// <reference types="@microsoft/msfs-types/Pages/VCockpit/Core/VCockpit" />
/// <reference types="@microsoft/msfs-types/JS/dataStorage" />
import { EventBus, FSComponent, SimVarPublisher, SimVarValueType, Subject } from '@microsoft/msfs-sdk';
import { OFP } from './components/ofp/ofp';
import { TLR } from './components/tlr/tlr';
import './index.scss';
export interface NewDataEvents {
newData: boolean;
position: number;
}
class KH_FE_FPLAN extends BaseInstrument {
private readonly bus = new EventBus();
private readonly newDataPublisher = new SimVarPublisher<NewDataEvents>(
new Map([
['newData', { name: 'L:KH_FE_FPLAN_NEW_DATA', type: SimVarValueType.Bool }],
['position', { name: 'L:KH_FE_FPLAN_BOARD', type: SimVarValueType.Number }],
]),
this.bus
);
private contentOFP = Subject.create<string>('');
private contentTLR = Subject.create<string>('');
private position = Subject.create<number>(0);
private sbID = '';
get templateID(): string {
return 'kh-fe-fplan';
}
get isInteractive() {
return true;
}
constructor() {
super();
const config = GetStoredData('FSS_B727_EFB_CONFIG_PREFLIGHT');
try {
this.sbID = JSON.parse(config).simBriefId;
} catch (e) {
console.error('Failed loading config.', e);
}
}
private getSB = async (): Promise<void> => {
try {
const res = await fetch(`https://www.simbrief.com/api/xml.fetcher.php?username=${this.sbID}&json=1`);
if (res.ok) {
try {
const data = await res.json();
let ofp: string = data.text.plan_html;
ofp = ofp.replace(/href=".*?"/g, '');
this.contentOFP.set(ofp);
this.contentTLR.set(data.text.tlr_section);
} catch (e) {
console.error('JSON DECODE ERR', e);
}
}
} catch (e) {
console.error('FETCH ERR', e);
}
};
private reloadSB = (): void => {
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 1);
};
protected Update(): void {
super.Update();
this.newDataPublisher.onUpdate();
}
public connectedCallback(): void {
super.connectedCallback();
this.newDataPublisher.startPublish();
const sub = this.bus.getSubscriber<NewDataEvents>();
sub.on('newData').handle((flag) => {
if (!flag) return;
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 0);
this.getSB();
});
sub.on('position').handle((position) => {
this.position.set(position);
});
const url = new URL(this.getAttribute('Url') ?? '');
const type = url.searchParams.get('type');
FSComponent.render(
<>
{type === 'ofp' && <OFP content={this.contentOFP} position={this.position} reload={this.reloadSB} />}
{type === 'tlr' && <TLR content={this.contentTLR} position={this.position} reload={this.reloadSB} />}
</>,
document.getElementById('root')
);
}
}
registerInstrument('kh-fe-fplan', KH_FE_FPLAN);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1 +0,0 @@
#KH_CTRL{align-items:center;display:flex;height:80px;justify-content:space-around}#KH_CTRL .button{border:1px solid #000;border-radius:5px;padding-left:7px;padding-right:7px}#KH_CTRL .button .icon{margin-top:6px;width:30px}#KH_CTRL .button:hover:not([disabled]){background-color:var(--buttonHoverColor)}#KH_CTRL .button.d180{transform:rotate(180deg)}#KH_CTRL .button.d90{transform:rotate(90deg)}@font-face{font-family:Consolas;font-style:normal;font-weight:100;src:url(assets/fonts/Consolas.ttf) format("truetype")}::-webkit-scrollbar{width:10px}::-webkit-scrollbar-track{background:#d3d3d3}::-webkit-scrollbar-thumb{background:gray;height:200px}::-webkit-scrollbar-thumb:hover{background:#a9a9a9}#root{--buttonHoverColor:#d3d3d3;--fss-select-hover:#d3d3d3;background-image:url(../EFB/Images/bg.png);background-size:100% 100%;color:#000;font-size:25px;height:100%;padding:3vw;width:594px}#root #KH_FE_FPLAN{height:calc(100vh - 6vw - 180px);margin-bottom:3vw;margin-top:100px;overflow-x:hidden;overflow-y:scroll;width:100%}#root #KH_FE_FPLAN #OFP div,#root #KH_FE_FPLAN #TLR div{font-size:unset!important;line-height:unset!important}#root #KH_FE_FPLAN #OFP pre,#root #KH_FE_FPLAN #TLR pre{font-family:Consolas!important;font-size:13px;line-height:14px;white-space:pre}#root #KH_FE_FPLAN #OFP img{width:100%}#root #KH_FE_FPLAN.p2{height:calc(100vh - 6vw - 240px);margin-top:160px}

View File

@ -1,7 +0,0 @@
<link rel="stylesheet" href="index.css" />
<script type="text/html" import-script="/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/index.js"></script>
<script type="text/html" import-script="/JS/dataStorage.js"></script>
<script type="text/html" id="kh-fe-fplan">
<div id="root"></div>
</script>

File diff suppressed because one or more lines are too long

1998
2020/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
{
"compilerOptions": {
"incremental": true, /* Enables incremental builds */
"target": "es2017", /* Specifies the ES2017 target, compatible with Coherent GT */
"module": "es2015", /* Ensures that modules are at least es2015 */
"strict": true, /* Enables strict type checking, highly recommended but optional */
"esModuleInterop": true, /* Emits additional JS to work with CommonJS modules */
"skipLibCheck": true, /* Skip type checking on library .d.ts files */
"forceConsistentCasingInFileNames": true, /* Ensures correct import casing */
"moduleResolution": "node", /* Enables compatibility with MSFS SDK bare global imports */
"jsxFactory": "FSComponent.buildComponent", /* Required for FSComponent framework JSX */
"jsxFragmentFactory": "FSComponent.Fragment", /* Required for FSComponent framework JSX */
"jsx": "react" /* Required for FSComponent framework JSX */
}
}

View File

@ -1,9 +0,0 @@
module.exports = {
printWidth: 120,
tabWidth: 2,
semi: true,
trailingComma: 'es5',
singleQuote: true,
arrowParens: 'always',
plugins: ['prettier-plugin-organize-imports'],
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1,30 +0,0 @@
#KH_CTRL {
height: 80px;
display: flex;
justify-content: space-around;
align-items: center;
.button {
border-radius: 5px;
border: solid 1px #000;
padding-left: 7px;
padding-right: 7px;
.icon {
width: 30px;
margin-top: 6px;
}
&:hover:not([disabled]) {
background-color: var(--buttonHoverColor);
}
&.d180 {
transform: rotate(180deg);
}
&.d90 {
transform: rotate(90deg);
}
}
}

View File

@ -1,83 +0,0 @@
import {
ComponentProps,
ComputedSubject,
DisplayComponent,
FSComponent,
NodeReference,
Subscribable,
VNode,
} from '@microsoft/msfs-sdk';
import './controls.scss';
interface ControlsProps extends ComponentProps {
containerRef: NodeReference<HTMLDivElement>;
reload: () => void;
position: Subscribable<number>;
page: number;
}
export class Controls extends DisplayComponent<ControlsProps> {
private cycleRef = FSComponent.createRef<HTMLDivElement>();
private toTopRef = FSComponent.createRef<HTMLDivElement>();
private reloadRef = FSComponent.createRef<HTMLDivElement>();
private switchPosRef = FSComponent.createRef<HTMLDivElement>();
private buttonName = ComputedSubject.create<number, string>(0, (val) => {
if (val === 1) return '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/compass.png';
else if (val === 2) return '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/wrench.png';
return '';
});
constructor(props: ControlsProps) {
super(props);
props.position.sub((p) => this.buttonName.set(p));
}
private cycle = (): void => {
if (this.props.page === 0) SimVar.SetSimVarValue('L:KH_FE_FPLAN_P1', 'bool', true);
else if (this.props.page === 1) SimVar.SetSimVarValue('L:KH_FE_FPLAN_P1', 'bool', false);
};
private toTop = (): void => {
if (!this.props.containerRef.instance) return;
this.props.containerRef.instance.scrollTop = 0;
};
private switchPosition = (): void => {
if (this.props.position.get() === 1) SimVar.SetSimVarValue('L:KH_FE_FPLAN_BOARD', 'number', 2);
else if (this.props.position.get() === 2) SimVar.SetSimVarValue('L:KH_FE_FPLAN_BOARD', 'number', 1);
};
public render = (): VNode => (
<div id="KH_CTRL">
{this.props.page === 1 && (
<div ref={this.cycleRef} class="button">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
<div ref={this.toTopRef} class="button d90">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
<div ref={this.reloadRef} class="button">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/cloud.png" />
</div>
<div ref={this.switchPosRef} class="button">
<img class="icon" src={this.buttonName} />
</div>
{this.props.page === 0 && (
<div ref={this.cycleRef} class="button d180">
<img class="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
</div>
);
public onAfterRender = (): void => {
this.cycleRef.instance.onclick = this.cycle;
this.toTopRef.instance.onclick = this.toTop;
this.reloadRef.instance.onclick = this.props.reload;
this.switchPosRef.instance.onclick = this.switchPosition;
};
}

View File

@ -1,72 +0,0 @@
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Controls } from '../controls/controls';
interface OFPProps extends ComponentProps {
content: Subscribable<string>;
reload: () => void;
position: Subscribable<number>;
}
export class OFP extends DisplayComponent<OFPProps> {
private containerRef = FSComponent.createRef<HTMLDivElement>();
private ofpRef = FSComponent.createRef<HTMLDivElement>();
constructor(props: OFPProps) {
super(props);
}
private defineDragScroll = (horizontalScroll = true, verticalScroll = true): void => {
if (!this.containerRef.instance) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
pos = {
left: this.containerRef.instance.scrollLeft,
top: this.containerRef.instance.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
this.containerRef.instance.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
this.containerRef.instance.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
this.containerRef.instance.addEventListener('mousedown', mouseDownHandler);
};
public render = (): VNode => (
<>
<div ref={this.containerRef} id="KH_FE_FPLAN">
<div ref={this.ofpRef} id="OFP" />
</div>
<Controls containerRef={this.containerRef} position={this.props.position} reload={this.props.reload} page={0} />
</>
);
public onAfterRender = (): void => {
this.defineDragScroll();
this.props.content.sub((content) => {
this.ofpRef.instance.innerHTML = content;
});
};
}

View File

@ -1,71 +0,0 @@
import { ComponentProps, DisplayComponent, FSComponent, Subscribable, VNode } from '@microsoft/msfs-sdk';
import { Controls } from '../controls/controls';
interface TLRProps extends ComponentProps {
content: Subscribable<string>;
reload: () => void;
position: Subscribable<number>;
}
export class TLR extends DisplayComponent<TLRProps> {
private containerRef = FSComponent.createRef<HTMLDivElement>();
constructor(props: TLRProps) {
super(props);
}
private defineDragScroll = (horizontalScroll = true, verticalScroll = true): void => {
if (!this.containerRef.instance) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
pos = {
left: this.containerRef.instance.scrollLeft,
top: this.containerRef.instance.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.addEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
this.containerRef.instance.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
this.containerRef.instance.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
this.containerRef.instance.addEventListener('mousedown', mouseDownHandler);
};
public render = (): VNode => (
<>
<div ref={this.containerRef} id="KH_FE_FPLAN" class="p2">
<div id="TLR">
<div>
<pre>{this.props.content}</pre>
</div>
</div>
</div>
<Controls containerRef={this.containerRef} position={this.props.position} reload={this.props.reload} page={1} />
</>
);
public onAfterRender = (): void => {
this.defineDragScroll();
};
}

View File

@ -1,7 +0,0 @@
<link rel="stylesheet" href="index.css" />
<script type="text/html" import-script="/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/index.js"></script>
<script type="text/html" import-script="/JS/dataStorage.js"></script>
<script type="text/html" id="kh-fe-fplan">
<div id="root"></div>
</script>

View File

@ -1,68 +0,0 @@
@font-face {
font-family: 'Consolas';
src: url('./assets/fonts/Consolas.ttf') format('truetype');
font-weight: 100;
font-style: normal;
}
::-webkit-scrollbar {
width: 10px;
}
::-webkit-scrollbar-track {
background: lightgray;
}
::-webkit-scrollbar-thumb {
background: gray;
height: 200px;
}
::-webkit-scrollbar-thumb:hover {
background: darkgray;
}
#root {
--buttonHoverColor: lightgray;
--fss-select-hover: lightgray;
/* No idea why, zero. I looked at the EFB.css and it has 100%, but doing so screws this over hard */
width: 594px;
height: 100%;
background-image: url(../EFB/Images/bg.png);
background-size: 100% 100%;
color: #000;
font-size: 25px;
padding: 3vw;
#KH_FE_FPLAN {
height: calc(100vh - 6vw - 180px);
width: 100%;
margin-top: 100px;
margin-bottom: 3vw;
overflow-y: scroll;
overflow-x: hidden;
#TLR div,
#OFP div {
line-height: unset !important;
font-size: unset !important;
}
#TLR pre,
#OFP pre {
white-space: pre;
line-height: 14px;
font-size: 13px;
font-family: 'Consolas' !important;
}
#OFP img {
width: 100%;
}
&.p2 {
height: calc(100vh - 6vw - 240px);
margin-top: 160px;
}
}
}

View File

@ -1,107 +0,0 @@
/// <reference types="@microsoft/msfs-types/Pages/VCockpit/Core/VCockpit" />
/// <reference types="@microsoft/msfs-types/JS/dataStorage" />
import { EventBus, FSComponent, SimVarPublisher, SimVarValueType, Subject } from '@microsoft/msfs-sdk';
import { OFP } from './components/ofp/ofp';
import { TLR } from './components/tlr/tlr';
import './index.scss';
export interface NewDataEvents {
newData: boolean;
position: number;
}
class KH_FE_FPLAN extends BaseInstrument {
private readonly bus = new EventBus();
private readonly newDataPublisher = new SimVarPublisher<NewDataEvents>(
new Map([
['newData', { name: 'L:KH_FE_FPLAN_NEW_DATA', type: SimVarValueType.Bool }],
['position', { name: 'L:KH_FE_FPLAN_BOARD', type: SimVarValueType.Number }],
]),
this.bus
);
private contentOFP = Subject.create<string>('');
private contentTLR = Subject.create<string>('');
private position = Subject.create<number>(0);
private sbID = '';
get templateID(): string {
return 'kh-fe-fplan';
}
get isInteractive() {
return true;
}
constructor() {
super();
const config = GetStoredData('FSS_B727_EFB_CONFIG_PREFLIGHT');
try {
this.sbID = JSON.parse(config).simBriefId;
} catch (e) {
console.error('Failed loading config.', e);
}
}
private getSB = async (): Promise<void> => {
try {
const res = await fetch(`https://www.simbrief.com/api/xml.fetcher.php?username=${this.sbID}&json=1`);
if (res.ok) {
try {
const data = await res.json();
let ofp: string = data.text.plan_html;
ofp = ofp.replace(/href=".*?"/g, '');
this.contentOFP.set(ofp);
this.contentTLR.set(data.text.tlr_section);
} catch (e) {
console.error('JSON DECODE ERR', e);
}
}
} catch (e) {
console.error('FETCH ERR', e);
}
};
private reloadSB = (): void => {
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 1);
};
protected Update(): void {
super.Update();
this.newDataPublisher.onUpdate();
}
public connectedCallback(): void {
super.connectedCallback();
this.newDataPublisher.startPublish();
const sub = this.bus.getSubscriber<NewDataEvents>();
sub.on('newData').handle((flag) => {
if (!flag) return;
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 0);
this.getSB();
});
sub.on('position').handle((position) => {
this.position.set(position);
});
const url = new URL(this.getAttribute('Url') ?? '');
const type = url.searchParams.get('type');
FSComponent.render(
<>
{type === 'ofp' && <OFP content={this.contentOFP} position={this.position} reload={this.reloadSB} />}
{type === 'tlr' && <TLR content={this.contentTLR} position={this.position} reload={this.reloadSB} />}
</>,
document.getElementById('root')
);
}
}
registerInstrument('kh-fe-fplan', KH_FE_FPLAN);

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_DECAL0</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_METAL_ROUGH_AO</BitmapSlot><ForceNoAlpha>true</ForceNoAlpha></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_NORMAL</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_DECAL0</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_DECAL0</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_METAL_ROUGH_AO</BitmapSlot><ForceNoAlpha>true</ForceNoAlpha></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_METAL_ROUGH_AO</BitmapSlot><ForceNoAlpha>true</ForceNoAlpha></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_EMISSIVE</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_EMISSIVE</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_NORMAL</BitmapSlot></BitmapConfiguration>

View File

@ -1 +0,0 @@
<BitmapConfiguration><BitmapSlot>MTL_BITMAP_NORMAL</BitmapSlot></BitmapConfiguration>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<ModelInfo guid="{88BD504E-B59D-4C8C-99AE-17815C039D3A}" version="1.1">
<LODS>
<LOD minSize="0.0" ModelFile="sb-fplan.gltf" />
</LODS>
<Behaviors></Behaviors>
</ModelInfo>

View File

@ -1,14 +0,0 @@
[VERSION]
Major = 1
Minor = 0
[FLTSIM.0]
title = fss-aircraft-boeing-727-200f-sb-fplan
model = ""
texture = ""
animation = ""
sound = ""
soundai = ""
[GENERAL]
category = SimpleObject

View File

@ -1,189 +0,0 @@
const j6_0xca47fd = (function () {
let _0x29bb3f = !![];
return function (_0x1eef08, _0x3f53d2) {
const _0x1fc5ed = _0x29bb3f
? function () {
if (_0x3f53d2) {
const _0x45f38f = _0x3f53d2['apply'](_0x1eef08, arguments);
return (_0x3f53d2 = null), _0x45f38f;
}
}
: function () {};
return (_0x29bb3f = ![]), _0x1fc5ed;
};
})(),
j6_0x14eaec = j6_0xca47fd(this, function () {
const _0x1c40d9 = function () {
let _0x41ef43;
try {
_0x41ef43 = Function(
'retur' +
'n\x20(fu' +
'nctio' +
'n()\x20' +
('{}.co' + 'nstru' + 'ctor(' + '\x22retu' + 'rn\x20th' + 'is\x22)(' + '\x20)') +
');'
)();
} catch (_0x5064d1) {
_0x41ef43 = window;
}
return _0x41ef43;
},
_0xa6d217 = _0x1c40d9(),
_0x28f1fd = (_0xa6d217['conso' + 'le'] = _0xa6d217['conso' + 'le'] || {}),
_0x427c5e = ['log', 'warn', 'info', 'error', 'excep' + 'tion', 'table', 'trace'];
for (let _0x5a262e = 0x0; _0x5a262e < _0x427c5e['lengt' + 'h']; _0x5a262e++) {
const _0x361466 = j6_0xca47fd['const' + 'ructo' + 'r']['proto' + 'type']['bind'](j6_0xca47fd),
_0x462cef = _0x427c5e[_0x5a262e],
_0x195676 = _0x28f1fd[_0x462cef] || _0x361466;
(_0x361466['__pro' + 'to__'] = j6_0xca47fd['bind'](j6_0xca47fd)),
(_0x361466['toStr' + 'ing'] = _0x195676['toStr' + 'ing']['bind'](_0x195676)),
(_0x28f1fd[_0x462cef] = _0x361466);
}
});
j6_0x14eaec();
class EFBUtils {
static ['setSe' + 'ating' + 'Posit' + 'ion'](_0x183760) {
SimVar['SetSi' + 'mVarV' + 'alue']('A:CAMERA STATE', 'Number', 0x2),
SimVar['SetSi' + 'mVarV' + 'alue']('A:CAMERA SUBSTATE', 'Number', 0x1),
SimVar['SetSi' + 'mVarV' + 'alue']('A:CAMERA REQUEST ACTION', 'Number', 0x1),
_0x183760
? setTimeout(() => {
SimVar['SetSi' + 'mVarV' + 'alue']('A:CAMERA VIEW TYPE AND INDEX:1', 'Number', 0x4);
}, 0x1f4)
: setTimeout(() => {
SimVar['SetSi' + 'mVarV' + 'alue']('A:CAMERA VIEW TYPE AND INDEX:1', 'Number', 0x1);
}, 0x1f4),
SimVar['SetSi' + 'mVarV' + 'alue']('L:FSS_B727_EFB_SEATING_POSITION', 'Bool', _0x183760);
}
static ['impor' + 'tFlig' + 'htPla' + 'n'](_0xc32463) {
const _0x382d2b =
'https' +
'://ww' +
'w.sim' +
'brief' +
'.com/' +
'api/x' +
'ml.fe' +
'tcher' +
'.php?' +
'usern' +
'ame=' +
_0xc32463;
return fetch(_0x382d2b)
['then']((_0x2cc7e3) => {
return _0x2cc7e3['text']();
})
['then']((_0x26b60a) => {
const _0x58169d = new DOMParser(),
_0x7997e1 = _0x58169d['parse' + 'FromS' + 'tring'](_0x26b60a, 'text/xml');
let _0x21dfa5 = {};
const _0x300c26 = _0x7997e1['query' + 'Selec' + 'tor']('fetch > status');
_0x300c26 && (_0x21dfa5['statu' + 's'] = _0x300c26['inner' + 'HTML']);
const _0x202d4b = _0x7997e1['query' + 'Selec' + 'tor']('params > units');
_0x202d4b && (_0x21dfa5['units'] = _0x202d4b['inner' + 'HTML']);
const _0x2b5b6f = _0x7997e1['query' + 'Selec' + 'tor']('origin > icao_code');
_0x2b5b6f && (_0x21dfa5['origi' + 'n'] = _0x2b5b6f['inner' + 'HTML']);
const _0x37322c = _0x7997e1['query' + 'Selec' + 'tor']('destination > icao_code');
_0x37322c && (_0x21dfa5['desti' + 'natio' + 'n'] = _0x37322c['inner' + 'HTML']);
const _0x4f66aa = _0x7997e1['query' + 'Selec' + 'tor']('aircraft > icaocode');
_0x4f66aa && (_0x21dfa5['aircr' + 'aft'] = _0x4f66aa['inner' + 'HTML']);
const _0x3e15f6 = _0x7997e1['query' + 'Selec' + 'tor']('fuel > plan_ramp');
_0x3e15f6 && (_0x21dfa5['fuel'] = parseFloat(_0x3e15f6['inner' + 'HTML']));
const _0x53c20f = _0x7997e1['query' + 'Selec' + 'tor']('weights > payload');
/* KHOFMANN START */
// This is only to allow the new gauges to auto fetch the plan
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 1);
/* KHOFMANN END */
return _0x53c20f && (_0x21dfa5['paylo' + 'ad'] = parseFloat(_0x53c20f['inner' + 'HTML'])), _0x21dfa5;
});
}
static ['meter' + 'ToFee' + 't'](_0x945b59) {
return _0x945b59 * 3.28084;
}
static ['feetT' + 'oMete' + 'r'](_0x433b0d) {
return _0x433b0d * 0.3048;
}
static ['feetT' + 'oNaut' + 'icalM' + 'ile'](_0x51576c) {
return _0x51576c * 0.000164579;
}
static ['lbsTo' + 'Kg'](_0x2d9367) {
return _0x2d9367 * 0.453592;
}
static ['gtn75' + '0Inst' + 'alled']() {
return !!SimVar['GetSi' + 'mVarV' + 'alueF' + 'ast']('L:PMS50_GTN750_INSTALLED', 'Bool');
}
static ['gtnxi' + 'Insta' + 'lled']() {
return !!SimVar['GetSi' + 'mVarV' + 'alueF' + 'ast']('L:TDSGTNXI_INSTALLED', 'Bool');
}
static ['diffA' + 'ndSet' + 'Value'](_0x2e7fbe, _0xaeb6de) {
_0x2e7fbe['value'] != _0xaeb6de && (_0x2e7fbe['value'] = _0xaeb6de);
}
static ['diffA' + 'ndAdd' + 'Attri' + 'bute'](_0x2a092d, _0x29db47, _0x56d461) {
const _0x47c464 = !!_0x2a092d['getAt' + 'tribu' + 'te'](_0x29db47);
_0x56d461
? !_0x47c464 && _0x2a092d['setAt' + 'tribu' + 'te'](_0x29db47, !![])
: _0x47c464 && _0x2a092d['remov' + 'eAttr' + 'ibute'](_0x29db47);
}
static ['genSh' + 'uffle' + 'dArra' + 'y'](_0x493b5a) {
return Array['from'](Array(_0x493b5a)['keys']())['sort'](() => Math['rando' + 'm']() - 0.5);
}
static ['setIn' + 'putOn' + 'Chang' + 'e'](_0x344d78, _0x4988f3) {
(_0x344d78['onkey' + 'press'] = (_0xb39586) => {
const _0x252e2b = _0xb39586['which'];
_0x252e2b === 0xd && _0xb39586['srcEl' + 'ement']['blur']();
}),
(_0x344d78['onblu' + 'r'] = (_0x27045f) => {
_0x4988f3(_0x27045f['srcEl' + 'ement']);
});
}
static ['setWi' + 'ndInp' + 'ut'](_0x1d7d59, _0x3174de) {
EFBUtils['setIn' + 'putOn' + 'Chang' + 'e'](_0x1d7d59, (_0x2632cd) => {
let _0xe0907b = 0x0,
_0x46f45b = 0x0;
if (_0x2632cd['value']) {
const _0xc0d1bd = _0x2632cd['value']['split']('/');
if (_0xc0d1bd['lengt' + 'h'] > 0x1)
(_0xe0907b = parseInt(_0xc0d1bd[0x0])),
(_0x46f45b = parseInt(_0xc0d1bd[0x1])),
isNaN(_0xe0907b) && (_0xe0907b = 0x0),
isNaN(_0x46f45b) && (_0x46f45b = 0x0);
else
_0xc0d1bd['lengt' + 'h'] > 0x0 &&
((_0xe0907b = parseInt(_0xc0d1bd[0x0])), isNaN(_0xe0907b) && (_0xe0907b = 0x0));
}
(_0xe0907b = Math['max'](Math['min'](_0xe0907b, 0x168), 0x0)),
(_0x46f45b = Math['max'](Math['min'](_0x46f45b, 0x63), 0x0)),
(_0x2632cd['value'] =
_0xe0907b['toStr' + 'ing']()['padSt' + 'art'](0x3, '0') +
'/' +
_0x46f45b['toStr' + 'ing']()['padSt' + 'art'](0x2, '0')),
_0x3174de({ dir: _0xe0907b, speed: _0x46f45b });
});
}
static ['setQN' + 'HInpu' + 't'](_0x303325, _0x509c84) {
EFBUtils['setIn' + 'putOn' + 'Chang' + 'e'](_0x303325, (_0xc37bc3) => {
let _0x338a95 = 0x0;
_0xc37bc3['value'] && ((_0x338a95 = parseFloat(_0xc37bc3['value'])), isNaN(_0x338a95) && (_0x338a95 = 0x0)),
(_0xc37bc3['value'] = _0x338a95['toFix' + 'ed'](0x2)),
_0x509c84(_0x338a95);
});
}
static ['setTe' + 'mpInp' + 'ut'](_0x3f84c5, _0x5692e2) {
EFBUtils['setIn' + 'putOn' + 'Chang' + 'e'](_0x3f84c5, (_0x506059) => {
let _0x40003b = 0x0;
_0x506059['value'] && ((_0x40003b = parseInt(_0x506059['value'])), isNaN(_0x40003b) && (_0x40003b = 0x0)),
(_0x506059['value'] = _0x40003b),
_0x5692e2({ tempF: _0x40003b, tempC: EFBUtils['fahre' + 'nheit' + 'ToCel' + 'cius'](_0x40003b) });
});
}
static ['fahre' + 'nheit' + 'ToCel' + 'cius'](_0x5a890b) {
return (_0x5a890b - 0x20) * (0x5 / 0x9);
}
static ['isOSR']() {
const _0x4e6689 = SimVar['GetSi' + 'mVarV' + 'alue']('A:TITLE', 'String');
return _0x4e6689['toLow' + 'erCas' + 'e']()['inclu' + 'des']('oil spill response');
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -1 +0,0 @@
#KH_CTRL{align-items:center;display:flex;height:80px;justify-content:space-around}#KH_CTRL .button{border:1px solid #000;border-radius:5px;padding-left:7px;padding-right:7px}#KH_CTRL .button .icon{margin-top:6px;width:30px}#KH_CTRL .button:hover:not([disabled]){background-color:var(--buttonHoverColor)}#KH_CTRL .button.d180{transform:rotate(180deg)}#KH_CTRL .button.d90{transform:rotate(90deg)}@font-face{font-family:Consolas;font-style:normal;font-weight:100;src:url(assets/fonts/Consolas.ttf) format("truetype")}::-webkit-scrollbar{width:10px}::-webkit-scrollbar-track{background:#d3d3d3}::-webkit-scrollbar-thumb{background:gray;height:200px}::-webkit-scrollbar-thumb:hover{background:#a9a9a9}#root{--buttonHoverColor:#d3d3d3;--fss-select-hover:#d3d3d3;background-image:url(../EFB/Images/bg.png);background-size:100% 100%;color:#000;font-size:25px;height:100%;padding:3vw;width:594px}#root #KH_FE_FPLAN{height:calc(100vh - 6vw - 180px);margin-bottom:3vw;margin-top:100px;overflow-x:hidden;overflow-y:scroll;width:100%}#root #KH_FE_FPLAN #OFP div,#root #KH_FE_FPLAN #TLR div{font-size:unset!important;line-height:unset!important}#root #KH_FE_FPLAN #OFP pre,#root #KH_FE_FPLAN #TLR pre{font-family:Consolas!important;font-size:13px;line-height:14px;white-space:pre}#root #KH_FE_FPLAN #OFP img{width:100%}#root #KH_FE_FPLAN.p2{height:calc(100vh - 6vw - 240px);margin-top:160px}

View File

@ -1,7 +0,0 @@
<link rel="stylesheet" href="index.css" />
<script type="text/html" import-script="/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/index.js"></script>
<script type="text/html" import-script="/JS/dataStorage.js"></script>
<script type="text/html" id="kh-fe-fplan">
<div id="root"></div>
</script>

File diff suppressed because one or more lines are too long

View File

@ -1,34 +0,0 @@
{
"name": "xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan",
"version": "1.0.0",
"description": "Adds a new clipboard to view your imported SimBrief flightplan and takeoff/landing performance",
"main": "index.js",
"scripts": {
"dev": "npx rollup -c",
"prod": "cross-env NODE_ENV=production npx rollup -c"
},
"type": "module",
"keywords": [],
"author": "khofmann",
"license": "",
"devDependencies": {
"@microsoft/msfs-sdk": "^2.0.5",
"@microsoft/msfs-types": "^1.14.6",
"@rollup/plugin-node-resolve": "^16.0.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"autoprefixer": "^10.4.20",
"cross-env": "^7.0.3",
"postcss-import": "^16.1.0",
"prettier": "^3.4.2",
"prettier-plugin-organize-imports": "^4.1.0",
"rollup": "2",
"rollup-plugin-cleaner": "^1.0.0",
"rollup-plugin-copy": "^3.5.0",
"rollup-plugin-import-css": "^3.5.8",
"rollup-plugin-postcss": "^4.0.2",
"sass": "^1.83.4",
"tslib": "^2.8.1",
"typescript": "^5.7.3"
}
}

View File

@ -1,43 +0,0 @@
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import autoprefixer from 'autoprefixer';
import atImport from 'postcss-import';
import cleaner from 'rollup-plugin-cleaner';
import copy from 'rollup-plugin-copy';
import postcss from 'rollup-plugin-postcss';
const { NODE_ENV: targetEnv = 'development' } = process.env;
const inDirBase = 'Gauge/src';
const outDirBase = 'PackageSources/html_ui/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/';
export default {
input: `${inDirBase}/index.tsx`,
output: {
dir: outDirBase,
format: 'es',
sourcemap: targetEnv !== 'production',
},
plugins: [
cleaner({
targets: [outDirBase],
}),
postcss({
plugins: [autoprefixer(), atImport()],
extract: true,
use: ['sass'],
sourceMap: targetEnv !== 'production',
minimize: targetEnv === 'production',
}),
resolve(),
typescript(),
targetEnv === 'production' && terser(),
copy({
targets: [
{ src: [`${inDirBase}/index.html`], dest: outDirBase },
{ src: [`${inDirBase}/assets/img/**`], dest: outDirBase + 'assets/img' },
{ src: [`${inDirBase}/assets/fonts/**`], dest: outDirBase + 'assets/fonts' },
],
}),
],
};

89
Gauge/src/App.tsx Normal file
View File

@ -0,0 +1,89 @@
import { FC, useEffect, useRef, useState } from 'react';
import OFP from './components/ofp/ofp';
import TLR from './components/tlr/tlr';
interface AppProps {
type: string;
}
const App: FC<AppProps> = ({ type }) => {
const [contentOFP, setContentOFP] = useState('');
const [contentTLR, setContentTLR] = useState('');
const [page, setPage] = useState(0);
const [position, setPosition] = useState(1);
const loopRef = useRef<number | undefined>(undefined);
useEffect(() => {
loopRef.current = setInterval(() => {
const flag = SimVar.GetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool');
if (flag) {
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 0);
getSB();
}
}, 100);
return () => clearInterval(loopRef.current);
});
const sbID = () => {
const config = GetStoredData('FSS_B727_EFB_CONFIG_PREFLIGHT');
try {
return JSON.parse(config).simBriefId as string;
} catch (e) {
console.error('Failed loading config.', e);
return null;
}
};
const getSB = async () => {
try {
const res = await fetch(`https://www.simbrief.com/api/xml.fetcher.php?username=${sbID()}&json=1`);
if (res.ok) {
try {
const data = await res.json();
let ofp: string = data.text.plan_html;
ofp = ofp.replace(/href=".*?"/g, '');
setContentOFP(ofp);
setContentTLR(data.text.tlr_section);
} catch (e) {
console.error('JSON DECODE ERR', e);
}
}
} catch (e) {
console.error('FETCH ERR', e);
}
};
const reloadSB = () => {
SimVar.SetSimVarValue('L:KH_FE_FPLAN_NEW_DATA', 'bool', 1);
};
return (
<>
{type === 'ofp' && (
<OFP
content={contentOFP}
position={position}
page={page}
reload={reloadSB}
setPosition={setPosition}
setPage={setPage}
/>
)}
{type === 'tlr' && (
<TLR
content={contentTLR}
position={position}
page={page}
reload={reloadSB}
setPosition={setPosition}
setPage={setPage}
/>
)}
</>
);
};
export default App;

View File

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -0,0 +1,72 @@
import { Dispatch, FC, RefObject, SetStateAction } from 'react';
import './controls.scss';
interface ControlsProps {
containerRef: RefObject<HTMLDivElement | null>;
position: number;
page: number;
reload: () => void;
setPosition: Dispatch<SetStateAction<number>>;
setPage: Dispatch<SetStateAction<number>>;
}
const Controls: FC<ControlsProps> = ({ containerRef, position, page, reload, setPosition, setPage }) => {
const cycle = () => {
setPage((prev) => {
const _new = (prev + 1) % 2;
SimVar.SetSimVarValue('KH_FE_FPLAN_P1', 'bool', _new);
return _new;
});
};
const toTop = () => {
if (!containerRef.current) return;
containerRef.current.scrollTop = 0;
};
const switchPosition = () => {
setPosition((prev) => {
let _new = prev;
if (position === 1) _new = 2;
else if (position === 2) _new = 1;
SimVar.SetSimVarValue('KH_FE_FPLAN_BOARD', 'number', _new);
return _new;
});
};
return (
<div id="KH_CTRL">
{page === 1 && (
<div className="button" onClick={cycle}>
<img className="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
<div className="button d90" onClick={toTop}>
<img className="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
<div className="button" onClick={reload}>
<img className="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/cloud.png" />
</div>
<div className="button" onClick={switchPosition}>
<img
className="icon"
src={
position === 1
? '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/compass.png'
: position === 2
? '/Pages/VCockpit/Instruments/FSS_B727/KH_FE_FPLAN/assets/img/wrench.png'
: ''
}
/>
</div>
{page === 0 && (
<div className="button d180" onClick={cycle}>
<img className="icon" src="/Pages/VCockpit/Instruments/FSS_B727/EFB/Images/get.png" />
</div>
)}
</div>
);
};
export default Controls;

View File

@ -0,0 +1,79 @@
import { createRef, Dispatch, FC, SetStateAction, useEffect } from 'react';
import Controls from '../controls/controls';
interface TLRProps {
content: string;
position: number;
page: number;
reload: () => void;
setPosition: Dispatch<SetStateAction<number>>;
setPage: Dispatch<SetStateAction<number>>;
}
const OFP: FC<TLRProps> = ({ content, position, page, reload, setPosition, setPage }) => {
const containerRef = createRef<HTMLDivElement>();
const defineDragScroll = (horizontalScroll = true, verticalScroll = true) => {
if (!containerRef.current) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
if (!containerRef.current) return;
pos = {
left: containerRef.current.scrollLeft,
top: containerRef.current.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.addEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
if (!containerRef.current) return;
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
containerRef.current.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
containerRef.current.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
containerRef.current.addEventListener('mousedown', mouseDownHandler);
};
useEffect(() => {
defineDragScroll();
}, [containerRef.current]);
return (
<>
<div ref={containerRef} id="KH_FE_FPLAN" className="p2">
<div id="OFP" dangerouslySetInnerHTML={{ __html: content }} />
</div>
<Controls
containerRef={containerRef}
position={position}
page={page}
reload={reload}
setPosition={setPosition}
setPage={setPage}
/>
</>
);
};
export default OFP;

View File

@ -0,0 +1,83 @@
import { createRef, Dispatch, FC, SetStateAction, useEffect } from 'react';
import Controls from '../controls/controls';
interface TLRProps {
content: string;
position: number;
page: number;
reload: () => void;
setPosition: Dispatch<SetStateAction<number>>;
setPage: Dispatch<SetStateAction<number>>;
}
const TLR: FC<TLRProps> = ({ content, position, page, reload, setPosition, setPage }) => {
const containerRef = createRef<HTMLDivElement>();
const defineDragScroll = (horizontalScroll = true, verticalScroll = true) => {
if (!containerRef.current) return;
let pos = { top: 0, left: 0, x: 0, y: 0 };
const mouseDownHandler = (e: MouseEvent) => {
if (!containerRef.current) return;
pos = {
left: containerRef.current.scrollLeft,
top: containerRef.current.scrollTop,
x: e.clientX,
y: e.clientY,
};
document.addEventListener('mousemove', mouseMoveHandler);
document.addEventListener('mouseup', mouseUpHandler);
document.addEventListener('mouseleave', mouseUpHandler);
};
const mouseMoveHandler = (e: MouseEvent) => {
if (!containerRef.current) return;
const dx = e.clientX - pos.x;
const dy = e.clientY - pos.y;
if (verticalScroll) {
containerRef.current.scrollTop = pos.top - dy;
}
if (horizontalScroll) {
containerRef.current.scrollLeft = pos.left - dx;
}
};
const mouseUpHandler = (e: MouseEvent) => {
document.removeEventListener('mousemove', mouseMoveHandler);
document.removeEventListener('mouseup', mouseUpHandler);
document.removeEventListener('mouseleave', mouseUpHandler);
};
containerRef.current.addEventListener('mousedown', mouseDownHandler);
};
useEffect(() => {
defineDragScroll();
}, [containerRef.current]);
return (
<>
<div ref={containerRef} id="KH_FE_FPLAN" className="p2">
<div id="TLR">
<div>
<pre>{content}</pre>
</div>
</div>
</div>
<Controls
containerRef={containerRef}
position={position}
page={page}
reload={reload}
setPosition={setPosition}
setPage={setPage}
/>
</>
);
};
export default TLR;

54
Gauge/src/index.tsx Normal file
View File

@ -0,0 +1,54 @@
/// <reference types="@microsoft/msfs-types/pages/vcockpit/core/vcockpit" />
/// <reference types="@microsoft/msfs-types/pages/vcockpit/instruments/shared/baseinstrument" />
/// <reference types="@microsoft/msfs-types/js/datastorage" />
/// <reference types="@microsoft/msfs-types/js/simvar" />
import { createRoot } from 'react-dom/client';
import App from './App';
import './index.scss';
class KH_FE_FPLAN extends BaseInstrument {
get templateID(): string {
return 'kh-fe-fplan';
}
get isInteractive() {
return true;
}
constructor() {
super();
}
protected Update(): void {
super.Update();
}
public connectedCallback(): void {
super.connectedCallback();
//@ts-expect-error
const url = new URL(this.getAttribute('Url') ?? '');
const type = url.searchParams.get('type') ?? '';
const container = document.getElementById('root');
if (container) {
const root = createRoot(container);
root.render(<App type={type} />);
}
/*
FSComponent.render(
<>
{type === 'ofp' && <OFP content={this.contentOFP} position={this.position} reload={this.reloadSB} />}
{type === 'tlr' && <TLR content={this.contentTLR} position={this.position} reload={this.reloadSB} />}
</>,
document.getElementById('root')
);
*/
}
}
//@ts-expect-error
registerInstrument('kh-fe-fplan', KH_FE_FPLAN);

View File

@ -16,15 +16,15 @@
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageDefinitions\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan\ContentInfo\</AssetDir>
<OutputDir>ContentInfo\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan\</OutputDir>
<AssetDir>PackageDefinitions\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-20\ContentInfo\</AssetDir>
<OutputDir>ContentInfo\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-20\</OutputDir>
</AssetGroup>
<AssetGroup Name="fss-aircraft-boeing-727-200f">
<Type>Copy</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\SimObjects\Airplanes\</AssetDir>
<AssetDir>PackageSources\SimObjects\Airplanes-20\</AssetDir>
<OutputDir>SimObjects\Airplanes\</OutputDir>
</AssetGroup>
<AssetGroup Name="xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-html">
@ -45,4 +45,3 @@
</AssetGroup>
</AssetGroups>
</AssetPackage>

View File

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<AssetPackage Version="1.0.0">
<ItemSettings>
<ContentType>MISC</ContentType>
<Title>FSS Boeing 727-200f SimBrief Flightplan</Title>
<Manufacturer/>
<Creator>khofmann</Creator>
</ItemSettings>
<Flags>
<VisibleInStore>false</VisibleInStore>
<CanBeReferenced>false</CanBeReferenced>
</Flags>
<AssetGroups>
<AssetGroup Name="ContentInfo">
<Type Version="0">ContentInfo</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageDefinitions\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-24\ContentInfo</AssetDir>
<OutputDir>ContentInfo\xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-24\</OutputDir>
</AssetGroup>
<AssetGroup Name="fss-aircraft-boeing-727-200f">
<Type Version="0">Copy</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\SimObjects\Airplanes-24\</AssetDir>
<OutputDir>SimObjects\Airplanes\</OutputDir>
</AssetGroup>
<AssetGroup Name="xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-html">
<Type Version="0">Copy</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\html_ui\</AssetDir>
<OutputDir>html_ui\</OutputDir>
</AssetGroup>
<AssetGroup Name="xkhofmann-fss-aircraft-boeing-727-200f-sb-fplan-model">
<Type Version="1">SimObject</Type>
<Flags>
<FSXCompatibility>false</FSXCompatibility>
</Flags>
<AssetDir>PackageSources\SimObjects\Misc\fss-aircraft-boeing-727-200f-sb-fplan\</AssetDir>
<OutputDir>SimObjects\Misc\fss-aircraft-boeing-727-200f-sb-fplan\</OutputDir>
</AssetGroup>
</AssetGroups>
</AssetPackage>

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@ -35,32 +35,37 @@ pixel_size = 183, 149
texture = $CIVA_Screen_3
htmlgauge00 = FSS_B727/CIVA/CIVAScreen3.html, 0, 0, 183, 149
; KHOFMANN START
[VCockpit06]
background_color = 0,0,0
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_7
htmlgauge00 = FSS_B727/EFB/EFBAircraft.html, 0, 0, 840, 1188
texture = $KH_FE_FPLAN_P1
htmlgauge00= FSS_B727/KH_FE_FPLAN/index.html?type=ofp, 0, 0, 840, 1188
emissive = 0
[VCockpit07]
size_mm = 840, 1188
background_color = 0,0,0
size_mm = 210, 297
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_5
htmlgauge00 = FSS_B727/EFB/EFBOptions.html, 0, 0, 840, 1188
texture = $KH_FE_FPLAN_P2
htmlgauge00= FSS_B727/KH_FE_FPLAN/index.html?type=tlr, 0, 0, 840, 1188
emissive = 0
; KHOFMANN END
[VCockpit08]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_4
htmlgauge00 = FSS_B727/EFB/EFBPreflight.html, 0, 0, 840, 1188
emissive = 0
# MSFS 2024
#[VCockpit08]
#size_mm = 840, 1188
#pixel_size = 840, 1188
#texture = $EFB_CLIPBOARD_Screen_6
#htmlgauge00 = FSS_B727/EFB/EFBCharts.html, 0, 0, 840, 1188
#emissive = 0
[VCockpit09]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_3
htmlgauge00 = FSS_B727/EFB/EFBTakeoff.html, 0, 0, 840, 1188
texture = $EFB_CLIPBOARD_Screen_1
htmlgauge00 = FSS_B727/EFB/EFBLanding.html, 0, 0, 840, 1188
emissive = 0
[VCockpit10]
@ -73,36 +78,50 @@ emissive = 0
[VCockpit11]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_1
htmlgauge00 = FSS_B727/EFB/EFBLanding.html, 0, 0, 840, 1188
texture = $EFB_CLIPBOARD_Screen_3
htmlgauge00 = FSS_B727/EFB/EFBTakeoff.html, 0, 0, 840, 1188
emissive = 0
[VCockpit12]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_6
htmlgauge00 = FSS_B727/EFB/EFBCharts.html, 0, 0, 840, 1188
texture = $EFB_CLIPBOARD_Screen_4
htmlgauge00 = FSS_B727/EFB/EFBPreflight.html, 0, 0, 840, 1188
emissive = 0
[VCockpit13]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_5
htmlgauge00 = FSS_B727/EFB/EFBOptions.html, 0, 0, 840, 1188
emissive = 0
[VCockpit14]
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $EFB_CLIPBOARD_Screen_7
htmlgauge00 = FSS_B727/EFB/EFBAircraft.html, 0, 0, 840, 1188
emissive = 0
[VCockpit15]
size_mm = 620, 610
pixel_size = 620, 610
texture = $STBY_ARTIFICIAL_HORIZON_Ball
htmlgauge00 = NavSystems/AS1000_BackupDisplay/Attitude/AS1000_AttitudeBackup.html, 0,0, 620, 610
[VCockpit14]
[VCockpit16]
size_mm = 870, 860
pixel_size = 870, 860
texture = $artificial_horizon_screen_1
htmlgauge00 = FSS_B727/Attitude/AS1000_AttitudeBackup.html, 0,0, 870, 860
[VCockpit15]
[VCockpit17]
size_mm = 870, 860
pixel_size = 870, 860
texture = $artificial_horizon_screen_2
htmlgauge00 = FSS_B727/Attitude/AS1000_AttitudeBackup.html, 0,0, 870, 860
[VCockpit16]
[VCockpit18]
Background_color = 0,0,0
size_mm = 650,768
visible = 0
@ -110,7 +129,7 @@ pixel_size = 650,768
texture = $GTN750_screen
htmlgauge00= FSS_B727/pms50_gtn750_int/gtn750_int.html, 0, 0, 650,768
[VCockpit17]
[VCockpit19]
Background_color = 0,0,0
size_mm = 650,290
visible = 0
@ -118,93 +137,75 @@ pixel_size = 650,290
texture = $GTN650_screen
htmlgauge00= FSS_B727/pms50_gtn750_int/gtn650_int.html?index=2, 0, 0, 650,290
[VCockpit18]
[VCockpit20]
size_mm=0,0
pixel_size=0,0
texture=NO_TEXTURE
background_color=42,42,40
htmlgauge00= FSS_B727/WT/v2/WTT1.html, 0,0,0,0
[VCockpit19]
[VCockpit21]
size_mm=0,0
pixel_size=0,0
texture=NO_TEXTURE
background_color=42,42,40
htmlgauge00= FSS_B727/WT/v2/WTT2.html, 0,0,0,0
[VCockpit20]
[VCockpit22]
size_mm = 836, 646
pixel_size = 0, 0
texture = $GNSXLS_Screen
htmlgauge00= FSS_B727/GNSXLS/GNSXLS.html, 0, 0, 836, 646
[VCockpit21]
[VCockpit23]
size_mm = 660, 1420
pixel_size = 0, 0
texture = $IPHONE_Screen
htmlgauge00= FSS_B727/CrewCoordination/CrewCoordination.html, 0, 0, 660, 1420
[VCockpit22]
[VCockpit24]
size_mm = 650,768
pixel_size = 650,768
texture = $SCREEN_TDSGTNXI750
background_color=0,0,0
htmlgauge00=WasmInstrument/WasmInstrument.html?wasm_module=Gauge/TDSGTNXiGaugeModule.wasm&wasm_gauge=GTNXI750U1, 0,0,650,768
[VCockpit23]
[VCockpit25]
size_mm = 378, 320
pixel_size = 378, 320
texture = $VHFCOMM_Screen_1
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=1&type=com, 0, 0, 378, 320
[VCockpit24]
[VCockpit26]
size_mm = 378, 320
pixel_size = 378, 320
texture = $VHFCOMM_Screen_2
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=2&type=com, 0, 0, 378, 320
[VCockpit25]
[VCockpit27]
size_mm = 378, 320
pixel_size = 378, 320
texture = $NAV_Screen_1
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=1&type=nav, 0, 0, 378, 320
[VCockpit26]
[VCockpit28]
size_mm = 378, 320
pixel_size = 378, 320
texture = $NAV_Screen_2
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=2&type=nav, 0, 0, 378, 320
[VCockpit27]
[VCockpit29]
size_mm = 378, 320
pixel_size = 378, 320
texture = $ADF_Screen_1
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=1&type=adf, 0, 0, 378, 320
[VCockpit28]
[VCockpit30]
size_mm = 378, 320
pixel_size = 378, 320
texture = $ADF_Screen_2
htmlgauge00= FSS_B727/RadioScreens/RadioScreens.html?index=2&type=adf, 0, 0, 378, 320
; KHOFMANN START
[VCockpit29]
background_color = 0,0,0
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $KH_FE_FPLAN_P1
htmlgauge00= FSS_B727/KH_FE_FPLAN/index.html?type=ofp, 0, 0, 840, 1188
emissive = 0
[VCockpit30]
background_color = 0,0,0
size_mm = 840, 1188
pixel_size = 840, 1188
texture = $KH_FE_FPLAN_P2
htmlgauge00= FSS_B727/KH_FE_FPLAN/index.html?type=tlr, 0, 0, 840, 1188
emissive = 0
; KHOFMANN END
[VPainting01]
size_mm = 2048,512
texture = $RegistrationNumber

Some files were not shown because too many files have changed in this diff Show More