generated from sigonasr2/CPlusPlusProjectTemplate
Basic shop item display
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
7aba68c6c0
commit
97679dd678
Binary file not shown.
23
main.cpp
23
main.cpp
@ -165,7 +165,6 @@ EquipSlot::Equip EQUIP_MENU_SLOT=EquipSlot::WEAPON;
|
|||||||
int EQUIP_ITEM_MENU_CURSOR=0;
|
int EQUIP_ITEM_MENU_CURSOR=0;
|
||||||
int EQUIP_ITEM_MENU_OFFSET=0;
|
int EQUIP_ITEM_MENU_OFFSET=0;
|
||||||
std::vector<int> EQUIP_ITEM_MENU_CONTENTS={};
|
std::vector<int> EQUIP_ITEM_MENU_CONTENTS={};
|
||||||
std::vector<std::pair<Item*,int>> SHOP_MENU_CONTENTS={};
|
|
||||||
int MESSAGE_BOX_DIALOG_ANSWER=-1;
|
int MESSAGE_BOX_DIALOG_ANSWER=-1;
|
||||||
int MESSAGE_BOX_DIALOG_CHOICES_MADE=0;
|
int MESSAGE_BOX_DIALOG_CHOICES_MADE=0;
|
||||||
std::vector<std::string> MESSAGE_BOX_CHOICE_LIST={};
|
std::vector<std::string> MESSAGE_BOX_CHOICE_LIST={};
|
||||||
@ -196,6 +195,11 @@ void DisplayMessageBox(std::string targetT) {
|
|||||||
messageBoxStopMarker=0;
|
messageBoxStopMarker=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetupShop(std::vector<std::pair<Item*,int>> shopItems){
|
||||||
|
SHOP_ITEMS.clear();
|
||||||
|
SHOP_ITEMS=shopItems;
|
||||||
|
}
|
||||||
|
|
||||||
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
bool MOUSE_PRESSED_DOWN=false,MOUSE_DOWN=false,MOUSE_RELEASED=false; //TODO Implement Mouse things.
|
||||||
|
|
||||||
std::vector<std::vector<TILE*>> MAP={}; //The foreground layer.
|
std::vector<std::vector<TILE*>> MAP={}; //The foreground layer.
|
||||||
@ -2295,6 +2299,18 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
//////////////////INTERFACE LAYER.
|
//////////////////INTERFACE LAYER.
|
||||||
SetDrawTarget(layer::INTERFACE);
|
SetDrawTarget(layer::INTERFACE);
|
||||||
|
|
||||||
|
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));
|
||||||
|
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)});
|
||||||
|
}
|
||||||
|
}
|
||||||
if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::MOVE_SELECT) {
|
if (BATTLE_ENCOUNTER!=nullptr&&BATTLE_STATE==BattleState::MOVE_SELECT) {
|
||||||
vd2d cursorOffset = {-2,-2};
|
vd2d cursorOffset = {-2,-2};
|
||||||
vd2d cursorScale = {1,1};
|
vd2d cursorScale = {1,1};
|
||||||
@ -4782,6 +4798,11 @@ This is a test message that lets us trigger straight from a cutscene! Cool!)"),
|
|||||||
bool MessageBoxAllowedToAdvance() {
|
bool MessageBoxAllowedToAdvance() {
|
||||||
return messageBoxMarker<messageBoxFinalText.length()&&!waitingForChoice;
|
return messageBoxMarker<messageBoxFinalText.length()&&!waitingForChoice;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vf2d AutoScaleText(std::string str,int targetWidth,vf2d scale={1,1},bool prop=true) {
|
||||||
|
vf2d size = ((prop)?GetTextSizeProp(str):GetTextSize(str))*scale;
|
||||||
|
return {std::min(scale.x,targetWidth/size.x),scale.y};
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
|
9
object.h
9
object.h
@ -190,6 +190,8 @@ class TrashCan_Obj : public Object{
|
|||||||
extern int MESSAGE_BOX_DIALOG_ANSWER;
|
extern int MESSAGE_BOX_DIALOG_ANSWER;
|
||||||
extern bool GAME_FLAGS[128];
|
extern bool GAME_FLAGS[128];
|
||||||
extern int GAME_STATE;
|
extern int GAME_STATE;
|
||||||
|
extern void SetupShop(std::vector<std::pair<Item*,int>> shopItems);
|
||||||
|
extern std::map<ItemName,Item*>ITEMLIST;
|
||||||
|
|
||||||
class Shopkeeper_Obj : public Object{
|
class Shopkeeper_Obj : public Object{
|
||||||
DynamicObject(Shopkeeper_Obj)
|
DynamicObject(Shopkeeper_Obj)
|
||||||
@ -221,6 +223,13 @@ class Shopkeeper_Obj : public Object{
|
|||||||
}
|
}
|
||||||
void DialogClosed()override{
|
void DialogClosed()override{
|
||||||
GAME_STATE = GameState::SHOPKEEPER_MENU;
|
GAME_STATE = GameState::SHOPKEEPER_MENU;
|
||||||
|
SetupShop(
|
||||||
|
{
|
||||||
|
{ITEMLIST[ItemName::EGG],8},
|
||||||
|
{ITEMLIST[ItemName::COOKIE],4},
|
||||||
|
{ITEMLIST[ItemName::PIZZA],36},
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
x
Reference in New Issue
Block a user