From 47b013fc22472ebdcad7e23325595a0d92939be1 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada D'Ottone Date: Thu, 9 Mar 2023 08:17:29 -0300 Subject: [PATCH] Debug menu to give items based on max quantity and map number 3digits display (#2807) --- src/debug.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/debug.c b/src/debug.c index 90081eb61..759341d86 100644 --- a/src/debug.c +++ b/src/debug.c @@ -147,7 +147,7 @@ enum { //Sound #define DEBUG_NUMBER_DIGITS_VARIABLES 5 #define DEBUG_NUMBER_DIGITS_VARIABLE_VALUE 5 #define DEBUG_NUMBER_DIGITS_ITEMS 4 -#define DEBUG_NUMBER_DIGITS_ITEM_QUANTITY 2 +#define DEBUG_NUMBER_DIGITS_ITEM_QUANTITY 3 #define DEBUG_NUMBER_ICON_X 210 #define DEBUG_NUMBER_ICON_Y 50 @@ -1015,8 +1015,8 @@ static void DebugAction_Util_Warp_SelectMapGroup(u8 taskId) gTasks[taskId].data[3] = 0; gTasks[taskId].data[4] = 0; - ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].data[3], STR_CONV_MODE_LEADING_ZEROS, 2); - ConvertIntToDecimalStringN(gStringVar2, MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1, STR_CONV_MODE_LEADING_ZEROS, 2); + ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].data[3], STR_CONV_MODE_LEADING_ZEROS, (MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1 >= 100) ? 3 : 2); + ConvertIntToDecimalStringN(gStringVar2, MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1, STR_CONV_MODE_LEADING_ZEROS, (MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1 >= 100) ? 3 : 2); StringExpandPlaceholders(gStringVar1, sDebugText_Util_WarpToMap_SelMax); GetMapName(gStringVar2, Overworld_GetMapHeaderByGroupAndId(gTasks[taskId].data[5], gTasks[taskId].data[3])->regionMapSectionId, 0); StringCopy(gStringVar3, gText_DigitIndicator[gTasks[taskId].data[4]]); @@ -1061,8 +1061,8 @@ static void DebugAction_Util_Warp_SelectMap(u8 taskId) gTasks[taskId].data[4] += 1; } - ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].data[3], STR_CONV_MODE_LEADING_ZEROS, 2); - ConvertIntToDecimalStringN(gStringVar2, MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1, STR_CONV_MODE_LEADING_ZEROS, 2); + ConvertIntToDecimalStringN(gStringVar1, gTasks[taskId].data[3], STR_CONV_MODE_LEADING_ZEROS, (max_value >= 100) ? 3 : 2); + ConvertIntToDecimalStringN(gStringVar2, MAP_GROUP_COUNT[gTasks[taskId].data[5]] - 1, STR_CONV_MODE_LEADING_ZEROS, (max_value >= 100) ? 3 : 2); StringExpandPlaceholders(gStringVar1, sDebugText_Util_WarpToMap_SelMax); GetMapName(gStringVar2, Overworld_GetMapHeaderByGroupAndId(gTasks[taskId].data[5], gTasks[taskId].data[3])->regionMapSectionId, 0); StringCopy(gStringVar3, gText_DigitIndicator[gTasks[taskId].data[4]]); @@ -1905,15 +1905,18 @@ static void DebugAction_Give_Item_SelectId(u8 taskId) } static void DebugAction_Give_Item_SelectQuantity(u8 taskId) { + u32 itemId = gTasks[taskId].data[5]; + if (JOY_NEW(DPAD_ANY)) { PlaySE(SE_SELECT); if (JOY_NEW(DPAD_UP)) { + u32 maxCapacity = (ItemId_GetPocket(itemId) - 1 == BERRIES_POCKET) ? MAX_BERRY_CAPACITY : MAX_BAG_ITEM_CAPACITY; gTasks[taskId].data[3] += sPowersOfTen[gTasks[taskId].data[4]]; - if (gTasks[taskId].data[3] >= 100) - gTasks[taskId].data[3] = 99; + if (gTasks[taskId].data[3] > maxCapacity) + gTasks[taskId].data[3] = maxCapacity; } if (JOY_NEW(DPAD_DOWN)) { @@ -1947,7 +1950,7 @@ static void DebugAction_Give_Item_SelectQuantity(u8 taskId) DestroySprite(&gSprites[gTasks[taskId].data[6]]); //Destroy item icon PlaySE(MUS_OBTAIN_ITEM); - AddBagItem(gTasks[taskId].data[5], gTasks[taskId].data[3]); + AddBagItem(itemId, gTasks[taskId].data[3]); DebugAction_DestroyExtraWindow(taskId); } else if (JOY_NEW(B_BUTTON))