mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Migration to node.js completed
This commit is contained in:
@@ -7,6 +7,7 @@ import { SelectionScroll } from "./controls/selectionscroll";
|
||||
import { Dropdown } from "./controls/dropdown";
|
||||
import { ConnectionStatusPanel } from "./panels/connectionstatuspanel";
|
||||
import { Button } from "./controls/button";
|
||||
import { MissionData } from "./missiondata/missiondata";
|
||||
|
||||
/* TODO: should this be a class? */
|
||||
var map: Map;
|
||||
@@ -19,26 +20,44 @@ var scenarioDropdown: Dropdown;
|
||||
var mapSourceDropdown: Dropdown;
|
||||
var connected: boolean;
|
||||
var connectionStatusPanel: ConnectionStatusPanel;
|
||||
var missionData: MissionData;
|
||||
|
||||
var slowButton: Button;
|
||||
var fastButton: Button;
|
||||
var climbButton: Button;
|
||||
var descendButton: Button;
|
||||
var userVisibilityButton: Button;
|
||||
var aiVisibilityButton: Button;
|
||||
var weaponVisibilityButton: Button;
|
||||
var deadVisibilityButton: Button;
|
||||
|
||||
function setup()
|
||||
{
|
||||
function setup() {
|
||||
/* Initialize */
|
||||
map = new Map('map-container');
|
||||
selectionWheel = new SelectionWheel("selection-wheel");
|
||||
selectionScroll = new SelectionScroll("selection-scroll");
|
||||
unitsManager = new UnitsManager();
|
||||
unitInfoPanel = new UnitInfoPanel("unit-info-panel");
|
||||
scenarioDropdown = new Dropdown("scenario-dropdown", ["Caucasus", "Syria", "Nevada", "Marianas", "South Atlantic", "The channel"], () => {});
|
||||
scenarioDropdown = new Dropdown("scenario-dropdown", ["Caucasus", "Syria", "Nevada", "Marianas", "South Atlantic", "The channel"], () => { });
|
||||
mapSourceDropdown = new Dropdown("map-source-dropdown", map.getLayers(), (option: string) => map.setLayer(option));
|
||||
connectionStatusPanel = new ConnectionStatusPanel("connection-status-panel");
|
||||
slowButton = new Button("slow-button", ["images/buttons/slow.svg"], () => {});
|
||||
fastButton = new Button("fast-button", ["images/buttons/fast.svg"], () => {});
|
||||
climbButton = new Button("climb-button", ["images/buttons/climb.svg"], () => {});
|
||||
descendButton = new Button("descend-button", ["images/buttons/descend.svg"], () => {});
|
||||
missionData = new MissionData();
|
||||
|
||||
/* Unit control buttons */
|
||||
slowButton = new Button("slow-button", ["images/buttons/slow.svg"], () => { getUnitsManager().selectedUnitsChangeSpeed("slow"); });
|
||||
fastButton = new Button("fast-button", ["images/buttons/fast.svg"], () => { getUnitsManager().selectedUnitsChangeSpeed("fast"); });
|
||||
climbButton = new Button("climb-button", ["images/buttons/climb.svg"], () => { getUnitsManager().selectedUnitsChangeAltitude("climb"); });
|
||||
descendButton = new Button("descend-button", ["images/buttons/descend.svg"], () => { getUnitsManager().selectedUnitsChangeAltitude("descend"); });
|
||||
|
||||
/* Visibility buttons */
|
||||
userVisibilityButton = new Button("user-visibility-button", ["images/buttons/user-full.svg", "images/buttons/user-partial.svg", "images/buttons/user-none.svg", "images/buttons/user-hidden.svg"], () => { });
|
||||
aiVisibilityButton = new Button("ai-visibility-button", ["images/buttons/ai-full.svg", "images/buttons/ai-partial.svg", "images/buttons/ai-none.svg", "images/buttons/ai-hidden.svg"], () => { });
|
||||
weaponVisibilityButton = new Button("weapon-visibility-button", ["images/buttons/weapon-partial.svg", "images/buttons/weapon-none.svg", "images/buttons/weapon-hidden.svg"], () => { });
|
||||
deadVisibilityButton = new Button("dead-visibility-button", ["images/buttons/dead.svg", "images/buttons/dead-hidden.svg"], () => { });
|
||||
|
||||
aiVisibilityButton.setState(1);
|
||||
weaponVisibilityButton.setState(1);
|
||||
deadVisibilityButton.setState(1);
|
||||
|
||||
/* Default values */
|
||||
activeCoalition = "blue";
|
||||
@@ -47,62 +66,100 @@ function setup()
|
||||
requestUpdate();
|
||||
}
|
||||
|
||||
function requestUpdate()
|
||||
{
|
||||
function requestUpdate() {
|
||||
getDataFromDCS(update);
|
||||
/* Main update rate = 250ms is minimum time, equal to server update time. */
|
||||
setTimeout(() => requestUpdate(), getConnected() ? 250: 1000);
|
||||
connectionStatusPanel.update(getConnected() );
|
||||
setTimeout(() => requestUpdate(), getConnected() ? 250 : 1000);
|
||||
connectionStatusPanel.update(getConnected());
|
||||
}
|
||||
|
||||
export function update(data: JSON)
|
||||
{
|
||||
export function update(data: JSON) {
|
||||
unitsManager.update(data);
|
||||
missionData.update(data);
|
||||
}
|
||||
|
||||
export function getMap()
|
||||
{
|
||||
export function getMap() {
|
||||
return map;
|
||||
}
|
||||
|
||||
export function getSelectionWheel()
|
||||
{
|
||||
export function getSelectionWheel() {
|
||||
return selectionWheel;
|
||||
}
|
||||
|
||||
export function getSelectionScroll()
|
||||
{
|
||||
export function getSelectionScroll() {
|
||||
return selectionScroll;
|
||||
}
|
||||
|
||||
export function getUnitsManager()
|
||||
{
|
||||
export function getUnitsManager() {
|
||||
return unitsManager;
|
||||
}
|
||||
|
||||
export function getUnitInfoPanel()
|
||||
{
|
||||
export function getUnitInfoPanel() {
|
||||
return unitInfoPanel;
|
||||
}
|
||||
|
||||
export function setActiveCoalition(newActiveCoalition: string)
|
||||
{
|
||||
export function setActiveCoalition(newActiveCoalition: string) {
|
||||
activeCoalition = newActiveCoalition;
|
||||
}
|
||||
|
||||
export function getActiveCoalition()
|
||||
{
|
||||
export function getActiveCoalition() {
|
||||
return activeCoalition;
|
||||
}
|
||||
|
||||
export function setConnected(newConnected: boolean)
|
||||
{
|
||||
export function setConnected(newConnected: boolean) {
|
||||
connected = newConnected
|
||||
}
|
||||
|
||||
export function getConnected()
|
||||
{
|
||||
export function getConnected() {
|
||||
return connected;
|
||||
}
|
||||
|
||||
export function getVisibilitySettings() {
|
||||
var visibility = {
|
||||
user: "",
|
||||
ai: "",
|
||||
weapon: "",
|
||||
dead: ""
|
||||
};
|
||||
|
||||
switch (userVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.user = "full"; break;
|
||||
case 1:
|
||||
visibility.user = "partial"; break;
|
||||
case 2:
|
||||
visibility.user = "none"; break;
|
||||
case 3:
|
||||
visibility.user = "hidden"; break;
|
||||
}
|
||||
|
||||
switch (aiVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.ai = "full"; break;
|
||||
case 1:
|
||||
visibility.ai = "partial"; break;
|
||||
case 2:
|
||||
visibility.ai = "none"; break;
|
||||
case 3:
|
||||
visibility.ai = "hidden"; break;
|
||||
}
|
||||
|
||||
switch (weaponVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.weapon = "partial"; break;
|
||||
case 1:
|
||||
visibility.weapon = "none"; break;
|
||||
case 2:
|
||||
visibility.weapon = "hidden"; break;
|
||||
}
|
||||
|
||||
switch (deadVisibilityButton.getState()) {
|
||||
case 0:
|
||||
visibility.dead = "none"; break;
|
||||
case 1:
|
||||
visibility.dead = "hidden"; break;
|
||||
}
|
||||
return visibility;
|
||||
}
|
||||
|
||||
window.onload = setup;
|
||||
Reference in New Issue
Block a user