undo/redo editing sign text
This commit is contained in:
@@ -425,16 +425,18 @@ void edit_placed_item(short which_i) {
|
|||||||
|
|
||||||
static bool edit_sign_event_filter(cDialog& me, sign_loc_t& which_sign) {
|
static bool edit_sign_event_filter(cDialog& me, sign_loc_t& which_sign) {
|
||||||
if(!me.toast(true)) return true;
|
if(!me.toast(true)) return true;
|
||||||
which_sign.text = me["text"].getText();
|
|
||||||
#if 0 // TODO: Apparently there used to be left/right buttons on this dialog.
|
std::string cur_text = me["text"].getText();
|
||||||
if(item_hit == 3)
|
if(which_sign.text != cur_text){
|
||||||
which_sign--;
|
undo_list.add(action_ptr(new aEditSignText(which_sign, which_sign.text, cur_text)));
|
||||||
else which_sign++;
|
update_edit_menu();
|
||||||
if(which_sign < 0)
|
which_sign.text = cur_text;
|
||||||
which_sign = (editing_town) ? 14 : 7;
|
}
|
||||||
if(which_sign > (editing_town) ? 14 : 7)
|
|
||||||
which_sign = 0;
|
// There used to be left/right buttons in the sign editor dialog, but there shouldn't be,
|
||||||
#endif
|
// because left/right is not a meaningful index to let the designer know which sign they're editing.
|
||||||
|
// I removed the unused code.
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -244,3 +244,19 @@ bool aPlaceEraseCreature::redo_me() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool aEditSignText::undo_me() {
|
||||||
|
cArea* cur_area = get_current_area();
|
||||||
|
auto& signs = cur_area->sign_locs;
|
||||||
|
auto iter = std::find(signs.begin(), signs.end(), area.where);
|
||||||
|
iter->text = old_text;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool aEditSignText::redo_me() {
|
||||||
|
cArea* cur_area = get_current_area();
|
||||||
|
auto& signs = cur_area->sign_locs;
|
||||||
|
auto iter = std::find(signs.begin(), signs.end(), area.where);
|
||||||
|
iter->text = new_text;
|
||||||
|
return true;
|
||||||
|
}
|
@@ -35,6 +35,7 @@ class cTerrainAction : public cAction {
|
|||||||
public:
|
public:
|
||||||
cTerrainAction(std::string name, short town_num, location where, bool reversed = false);
|
cTerrainAction(std::string name, short town_num, location where, bool reversed = false);
|
||||||
cTerrainAction(std::string name, location out_sec, location where, bool reversed = false);
|
cTerrainAction(std::string name, location out_sec, location where, bool reversed = false);
|
||||||
|
// Construct cTerrainAction in the current town/outdoor section
|
||||||
cTerrainAction(std::string name, location where, bool reversed = false);
|
cTerrainAction(std::string name, location where, bool reversed = false);
|
||||||
void undo();
|
void undo();
|
||||||
void redo();
|
void redo();
|
||||||
@@ -43,6 +44,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
/// Show where the change happened
|
/// Show where the change happened
|
||||||
void showChangeSite();
|
void showChangeSite();
|
||||||
|
protected:
|
||||||
area_ref_t area;
|
area_ref_t area;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -92,6 +94,17 @@ public:
|
|||||||
aPlaceEraseCreature(std::string name, bool place, size_t index, cTownperson creature);
|
aPlaceEraseCreature(std::string name, bool place, size_t index, cTownperson creature);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Action which edits sign text
|
||||||
|
class aEditSignText : public cTerrainAction {
|
||||||
|
std::string old_text;
|
||||||
|
std::string new_text;
|
||||||
|
bool undo_me() override;
|
||||||
|
bool redo_me() override;
|
||||||
|
public:
|
||||||
|
aEditSignText(location loc, std::string old_text, std::string new_text) :
|
||||||
|
cTerrainAction("Edit Sign Text", loc), old_text(old_text), new_text(new_text) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// Action which adds a new town to the end of the list, or deletes the last one
|
/// Action which adds a new town to the end of the list, or deletes the last one
|
||||||
class aCreateDeleteTown : public cAction {
|
class aCreateDeleteTown : public cAction {
|
||||||
bool created;
|
bool created;
|
||||||
|
Reference in New Issue
Block a user