Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 116 Lines • ▼ Show 20 Lines | for (let action of g_BarterActions) | ||||
button[action] = Engine.GetGUIObjectByName("unitBarter" + action + "Button[" + data.i + "]"); | button[action] = Engine.GetGUIObjectByName("unitBarter" + action + "Button[" + data.i + "]"); | ||||
setPanelObjectPosition(button.Sell, data.i, data.rowLength); | setPanelObjectPosition(button.Sell, data.i, data.rowLength); | ||||
setPanelObjectPosition(button.Buy, data.i + data.rowLength, data.rowLength); | setPanelObjectPosition(button.Buy, data.i + data.rowLength, data.rowLength); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Command = { | g_SelectionPanels.Command = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
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... | |||||
{ | { | ||||
return 6; | return 12; | ||||
}, | }, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
let commands = []; | let commands = []; | ||||
Not Done Inline Actions+\n. Freagarach: +`\n`. | |||||
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); | ||||
if (info) | if (info) | ||||
{ | { | ||||
info.name = command; | info.name = command; | ||||
commands.push(info); | commands.push(info); | ||||
} | } | ||||
Show All 15 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 buttonsPerPage = this.getMaxNumberOfItems()/2; | |||||
bbUnsubmitted 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; | ||||
// count on square buttons, so size.bottom is the width too | // count on square buttons, so size.bottom is the width too | ||||
let spacer = size.bottom + 1; | let spacer = size.bottom + 1; | ||||
// 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 | // offset from the center calculation | ||||
size.left = (data.i - data.numberOfItems / 2) * spacer; | size.left = (data.i % buttonsPerPage - Math.min(data.numberOfItems, buttonsPerPage) / 2) * spacer; | ||||
size.right = size.left + size.bottom; | size.right = size.left + size.bottom; | ||||
data.button.size = size; | data.button.size = size; | ||||
data.button.hidden = g_IsFirstCommandPage == (data.i >= this.getMaxNumberOfItems()/2); | |||||
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 ^^ | |||||
let fitsOnePage = data.numberOfItems <= buttonsPerPage; | |||||
if (fitsOnePage) | |||||
g_IsFirstCommandPage = true; | |||||
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… | |||||
Engine.GetGUIObjectByName("unitCommandArrowN").hidden = fitsOnePage || !g_IsFirstCommandPage; | |||||
Engine.GetGUIObjectByName("unitCommandArrowP").hidden = fitsOnePage || g_IsFirstCommandPage; | |||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.AllyCommand = { | g_SelectionPanels.AllyCommand = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 2; | return 2; | ||||
▲ Show 20 Lines • Show All 994 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