From 99fbe6ced404076611d14a7c34dcab5a3514906d Mon Sep 17 00:00:00 2001 From: DarwinBaker Date: Sat, 15 Jun 2024 12:15:51 -0400 Subject: [PATCH] Layout improvements for 1.21 --- AATool/UI/Controls/UICriteriaGroup.cs | 59 +++++++++++++++---- .../1.21/advancements/adventure.xml | 19 +++--- .../1.21/advancements/husbandry.xml | 10 ++-- .../all_advancements/1.21/main_relaxed.xml | 12 ++-- 4 files changed, 69 insertions(+), 31 deletions(-) diff --git a/AATool/UI/Controls/UICriteriaGroup.cs b/AATool/UI/Controls/UICriteriaGroup.cs index e480c59..1f89ca2 100644 --- a/AATool/UI/Controls/UICriteriaGroup.cs +++ b/AATool/UI/Controls/UICriteriaGroup.cs @@ -35,6 +35,8 @@ class UICriteriaGroup : UIPanel private int cellWidth; private int spacerCells; + private Dictionary spacers = new(); + public UICriteriaGroup() { this.BuildFromTemplate(); @@ -109,17 +111,22 @@ private void PopulateCriteria() if (!Config.Main.UseCompactStyling && !Config.Main.UseVerticalStyling) this.criteriaPanel.AddControl(spacer); - for (int i = 0; i < this.spacerCells; i++) - { - this.criteriaPanel.AddControl(new UIPanel() { - FlexWidth = new(this.cellWidth), - FlexHeight = new(16), - DrawMode = DrawMode.None, - }); - } - + int index = 0; foreach (KeyValuePair criterion in this.advancement.Criteria.All) { + //handle spacers to allow for finer control of layouts + if (this.spacers.TryGetValue(index, out int spacerCount)) + { + for (int i = 0; i < spacerCount; i++) + { + this.criteriaPanel.AddControl(new UIPanel() { + FlexWidth = new(this.cellWidth), + FlexHeight = new(16), + DrawMode = DrawMode.None, + }); + } + } + UICriterion crit = advancement.Id is ArmorTrims.AdvancementId ? new UIArmorTrimCriterion { HorizontalAlign = HorizontalAlign.Left } : new UICriterion { HorizontalAlign = HorizontalAlign.Left }; @@ -130,6 +137,8 @@ private void PopulateCriteria() crit.FlexWidth = new (this.cellWidth); } this.criteriaPanel.AddControl(crit); + + index++; } } @@ -372,7 +381,37 @@ public override void ReadNode(XmlNode node) base.ReadNode(node); this.advancementName = Attribute(node, "advancement", string.Empty); this.cellWidth = Attribute(node, "cell_width", 0); - this.spacerCells = Attribute(node, "spacers", 0); + this.ReadSpacers(node); + } + + private void ReadSpacers(XmlNode node) + { + string list = Attribute(node, "spacers", string.Empty); + if (string.IsNullOrEmpty(list)) + return; + + string[] entries = list.Split(','); + + if (entries.Length == 1) + { + if (int.TryParse(entries[0], out int count)) + { + this.spacers[0] = count; + return; + } + } + + foreach (string entry in list.Split(',')) + { + string[] tokens = entry.Split('@'); + + if (tokens.Length == 2 + && int.TryParse(tokens[0], out int count) + && int.TryParse(tokens[1], out int index)) + { + this.spacers[index] = count; + } + } } } } diff --git a/AATool/assets/objectives/1.21/advancements/adventure.xml b/AATool/assets/objectives/1.21/advancements/adventure.xml index 0feb3ee..21d24c0 100644 --- a/AATool/assets/objectives/1.21/advancements/adventure.xml +++ b/AATool/assets/objectives/1.21/advancements/adventure.xml @@ -20,8 +20,8 @@ - - + + - + @@ -54,18 +54,17 @@ + - - - + + - @@ -145,7 +144,6 @@ - @@ -155,17 +153,18 @@ + - + + - \ No newline at end of file diff --git a/AATool/assets/objectives/1.21/advancements/husbandry.xml b/AATool/assets/objectives/1.21/advancements/husbandry.xml index dcafe00..9ec2185 100644 --- a/AATool/assets/objectives/1.21/advancements/husbandry.xml +++ b/AATool/assets/objectives/1.21/advancements/husbandry.xml @@ -9,21 +9,20 @@ + + - - - - + + - @@ -125,6 +124,7 @@ + diff --git a/AATool/assets/views/all_advancements/1.21/main_relaxed.xml b/AATool/assets/views/all_advancements/1.21/main_relaxed.xml index 0b0e8f5..0c80613 100644 --- a/AATool/assets/views/all_advancements/1.21/main_relaxed.xml +++ b/AATool/assets/views/all_advancements/1.21/main_relaxed.xml @@ -37,7 +37,7 @@ - + @@ -50,7 +50,7 @@ - + - @@ -60,10 +60,10 @@ - - - - + + + +