fix(v2): pack capacity fill bars now show actual fill level
The pack fill bars were always empty because items weren't mapping to container key 0 (main backpack). The bodyContainerId detection failed when the inventory service doesn't include container_id on wielded items. Now falls back to using the largest non-container item group as the main backpack if key 0 is empty. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e6adb5cb68
commit
8c8409eac6
3 changed files with 37 additions and 24 deletions
|
|
@ -248,7 +248,20 @@ export const InventoryWindow: React.FC<Props> = ({ id, charName, zIndex }) => {
|
||||||
return { equippedMap, containers, packItems };
|
return { equippedMap, containers, packItems };
|
||||||
}, [items]);
|
}, [items]);
|
||||||
|
|
||||||
const mainItems = packItems.get(0) ?? [];
|
// Main backpack: key 0, OR the largest non-container group if bodyContainerId wasn't detected
|
||||||
|
let mainItems = packItems.get(0) ?? [];
|
||||||
|
let mainPackKey: number = 0;
|
||||||
|
if (mainItems.length === 0) {
|
||||||
|
// bodyContainerId wasn't detected — find the biggest group that isn't a container
|
||||||
|
let biggest = 0;
|
||||||
|
for (const [cid, items] of packItems.entries()) {
|
||||||
|
if (!containers.some((c: any) => c.item_id === cid) && items.length > biggest) {
|
||||||
|
biggest = items.length;
|
||||||
|
mainPackKey = cid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mainItems = packItems.get(mainPackKey) ?? [];
|
||||||
|
}
|
||||||
const activeItems = activePack !== null ? (packItems.get(activePack) ?? []) : mainItems;
|
const activeItems = activePack !== null ? (packItems.get(activePack) ?? []) : mainItems;
|
||||||
|
|
||||||
// Burden
|
// Burden
|
||||||
|
|
@ -320,7 +333,7 @@ export const InventoryWindow: React.FC<Props> = ({ id, charName, zIndex }) => {
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<PackIcon iconSrc="/icons/0600127E.png" isActive={activePack === null}
|
<PackIcon iconSrc="/icons/0600127E.png" isActive={activePack === null}
|
||||||
fillPct={Math.min(100, (mainItems.length / 102) * 100)}
|
fillPct={mainItems.length > 0 ? Math.min(100, (mainItems.length / 102) * 100) : 0}
|
||||||
label={`Backpack (${mainItems.length}/102)`} onClick={() => setActivePack(null)} />
|
label={`Backpack (${mainItems.length}/102)`} onClick={() => setActivePack(null)} />
|
||||||
{containers.map((c: any) => {
|
{containers.map((c: any) => {
|
||||||
const cid = c.item_id;
|
const cid = c.item_id;
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>Mosswart Overlord v2</title>
|
<title>Mosswart Overlord v2</title>
|
||||||
<link rel="icon" type="image/png" href="/icons/7735.png" />
|
<link rel="icon" type="image/png" href="/icons/7735.png" />
|
||||||
<script type="module" crossorigin src="/v2/assets/index-DXm3K60h.js"></script>
|
<script type="module" crossorigin src="/v2/assets/index-B2Cf6gGs.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/v2/assets/index-DrsM2PEe.css">
|
<link rel="stylesheet" crossorigin href="/v2/assets/index-DrsM2PEe.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue