Author: ilor
Date: Sat Jul 26 22:05:57 2008
New Revision: 28230
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28230&view=rev
Log:
editor2: context menu, starting location labels (defunct atm)
Modified:
trunk/data/themes/editor2.cfg
trunk/src/controller_base.cpp
trunk/src/editor2/editor_common.hpp
trunk/src/editor2/editor_controller.cpp
trunk/src/editor2/editor_controller.hpp
trunk/src/editor2/editor_map.cpp
trunk/src/editor2/editor_map.hpp
trunk/src/mouse_events.hpp
trunk/src/mouse_handler_base.hpp
trunk/src/play_controller.cpp
Modified: trunk/data/themes/editor2.cfg
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/themes/editor2.cfg?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/data/themes/editor2.cfg (original)
+++ trunk/data/themes/editor2.cfg Sat Jul 26 22:05:57 2008
@@ -169,14 +169,9 @@
[menu]
id=menu-editor-selection
is_context_menu=true
-
items=editor-cut,editor-copy,editor-paste,editor-selection-rotate,editor-selection-flip,editor-selection-generate,editor-selection-randomize
+
items=menu-editor-starting-position,undo,redo,editor-cut,editor-copy,editor-paste,editor-selection-rotate,editor-selection-flip,editor-selection-generate,editor-selection-randomize
[/menu]
- [menu]
- is_context_menu=true
-
items=wml,undo,redo,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,delayshroud,updateshroud,cycle,endturn
- [/menu]
-
[mini_map]
id=mini-map
ref=top-right-panel
Modified: trunk/src/controller_base.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/controller_base.cpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/controller_base.cpp (original)
+++ trunk/src/controller_base.cpp Sat Jul 26 22:05:57 2008
@@ -77,6 +77,9 @@
case SDL_MOUSEBUTTONUP:
get_mouse_handler_base().mouse_press(event.button, browse_);
post_mouse_press(event);
+ if (get_mouse_handler_base().get_show_menu()){
+
show_menu(get_display().get_theme().context_menu()->items(),event.button.x,event.button.y,true);
+ }
break;
case SDL_ACTIVEEVENT:
if (event.active.type == SDL_APPMOUSEFOCUS && event.active.gain
== 0) {
Modified: trunk/src/editor2/editor_common.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_common.hpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/editor2/editor_common.hpp (original)
+++ trunk/src/editor2/editor_common.hpp Sat Jul 26 22:05:57 2008
@@ -30,6 +30,8 @@
#define ERR_ED LOG_STREAM_INDENT(err, editor)
#define SCOPE_ED log_scope2(editor, __FUNCTION__)
+class display;
+class gamemap;
namespace editor2 {
Modified: trunk/src/editor2/editor_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.cpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.cpp (original)
+++ trunk/src/editor2/editor_controller.cpp Sat Jul 26 22:05:57 2008
@@ -67,6 +67,7 @@
mouse_actions_.insert(std::make_pair(hotkey::HOTKEY_EDITOR_TOOL_SELECT,
new mouse_action_select(*this)));
hotkey_set_mouse_action(hotkey::HOTKEY_EDITOR_TOOL_PAINT);
+ map_.set_starting_position_labels(gui());
cursor::set(cursor::NORMAL);
gui_->invalidate_game_status();
palette_->adjust_size();
@@ -241,8 +242,10 @@
void editor_controller::set_map(const editor_map& map)
{
+ map_.clear_starting_position_labels(gui());
map_ = map;
gui().reload_map();
+ map_.set_starting_position_labels(gui());
refresh_all();
}
@@ -363,6 +366,25 @@
}
}
+void
editor_controller::expand_starting_position_menu(std::vector<std::string>&
items)
+{
+ for (unsigned int i = 0; i < items.size(); ++i) {
+ if (items[i] == "editor-STARTING-POSITION") {
+ items.erase(items.begin() + i);
+ std::vector<std::string> newitems;
+ std::vector<std::string> newsaves;
+ for (int player_i = 0; player_i < gamemap::MAX_PLAYERS;
++player_i) {
+ //TODO gettext format
+ std::string name = "Set starting position for
player " + lexical_cast<std::string>(player_i);
+ newitems.push_back(name);
+ }
+
+ items.insert(items.begin()+i, newitems.begin(),
newitems.end());
+ break;
+ }
+ }
+}
+
void editor_controller::show_menu(const std::vector<std::string>& items_arg,
int xloc, int yloc, bool context_menu)
{
std::vector<std::string> items = items_arg;
@@ -385,6 +407,7 @@
}
++i;
}
+ expand_starting_position_menu(items);
controller_base::show_menu(items, xloc, yloc, context_menu);
}
@@ -541,6 +564,4 @@
}
}
-
-
} //end namespace editor2
Modified: trunk/src/editor2/editor_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_controller.hpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/editor2/editor_controller.hpp (original)
+++ trunk/src/editor2/editor_controller.hpp Sat Jul 26 22:05:57 2008
@@ -62,6 +62,7 @@
bool can_execute_command(hotkey::HOTKEY_COMMAND, int index =
-1) const;
hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND
command) const;
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();
Modified: trunk/src/editor2/editor_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.cpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.cpp (original)
+++ trunk/src/editor2/editor_map.cpp Sat Jul 26 22:05:57 2008
@@ -15,8 +15,10 @@
#include "action_base.hpp"
#include "editor_map.hpp"
+#include "../display.hpp"
#include "../filesystem.hpp"
#include "../foreach.hpp"
+#include "../gettext.hpp"
#include "../pathutils.hpp"
#include <cassert>
@@ -68,6 +70,26 @@
return result;
}
+void editor_map::clear_starting_position_labels(display& disp) const
+{
+ foreach (const gamemap::location& loc, startingPositions_) {
+ if (loc.valid()) {
+ disp.labels().set_label(loc, "");
+ }
+ }
+}
+
+void editor_map::set_starting_position_labels(display& disp) const
+{
+ std::string label = _("Player");
+ label += " ";
+ for (int i = 1; i <= gamemap::MAX_PLAYERS; i++) {
+ if (startingPositions_[i].valid()) {
+ disp.labels().set_label(startingPositions_[i], label +
lexical_cast<std::string>(i));
+ }
+ }
+}
+
bool editor_map::save()
{
std::string data = write();
Modified: trunk/src/editor2/editor_map.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.hpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.hpp (original)
+++ trunk/src/editor2/editor_map.hpp Sat Jul 26 22:05:57 2008
@@ -43,6 +43,10 @@
* @return a contigious set of locations that will always contain at
least the starting element
*/
std::set<gamemap::location> get_contigious_terrain_tiles(const
gamemap::location& start) const;
+
+ void clear_starting_position_labels(display& disp) const;
+
+ void set_starting_position_labels(display& disp) const;
/**
* @return true when the location is part of the selection, false
otherwise
Modified: trunk/src/mouse_events.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_events.hpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/mouse_events.hpp (original)
+++ trunk/src/mouse_events.hpp Sat Jul 26 22:05:57 2008
@@ -45,7 +45,6 @@
const gamemap::location& get_last_hex() const { return last_hex_; }
gamemap::location get_selected_hex() const { return selected_hex_; }
bool get_undo() const { return undo_; }
- bool get_show_menu() const { return show_menu_; }
void set_path_turns(const int path_turns) { path_turns_ = path_turns; }
void set_current_paths(paths new_paths);
void set_selected_hex(gamemap::location hex) { selected_hex_ = hex; }
Modified: trunk/src/mouse_handler_base.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_handler_base.hpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/mouse_handler_base.hpp (original)
+++ trunk/src/mouse_handler_base.hpp Sat Jul 26 22:05:57 2008
@@ -51,6 +51,8 @@
bool is_dragging() { return dragging_; }
+ bool get_show_menu() const { return show_menu_; }
+
/**
* This handles minimap scrolling and click-drag.
* @returns true when the caller should not process the mouse motion
Modified: trunk/src/play_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=28230&r1=28229&r2=28230&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Sat Jul 26 22:05:57 2008
@@ -730,9 +730,6 @@
mouse_handler_.set_undo(false);
menu_handler_.undo(player_number_);
}
- if (mouse_handler_.get_show_menu()){
-
show_menu(gui_->get_theme().context_menu()->items(),event.button.x,event.button.y,true);
- }
}
static void trim_items(std::vector<std::string>& newitems) {
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits