Author: ilor
Date: Fri Jul 25 20:30:46 2008
New Revision: 28195
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28195&view=rev
Log:
make editor2 painting more correct in line with old editor
Modified:
trunk/src/editor2/action.cpp
trunk/src/editor2/action.hpp
Modified: trunk/src/editor2/action.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.cpp?rev=28195&r1=28194&r2=28195&view=diff
==============================================================================
--- trunk/src/editor2/action.cpp (original)
+++ trunk/src/editor2/action.cpp Fri Jul 25 20:30:46 2008
@@ -27,6 +27,44 @@
std::string editor_action::get_description()
{
return "Unknown action";
+}
+
+void draw_terrain(editor_map& map, t_translation::t_terrain terrain,
+ const gamemap::location& loc, const bool one_layer_only = false)
+{
+ if (!one_layer_only) {
+ terrain = map.get_terrain_info(terrain).terrain_with_default_base();
+ }
+ t_translation::t_terrain old_terrain = map.get_terrain(loc);
+ if (terrain != old_terrain) {
+ if (terrain.base == t_translation::NO_LAYER) {
+ map.set_terrain(loc, terrain, gamemap::OVERLAY);
+ } else if (one_layer_only) {
+ map.set_terrain(loc, terrain, gamemap::BASE);
+ } else {
+ map.set_terrain(loc, terrain);
+ }
+ }
+}
+
+void draw_terrain(editor_map& map, t_translation::t_terrain terrain,
+ const std::set<gamemap::location>& locs, const bool one_layer_only =
false)
+{
+ if (!one_layer_only) {
+ terrain = map.get_terrain_info(terrain).terrain_with_default_base();
+ }
+ foreach (const gamemap::location& loc, locs) {
+ t_translation::t_terrain old_terrain = map.get_terrain(loc);
+ if (terrain != old_terrain) {
+ if (terrain.base == t_translation::NO_LAYER) {
+ map.set_terrain(loc, terrain, gamemap::OVERLAY);
+ } else if (one_layer_only) {
+ map.set_terrain(loc, terrain, gamemap::BASE);
+ } else {
+ map.set_terrain(loc, terrain);
+ }
+ }
+ }
}
editor_action_whole_map* editor_action_whole_map::perform(editor_map& m) const
{
@@ -79,7 +117,7 @@
}
void editor_action_paint_hex::perform_without_undo(editor_map& map) const
{
- map.set_terrain(loc_, t_);
+ draw_terrain(map, t_, loc_);
}
editor_action_paste* editor_action_paint_area::perform(editor_map& map) const
@@ -92,29 +130,20 @@
void editor_action_paint_area::perform_without_undo(editor_map& map) const
{
- foreach (gamemap::location loc, area_) {
- map.set_terrain(loc, t_);
- }
+ draw_terrain(map, t_, area_);
}
editor_action_paint_area* editor_action_fill::perform(editor_map& map) const
{
std::set<gamemap::location> to_fill =
map.get_contigious_terrain_tiles(loc_);
editor_action_paint_area* undo = new editor_action_paint_area(to_fill,
map.get_terrain(loc_));
- perform_actual(map, to_fill);
+ draw_terrain(map, t_, to_fill);
return undo;
}
void editor_action_fill::perform_without_undo(editor_map& map) const
{
std::set<gamemap::location> to_fill =
map.get_contigious_terrain_tiles(loc_);
- perform_actual(map, to_fill);
-}
-
-void editor_action_fill::perform_actual(editor_map& map, const
std::set<gamemap::location>& to_fill) const
-{
- foreach (gamemap::location l, to_fill) {
- map.set_terrain(l, t_);
- }
+ draw_terrain(map, t_, to_fill);
}
editor_action_whole_map* editor_action_resize_map::perform(editor_map&
/*map*/) const
Modified: trunk/src/editor2/action.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/action.hpp?rev=28195&r1=28194&r2=28195&view=diff
==============================================================================
--- trunk/src/editor2/action.hpp (original)
+++ trunk/src/editor2/action.hpp Fri Jul 25 20:30:46 2008
@@ -144,7 +144,6 @@
}
editor_action_paint_area* perform(editor_map& map) const;
void perform_without_undo(editor_map& map) const;
- void perform_actual(editor_map& map, const
std::set<gamemap::location>& to_fill) const;
};
//resize map (streching / clipping behaviour?)
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits