add methods get_shop to check access bounds,
+ Scenario Editor: display all talk messages
This commit is contained in:
@@ -109,7 +109,7 @@ void start_shop_mode(short which,short cost_adj,std::string store_name) {
|
|||||||
// This would be a place to hide the text box, if I add it.
|
// This would be a place to hide the text box, if I add it.
|
||||||
|
|
||||||
active_shop_num = which;
|
active_shop_num = which;
|
||||||
active_shop = univ.scenario.shops[which];
|
active_shop = univ.get_shop(which);
|
||||||
active_shop.setCostAdjust(cost_adj);
|
active_shop.setCostAdjust(cost_adj);
|
||||||
active_shop.setName(store_name);
|
active_shop.setName(store_name);
|
||||||
|
|
||||||
|
@@ -280,13 +280,35 @@ cSpecItem &cScenario::get_special_item(item_num_t item)
|
|||||||
return badItem;
|
return badItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cShop getBadShop() {
|
||||||
|
cShop badShop;
|
||||||
|
badShop.setName("Bad Shop");
|
||||||
|
badShop.setFace(-3);
|
||||||
|
return badShop;
|
||||||
|
}
|
||||||
|
cShop const &cScenario::get_shop(int shop) const
|
||||||
|
{
|
||||||
|
if (shop>=0 && shop<shops.size())
|
||||||
|
return shops[shop];
|
||||||
|
static cShop badShop=getBadShop();
|
||||||
|
return badShop;
|
||||||
|
|
||||||
|
}
|
||||||
|
cShop &cScenario::get_shop(int shop)
|
||||||
|
{
|
||||||
|
if (shop>=0 && shop<shops.size())
|
||||||
|
return shops[shop];
|
||||||
|
static cShop badShop;
|
||||||
|
badShop=getBadShop();
|
||||||
|
return badShop;
|
||||||
|
}
|
||||||
|
|
||||||
static cTerrain getBadTerrain() {
|
static cTerrain getBadTerrain() {
|
||||||
cTerrain badTerrain;
|
cTerrain badTerrain;
|
||||||
badTerrain.picture = -3;
|
badTerrain.picture = -3;
|
||||||
badTerrain.map_pic = -3;
|
badTerrain.map_pic = -3;
|
||||||
return badTerrain;
|
return badTerrain;
|
||||||
}
|
}
|
||||||
|
|
||||||
cTerrain const &cScenario::get_terrain(ter_num_t ter) const
|
cTerrain const &cScenario::get_terrain(ter_num_t ter) const
|
||||||
{
|
{
|
||||||
if (ter<ter_types.size())
|
if (ter<ter_types.size())
|
||||||
|
@@ -49,15 +49,18 @@ public:
|
|||||||
cItemStorage& operator = (legacy::item_storage_shortcut_type const &old);
|
cItemStorage& operator = (legacy::item_storage_shortcut_type const &old);
|
||||||
};
|
};
|
||||||
void destroy_terrain();
|
void destroy_terrain();
|
||||||
cTerrain const &get_terrain(ter_num_t ter) const;
|
|
||||||
cTerrain &get_terrain(ter_num_t ter);
|
|
||||||
cItem const &get_item(item_num_t item) const;
|
cItem const &get_item(item_num_t item) const;
|
||||||
cItem &get_item(item_num_t item);
|
cItem &get_item(item_num_t item);
|
||||||
cQuest const &get_quest(int quest) const;
|
cQuest const &get_quest(int quest) const;
|
||||||
cQuest &get_quest(int quest);
|
cQuest &get_quest(int quest);
|
||||||
cSpecItem const &get_special_item(item_num_t item) const;
|
cSpecItem const &get_special_item(item_num_t item) const;
|
||||||
cSpecItem &get_special_item(item_num_t item);
|
cSpecItem &get_special_item(item_num_t item);
|
||||||
|
cShop const &get_shop(int shop) const;
|
||||||
|
cShop &get_shop(int shop);
|
||||||
|
cTerrain const &get_terrain(ter_num_t ter) const;
|
||||||
|
cTerrain &get_terrain(ter_num_t ter);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned short difficulty,intro_pic,default_ground;
|
unsigned short difficulty,intro_pic,default_ground;
|
||||||
int bg_out, bg_fight, bg_town, bg_dungeon;
|
int bg_out, bg_fight, bg_town, bg_dungeon;
|
||||||
|
@@ -659,9 +659,9 @@ static bool handle_rb_action(location the_point, bool option_hit) {
|
|||||||
if(option_hit) {
|
if(option_hit) {
|
||||||
if(j == scenario.shops.size() - 1)
|
if(j == scenario.shops.size() - 1)
|
||||||
scenario.shops.pop_back();
|
scenario.shops.pop_back();
|
||||||
else scenario.shops[j] = cShop("Unused Shop");
|
else scenario.get_shop(j) = cShop("Unused Shop");
|
||||||
} else {
|
} else {
|
||||||
if(!edit_shop(j) && j == size_before && scenario.shops[j].getName() == "New Shop")
|
if(!edit_shop(j) && j == size_before && scenario.get_shop(j).getName() == "New Shop")
|
||||||
scenario.shops.pop_back();
|
scenario.shops.pop_back();
|
||||||
}
|
}
|
||||||
start_shops_editing(size_before == scenario.shops.size());
|
start_shops_editing(size_before == scenario.shops.size());
|
||||||
@@ -2516,7 +2516,7 @@ void start_shops_editing(bool just_redo_text) {
|
|||||||
std::string title;
|
std::string title;
|
||||||
if(i == scenario.shops.size())
|
if(i == scenario.shops.size())
|
||||||
title = "Create New Shop";
|
title = "Create New Shop";
|
||||||
else title = scenario.shops[i].getName();
|
else title = scenario.get_shop(i).getName();
|
||||||
title = std::to_string(i) + " - " + title;
|
title = std::to_string(i) + " - " + title;
|
||||||
set_rb(i, RB_SHOP, i, title);
|
set_rb(i, RB_SHOP, i, title);
|
||||||
}
|
}
|
||||||
@@ -2657,17 +2657,17 @@ void start_dialogue_editing(short restoring) {
|
|||||||
right_sbar->show();
|
right_sbar->show();
|
||||||
pal_sbar->hide();
|
pal_sbar->hide();
|
||||||
|
|
||||||
|
size_t n_nodes = town->talking.talk_nodes.size();
|
||||||
if(restoring == 0) {
|
if(restoring == 0) {
|
||||||
right_sbar->setPosition(0);
|
right_sbar->setPosition(0);
|
||||||
reset_rb();
|
reset_rb();
|
||||||
right_sbar->setMaximum(70 - NRSONPAGE);
|
right_sbar->setMaximum(10+n_nodes+1 - NRSONPAGE);
|
||||||
}
|
}
|
||||||
for(short i = 0; i < 10; i++) {
|
for(short i = 0; i < 10; i++) {
|
||||||
std::ostringstream strb;
|
std::ostringstream strb;
|
||||||
strb << "Personality " << (i + cur_town * 10) << " - " << town->talking.people[i].title;
|
strb << "Personality " << (i + cur_town * 10) << " - " << town->talking.people[i].title;
|
||||||
set_rb(i,RB_PERSONALITY, i, strb.str());
|
set_rb(i,RB_PERSONALITY, i, strb.str());
|
||||||
}
|
}
|
||||||
size_t n_nodes = town->talking.talk_nodes.size();
|
|
||||||
for(short i = 0; i < n_nodes; i++) {
|
for(short i = 0; i < n_nodes; i++) {
|
||||||
for(short j = 0; j < 4; j++) {
|
for(short j = 0; j < 4; j++) {
|
||||||
s[j] = town->talking.talk_nodes[i].link1[j];
|
s[j] = town->talking.talk_nodes[i].link1[j];
|
||||||
|
@@ -2215,7 +2215,7 @@ static bool save_shop_from_dlog(cDialog& me, cShop& shop, size_t which_shop, boo
|
|||||||
shop.setFace(dynamic_cast<cPict&>(me["face"]).getPicNum());
|
shop.setFace(dynamic_cast<cPict&>(me["face"]).getPicNum());
|
||||||
// Items are filled in as they're added by the dialog, so that's all we need to do here
|
// Items are filled in as they're added by the dialog, so that's all we need to do here
|
||||||
|
|
||||||
scenario.shops[which_shop] = shop;
|
scenario.get_shop(which_shop) = shop;
|
||||||
if(!close) me.untoast();
|
if(!close) me.untoast();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2234,7 +2234,7 @@ static bool change_shop_dlog_page(cDialog& me, std::string dir, cShop& shop, siz
|
|||||||
which_shop = 0;
|
which_shop = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
shop = scenario.shops[which_shop];
|
shop = scenario.get_shop(which_shop);
|
||||||
put_shop_in_dlog(me, shop, which_shop);
|
put_shop_in_dlog(me, shop, which_shop);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2465,7 +2465,7 @@ bool edit_shop(size_t which_shop, cDialog* parent) {
|
|||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
if(which_shop == scenario.shops.size())
|
if(which_shop == scenario.shops.size())
|
||||||
scenario.shops.emplace_back("New Shop");
|
scenario.shops.emplace_back("New Shop");
|
||||||
cShop shop = scenario.shops[which_shop];
|
cShop shop = scenario.get_shop(which_shop);
|
||||||
|
|
||||||
cDialog shop_dlg("edit-shop", parent);
|
cDialog shop_dlg("edit-shop", parent);
|
||||||
shop_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
|
shop_dlg["cancel"].attachClickHandler(std::bind(&cDialog::toast, _1, false));
|
||||||
|
@@ -219,6 +219,8 @@ public:
|
|||||||
cItem &get_item(item_num_t item) { return scenario.get_item(item); }
|
cItem &get_item(item_num_t item) { return scenario.get_item(item); }
|
||||||
cQuest const &get_quest(int quest) const { return scenario.get_quest(quest); }
|
cQuest const &get_quest(int quest) const { return scenario.get_quest(quest); }
|
||||||
cQuest &get_quest(int quest) { return scenario.get_quest(quest); }
|
cQuest &get_quest(int quest) { return scenario.get_quest(quest); }
|
||||||
|
cShop const &get_shop(int shop) const { return scenario.get_shop(shop); }
|
||||||
|
cShop &get_shop(int shop) { return scenario.get_shop(shop); }
|
||||||
cSpecItem const &get_special_item(item_num_t item) const { return scenario.get_special_item(item); }
|
cSpecItem const &get_special_item(item_num_t item) const { return scenario.get_special_item(item); }
|
||||||
cSpecItem &get_special_item(item_num_t item) { return scenario.get_special_item(item); }
|
cSpecItem &get_special_item(item_num_t item) { return scenario.get_special_item(item); }
|
||||||
cTerrain const &get_terrain(ter_num_t ter) const { return scenario.get_terrain(ter); }
|
cTerrain const &get_terrain(ter_num_t ter) const { return scenario.get_terrain(ter); }
|
||||||
|
Reference in New Issue
Block a user