Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
{ | { | ||||
g_SelectionPanelBarterButtonManager.setViewedPlayer(data.player); | g_SelectionPanelBarterButtonManager.setViewedPlayer(data.player); | ||||
g_SelectionPanelBarterButtonManager.update(); | g_SelectionPanelBarterButtonManager.update(); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
/** | |||||
* The command buttons are grouped by pages the size of this variable. | |||||
bb: maybe these should be moved to the top of the file (not sure for this file), also some jsdocs… | |||||
Not Done Inline ActionsThought I leave them her, because they are only used here... Imarok: Thought I leave them her, because they are only used here... | |||||
*/ | |||||
var g_CommandButtonsPerPage = 6; | |||||
/** | |||||
* The current command buttons page. | |||||
*/ | |||||
var g_OpenCommandPage = 1; | |||||
FreagarachUnsubmitted Not Done Inline Actions+\n. Freagarach: +`\n`. | |||||
g_SelectionPanels.Command = { | g_SelectionPanels.Command = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 6; | return 18; | ||||
}, | }, | ||||
"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 = g_EntityCommands[command].getInfo(unitEntStates); | ||||
Show All 20 Lines | "setupButton": function(data) | ||||
data.button.enabled = | data.button.enabled = | ||||
g_IsObserver && data.item.name == "focus-rally" || | g_IsObserver && data.item.name == "focus-rally" || | ||||
controlsPlayer(data.player) && (data.item.name != "delete" || | controlsPlayer(data.player) && (data.item.name != "delete" || | ||||
data.unitEntStates.some(state => !isUndeletable(state))); | 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 numberOfPages = Math.ceil(data.numberOfItems / g_CommandButtonsPerPage); | |||||
Done Inline Actionsmaybe make a this.itemPages for the 2 bb: maybe make a this.itemPages for the `2` | |||||
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 % g_CommandButtonsPerPage - Math.min(data.numberOfItems, g_CommandButtonsPerPage) / 2) * | ||||
(size.bottom + 1); | |||||
size.right = size.left + size.bottom; | size.right = size.left + size.bottom; | ||||
data.button.size = size; | data.button.size = size; | ||||
if (g_OpenCommandPage > numberOfPages) | |||||
g_OpenCommandPage = numberOfPages; | |||||
Done Inline Actionsthe number of pages could fluctuate over time, and can be 3 to 2 so I guess you mean if (numberOfPages < g_OpenCommandPage) g_OpenCommandPage = max(1, numberOfPages); (not sure if that 1 is required) bb: the number of pages could fluctuate over time, and can be 3 to 2 so I guess you mean
```
if… | |||||
Not Done Inline Actionstrue, I still had only 2 pages in mind ^^ Imarok: true, I still had only 2 pages in mind ^^ | |||||
data.button.hidden = g_OpenCommandPage != Math.ceil((data.i + 1) / g_CommandButtonsPerPage); | |||||
Engine.GetGUIObjectByName("unitCommandArrowN").hidden = g_OpenCommandPage == numberOfPages; | |||||
Engine.GetGUIObjectByName("unitCommandArrowP").hidden = g_OpenCommandPage == 1; | |||||
Done Inline Actionsif there are no pages, at least one of them will bug I guess the max(1,foo) from above should be removed and check for <=1 here bb: if there are no pages, at least one of them will bug
I guess the max(1,foo) from above should… | |||||
Not Done Inline Actions
no pages <=> no items => panel won't be shown
which max? Imarok: > if there are no pages, at least one of them will bug
no pages <=> no items => panel won't be… | |||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.AllyCommand = { | g_SelectionPanels.AllyCommand = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 2; | return 2; | ||||
▲ Show 20 Lines • Show All 1,028 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
maybe these should be moved to the top of the file (not sure for this file), also some jsdocs perhaps