Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/gui/session/selection_panels.js
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Command = { | g_SelectionPanels.Command = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 6; | return 10; | ||||
}, | }, | ||||
"rowLength": 10, | |||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
let commands = []; | let commands = []; | ||||
for (let command in g_EntityCommands) | for (let command in g_EntityCommands) | ||||
{ | { | ||||
let info = getCommandInfo(command, unitEntStates); | let info = getCommandInfo(command, unitEntStates); | ||||
if (info) | if (info) | ||||
Show All 16 Lines | "setupButton": function(data) | ||||
}; | }; | ||||
data.countDisplay.caption = data.item.count || ""; | data.countDisplay.caption = data.item.count || ""; | ||||
data.button.enabled = data.item.enabled == true; | data.button.enabled = data.item.enabled == true; | ||||
data.icon.sprite = "stretched:session/icons/" + data.item.icon; | data.icon.sprite = "stretched:session/icons/" + data.item.icon; | ||||
let size = data.button.size; | setPanelObjectPosition(data.button, data.i + 30, data.rowLength); | ||||
// 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; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Construction = { | g_SelectionPanels.Construction = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 30 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function() | "getItems": function() | ||||
{ | { | ||||
return getAllBuildableEntitiesFromSelection(); | return getAllBuildableEntitiesFromSelection(); | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Gate = { | g_SelectionPanels.Gate = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 30 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
let hideLocked = unitEntStates.every(state => !state.gate || !state.gate.locked); | let hideLocked = unitEntStates.every(state => !state.gate || !state.gate.locked); | ||||
let hideUnlocked = unitEntStates.every(state => !state.gate || state.gate.locked); | let hideUnlocked = unitEntStates.every(state => !state.gate || state.gate.locked); | ||||
if (hideLocked && hideUnlocked) | if (hideLocked && hideUnlocked) | ||||
Show All 25 Lines | "setupButton": function(data) | ||||
setPanelObjectPosition(data.button, data.i + getNumberOfRightPanelButtons(), data.rowLength); | setPanelObjectPosition(data.button, data.i + getNumberOfRightPanelButtons(), data.rowLength); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Pack = { | g_SelectionPanels.Pack = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 30 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
let checks = {}; | let checks = {}; | ||||
for (let state of unitEntStates) | for (let state of unitEntStates) | ||||
{ | { | ||||
if (!state.pack) | if (!state.pack) | ||||
▲ Show 20 Lines • Show All 370 Lines • ▼ Show 20 Lines | for (let tech of data.item.tech.pair ? [data.item.tech.bottom, data.item.tech.top] : [data.item.tech]) | ||||
modifier += "color:0 0 0 127:grayscale:"; | modifier += "color:0 0 0 127:grayscale:"; | ||||
button.tooltip += "\n" + coloredText(translate("Cannot research while upgrading."), "red"); | button.tooltip += "\n" + coloredText(translate("Cannot research while upgrading."), "red"); | ||||
} | } | ||||
if (template.icon) | if (template.icon) | ||||
icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | icon.sprite = modifier + "stretched:session/portraits/" + template.icon; | ||||
setPanelObjectPosition(button, position, data.rowLength); | setPanelObjectPosition(button, position + data.rowLength, data.rowLength); | ||||
// Prepare to handle the top button (if any) | // Prepare to handle the top button (if any) | ||||
position -= data.rowLength; | position -= data.rowLength; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
setPanelObjectPosition(data.button, data.i, data.rowLength); | setPanelObjectPosition(data.button, data.i, data.rowLength); | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Training = { | g_SelectionPanels.Training = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 30 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function() | "getItems": function() | ||||
{ | { | ||||
return getAllTrainableEntitiesFromSelection(); | return getAllTrainableEntitiesFromSelection(); | ||||
}, | }, | ||||
"setupButton": function(data) | "setupButton": function(data) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | "setupButton": function(data) | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
g_SelectionPanels.Upgrade = { | g_SelectionPanels.Upgrade = { | ||||
"getMaxNumberOfItems": function() | "getMaxNumberOfItems": function() | ||||
{ | { | ||||
return 40 - getNumberOfRightPanelButtons(); | return 30 - getNumberOfRightPanelButtons(); | ||||
}, | }, | ||||
"rowLength": 10, | "rowLength": 10, | ||||
"getItems": function(unitEntStates) | "getItems": function(unitEntStates) | ||||
{ | { | ||||
// Interface becomes complicated with multiple different units and this is meant per-entity, so prevent it if the selection has multiple different units. | // Interface becomes complicated with multiple different units and this is meant per-entity, so prevent it if the selection has multiple different units. | ||||
if (unitEntStates.some(state => state.template != unitEntStates[0].template)) | if (unitEntStates.some(state => state.template != unitEntStates[0].template)) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 174 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator