Traveling Merchant Purchase Window and systems implemented.
This commit is contained in:
@@ -41,13 +41,15 @@ All rights reserved.
|
||||
#include "RowMerchantInventoryScrollableWindowComponent.h"
|
||||
#include "MenuItemItemButton.h"
|
||||
#include "MenuComponent.h"
|
||||
#include "PlayerMoneyLabel.h"
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_ITEM_CATEGORIES
|
||||
INCLUDE_DATA
|
||||
INCLUDE_GFX
|
||||
|
||||
void Menu::InitializeMerchantWindow(){
|
||||
Menu*merchantWindow=CreateMenu(MERCHANT,CENTERED,game->GetScreenSize()-vi2d{24,24});
|
||||
Menu*merchantWindow=CreateMenu(MERCHANT,CENTERED,game->GetScreenSize()-vi2d{52,52});
|
||||
|
||||
static std::string lastInventoryTypeOpened="";
|
||||
|
||||
@@ -63,7 +65,12 @@ void Menu::InitializeMerchantWindow(){
|
||||
[](MenuFuncData data){
|
||||
RowItemDisplay*item=dynamic_cast<RowItemDisplay*>(data.component);
|
||||
Component<MenuLabel>(BUY_ITEM,"Item Purchase Header")->S(A::ITEM_NAME)=item->GetItem().ActualName();
|
||||
Component<MenuLabel>(BUY_ITEM,"Price per item Amount Label")->SetLabel(std::to_string(item->GetItem().BuyValue()));
|
||||
Component<MenuLabel>(BUY_ITEM,"Amount to buy Amount Label")->SetLabel("1");
|
||||
Component<MenuLabel>(BUY_ITEM,"Total Price Amount Label")->SetLabel(std::to_string(item->GetItem().BuyValue()));
|
||||
Merchant&merchant=Merchant::GetCurrentTravelingMerchant();
|
||||
Component<MenuLabel>(BUY_ITEM,"Item Purchase Header")->SetLabel("Buying "+item->GetItem().DisplayName());
|
||||
Component<MenuComponent>(BUY_ITEM,"Purchase Button")->SetGrayedOut(!merchant.CanPurchaseItem(item->GetItem().DisplayName(),1));
|
||||
Menu::OpenMenu(BUY_ITEM);
|
||||
return true;
|
||||
},
|
||||
@@ -89,4 +96,20 @@ void Menu::InitializeMerchantWindow(){
|
||||
merchantWindow->ADD("Item Name Label",MenuLabel)({{226,84},{inventoryDescriptionWidth-6,12}},"",0.75f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END;
|
||||
merchantWindow->ADD("Item Description Label",MenuLabel)({{226,94},{inventoryDescriptionWidth-6,merchantWindow->size.y-44-66}},"",0.5f,ComponentAttr::LEFT_ALIGN|ComponentAttr::SHADOW)END;
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Money Display
|
||||
vf2d moneyIconPos={224+inventoryDescriptionWidth-24,28+merchantWindow->size.y-44+8};
|
||||
auto moneyIcon=merchantWindow->ADD("Money Icon",MenuIconButton)({moneyIconPos,{24,24}},GFX["money.png"].Decal(),DO_NOTHING,IconButtonAttr::NOT_SELECTABLE|IconButtonAttr::NO_OUTLINE|IconButtonAttr::NO_BACKGROUND)END;
|
||||
std::string moneyText=std::to_string(game->GetPlayer()->GetMoney());
|
||||
vf2d moneyTextSize=game->GetTextSizeProp(moneyText)*2;
|
||||
auto moneyDisplay=merchantWindow->ADD("Money Label",PlayerMoneyLabel)({moneyIconPos-vf2d{2+moneyTextSize.x,0},moneyTextSize},2,ComponentAttr::SHADOW|ComponentAttr::LEFT_ALIGN)END;
|
||||
moneyDisplay->SetRightAlignment(true);
|
||||
Player::AddMoneyListener(moneyDisplay);
|
||||
#pragma endregion
|
||||
|
||||
merchantWindow->ADD("Leave Button",MenuComponent)({{merchantWindow->size.x/2-48,28+merchantWindow->size.y-44+6},{96,24}},"Leave",MenuType::ENUM_END,
|
||||
[](MenuFuncData data){
|
||||
Menu::CloseMenu();
|
||||
return true;
|
||||
},{2,2})END;
|
||||
}
|
||||
Reference in New Issue
Block a user