mail[Wesnoth-commits] r44266 - in /trunk/src: builder.cpp builder.hpp menu_events.cpp


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

Header


Content

Posted by alinktomine on July 18, 2010 - 03:47:
Author: alink
Date: Sun Jul 18 03:47:07 2010
New Revision: 44266

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44266&view=rev
Log:
Clean ":layers" and add layer order and back/foreground flag

Modified:
    trunk/src/builder.cpp
    trunk/src/builder.hpp
    trunk/src/menu_events.cpp

Modified: trunk/src/builder.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/builder.cpp?rev=44266&r1=44265&r2=44266&view=diff
==============================================================================
--- trunk/src/builder.cpp (original)
+++ trunk/src/builder.cpp Sun Jul 18 03:47:07 2010
@@ -32,18 +32,6 @@
 static lg::log_domain log_engine("engine");
 #define ERR_NG LOG_STREAM(err, log_engine)
 #define WRN_NG LOG_STREAM(warn, log_engine)
-
-/** The tile width used when using basex and basey. This is not,
- * necessarily, the tile width in pixels, this is totally
- * arbitrary. However, it will be set to 72 for convenience.
- */
-static const int TILEWIDTH = 72;
-/** The position of unit graphics in a tile. Graphics whose y
- * position is below this value are considered background for
- * this tile; graphics whose y position is above this value are
- * considered foreground.
- */
-static const int UNITPOS = 36 + 18;
 
 terrain_builder::building_ruleset terrain_builder::building_rules_;
 const config* terrain_builder::rules_cfg_ = NULL;
@@ -80,7 +68,7 @@
        }
 
        foreach(const rule_image_rand& ri, images){
-               bool is_background = ri->layer < 0 || (ri->layer == 0 && 
ri->basey < UNITPOS);
+               bool is_background = ri->is_background();
 
                imagelist& img_list = is_background ? images_background : 
images_foreground;
 
@@ -111,37 +99,6 @@
                }
        }
 }
-
-std::vector<std::string> terrain_builder::tile::get_info() const
-{
-       std::vector<std::string> res;
-       //TODO sort images if needed
-       foreach(const rule_image_rand& ri, images){
-               //TODO: read all variants
-               const rule_image_variant& variant = ri->variants.back();
-
-               std::ostringstream info;
-
-               const image::locator& img = variant.image.get_first_frame();
-               const std::string& name = img.get_filename();
-               //const std::string& modif = img.get_modifications();
-               std::string img_sep(char(1), 1);
-               const map_location& loc = img.get_loc();
-               info << "&" << name << "~LOC("
-                       <<loc.x << "," << loc.y << ","
-                       << img.get_center_x() << "," << img.get_center_y()
-                       << ")"
-                       << img_sep << name
-                       << "=" << img.get_loc()
-                       << "=" << ri->layer
-                       << "=" << ri->basex
-                       << "=" << ri->basey;
-               res.push_back(info.str());
-       }
-
-       return res;
-}
-
 
 void terrain_builder::tile::clear()
 {

Modified: trunk/src/builder.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/builder.hpp?rev=44266&r1=44265&r2=44266&view=diff
==============================================================================
--- trunk/src/builder.hpp (original)
+++ trunk/src/builder.hpp Sun Jul 18 03:47:07 2010
@@ -57,6 +57,19 @@
                                                 */
        };
 
+       /** The tile width used when using basex and basey. This is not,
+        * necessarily, the tile width in pixels, this is totally
+        * arbitrary. However, it will be set to 72 for convenience.
+        */
+       static const int TILEWIDTH = 72;
+
+       /** The position of unit graphics in a tile. Graphics whose y
+        * position is below this value are considered background for
+        * this tile; graphics whose y position is above this value are
+        * considered foreground.
+        */
+       static const int UNITPOS = 36 + 18;
+
        /** A shorthand typedef for a list of animated image locators,
         * the base data type returned by the get_terrain_at method.
         */
@@ -194,6 +207,10 @@
         */
        struct rule_image {
                rule_image(int layer, int x, int y, bool global_image=false, 
int center_x=-1, int center_y=-1);
+
+               bool is_background() const {
+               return layer < 0 || (layer == 0 && basey < UNITPOS);
+               }
 
                /** The layer of the image for horizontal layering */
                int layer;
@@ -273,8 +290,6 @@
                 * @param tod    The current time-of-day
                 */
                void rebuild_cache(const std::string &tod, logs* log = NULL);
-
-               std::vector<std::string> get_info() const;
 
                /** Clears all data in this tile, and resets the cache */
                void clear();

Modified: trunk/src/menu_events.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=44266&r1=44265&r2=44266&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Sun Jul 18 03:47:07 2010
@@ -3123,14 +3123,15 @@
        std::vector<std::string> layers;
        //NOTE: columns reflect WML keys, don't translate them
        std::string heading = std::string(1,HEADING_PREFIX) +
-               "Image"   + COLUMN_SEPARATOR + // 0
-               "Name"    + COLUMN_SEPARATOR + // 1
-               "Loc"     + COLUMN_SEPARATOR + // 2
-               "Layer"   + COLUMN_SEPARATOR + // 3
-               "Base.x"  + COLUMN_SEPARATOR + // 4
-               "Base.y"  + COLUMN_SEPARATOR + // 5
-               "Center.x"+ COLUMN_SEPARATOR + // 6
-               "Center.y"                     // 7
+               "^#"      + COLUMN_SEPARATOR + // 0
+               "Image"   + COLUMN_SEPARATOR + // 1
+               "Name"    + COLUMN_SEPARATOR + // 2
+               "Loc"     + COLUMN_SEPARATOR + // 3
+               "Layer"   + COLUMN_SEPARATOR + // 4
+               "Base.x"  + COLUMN_SEPARATOR + // 5
+               "Base.y"  + COLUMN_SEPARATOR + // 6
+               "Center"                       // 7
+
        ;
        layers.push_back(heading);
 
@@ -3142,6 +3143,7 @@
        terrain_builder::tile::logs tile_logs;
        tile->rebuild_cache(tod_id, &tile_logs);
 
+       int order = 1;
        foreach(const terrain_builder::tile::log_details det, tile_logs) {
                const terrain_builder::tile::rule_image_rand& ri = *det.first;
                const terrain_builder::rule_image_variant& variant = 
*det.second;
@@ -3153,7 +3155,9 @@
                const map_location& loc_cut = img.get_loc();
 
                std::ostringstream str;
-               str << IMAGE_PREFIX << "terrain/foreground.png"
+               str << (ri->is_background() ? "B ": "F ") << order
+                       << COLUMN_SEPARATOR
+                       << IMAGE_PREFIX << "terrain/foreground.png"
                        << "~BLIT("
                                << name << "~LOC("
                                << loc_cut.x << "," << loc_cut.y << ","
@@ -3166,9 +3170,10 @@
                        << COLUMN_SEPARATOR << ri->layer
                        << COLUMN_SEPARATOR << ri->basex
                        << COLUMN_SEPARATOR << ri->basey
-                       << COLUMN_SEPARATOR << ri->center_x
-                       << COLUMN_SEPARATOR << ri->center_y;
+                       << COLUMN_SEPARATOR
+                       << ri->center_x << ", " << ri->center_y;
                layers.push_back(str.str());
+               ++order;
        }
 
        std::vector<std::string> flags(tile->flags.begin(),tile->flags.end());
@@ -3176,8 +3181,8 @@
        // NOTE using ", " also allows better word wrapping
        info << "Flags :" << utils::join(flags, ", ");
        int choice = 0;
-       {
-               gui::dialog menu(*menu_handler_.gui_, _("Layers"), 
info.str(), gui::OK_CANCEL);
+       {
+               gui::dialog menu(*menu_handler_.gui_, _("Layers"), 
info.str(), gui::OK_CANCEL);
                menu.set_menu(layers);
                choice = menu.show();
        }




Related Messages


Powered by MHonArc, Updated Sun Jul 18 05:40:18 2010