Index: binaries/data/mods/public/gui/credits/texts/programming.json =================================================================== --- binaries/data/mods/public/gui/credits/texts/programming.json +++ binaries/data/mods/public/gui/credits/texts/programming.json @@ -135,6 +135,7 @@ {"nick": "Louhike"}, {"nick": "lsdh"}, {"nick": "Ludovic", "name": "Ludovic Rousseau"}, + {"nick": "luiko", "name": "Luis Carlos Garcia Barajas"}, {"nick": "madmax", "name": "Abhijit Nandy"}, {"nick": "madpilot", "name": "Guido Falsi"}, {"nick": "m0l0t0ph", "name": "Christoph Gielisch"}, Index: binaries/data/mods/public/gui/session/input.js =================================================================== --- binaries/data/mods/public/gui/session/input.js +++ binaries/data/mods/public/gui/session/input.js @@ -1130,36 +1130,10 @@ if (!controlsPlayer(g_ViewedPlayer)) return false; - // If shift is down, add the order to the unit's order queue instead - // of running it immediately - var orderone = Engine.HotkeyIsPressed("session.orderone"); - var queued = Engine.HotkeyIsPressed("session.queue"); - var target = Engine.GetTerrainAtScreenPoint(ev.x, ev.y); + return handleUnitAction(Engine.GetTerrainAtScreenPoint(ev.x, ev.y), action); +} - if (g_UnitActions[action.type] && g_UnitActions[action.type].execute) - { - let selection = g_Selection.toList(); - if (orderone) - { - // pick the first unit that can do this order. - let unit = selection.find(entity => - ["preSelectedActionCheck", "hotkeyActionCheck", "actionCheck"].some(method => - g_UnitActions[action.type][method] && - g_UnitActions[action.type][method](action.target || undefined, [entity]) - )); - if (unit) - { - selection = [unit]; - g_Selection.removeList(selection); - } - } - return g_UnitActions[action.type].execute(target, action, selection, queued); - } - error("Invalid action.type " + action.type); - return false; -} - function positionUnitsFreehandSelectionMouseMove(ev) { // Converting the input line into a List of points. @@ -1251,18 +1225,42 @@ if (inputState != INPUT_NORMAL) return false; - var fromMinimap = true; - var action = determineAction(undefined, undefined, fromMinimap); + let action = determineAction(undefined, undefined, true); if (!action) return false; - var selection = g_Selection.toList(); + return handleUnitAction(target, action); +} - var queued = Engine.HotkeyIsPressed("session.queue"); - if (g_UnitActions[action.type] && g_UnitActions[action.type].execute) - return g_UnitActions[action.type].execute(target, action, selection, queued); - error("Invalid action.type " + action.type); - return false; +function handleUnitAction(target, action) +{ + // If shift is down, add the order to the unit's order queue instead + // of running it immediately + const orderone = Engine.HotkeyIsPressed("session.orderone"); + let queued = Engine.HotkeyIsPressed("session.queue"); + + if (!g_UnitActions[action.type] || !g_UnitActions[action.type].execute) + { + error("Invalid action.type " + action.type); + return false; + } + + let selection = g_Selection.toList(); + if (orderone) + { + // Pick the first unit that can do this order. + const unit = selection.find(entity => + ["preSelectedActionCheck", "hotkeyActionCheck", "actionCheck"].some(method => + g_UnitActions[action.type][method] && + g_UnitActions[action.type][method](action.target || undefined, [entity]) + )); + if (unit) + { + selection = [unit]; + g_Selection.removeList(selection); + } + } + return g_UnitActions[action.type].execute(target, action, selection, queued); } function getEntityLimitAndCount(playerState, entType)