Author: ilor
Date: Tue Aug 19 14:09:52 2008
New Revision: 28768
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28768&view=rev
Log:
editor2: make number keys always scroll to starting position, alt+number always
set the position under cursor. This reverses alt/no-alt behavior, imo more
sensible now.
Modified:
trunk/data/core/editor2-tool-hints.cfg
trunk/src/editor2/mouse_action.cpp
trunk/src/editor2/mouse_action.hpp
Modified: trunk/data/core/editor2-tool-hints.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/core/editor2-tool-hints.cfg?rev=28768&r1=28767&r2=28768&view=diff
==============================================================================
--- trunk/data/core/editor2-tool-hints.cfg (original)
+++ trunk/data/core/editor2-tool-hints.cfg Tue Aug 19 14:09:52 2008
@@ -18,5 +18,5 @@
[editor2_tool_hint]
id="editor-tool-starting-position"
- text= _ "Left mouse button displays player selection, right clears.
Keys 1-9 set respectove starting position under cursor and delete clears,
alt+key scrolls to the starting position."
+ text= _ "Left mouse button displays player selection, right clears.
Number keys scroll to the starting position, alt+number sets respective
starting position under cursor, delete clears."
[/editor2_tool_hint]
Modified: trunk/src/editor2/mouse_action.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/mouse_action.cpp?rev=28768&r1=28767&r2=28768&view=diff
==============================================================================
--- trunk/src/editor2/mouse_action.cpp (original)
+++ trunk/src/editor2/mouse_action.cpp Tue Aug 19 14:09:52 2008
@@ -60,9 +60,34 @@
}
editor_action* mouse_action::key_event(
- editor_display& /*disp*/, const SDL_Event& /*e*/)
-{
- return NULL;
+ editor_display& disp, const SDL_Event& event)
+{
+ if (!has_alt_modifier() && (event.key.keysym.sym >= '1' &&
event.key.keysym.sym <= '9')) {
+ int side = event.key.keysym.sym - '0';
+ if (side >= 1 && side <= gamemap::MAX_PLAYERS) {
+ gamemap::location pos =
disp.get_map().starting_position(side);
+ if (pos.valid()) {
+ disp.scroll_to_tile(pos, display::WARP);
+ }
+ }
+ return NULL;
+ }
+ if (!disp.map().on_board(previous_move_hex_) || event.type !=
SDL_KEYUP) {
+ return NULL;
+ }
+ editor_action* a = NULL;
+ if ((has_alt_modifier() && (event.key.keysym.sym >= '1' &&
event.key.keysym.sym <= '9'))
+ || event.key.keysym.sym == SDLK_DELETE) {
+ int res = event.key.keysym.sym - '0';
+ if (res > gamemap::MAX_PLAYERS || event.key.keysym.sym ==
SDLK_DELETE) res = 0;
+ int player_starting_at_hex =
disp.map().is_starting_position(previous_move_hex_) + 1;
+ if (res == 0 && player_starting_at_hex != -1) {
+ a = new
editor_action_starting_position(gamemap::location(), player_starting_at_hex);
+ } else if (res > 0 && res != player_starting_at_hex) {
+ a = new
editor_action_starting_position(previous_move_hex_, res);
+ }
+ }
+ return a;
}
bool mouse_action::has_alt_modifier() const
@@ -161,13 +186,13 @@
}
editor_action* mouse_action_select::key_event(
- editor_display& disp, const SDL_Event& /*e*/)
-{
- // Force an actual move
+ editor_display& disp, const SDL_Event& event)
+{
+ // Force an actual move event to update the brush
gamemap::location tmp = previous_move_hex_;
previous_move_hex_ = gamemap::location();
move(disp, tmp);
- return NULL;
+ return mouse_action::key_event(disp, event);
}
editor_action* mouse_action_select::click_perform_left(
@@ -266,34 +291,4 @@
}
}
-editor_action* mouse_action_starting_position::key_event(editor_display& disp,
const SDL_Event& event)
-{
- if (has_alt_modifier() && (event.key.keysym.sym >= '1' &&
event.key.keysym.sym <= '9')) {
- int side = event.key.keysym.sym - '0';
- if (side >= 1 && side <= gamemap::MAX_PLAYERS) {
- gamemap::location pos =
disp.get_map().starting_position(side);
- if (pos.valid()) {
- disp.scroll_to_tile(pos, display::WARP);
- }
- }
- return NULL;
- }
- if (!disp.map().on_board(previous_move_hex_) || event.type !=
SDL_KEYUP) {
- return NULL;
- }
- editor_action* a = NULL;
- if ((event.key.keysym.sym >= '1' && event.key.keysym.sym <= '9') ||
event.key.keysym.sym == SDLK_DELETE) {
- int res = event.key.keysym.sym - '0';
- if (res > gamemap::MAX_PLAYERS || event.key.keysym.sym ==
SDLK_DELETE) res = 0;
- int player_starting_at_hex =
disp.map().is_starting_position(previous_move_hex_) + 1;
- if (res == 0 && player_starting_at_hex != -1) {
- a = new
editor_action_starting_position(gamemap::location(), player_starting_at_hex);
- } else if (res > 0 && res != player_starting_at_hex) {
- a = new
editor_action_starting_position(previous_move_hex_, res);
- }
- }
- return a;
-}
-
-
} //end namespace editor2
Modified: trunk/src/editor2/mouse_action.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/mouse_action.hpp?rev=28768&r1=28767&r2=28768&view=diff
==============================================================================
--- trunk/src/editor2/mouse_action.hpp (original)
+++ trunk/src/editor2/mouse_action.hpp Tue Aug 19 14:09:52 2008
@@ -79,7 +79,7 @@
/**
* Function called by the controller on a key event for the current
mouse action.
- * Defaults to no action.
+ * Defaults to starting position processing.
*/
virtual editor_action* key_event(editor_display& disp, const SDL_Event&
e);
@@ -331,11 +331,6 @@
}
/**
- * Allows setting/clearing the starting positions in the mouseover
hexes via keyboard
- */
- editor_action* key_event(editor_display& disp, const SDL_Event& e);
-
- /**
* Left click displays a player-number-selector dialog and then creates
an action
* or returns NULL if cancel was pressed or there would be no change.
*/
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits