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.
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
/**
|
|
* This code wraps the gui representing buildable structures within the structree.
|
|
*
|
|
* An instance of this class is created for each child of the gui element named "structures".
|
|
*/
|
|
class StructureBox extends EntityBox
|
|
{
|
|
constructor(page, structureIdx)
|
|
{
|
|
super(page);
|
|
this.gui = Engine.GetGUIObjectByName("structure[" + structureIdx + "]");
|
|
this.ProductionRows = new ProductionRowManager(this.page, "structure[" + structureIdx + "]_productionRows", true);
|
|
}
|
|
|
|
draw(templateName, civCode, runningWidths)
|
|
{
|
|
super.draw(templateName, civCode);
|
|
|
|
this.phaseIdx = this.page.TemplateParser.phaseList.indexOf(this.template.phase);
|
|
|
|
// Draw the production rows
|
|
this.ProductionRows.draw(this.template, civCode, this.phaseIdx);
|
|
|
|
const boxWidth = Math.max(this.MinWidth, this.captionWidth(), this.ProductionRows.width);
|
|
|
|
// Set position of the Structure Box
|
|
Object.assign(this.gui.size, {
|
|
"left": this.HMargin + runningWidths[this.phaseIdx], "top": TreeSection.getPositionOffset(this.phaseIdx, this.page.TemplateParser),
|
|
"right": this.HMargin + runningWidths[this.phaseIdx] + boxWidth, "bottom": TreeSection.getPositionOffset(this.phaseIdx + 1, this.page.TemplateParser) - this.VMargin
|
|
});
|
|
|
|
// Update new right-side-edge dimension
|
|
runningWidths[this.phaseIdx] += boxWidth + this.HMargin / 2;
|
|
}
|
|
}
|