Differential D270 Diff 12733 ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
Show All 29 Lines | GuiInterface.prototype.Init = function() | ||||
this.renamedEntities = []; | this.renamedEntities = []; | ||||
this.miragedEntities = []; | this.miragedEntities = []; | ||||
this.timeNotificationID = 1; | this.timeNotificationID = 1; | ||||
this.timeNotifications = []; | this.timeNotifications = []; | ||||
this.entsRallyPointsDisplayed = []; | this.entsRallyPointsDisplayed = []; | ||||
this.entsWithAuraAndStatusBars = new Set(); | this.entsWithAuraAndStatusBars = new Set(); | ||||
this.enabledVisualRangeOverlayTypes = {}; | this.enabledVisualRangeOverlayTypes = {}; | ||||
this.templateModified = {}; | this.templateModified = {}; | ||||
this.selectionDirty = {}; | |||||
this.obstructionSnap = new ObstructionSnap(); | this.obstructionSnap = new ObstructionSnap(); | ||||
}; | }; | ||||
/* | /* | ||||
* All of the functions defined below are called via Engine.GuiInterfaceCall(name, arg) | * All of the functions defined below are called via Engine.GuiInterfaceCall(name, arg) | ||||
* from GUI scripts, and executed here with arguments (player, arg). | * from GUI scripts, and executed here with arguments (player, arg). | ||||
* | * | ||||
* CAUTION: The input to the functions in this module is not network-synchronised, so it | * CAUTION: The input to the functions in this module is not network-synchronised, so it | ||||
▲ Show 20 Lines • Show All 608 Lines • ▼ Show 20 Lines | |||||
/** | /** | ||||
* State of the templateData (player dependent): true when some template values have been modified | * State of the templateData (player dependent): true when some template values have been modified | ||||
* and need to be reloaded by the gui. | * and need to be reloaded by the gui. | ||||
*/ | */ | ||||
GuiInterface.prototype.OnTemplateModification = function(msg) | GuiInterface.prototype.OnTemplateModification = function(msg) | ||||
{ | { | ||||
this.templateModified[msg.player] = true; | this.templateModified[msg.player] = true; | ||||
this.selectionDirty[msg.player] = true; | |||||
}; | }; | ||||
GuiInterface.prototype.IsTemplateModified = function(player) | GuiInterface.prototype.IsTemplateModified = function(player) | ||||
{ | { | ||||
return this.templateModified[player] || false; | return this.templateModified[player] || false; | ||||
}; | }; | ||||
GuiInterface.prototype.ResetTemplateModified = function() | GuiInterface.prototype.ResetTemplateModified = function() | ||||
{ | { | ||||
this.templateModified = {}; | this.templateModified = {}; | ||||
}; | }; | ||||
/** | /** | ||||
* Some changes may require an update to the selection panel, | |||||
* which is cached for efficiency. Inform the GUI it needs reloading. | |||||
*/ | |||||
GuiInterface.prototype.OnDisabledTemplatesChanged = function(msg) | |||||
{ | |||||
this.selectionDirty[msg.player] = true; | |||||
}; | |||||
GuiInterface.prototype.OnDisabledTechnologiesChanged = function(msg) | |||||
{ | |||||
this.selectionDirty[msg.player] = true; | |||||
}; | |||||
GuiInterface.prototype.SetSelectionDirty = function(player) | |||||
{ | |||||
this.selectionDirty[player] = true; | |||||
}; | |||||
GuiInterface.prototype.IsSelectionDirty = function(player) | |||||
{ | |||||
return this.selectionDirty[player] || false; | |||||
}; | |||||
GuiInterface.prototype.ResetSelectionDirty = function() | |||||
{ | |||||
this.selectionDirty = {}; | |||||
}; | |||||
/** | |||||
* Add a timed notification. | * Add a timed notification. | ||||
* Warning: timed notifacations are serialised | * Warning: timed notifacations are serialised | ||||
* (to also display them on saved games or after a rejoin) | * (to also display them on saved games or after a rejoin) | ||||
* so they should allways be added and deleted in a deterministic way. | * so they should allways be added and deleted in a deterministic way. | ||||
*/ | */ | ||||
GuiInterface.prototype.AddTimeNotification = function(notification, duration = 10000) | GuiInterface.prototype.AddTimeNotification = function(notification, duration = 10000) | ||||
{ | { | ||||
let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | let cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); | ||||
▲ Show 20 Lines • Show All 1,303 Lines • ▼ Show 20 Lines | let exposedFunctions = { | ||||
"SetMotionDebugOverlay": 1, | "SetMotionDebugOverlay": 1, | ||||
"SetRangeDebugOverlay": 1, | "SetRangeDebugOverlay": 1, | ||||
"EnableVisualRangeOverlayType": 1, | "EnableVisualRangeOverlayType": 1, | ||||
"SetRangeOverlays": 1, | "SetRangeOverlays": 1, | ||||
"GetTraderNumber": 1, | "GetTraderNumber": 1, | ||||
"GetTradingGoods": 1, | "GetTradingGoods": 1, | ||||
"IsTemplateModified": 1, | "IsTemplateModified": 1, | ||||
"ResetTemplateModified": 1 | "ResetTemplateModified": 1, | ||||
"IsSelectionDirty": 1, | |||||
"ResetSelectionDirty": 1 | |||||
}; | }; | ||||
GuiInterface.prototype.ScriptCall = function(player, name, args) | GuiInterface.prototype.ScriptCall = function(player, name, args) | ||||
{ | { | ||||
if (exposedFunctions[name]) | if (exposedFunctions[name]) | ||||
return this[name](player, args); | return this[name](player, args); | ||||
throw new Error("Invalid GuiInterface Call name \"" + name + "\""); | throw new Error("Invalid GuiInterface Call name \"" + name + "\""); | ||||
}; | }; | ||||
Engine.RegisterSystemComponentType(IID_GuiInterface, "GuiInterface", GuiInterface); | Engine.RegisterSystemComponentType(IID_GuiInterface, "GuiInterface", GuiInterface); |
Wildfire Games · Phabricator