Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/input.js
Show First 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | else if (placementSupport.mode === "wall") | ||||
{ | { | ||||
// Fetch an updated list of snapping candidate entities | // Fetch an updated list of snapping candidate entities | ||||
placementSupport.wallSnapEntities = Engine.PickSimilarPlayerEntities( | placementSupport.wallSnapEntities = Engine.PickSimilarPlayerEntities( | ||||
placementSupport.wallSet.templates.tower, | placementSupport.wallSet.templates.tower, | ||||
placementSupport.wallSnapEntitiesIncludeOffscreen, | placementSupport.wallSnapEntitiesIncludeOffscreen, | ||||
true, // require exact template match | true, // require exact template match | ||||
true // include foundations | true // include foundations | ||||
); | ); | ||||
placementSupport.wallSlots = null; | |||||
Freagarach: Is `placementSupport.wallSlots;` the same? | |||||
Done Inline ActionsWould be undefined :) Stan: Would be undefined :) | |||||
Done Inline ActionsYou can define this in placement.js as is the case of other properties. Freagarach: You can define this in `placement.js` as is the case of other properties. | |||||
if (placementSupport.wallSet.templates.towerSlot) | |||||
placementSupport.wallSlots = Engine.GuiInterfaceCall("GetSlots", undefined); | |||||
return Engine.GuiInterfaceCall("SetWallPlacementPreview", { | return Engine.GuiInterfaceCall("SetWallPlacementPreview", { | ||||
"wallSet": placementSupport.wallSet, | "wallSet": placementSupport.wallSet, | ||||
"start": placementSupport.position, | "start": placementSupport.position, | ||||
"end": placementSupport.wallEndPosition, | "end": placementSupport.wallEndPosition, | ||||
"snapEntities": placementSupport.wallSnapEntities, // snapping entities (towers) for starting a wall segment | "snapEntities": placementSupport.wallSnapEntities, // snapping entities (towers) for starting a wall segment | ||||
"snapSlots": placementSupport.wallSlots | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 144 Lines • ▼ Show 20 Lines | var cmd = { | ||||
"autorepair": true, | "autorepair": true, | ||||
"autocontinue": true, | "autocontinue": true, | ||||
"queued": queued, | "queued": queued, | ||||
"entities": selection, | "entities": selection, | ||||
"wallSet": placementSupport.wallSet, | "wallSet": placementSupport.wallSet, | ||||
"pieces": wallPlacementInfo.pieces, | "pieces": wallPlacementInfo.pieces, | ||||
"startSnappedEntity": wallPlacementInfo.startSnappedEnt, | "startSnappedEntity": wallPlacementInfo.startSnappedEnt, | ||||
"endSnappedEntity": wallPlacementInfo.endSnappedEnt, | "endSnappedEntity": wallPlacementInfo.endSnappedEnt, | ||||
"rebuildStartTower": wallPlacementInfo.rebuildStartTower | |||||
}; | }; | ||||
// make sure that there's at least one non-tower entity getting built, to prevent silly edge cases where the start and end | // make sure that there's at least one non-tower entity getting built, to prevent silly edge cases where the start and end | ||||
// point are too close together for the algorithm to place a wall segment inbetween, and only the towers are being previewed | // point are too close together for the algorithm to place a wall segment inbetween, and only the towers are being previewed | ||||
// (this is somewhat non-ideal and hardcode-ish) | // (this is somewhat non-ideal and hardcode-ish) | ||||
var hasWallSegment = false; | var hasWallSegment = false; | ||||
for (let piece of cmd.pieces) | for (let piece of cmd.pieces) | ||||
{ | { | ||||
if (piece.template != cmd.wallSet.templates.tower) // TODO: hardcode-ish :( | if (piece.template != cmd.wallSet.templates.tower) // TODO: hardcode-ish :( | ||||
{ | { | ||||
hasWallSegment = true; | hasWallSegment = true; | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
if (hasWallSegment) | if (hasWallSegment || cmd.rebuildStartTower) | ||||
{ | { | ||||
Engine.PostNetworkCommand(cmd); | Engine.PostNetworkCommand(cmd); | ||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] }); | Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] }); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 304 Lines • ▼ Show 20 Lines | switch (ev.type) | ||||
placementSupport.wallEndPosition = undefined; | placementSupport.wallEndPosition = undefined; | ||||
inputState = INPUT_BUILDING_WALL_CLICK; | inputState = INPUT_BUILDING_WALL_CLICK; | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
placementSupport.Reset(); | placementSupport.Reset(); | ||||
inputState = INPUT_NORMAL; | inputState = INPUT_NORMAL; | ||||
Engine.GuiInterfaceCall("SetSlotVisibility", { "hidden": true }); | |||||
} | } | ||||
} | } | ||||
else | else | ||||
placementSupport.tooltipMessage = translate("Cannot build wall here!"); | placementSupport.tooltipMessage = translate("Cannot build wall here!"); | ||||
updateBuildingPlacementPreview(); | updateBuildingPlacementPreview(); | ||||
return true; | return true; | ||||
} | } | ||||
else if (ev.button == SDL_BUTTON_RIGHT) | else if (ev.button == SDL_BUTTON_RIGHT) | ||||
{ | { | ||||
Engine.GuiInterfaceCall("SetSlotVisibility", { "hidden": true }); | |||||
// reset to normal input mode | // reset to normal input mode | ||||
placementSupport.Reset(); | placementSupport.Reset(); | ||||
updateBuildingPlacementPreview(); | updateBuildingPlacementPreview(); | ||||
inputState = INPUT_NORMAL; | inputState = INPUT_NORMAL; | ||||
return true; | return true; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 393 Lines • ▼ Show 20 Lines | case "mousebuttondown": | ||||
g_DragStart = new Vector2D(ev.x, ev.y); | g_DragStart = new Vector2D(ev.x, ev.y); | ||||
inputState = INPUT_BUILDING_CLICK; | inputState = INPUT_BUILDING_CLICK; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
else if (ev.button == SDL_BUTTON_RIGHT) | else if (ev.button == SDL_BUTTON_RIGHT) | ||||
{ | { | ||||
// Cancel building | // Cancel building | ||||
Engine.GuiInterfaceCall("SetSlotVisibility", { "hidden": true }); | |||||
Done Inline Actions{"player": g_ViewedPlayer, "active": false} → { "player": g_ViewedPlayer, "active": false } Stan: {"player": g_ViewedPlayer, "active": false} → { "player": g_ViewedPlayer, "active": false } | |||||
placementSupport.Reset(); | placementSupport.Reset(); | ||||
inputState = INPUT_NORMAL; | inputState = INPUT_NORMAL; | ||||
return true; | return true; | ||||
} | } | ||||
break; | break; | ||||
case "hotkeydown": | case "hotkeydown": | ||||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Lines | function startBuildingPlacement(buildTemplate, playerState) | ||||
// find out if we're building a wall, and change the entity appropriately if so | // find out if we're building a wall, and change the entity appropriately if so | ||||
var templateData = GetTemplateData(buildTemplate); | var templateData = GetTemplateData(buildTemplate); | ||||
if (templateData.wallSet) | if (templateData.wallSet) | ||||
{ | { | ||||
placementSupport.mode = "wall"; | placementSupport.mode = "wall"; | ||||
placementSupport.wallSet = templateData.wallSet; | placementSupport.wallSet = templateData.wallSet; | ||||
inputState = INPUT_BUILDING_PLACEMENT; | inputState = INPUT_BUILDING_PLACEMENT; | ||||
Engine.GuiInterfaceCall("SetSlotVisibility", { "hidden": false }); | |||||
Done Inline Actions{space space} for JS objects elexis: {space space} for JS objects | |||||
Done Inline Actions{"player": g_ViewedPlayer, "active": true}) → { "player": g_ViewedPlayer, "active": true }) Maybe it could be a function ? Stan: {"player": g_ViewedPlayer, "active": true}) → { "player": g_ViewedPlayer, "active": true })… | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
placementSupport.mode = "building"; | placementSupport.mode = "building"; | ||||
placementSupport.template = buildTemplate; | placementSupport.template = buildTemplate; | ||||
inputState = INPUT_BUILDING_PLACEMENT; | inputState = INPUT_BUILDING_PLACEMENT; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 344 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
Is placementSupport.wallSlots; the same?