undo/redo for advanced town details
This commit is contained in:
@@ -1027,9 +1027,19 @@ void edit_advanced_town() {
|
||||
|
||||
put_advanced_town_in_dlog(town_dlg);
|
||||
|
||||
town_advanced_t old_details = advanced_from_town(cur_town, *town, scenario);
|
||||
town_dlg.run();
|
||||
if(town_dlg.accepted() && delete_rect)
|
||||
scenario.store_item_rects.erase(cur_town);
|
||||
if(town_dlg.accepted()){
|
||||
if(delete_rect){
|
||||
scenario.store_item_rects.erase(cur_town);
|
||||
}
|
||||
|
||||
town_advanced_t new_details = advanced_from_town(cur_town, *town, scenario);
|
||||
if(new_details != old_details){
|
||||
undo_list.add(action_ptr(new aEditTownAdvancedDetails(cur_town, old_details, new_details)));
|
||||
update_edit_menu();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bool save_town_wand(cDialog& me, std::string, eKeyMod) {
|
||||
|
@@ -950,4 +950,14 @@ bool aEditTownWandering::redo_me() {
|
||||
scenario.towns[which]->wandering = new_wandering;
|
||||
scenario.towns[which]->wandering_locs = new_wandering_locs;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aEditTownAdvancedDetails::undo_me() {
|
||||
town_set_advanced(which, *scenario.towns[which], scenario, old_details);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aEditTownAdvancedDetails::redo_me() {
|
||||
town_set_advanced(which, *scenario.towns[which], scenario, new_details);
|
||||
return true;
|
||||
}
|
@@ -609,4 +609,15 @@ public:
|
||||
new_wandering(new_wandering), new_wandering_locs(new_wandering_locs) {}
|
||||
};
|
||||
|
||||
class aEditTownAdvancedDetails : public cAction {
|
||||
size_t which;
|
||||
town_advanced_t old_details;
|
||||
town_advanced_t new_details;
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
public:
|
||||
aEditTownAdvancedDetails(size_t which, town_advanced_t old_details, town_advanced_t new_details) :
|
||||
cAction("Edit Town Advanced Details"), which(which), old_details(old_details), new_details(new_details) {}
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user