PC creation tweaks

- Allow scenario designer to specify exactly which towns allow character creation in them
- Clicking the "Empty" name in the edit party dialog is now equivalent to clicking the create button
- Fix dialog not properly focusing after deleting a PC
This commit is contained in:
2015-01-26 19:33:55 -05:00
parent d0ea2064c5
commit 495a0dab54
7 changed files with 19 additions and 17 deletions

View File

@@ -17,8 +17,8 @@
<field name='exit3-y' top='285' left='371' width='39' height='16'/>
<field name='exit4-x' top='312' left='323' width='39' height='16'/>
<field name='exit4-y' top='312' left='371' width='39' height='16'/>
<button name='okay' type='regular' top='380' left='452'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='380' left='386'>Cancel</button>
<button name='okay' type='regular' top='397' left='452'>OK</button>
<button name='cancel' type='regular' def-key='esc' top='397' left='386'>Cancel</button>
<pict type='dlog' num='16' top='8' left='8'/>
<text size='large' top='6' left='50' width='256' height='17'>Advanced town details</text>
<text top='25' left='50' width='439' height='40'>
@@ -64,4 +64,5 @@
<led name='nomap' font='plain' top='353' left='50' width='200'>No automap in this town</led>
<led name='noscry' font='plain' top='370' left='50' width='200'>Defy scrying (Magic Map doesn't work)</led>
<led name='barrier' font='plain' top='387' left='50' width='220'>Magical barriers are stronger in this town</led>
<led name='tavern' font='plain' top='404' left='50' width='220'>You can create new PCs in this town</led>
</dialog>

View File

@@ -1161,10 +1161,9 @@ static bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod)
item_hit = item_hit.substr(0, item_hit.length() - 1);
if(item_hit == "name") {
if(univ.party[which_pc].main_status == eMainStatus::ABSENT) {
// TODO: Clicking a blank field made a new PC? Something to consider reinstating!
//give_help(56,0,989);
//create_pc(which_pc,989);
//cd_initial_draw(989); // extra redraw, just in case
give_help(56,0,me);
create_pc(which_pc,&me);
put_party_stats(me);
}
else pick_pc_name(which_pc,&me);
put_party_stats(me);
@@ -1181,7 +1180,7 @@ static bool edit_party_event_filter(cDialog& me, std::string item_hit, eKeyMod)
put_party_stats(me);
} else if(item_hit == "delete") { // Note: This button is also used for "create new PC".
if(univ.party[which_pc].main_status != eMainStatus::ABSENT) {
if(cChoiceDlog("delete-pc-confirm",{"yes","no"}).show() == "yes")
if(cChoiceDlog("delete-pc-confirm",{"yes","no"},&me).show() == "yes")
univ.party[which_pc].main_status = eMainStatus::ABSENT;
put_party_stats(me);
}

View File

@@ -462,16 +462,13 @@ void handle_menu_choice(eMenu item_hit) {
print_buf();
break;
}
if(univ.town.num == univ.scenario.which_town_start) {
if(univ.town->has_tavern) {
give_help(56,0);
create_pc(6,NULL);
}
else {
// TODO: Allow additional towns to specify that you can make new characters in them
// (Otherwise, certain scenarios where you can't return to the start town would prevent you from creating new characters in the scenario.)
add_string_to_buf("Add PC: You can only make new");
add_string_to_buf(" characters in the town you ");
add_string_to_buf(" started in.");
} else {
add_string_to_buf("Add PC: You cannot add new");
add_string_to_buf(" characters in this town.");
add_string_to_buf(" Try in the town you started in.");
}
print_buf();
put_pc_screen();

View File

@@ -108,7 +108,7 @@ cTown::cTown(cScenario& scenario, bool init_strings) : scenario(scenario) {
}
difficulty = 0;
bg_town = bg_fight = -1;
strong_barriers = defy_scrying = defy_mapping = is_hidden = false;
strong_barriers = defy_scrying = defy_mapping = is_hidden = has_tavern = false;
for(i = 0; i < 60; i++) {
talking.talk_nodes[i].personality = -1;
talking.talk_nodes[i].type = eTalkNode::REGULAR;

View File

@@ -94,7 +94,8 @@ public:
bool defy_mapping : 1;
bool defy_scrying : 1;
bool is_hidden : 1;
char : 4;
bool has_tavern : 1;
char : 3;
short difficulty;
std::string town_name;
// Using std::array here so we can have .size()

View File

@@ -814,6 +814,7 @@ static bool save_advanced_town(cDialog& me, std::string, eKeyMod) {
town->defy_mapping = dynamic_cast<cLed&>(me["nomap"]).getState() != led_off;
town->defy_scrying = dynamic_cast<cLed&>(me["noscry"]).getState() != led_off;
town->strong_barriers = dynamic_cast<cLed&>(me["barrier"]).getState() != led_off;
town->has_tavern = dynamic_cast<cLed&>(me["tavern"]).getState() != led_off;
return true;
}
@@ -834,6 +835,7 @@ static void put_advanced_town_in_dlog(cDialog& me) {
dynamic_cast<cLed&>(me["nomap"]).setState(town->defy_mapping ? led_red : led_off);
dynamic_cast<cLed&>(me["noscry"]).setState(town->defy_scrying ? led_red : led_off);
dynamic_cast<cLed&>(me["barrier"]).setState(town->strong_barriers ? led_red : led_off);
dynamic_cast<cLed&>(me["tavern"]).setState(town->has_tavern ? led_red : led_off);
}
static bool edit_advanced_town_special(cDialog& me, std::string hit, eKeyMod) {

View File

@@ -150,6 +150,8 @@ bool load_scenario_v1(fs::path file_to_load, cScenario& scenario){
}
load_town_v1(scenario.scen_file, i, *scenario.towns[i], *temp_scenario);
}
// Enable character creation in starting town
scenario.towns[scenario.which_town_start]->has_tavern = true;
delete temp_scenario;
delete item_data;