Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 1,052 Lines • ▼ Show 20 Lines | "set-rallypoint": | ||||
"getActionInfo": function(entState, targetState) | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
if (!entState.rallyPoint) | if (!entState.rallyPoint) | ||||
return false; | return false; | ||||
// Don't allow the rally point to be set on any of the currently selected entities (used for unset) | // Don't allow the rally point to be set on any of the currently selected entities (used for unset) | ||||
// except if the autorallypoint hotkey is pressed and the target can produce entities. | // except if the autorallypoint hotkey is pressed and the target can produce entities. | ||||
if (targetState && (!Engine.HotkeyIsPressed("session.autorallypoint") || | if (targetState && (!Engine.HotkeyIsPressed("session.autorallypoint") || | ||||
!targetState.production || | !targetState.trainer || | ||||
!targetState.production.entities.length)) | !targetState.trainer.entities.length)) | ||||
for (const ent of g_Selection.toList()) | for (const ent of g_Selection.toList()) | ||||
if (targetState.id == ent) | if (targetState.id == ent) | ||||
return false; | return false; | ||||
let tooltip; | let tooltip; | ||||
let disabled = false; | let disabled = false; | ||||
// default to walking there (or attack-walking if hotkey pressed) | // default to walking there (or attack-walking if hotkey pressed) | ||||
let data = { "command": "walk" }; | let data = { "command": "walk" }; | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
} | } | ||||
else if (entState.market && targetState && targetState.market && | else if (entState.market && targetState && targetState.market && | ||||
entState.id != targetState.id && | entState.id != targetState.id && | ||||
(!entState.market.naval || targetState.market.naval) && | (!entState.market.naval || targetState.market.naval) && | ||||
!playerCheck(entState, targetState, ["Enemy"])) | !playerCheck(entState, targetState, ["Enemy"])) | ||||
{ | { | ||||
// Find a trader (if any) that this structure can train. | // Find a trader (if any) that this structure can train. | ||||
let trader; | let trader; | ||||
if (entState.production && entState.production.entities.length) | if (entState.trainer?.entities?.length) | ||||
for (let i = 0; i < entState.production.entities.length; ++i) | for (let i = 0; i < entState.trainer.entities.length; ++i) | ||||
if ((trader = GetTemplateData(entState.production.entities[i]).trader)) | if ((trader = GetTemplateData(entState.trainer.entities[i]).trader)) | ||||
break; | break; | ||||
let traderData = { | let traderData = { | ||||
"firstMarket": entState.id, | "firstMarket": entState.id, | ||||
"secondMarket": targetState.id, | "secondMarket": targetState.id, | ||||
"template": trader | "template": trader | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 620 Lines • ▼ Show 20 Lines | "execute": function(entState) | ||||
// This command button is always disabled. | // This command button is always disabled. | ||||
}, | }, | ||||
"allowedPlayers": ["Ally", "Observer"] | "allowedPlayers": ["Ally", "Observer"] | ||||
}, | }, | ||||
"autoqueue-on": { | "autoqueue-on": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.production || !entState.production.entities.length || entState.production.autoqueue)) | if (entStates.every(entState => !entState.trainer || !entState.trainer.entities.length || entState.production.autoqueue)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueon") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueon") + | ||||
translate("Activate auto-queue for selected structures."), | translate("Activate auto-queue for selected structures."), | ||||
"icon": "autoqueue-on.png", | "icon": "autoqueue-on.png", | ||||
"enabled": true | "enabled": true | ||||
}; | }; | ||||
}, | }, | ||||
"execute": function(entStates) | "execute": function(entStates) | ||||
{ | { | ||||
if (entStates.length) | if (entStates.length) | ||||
turnAutoQueueOn(); | turnAutoQueueOn(); | ||||
}, | }, | ||||
"allowedPlayers": ["Player"] | "allowedPlayers": ["Player"] | ||||
}, | }, | ||||
"autoqueue-off": { | "autoqueue-off": { | ||||
"getInfo": function(entStates) | "getInfo": function(entStates) | ||||
{ | { | ||||
if (entStates.every(entState => !entState.production || !entState.production.entities.length || !entState.production.autoqueue)) | if (entStates.every(entState => !entState.trainer || !entState.trainer.entities.length || !entState.production.autoqueue)) | ||||
return false; | return false; | ||||
return { | return { | ||||
"tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueoff") + | "tooltip": colorizeHotkey("%(hotkey)s" + " ", "session.queueunit.autoqueueoff") + | ||||
translate("Deactivate auto-queue for selected structures."), | translate("Deactivate auto-queue for selected structures."), | ||||
"icon": "autoqueue-off.png", | "icon": "autoqueue-off.png", | ||||
"enabled": true | "enabled": true | ||||
}; | }; | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 133 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator