Differential D238 Diff 1678 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 27 Lines | GuiInterface.prototype.Init = function() | ||||
this.placementWallLastAngle = 0; | this.placementWallLastAngle = 0; | ||||
this.notifications = []; | this.notifications = []; | ||||
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 = {}; | |||||
}; | }; | ||||
/* | /* | ||||
* 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 | ||||
* mustn't affect the simulation state (i.e. the data that is serialised and can affect | * mustn't affect the simulation state (i.e. the data that is serialised and can affect | ||||
▲ Show 20 Lines • Show All 846 Lines • ▼ Show 20 Lines | if (!color) | ||||
color = { "r":1, "g":1, "b":1 }; | color = { "r":1, "g":1, "b":1 }; | ||||
let cmpPlayer = QueryPlayerIDInterface(owner); | let cmpPlayer = QueryPlayerIDInterface(owner); | ||||
if (cmpPlayer) | if (cmpPlayer) | ||||
color = cmpPlayer.GetColor(); | color = cmpPlayer.GetColor(); | ||||
playerColors[owner] = color; | playerColors[owner] = color; | ||||
} | } | ||||
cmpSelectable.SetSelectionHighlight({ "r": color.r, "g": color.g, "b": color.b, "a": cmd.alpha }, cmd.selected); | cmpSelectable.SetSelectionHighlight({ "r": color.r, "g": color.g, "b": color.b, "a": cmd.alpha }, cmd.selected); | ||||
let cmpRangeVisualization = Engine.QueryInterface(ent, IID_RangeVisualization); | |||||
if (!cmpRangeVisualization || player != owner && player != -1) | |||||
continue; | |||||
cmpRangeVisualization.SetEnabled(cmd.selected, this.enabledVisualRangeOverlayTypes); | |||||
} | } | ||||
}; | }; | ||||
GuiInterface.prototype.EnableVisualRangeOverlayType = function(player, data) | |||||
{ | |||||
this.enabledVisualRangeOverlayTypes[data.type] = data.enabled; | |||||
}; | |||||
GuiInterface.prototype.GetEntitiesWithStatusBars = function() | GuiInterface.prototype.GetEntitiesWithStatusBars = function() | ||||
{ | { | ||||
return [...this.entsWithAuraAndStatusBars]; | return [...this.entsWithAuraAndStatusBars]; | ||||
}; | }; | ||||
GuiInterface.prototype.SetStatusBars = function(player, cmd) | GuiInterface.prototype.SetStatusBars = function(player, cmd) | ||||
{ | { | ||||
let affectedEnts = new Set(); | let affectedEnts = new Set(); | ||||
Show All 24 Lines | GuiInterface.prototype.SetStatusBars = function(player, cmd) | ||||
for (let ent of affectedEnts) | for (let ent of affectedEnts) | ||||
{ | { | ||||
let cmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars); | let cmpStatusBars = Engine.QueryInterface(ent, IID_StatusBars); | ||||
if (cmpStatusBars) | if (cmpStatusBars) | ||||
cmpStatusBars.RegenerateSprites(); | cmpStatusBars.RegenerateSprites(); | ||||
} | } | ||||
}; | }; | ||||
GuiInterface.prototype.SetRangeOverlays = function(player, cmd) | |||||
{ | |||||
for (let ent of cmd.entities) | |||||
{ | |||||
let cmpRangeVisualization = Engine.QueryInterface(ent, IID_RangeVisualization); | |||||
if (cmpRangeVisualization) | |||||
cmpRangeVisualization.SetEnabled(cmd.enabled, this.enabledVisualRangeOverlayTypes); | |||||
} | |||||
}; | |||||
GuiInterface.prototype.GetPlayerEntities = function(player) | GuiInterface.prototype.GetPlayerEntities = function(player) | ||||
{ | { | ||||
return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetEntitiesByPlayer(player); | return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetEntitiesByPlayer(player); | ||||
}; | }; | ||||
GuiInterface.prototype.GetNonGaiaEntities = function() | GuiInterface.prototype.GetNonGaiaEntities = function() | ||||
{ | { | ||||
return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities(); | return Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager).GetNonGaiaEntities(); | ||||
▲ Show 20 Lines • Show All 1,063 Lines • ▼ Show 20 Lines | let exposedFunctions = { | ||||
"GetBatchTime": 1, | "GetBatchTime": 1, | ||||
"IsMapRevealed": 1, | "IsMapRevealed": 1, | ||||
"SetPathfinderDebugOverlay": 1, | "SetPathfinderDebugOverlay": 1, | ||||
"SetPathfinderHierDebugOverlay": 1, | "SetPathfinderHierDebugOverlay": 1, | ||||
"SetObstructionDebugOverlay": 1, | "SetObstructionDebugOverlay": 1, | ||||
"SetMotionDebugOverlay": 1, | "SetMotionDebugOverlay": 1, | ||||
"SetRangeDebugOverlay": 1, | "SetRangeDebugOverlay": 1, | ||||
"EnableVisualRangeOverlayType": 1, | |||||
"SetRangeOverlays": 1, | |||||
"GetTraderNumber": 1, | "GetTraderNumber": 1, | ||||
"GetTradingGoods": 1, | "GetTradingGoods": 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); | ||||
else | else | ||||
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