undo/redo setting all items not property
This commit is contained in:
8
rsrc/dialogs/no-items-property.xml
Normal file
8
rsrc/dialogs/no-items-property.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8' standalone='no'?>
|
||||||
|
<!-- NOTE: This file should be updated to use relative positioning the next time it changes. -->
|
||||||
|
<?xml-stylesheet href="dialog.xsl" type="text/xsl"?>
|
||||||
|
<dialog defbtn='okay' escbtn='okay'>
|
||||||
|
<button name='okay' type='regular' top='37' left='256'>OK</button>
|
||||||
|
<pict type='dlog' num='16' top='6' left='6'/>
|
||||||
|
<text top='6' left='49' width='272' height='28'>Nothing changed. No items in this town were marked as property.</text>
|
||||||
|
</dialog>
|
@@ -693,17 +693,28 @@ void handle_menu_choice(eMenu item_hit) {
|
|||||||
place_items_in_town();
|
place_items_in_town();
|
||||||
change_made = true;
|
change_made = true;
|
||||||
break;
|
break;
|
||||||
case eMenu::TOWN_ITEMS_NOT_PROPERTY:
|
case eMenu::TOWN_ITEMS_NOT_PROPERTY:{
|
||||||
if(!town->any_items()){
|
if(!town->any_items()){
|
||||||
cChoiceDlog("no-items").show();
|
cChoiceDlog("no-items").show();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
for(int i = 0; i < town->preset_items.size(); i++)
|
std::vector<bool> old_property;
|
||||||
town->preset_items[i].property = 0;
|
bool any_were = false;
|
||||||
cChoiceDlog("set-not-owned").show();
|
for(cTown::cItem& item: town->preset_items){
|
||||||
|
if(item.property) any_were = true;
|
||||||
|
old_property.push_back(item.property);
|
||||||
|
item.property = false;
|
||||||
|
}
|
||||||
|
if(any_were){
|
||||||
|
undo_list.add(action_ptr(new aClearProperty(old_property)));
|
||||||
|
update_edit_menu();
|
||||||
|
cChoiceDlog("set-not-owned").show();
|
||||||
|
}else{
|
||||||
|
cChoiceDlog("no-items-property").show();
|
||||||
|
}
|
||||||
draw_terrain();
|
draw_terrain();
|
||||||
change_made = true;
|
change_made = true;
|
||||||
break;
|
}break;
|
||||||
case eMenu::TOWN_ITEMS_CLEAR:{
|
case eMenu::TOWN_ITEMS_CLEAR:{
|
||||||
if(!town->any_items()){
|
if(!town->any_items()){
|
||||||
cChoiceDlog("no-items").show();
|
cChoiceDlog("no-items").show();
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
extern bool editing_town;
|
extern bool editing_town;
|
||||||
extern short cur_town;
|
extern short cur_town;
|
||||||
extern short cur_town;
|
extern cTown* town;
|
||||||
extern location cur_out;
|
extern location cur_out;
|
||||||
extern short cen_x;
|
extern short cen_x;
|
||||||
extern short cen_y;
|
extern short cen_y;
|
||||||
@@ -295,4 +295,18 @@ bool aEditTownEntrance::undo_me() {
|
|||||||
bool aEditTownEntrance::redo_me() {
|
bool aEditTownEntrance::redo_me() {
|
||||||
set_town_entrance(area.where, new_town);
|
set_town_entrance(area.where, new_town);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool aClearProperty::undo_me() {
|
||||||
|
for(size_t i = 0; i < town->preset_items.size(); ++i){
|
||||||
|
town->preset_items[i].property = old_property[i];
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool aClearProperty::redo_me() {
|
||||||
|
for(cTown::cItem& item : town->preset_items){
|
||||||
|
item.property = false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
@@ -10,6 +10,7 @@
|
|||||||
#include "scenario/vehicle.hpp"
|
#include "scenario/vehicle.hpp"
|
||||||
|
|
||||||
extern cScenario scenario;
|
extern cScenario scenario;
|
||||||
|
extern cTown* town;
|
||||||
|
|
||||||
struct area_ref_t {
|
struct area_ref_t {
|
||||||
bool is_town;
|
bool is_town;
|
||||||
@@ -49,6 +50,16 @@ protected:
|
|||||||
area_ref_t area;
|
area_ref_t area;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// Action that clears the 'not yours' flag from every item in town
|
||||||
|
class aClearProperty : public cTerrainAction {
|
||||||
|
std::vector<bool> old_property;
|
||||||
|
bool undo_me() override;
|
||||||
|
bool redo_me() override;
|
||||||
|
public:
|
||||||
|
aClearProperty(std::vector<bool> old_property) : cTerrainAction("Set All Items Not Property", town->preset_items[0].loc),
|
||||||
|
old_property(old_property) {}
|
||||||
|
};
|
||||||
|
|
||||||
/// Action that erased a special encounter from a spot
|
/// Action that erased a special encounter from a spot
|
||||||
class aEraseSpecial : public cTerrainAction {
|
class aEraseSpecial : public cTerrainAction {
|
||||||
public:
|
public:
|
||||||
|
Reference in New Issue
Block a user