Author: sapient
Date: Wed Apr  4 04:25:18 2007
New Revision: 16583

URL: http://svn.gna.org/viewcvs/wesnoth?rev=16583&view=rev
Log:
minor refinements of select raising with menu item events

Modified:
    trunk/src/game_events.cpp
    trunk/src/gamestatus.cpp
    trunk/src/gamestatus.hpp
    trunk/src/play_controller.cpp

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=16583&r1=16582&r2=16583&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Wed Apr  4 04:25:18 2007
@@ -1748,6 +1748,9 @@
                if(cfg.has_attribute("description")) {
                        mref->description = cfg["description"];
                }
+               if(cfg.has_attribute("needs_select")) {
+                       mref->needs_select = 
utils::string_bool(cfg["needs_select"], false);
+               }
                if(cfg.has_child("show_if")) {
                        mref->show_if = cfg.child("show_if").get_config();
                }
@@ -2229,6 +2232,9 @@
 
        //the event hasn't been filtered out, so execute the handler
        const bool res = handler.handle_event(ev);
+       if(ev.name == "select") {
+               state_of_game->last_selected = ev.loc1;
+       }
 
        if(handler.rebuild_screen()) {
                handler.rebuild_screen() = false;
@@ -2469,10 +2475,6 @@
 
                        snprintf(buf,sizeof(buf),"%d",ev.loc2.y+1);
                        state_of_game->set_variable("y2", buf);
-
-                       if(event_name == "select") {
-                               state_of_game->last_selected = ev.loc1;
-                       }
                }
 
                while(i.first != i.second) {

Modified: trunk/src/gamestatus.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.cpp?rev=16583&r1=16582&r2=16583&view=diff
==============================================================================
--- trunk/src/gamestatus.cpp (original)
+++ trunk/src/gamestatus.cpp Wed Apr  4 04:25:18 2007
@@ -634,6 +634,7 @@
                new_cfg["id"]=j->first;
                new_cfg["image"]=j->second->image;
                new_cfg["description"]=j->second->description;
+               new_cfg["needs_select"]= (j->second->needs_select) ? "yes" : 
"no";
                if(!j->second->show_if.empty())
                        new_cfg.add_child("show_if", j->second->show_if);
                if(!j->second->location_filter.empty())
@@ -680,6 +681,7 @@
                out.write_key_val("id", j->first);
                out.write_key_val("image", j->second->image);
                out.write_key_val("description", j->second->description);
+               out.write_key_val("needs_select", (j->second->needs_select) ? 
"yes" : "no");
                if(!j->second->show_if.empty())
                        out.write_child("show_if", j->second->show_if);
                if(!j->second->location_filter.empty())
@@ -1404,7 +1406,8 @@
        }
 }
 
-wml_menu_item::wml_menu_item(const std::string& id, const config* cfg) {
+wml_menu_item::wml_menu_item(const std::string& id, const config* cfg) : 
needs_select(false)
+{
        std::stringstream temp;
        temp << "menu item";
        if(!id.empty()) {
@@ -1414,6 +1417,7 @@
        if(cfg != NULL) {
                image = (*cfg)["image"];
                description = (*cfg)["description"];
+               needs_select = utils::string_bool((*cfg)["needs_select"], 
false);
                config const* temp;
                if((temp = (*cfg).child("show_if")) != NULL) show_if = *temp;
                if((temp = (*cfg).child("location_filter")) != NULL) 
location_filter = *temp;

Modified: trunk/src/gamestatus.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gamestatus.hpp?rev=16583&r1=16582&r2=16583&view=diff
==============================================================================
--- trunk/src/gamestatus.hpp (original)
+++ trunk/src/gamestatus.hpp Wed Apr  4 04:25:18 2007
@@ -58,6 +58,7 @@
        std::string name;
        std::string image;
        t_string description;
+       bool needs_select;
        config show_if;
        config location_filter;
        config command;

Modified: trunk/src/play_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/play_controller.cpp?rev=16583&r1=16582&r2=16583&view=diff
==============================================================================
--- trunk/src/play_controller.cpp (original)
+++ trunk/src/play_controller.cpp Wed Apr  4 04:25:18 2007
@@ -464,7 +464,7 @@
                        throw game::load_game_exception(savenames_[i],false);
 
                } else if (i < wml_commands_.size() && wml_commands_[i] != 
NULL) {
-                       if(gamestate_.last_selected.valid()) {
+                       if(gamestate_.last_selected.valid() && 
wml_commands_[i]->needs_select) {
                                recorder.add_event("select", 
gamestate_.last_selected);
                        }
                        gamemap::location const& menu_hex = 
mouse_handler_.get_last_hex();


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to