From 16f0be1a4553826fb6cb35d1a1bbefee485e375f Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Tue, 16 Aug 2022 21:08:04 +0300 Subject: [PATCH] Add more inventory UI constants --- src/inventory.cc | 276 ++++++++++++++++++++++++++++------------------- 1 file changed, 163 insertions(+), 113 deletions(-) diff --git a/src/inventory.cc b/src/inventory.cc index 5c46305..efa47ef 100644 --- a/src/inventory.cc +++ b/src/inventory.cc @@ -72,14 +72,20 @@ #define INVENTORY_ARMOR_SLOT_MAX_X (INVENTORY_ARMOR_SLOT_X + INVENTORY_LARGE_SLOT_WIDTH) #define INVENTORY_ARMOR_SLOT_MAX_Y (INVENTORY_ARMOR_SLOT_Y + INVENTORY_LARGE_SLOT_HEIGHT) +#define INVENTORY_TRADE_SCROLLER_Y 35 +#define INVENTORY_TRADE_INNER_SCROLLER_Y 20 + #define INVENTORY_TRADE_LEFT_SCROLLER_X 29 +#define INVENTORY_TRADE_LEFT_SCROLLER_Y INVENTORY_TRADE_SCROLLER_Y + #define INVENTORY_TRADE_RIGHT_SCROLLER_X 395 +#define INVENTORY_TRADE_RIGHT_SCROLLER_Y INVENTORY_TRADE_SCROLLER_Y #define INVENTORY_TRADE_INNER_LEFT_SCROLLER_X 165 -#define INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X 250 +#define INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y INVENTORY_TRADE_INNER_SCROLLER_Y -#define INVENTORY_TRADE_OUTER_SCROLLER_Y 35 -#define INVENTORY_TRADE_INNER_SCROLLER_Y 20 +#define INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X 250 +#define INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y INVENTORY_TRADE_INNER_SCROLLER_Y #define INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_X 0 #define INVENTORY_TRADE_LEFT_SCROLLER_TRACKING_Y 10 @@ -123,6 +129,48 @@ #define INVENTORY_LOOT_LEFT_BODY_VIEW_X 44 #define INVENTORY_LOOT_LEFT_BODY_VIEW_Y 35 +#define INVENTORY_SUMMARY_X 297 +#define INVENTORY_SUMMARY_Y 44 +#define INVENTORY_SUMMARY_MAX_X 440 + +#define INVENTORY_WINDOW_WIDTH 499 +#define INVENTORY_USE_ON_WINDOW_WIDTH 292 +#define INVENTORY_LOOT_WINDOW_WIDTH 537 +#define INVENTORY_TRADE_WINDOW_WIDTH 480 +#define INVENTORY_TIMER_WINDOW_WIDTH 259 + +#define INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH 640 +#define INVENTORY_TRADE_BACKGROUND_WINDOW_HEIGHT 480 +#define INVENTORY_TRADE_WINDOW_OFFSET ((INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH - INVENTORY_TRADE_WINDOW_WIDTH) / 2) + +#define INVENTORY_SLOT_PADDING 4 + +#define INVENTORY_SCROLLER_X_PAD (INVENTORY_SCROLLER_X + INVENTORY_SLOT_PADDING) +#define INVENTORY_SCROLLER_Y_PAD (INVENTORY_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_LOOT_LEFT_SCROLLER_X_PAD (INVENTORY_LOOT_LEFT_SCROLLER_X + INVENTORY_SLOT_PADDING) +#define INVENTORY_LOOT_LEFT_SCROLLER_Y_PAD (INVENTORY_LOOT_LEFT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_LOOT_RIGHT_SCROLLER_X_PAD (INVENTORY_LOOT_RIGHT_SCROLLER_X + INVENTORY_SLOT_PADDING) +#define INVENTORY_LOOT_RIGHT_SCROLLER_Y_PAD (INVENTORY_LOOT_RIGHT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_TRADE_LEFT_SCROLLER_X_PAD 26 +#define INVENTORY_TRADE_LEFT_SCROLLER_Y_PAD (INVENTORY_TRADE_LEFT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_TRADE_LEFT_SCROLLER_X_AUX 20 + +#define INVENTORY_TRADE_RIGHT_SCROLLER_X_PAD (INVENTORY_TRADE_RIGHT_SCROLLER_X + 2) +#define INVENTORY_TRADE_RIGHT_SCROLLER_Y_PAD (INVENTORY_TRADE_RIGHT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD (INVENTORY_TRADE_INNER_LEFT_SCROLLER_X + INVENTORY_SLOT_PADDING) +#define INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y_PAD (INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD (INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X + INVENTORY_SLOT_PADDING) +#define INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y_PAD (INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y + INVENTORY_SLOT_PADDING) + +#define INVENTORY_SLOT_WIDTH_PAD (INVENTORY_SLOT_WIDTH - INVENTORY_SLOT_PADDING * 2) +#define INVENTORY_SLOT_HEIGHT_PAD (INVENTORY_SLOT_HEIGHT - INVENTORY_SLOT_PADDING * 2) + #define INVENTORY_NORMAL_WINDOW_PC_ROTATION_DELAY (1000U / ROTATION_COUNT) #define OFF_59E7BC_COUNT 12 @@ -275,12 +323,12 @@ static int _inven_display_msg_line = 1; // 0x519068 static const InventoryWindowDescription gInventoryWindowDescriptions[INVENTORY_WINDOW_TYPE_COUNT] = { - { 48, 499, 377, 80, 0 }, - { 113, 292, 376, 80, 0 }, - { 114, 537, 376, 80, 0 }, - { 111, 480, 180, 80, 290 }, - { 305, 259, 162, 140, 80 }, - { 305, 259, 162, 140, 80 }, + { 48, INVENTORY_WINDOW_WIDTH, 377, 80, 0 }, + { 113, INVENTORY_USE_ON_WINDOW_WIDTH, 376, 80, 0 }, + { 114, INVENTORY_LOOT_WINDOW_WIDTH, 376, 80, 0 }, + { 111, INVENTORY_TRADE_WINDOW_WIDTH, 180, 80, 290 }, + { 305, INVENTORY_TIMER_WINDOW_WIDTH, 162, 140, 80 }, + { 305, INVENTORY_TIMER_WINDOW_WIDTH, 162, 140, 80 }, }; // 0x5190E0 @@ -711,15 +759,15 @@ static bool _setup_inventory(int inventoryWindowType) gInventorySlotsCount = 3; // Trade inventory window is a part of game dialog, which is 640x480. - int tradeWindowX = (screenGetWidth() - 640) / 2 + INVENTORY_TRADE_WINDOW_X; - int tradeWindowY = (screenGetHeight() - 480) / 2 + INVENTORY_TRADE_WINDOW_Y; + int tradeWindowX = (screenGetWidth() - INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH) / 2 + INVENTORY_TRADE_WINDOW_X; + int tradeWindowY = (screenGetHeight() - INVENTORY_TRADE_BACKGROUND_WINDOW_HEIGHT) / 2 + INVENTORY_TRADE_WINDOW_Y; gInventoryWindow = windowCreate(tradeWindowX, tradeWindowY, INVENTORY_TRADE_WINDOW_WIDTH, INVENTORY_TRADE_WINDOW_HEIGHT, 257, 0); gInventoryWindowMaxX = tradeWindowX + INVENTORY_TRADE_WINDOW_WIDTH; gInventoryWindowMaxY = tradeWindowY + INVENTORY_TRADE_WINDOW_HEIGHT; unsigned char* dest = windowGetBuffer(gInventoryWindow); unsigned char* src = windowGetBuffer(_barter_back_win); - blitBufferToBuffer(src + INVENTORY_TRADE_WINDOW_X, INVENTORY_TRADE_WINDOW_WIDTH, INVENTORY_TRADE_WINDOW_HEIGHT, 640, dest, INVENTORY_TRADE_WINDOW_WIDTH); + blitBufferToBuffer(src + INVENTORY_TRADE_WINDOW_X, INVENTORY_TRADE_WINDOW_WIDTH, INVENTORY_TRADE_WINDOW_HEIGHT, INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH, dest, INVENTORY_TRADE_WINDOW_WIDTH); gInventoryPrintItemDescriptionHandler = gameDialogRenderSupplementaryMessage; } @@ -754,7 +802,7 @@ static bool _setup_inventory(int inventoryWindowType) y -= INVENTORY_SLOT_HEIGHT; } } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { - int y1 = INVENTORY_TRADE_OUTER_SCROLLER_Y; + int y1 = INVENTORY_TRADE_SCROLLER_Y; int y2 = INVENTORY_TRADE_INNER_SCROLLER_Y; for (int index = 0; index < gInventorySlotsCount; index++) { @@ -1194,7 +1242,7 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) int v49 = 0; if (inventoryWindowType == INVENTORY_WINDOW_TYPE_NORMAL) { - pitch = 499; + pitch = INVENTORY_WINDOW_WIDTH; int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 48, 0, 0, 0); @@ -1202,7 +1250,7 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (backgroundFrmData != NULL) { // Clear scroll view background. - blitBufferToBuffer(backgroundFrmData + pitch * 35 + 44, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * 35 + 44, pitch); + blitBufferToBuffer(backgroundFrmData + pitch * INVENTORY_SCROLLER_Y + INVENTORY_SCROLLER_X, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * INVENTORY_SCROLLER_Y + INVENTORY_SCROLLER_X, pitch); // Clear armor button background. blitBufferToBuffer(backgroundFrmData + pitch * INVENTORY_ARMOR_SLOT_Y + INVENTORY_ARMOR_SLOT_X, INVENTORY_LARGE_SLOT_WIDTH, INVENTORY_LARGE_SLOT_HEIGHT, pitch, windowBuffer + pitch * INVENTORY_ARMOR_SLOT_Y + INVENTORY_ARMOR_SLOT_X, pitch); @@ -1228,7 +1276,7 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) artUnlock(backgroundFrmHandle); } } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_USE_ITEM_ON) { - pitch = 292; + pitch = INVENTORY_USE_ON_WINDOW_WIDTH; int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 113, 0, 0, 0); @@ -1236,11 +1284,11 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (backgroundFrmData != NULL) { // Clear scroll view background. - blitBufferToBuffer(backgroundFrmData + pitch * 35 + 44, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * 35 + 44, pitch); + blitBufferToBuffer(backgroundFrmData + pitch * INVENTORY_SCROLLER_Y + INVENTORY_SCROLLER_X, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * INVENTORY_SCROLLER_Y + INVENTORY_SCROLLER_X, pitch); artUnlock(backgroundFrmHandle); } } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_LOOT) { - pitch = 537; + pitch = INVENTORY_LOOT_WINDOW_WIDTH; int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 114, 0, 0, 0); @@ -1248,16 +1296,16 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (backgroundFrmData != NULL) { // Clear scroll view background. - blitBufferToBuffer(backgroundFrmData + pitch * 37 + 176, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * 37 + 176, pitch); + blitBufferToBuffer(backgroundFrmData + pitch * INVENTORY_LOOT_LEFT_SCROLLER_Y + INVENTORY_LOOT_LEFT_SCROLLER_X, INVENTORY_SLOT_WIDTH, gInventorySlotsCount * INVENTORY_SLOT_HEIGHT, pitch, windowBuffer + pitch * INVENTORY_LOOT_LEFT_SCROLLER_Y + INVENTORY_LOOT_LEFT_SCROLLER_X, pitch); artUnlock(backgroundFrmHandle); } } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { - pitch = 480; + pitch = INVENTORY_TRADE_WINDOW_WIDTH; windowBuffer = windowGetBuffer(gInventoryWindow); - blitBufferToBuffer(windowGetBuffer(_barter_back_win) + 35 * 640 + 100, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, 640, windowBuffer + pitch * 35 + 20, pitch); - v49 = -20; + blitBufferToBuffer(windowGetBuffer(_barter_back_win) + INVENTORY_TRADE_LEFT_SCROLLER_Y * INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH + INVENTORY_TRADE_LEFT_SCROLLER_X_AUX + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH, windowBuffer + pitch * INVENTORY_TRADE_LEFT_SCROLLER_Y + INVENTORY_TRADE_LEFT_SCROLLER_X_AUX, pitch); + v49 = -INVENTORY_TRADE_LEFT_SCROLLER_X_AUX; } else { assert(false && "Should be unreachable"); } @@ -1289,26 +1337,26 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) int width; int offset; if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { - offset = pitch * (y + 39) + 26; + offset = pitch * (y + INVENTORY_TRADE_LEFT_SCROLLER_Y_PAD) + INVENTORY_TRADE_LEFT_SCROLLER_X_PAD; width = 59; } else { if (inventoryWindowType == INVENTORY_WINDOW_TYPE_LOOT) { - offset = pitch * (y + 41) + 180; + offset = pitch * (y + INVENTORY_LOOT_LEFT_SCROLLER_Y_PAD) + INVENTORY_LOOT_LEFT_SCROLLER_X_PAD; } else { - offset = pitch * (y + 39) + 48; + offset = pitch * (y + INVENTORY_SCROLLER_Y_PAD) + INVENTORY_SCROLLER_X_PAD; } - width = 56; + width = INVENTORY_SLOT_WIDTH_PAD; } InventoryItem* inventoryItem = &(_pud->items[_pud->length - v21]); int inventoryFid = itemGetInventoryFid(inventoryItem->item); - artRender(inventoryFid, windowBuffer + offset, width, 40, pitch); + artRender(inventoryFid, windowBuffer + offset, width, INVENTORY_SLOT_HEIGHT_PAD, pitch); if (inventoryWindowType == INVENTORY_WINDOW_TYPE_LOOT) { - offset = pitch * (y + 41) + 180 + v49; + offset = pitch * (y + INVENTORY_LOOT_LEFT_SCROLLER_Y_PAD) + INVENTORY_LOOT_LEFT_SCROLLER_X_PAD + v49; } else { - offset = pitch * (y + 39) + 48 + v49; + offset = pitch * (y + INVENTORY_SCROLLER_Y_PAD) + INVENTORY_SCROLLER_X_PAD + v49; } _display_inventory_info(inventoryItem->item, inventoryItem->quantity, windowBuffer + offset, pitch, v19 == a2); @@ -1320,17 +1368,17 @@ static void _display_inventory(int a1, int a2, int inventoryWindowType) if (gInventoryRightHandItem != NULL) { int width = gInventoryRightHandItem == gInventoryLeftHandItem ? INVENTORY_LARGE_SLOT_WIDTH * 2 : INVENTORY_LARGE_SLOT_WIDTH; int inventoryFid = itemGetInventoryFid(gInventoryRightHandItem); - artRender(inventoryFid, windowBuffer + 499 * INVENTORY_RIGHT_HAND_SLOT_Y + INVENTORY_RIGHT_HAND_SLOT_X, width, INVENTORY_LARGE_SLOT_HEIGHT, 499); + artRender(inventoryFid, windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_RIGHT_HAND_SLOT_Y + INVENTORY_RIGHT_HAND_SLOT_X, width, INVENTORY_LARGE_SLOT_HEIGHT, INVENTORY_WINDOW_WIDTH); } if (gInventoryLeftHandItem != NULL && gInventoryLeftHandItem != gInventoryRightHandItem) { int inventoryFid = itemGetInventoryFid(gInventoryLeftHandItem); - artRender(inventoryFid, windowBuffer + 499 * INVENTORY_LEFT_HAND_SLOT_Y + INVENTORY_LEFT_HAND_SLOT_X, INVENTORY_LARGE_SLOT_WIDTH, INVENTORY_LARGE_SLOT_HEIGHT, 499); + artRender(inventoryFid, windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_LEFT_HAND_SLOT_Y + INVENTORY_LEFT_HAND_SLOT_X, INVENTORY_LARGE_SLOT_WIDTH, INVENTORY_LARGE_SLOT_HEIGHT, INVENTORY_WINDOW_WIDTH); } if (gInventoryArmor != NULL) { int inventoryFid = itemGetInventoryFid(gInventoryArmor); - artRender(inventoryFid, windowBuffer + 499 * INVENTORY_ARMOR_SLOT_Y + INVENTORY_ARMOR_SLOT_X, INVENTORY_LARGE_SLOT_WIDTH, INVENTORY_LARGE_SLOT_HEIGHT, 499); + artRender(inventoryFid, windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_ARMOR_SLOT_Y + INVENTORY_ARMOR_SLOT_X, INVENTORY_LARGE_SLOT_WIDTH, INVENTORY_LARGE_SLOT_HEIGHT, INVENTORY_WINDOW_WIDTH); } } @@ -1349,21 +1397,21 @@ static void _display_target_inventory(int a1, int a2, Inventory* inventory, int int pitch; if (inventoryWindowType == INVENTORY_WINDOW_TYPE_LOOT) { - pitch = 537; + pitch = INVENTORY_LOOT_WINDOW_WIDTH; int fid = buildFid(OBJ_TYPE_INTERFACE, 114, 0, 0, 0); CacheEntry* handle; unsigned char* data = artLockFrameData(fid, 0, 0, &handle); if (data != NULL) { - blitBufferToBuffer(data + 537 * 37 + 297, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, 537, windowBuffer + 537 * 37 + 297, 537); + blitBufferToBuffer(data + pitch * INVENTORY_LOOT_RIGHT_SCROLLER_Y + INVENTORY_LOOT_RIGHT_SCROLLER_X, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, pitch, windowBuffer + pitch * INVENTORY_LOOT_RIGHT_SCROLLER_Y + INVENTORY_LOOT_RIGHT_SCROLLER_X, pitch); artUnlock(handle); } } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { - pitch = 480; + pitch = INVENTORY_TRADE_WINDOW_WIDTH; unsigned char* src = windowGetBuffer(_barter_back_win); - blitBufferToBuffer(src + 640 * 35 + 475, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, 640, windowBuffer + 480 * 35 + 395, 480); + blitBufferToBuffer(src + INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH * INVENTORY_TRADE_RIGHT_SCROLLER_Y + INVENTORY_TRADE_RIGHT_SCROLLER_X + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT * gInventorySlotsCount, INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH, windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_TRADE_RIGHT_SCROLLER_Y + INVENTORY_TRADE_RIGHT_SCROLLER_X, INVENTORY_TRADE_WINDOW_WIDTH); } else { assert(false && "Should be unreachable"); } @@ -1377,16 +1425,16 @@ static void _display_target_inventory(int a1, int a2, Inventory* inventory, int int offset; if (inventoryWindowType == INVENTORY_WINDOW_TYPE_LOOT) { - offset = pitch * (y + 41) + 301; + offset = pitch * (y + INVENTORY_LOOT_RIGHT_SCROLLER_Y_PAD) + INVENTORY_LOOT_RIGHT_SCROLLER_X_PAD; } else if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { - offset = pitch * (y + 39) + 397; + offset = pitch * (y + INVENTORY_TRADE_RIGHT_SCROLLER_Y_PAD) + INVENTORY_TRADE_RIGHT_SCROLLER_X_PAD; } else { assert(false && "Should be unreachable"); } InventoryItem* inventoryItem = &(inventory->items[inventory->length - (v27 + 1)]); int inventoryFid = itemGetInventoryFid(inventoryItem->item); - artRender(inventoryFid, windowBuffer + offset, 56, 40, pitch); + artRender(inventoryFid, windowBuffer + offset, INVENTORY_SLOT_WIDTH_PAD, INVENTORY_SLOT_HEIGHT_PAD, pitch); _display_inventory_info(inventoryItem->item, inventoryItem->quantity, windowBuffer + offset, pitch, index == a2); y += INVENTORY_SLOT_HEIGHT; @@ -1584,10 +1632,10 @@ static void _display_body(int fid, int inventoryWindowType) int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 114, 0, 0, 0); unsigned char* src = artLockFrameData(backgroundFid, 0, 0, &backrgroundFrmHandle); if (src != NULL) { - blitBufferToBuffer(src + 537 * rect.top + rect.left, + blitBufferToBuffer(src + INVENTORY_LOOT_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_BODY_VIEW_WIDTH, INVENTORY_BODY_VIEW_HEIGHT, - 537, + INVENTORY_LOOT_WINDOW_WIDTH, windowBuffer + windowPitch * rect.top + rect.left, windowPitch); } @@ -1791,8 +1839,8 @@ static void _inven_pickup(int keyCode, int a2) // NOTE: Original code a little bit different, this code path // is only for key codes below 1006. v3 = keyCode - 1000; - rect.left = 44; - rect.top = INVENTORY_SLOT_HEIGHT * v3 + 35; + rect.left = INVENTORY_SCROLLER_X; + rect.top = INVENTORY_SLOT_HEIGHT * v3 + INVENTORY_SCROLLER_Y; break; } @@ -1813,7 +1861,7 @@ static void _inven_pickup(int keyCode, int a2) int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 48, 0, 0, 0); unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (backgroundFrmData != NULL) { - blitBufferToBuffer(backgroundFrmData + 499 * rect.top + rect.left, width, height, 499, windowBuffer + 499 * rect.top + rect.left, 499); + blitBufferToBuffer(backgroundFrmData + INVENTORY_WINDOW_WIDTH * rect.top + rect.left, width, height, INVENTORY_WINDOW_WIDTH, windowBuffer + INVENTORY_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_WINDOW_WIDTH); artUnlock(backgroundFrmHandle); } @@ -1824,7 +1872,7 @@ static void _inven_pickup(int keyCode, int a2) int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 48, 0, 0, 0); unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle); if (backgroundFrmData != NULL) { - blitBufferToBuffer(backgroundFrmData + 499 * 286 + 154, 180, 61, 499, windowBuffer + 499 * 286 + 154, 499); + blitBufferToBuffer(backgroundFrmData + INVENTORY_WINDOW_WIDTH * 286 + 154, 180, 61, INVENTORY_WINDOW_WIDTH, windowBuffer + INVENTORY_WINDOW_WIDTH * 286 + 154, INVENTORY_WINDOW_WIDTH); artUnlock(backgroundFrmHandle); } @@ -2365,44 +2413,44 @@ static void inventoryRenderSummary() CacheEntry* backgroundHandle; unsigned char* backgroundData = artLockFrameData(fid, 0, 0, &backgroundHandle); if (backgroundData != NULL) { - blitBufferToBuffer(backgroundData + 499 * 44 + 297, 152, 188, 499, windowBuffer + 499 * 44 + 297, 499); + blitBufferToBuffer(backgroundData + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X, 152, 188, INVENTORY_WINDOW_WIDTH, windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X, INVENTORY_WINDOW_WIDTH); } artUnlock(backgroundHandle); // Render character name. const char* critterName = critterGetName(_stack[0]); - fontDrawText(windowBuffer + 499 * 44 + 297, critterName, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X, critterName, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); bufferDrawLine(windowBuffer, - 499, - 297, - 3 * fontGetLineHeight() / 2 + 44, - 440, - 3 * fontGetLineHeight() / 2 + 44, + INVENTORY_WINDOW_WIDTH, + INVENTORY_SUMMARY_X, + 3 * fontGetLineHeight() / 2 + INVENTORY_SUMMARY_Y, + INVENTORY_SUMMARY_MAX_X, + 3 * fontGetLineHeight() / 2 + INVENTORY_SUMMARY_Y, _colorTable[992]); MessageListItem messageListItem; - int offset = 499 * 2 * fontGetLineHeight() + 499 * 44 + 297; + int offset = INVENTORY_WINDOW_WIDTH * 2 * fontGetLineHeight() + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X; for (int stat = 0; stat < 7; stat++) { messageListItem.num = stat; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { - fontDrawText(windowBuffer + offset, messageListItem.text, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, messageListItem.text, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } int value = critterGetStat(_stack[0], stat); sprintf(formattedText, "%d", value); - fontDrawText(windowBuffer + offset + 24, formattedText, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset + 24, formattedText, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); } - offset -= 499 * 7 * fontGetLineHeight(); + offset -= INVENTORY_WINDOW_WIDTH * 7 * fontGetLineHeight(); for (int index = 0; index < 7; index += 1) { messageListItem.num = 7 + index; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { - fontDrawText(windowBuffer + offset + 40, messageListItem.text, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset + 40, messageListItem.text, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } if (v57[index] == -1) { @@ -2415,13 +2463,13 @@ static void inventoryRenderSummary() sprintf(formattedText, format, value1, value2); } - fontDrawText(windowBuffer + offset + 104, formattedText, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset + 104, formattedText, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); } - bufferDrawLine(windowBuffer, 499, 297, 18 * fontGetLineHeight() / 2 + 48, 440, 18 * fontGetLineHeight() / 2 + 48, _colorTable[992]); - bufferDrawLine(windowBuffer, 499, 297, 26 * fontGetLineHeight() / 2 + 48, 440, 26 * fontGetLineHeight() / 2 + 48, _colorTable[992]); + bufferDrawLine(windowBuffer, INVENTORY_WINDOW_WIDTH, INVENTORY_SUMMARY_X, 18 * fontGetLineHeight() / 2 + 48, INVENTORY_SUMMARY_MAX_X, 18 * fontGetLineHeight() / 2 + 48, _colorTable[992]); + bufferDrawLine(windowBuffer, INVENTORY_WINDOW_WIDTH, INVENTORY_SUMMARY_X, 26 * fontGetLineHeight() / 2 + 48, INVENTORY_SUMMARY_MAX_X, 26 * fontGetLineHeight() / 2 + 48, _colorTable[992]); Object* itemsInHands[2] = { gInventoryLeftHandItem, @@ -2443,7 +2491,7 @@ static void inventoryRenderSummary() HIT_MODE_KICK, }; - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); for (int index = 0; index < 2; index += 1) { Object* item = itemsInHands[index]; @@ -2453,10 +2501,10 @@ static void inventoryRenderSummary() // No item messageListItem.num = 14; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { - fontDrawText(windowBuffer + offset, messageListItem.text, 120, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, messageListItem.text, 120, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); // Unarmed dmg: messageListItem.num = 24; @@ -2490,16 +2538,16 @@ static void inventoryRenderSummary() bonusDamage + meleeDamage + maxDamage); } - fontDrawText(windowBuffer + offset, formattedText, 120, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, formattedText, 120, INVENTORY_WINDOW_WIDTH, _colorTable[992]); - offset += 3 * 499 * fontGetLineHeight(); + offset += 3 * INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); continue; } const char* itemName = itemGetName(item); - fontDrawText(windowBuffer + offset, itemName, 140, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, itemName, 140, INVENTORY_WINDOW_WIDTH, _colorTable[992]); - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); int itemType = itemGetType(item); if (itemType != ITEM_TYPE_WEAPON) { @@ -2507,11 +2555,11 @@ static void inventoryRenderSummary() // (Not worn) messageListItem.num = 18; if (messageListGetItem(&gInventoryMessageList, &messageListItem)) { - fontDrawText(windowBuffer + offset, messageListItem.text, 120, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, messageListItem.text, 120, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } } - offset += 3 * 499 * fontGetLineHeight(); + offset += 3 * INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); continue; } @@ -2587,10 +2635,10 @@ static void inventoryRenderSummary() } } - fontDrawText(windowBuffer + offset, formattedText, 140, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, formattedText, 140, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } - offset += 499 * fontGetLineHeight(); + offset += INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); if (ammoGetCapacity(item) > 0) { int ammoTypePid = weaponGetAmmoTypePid(item); @@ -2617,10 +2665,10 @@ static void inventoryRenderSummary() sprintf(formattedText, "%s %d/%d", messageListItem.text, quantity, capacity); } - fontDrawText(windowBuffer + offset, formattedText, 140, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset, formattedText, 140, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } - offset += 2 * 499 * fontGetLineHeight(); + offset += 2 * INVENTORY_WINDOW_WIDTH * fontGetLineHeight(); } // Total wt: @@ -2636,12 +2684,12 @@ static void inventoryRenderSummary() color = _colorTable[31744]; } - fontDrawText(windowBuffer + offset + 15, formattedText, 120, 499, color); + fontDrawText(windowBuffer + offset + 15, formattedText, 120, INVENTORY_WINDOW_WIDTH, color); } else { int inventoryWeight = objectGetInventoryWeight(_stack[0]); sprintf(formattedText, "%s %d", messageListItem.text, inventoryWeight); - fontDrawText(windowBuffer + offset + 30, formattedText, 80, 499, _colorTable[992]); + fontDrawText(windowBuffer + offset + 30, formattedText, 80, INVENTORY_WINDOW_WIDTH, _colorTable[992]); } } @@ -3025,7 +3073,7 @@ static void inventoryRenderItemDescription(char* string) fontSetCurrent(101); unsigned char* windowBuffer = windowGetBuffer(gInventoryWindow); - windowBuffer += 499 * 44 + 297; + windowBuffer += INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X; char* c = string; while (c != NULL && *c != '\0') { @@ -3047,7 +3095,7 @@ static void inventoryRenderItemDescription(char* string) // This was the last line containing very long word. Text // drawing routine will silently truncate it after reaching // desired length. - fontDrawText(windowBuffer + 499 * _inven_display_msg_line * fontGetLineHeight(), c, 152, 499, _colorTable[992]); + fontDrawText(windowBuffer + INVENTORY_WINDOW_WIDTH * _inven_display_msg_line * fontGetLineHeight(), c, 152, INVENTORY_WINDOW_WIDTH, _colorTable[992]); return; } @@ -3088,7 +3136,7 @@ static void inventoryRenderItemDescription(char* string) return; } - fontDrawText(windowBuffer + 499 * _inven_display_msg_line * fontGetLineHeight(), c, 152, 499, _colorTable[992]); + fontDrawText(windowBuffer + INVENTORY_WINDOW_WIDTH * _inven_display_msg_line * fontGetLineHeight(), c, 152, INVENTORY_WINDOW_WIDTH, _colorTable[992]); if (space != NULL) { c = space + 1; @@ -3119,7 +3167,7 @@ static void inventoryExamineItem(Object* critter, Object* item) CacheEntry* handle; unsigned char* backgroundData = artLockFrameData(backgroundFid, 0, 0, &handle); if (backgroundData != NULL) { - blitBufferToBuffer(backgroundData + 499 * 44 + 297, 152, 188, 499, windowBuffer + 499 * 44 + 297, 499); + blitBufferToBuffer(backgroundData + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X, 152, 188, INVENTORY_WINDOW_WIDTH, windowBuffer + INVENTORY_WINDOW_WIDTH * INVENTORY_SUMMARY_Y + INVENTORY_SUMMARY_X, INVENTORY_WINDOW_WIDTH); } artUnlock(handle); @@ -3137,10 +3185,10 @@ static void inventoryExamineItem(Object* critter, Object* item) // Draw separator. bufferDrawLine(windowBuffer, - 499, - 297, + INVENTORY_WINDOW_WIDTH, + INVENTORY_SUMMARY_X, 3 * lineHeight / 2 + 49, - 440, + INVENTORY_SUMMARY_MAX_X, 3 * lineHeight / 2 + 49, _colorTable[992]); @@ -3329,8 +3377,8 @@ static void inventoryWindowOpenContextMenu(int keyCode, int inventoryWindowType) if (inventoryWindowType == INVENTORY_WINDOW_TYPE_TRADE) { unsigned char* src = windowGetBuffer(_barter_back_win); - int pitch = 640; - blitBufferToBuffer(src + pitch * rect.top + rect.left + 80, + int pitch = INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH; + blitBufferToBuffer(src + pitch * rect.top + rect.left + INVENTORY_TRADE_WINDOW_OFFSET, cursorData->width, menuButtonHeight, pitch, @@ -3998,7 +4046,7 @@ static int _move_inventory(Object* a1, int a2, Object* a3, bool a4) int fid = buildFid(OBJ_TYPE_INTERFACE, 114, 0, 0, 0); unsigned char* data = artLockFrameData(fid, 0, 0, &handle); if (data != NULL) { - blitBufferToBuffer(data + 537 * rect.top + rect.left, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, 537, windowBuffer + 537 * rect.top + rect.left, 537); + blitBufferToBuffer(data + INVENTORY_LOOT_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, INVENTORY_LOOT_WINDOW_WIDTH, windowBuffer + INVENTORY_LOOT_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_LOOT_WINDOW_WIDTH); artUnlock(handle); } @@ -4215,8 +4263,8 @@ static void _barter_move_inventory(Object* a1, int quantity, int a3, int a4, Obj unsigned char* dest = windowGetBuffer(gInventoryWindow); unsigned char* src = windowGetBuffer(_barter_back_win); - int pitch = 640; - blitBufferToBuffer(src + pitch * rect.top + rect.left + 80, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, pitch, dest + 480 * rect.top + rect.left, 480); + int pitch = INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH; + blitBufferToBuffer(src + pitch * rect.top + rect.left + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, pitch, dest + INVENTORY_TRADE_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_TRADE_WINDOW_WIDTH); rect.right = rect.left + INVENTORY_SLOT_WIDTH - 1; rect.bottom = rect.top + INVENTORY_SLOT_HEIGHT - 1; @@ -4281,11 +4329,11 @@ static void _barter_move_from_table_inventory(Object* a1, int quantity, int a3, { Rect rect; if (a6) { - rect.left = 169; - rect.top = INVENTORY_SLOT_HEIGHT * a3 + 24; + rect.left = INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD; + rect.top = INVENTORY_SLOT_HEIGHT * a3 + INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y_PAD; } else { - rect.left = 254; - rect.top = INVENTORY_SLOT_HEIGHT * a3 + 24; + rect.left = INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD; + rect.top = INVENTORY_SLOT_HEIGHT * a3 + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y_PAD; } if (quantity > 1) { @@ -4298,8 +4346,8 @@ static void _barter_move_from_table_inventory(Object* a1, int quantity, int a3, unsigned char* dest = windowGetBuffer(gInventoryWindow); unsigned char* src = windowGetBuffer(_barter_back_win); - int pitch = 640; - blitBufferToBuffer(src + pitch * rect.top + rect.left + 80, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, pitch, dest + 480 * rect.top + rect.left, 480); + int pitch = INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH; + blitBufferToBuffer(src + pitch * rect.top + rect.left + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, INVENTORY_SLOT_HEIGHT, pitch, dest + INVENTORY_TRADE_WINDOW_WIDTH * rect.top + rect.left, INVENTORY_TRADE_WINDOW_WIDTH); rect.right = rect.left + INVENTORY_SLOT_WIDTH - 1; rect.bottom = rect.top + INVENTORY_SLOT_HEIGHT - 1; @@ -4372,17 +4420,17 @@ static void inventoryWindowRenderInnerInventories(int win, Object* a2, Object* a if (a2 != NULL) { unsigned char* src = windowGetBuffer(win); - blitBufferToBuffer(src + 640 * 20 + 249, INVENTORY_SLOT_WIDTH, v45 + 1, 640, windowBuffer + 480 * 20 + 169, 480); + blitBufferToBuffer(src + INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH * INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y + INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, v45 + 1, INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH, windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y + INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD, INVENTORY_TRADE_WINDOW_WIDTH); - unsigned char* dest = windowBuffer + 480 * 24 + 169; + unsigned char* dest = windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y_PAD + INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD; Inventory* inventory = &(a2->data.inventory); for (int index = 0; index < gInventorySlotsCount && index + _ptable_offset < inventory->length; index++) { InventoryItem* inventoryItem = &(inventory->items[inventory->length - (index + _ptable_offset + 1)]); int inventoryFid = itemGetInventoryFid(inventoryItem->item); - artRender(inventoryFid, dest, 56, 40, 480); - _display_inventory_info(inventoryItem->item, inventoryItem->quantity, dest, 480, index == a4); + artRender(inventoryFid, dest, INVENTORY_SLOT_WIDTH_PAD, INVENTORY_SLOT_HEIGHT_PAD, INVENTORY_TRADE_WINDOW_WIDTH); + _display_inventory_info(inventoryItem->item, inventoryItem->quantity, dest, INVENTORY_TRADE_WINDOW_WIDTH, index == a4); - dest += 480 * INVENTORY_SLOT_HEIGHT; + dest += INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_SLOT_HEIGHT; } if (gGameDialogSpeakerIsPartyMember) { @@ -4398,29 +4446,30 @@ static void inventoryWindowRenderInnerInventories(int win, Object* a2, Object* a sprintf(formattedText, "$%d", cost); } - fontDrawText(windowBuffer + 480 * (INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + 24) + 169, formattedText, 80, 480, _colorTable[32767]); + fontDrawText(windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * (INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y_PAD) + INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD, formattedText, 80, INVENTORY_TRADE_WINDOW_WIDTH, _colorTable[32767]); Rect rect; - rect.left = 169; - rect.top = 24; - rect.right = 223; + rect.left = INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD; + rect.top = INVENTORY_TRADE_INNER_LEFT_SCROLLER_Y_PAD; + // NOTE: Odd math, the only way to get 223 is to subtract 2. + rect.right = INVENTORY_TRADE_INNER_LEFT_SCROLLER_X_PAD + INVENTORY_SLOT_WIDTH_PAD - 2; rect.bottom = rect.top + v45; windowRefreshRect(gInventoryWindow, &rect); } if (a3 != NULL) { unsigned char* src = windowGetBuffer(win); - blitBufferToBuffer(src + 640 * 20 + 334, INVENTORY_SLOT_WIDTH, v45 + 1, 640, windowBuffer + 480 * 20 + 254, 480); + blitBufferToBuffer(src + INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH * INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD + INVENTORY_TRADE_WINDOW_OFFSET, INVENTORY_SLOT_WIDTH, v45 + 1, INVENTORY_TRADE_BACKGROUND_WINDOW_WIDTH, windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD, INVENTORY_TRADE_WINDOW_WIDTH); - unsigned char* dest = windowBuffer + 480 * 24 + 254; + unsigned char* dest = windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y_PAD + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD; Inventory* inventory = &(a3->data.inventory); for (int index = 0; index < gInventorySlotsCount && index + _btable_offset < inventory->length; index++) { InventoryItem* inventoryItem = &(inventory->items[inventory->length - (index + _btable_offset + 1)]); int inventoryFid = itemGetInventoryFid(inventoryItem->item); - artRender(inventoryFid, dest, 56, 40, 480); - _display_inventory_info(inventoryItem->item, inventoryItem->quantity, dest, 480, index == a4); + artRender(inventoryFid, dest, INVENTORY_SLOT_WIDTH_PAD, INVENTORY_SLOT_HEIGHT_PAD, INVENTORY_TRADE_WINDOW_WIDTH); + _display_inventory_info(inventoryItem->item, inventoryItem->quantity, dest, INVENTORY_TRADE_WINDOW_WIDTH, index == a4); - dest += 480 * INVENTORY_SLOT_HEIGHT; + dest += INVENTORY_TRADE_WINDOW_WIDTH * INVENTORY_SLOT_HEIGHT; } if (gGameDialogSpeakerIsPartyMember) { @@ -4436,12 +4485,13 @@ static void inventoryWindowRenderInnerInventories(int win, Object* a2, Object* a sprintf(formattedText, "$%d", cost); } - fontDrawText(windowBuffer + 480 * (INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + 24) + 254, formattedText, 80, 480, _colorTable[32767]); + fontDrawText(windowBuffer + INVENTORY_TRADE_WINDOW_WIDTH * (INVENTORY_SLOT_HEIGHT * gInventorySlotsCount + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y_PAD) + INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD, formattedText, 80, INVENTORY_TRADE_WINDOW_WIDTH, _colorTable[32767]); Rect rect; - rect.left = 254; - rect.top = 24; - rect.right = 318; + rect.left = INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD; + rect.top = INVENTORY_TRADE_INNER_RIGHT_SCROLLER_Y_PAD; + // NOTE: Odd math, likely should be `INVENTORY_SLOT_WIDTH_PAD`. + rect.right = INVENTORY_TRADE_INNER_RIGHT_SCROLLER_X_PAD + INVENTORY_SLOT_WIDTH; rect.bottom = rect.top + v45; windowRefreshRect(gInventoryWindow, &rect); }