undo/redo for creating area description rects
This commit is contained in:
@@ -918,10 +918,18 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
|
||||
iter->descr = "";
|
||||
if(!edit_area_rect_str(*iter))
|
||||
iter->right = 0;
|
||||
else{
|
||||
undo_list.add(action_ptr(new aCreateAreaRect(iter - area_descs.begin(), *iter)));
|
||||
update_edit_menu();
|
||||
}
|
||||
} else {
|
||||
area_descs.emplace_back(working_rect);
|
||||
if(!edit_area_rect_str(area_descs.back()))
|
||||
area_descs.pop_back();
|
||||
else{
|
||||
undo_list.add(action_ptr(new aCreateAreaRect(area_descs.size() - 1, area_descs.back())));
|
||||
update_edit_menu();
|
||||
}
|
||||
}
|
||||
change_made = true;
|
||||
}
|
||||
|
@@ -1231,4 +1231,14 @@ bool aEditTownBounds::redo_me() {
|
||||
scenario.towns[area.town_num]->in_town_rect = new_rect;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aCreateAreaRect::undo_me() {
|
||||
area->area_desc[which] = {0, 0, 0, 0, "*"};
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aCreateAreaRect::redo_me() {
|
||||
area->area_desc[which] = rect;
|
||||
return true;
|
||||
}
|
@@ -17,6 +17,7 @@
|
||||
|
||||
extern cScenario scenario;
|
||||
extern cTown* town;
|
||||
extern cArea* get_current_area();
|
||||
extern bool editing_town;
|
||||
extern short cur_town;
|
||||
extern location cur_out;
|
||||
@@ -829,4 +830,18 @@ public:
|
||||
for_saved_items(saved_items), old_rect(old_rect), new_rect(new_rect) {}
|
||||
};
|
||||
|
||||
class aCreateAreaRect : public cTerrainAction {
|
||||
size_t which;
|
||||
info_rect_t rect;
|
||||
cArea* area;
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
public:
|
||||
aCreateAreaRect(size_t which, info_rect_t rect) :
|
||||
cTerrainAction("Create Area Description", rect.topLeft()),
|
||||
which(which),
|
||||
rect(rect),
|
||||
area(get_current_area()) {}
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user