undo/redo for replacing custom sheet

This commit is contained in:
2025-06-18 10:46:48 -05:00
parent 403a742375
commit 14014382b3
3 changed files with 72 additions and 4 deletions

View File

@@ -806,4 +806,32 @@ bool aDeleteGraphicsSheet::redo_me() {
if(fs::exists(sheetPath)) fs::remove(sheetPath);
return true;
}
}
bool aReplaceGraphicsSheet::undo_me() {
if(index >= spec_scen_g.numSheets) {
std::string resName = "sheet" + std::to_string(index);
fs::path toPath = get_pic_dir()/(resName + ".png");
old_image.saveToFile(toPath.string().c_str());
ResMgr::graphics.free(resName);
}else{
spec_scen_g.replace_sheet(index, old_image);
}
return true;
}
bool aReplaceGraphicsSheet::redo_me() {
if(index >= spec_scen_g.numSheets) {
std::string resName = "sheet" + std::to_string(index);
fs::path toPath = get_pic_dir()/(resName + ".png");
new_image.saveToFile(toPath.string().c_str());
ResMgr::graphics.free(resName);
}else{
spec_scen_g.replace_sheet(index, new_image);
}
return true;
}