Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/session.js
const g_IsReplay = Engine.IsVisualReplay(); | const g_IsReplay = Engine.IsVisualReplay(); | ||||
const g_CivData = loadCivData(false, true); | const g_CivData = loadCivData(false, true); | ||||
const g_Ceasefire = prepareForDropdown(g_Settings && g_Settings.Ceasefire); | const g_Ceasefire = prepareForDropdown(g_Settings && g_Settings.Ceasefire); | ||||
const g_MapSizes = prepareForDropdown(g_Settings && g_Settings.MapSizes); | const g_MapSizes = prepareForDropdown(g_Settings && g_Settings.MapSizes); | ||||
const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes); | const g_MapTypes = prepareForDropdown(g_Settings && g_Settings.MapTypes); | ||||
const g_PopulationCapacities = prepareForDropdown(g_Settings && g_Settings.PopulationCapacities); | const g_PopulationCapacities = prepareForDropdown(g_Settings && g_Settings.PopulationCapacities); | ||||
const g_StartingResources = prepareForDropdown(g_Settings && g_Settings.StartingResources); | const g_StartingResources = prepareForDropdown(g_Settings && g_Settings.StartingResources); | ||||
const g_VictoryDurations = prepareForDropdown(g_Settings && g_Settings.VictoryDurations); | const g_VictoryDurations = prepareForDropdown(g_Settings && g_Settings.VictoryDurations); | ||||
const g_VictoryConditions = g_Settings && g_Settings.VictoryConditions; | const g_VictoryConditions = g_Settings && g_Settings.VictoryConditions; | ||||
var g_Chat; | var g_Chat; | ||||
var g_DeveloperOverlay; | |||||
var g_DiplomacyColors; | var g_DiplomacyColors; | ||||
var g_DiplomacyDialog; | var g_DiplomacyDialog; | ||||
var g_GameSpeedControl; | var g_GameSpeedControl; | ||||
var g_Menu; | var g_Menu; | ||||
var g_MiniMapPanel; | var g_MiniMapPanel; | ||||
var g_ObjectivesDialog; | var g_ObjectivesDialog; | ||||
var g_PauseControl; | var g_PauseControl; | ||||
var g_PauseOverlay; | var g_PauseOverlay; | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
var g_ReplaySelectionData; | var g_ReplaySelectionData; | ||||
/** | /** | ||||
* Remembers which clients are assigned to which player slots. | * Remembers which clients are assigned to which player slots. | ||||
* The keys are guids or "local" in Singleplayer. | * The keys are guids or "local" in Singleplayer. | ||||
*/ | */ | ||||
var g_PlayerAssignments; | var g_PlayerAssignments; | ||||
var g_DeveloperOverlay; | |||||
/** | /** | ||||
* Whether the entire UI should be hidden (useful for promotional screenshots). | * Whether the entire UI should be hidden (useful for promotional screenshots). | ||||
* Can be toggled with a hotkey. | * Can be toggled with a hotkey. | ||||
*/ | */ | ||||
var g_ShowGUI = true; | var g_ShowGUI = true; | ||||
/** | /** | ||||
* Whether status bars should be shown for all of the player's units. | * Whether status bars should be shown for all of the player's units. | ||||
Show All 9 Lines | |||||
var g_TechnologyData = {}; | var g_TechnologyData = {}; | ||||
var g_ResourceData = new Resources(); | var g_ResourceData = new Resources(); | ||||
/** | /** | ||||
* These handlers are called each time a new turn was simulated. | * These handlers are called each time a new turn was simulated. | ||||
* Use this as sparely as possible. | * Use this as sparely as possible. | ||||
*/ | */ | ||||
var g_SimulationUpdateHandlers = []; | var g_SimulationUpdateHandlers = new Set(); | ||||
/** | /** | ||||
* These handlers are called after the player states have been initialized. | * These handlers are called after the player states have been initialized. | ||||
*/ | */ | ||||
var g_PlayersInitHandlers = []; | var g_PlayersInitHandlers = new Set(); | ||||
/** | /** | ||||
* These handlers are called when a player has been defeated or won the game. | * These handlers are called when a player has been defeated or won the game. | ||||
*/ | */ | ||||
var g_PlayerFinishedHandlers = []; | var g_PlayerFinishedHandlers = new Set(); | ||||
/** | /** | ||||
* These events are fired whenever the player added or removed entities from the selection. | * These events are fired whenever the player added or removed entities from the selection. | ||||
*/ | */ | ||||
var g_EntitySelectionChangeHandlers = []; | var g_EntitySelectionChangeHandlers = new Set(); | ||||
/** | /** | ||||
* These events are fired when the user has performed a hotkey assignment change. | * These events are fired when the user has performed a hotkey assignment change. | ||||
* Currently only fired on init, but to be fired from any hotkey editor dialog. | * Currently only fired on init, but to be fired from any hotkey editor dialog. | ||||
*/ | */ | ||||
var g_HotkeyChangeHandlers = []; | var g_HotkeyChangeHandlers = []; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Lines | function init(initData, hotloadData) | ||||
g_PlayerViewControl = new PlayerViewControl(); | g_PlayerViewControl = new PlayerViewControl(); | ||||
g_PlayerViewControl.registerViewedPlayerChangeHandler(g_DiplomacyColors.updateDisplayedPlayerColors.bind(g_DiplomacyColors)); | g_PlayerViewControl.registerViewedPlayerChangeHandler(g_DiplomacyColors.updateDisplayedPlayerColors.bind(g_DiplomacyColors)); | ||||
g_DiplomacyColors.registerDiplomacyColorsChangeHandler(g_PlayerViewControl.rebuild.bind(g_PlayerViewControl)); | g_DiplomacyColors.registerDiplomacyColorsChangeHandler(g_PlayerViewControl.rebuild.bind(g_PlayerViewControl)); | ||||
g_DiplomacyColors.registerDiplomacyColorsChangeHandler(updateGUIObjects); | g_DiplomacyColors.registerDiplomacyColorsChangeHandler(updateGUIObjects); | ||||
g_PlayerViewControl.registerPreViewedPlayerChangeHandler(removeStatusBarDisplay); | g_PlayerViewControl.registerPreViewedPlayerChangeHandler(removeStatusBarDisplay); | ||||
g_PlayerViewControl.registerViewedPlayerChangeHandler(resetTemplates); | g_PlayerViewControl.registerViewedPlayerChangeHandler(resetTemplates); | ||||
g_Chat = new Chat(g_PlayerViewControl); | g_Chat = new Chat(g_PlayerViewControl); | ||||
g_DeveloperOverlay = new DeveloperOverlay(g_PlayerViewControl); | g_DeveloperOverlay = new DeveloperOverlay(g_PlayerViewControl, g_Selection); | ||||
g_DiplomacyDialog = new DiplomacyDialog(g_PlayerViewControl, g_DiplomacyColors); | g_DiplomacyDialog = new DiplomacyDialog(g_PlayerViewControl, g_DiplomacyColors); | ||||
g_GameSpeedControl = new GameSpeedControl(g_PlayerViewControl); | g_GameSpeedControl = new GameSpeedControl(g_PlayerViewControl); | ||||
g_MiniMapPanel = new MiniMapPanel(g_PlayerViewControl, g_DiplomacyColors, g_WorkerTypes); | g_MiniMapPanel = new MiniMapPanel(g_PlayerViewControl, g_DiplomacyColors, g_WorkerTypes); | ||||
g_ObjectivesDialog = new ObjectivesDialog(g_PlayerViewControl); | g_ObjectivesDialog = new ObjectivesDialog(g_PlayerViewControl); | ||||
g_PauseControl = new PauseControl(); | g_PauseControl = new PauseControl(); | ||||
g_PauseOverlay = new PauseOverlay(g_PauseControl); | g_PauseOverlay = new PauseOverlay(g_PauseControl); | ||||
g_Menu = new Menu(g_PauseControl, g_PlayerViewControl, g_Chat); | g_Menu = new Menu(g_PauseControl, g_PlayerViewControl, g_Chat); | ||||
g_TradeDialog = new TradeDialog(g_PlayerViewControl); | g_TradeDialog = new TradeDialog(g_PlayerViewControl); | ||||
Show All 25 Lines | function init(initData, hotloadData) | ||||
// TODO: use event instead | // TODO: use event instead | ||||
onSimulationUpdate(); | onSimulationUpdate(); | ||||
setTimeout(displayGamestateNotifications, 1000); | setTimeout(displayGamestateNotifications, 1000); | ||||
} | } | ||||
function registerPlayersInitHandler(handler) | function registerPlayersInitHandler(handler) | ||||
{ | { | ||||
g_PlayersInitHandlers.push(handler); | g_PlayersInitHandlers.add(handler); | ||||
} | } | ||||
function registerPlayersFinishedHandler(handler) | function registerPlayersFinishedHandler(handler) | ||||
{ | { | ||||
g_PlayerFinishedHandlers.push(handler); | g_PlayerFinishedHandlers.add(handler); | ||||
} | } | ||||
function registerSimulationUpdateHandler(handler) | function registerSimulationUpdateHandler(handler) | ||||
{ | { | ||||
g_SimulationUpdateHandlers.push(handler); | g_SimulationUpdateHandlers.add(handler); | ||||
} | |||||
function unregisterSimulationUpdateHandler(handler) | |||||
{ | |||||
g_SimulationUpdateHandlers.delete(handler); | |||||
} | } | ||||
function registerEntitySelectionChangeHandler(handler) | function registerEntitySelectionChangeHandler(handler) | ||||
{ | { | ||||
g_EntitySelectionChangeHandlers.push(handler); | g_EntitySelectionChangeHandlers.add(handler); | ||||
} | |||||
function unregisterEntitySelectionChangeHandler(handler) | |||||
{ | |||||
g_EntitySelectionChangeHandlers.delete(handler); | |||||
} | } | ||||
function registerHotkeyChangeHandler(handler) | function registerHotkeyChangeHandler(handler) | ||||
{ | { | ||||
g_HotkeyChangeHandlers.push(handler); | g_HotkeyChangeHandlers.push(handler); | ||||
} | } | ||||
function updatePlayerData() | function updatePlayerData() | ||||
▲ Show 20 Lines • Show All 1,061 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator