Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | g_SelectionPanels.Alert = { | ||||
}, | }, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
return unitEntStates.some(state => !!state.alertRaiser) ? ["raise", "end"] : []; | return unitEntStates.some(state => !!state.alertRaiser) ? ["raise", "end"] : []; | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
data.button.onPress = function() { | data.button.onPress = function() { | ||||
switch (data.item) | switch (data.item) | ||||
Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case "raise": | case "raise": | ||||
raiseAlert(); | raiseAlert(); | ||||
return; | return; | ||||
case "end": | case "end": | ||||
endOfAlert(); | endOfAlert(); | ||||
return; | return; | ||||
} | } | ||||
}; | }; | ||||
switch (data.item) | switch (data.item) | ||||
Lint: ESLintBear (default-case) Expected a default case. Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case "raise": | case "raise": | ||||
data.icon.sprite = "stretched:session/icons/bell_level1.png"; | data.icon.sprite = "stretched:session/icons/bell_level1.png"; | ||||
data.button.tooltip = translate("Raise an alert!"); | data.button.tooltip = translate("Raise an alert!"); | ||||
break; | break; | ||||
case "end": | case "end": | ||||
data.button.tooltip = translate("End of alert."); | data.button.tooltip = translate("End of alert."); | ||||
data.icon.sprite = "stretched:session/icons/bell_level0.png"; | data.icon.sprite = "stretched:session/icons/bell_level0.png"; | ||||
Show All 37 Lines | "getMaxNumberOfItems": function() | ||||
return 6; | return 6; | ||||
}, | }, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
let commands = []; | let commands = []; | ||||
for (let command in g_EntityCommands) | for (let command in g_EntityCommands) | ||||
{ | { | ||||
let info = g_EntityCommands[command].getInfo(unitEntStates); | let info = getCommandInfo(command, unitEntStates); | ||||
if (info) | if (info) | ||||
{ | { | ||||
info.name = command; | info.name = command; | ||||
commands.push(info); | commands.push(info); | ||||
} | } | ||||
} | } | ||||
return commands; | return commands; | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
data.button.tooltip = data.item.tooltip; | data.button.tooltip = data.item.tooltip; | ||||
data.button.onPress = function() { | data.button.onPress = function() { | ||||
if (data.item.callback) | if (data.item.callback) | ||||
data.item.callback(data.item); | data.item.callback(data.item); | ||||
else | else | ||||
performCommand(data.unitEntStates, data.item.name); | performCommand(data.unitEntStates, data.item.name); | ||||
}; | }; | ||||
data.countDisplay.caption = data.item.count || ""; | data.countDisplay.caption = data.item.count || ""; | ||||
data.button.enabled = | data.button.enabled = data.item.enabled == true; | ||||
Done Inline ActionsCould be deleted now, since the button is not visible. Freagarach: Could be deleted now, since the button is not visible. | |||||
Not Done Inline ActionsCan it be undefined? Stan: Can it be undefined? | |||||
Not Done Inline ActionsTheoretically, yes. Freagarach: Theoretically, yes. | |||||
g_IsObserver && data.item.name == "focus-rally" || | |||||
controlsPlayer(data.player) && (data.item.name != "delete" || | |||||
data.unitEntStates.some(state => !isUndeletable(state))); | |||||
data.icon.sprite = "stretched:session/icons/" + data.item.icon; | data.icon.sprite = "stretched:session/icons/" + data.item.icon; | ||||
let size = data.button.size; | let size = data.button.size; | ||||
// relative to the center ( = 50%) | // relative to the center ( = 50%) | ||||
size.rleft = 50; | size.rleft = 50; | ||||
size.rright = 50; | size.rright = 50; | ||||
// offset from the center calculation, count on square buttons, so size.bottom is the width too | // offset from the center calculation, count on square buttons, so size.bottom is the width too | ||||
size.left = (data.i - data.numberOfItems / 2) * (size.bottom + 1); | size.left = (data.i - data.numberOfItems / 2) * (size.bottom + 1); | ||||
size.right = size.left + size.bottom; | size.right = size.left + size.bottom; | ||||
data.button.size = size; | data.button.size = size; | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.AllyCommand = { | |||||
"getMaxNumberOfItems": function() | |||||
{ | |||||
return 2; | |||||
}, | |||||
"conflictsWith": ["Command"], | |||||
"getItems": function(unitEntStates) | |||||
{ | |||||
let commands = []; | |||||
for (let command in g_AllyEntityCommands) | |||||
for (let state of unitEntStates) | |||||
{ | |||||
let info = g_AllyEntityCommands[command].getInfo(state); | |||||
if (info) | |||||
{ | |||||
info.name = command; | |||||
commands.push(info); | |||||
break; | |||||
} | |||||
} | |||||
return commands; | |||||
}, | |||||
"setupButton": function(data) | |||||
{ | |||||
data.button.tooltip = data.item.tooltip; | |||||
data.button.onPress = function() { | |||||
if (data.item.callback) | |||||
data.item.callback(data.item); | |||||
else | |||||
performAllyCommand(data.unitEntStates[0].id, data.item.name); | |||||
}; | |||||
data.countDisplay.caption = data.item.count || ""; | |||||
data.button.enabled = !!data.item.count; | |||||
let grayscale = data.button.enabled ? "" : "grayscale:"; | |||||
data.icon.sprite = "stretched:" + grayscale + "session/icons/" + data.item.icon; | |||||
let size = data.button.size; | |||||
// relative to the center ( = 50%) | |||||
size.rleft = 50; | |||||
size.rright = 50; | |||||
// offset from the center calculation, count on square buttons, so size.bottom is the width too | |||||
size.left = (data.i - data.numberOfItems / 2) * (size.bottom + 1); | |||||
size.right = size.left + size.bottom; | |||||
data.button.size = size; | |||||
return true; | |||||
} | |||||
}; | |||||
g_SelectionPanels.Construction = { | g_SelectionPanels.Construction = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 40 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function() | "getItems": function() | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 517 Lines • ▼ Show 20 Lines | for (let tech of data.item.tech.pair ? [data.item.tech.bottom, data.item.tech.top] : [data.item.tech]) | ||||
{ | { | ||||
if (!req.entities) | if (!req.entities) | ||||
continue; | continue; | ||||
let entityCounts = []; | let entityCounts = []; | ||||
for (let entity of req.entities) | for (let entity of req.entities) | ||||
{ | { | ||||
let current = 0; | let current = 0; | ||||
switch (entity.check) | switch (entity.check) | ||||
Lint: ESLintBear (default-case) Expected a default case. Lint: ESLintBear (default-case): `Expected a default case.` | |||||
{ | { | ||||
case "count": | case "count": | ||||
current = playerState.classCounts[entity.class] || 0; | current = playerState.classCounts[entity.class] || 0; | ||||
break; | break; | ||||
case "variants": | case "variants": | ||||
current = playerState.typeCountsByClass[entity.class] ? | current = playerState.typeCountsByClass[entity.class] ? | ||||
Object.keys(playerState.typeCountsByClass[entity.class]).length : 0; | Object.keys(playerState.typeCountsByClass[entity.class]).length : 0; | ||||
Show All 18 Lines | for (let tech of data.item.tech.pair ? [data.item.tech.bottom, data.item.tech.top] : [data.item.tech]) | ||||
} | } | ||||
tooltips.push(getNeededResourcesTooltip(neededResources)); | tooltips.push(getNeededResourcesTooltip(neededResources)); | ||||
button.tooltip = tooltips.filter(tip => tip).join("\n"); | button.tooltip = tooltips.filter(tip => tip).join("\n"); | ||||
button.onPress = (t => function() { | button.onPress = (t => function() { | ||||
addResearchToQueue(data.item.researchFacilityId, t); | addResearchToQueue(data.item.researchFacilityId, t); | ||||
})(tech); | })(tech); | ||||
let showTemplateFunc = (t => function() { | let showTemplateFunc = (t => function() { | ||||
Lint: ESLintBear (no-multi-spaces) Multiple spaces found before '('. Lint: ESLintBear (no-multi-spaces): `Multiple spaces found before '('.` | |||||
showTemplateDetails( | showTemplateDetails( | ||||
t, | t, | ||||
GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); | GetTemplateData(data.unitEntStates.find(state => state.id == data.item.researchFacilityId).template).nativeCiv); | ||||
}); | }); | ||||
button.onPressRight = showTemplateFunc(tech); | button.onPressRight = showTemplateFunc(tech); | ||||
button.onPressRightDisabled = showTemplateFunc(tech); | button.onPressRightDisabled = showTemplateFunc(tech); | ||||
▲ Show 20 Lines • Show All 441 Lines • ▼ Show 20 Lines | let g_PanelsOrder = [ | ||||
"Pack", // Must always be shown on packable entities | "Pack", // Must always be shown on packable entities | ||||
"Upgrade", // Must always be shown on upgradable entities | "Upgrade", // Must always be shown on upgradable entities | ||||
"Training", | "Training", | ||||
"Construction", | "Construction", | ||||
"Research", // Normal together with training | "Research", // Normal together with training | ||||
// UNIQUE PANES (importance doesn't matter) | // UNIQUE PANES (importance doesn't matter) | ||||
"Command", | "Command", | ||||
"AllyCommand", | |||||
"Queue", | "Queue", | ||||
"Selection", | "Selection", | ||||
]; | ]; |
Wildfire Games · Phabricator
Expected a default case.