Delete the "make shop random" button in favour of a preset selection when first creating the shop - this also adds "healing" to the list of presets

This commit is contained in:
2025-02-01 12:49:27 -05:00
parent 65cf27bc81
commit 66256b305c
3 changed files with 23 additions and 10 deletions

View File

@@ -27,11 +27,7 @@
<led name='p6' top='170' left='210'>Alchemy</led>
<led name='p7' top='130' left='310'>Training</led>
</group>
<button name='rand' type='tiny' top='190' left='10'>
Click here to generate a standard random items shop.
(This will replace the entire shop definition.)
</button>
<text top='210' left='28' width='300' height='16'>Or edit the shop item list below:</text>
<text top='210' left='28' width='300' height='16'>Shop item list:</text>
<stack name='items'>
<text name='n1' top='230' left='10' width='15' height='16'/>
<pict name='pict1' type='item' num='0' size='small' top='230' left='30'/>

11
rsrc/dialogs/new-shop.xml Normal file
View File

@@ -0,0 +1,11 @@
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
<dialog defbtn='cancel'>
<text relative='pos pos-in' rel-anchor='next' top='8' left='8' size='large'>Create New Shop</text>
<pict type='dlog' num='16' top='8' left='8'/>
<text relative='pos-in pos' rel-anchor='prev' top='10' left='0'>What kind of shop do you want to create?</text>
<button name='magic' relative='pos-in pos' rel-anchor='prev' top='3' left='68' type='large'>Magic Shop</button>
<button name='heal' relative='pos-in pos' rel-anchor='prev' top='3' left='0' type='large'>Healer</button>
<button name='custom' relative='pos-in pos' rel-anchor='prev' top='3' left='0' type='large'>Custom</button>
<button name='cancel' relative='pos' rel-anchor='prev' type='regular' def-key='esc' top='10' left='5'>Cancel</button>
</dialog>

View File

@@ -2515,6 +2515,17 @@ bool edit_shop(size_t which_shop, cDialog* parent) {
if(which_shop == scenario.shops.size())
scenario.shops.emplace_back("New Shop");
cShop shop = scenario.shops[which_shop];
if(shop.size() == 0 && (shop.getName() == "New Shop" || shop.getName() == "Unused Shop")) {
cChoiceDlog new_shop_dlg("new-shop", {"magic", "heal", "custom", "cancel"});
std::string choice = new_shop_dlg.show();
if(choice == "magic") {
shop = cShop(SHOP_JUNK);
} else if(choice == "heal") {
shop = cShop(SHOP_HEALING);
} else if(choice == "cancel") {
return false;
}
}
cDialog shop_dlg(*ResMgr::dialogs.get("edit-shop"), parent);
shop_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
@@ -2524,11 +2535,6 @@ bool edit_shop(size_t which_shop, cDialog* parent) {
shop_dlg.attachClickHandlers(std::bind(delete_shop_entry, _1, _2, std::ref(shop), std::ref(which_shop)), {"del1", "del2", "del3", "del4", "del5"});
shop_dlg.attachClickHandlers(std::bind(edit_shop_entry, _1, _2, std::ref(shop)), {"ed1", "ed2", "ed3", "ed4", "ed5"});
shop_dlg.attachClickHandlers(std::bind(add_shop_entry, _1, _2, std::ref(shop), std::ref(which_shop)), {"item", "opt", "spec", "mage", "priest", "alch", "skill", "treas", "heal", "class"});
shop_dlg["rand"].attachClickHandler([&shop,which_shop](cDialog& me, std::string, eKeyMod) -> bool {
shop = cShop(SHOP_JUNK);
put_shop_in_dlog(me, shop, which_shop);
return true;
});
if(scenario.shops.size() == 1 || parent != nullptr) {
shop_dlg["left"].hide();