Author: ilor
Date: Thu Jul 31 14:30:57 2008
New Revision: 28286
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28286&view=rev
Log:
editor2: auto update terrain transitions switch, manual refresh functions
Modified:
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/editor_controller.hpp
trunk/src/editor2/editor_display.cpp
trunk/src/editor2/editor_display.hpp
trunk/src/mouse_handler_base.cpp
trunk/src/mouse_handler_base.hpp
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Thu Jul 31 14:30:57 2008
@@ -43,6 +43,7 @@
, mouse_handler_base(get_map())
, map_context_(editor_map(game_config, 44, 33, t_translation::GRASS_LAND))
, gui_(NULL), do_quit_(false), quit_mode_(EXIT_ERROR)
+, auto_update_transitions_(true)
{
init(video);
floating_label_manager_ = new font::floating_label_context();
@@ -350,8 +351,10 @@
case HOTKEY_EDITOR_TOOL_PAINT:
case HOTKEY_EDITOR_TOOL_FILL:
case HOTKEY_EDITOR_TOOL_SELECT:
-// case HOTKEY_EDITOR_TOOL_STARTING_POSITION:
+ case HOTKEY_EDITOR_TOOL_STARTING_POSITION:
return is_mouse_action_set(command) ? ACTION_ON :
ACTION_OFF;
+ case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS:
+ return auto_update_transitions_ ? ACTION_ON :
ACTION_OFF;
default:
return command_executor::get_action_state(command);
}
@@ -429,6 +432,19 @@
case HOTKEY_EDITOR_MAP_SAVE_AS:
save_map_as_dialog();
return true;
+ case HOTKEY_EDITOR_AUTO_UPDATE_TRANSITIONS:
+ auto_update_transitions_ = !auto_update_transitions_;
+ if (!auto_update_transitions_) {
+ return true;
+ } // else intentionally fall through
+ case HOTKEY_EDITOR_UPDATE_TRANSITIONS:
+ refresh_all();
+ return true;
+ break;
+ case HOTKEY_EDITOR_REFRESH:
+ reload_map();
+ return true;
+ break;
default:
return controller_base::execute_command(command, index);
}
@@ -567,27 +583,36 @@
}
-void editor_controller::refresh_after_action()
-{
- //TODO rebuild and ivalidate only what's really needed
+void editor_controller::refresh_after_action(bool drag_part)
+{
+
std::cerr<<__FUNCTION__<<get_map_context().changed_locations().size()<<"\n";
if (get_map_context().needs_reload()) {
+ std::cerr<<"reload\n";
reload_map();
get_map_context().set_needs_reload(false);
get_map_context().set_needs_terrain_rebuild(false);
get_map_context().clear_changed_locations();
} else if (get_map_context().needs_terrain_rebuild()) {
- gui().rebuild_all();
- gui().invalidate_all();
- get_map_context().set_needs_terrain_rebuild(false);
- get_map_context().clear_changed_locations();
- } else {
+ if (!drag_part || auto_update_transitions_ ||
get_map_context().everything_changed()) {
+ std::cerr<<"rebuild all\n";
+ gui().rebuild_all();
+ gui().invalidate_all();
+ get_map_context().set_needs_terrain_rebuild(false);
+ } else {
+ foreach (const gamemap::location& loc,
get_map_context().changed_locations()) {
+ gui().rebuild_terrain(loc);
+ }
+ gui().invalidate(get_map_context().changed_locations());
+ }
+ } else {
+ std::cerr<<"invalidate\n";
if (get_map_context().everything_changed()) {
gui().invalidate_all();
} else {
gui().invalidate(get_map_context().changed_locations());
}
- get_map_context().clear_changed_locations();
- }
+ }
+ get_map_context().clear_changed_locations();
gui().recalculate_minimap();
}
@@ -636,7 +661,7 @@
} else {
get_map_context().perform_action(*a);
}
- refresh_after_action();
+ refresh_after_action(true);
delete a;
}
} else {
@@ -661,7 +686,7 @@
editor_action* a = get_mouse_action()->click(*gui_, x, y);
if (a != NULL) {
get_map_context().perform_action(*a);
- refresh_after_action();
+ refresh_after_action(true);
delete a;
}
return true;
@@ -677,12 +702,21 @@
editor_action* a = get_mouse_action()->drag_end(*gui_, x, y);
if (a != NULL) {
get_map_context().perform_action(*a);
- refresh_after_action();
delete a;
}
+ refresh_after_action();
} else {
LOG_ED << __FUNCTION__ << ": There is no mouse action
active!\n";
}
}
+void editor_controller::left_mouse_up(int x, int y, const bool browse)
+{
+ if (get_mouse_action() != NULL) {
+ refresh_after_action();
+ } else {
+ LOG_ED << __FUNCTION__ << ": There is no mouse action
active!\n";
+ }
+}
+
} //end namespace editor2
Modified: trunk/src/editor2/editor_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.hpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.hpp (original)
+++ trunk/src/editor2/editor_controller.hpp Thu Jul 31 14:30:57 2008
@@ -82,6 +82,7 @@
bool execute_command(hotkey::HOTKEY_COMMAND command, int index
= -1);
void expand_starting_position_menu(std::vector<std::string>&
items);
void show_menu(const std::vector<std::string>& items_arg, int
xloc, int yloc, bool context_menu);
+
void cycle_brush();
void preferences();
void toggle_grid();
@@ -98,6 +99,7 @@
const editor_display& gui() const { return *gui_; }
bool left_click(int x, int y, const bool browse);
void left_drag_end(int x, int y, const bool browse);
+ void left_mouse_up(int x, int y, const bool browse);
protected:
mouse_handler_base& get_mouse_handler_base();
@@ -109,7 +111,7 @@
/** init the display object and general set-up */
void init(CVideo& video);
- void refresh_after_action();
+ void refresh_after_action(bool drag_part = false);
void refresh_all();
@@ -148,6 +150,8 @@
t_translation::t_terrain foreground_terrain_;
t_translation::t_terrain background_terrain_;
map_fragment clipboard_;
+
+ bool auto_update_transitions_;
};
} //end namespace editor2
Modified: trunk/src/editor2/editor_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_display.cpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/editor2/editor_display.cpp (original)
+++ trunk/src/editor2/editor_display.cpp Thu Jul 31 14:30:57 2008
@@ -53,6 +53,10 @@
invalidate(hex);
}
+void editor_display::rebuild_terrain(const gamemap::location &loc) {
+ builder_.rebuild_terrain(loc);
+}
+
void editor_display::pre_draw()
{
Modified: trunk/src/editor2/editor_display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_display.hpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/editor2/editor_display.hpp (original)
+++ trunk/src/editor2/editor_display.hpp Thu Jul 31 14:30:57 2008
@@ -32,7 +32,7 @@
void clear_brush_locs();
void remove_brush_loc(const gamemap::location& hex);
const editor_map& map() const { return static_cast<const
editor_map&>(map_); }
-
+ void rebuild_terrain(const gamemap::location &loc);
protected:
void pre_draw();
/**
Modified: trunk/src/mouse_handler_base.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_handler_base.cpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/mouse_handler_base.cpp (original)
+++ trunk/src/mouse_handler_base.cpp Thu Jul 31 14:30:57 2008
@@ -120,6 +120,7 @@
left_drag_end(event.x, event.y, browse);
}
dragging_started_= false;
+ left_mouse_up(event.x, event.y, browse);
} else if(is_middle_click(event) && event.state == SDL_RELEASED) {
minimap_scrolling_ = false;
} else if(is_left_click(event) && event.state == SDL_PRESSED) {
@@ -221,6 +222,10 @@
left_click(x, y, browse);
}
+void mouse_handler_base::left_mouse_up(int x, int y, const bool browse)
+{
+}
+
bool mouse_handler_base::right_click(int /*x*/, int /*y*/, const bool
/*browse*/)
{
Modified: trunk/src/mouse_handler_base.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_handler_base.hpp?rev=28286&r1=28285&r2=28286&view=diff
==============================================================================
--- trunk/src/mouse_handler_base.hpp (original)
+++ trunk/src/mouse_handler_base.hpp Thu Jul 31 14:30:57 2008
@@ -73,6 +73,8 @@
virtual void left_drag_end(int x, int y, const bool browse);
+ virtual void left_mouse_up(int x, int y, const bool browse);
+
virtual bool right_click(int x, int y, const bool browse);
/**
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits