Changeset View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
/** | /** | ||||
* Specifies which template should indicate the target location of a player command, | * Specifies which template should indicate the target location of a player command, | ||||
* given a command type. | * given a command type. | ||||
*/ | */ | ||||
var g_TargetMarker = { | var g_TargetMarker = { | ||||
"move": "special/target_marker" | "move": "special/target_marker" | ||||
}; | }; | ||||
/** | /** | ||||
* Which enemy entity types will be attacked on sight when patroling. | * Which enemy entity types will be attacked on sight when patroling. | ||||
*/ | */ | ||||
var g_PatrolTargets = ["Unit"]; | var g_PatrolTargets = ["Unit"]; | ||||
/** | /** | ||||
elexis: Color -> Tags as it may equally contain Font changes | |||||
* List of different actions units can execute, | * List of different actions units can execute, | ||||
* this is mostly used to determine which actions can be executed | * this is mostly used to determine which actions can be executed | ||||
* | * | ||||
* "execute" is meant to send the command to the engine | * "execute" is meant to send the command to the engine | ||||
* | * | ||||
* The next functions will always return false | * The next functions will always return false | ||||
* in case you have to continue to seek | * in case you have to continue to seek | ||||
* (i.e. look at the next entity for getActionInfo, the next | * (i.e. look at the next entity for getActionInfo, the next | ||||
▲ Show 20 Lines • Show All 550 Lines • ▼ Show 20 Lines | "getActionInfo": function(entState, targetState) | ||||
}); | }); | ||||
break; | break; | ||||
case "set first": | case "set first": | ||||
tooltip = translate("Right-click to set as origin trade market"); | tooltip = translate("Right-click to set as origin trade market"); | ||||
break; | break; | ||||
case "set second": | case "set second": | ||||
if (tradingDetails.gain.traderGain == 0) // markets too close | if (tradingDetails.gain.traderGain == 0) // markets too close | ||||
return false; | tooltip = translate("Market is too close to first one.\nRight-click to cancel setting of trading route.") | ||||
StanUnsubmitted Not Done Inline ActionsI believe you can remove 'setting of' Stan: I believe you can remove 'setting of' | |||||
StanUnsubmitted Not Done Inline Actions"Market is too close to the first one.\n Right-click to cancel." Stan: "Market is too close to the first one.\n Right-click to cancel." | |||||
Not Done Inline Actions(I've seen value == 0 being changed to !value in d2470, not that it matters) elexis: (I've seen value == 0 being changed to !value in d2470, not that it matters) | |||||
else | |||||
tooltip = translate("Right-click to set as destination trade market.") + "\n" + | tooltip = translate("Right-click to set as destination trade market.") + "\n" + | ||||
sprintf(translate("Gain: %(gain)s"), { | sprintf(translate("Gain: %(gain)s"), { | ||||
"gain": getTradingTooltip(tradingDetails.gain) | "gain": getTradingTooltip(tradingDetails.gain) | ||||
}); | }); | ||||
break; | break; | ||||
} | } | ||||
return { | return { | ||||
"possible": true, | "possible": true, | ||||
FreagarachUnsubmitted Not Done Inline ActionsBut it still returns true then? Freagarach: But it still returns `true` then? | |||||
SilierAuthorUnsubmitted Done Inline Actionsyes, esle it would not display. Silier: yes, esle it would not display.
its similar to trying set the same market twice, it will not… | |||||
FreagarachUnsubmitted Not Done Inline ActionsOkay, but what happens if you return "possible": false here? The icon/tooltip do not show up at all? Freagarach: Okay, but what happens if you return `"possible": false` here? The icon/tooltip do not show up… | |||||
"tooltip": tooltip | "tooltip": tooltip | ||||
}; | }; | ||||
}, | }, | ||||
"actionCheck": function(target, selection) | "actionCheck": function(target, selection) | ||||
{ | { | ||||
let actionInfo = getActionInfo("setup-trade-route", target, selection); | let actionInfo = getActionInfo("setup-trade-route", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "setup-trade-route", | "type": "setup-trade-route", | ||||
"cursor": "action-setup-trade-route", | "cursor": "action-setup-trade-route", | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"target": target | "target": target | ||||
Not Done Inline Actions(Not a fan of trailing commas, I've used them once and not seen any reward, but thats subjective) elexis: (Not a fan of trailing commas, I've used them once and not seen any reward, but thats… | |||||
Not Done Inline ActionsIt's in the cc now apparently https://trac.wildfiregames.com/wiki/Coding_Conventions?action=diff&version=46 Stan: It's in the cc now apparently https://trac.wildfiregames.com/wiki/Coding_Conventions? | |||||
Done Inline Actionsbecause one does not have to edit that last line if he wants to add new propperty after that Silier: because one does not have to edit that last line if he wants to add new propperty after that | |||||
Not Done Inline ActionsThe argument for not adding it is that a comma is a separator between two items, but the trailing comma does not separate two items, so it seems contradictory to that definition to me. (Its not the definition since the JS syntax allows it with an explicit exception.) I didn't know we can just edit the CC, I could have won many arguments based on what the CC says if Id just edit it beforehand :p I don't mind how you write your patches with this not so relevant syntax change, but if you add something to the CC you also impose how other people should write their patches, so I suppose it necessitates consensus, no? elexis: The argument for not adding it is that a comma is a separator between two items, but the… | |||||
Not Done Inline ActionsThen L596 also ;) Freagarach: Then L596 also ;) | |||||
}; | }; | ||||
}, | }, | ||||
"specificness": 0, | "specificness": 0, | ||||
}, | }, | ||||
"garrison": | "garrison": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
▲ Show 20 Lines • Show All 330 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
return false; | return false; | ||||
let actionInfo = getActionInfo("set-rallypoint", target, selection); | let actionInfo = getActionInfo("set-rallypoint", target, selection); | ||||
if (!actionInfo.possible) | if (!actionInfo.possible) | ||||
return false; | return false; | ||||
return { | return { | ||||
"type": "set-rallypoint", | "type": "set-rallypoint", | ||||
"cursor": actionInfo.cursor, | "cursor": actionInfo.cursor, | ||||
Not Done Inline Actions(Just wondering if there is a use case to distinguish undefined from null, I've never seen a use case where the distinction mattered, and not distinguishing falsy values allow for simpler falsy checks, or only distinguishing undefined from 0/emptystring, but doesn't matter) elexis: (Just wondering if there is a use case to distinguish undefined from null, I've never seen a… | |||||
Done Inline Actionsi used null because L391, havent look further Silier: i used null because L391, havent look further | |||||
"data": actionInfo.data, | "data": actionInfo.data, | ||||
"tooltip": actionInfo.tooltip, | "tooltip": actionInfo.tooltip, | ||||
"position": actionInfo.position | "position": actionInfo.position | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 6, | "specificness": 6, | ||||
}, | }, | ||||
▲ Show 20 Lines • Show All 580 Lines • Show Last 20 Lines |
Color -> Tags as it may equally contain Font changes