editor2: mouse modifier on paint/fill...

...hold either alt to draw on base terrain only, like in old editor
(fill support is new but not fully done)
This commit is contained in:
Tomasz Śniatowski 2008-08-06 23:18:10 +01:00
parent 8369d1c9d8
commit acce76ae8f
7 changed files with 28 additions and 19 deletions

View file

@ -109,7 +109,7 @@ editor_action_paste* editor_action_paint_area::perform(map_context& mc) const
}
void editor_action_paint_area::perform_without_undo(map_context& mc) const
{
mc.draw_terrain(t_, area_);
mc.draw_terrain(t_, area_, one_layer_);
mc.set_needs_terrain_rebuild();
}
@ -117,14 +117,14 @@ editor_action_paint_area* editor_action_fill::perform(map_context& mc) const
{
std::set<gamemap::location> to_fill = mc.get_map().get_contigious_terrain_tiles(loc_);
editor_action_paint_area* undo = new editor_action_paint_area(to_fill, mc.get_map().get_terrain(loc_));
mc.draw_terrain(t_, to_fill);
mc.draw_terrain(t_, to_fill, one_layer_);
mc.set_needs_terrain_rebuild();
return undo;
}
void editor_action_fill::perform_without_undo(map_context& mc) const
{
std::set<gamemap::location> to_fill = mc.get_map().get_contigious_terrain_tiles(loc_);
mc.draw_terrain(t_, to_fill);
mc.draw_terrain(t_, to_fill, one_layer_);
mc.set_needs_terrain_rebuild();
}

View file

@ -137,14 +137,15 @@ class editor_action_paint_area : public editor_action_area
{
public:
editor_action_paint_area(const std::set<gamemap::location>& area,
t_translation::t_terrain t)
: editor_action_area(area), t_(t)
t_translation::t_terrain t, bool one_layer=false)
: editor_action_area(area), t_(t), one_layer_(one_layer)
{
}
editor_action_paste* perform(map_context& mc) const;
void perform_without_undo(map_context& mc) const;
protected:
t_translation::t_terrain t_;
bool one_layer_;
};
//flood fill
@ -152,12 +153,14 @@ class editor_action_fill : public editor_action_location_terrain
{
public:
editor_action_fill(gamemap::location loc,
t_translation::t_terrain t)
: editor_action_location_terrain(loc, t)
t_translation::t_terrain t, bool one_layer=false)
: editor_action_location_terrain(loc, t), one_layer_(one_layer)
{
}
editor_action_paint_area* perform(map_context& mc) const;
void perform_without_undo(map_context& mc) const;
protected:
bool one_layer_;
};
class editor_action_starting_position : public editor_action_location

View file

@ -68,9 +68,9 @@ editor_controller::editor_controller(const config &game_config, CVideo& video)
}
brush_ = &brushes_[0];
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_PAINT,
new mouse_action_paint(foreground_terrain_, &brush_)));
new mouse_action_paint(foreground_terrain_, &brush_, key_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_FILL,
new mouse_action_fill(foreground_terrain_)));
new mouse_action_fill(foreground_terrain_, key_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
new mouse_action_select(&brush_)));
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_STARTING_POSITION,

View file

@ -44,7 +44,7 @@ map_context::~map_context()
}
void map_context::draw_terrain(t_translation::t_terrain terrain,
const gamemap::location& loc, const bool one_layer_only)
const gamemap::location& loc, bool one_layer_only)
{
if (!one_layer_only) {
terrain = map_.get_terrain_info(terrain).terrain_with_default_base();
@ -63,7 +63,7 @@ void map_context::draw_terrain(t_translation::t_terrain terrain,
}
void map_context::draw_terrain(t_translation::t_terrain terrain,
const std::set<gamemap::location>& locs, const bool one_layer_only)
const std::set<gamemap::location>& locs, bool one_layer_only)
{
if (!one_layer_only) {
terrain = map_.get_terrain_info(terrain).terrain_with_default_base();

View file

@ -37,10 +37,10 @@ public:
const editor_map& get_map() const { return map_; }
void draw_terrain(t_translation::t_terrain terrain, const gamemap::location& loc,
const bool one_layer_only = false);
bool one_layer_only = false);
void draw_terrain(t_translation::t_terrain terrain, const std::set<gamemap::location>& locs,
const bool one_layer_only = false);
bool one_layer_only = false);
bool needs_reload() const { return needs_reload_; }
void set_needs_reload(bool value=true) { needs_reload_ = value; }

View file

@ -84,7 +84,8 @@ const brush& brush_drag_mouse_action::get_brush()
editor_action* mouse_action_paint::click_perform(editor_display& disp, const gamemap::location& hex)
{
return new editor_action_paint_area(get_brush().project(hex), terrain_);
bool one_layer = (key_[SDLK_RALT] || key_[SDLK_LALT]);
return new editor_action_paint_area(get_brush().project(hex), terrain_, one_layer);
}
editor_action* mouse_action_select::click(editor_display& disp, int x, int y)
@ -130,8 +131,10 @@ void mouse_action_fill::move(editor_display& disp, int x, int y)
editor_action* mouse_action_fill::click(editor_display& disp, int x, int y)
{
bool one_layer = (key_[SDLK_RALT] || key_[SDLK_LALT]);
gamemap::location hex = disp.hex_clicked_on(x, y);
editor_action_fill* a = new editor_action_fill(hex, terrain_);
//TODO only take the base terrain into account when searching for contigious terrain when painting base only
editor_action_fill* a = new editor_action_fill(hex, terrain_, one_layer);
return a;
}

View file

@ -20,6 +20,7 @@
#include "../map.hpp"
#include "../terrain.hpp"
class CKey;
namespace editor2 {
@ -81,13 +82,14 @@ private:
class mouse_action_paint : public brush_drag_mouse_action
{
public:
mouse_action_paint(const t_translation::t_terrain& terrain, const brush* const * const brush)
: brush_drag_mouse_action(brush), terrain_(terrain)
mouse_action_paint(const t_translation::t_terrain& terrain, const brush* const * const brush, const CKey& key)
: brush_drag_mouse_action(brush), terrain_(terrain), key_(key)
{
}
editor_action* click_perform(editor_display& disp, const gamemap::location& hex);
protected:
const t_translation::t_terrain& terrain_;
const CKey& key_;
};
class mouse_action_select : public brush_drag_mouse_action
@ -119,14 +121,15 @@ protected:
class mouse_action_fill : public mouse_action
{
public:
mouse_action_fill(const t_translation::t_terrain& terrain)
: mouse_action(), terrain_(terrain)
mouse_action_fill(const t_translation::t_terrain& terrain, const CKey& key)
: mouse_action(), terrain_(terrain), key_(key)
{
}
void move(editor_display& disp, int x, int y);
editor_action* click(editor_display& disp, int x, int y);
protected:
const t_translation::t_terrain& terrain_;
const CKey& key_;
};
class mouse_action_starting_position : public mouse_action