show owned drugs on buy/sell menu

closes #3
This commit is contained in:
Rudis Muiznieks 2022-06-21 10:50:50 -05:00
parent a48e0f71e9
commit 168fc15b31
Signed by: rudism
GPG Key ID: CABF2F86EF7884F9
3 changed files with 45 additions and 32 deletions

View File

@ -160,3 +160,35 @@ void buildDrugMenu(const long extra[6]) {
menuCols = true;
menuSmall = col1Max + col2Max > 22;
}
int getMenuBackOut() {
// this whole thing could have been done so much better :(
// i suck at C++
switch (sGameState) {
case STATE_SELL_MENU:
case STATE_BORROW_INPUT:
case STATE_WITHDRAW_INPUT:
return 1;
case STATE_INVENTORY:
return 2;
case STATE_JET_MENU:
return 3;
case STATE_SHARK_MENU:
return 4;
case STATE_BANK_MENU:
return 5;
case STATE_BUY_QTY_INPUT:
case STATE_SELL_QTY_INPUT:
return sCurrentDrug;
case STATE_INFO_DIALOG:
switch (sPreviousGameState) {
case STATE_BUY_MENU:
case STATE_SELL_MENU:
return sCurrentDrug;
default:
return 0;
}
default:
return 0;
}
}

View File

@ -198,6 +198,7 @@ void loop() {
buildDrugMenu(sDrugPrices);
drawMenu(menuSmall, menuCols, menuLength, menu);
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
drawDrugsOwned(menuSelected);
break;
case STATE_JET_MENU: {
@ -437,6 +438,9 @@ void loop() {
}
}
drawMenuIndicator(menuSelected, menuSmall, menuCols, menuLength, menu, false);
if (sGameState == STATE_BUY_MENU || sGameState == STATE_SELL_MENU) {
drawDrugsOwned(menuSelected);
}
}
break;
}
@ -669,3 +673,12 @@ void drawFightPrompt() {
arduboy.drawCircle(67, 58, 5, WHITE);
arduboy.drawCircle(103, 58, 5, WHITE);
}
void drawDrugsOwned(Drug drug) {
// wipe old indicator
arduboy.fillRect(60, 9, 68, 12, BLACK);
String numStr = String(pInventory[drug]);
font3x5.setCursor(92 - numStr.length() * 4, 13);
font3x5.print("You own ");
font3x5.print(numStr);
}

View File

@ -192,38 +192,6 @@ void newDayRandomEvent() {
}
}
int getMenuBackOut() {
// this whole thing could have been done so much better :(
// i suck at C++
switch (sGameState) {
case STATE_SELL_MENU:
case STATE_BORROW_INPUT:
case STATE_WITHDRAW_INPUT:
return 1;
case STATE_INVENTORY:
return 2;
case STATE_JET_MENU:
return 3;
case STATE_SHARK_MENU:
return 4;
case STATE_BANK_MENU:
return 5;
case STATE_BUY_QTY_INPUT:
case STATE_SELL_QTY_INPUT:
return sCurrentDrug;
case STATE_INFO_DIALOG:
switch (sPreviousGameState) {
case STATE_BUY_MENU:
case STATE_SELL_MENU:
return sCurrentDrug;
default:
return 0;
}
default:
return 0;
}
}
void handleMenuAction() {
screenInitialized = false;
switch (sGameState) {