undo/redo for classifying graphics
This commit is contained in:
@@ -3590,6 +3590,15 @@ static bool set_custom_pic_type(cDialog& me, std::string hit, std::vector<ePicTy
|
||||
|
||||
static bool save_pics_types(cDialog& me, const std::vector<ePicType>& pics) {
|
||||
if(!me.toast(true)) return true;
|
||||
|
||||
// I could check the size, but it should always match, right?
|
||||
for(int i = 0; i < scenario.custom_graphics.size(); ++i){
|
||||
if(scenario.custom_graphics[i] != pics[i]){
|
||||
undo_list.add(action_ptr(new aClassifyGraphics(scenario.custom_graphics, pics)));
|
||||
update_edit_menu();
|
||||
break;
|
||||
}
|
||||
}
|
||||
scenario.custom_graphics = pics;
|
||||
return true;
|
||||
}
|
||||
|
@@ -879,3 +879,13 @@ bool aEditIntro::redo_me() {
|
||||
scen_set_intro(scenario, new_intro);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aClassifyGraphics::undo_me() {
|
||||
scenario.custom_graphics = old_types;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool aClassifyGraphics::redo_me() {
|
||||
scenario.custom_graphics = new_types;
|
||||
return true;
|
||||
}
|
@@ -532,4 +532,14 @@ public:
|
||||
cAction("Edit Scenario Intro/Picture"), old_intro(old_intro), new_intro(new_intro) {}
|
||||
};
|
||||
|
||||
class aClassifyGraphics : public cAction {
|
||||
std::vector<ePicType> old_types;
|
||||
std::vector<ePicType> new_types;
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
public:
|
||||
aClassifyGraphics(std::vector<ePicType> old_types, std::vector<ePicType> new_types) :
|
||||
cAction("Classify Custom Graphics"), old_types(old_types), new_types(new_types) {}
|
||||
};
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user