From: terencehill Date: Tue, 24 Dec 2024 11:23:49 +0000 (+0100) Subject: Guide: fix positions of a few items that aren't defined together with other items... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=refs%2Fheads%2FTimePath%2Fguide2;p=xonotic%2Fxonotic-data.pk3dir.git Guide: fix positions of a few items that aren't defined together with other items of the same type (Fuel and Vaporizer Ammo) --- diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index af56134c2..dee884a10 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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]; diff --git a/qcsrc/common/items/all.qh b/qcsrc/common/items/all.qh index 8294f638b..f8adbd428 100644 --- a/qcsrc/common/items/all.qh +++ b/qcsrc/common/items/all.qh @@ -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 diff --git a/qcsrc/menu/xonotic/guide/guide.qh b/qcsrc/menu/xonotic/guide/guide.qh index 93ae97c77..a336e5664 100644 --- a/qcsrc/menu/xonotic/guide/guide.qh +++ b/qcsrc/menu/xonotic/guide/guide.qh @@ -84,11 +84,11 @@ REGISTRY_SOURCE(BuffSource, Buffs, StatusEffect, it.instanceOfBuff) // The descriptions for these are in common/mutators/mutator/buffs/all.inc #include -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 -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