Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 270 Lines • ▼ Show 20 Lines | "hotkeyActionCheck": function(target, selection) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "patrol", | "type": "patrol", | ||||
"cursor": "action-patrol", | "cursor": "action-patrol", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_PATROL || !getActionInfo("patrol", target, selection).possible) | if ( !g_InputEvents.isInsideState("PRESELECTEDACTION.PATROL") || !getActionInfo("patrol", target, selection).possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "patrol", | "type": "patrol", | ||||
"cursor": "action-patrol", | "cursor": "action-patrol", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 37, | "specificness": 37, | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
!targetState.needsRepair && !targetState.foundation || | !targetState.needsRepair && !targetState.foundation || | ||||
!playerCheck(entState, targetState, ["Player", "Ally"])) | !playerCheck(entState, targetState, ["Player", "Ally"])) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_REPAIR) | if (!g_InputEvents.isInsideState("PRESELECTEDACTION.REPAIR")) | ||||
return false; | return false; | ||||
if (getActionInfo("repair", target, selection).possible) | if (getActionInfo("repair", target, selection).possible) | ||||
return { | return { | ||||
"type": "repair", | "type": "repair", | ||||
"cursor": "action-repair", | "cursor": "action-repair", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
"tooltip": tooltip | "tooltip": tooltip | ||||
}; | }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_GARRISON) | if (!g_InputEvents.isInsideState("PRESELECTEDACTION.GARRISON")) | ||||
return false; | return false; | ||||
let actionInfo = getActionInfo("garrison", target, selection); | let actionInfo = getActionInfo("garrison", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return { | return { | ||||
"type": "none", | "type": "none", | ||||
"cursor": "action-garrison-disabled", | "cursor": "action-garrison-disabled", | ||||
"target": null | "target": null | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
!entState.unitAI || !entState.unitAI.canGuard || | !entState.unitAI || !entState.unitAI.canGuard || | ||||
targetState.unitAI && targetState.unitAI.isGuarding) | targetState.unitAI && targetState.unitAI.isGuarding) | ||||
return false; | return false; | ||||
return { "possible": true }; | return { "possible": true }; | ||||
}, | }, | ||||
"preSelectedActionCheck": function(target, selection) | "preSelectedActionCheck": function(target, selection) | ||||
{ | { | ||||
if (preSelectedAction != ACTION_GUARD) | if (!g_InputEvents.isInsideState("PRESELECTEDACTION.GUARD")) | ||||
return false; | return false; | ||||
if (getActionInfo("guard", target, selection).possible) | if (getActionInfo("guard", target, selection).possible) | ||||
return { | return { | ||||
"type": "guard", | "type": "guard", | ||||
"cursor": "action-guard", | "cursor": "action-guard", | ||||
"target": target | "target": target | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 371 Lines • ▼ Show 20 Lines | "getInfo": function(entStates) | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.garrison") + | ||||
translate("Order the selected units to garrison in a building or unit."), | translate("Order the selected units to garrison in a building or unit."), | ||||
"icon": "garrison.png" | "icon": "garrison.png" | ||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | g_InputEvents.SwitchToNextState("PRESELECTEDACTION.GARRISON"); | ||||
preSelectedAction = ACTION_GARRISON; | } | ||||
}, | |||||
}, | }, | ||||
"unload": { | "unload": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => { | if (entStates.every(entState => { | ||||
if (!entState.unitAI || !entState.turretParent) | if (!entState.unitAI || !entState.turretParent) | ||||
return true; | return true; | ||||
Show All 22 Lines | "getInfo": function(entStates) | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.repair") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.repair") + | ||||
translate("Order the selected units to repair a building or mechanical unit."), | translate("Order the selected units to repair a building or mechanical unit."), | ||||
"icon": "repair.png" | "icon": "repair.png" | ||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | g_InputEvents.SwitchToNextState("PRESELECTEDACTION.REPAIR"); | ||||
preSelectedAction = ACTION_REPAIR; | |||||
}, | }, | ||||
}, | }, | ||||
"focus-rally": { | "focus-rally": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.rallyPoint)) | if (entStates.every(entState => !entState.rallyPoint)) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | "getInfo": function(entStates) | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.guard") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.guard") + | ||||
translate("Order the selected units to guard a building or unit."), | translate("Order the selected units to guard a building or unit."), | ||||
"icon": "add-guard.png" | "icon": "add-guard.png" | ||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | g_InputEvents.SwitchToNextState("PRESELECTEDACTION.GUARD"); | ||||
preSelectedAction = ACTION_GUARD; | |||||
}, | }, | ||||
}, | }, | ||||
"remove-guard": { | "remove-guard": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.unitAI || !entState.unitAI.isGuarding)) | if (entStates.every(entState => !entState.unitAI || !entState.unitAI.isGuarding)) | ||||
return false; | return false; | ||||
Show All 36 Lines | "getInfo": function(entStates) | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.patrol") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.patrol") + | ||||
translate("Patrol") + "\n" + | translate("Patrol") + "\n" + | ||||
translate("Attack all encountered enemy units while avoiding buildings."), | translate("Attack all encountered enemy units while avoiding buildings."), | ||||
"icon": "patrol.png" | "icon": "patrol.png" | ||||
}; | }; | ||||
}, | }, | ||||
"execute": function() | "execute": function() | ||||
{ | { | ||||
inputState = INPUT_PRESELECTEDACTION; | g_InputEvents.SwitchToNextState("PRESELECTEDACTION.PATROL"); | ||||
preSelectedAction = ACTION_PATROL; | |||||
}, | }, | ||||
}, | }, | ||||
"share-dropsite": { | "share-dropsite": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
let sharableEntities = entStates.filter( | let sharableEntities = entStates.filter( | ||||
entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | entState => entState.resourceDropsite && entState.resourceDropsite.sharable); | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator