mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-18 06:13:55 -07:00
It is possible to modify sizes by setting the properties directly. (Without having to create a copy of it) This allows to shorten those passages quite a bit without any functional change.
40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
/**
|
|
* This code wraps the gui representing "trainer units" (a unit that can train other units) within the structree.
|
|
*
|
|
* An instance of this class is created for each child of the gui element named "trainers".
|
|
*/
|
|
class TrainerBox extends EntityBox
|
|
{
|
|
constructor(page, trainerIdx)
|
|
{
|
|
super(page);
|
|
|
|
this.gui = Engine.GetGUIObjectByName("trainer[" + trainerIdx + "]");
|
|
this.ProductionRows = new ProductionRowManager(this.page, "trainer[" + trainerIdx + "]_productionRows", false);
|
|
|
|
const rowHeight = ProductionIcon.Size().rowHeight;
|
|
|
|
// Adjust height to accommodate production row
|
|
this.gui.size.bottom += rowHeight;
|
|
|
|
// We make the assumuption that all trainer boxes have the same height
|
|
const boxHeight = (this.VMargin / 2 + (this.gui.size.bottom - this.gui.size.top + this.VMargin)) * trainerIdx;
|
|
Object.assign(this.gui.size, {
|
|
"top": this.gui.size.top + boxHeight,
|
|
"bottom": this.gui.size.bottom + boxHeight,
|
|
// Make the box adjust automatically to column width
|
|
"rright": 100,
|
|
"right": -this.gui.size.left,
|
|
});
|
|
}
|
|
|
|
draw(templateName, civCode)
|
|
{
|
|
super.draw(templateName, civCode);
|
|
|
|
this.ProductionRows.draw(this.template, civCode);
|
|
|
|
// Return the box width
|
|
return Math.max(this.MinWidth, this.captionWidth(), this.ProductionRows.width);
|
|
}
|
|
}
|