Author: ilor
Date: Sun Jul 6 16:49:19 2008
New Revision: 27777
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27777&view=rev
Log:
move some more functions up to controller_base
Modified:
trunk/src/controller_base.cpp
trunk/src/controller_base.hpp
Modified: trunk/src/controller_base.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/controller_base.cpp?rev=27777&r1=27776&r2=27777&view=diff
==============================================================================
--- trunk/src/controller_base.cpp (original)
+++ trunk/src/controller_base.cpp Sun Jul 6 16:49:19 2008
@@ -179,3 +179,25 @@
//no action by default
}
+void controller_base::show_menu(const std::vector<std::string>& items_arg, int
xloc, int yloc, bool context_menu)
+{
+ std::vector<std::string> items = items_arg;
+ hotkey::HOTKEY_COMMAND command;
+ std::vector<std::string>::iterator i = items.begin();
+ while(i != items.end()) {
+ if(!can_execute_command(command)
+ || (context_menu && !in_context_menu(command))) {
+ i = items.erase(i);
+ continue;
+ }
+ ++i;
+ }
+ if(items.empty())
+ return;
+ command_executor::show_menu(items, xloc, yloc, context_menu,
get_display());
+}
+
+bool controller_base::in_context_menu(hotkey::HOTKEY_COMMAND /*command*/) const
+{
+ return true;
+}
Modified: trunk/src/controller_base.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/controller_base.hpp?rev=27777&r1=27776&r2=27777&view=diff
==============================================================================
--- trunk/src/controller_base.hpp (original)
+++ trunk/src/controller_base.hpp Sun Jul 6 16:49:19 2008
@@ -55,7 +55,7 @@
* Inherited from command_executor, still declared pure virtual but
might
* provide some defaults
*/
- virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int
index) const = 0;
+ virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int
index=-1) const = 0;
/**
* Get a reference to a mouse handler member a derived class uses
*/
@@ -106,7 +106,9 @@
*/
virtual void post_mouse_press(const SDL_Event& event);
- virtual void show_menu(const std::vector<std::string>& items_arg, int
xloc, int yloc, bool context_menu) = 0;
+ virtual void show_menu(const std::vector<std::string>& items_arg, int
xloc, int yloc, bool context_menu);
+
+ virtual bool in_context_menu(hotkey::HOTKEY_COMMAND command) const;
const config& game_config_;
const int ticks_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits