mail[Wesnoth-commits] r29123 - in /trunk/src: game_display.cpp game_display.hpp game_events.cpp playsingle_controller.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by lari . nieminen on August 30, 2008 - 22:49:
Author: zookeeper
Date: Sat Aug 30 22:35:23 2008
New Revision: 29123

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29123&view=rev
Log:
Applied patch #1100.

Modified:
    trunk/src/game_display.cpp
    trunk/src/game_display.hpp
    trunk/src/game_events.cpp
    trunk/src/playsingle_controller.cpp

Modified: trunk/src/game_display.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.cpp?rev=29123&r1=29122&r2=29123&view=diff
==============================================================================
--- trunk/src/game_display.cpp (original)
+++ trunk/src/game_display.cpp Sat Aug 30 22:35:23 2008
@@ -338,8 +338,12 @@
                typedef overlay_map::const_iterator Itor;
                std::pair<Itor,Itor> overlays = overlays_.equal_range(loc);
                for( ; overlays.first != overlays.second; ++overlays.first) {
-                       drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, 
tblit(xpos, ypos,
+                       (overlays.first->second.team_name == "" ||
+                       
overlays.first->second.team_name.find(teams_[playing_team()].team_name()) != 
std::string::npos)
+                       {
+                               drawing_buffer_add(LAYER_TERRAIN_BG, 
drawing_order, tblit(xpos, ypos,
                                
image::get_image(overlays.first->second.image,image_type)));
+                       }
                }
                // village-control flags.
                drawing_buffer_add(LAYER_TERRAIN_BG, drawing_order, 
tblit(xpos, ypos, get_flag(loc)));          
@@ -962,12 +966,12 @@
        set_attack_indicator(gamemap::location::null_location, 
gamemap::location::null_location);
 }
 
-void game_display::add_overlay(const gamemap::location& loc, const 
std::string& img, const std::string& halo)
+void game_display::add_overlay(const gamemap::location& loc, const 
std::string& img, const std::string& halo,const std::string& team_name)
 {
        const int halo_handle = halo::add(get_location_x(loc) + hex_size() / 
2,
                        get_location_y(loc) + hex_size() / 2, halo, loc);
 
-       const overlay item(img,halo,halo_handle);
+       const overlay item(img,halo,halo_handle,team_name);
        overlays_.insert(overlay_map::value_type(loc,item));
 }
 
@@ -1010,6 +1014,20 @@
                i->first.write(item);
                item["image"] = i->second.image;
                item["halo"] = i->second.halo;
+               item["team_name"] = i->second.team_name;
+       }
+}
+
+void game_display::parse_team_overlays()
+{
+       for (game_display::overlay_map::const_iterator overlay = 
overlays_.begin(); overlay != overlays_.end(); ++overlay) {
+
+               if (overlay->second.team_name != "" &&
+                       
bool(overlay->second.team_name.find(teams_[playing_team()].team_name())+1) !=
+                       
bool(overlay->second.team_name.find(teams_[playing_team()-1 > -1 ? 
playing_team()-1 : teams_.size()-1].team_name())+1))
+                       {
+                       invalidate(overlay->first);
+               }
        }
 }
 
@@ -1180,3 +1198,4 @@
 
 game_display *game_display::singleton_ = NULL;
 
+

Modified: trunk/src/game_display.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_display.hpp?rev=29123&r1=29122&r2=29123&view=diff
==============================================================================
--- trunk/src/game_display.hpp (original)
+++ trunk/src/game_display.hpp Sat Aug 30 22:35:23 2008
@@ -171,7 +171,7 @@
        //! Functions to add and remove overlays from locations.
        //! An overlay is an image that is displayed on top of the tile.
        //! One tile may have multiple overlays.
-       void add_overlay(const gamemap::location& loc, const std::string& 
image, const std::string& halo="");
+       void add_overlay(const gamemap::location& loc, const std::string& 
image, const std::string& halo="", const std::string& team_name="");
        //! remove_overlay will remove all overlays on a tile.
        void remove_overlay(const gamemap::location& loc);
        //! remove_single_overlay will remove a single overlay from a tile
@@ -180,6 +180,9 @@
        //! Function to serialize overlay data.
        void write_overlays(config& cfg) const;
 
+       //! Check the overlay_map for proper team-specific overlays
+       //! to be displayed/hidden
+       void parse_team_overlays();
 
        // Functions used in the editor:
 
@@ -278,10 +281,11 @@
 
        struct overlay {
                overlay(const std::string& img, const std::string& halo_img,
-                       int handle) : image(img), halo(halo_img),
-                               halo_handle(handle) {}
+                               int handle, const std::string& 
overlay_team_name) : image(img), halo(halo_img),
+                               halo_handle(handle), 
team_name(overlay_team_name) {}
                std::string image;
                std::string halo;
+               std::string team_name;
                int halo_handle;
        };
 

Modified: trunk/src/game_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=29123&r1=29122&r2=29123&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Aug 30 22:35:23 2008
@@ -1564,9 +1564,10 @@
                gamemap::location loc = cfg_to_loc(cfg);
                std::string img = cfg["image"];
                std::string halo = cfg["halo"];
+               std::string team_name = cfg["team_name"];
                assert(state_of_game != NULL);
                if(!img.empty() || !halo.empty()) {
-                       (screen)->add_overlay(loc,img,halo);
+                       (screen)->add_overlay(loc,img,halo,team_name);
                        (screen)->invalidate(loc);
                        (screen)->draw();
                }

Modified: trunk/src/playsingle_controller.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=29123&r1=29122&r2=29123&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Sat Aug 30 22:35:23 2008
@@ -253,7 +253,7 @@
        // Find a list of 'items' (i.e. overlays) on the level, and add them
        const config::child_list& overlays = level_.get_children("item");
        for(config::child_list::const_iterator overlay = overlays.begin(); 
overlay != overlays.end(); ++overlay) {
-               
gui_->add_overlay(gamemap::location(**overlay,game_events::get_state_of_game()),(**overlay)["image"],
 (**overlay)["halo"]);
+               
gui_->add_overlay(gamemap::location(**overlay,game_events::get_state_of_game()),(**overlay)["image"],
 (**overlay)["halo"],(**overlay)["team_name"]);
        }
 
        victory_conditions::set_victory_when_enemies_defeated(
@@ -563,6 +563,9 @@
 
 void playsingle_controller::play_side(const unsigned int team_index, bool 
save)
 {
+       //check for team-specific items in the scenario
+       gui_->parse_team_overlays();
+
        //flag used when we fallback from ai and give temporarily control to 
human
        bool temporary_human = false;
        do {




Related Messages


Powered by MHonArc, Updated Sun Aug 31 01:02:19 2008