Skip to content

Commit

Permalink
Layout improvements for 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
DarwinBaker committed Jun 15, 2024
1 parent 8ba2aac commit 99fbe6c
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 31 deletions.
59 changes: 49 additions & 10 deletions AATool/UI/Controls/UICriteriaGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class UICriteriaGroup : UIPanel
private int cellWidth;
private int spacerCells;

private Dictionary<int, int> spacers = new();

public UICriteriaGroup()
{
this.BuildFromTemplate();
Expand Down Expand Up @@ -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<string, Criterion> 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 };
Expand All @@ -130,6 +137,8 @@ private void PopulateCriteria()
crit.FlexWidth = new (this.cellWidth);
}
this.criteriaPanel.AddControl(crit);

index++;
}
}

Expand Down Expand Up @@ -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;
}
}
}
}
}
19 changes: 9 additions & 10 deletions AATool/assets/objectives/1.21/advancements/adventure.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
<advancement id="minecraft:adventure/play_jukebox_in_meadows" name="Sound of Music" short_name="Music"/>
<advancement id="minecraft:adventure/brush_armadillo" name="Isn't it Scute?" short_name="Scute?" icon="brush_armadillo"/>
<advancement id="minecraft:adventure/salvage_sherd" name="Respecting Remnants" short_name="Remnants"/>
<advancement id="minecraft:adventure/craft_decorated_pot_using_only_sherds" name="Careful Restoration" short_name="Restoration" icon="craft_decorated_pot"/>
<advancement id="minecraft:adventure/trim_with_any_armor_pattern" name="Crafting a New&#160;Look" short_name="New Look" icon="trim_dune"/>
<advancement id="minecraft:adventure/craft_decorated_pot_using_only_sherds" name="Careful Restoration" short_name="Restoration" icon="craft_decorated_pot"/>
<advancement id="minecraft:adventure/trim_with_any_armor_pattern" name="Crafting a New&#160;Look" short_name="New Look" icon="trim_dune"/>
<advancement id="minecraft:adventure/trim_with_all_exclusive_armor_patterns" name="Smithing With&#160;Style" short_name="With Style" icon="trim_silence" type="challenge">
<criteria goal="Trims Applied">
<criterion id="armor_trimmed_minecraft:snout_armor_trim_smithing_template_smithing_trim"
Expand All @@ -42,7 +42,7 @@
name="Silence" icon="trim_silence" recipe="minecraft:recipes/misc/silence_armor_trim_smithing_template"/>
</criteria>
</advancement>

<advancement id="minecraft:adventure/spyglass_at_parrot" name="Is It a&#xA;Bird?" short_name="A Bird?" icon="spyglass"/>
<advancement id="minecraft:adventure/spyglass_at_ghast" name="Is It a&#xA;Balloon?" short_name="A Balloon?" icon="spyglass"/>
<advancement id="minecraft:adventure/spyglass_at_dragon" name="Is It a&#xA;Plane?" short_name="A Plane?" icon="spyglass"/>
Expand All @@ -54,18 +54,17 @@
<advancement id="minecraft:adventure/lighten_up" name="Lighten Up" short_name="Lighten Up"/>
<advancement id="minecraft:adventure/who_needs_rockets" name="Who Needs Rockets?" short_name="Rockets?"/>
<advancement id="minecraft:adventure/blowback" name="Blowback" short_name="Blowback"/>

<advancement id="minecraft:adventure/under_lock_and_key" name="Under Lock and Key" short_name="Lock/Key"/>
<advancement id="minecraft:adventure/revaulting" name="Revaulting" short_name="Revaulting"/>
<advancement id="minecraft:adventure/overoverkill" name="Over-Overkill" short_name="Overkill"/>
<advancement id="minecraft:adventure/totem_of_undying" name="Postmortal" type="goal"/>
<advancement id="minecraft:adventure/walk_on_powder_snow_with_leather_boots" name="Light as a&#160;Rabbit" short_name="LaaR" icon="leather_boots"/>

<advancement id="minecraft:adventure/honey_block_slide" name="Sticky Situation" short_name="Sticky "/>

<advancement id="minecraft:adventure/lightning_rod_with_villager_no_fire" name="Surge Protector" short_name="Surge Prot" icon="lightning_rod"/>
<advancement id="minecraft:adventure/voluntary_exile" name="Voluntary Exile" short_name="Exile" icon="pillager_banner"/>

<advancement id="minecraft:adventure/voluntary_exile" name="Voluntary Exile" short_name="Exile" icon="pillager_banner"/>
<advancement id="minecraft:adventure/hero_of_the_village" name="Hero of the&#160;Village" short_name="Hero OTV" icon="pillager_banner" type="challenge"/>

<advancement id="minecraft:adventure/throw_trident" name="A Throwaway Joke" short_name="ATJ"/>
<advancement id="minecraft:adventure/very_very_frightening" name="Very Very Frightening" short_name="VVF"/>
<advancement id="minecraft:adventure/adventuring_time" name="Adventuring Time" short_name="Adventuring" type="challenge">
Expand Down Expand Up @@ -145,7 +144,6 @@
<criterion id="minecraft:ghast"/>
<criterion id="minecraft:blaze"/>
<criterion id="minecraft:wither_skeleton" name="Wither Skeleton" short_name="W Skeleton"/>
<criterion id="minecraft:wither"/>
<criterion id="minecraft:piglin"/>
<criterion id="minecraft:piglin_brute"/>
<criterion id="minecraft:zombified_piglin" name="Zombie Piglin"/>
Expand All @@ -155,17 +153,18 @@
<criterion id="minecraft:ender_dragon"/>
<criterion id="minecraft:endermite"/>
<criterion id="minecraft:shulker"/>
<criterion id="minecraft:wither"/>
<criterion id="minecraft:phantom"/>
<criterion id="minecraft:guardian"/>
<criterion id="minecraft:elder_guardian"/>
<criterion id="minecraft:zombie_villager" short_name="Z-Villager"/>
<criterion id="minecraft:breeze"/>
<criterion id="minecraft:zombie_villager" name="Zillager" short_name="Zillager"/>
<criterion id="minecraft:witch"/>
<criterion id="minecraft:pillager"/>
<criterion id="minecraft:vindicator"/>
<criterion id="minecraft:evoker"/>
<criterion id="minecraft:vex" icon="vex_1.19.3"/>
<criterion id="minecraft:ravager"/>
<criterion id="minecraft:breeze"/>
</criteria>
</advancement>
</group>
10 changes: 5 additions & 5 deletions AATool/assets/objectives/1.21/advancements/husbandry.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,20 @@
<advancement id="minecraft:husbandry/axolotl_in_a_bucket" name="The Cutest Predator" short_name="Predator"/>
<advancement id="minecraft:husbandry/kill_axolotl_target" name="Healing&#160;Power of Friendship" short_name="Friendship"/>
<advancement id="minecraft:husbandry/make_a_sign_glow" name="Glow and Behold!" short_name="Behold!"/>
<advancement id="minecraft:husbandry/ride_a_boat_with_a_goat" name="Whatev&#160;Floats Your&#160;Goat!" short_name="Goat Boat"/>

<advancement id="minecraft:husbandry/safely_harvest_honey" name="Bee Our Guest" short_name="Our Guest"/>
<advancement id="minecraft:husbandry/wax_on" name="Wax On"/>
<advancement id="minecraft:husbandry/wax_off" name="Wax Off"/>
<advancement id="minecraft:husbandry/silk_touch_nest" name="Total Beelocation" short_name="Beelocation"/>
<advancement id="minecraft:husbandry/obtain_netherite_hoe" name="Serious Dedication" short_name="Dedication" type="challenge"/>

<advancement id="minecraft:husbandry/repair_wolf_armor" name="Good as New" short_name="Repair" icon="repair_wolf_armor"/>
<advancement id="minecraft:husbandry/remove_wolf_armor" name="Shear Brilliance" short_name="Shear" icon="shears"/>
<advancement id="minecraft:husbandry/ride_a_boat_with_a_goat" name="Whatev&#160;Floats Your&#160;Goat!" short_name="Goat Boat"/>
<advancement id="minecraft:husbandry/allay_deliver_item_to_player" name="You Got a Friend in Me" short_name="A Friend" icon="cookie"/>
<advancement id="minecraft:husbandry/allay_deliver_cake_to_note_block" name="Birthday Song" short_name="Birthday" icon="birthday"/>
<advancement id="minecraft:husbandry/obtain_sniffer_egg" name="Smells Interesting" short_name="Smells" icon="obtain_sniffer_egg"/>

<advancement id="minecraft:husbandry/obtain_sniffer_egg" name="Smells Interesting" short_name="Smells" icon="obtain_sniffer_egg"/>
<advancement id="minecraft:husbandry/feed_snifflet" name="Little Sniffs" short_name="Lil Sniffs" icon="feed_snifflet"/>
<advancement id="minecraft:husbandry/plant_any_sniffer_seed" name="Planting The&#160;Past" short_name="The Past" icon="plant_any_sniffer_seed"/>

<advancement id="minecraft:husbandry/bred_all_animals" name="Two by Two" type="challenge">
<criteria goal="Animals Bred">
<criterion id="minecraft:pig"/>
Expand Down Expand Up @@ -125,6 +124,7 @@
<criterion id="minecraft:woods" name="Woods" icon="wolf_woods"/>
</criteria>
</advancement>
<advancement id="minecraft:husbandry/obtain_netherite_hoe" name="Serious Dedication" short_name="Dedication" type="challenge"/>

<advancement id="minecraft:husbandry/froglights" name="Our&#160;Powers Combined!" short_name="Froglights" type="challenge"/>
<advancement id="minecraft:husbandry/leash_all_frog_variants" name="Squad Hops Into Town" short_name="The Squad" icon="tame_an_animal"/>
Expand Down
12 changes: 6 additions & 6 deletions AATool/assets/views/all_advancements/1.21/main_relaxed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<advancement_group group="adventure" row="0" col="5" end="minecraft:adventure/spyglass_at_dragon" exclude="minecraft:adventure/spyglass_at_parrot,minecraft:adventure/spyglass_at_ghast,minecraft:adventure/spyglass_at_dragon"/>
<advancement_group group="adventure" row="1" col="5" start="minecraft:adventure/avoid_vibration"/>

<advancement_group group="husbandry" row="1" col="1" colspan="2" end="minecraft:husbandry/whole_pack" exclude="minecraft:husbandry/root,minecraft:husbandry/breed_an_animal"/>
<advancement_group group="husbandry" row="1" col="1" colspan="2" end="minecraft:husbandry/obtain_netherite_hoe" exclude="minecraft:husbandry/root,minecraft:husbandry/breed_an_animal"/>
<advancement_group group="husbandry" row="1" col="3" start="minecraft:husbandry/froglights"/>
<advancement_group group="adventure" row="1" col="4" start="minecraft:adventure/spyglass_at_parrot" end="minecraft:adventure/spyglass_at_dragon"/>

Expand All @@ -50,7 +50,7 @@
<flow_panel row="1" col="6">
<objective_frame complex="WitherSkulls"/>
<objective_frame complex="GoldBlocks"/>
<objective_frame complex="Bees"/>
<objective_frame complex="HeavyCore"/>
</flow_panel>
-
<!-- info panel -->
Expand All @@ -60,10 +60,10 @@

<!-- advancements with subcriteria -->
<flow_panel row="1" col="1" colspan="2">
<criteria_group width="6 * 68" advancement="minecraft:adventure/adventuring_time" cell_width="128"/>
<criteria_group width="4 * 68" advancement="minecraft:adventure/kill_all_mobs" cell_width="120"/>
<criteria_group width="5 * 68" advancement="minecraft:husbandry/balanced_diet" cell_width="112"/>
<criteria_group width="3 * 68" advancement="minecraft:husbandry/bred_all_animals"/>
<criteria_group width="6 * 68" advancement="minecraft:adventure/adventuring_time" cell_width="130"/>
<criteria_group width="4.5 * 68" advancement="minecraft:adventure/kill_all_mobs" cell_width="108" spacers="3@12,3@29,"/>
<criteria_group width="5 * 68" advancement="minecraft:husbandry/balanced_diet" cell_width="112" spacers="4@11,4@27,"/>
<criteria_group width="2.5 * 68" advancement="minecraft:husbandry/bred_all_animals" cell_width="88" spacers="4@11"/>
<criteria_group width="1.5 * 68" advancement="minecraft:husbandry/complete_catalogue"/>
<criteria_group width="1.5 * 68" advancement="minecraft:husbandry/whole_pack"/>
<panel width="3 * 68" draw_mode="childrenonly">
Expand Down

0 comments on commit 99fbe6c

Please sign in to comment.