Refactor shopkeeper menu and add money box to overworld menu.

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
master
sigonasr2 2 years ago
parent c8083c3485
commit 9535d6fa54
  1. BIN
      C++ProjectTemplate
  2. 49
      main.cpp

Binary file not shown.

@ -1284,6 +1284,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (closest!=nullptr) {
//Run the Interaction for this object.
INTERACTING_WITH=closest;
GAME_STATE=GameState::GAME_WORLD;
Interaction interaction = closest->Interact();
if (interaction.messages.size()>0) {
INTERACTION_MESSAGES=interaction.messages;
@ -1934,8 +1935,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
case GameState::OVERWORLD_EQUIP_MENU:
case GameState::OVERWORLD_EQUIP_PLAYER_MENU:
case GameState::OVERWORLD_STATUS_MENU:
case GameState::OVERWORLD_TARGET_MENU:
case GameState::SHOPKEEPER_MENU:{
case GameState::OVERWORLD_TARGET_MENU:{
DrawGameWorld();
SetDrawTarget(layer::INTERFACE);
if (GAME_STATE!=GameState::GAME_WORLD&&GAME_STATE!=GameState::OVERWORLD_TARGET_MENU) {
@ -1947,6 +1947,7 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
DrawStringPropDecal(boxPos+textPos,MENU_ITEMS[i]);
}
DrawDecal({static_cast<float>(2+4),static_cast<float>(2+6+OVERWORLD_MENU_SELECTION*16)},SPRITES["cursor.png"]);
DrawMoneyBox({(float)boxPos.x,(float)boxPos.y+5*16+4},{WIDTH/4+4,HEIGHT/6});
}
if (GAME_STATE==GameState::OVERWORLD_EQUIP_PLAYER_MENU||GAME_STATE==GameState::OVERWORLD_EQUIP_MENU||GAME_STATE==GameState::OVERWORLD_EQUIP_ITEM_MENU) {
DrawDialogBox({4,4},{(int)(WIDTH/1.5),HEIGHT/4},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
@ -2070,25 +2071,27 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
if (GAME_STATE==GameState::OVERWORLD_POWER_MENU||GAME_STATE==GameState::OVERWORLD_POWER_PLAYER_MENU||GAME_STATE==GameState::OVERWORLD_GRADE_MENU) {
DrawBattleMoveList(OVERWORLD_POWER_SELECTION_MEMBER);
}
if (GAME_STATE==GameState::SHOPKEEPER_MENU) {
DrawDialogBox({1,1},{WIDTH/2-2,HEIGHT/2},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDialogBox({(int)(WIDTH/2+2),2},{(int)(WIDTH/2-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
for (int i=0;i<SHOP_ITEMS.size();i++) {
DrawStringPropDecal({12,(float)(8+i*12)},SHOP_ITEMS[i].first->name,WHITE,AutoScaleText(SHOP_ITEMS[i].first->name,WIDTH*(1.f/3)-14));
std::string moneyText="$"+std::to_string(SHOP_ITEMS[i].second);
vf2d textSize=GetTextSizeProp(moneyText);
DrawStringPropDecal({WIDTH*(1.f/3)+4,(float)(8+i*12)},moneyText);
vf2d textSize2=(vf2d)GetTextSizeProp("00");
DrawStringPropDecal({WIDTH*(1.f/3)+4+textSize.x,(float)(8+i*12)},"00",WHITE,{0.4f,0.7f});
DrawLineDecal({WIDTH*(1.f/3)+4+textSize.x,(float)(8+i*12+textSize2.y*0.7f)},{WIDTH*(1.f/3)+4+textSize.x+textSize2.x*0.4f,(float)(8+i*12+textSize2.y*0.7f)});
}
DrawMoneyBox({2,HEIGHT/2+2});
DrawStringPropDecal({12,(float)(8+SHOP_ITEMS.size()*12)},"Exit",WHITE);
DrawDecal({4,(float)(8+SHOP_MENU_CURSOR*12)},SPRITES["cursor.png"]);
if (SHOP_MENU_CURSOR<SHOP_ITEMS.size()) {
DrawStringPropDecal({(int)(WIDTH/2)+6,6},Wrap(SHOP_ITEMS[SHOP_MENU_CURSOR].first->description,(int)(WIDTH/2)-6,true,{1,1}));
}
}break;
case GameState::SHOPKEEPER_MENU:{
DrawGameWorld();
SetDrawTarget(layer::INTERFACE);
DrawDialogBox({1,1},{WIDTH/2-2,HEIGHT/2},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
DrawDialogBox({(int)(WIDTH/2+2),2},{(int)(WIDTH/2-4),(int)(HEIGHT/4)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
for (int i=0;i<SHOP_ITEMS.size();i++) {
DrawStringPropDecal({12,(float)(8+i*12)},SHOP_ITEMS[i].first->name,WHITE,AutoScaleText(SHOP_ITEMS[i].first->name,WIDTH*(1.f/3)-14));
std::string moneyText="$"+std::to_string(SHOP_ITEMS[i].second);
vf2d textSize=GetTextSizeProp(moneyText);
DrawStringPropDecal({WIDTH*(1.f/3)+4,(float)(8+i*12)},moneyText);
vf2d textSize2=(vf2d)GetTextSizeProp("00");
DrawStringPropDecal({WIDTH*(1.f/3)+4+textSize.x,(float)(8+i*12)},"00",WHITE,{0.4f,0.7f});
DrawLineDecal({WIDTH*(1.f/3)+4+textSize.x,(float)(8+i*12+textSize2.y*0.7f)},{WIDTH*(1.f/3)+4+textSize.x+textSize2.x*0.4f,(float)(8+i*12+textSize2.y*0.7f)});
}
DrawMoneyBox({2,HEIGHT/2+2});
DrawStringPropDecal({12,(float)(8+SHOP_ITEMS.size()*12)},"Exit",WHITE);
DrawDecal({4,(float)(8+SHOP_MENU_CURSOR*12)},SPRITES["cursor.png"]);
if (SHOP_MENU_CURSOR<SHOP_ITEMS.size()) {
DrawStringPropDecal({(int)(WIDTH/2)+6,6},Wrap(SHOP_ITEMS[SHOP_MENU_CURSOR].first->description,(int)(WIDTH/2)-6,true,{1,1}));
}
}break;
case GameState::EDITOR:{
@ -4837,8 +4840,8 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
}
//The player's money count. It's shown in a box that is WIDTH/4 and HEIGHT/6 in size.
void DrawMoneyBox(vf2d pos) {
DrawDialogBox(pos,{(int)(WIDTH/4),(int)(HEIGHT/6)},Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
void DrawMoneyBox(vf2d pos,vf2d size={(int)(WIDTH/4),(int)(HEIGHT/6)}) {
DrawDialogBox(pos,size,Pixel(70, 33, 105,220),Pixel(62, 54, 69,220),Pixel(185, 148, 255,220));
std::string drawStr="$ "+std::to_string(MONEY);
vf2d textSize=GetTextSizeProp(drawStr);
vf2d stringOffset={4,2+(HEIGHT/12)-textSize.y};

Loading…
Cancel
Save