update UI and code to clarify that out wandering locs are shared
This commit is contained in:
@@ -646,7 +646,6 @@ static void put_out_wand_in_dlog(cDialog& me, short which, const cOutdoors::cWan
|
||||
me["onflee"].setTextToNum(wand.spec_on_flee);
|
||||
me["endy"].setTextToNum(wand.end_spec1);
|
||||
me["endx"].setTextToNum(wand.end_spec2);
|
||||
me["location"].setText(boost::lexical_cast<std::string>(current_terrain->wandering_locs[which]));
|
||||
}
|
||||
|
||||
// mode 0 - wandering, 1 - special, 100 - do not commit changes to the scenario yet
|
||||
@@ -662,16 +661,13 @@ static void save_out_wand(cDialog& me, short which, cOutdoors::cWandering& wand,
|
||||
wand.cant_flee = dynamic_cast<cLed&>(me["no-flee"]).getState() != led_off;
|
||||
|
||||
switch(mode) {
|
||||
case 0:{
|
||||
case 0:
|
||||
current_terrain->wandering[which] = wand;
|
||||
location old_loc = current_terrain->wandering_locs[which];
|
||||
location new_loc = boost::lexical_cast<location>(me["location"].getText());
|
||||
current_terrain->wandering_locs[which] = new_loc;
|
||||
undo_list.add(action_ptr(new aEditOutEncounter(cur_out, which, old_wand, old_loc, wand, new_loc)));
|
||||
}break;
|
||||
undo_list.add(action_ptr(new aEditOutEncounter(true, cur_out, which, old_wand, wand)));
|
||||
break;
|
||||
case 1:
|
||||
current_terrain->special_enc[which] = wand;
|
||||
undo_list.add(action_ptr(new aEditOutEncounter(cur_out, which, old_wand, wand)));
|
||||
undo_list.add(action_ptr(new aEditOutEncounter(false, cur_out, which, old_wand, wand)));
|
||||
break;
|
||||
}
|
||||
update_edit_menu();
|
||||
@@ -680,9 +676,8 @@ static void save_out_wand(cDialog& me, short which, cOutdoors::cWandering& wand,
|
||||
static bool edit_out_wand_event_filter(cDialog& me, std::string hit, short& which, cOutdoors::cWandering& wand, short mode) {
|
||||
if(!me.toast(true)) return true;
|
||||
|
||||
bool loc_changed = (mode == 0 && current_terrain->wandering_locs[which] != boost::lexical_cast<location>(me["location"].getText()));
|
||||
cOutdoors::cWandering old_wand = (mode == 0 ? current_terrain->wandering[which] : current_terrain->special_enc[which]);
|
||||
if((loc_changed || wand != old_wand)){
|
||||
if(wand != old_wand){
|
||||
// Confirm before moving left/right and committing changes
|
||||
if(hit == "left" || hit == "right"){
|
||||
cChoiceDlog dlog("confirm-edit-out-wand", {"keep","revert","cancel"}, &me);
|
||||
@@ -772,18 +767,30 @@ void edit_out_wand(short mode) {
|
||||
me["endy"].setTextToNum(sdf.y);
|
||||
return true;
|
||||
});
|
||||
wand_dlg["choose-location"].attachClickHandler([&which](cDialog& me, std::string, eKeyMod) {
|
||||
location current = boost::lexical_cast<location>(me["location"].getText());
|
||||
current = cLocationPicker(current, *town, "Choose wandering encounter " + std::to_string(which) + " location", &me).run();
|
||||
me["location"].setText(boost::lexical_cast<std::string>(current));
|
||||
return true;
|
||||
});
|
||||
|
||||
for(int i = 0; i < current_terrain->wandering_locs.size(); ++i){
|
||||
wand_dlg["choose-loc" + std::to_string(i+1)].attachClickHandler([&which, i](cDialog& me, std::string, eKeyMod) {
|
||||
location current = boost::lexical_cast<location>(me["loc" + std::to_string(i+1)].getText());
|
||||
location new_loc = cLocationPicker(current, *current_terrain, "Choose wandering encounter location " + std::to_string(i+1), &me).run();
|
||||
if(new_loc != current){
|
||||
me["loc" + std::to_string(i+1)].setText(boost::lexical_cast<std::string>(new_loc));
|
||||
current_terrain->wandering_locs[i] = new_loc;
|
||||
undo_list.add(action_ptr(new aMoveOutEncounterLoc(i, current, new_loc)));
|
||||
update_edit_menu();
|
||||
}
|
||||
return true;
|
||||
});
|
||||
wand_dlg["loc" + std::to_string(i+1)].setText(boost::lexical_cast<std::string>(current_terrain->wandering_locs[which]));
|
||||
if(mode == 1){
|
||||
wand_dlg["loc" + std::to_string(i+1)].hide();
|
||||
wand_dlg["choose-loc" + std::to_string(i+1)].hide();
|
||||
}
|
||||
}
|
||||
|
||||
if(mode == 1){
|
||||
wand_dlg["title"].setText("Outdoor Special Encounter:");
|
||||
wand_dlg["loc-label"].hide();
|
||||
wand_dlg["location"].hide();
|
||||
wand_dlg["choose-location"].hide();
|
||||
wand_dlg["loc-label2"].hide();
|
||||
}
|
||||
|
||||
put_out_wand_in_dlog(wand_dlg, which, wand);
|
||||
|
@@ -986,7 +986,6 @@ bool aEditOutEncounter::undo_me() {
|
||||
cOutdoors& outdoors = *scenario.outdoors[out_sec.x][out_sec.y];
|
||||
auto& encounters = (mode == 0 ? outdoors.wandering : outdoors.special_enc);
|
||||
encounters[which] = old_enc;
|
||||
if(mode == 0) outdoors.wandering_locs[which] = old_loc;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -994,7 +993,17 @@ bool aEditOutEncounter::redo_me() {
|
||||
cOutdoors& outdoors = *scenario.outdoors[out_sec.x][out_sec.y];
|
||||
auto& encounters = (mode == 0 ? outdoors.wandering : outdoors.special_enc);
|
||||
encounters[which] = new_enc;
|
||||
if(mode == 0) outdoors.wandering_locs[which] = new_loc;
|
||||
return true;
|
||||
}
|
||||
|
||||
// as a cTerrainAction, this one will already have the correct outdoor section active
|
||||
bool aMoveOutEncounterLoc::undo_me() {
|
||||
current_terrain->wandering_locs[which] = old_loc;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aMoveOutEncounterLoc::redo_me() {
|
||||
current_terrain->wandering_locs[which] = area.where;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -655,18 +655,22 @@ class aEditOutEncounter : public cAction {
|
||||
size_t which;
|
||||
cOutdoors::cWandering old_enc;
|
||||
cOutdoors::cWandering new_enc;
|
||||
// Ignored for special encounters:
|
||||
location old_loc;
|
||||
location new_loc;
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
public:
|
||||
aEditOutEncounter(location out_sec, size_t which, cOutdoors::cWandering old_enc, location old_loc, cOutdoors::cWandering new_enc, location new_loc) :
|
||||
cAction("Edit Outdoor Wandering Encounter"),
|
||||
out_sec(out_sec), mode(0), which(which), old_enc(old_enc), old_loc(old_loc), new_enc(new_enc), new_loc(new_loc) {}
|
||||
aEditOutEncounter(location out_sec, size_t which, cOutdoors::cWandering old_enc, cOutdoors::cWandering new_enc) :
|
||||
cAction("Edit Outdoor Special Encounter"),
|
||||
out_sec(out_sec), mode(1), which(which), old_enc(old_enc), new_enc(new_enc) {}
|
||||
aEditOutEncounter(bool wandering, location out_sec, size_t which, cOutdoors::cWandering old_enc, cOutdoors::cWandering new_enc) :
|
||||
cAction(wandering ? "Edit Outdoor Wandering Encounter" : "Edit Outdoor Special Encounter"),
|
||||
out_sec(out_sec), mode(wandering ? 0 : 1), which(which), old_enc(old_enc), new_enc(new_enc) {}
|
||||
};
|
||||
|
||||
class aMoveOutEncounterLoc : public cTerrainAction {
|
||||
size_t which;
|
||||
location old_loc;
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
public:
|
||||
aMoveOutEncounterLoc(size_t which, location old_loc, location new_loc) :
|
||||
cTerrainAction("Move Outdoor Encounter Location", new_loc), which(which), old_loc(old_loc) {}
|
||||
};
|
||||
|
||||
class aEditPersonality : public cAction {
|
||||
|
Reference in New Issue
Block a user