undo/redo for clearing non-location strings

This commit is contained in:
2025-06-21 12:20:12 -05:00
parent a37931121c
commit 66d6e197b9
2 changed files with 13 additions and 4 deletions

View File

@@ -344,6 +344,13 @@ static bool handle_lb_click(location the_point) {
return false;
}
static void clear_string(eStrMode mode, size_t which) {
std::string& value = fetch_str(mode, which);
undo_list.add(action_ptr(new aEditClearString(edit_string_action_name(true, mode), mode, which, value, "*")));
update_edit_menu();
value = "*";
}
static bool handle_rb_action(location the_point, bool option_hit) {
long right_top = right_sbar->getPosition();
for(int i = 0; i < NRSONPAGE && i + right_top < NRS; i++)
@@ -426,7 +433,7 @@ static bool handle_rb_action(location the_point, bool option_hit) {
scenario.spec_strs.pop_back();
else if(j == size_before)
scenario.spec_strs.resize(size_before + 8, "*");
else scenario.spec_strs[j] = "*";
else clear_string(STRS_SCEN, j);
} else {
if(j == size_before)
scenario.spec_strs.emplace_back("*");
@@ -445,7 +452,7 @@ static bool handle_rb_action(location the_point, bool option_hit) {
current_terrain->spec_strs.pop_back();
else if(j == size_before)
current_terrain->spec_strs.resize(size_before + 8, "*");
else current_terrain->spec_strs[j] = "*";
else clear_string(STRS_OUT, j);
} else {
if(j == size_before)
current_terrain->spec_strs.emplace_back("*");
@@ -464,7 +471,7 @@ static bool handle_rb_action(location the_point, bool option_hit) {
town->spec_strs.pop_back();
else if(j == size_before)
town->spec_strs.resize(size_before + 8, "*");
else town->spec_strs[j] = "*";
else clear_string(STRS_TOWN, j);
} else {
if(j == size_before)
town->spec_strs.emplace_back("*");
@@ -517,7 +524,7 @@ static bool handle_rb_action(location the_point, bool option_hit) {
scenario.journal_strs.pop_back();
else if(j == size_before)
scenario.journal_strs.resize(size_before + 8, "*");
else scenario.journal_strs[j] = "*";
else clear_string(STRS_JOURNAL, j);
} else {
if(j == size_before)
scenario.journal_strs.emplace_back("*");

View File

@@ -115,5 +115,7 @@ enum ePalBtn {
};
extern std::string& fetch_str(eStrMode str_mode, size_t which);
extern std::string edit_string_action_name(bool clear, eStrMode str_mode);
#endif