show better changesite for floodfill/terrain frill/item place
This commit is contained in:
@@ -291,7 +291,7 @@ aPlaceEraseItem::aPlaceEraseItem(std::string name, bool place, size_t index, cTo
|
||||
{}
|
||||
|
||||
aPlaceEraseItem::aPlaceEraseItem(std::string name, bool place, item_changes_t items)
|
||||
: cTerrainAction(name, items.begin()->second.loc, !place)
|
||||
: cTerrainAction(name, closest_to_view(items), !place)
|
||||
, items(items)
|
||||
{}
|
||||
|
||||
@@ -1249,3 +1249,19 @@ bool aCreateAreaRect::redo_me() {
|
||||
area->area_desc[which] = rect;
|
||||
return true;
|
||||
}
|
||||
|
||||
location closest_to_view(stroke_ter_changes_t changes) {
|
||||
std::vector<location> locs;
|
||||
for(auto& it : changes){
|
||||
locs.push_back(it.first);
|
||||
}
|
||||
return closest_point(locs, loc(cen_x, cen_y));
|
||||
}
|
||||
|
||||
location closest_to_view(item_changes_t changes) {
|
||||
std::vector<location> locs;
|
||||
for(auto& it : changes){
|
||||
locs.push_back(it.second.loc);
|
||||
}
|
||||
return closest_point(locs, loc(cen_x, cen_y));
|
||||
}
|
@@ -45,6 +45,9 @@ typedef std::map<location,cOutdoors*,loc_compare> outdoor_sections_t;
|
||||
typedef std::map<location,std::vector<eFieldType>,loc_compare> clear_field_stroke_t;
|
||||
typedef std::set<location,loc_compare> field_stroke_t;
|
||||
|
||||
location closest_to_view(stroke_ter_changes_t changes);
|
||||
location closest_to_view(item_changes_t changes);
|
||||
|
||||
// Action that modified something in town or outdoor terrain, so we should show the modified area when undoing or redoing
|
||||
class cTerrainAction : public cAction {
|
||||
public:
|
||||
@@ -100,7 +103,7 @@ public:
|
||||
class aDrawTerrain : public cTerrainAction {
|
||||
public:
|
||||
aDrawTerrain(std::string name, stroke_ter_changes_t stroke_changes) :
|
||||
cTerrainAction(name, stroke_changes.begin()->first), // Use arbitrary changed tile as site of change
|
||||
cTerrainAction(name, closest_to_view(stroke_changes)),
|
||||
changes(stroke_changes) {}
|
||||
bool undo_me() override;
|
||||
bool redo_me() override;
|
||||
|
Reference in New Issue
Block a user