Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/unit_actions.js
Show First 20 Lines • Show All 522 Lines • ▼ Show 20 Lines | "actionCheck": function(target, selection) | ||||
"type": "returnresource", | "type": "returnresource", | ||||
"cursor": actionInfo.cursor, | "cursor": actionInfo.cursor, | ||||
"target": target | "target": target | ||||
}; | }; | ||||
}, | }, | ||||
"specificness": 2, | "specificness": 2, | ||||
}, | }, | ||||
"cancel-setup-trade-route": | |||||
{ | |||||
"execute":function(target, action, selection, queued) | |||||
{ | |||||
Engine.PostNetworkCommand({ | |||||
"type": "cancel-setup-trade-route", | |||||
"entities": selection, | |||||
"target": action.target, | |||||
"queued": queued | |||||
}); | |||||
return true; | |||||
}, | |||||
"getActionInfo": function(entState, targetState) | |||||
{ | |||||
if (targetState.foundation || !entState.trader || !targetState.market || | |||||
playerCheck(entState, targetState, ["Enemy"]) || | |||||
!(targetState.market.land && hasClass(entState, "Organic") || | |||||
targetState.market.naval && hasClass(entState, "Ship"))) | |||||
return false; | |||||
let tradingDetails = Engine.GuiInterfaceCall("GetTradingDetails", { | |||||
"trader": entState.id, | |||||
"target": targetState.id | |||||
}); | |||||
if (!tradingDetails || !tradingDetails.type) | |||||
return false; | |||||
if (tradingDetails.type == "is first" && !tradingDetails.hasBothMarkets) | |||||
return { | |||||
"possible": true, | |||||
"tooltip": translate("This is the origin trade market.\n Right-click to cancel trade route.") | |||||
Freagarach: You can ditch the ` ` after the `\n` :) | |||||
}; | |||||
return false; | |||||
}, | |||||
"actionCheck": function(target, selection) | |||||
{ | |||||
let actionInfo = getActionInfo("cancel-setup-trade-route", target, selection); | |||||
if (!actionInfo.possible) | |||||
return false; | |||||
return { | |||||
"type": "cancel-setup-trade-route", | |||||
"cursor": "action-setup-trade-route-disabled", | |||||
"tooltip": actionInfo.tooltip, | |||||
"target": target | |||||
} | |||||
}, | |||||
"specificness": 2, | |||||
}, | |||||
"setup-trade-route": | "setup-trade-route": | ||||
{ | { | ||||
"execute": function(target, action, selection, queued) | "execute": function(target, action, selection, queued) | ||||
{ | { | ||||
Engine.PostNetworkCommand({ | Engine.PostNetworkCommand({ | ||||
"type": "setup-trade-route", | "type": "setup-trade-route", | ||||
"entities": selection, | "entities": selection, | ||||
"target": action.target, | "target": action.target, | ||||
Show All 30 Lines | "getActionInfo": function(entState, targetState) | ||||
{ | { | ||||
case "is first": | case "is first": | ||||
tooltip = translate("Origin trade market.") + "\n"; | tooltip = translate("Origin trade market.") + "\n"; | ||||
if (tradingDetails.hasBothMarkets) | if (tradingDetails.hasBothMarkets) | ||||
tooltip += sprintf(translate("Gain: %(gain)s"), { | tooltip += sprintf(translate("Gain: %(gain)s"), { | ||||
"gain": getTradingTooltip(tradingDetails.gain) | "gain": getTradingTooltip(tradingDetails.gain) | ||||
}); | }); | ||||
else | else | ||||
tooltip += translate("Right-click on another market to set it as a destination trade market."); | return false; | ||||
break; | break; | ||||
case "is second": | case "is second": | ||||
tooltip = translate("Destination trade market.") + "\n" + | tooltip = translate("Destination trade market.") + "\n" + | ||||
sprintf(translate("Gain: %(gain)s"), { | sprintf(translate("Gain: %(gain)s"), { | ||||
"gain": getTradingTooltip(tradingDetails.gain) | "gain": getTradingTooltip(tradingDetails.gain) | ||||
}); | }); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 1,009 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
You can ditch the after the \n :)