]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Guide: fix positions of a few items that aren't defined together with other items... TimePath/guide2
authorterencehill <piuntn@gmail.com>
Tue, 24 Dec 2024 11:23:49 +0000 (12:23 +0100)
committerterencehill <piuntn@gmail.com>
Tue, 24 Dec 2024 11:23:49 +0000 (12:23 +0100)
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/common/items/all.qh
qcsrc/menu/xonotic/guide/guide.qh

index af56134c2affa170ff7a142f5cb8b9c17336ee1b..dee884a108125a1e8c7c401f825f3cd5414229af 100644 (file)
@@ -1918,7 +1918,7 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
 
        int disowned_cnt = 0;
        int uninteresting_cnt = 0;
-       IL_EACH(default_order_items, true, {
+       IL_EACH(Items_sorted_by_type, true, {
                int q = g_inventory.inv_items[it.m_id];
                //q = 1; // debug: display all items
                if (is_item_filtered(it))
@@ -1987,7 +1987,7 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
        vector tmpos = pos;
 
        int column = 0;
-       IL_EACH(default_order_items, !is_item_filtered(it), {
+       IL_EACH(Items_sorted_by_type, !is_item_filtered(it), {
                int n = g_inventory.inv_items[it.m_id];
                //n = 1 + floor(i * 3 + 4.8) % 7; // debug: display a value for each item
                if (n <= 0) continue;
@@ -2263,7 +2263,7 @@ bool Scoreboard_ItemStats_WouldDraw(float ypos)
 
        if (!have_item_stats)
        {
-               IL_EACH(default_order_items, true, {
+               IL_EACH(Items_sorted_by_type, true, {
                        if (!is_item_filtered(it))
                        {
                                int q = g_inventory.inv_items[it.m_id];
index 8294f638b3976d9cc7ad27fc2919e927b3c13ffa..f8adbd428da647068a9c04de850011a37d11214f 100644 (file)
@@ -13,14 +13,30 @@ REGISTER_REGISTRY(Items)
 #define REGISTER_ITEM(id, inst) REGISTER(Items, ITEM, id, m_id, inst)
 
 #ifndef SVQC
-// Copy Items registry here before it gets sorted alphabetically by REGISTRY_SORT
-// so we can keep items sorted by categories (as they appear in the code)
-IntrusiveList default_order_items;
-STATIC_INIT(default_order_items)
+.bool instanceOfAmmo;
+.bool instanceOfHealth;
+.bool instanceOfArmor;
+.bool instanceOfPowerup;
+// Items in Items_sorted_by_type are sorted by type and weigth / importance (as they appear in the code)
+//  e.g. Small Armor, Medium Armor, Big Armor, Mega Armor
+//  whereas items in Items are sorted alphabetically by REGISTRY_SORT, regardless of type
+// Sorting by type is needed to fix positions of a few items that aren't defined together with other
+//  items of the same type, e.g. Fuel
+IntrusiveList Items_sorted_by_type;
+STATIC_INIT(Items_sorted_by_type)
 {
-       default_order_items = IL_NEW();
-       FOREACH(Items, true, {
-               IL_PUSH(default_order_items, it);
+       Items_sorted_by_type = IL_NEW();
+       FOREACH(Items, it.instanceOfAmmo, {
+               IL_PUSH(Items_sorted_by_type, it);
+       });
+       FOREACH(Items, it.instanceOfHealth, {
+               IL_PUSH(Items_sorted_by_type, it);
+       });
+       FOREACH(Items, it.instanceOfArmor, {
+               IL_PUSH(Items_sorted_by_type, it);
+       });
+       FOREACH(Items, it.instanceOfPowerup, {
+               IL_PUSH(Items_sorted_by_type, it);
        });
 }
 #endif
index 93ae97c779d1f930d32d735e2def1aa9b1b27df5..a336e5664bbebfdb28149b3cf3971e9a14712384 100644 (file)
@@ -84,11 +84,11 @@ REGISTRY_SOURCE(BuffSource, Buffs, StatusEffect, it.instanceOfBuff)
 // The descriptions for these are in common/mutators/mutator/buffs/all.inc
 
 #include <common/mutators/mutator/powerups/powerup/_mod.qh>
-IL_SOURCE(PowerupSource, Powerups, default_order_items, it.instanceOfPowerup)
+IL_SOURCE(PowerupSource, Powerups, Items_sorted_by_type, it.instanceOfPowerup)
 // The descriptions for these are in common/mutators/mutator/powerups/powerup/*.qc and common/items/item/jetpack.qc
 
 #include <common/items/all.qh>
-IL_SOURCE(ItemSource, Items, default_order_items, !it.instanceOfPowerup)
+IL_SOURCE(ItemSource, Items, Items_sorted_by_type, !it.instanceOfPowerup)
 // The descriptions for these are in common/items/item/*.qc and common/mutators/mutator/instagib/items.qc
 
 #include <common/mutators/mutator/nades/nades.qh>