undo/redo edit placed creatures
This commit is contained in:
@@ -1035,3 +1035,21 @@ bool cMonster::operator==(const cMonster& other) {
|
|||||||
CHECK_EQ(other, see_spec);
|
CHECK_EQ(other, see_spec);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cTownperson::operator==(const cTownperson& other) {
|
||||||
|
CHECK_EQ(other, number);
|
||||||
|
CHECK_EQ(other, start_attitude);
|
||||||
|
CHECK_EQ(other, start_loc);
|
||||||
|
CHECK_EQ(other, mobility);
|
||||||
|
CHECK_EQ(other, time_flag);
|
||||||
|
CHECK_EQ(other, spec1);
|
||||||
|
CHECK_EQ(other, spec2);
|
||||||
|
CHECK_EQ(other, spec_enc_code);
|
||||||
|
CHECK_EQ(other, time_code);
|
||||||
|
CHECK_EQ(other, monster_time);
|
||||||
|
CHECK_EQ(other, personality);
|
||||||
|
CHECK_EQ(other, special_on_kill);
|
||||||
|
CHECK_EQ(other, special_on_talk);
|
||||||
|
CHECK_EQ(other, facial_pic);
|
||||||
|
return true;
|
||||||
|
}
|
@@ -98,6 +98,10 @@ public:
|
|||||||
short special_on_kill, special_on_talk;
|
short special_on_kill, special_on_talk;
|
||||||
pic_num_t facial_pic;
|
pic_num_t facial_pic;
|
||||||
|
|
||||||
|
// For detecting actual changes to town monsters in the editor
|
||||||
|
bool operator==(const cTownperson& other);
|
||||||
|
bool operator!=(const cTownperson& other) { return !(*this == other); }
|
||||||
|
|
||||||
void import_legacy(legacy::creature_start_type old);
|
void import_legacy(legacy::creature_start_type old);
|
||||||
cTownperson();
|
cTownperson();
|
||||||
cTownperson(location loc, mon_num_t num, const cMonster& monst);
|
cTownperson(location loc, mon_num_t num, const cMonster& monst);
|
||||||
|
@@ -1015,9 +1015,15 @@ static bool handle_terrain_action(location the_point, bool ctrl_hit) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MODE_EDIT_CREATURE: //edit monst
|
case MODE_EDIT_CREATURE: //edit monst
|
||||||
for(short x = 0; x < town->creatures.size(); x++)
|
for(short x = 0; x < town->creatures.size(); x++){
|
||||||
if(monst_on_space(spot_hit,x)) {
|
if(monst_on_space(spot_hit,x)) {
|
||||||
|
cTownperson old_creature = town->creatures[x];
|
||||||
edit_placed_monst(x);
|
edit_placed_monst(x);
|
||||||
|
if(town->creatures[x] != old_creature){
|
||||||
|
undo_list.add(action_ptr(new aEditPlacedCreature(x, old_creature, town->creatures[x])));
|
||||||
|
update_edit_menu();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
overall_mode = MODE_DRAWING;
|
overall_mode = MODE_DRAWING;
|
||||||
break;
|
break;
|
||||||
|
@@ -320,3 +320,13 @@ bool aEditPlacedItem::redo_me() {
|
|||||||
town->preset_items[which] = new_item;
|
town->preset_items[which] = new_item;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool aEditPlacedCreature::undo_me() {
|
||||||
|
town->creatures[which] = old_creature;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool aEditPlacedCreature::redo_me() {
|
||||||
|
town->creatures[which] = new_creature;
|
||||||
|
return true;
|
||||||
|
}
|
@@ -108,6 +108,19 @@ public:
|
|||||||
which(which), old_item(old_item), new_item(new_item) {}
|
which(which), old_item(old_item), new_item(new_item) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Action which edits a creature in a town
|
||||||
|
class aEditPlacedCreature : public cTerrainAction {
|
||||||
|
size_t which;
|
||||||
|
cTownperson old_creature;
|
||||||
|
cTownperson new_creature;
|
||||||
|
bool undo_me() override;
|
||||||
|
bool redo_me() override;
|
||||||
|
public:
|
||||||
|
aEditPlacedCreature(size_t which, cTownperson old_creature, cTownperson new_creature) :
|
||||||
|
cTerrainAction("Edit Placed Creature", new_creature.start_loc),
|
||||||
|
which(which), old_creature(old_creature), new_creature(new_creature) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// Action which places or erases creature(s) in a town
|
/// Action which places or erases creature(s) in a town
|
||||||
class aPlaceEraseCreature : public cTerrainAction {
|
class aPlaceEraseCreature : public cTerrainAction {
|
||||||
bool placed;
|
bool placed;
|
||||||
|
Reference in New Issue
Block a user