Changeset View
Standalone View
binaries/data/mods/public/simulation/components/GuiInterface.js
Show First 20 Lines • Show All 1,041 Lines • ▼ Show 20 Lines | if (pos) | ||||
// rebuild the renderer when not set (when reading saved game or in case of building update) | // rebuild the renderer when not set (when reading saved game or in case of building update) | ||||
else if (!cmpRallyPointRenderer.IsSet()) | else if (!cmpRallyPointRenderer.IsSet()) | ||||
for (let posi of cmpRallyPoint.GetPositions()) | for (let posi of cmpRallyPoint.GetPositions()) | ||||
cmpRallyPointRenderer.AddPosition({ 'x': posi.x, 'y': posi.z }); | cmpRallyPointRenderer.AddPosition({ 'x': posi.x, 'y': posi.z }); | ||||
cmpRallyPointRenderer.SetDisplayed(true); | cmpRallyPointRenderer.SetDisplayed(true); | ||||
// remember which entities have their rally points displayed so we can hide them again | // remember which entities have their rally points displayed so we can hide them again | ||||
this.entsRallyPointsDisplayed.push(ent); | this.entsRallyPointsDisplayed.push(ent); | ||||
fatherbushido: Is there any reason for choosing 1100 and not 1000 for example? (not that I think that 1000 is… | |||||
Not Done Inline ActionsThat's about the time at a normal turn length where the anim loops twice. Stan: That's about the time at a normal turn length where the anim loops twice. | |||||
Not Done Inline ActionsSo it's related to your animation? fatherbushido: So it's related to your animation?
Could you detail a bit more for my own knowledge? | |||||
} | } | ||||
} | } | ||||
}; | }; | ||||
GuiInterface.prototype.AddTargetMarker = function(player, cmd) | |||||
{ | |||||
let targetMarker = Engine.AddLocalEntity(cmd.template); | |||||
Done Inline ActionsDidn't you already spend quite a lot of time reading the coding conventions? leper: Didn't you already spend quite a lot of time reading the coding conventions? | |||||
Not Done Inline Actionsent seems a more common name than templateMarker, though the latter is legit too. elexis: `ent` seems a more common name than `templateMarker`, though the latter is legit too. | |||||
if (!targetMarker) | |||||
return; | |||||
Not Done Inline ActionsEither don't return anything in both cases or return something in both cases (as in explcitily undefined). elexis: Either don't return anything in both cases or return something in both cases (as in explcitily… | |||||
let cmpPosition = Engine.QueryInterface(targetMarker, IID_Position); | |||||
Done Inline ActionsI could say something, but if you read the other inline comment for this below you might notice that this.targetMarker's existence is questionable. leper: I could say something, but if you read the other inline comment for this below you might notice… | |||||
Done Inline ActionsThat's not how we name variables for components. leper: That's not how we name variables for components. | |||||
Done Inline ActionsOh right duh. It's done that way in some part of this files so I didn't notice it. Stan: Oh right duh. It's done that way in some part of this files so I didn't notice it. | |||||
cmpPosition.JumpTo(cmd.x, cmd.z); | |||||
Done Inline ActionsI think we would want an error in case the template is missing important things we depend on. leper: I think we would want an error in case the template is missing important things we depend on. | |||||
Done Inline ActionsSounds fair. Stan: Sounds fair. | |||||
return targetMarker; | |||||
}; | |||||
Not Done Inline ActionsSo is ownership needed for fogging issues or not? (There are number of loops that iterate through owned entities, but local entities must be excluded (1. by definition and 2. because otherwise stuff would have blown up already on a large scale)) (There is also stuff like) <Visibility> <RetainInFog>true</RetainInFog> elexis: So is ownership needed for fogging issues or not?
(There are number of loops that iterate… | |||||
Done Inline ActionsI guess we need ownership so that it is actually visible in FoW/SoD, right? leper: I guess we need ownership so that it is actually visible in FoW/SoD, right? | |||||
Done Inline ActionsIndeed, else you wouldn't know where you click. Stan: Indeed, else you wouldn't know where you click. | |||||
/** | /** | ||||
* Display the building placement preview. | * Display the building placement preview. | ||||
Not Done Inline ActionsAdding serialized timers for non-serialized entities for fun & profit? elexis: Adding serialized timers for non-serialized entities for fun & profit?
Use a GUI timer that… | |||||
* cmd.template is the name of the entity template, or "" to disable the preview. | * cmd.template is the name of the entity template, or "" to disable the preview. | ||||
* cmd.x, cmd.z, cmd.angle give the location. | * cmd.x, cmd.z, cmd.angle give the location. | ||||
* | * | ||||
* Returns result object from CheckPlacement: | * Returns result object from CheckPlacement: | ||||
* { | * { | ||||
* "success": true iff the placement is valid, else false | * "success": true iff the placement is valid, else false | ||||
Not Done Inline ActionsMissing ;. leper: Missing `;`. | |||||
* "message": message to display in UI for invalid placement, else "" | * "message": message to display in UI for invalid placement, else "" | ||||
* "parameters": parameters to use in the message | * "parameters": parameters to use in the message | ||||
* "translateMessage": localisation info | * "translateMessage": localisation info | ||||
Done Inline ActionsWhy don't you pass the entity id in the data parameter, then you won't run into issues with calling RemoveTargetMarker and then deleting the last set targetMarker instead of the corresponding one. Also not sure why we'd need to know the id to possibly terminate the set timeout, nor why we'd store it, if we never read it. leper: Why don't you pass the entity id in the data parameter, then you won't run into issues with… | |||||
* "translateParameters": localisation info | * "translateParameters": localisation info | ||||
* "pluralMessage": we might return a plural translation instead (optional) | * "pluralMessage": we might return a plural translation instead (optional) | ||||
* "pluralCount": localisation info (optional) | * "pluralCount": localisation info (optional) | ||||
* } | * } | ||||
*/ | */ | ||||
GuiInterface.prototype.SetBuildingPlacementPreview = function(player, cmd) | GuiInterface.prototype.SetBuildingPlacementPreview = function(player, cmd) | ||||
{ | { | ||||
let result = { | let result = { | ||||
▲ Show 20 Lines • Show All 919 Lines • ▼ Show 20 Lines | let exposedFunctions = { | ||||
"GetAvailableFormations": 1, | "GetAvailableFormations": 1, | ||||
"GetFormationRequirements": 1, | "GetFormationRequirements": 1, | ||||
"CanMoveEntsIntoFormation": 1, | "CanMoveEntsIntoFormation": 1, | ||||
"IsFormationSelected": 1, | "IsFormationSelected": 1, | ||||
"GetFormationInfoFromTemplate": 1, | "GetFormationInfoFromTemplate": 1, | ||||
"IsStanceSelected": 1, | "IsStanceSelected": 1, | ||||
"SetSelectionHighlight": 1, | "SetSelectionHighlight": 1, | ||||
Done Inline ActionsI'd put it in the same place as the function itself, not that it really matters, but putting it in some random place seems random. leper: I'd put it in the same place as the function itself, not that it really matters, but putting it… | |||||
"GetAllBuildableEntities": 1, | "GetAllBuildableEntities": 1, | ||||
"SetStatusBars": 1, | "SetStatusBars": 1, | ||||
"GetPlayerEntities": 1, | "GetPlayerEntities": 1, | ||||
"GetNonGaiaEntities": 1, | "GetNonGaiaEntities": 1, | ||||
"DisplayRallyPoint": 1, | "DisplayRallyPoint": 1, | ||||
"AddTargetMarker": 1, | |||||
"SetBuildingPlacementPreview": 1, | "SetBuildingPlacementPreview": 1, | ||||
"SetWallPlacementPreview": 1, | "SetWallPlacementPreview": 1, | ||||
"GetFoundationSnapData": 1, | "GetFoundationSnapData": 1, | ||||
"PlaySound": 1, | "PlaySound": 1, | ||||
"FindIdleUnits": 1, | "FindIdleUnits": 1, | ||||
"HasIdleUnits": 1, | "HasIdleUnits": 1, | ||||
"GetTradingRouteGain": 1, | "GetTradingRouteGain": 1, | ||||
"GetTradingDetails": 1, | "GetTradingDetails": 1, | ||||
"CanAttack": 1, | "CanAttack": 1, | ||||
"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, | "EnableVisualRangeOverlayType": 1, | ||||
"SetRangeOverlays": 1, | "SetRangeOverlays": 1, | ||||
"GetTraderNumber": 1, | "GetTraderNumber": 1, | ||||
"GetTradingGoods": 1, | "GetTradingGoods": 1, | ||||
Done Inline ActionsKeep that trailing comma. leper: Keep that trailing comma. | |||||
}; | }; | ||||
Done Inline ActionsNot sure if that is the right group this should be added to. (Not that the groups make a lot of sense.) leper: Not sure if that is the right group this should be added to. (Not that the groups make a lot of… | |||||
Done Inline ActionsMove it to the same one as the rally point as they seem somewhat related. Stan: Move it to the same one as the rally point as they seem somewhat related. | |||||
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); |
Is there any reason for choosing 1100 and not 1000 for example? (not that I think that 1000 is more beautifull than 1100).