Index: ps/trunk/binaries/data/config/default.cfg =================================================================== --- ps/trunk/binaries/data/config/default.cfg +++ ps/trunk/binaries/data/config/default.cfg @@ -290,6 +290,7 @@ patrol = "P" ; Modifier to patrol a unit repair = "J" ; Modifier to repair when clicking on building/mechanical unit queue = Shift ; Modifier to queue unit orders instead of replacing +orderone = Alt ; Modifier to order only one entity in selection. batchtrain = Shift ; Modifier to train units in batches massbarter = Shift ; Modifier to barter bunch of resources masstribute = Shift ; Modifier to tribute bunch of resources Index: ps/trunk/binaries/data/mods/public/gui/manual/intro.txt =================================================================== --- ps/trunk/binaries/data/mods/public/gui/manual/intro.txt +++ ps/trunk/binaries/data/mods/public/gui/manual/intro.txt @@ -90,6 +90,7 @@ J + Right Click on building: Repair P + Right Click: Patrol Shift + Right Click: Queue the move/build/gather/etc order +Alt + Right Click: Order one unit from the current selection to move/build/gather/etc and unselect it. Used to quickly dispatch units with specific tasks. Shift + Left Click when training units: Add units in batches (the batch size is 5 by default and can be changed in the options) Shift + Left Click or Left Drag over unit on map: Add unit to selection Ctrl + Left Click or Left Drag over unit on map: Remove unit from selection Index: ps/trunk/binaries/data/mods/public/gui/session/input.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/input.js +++ ps/trunk/binaries/data/mods/public/gui/session/input.js @@ -185,10 +185,9 @@ return undefined; } -function getActionInfo(action, target) +function getActionInfo(action, target, selection) { var simState = GetSimState(); - var selection = g_Selection.toList(); // If the selection doesn't exist, no action var entState = GetEntityState(selection[0]); @@ -1136,15 +1135,31 @@ if (!controlsPlayer(g_ViewedPlayer)) return false; - var selection = g_Selection.toList(); - // 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); if (unitActions[action.type] && 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 => + unitActions[action.type][method] && + unitActions[action.type][method](action.target || undefined, [entity]) + )); + if (unit) + { + selection = [unit]; + g_Selection.removeList(selection); + } + } return unitActions[action.type].execute(target, action, selection, queued); + } error("Invalid action.type " + action.type); return false; Index: ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js +++ ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js @@ -68,7 +68,7 @@ }, "actionCheck": function(target, selection) { - if (!someUnitAI(selection) || !getActionInfo("move", target).possible) + if (!someUnitAI(selection) || !getActionInfo("move", target, selection).possible) return false; return { "type": "move" }; @@ -112,7 +112,7 @@ { if (!someUnitAI(selection) || !Engine.HotkeyIsPressed("session.attackmove") || - !getActionInfo("attack-move", target).possible) + !getActionInfo("attack-move", target, selection).possible) return false; return { @@ -155,9 +155,9 @@ }) }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - if (!getActionInfo("capture", target).possible) + if (!getActionInfo("capture", target, selection).possible) return false; return { @@ -201,10 +201,10 @@ }) }; }, - "hotkeyActionCheck": function(target) + "hotkeyActionCheck": function(target, selection) { if (!Engine.HotkeyIsPressed("session.attack") || - !getActionInfo("attack", target).possible) + !getActionInfo("attack", target, selection).possible) return false; return { @@ -213,9 +213,9 @@ "target": target }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - if (!getActionInfo("attack", target).possible) + if (!getActionInfo("attack", target, selection).possible) return false; return { @@ -258,7 +258,7 @@ { if (!someCanPatrol(selection) || !Engine.HotkeyIsPressed("session.patrol") || - !getActionInfo("patrol", target).possible) + !getActionInfo("patrol", target, selection).possible) return false; return { "type": "patrol", @@ -266,9 +266,9 @@ "target": target }; }, - "preSelectedActionCheck": function(target) + "preSelectedActionCheck": function(target, selection) { - if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target).possible) + if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target, selection).possible) return false; return { "type": "patrol", @@ -315,9 +315,9 @@ return { "possible": true }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - if (!getActionInfo("heal", target).possible) + if (!getActionInfo("heal", target, selection).possible) return false; return { @@ -357,12 +357,12 @@ return { "possible": true }; }, - "preSelectedActionCheck": function(target) + "preSelectedActionCheck": function(target, selection) { if (preSelectedAction != ACTION_REPAIR) return false; - if (getActionInfo("repair", target).possible) + if (getActionInfo("repair", target, selection).possible) return { "type": "repair", "cursor": "action-repair", @@ -375,10 +375,10 @@ "target": null }; }, - "hotkeyActionCheck": function(target) + "hotkeyActionCheck": function(target, selection) { if (!Engine.HotkeyIsPressed("session.repair") || - !getActionInfo("repair", target).possible) + !getActionInfo("repair", target, selection).possible) return false; return { @@ -387,9 +387,9 @@ "target": target }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - if (!getActionInfo("repair", target).possible) + if (!getActionInfo("repair", target, selection).possible) return false; return { @@ -433,9 +433,9 @@ "cursor": "action-gather-" + resource }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - let actionInfo = getActionInfo("gather", target); + let actionInfo = getActionInfo("gather", target, selection); if (!actionInfo.possible) return false; @@ -493,9 +493,9 @@ "cursor": "action-return-" + carriedType }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - let actionInfo = getActionInfo("returnresource", target); + let actionInfo = getActionInfo("returnresource", target, selection); if (!actionInfo.possible) return false; @@ -585,9 +585,9 @@ "tooltip": tooltip }; }, - "actionCheck": function(target) + "actionCheck": function(target, selection) { - let actionInfo = getActionInfo("setup-trade-route", target); + let actionInfo = getActionInfo("setup-trade-route", target, selection); if (!actionInfo.possible) return false; @@ -645,12 +645,12 @@ "tooltip": tooltip }; }, - "preSelectedActionCheck": function(target) + "preSelectedActionCheck": function(target, selection) { if (preSelectedAction != ACTION_GARRISON) return false; - let actionInfo = getActionInfo("garrison", target); + let actionInfo = getActionInfo("garrison", target, selection); if (!actionInfo.possible) return { "type": "none", @@ -665,9 +665,9 @@ "target": target }; }, - "hotkeyActionCheck": function(target) + "hotkeyActionCheck": function(target, selection) { - let actionInfo = getActionInfo("garrison", target); + let actionInfo = getActionInfo("garrison", target, selection); if (!Engine.HotkeyIsPressed("session.garrison") || !actionInfo.possible) return false; @@ -710,12 +710,12 @@ return { "possible": true }; }, - "preSelectedActionCheck": function(target) + "preSelectedActionCheck": function(target, selection) { if (preSelectedAction != ACTION_GUARD) return false; - if (getActionInfo("guard", target).possible) + if (getActionInfo("guard", target, selection).possible) return { "type": "guard", "cursor": "action-guard", @@ -728,10 +728,10 @@ "target": null }; }, - "hotkeyActionCheck": function(target) + "hotkeyActionCheck": function(target, selection) { if (!Engine.HotkeyIsPressed("session.guard") || - !getActionInfo("guard", target).possible) + !getActionInfo("guard", target, selection).possible) return false; return { @@ -764,7 +764,7 @@ "hotkeyActionCheck": function(target, selection) { if (!Engine.HotkeyIsPressed("session.guard") || - !getActionInfo("remove-guard", target).possible || + !getActionInfo("remove-guard", target, selection).possible || !someGuarding(selection)) return false; @@ -931,7 +931,7 @@ if (someUnitAI(selection) || !someRallyPoints(selection)) return false; - let actionInfo = getActionInfo("set-rallypoint", target); + let actionInfo = getActionInfo("set-rallypoint", target, selection); if (!actionInfo.possible) return false; @@ -973,7 +973,7 @@ "actionCheck": function(target, selection) { if (someUnitAI(selection) || !someRallyPoints(selection) || - !getActionInfo("unset-rallypoint", target).possible) + !getActionInfo("unset-rallypoint", target, selection).possible) return false; return {