BlueGit

timfa questward

Show equipped arrow ammo above the favourites bar.

Add a bottom-left ammo HUD that mirrors offhand arrow stacks whenever inventory updates.

timfa Tim Falken · pushed by timfa

Authored 2026-09-06 · 2 months ago

Hash
e7eb3bb9b35ee6d5a6cdf75d5c4c89251443b284
Parent
7b9fdb76
4 files changed +75 −3
client/index.html +4 −1
@@ -162,7 +162,10 @@
162 162 </label>
163 163 <div id="spells-list" class="spells-grid"></div>
164 164 </aside>
165 <div id="spell-favorites-bar" hidden></div>
165 <div id="bottom-left-hud">
166 <div id="equipped-ammo-hud" hidden></div>
167 <div id="spell-favorites-bar" hidden></div>
168 </div>
166 169
167 170 <div id="send-backdrop" class="modal-backdrop" hidden></div>
168 171 <aside id="send-panel" hidden>
@@ -162,7 +162,10 @@
162 </label>
162 </label>
163 <div id="spells-list" class="spells-grid"></div>
163 <div id="spells-list" class="spells-grid"></div>
164 </aside>
164 </aside>
165 <div id="spell-favorites-bar" hidden></div>
165 <div id="bottom-left-hud">
166 <div id="equipped-ammo-hud" hidden></div>
167 <div id="spell-favorites-bar" hidden></div>
168 </div>
166
169
167 <div id="send-backdrop" class="modal-backdrop" hidden></div>
170 <div id="send-backdrop" class="modal-backdrop" hidden></div>
168 <aside id="send-panel" hidden>
171 <aside id="send-panel" hidden>
client/src/play/inventory.js +28 −0
@@ -10,6 +10,7 @@ import
10 10 EQUIPMENT_SLOT,
11 11 LETTER_MAX_BODY_CHARS
12 12 } from "/shared/definitions/items.js";
13 import { EquipmentKind } from "/shared/definitions/equipmentKinds.js";
13 14 import { stackQuantity } from "/shared/items/inventory.js";
14 15 import { formatLetterSignature } from "/shared/courier/systemLetters.js";
15 16 import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";
@@ -52,6 +53,7 @@ export function initInventory ({
52 53 const bagPanel = document.getElementById("bag-panel");
53 54 const bagGrid = document.getElementById("bag-grid");
54 55 const equipGrid = document.getElementById("equip-grid");
56 const ammoHud = document.getElementById("equipped-ammo-hud");
55 57 const bagMaxHitEl = document.getElementById("bag-max-hit");
56 58 const hint = document.getElementById("bag-hint");
57 59 const bankPanel = document.getElementById("bank-panel");
@@ -219,6 +221,31 @@ export function initInventory ({
219 221 bagMaxHitEl.hidden = false;
220 222 }
221 223
224 function refreshEquippedAmmoHud ()
225 {
226 if (!ammoHud)
227 { return; }
228 const worn = bag.equipment?.slots?.[EQUIPMENT_SLOT.offhand] ?? null;
229 const def = worn ? itemDefinition(worn.itemId) : null;
230 if (!worn || def?.equipment?.kind !== EquipmentKind.arrowAmmo)
231 {
232 ammoHud.hidden = true;
233 ammoHud.replaceChildren();
234 return;
235 }
236 ammoHud.hidden = false;
237 ammoHud.replaceChildren();
238 const img = document.createElement("img");
239 applyItemIcon(img, worn, itemAssetPathForStack(worn));
240 img.alt = itemDisplayName(worn);
241 ammoHud.append(img);
242 const count = document.createElement("span");
243 count.className = "qty";
244 count.textContent = formatQuantity(stackQuantity(worn.quantity));
245 ammoHud.append(count);
246 ammoHud.title = `${itemDisplayName(worn)} ×${formatQuantity(stackQuantity(worn.quantity))}`;
247 }
248
222 249 function render ()
223 250 {
224 251 bagGrid.innerHTML = "";
@@ -366,6 +393,7 @@ export function initInventory ({
366 393 });
367 394 equipGrid.append(button);
368 395 }
396 refreshEquippedAmmoHud();
369 397 refreshMaxHit();
370 398 }
371 399
@@ -10,6 +10,7 @@ import
10 EQUIPMENT_SLOT,
10 EQUIPMENT_SLOT,
11 LETTER_MAX_BODY_CHARS
11 LETTER_MAX_BODY_CHARS
12} from "/shared/definitions/items.js";
12} from "/shared/definitions/items.js";
13import { EquipmentKind } from "/shared/definitions/equipmentKinds.js";
13import { stackQuantity } from "/shared/items/inventory.js";
14import { stackQuantity } from "/shared/items/inventory.js";
14import { formatLetterSignature } from "/shared/courier/systemLetters.js";
15import { formatLetterSignature } from "/shared/courier/systemLetters.js";
15import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";
16import { spellIdFromSpellbookStack } from "/shared/definitions/spellItems.js";
@@ -52,6 +53,7 @@ export function initInventory ({
52 const bagPanel = document.getElementById("bag-panel");
53 const bagPanel = document.getElementById("bag-panel");
53 const bagGrid = document.getElementById("bag-grid");
54 const bagGrid = document.getElementById("bag-grid");
54 const equipGrid = document.getElementById("equip-grid");
55 const equipGrid = document.getElementById("equip-grid");
56 const ammoHud = document.getElementById("equipped-ammo-hud");
55 const bagMaxHitEl = document.getElementById("bag-max-hit");
57 const bagMaxHitEl = document.getElementById("bag-max-hit");
56 const hint = document.getElementById("bag-hint");
58 const hint = document.getElementById("bag-hint");
57 const bankPanel = document.getElementById("bank-panel");
59 const bankPanel = document.getElementById("bank-panel");
@@ -219,6 +221,31 @@ export function initInventory ({
219 bagMaxHitEl.hidden = false;
221 bagMaxHitEl.hidden = false;
220 }
222 }
221
223
224 function refreshEquippedAmmoHud ()
225 {
226 if (!ammoHud)
227 { return; }
228 const worn = bag.equipment?.slots?.[EQUIPMENT_SLOT.offhand] ?? null;
229 const def = worn ? itemDefinition(worn.itemId) : null;
230 if (!worn || def?.equipment?.kind !== EquipmentKind.arrowAmmo)
231 {
232 ammoHud.hidden = true;
233 ammoHud.replaceChildren();
234 return;
235 }
236 ammoHud.hidden = false;
237 ammoHud.replaceChildren();
238 const img = document.createElement("img");
239 applyItemIcon(img, worn, itemAssetPathForStack(worn));
240 img.alt = itemDisplayName(worn);
241 ammoHud.append(img);
242 const count = document.createElement("span");
243 count.className = "qty";
244 count.textContent = formatQuantity(stackQuantity(worn.quantity));
245 ammoHud.append(count);
246 ammoHud.title = `${itemDisplayName(worn)} ×${formatQuantity(stackQuantity(worn.quantity))}`;
247 }
248
222 function render ()
249 function render ()
223 {
250 {
224 bagGrid.innerHTML = "";
251 bagGrid.innerHTML = "";
@@ -366,6 +393,7 @@ export function initInventory ({
366 });
393 });
367 equipGrid.append(button);
394 equipGrid.append(button);
368 }
395 }
396 refreshEquippedAmmoHud();
369 refreshMaxHit();
397 refreshMaxHit();
370 }
398 }
371
399
client/src/play/main.js +1 −1
@@ -369,7 +369,7 @@ function pointerOverSpellUi ()
369 369 const el = document.elementFromPoint(GameInput.mousePosition.x, GameInput.mousePosition.y);
370 370 if (!el)
371 371 { return false; }
372 return !!el.closest("#spells-panel, #spell-favorites-bar, #spells-toggle");
372 return !!el.closest("#spells-panel, #spell-favorites-bar, #equipped-ammo-hud, #spells-toggle");
373 373 }
374 374
375 375 function pointerOverToastUi ()
@@ -369,7 +369,7 @@ function pointerOverSpellUi ()
369 const el = document.elementFromPoint(GameInput.mousePosition.x, GameInput.mousePosition.y);
369 const el = document.elementFromPoint(GameInput.mousePosition.x, GameInput.mousePosition.y);
370 if (!el)
370 if (!el)
371 { return false; }
371 { return false; }
372 return !!el.closest("#spells-panel, #spell-favorites-bar, #spells-toggle");
372 return !!el.closest("#spells-panel, #spell-favorites-bar, #equipped-ammo-hud, #spells-toggle");
373}
373}
374
374
375function pointerOverToastUi ()
375function pointerOverToastUi ()
client/ui/play.css +42 −1
@@ -1090,11 +1090,52 @@ button.friend-account-name:hover {
1090 1090 cursor: not-allowed;
1091 1091 }
1092 1092
1093 #spell-favorites-bar {
1093 #bottom-left-hud {
1094 1094 position: fixed;
1095 1095 z-index: 5;
1096 1096 left: 0.75rem;
1097 1097 bottom: 0.65rem;
1098 display: flex;
1099 flex-direction: column;
1100 align-items: flex-start;
1101 gap: 0.35rem;
1102 pointer-events: none;
1103 }
1104
1105 #bottom-left-hud > * {
1106 pointer-events: auto;
1107 }
1108
1109 #equipped-ammo-hud {
1110 display: flex;
1111 align-items: center;
1112 gap: 0.4rem;
1113 padding: 0.3rem 0.45rem 0.3rem 0.3rem;
1114 border-radius: 10px;
1115 background: rgba(18, 21, 27, 0.94);
1116 border: 1px solid #2c3340;
1117 box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
1118 color: #e8ecf4;
1119 font-size: 0.95rem;
1120 font-variant-numeric: tabular-nums;
1121 }
1122
1123 #equipped-ammo-hud[hidden] {
1124 display: none;
1125 }
1126
1127 #equipped-ammo-hud img {
1128 width: 36px;
1129 height: 36px;
1130 object-fit: contain;
1131 image-rendering: pixelated;
1132 }
1133
1134 #equipped-ammo-hud .qty {
1135 min-width: 1.25ch;
1136 }
1137
1138 #spell-favorites-bar {
1098 1139 display: flex;
1099 1140 gap: 0.35rem;
1100 1141 padding: 0.35rem;
@@ -1090,11 +1090,52 @@ button.friend-account-name:hover {
1090 cursor: not-allowed;
1090 cursor: not-allowed;
1091}
1091}
1092
1092
1093#spell-favorites-bar {
1093#bottom-left-hud {
1094 position: fixed;
1094 position: fixed;
1095 z-index: 5;
1095 z-index: 5;
1096 left: 0.75rem;
1096 left: 0.75rem;
1097 bottom: 0.65rem;
1097 bottom: 0.65rem;
1098 display: flex;
1099 flex-direction: column;
1100 align-items: flex-start;
1101 gap: 0.35rem;
1102 pointer-events: none;
1103}
1104
1105#bottom-left-hud > * {
1106 pointer-events: auto;
1107}
1108
1109#equipped-ammo-hud {
1110 display: flex;
1111 align-items: center;
1112 gap: 0.4rem;
1113 padding: 0.3rem 0.45rem 0.3rem 0.3rem;
1114 border-radius: 10px;
1115 background: rgba(18, 21, 27, 0.94);
1116 border: 1px solid #2c3340;
1117 box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
1118 color: #e8ecf4;
1119 font-size: 0.95rem;
1120 font-variant-numeric: tabular-nums;
1121}
1122
1123#equipped-ammo-hud[hidden] {
1124 display: none;
1125}
1126
1127#equipped-ammo-hud img {
1128 width: 36px;
1129 height: 36px;
1130 object-fit: contain;
1131 image-rendering: pixelated;
1132}
1133
1134#equipped-ammo-hud .qty {
1135 min-width: 1.25ch;
1136}
1137
1138#spell-favorites-bar {
1098 display: flex;
1139 display: flex;
1099 gap: 0.35rem;
1140 gap: 0.35rem;
1100 padding: 0.35rem;
1141 padding: 0.35rem;