From 4b8c82bbcbebe00dce8f29ccad6234f3f4e80305 Mon Sep 17 00:00:00 2001 From: Angen Date: Sat, 7 Dec 2019 18:42:26 +0000 Subject: [PATCH] Allow to play different sound when building new structure and when repairing existing structure Entities have different sound entries for build and repair orders in templates but currently only one is used. This patch is using build order for foundations and repair order for anything else. Also playing correctly order_build when placing new construction. Differential Revision: https://code.wildfiregames.com/D2276 Fixes: #5374 Reviewed by: @Freagarach This was SVN commit r23221. --- .../data/mods/public/gui/session/input.js | 4 +-- .../mods/public/gui/session/unit_actions.js | 25 +++++++++++++------ .../templates/template_unit_infantry.xml | 1 + .../templates/template_unit_support_slave.xml | 1 + 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index f913e1dd44..a138dd4d68 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -310,7 +310,7 @@ function tryPlaceBuilding(queued) "autocontinue": true, "queued": queued }); - Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] }); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] }); if (!queued) placementSupport.Reset(); @@ -367,7 +367,7 @@ function tryPlaceWall(queued) if (hasWallSegment) { Engine.PostNetworkCommand(cmd); - Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] }); + Engine.GuiInterfaceCall("PlaySound", { "name": "order_build", "entity": selection[0] }); } return true; diff --git a/binaries/data/mods/public/gui/session/unit_actions.js b/binaries/data/mods/public/gui/session/unit_actions.js index 5735700497..f931a01b14 100644 --- a/binaries/data/mods/public/gui/session/unit_actions.js +++ b/binaries/data/mods/public/gui/session/unit_actions.js @@ -351,7 +351,7 @@ var g_UnitActions = }); Engine.GuiInterfaceCall("PlaySound", { - "name": "order_repair", + "name": action.foundation ? "order_build" : "order_repair", "entity": selection[0] }); @@ -364,18 +364,23 @@ var g_UnitActions = !playerCheck(entState, targetState, ["Player", "Ally"])) return false; - return { "possible": true }; + return { + "possible": true, + "foundation": targetState.foundation + }; }, "preSelectedActionCheck": function(target, selection) { if (preSelectedAction != ACTION_REPAIR) return false; - if (getActionInfo("repair", target, selection).possible) + let actionInfo = getActionInfo("repair", target, selection); + if (actionInfo.possible) return { "type": "repair", "cursor": "action-repair", - "target": target + "target": target, + "foundation": actionInfo.foundation }; return { @@ -386,25 +391,29 @@ var g_UnitActions = }, "hotkeyActionCheck": function(target, selection) { + let actionInfo = getActionInfo("repair", target, selection); if (!Engine.HotkeyIsPressed("session.repair") || - !getActionInfo("repair", target, selection).possible) + !actionInfo.possible) return false; return { "type": "repair", "cursor": "action-repair", - "target": target + "target": target, + "foundation": actionInfo.foundation }; }, "actionCheck": function(target, selection) { - if (!getActionInfo("repair", target, selection).possible) + let actionInfo = getActionInfo("repair", target, selection); + if (!actionInfo.possible) return false; return { "type": "repair", "cursor": "action-repair", - "target": target + "target": target, + "foundation": actionInfo.foundation }; }, "specificness": 11, diff --git a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml index 2e00771af7..1f742912c8 100644 --- a/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml +++ b/binaries/data/mods/public/simulation/templates/template_unit_infantry.xml @@ -106,6 +106,7 @@ voice/{lang}/civ/civ_{phenotype}_attack.xml voice/{lang}/civ/civ_{phenotype}_gather.xml voice/{lang}/civ/civ_{phenotype}_repair.xml + voice/{lang}/civ/civ_{phenotype}_build.xml voice/{lang}/civ/civ_{phenotype}_garrison.xml actor/human/movement/walk.xml actor/human/movement/run.xml diff --git a/binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml b/binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml index 70b6e64f93..28f992d0d1 100644 --- a/binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml +++ b/binaries/data/mods/public/simulation/templates/template_unit_support_slave.xml @@ -69,6 +69,7 @@ voice/{lang}/civ/civ_{phenotype}_walk.xml voice/{lang}/civ/civ_{phenotype}_gather.xml voice/{lang}/civ/civ_{phenotype}_repair.xml + voice/{lang}/civ/civ_{phenotype}_build.xml voice/{lang}/civ/civ_{phenotype}_garrison.xml actor/human/movement/walk.xml actor/human/movement/run.xml