Browse Source

minor fixes

dmuratshin 10 years ago
parent
commit
27aa7f9736

+ 2 - 0
oxygine/src/Actor.h

@@ -226,7 +226,9 @@ namespace oxygine
         void addChild(Actor* actor);//avoid conversion to spActor
         void addChild(Actor* actor);//avoid conversion to spActor
         void attachTo(spActor parent);
         void attachTo(spActor parent);
         void attachTo(Actor* parent);//avoid conversion to spActor
         void attachTo(Actor* parent);//avoid conversion to spActor
+        /**Remove one child*/
         void removeChild(spActor actor);
         void removeChild(spActor actor);
+        /**Removes all children from Actor*/
         void removeChildren();
         void removeChildren();
 
 
 
 

+ 2 - 0
oxygine/src/AnimationFrame.h

@@ -61,6 +61,8 @@ namespace oxygine
         void            setDiffuse(const Diffuse& d) { _diffuse = d; }
         void            setDiffuse(const Diffuse& d) { _diffuse = d; }
         void            setSize(const Vector2& size) {_frameSize = size;}
         void            setSize(const Vector2& size) {_frameSize = size;}
         void            setHitTestData(const HitTestData& ad) { _hittest = ad; }
         void            setHitTestData(const HitTestData& ad) { _hittest = ad; }
+        void            setRow(int v) {_row = v;}
+        void            setColumn(int v) {_column = v;}
 
 
         void            flipX();
         void            flipX();
         void            flipY();
         void            flipY();

+ 1 - 0
oxygine/src/Serialize.h

@@ -20,6 +20,7 @@ namespace oxygine
         virtual spActor     create(const char* type) const;
         virtual spActor     create(const char* type) const;
         virtual Resource*   getResource(const char* id) const {return 0;}
         virtual Resource*   getResource(const char* id) const {return 0;}
         virtual ResAnim*    getResAnim(const char* id) const {return safeCast<ResAnim*>(getResource(id));}
         virtual ResAnim*    getResAnim(const char* id) const {return safeCast<ResAnim*>(getResource(id));}
+        virtual AnimationFrame getFrame(const char* id, int col, int row) const {return getResAnim(id)->getFrame(col, row);}
         virtual ResFont*    getResFont(const char* id) const {return safeCast<ResFont*>(getResource(id));}
         virtual ResFont*    getResFont(const char* id) const {return safeCast<ResFont*>(getResource(id));}
     };
     };
 
 

+ 20 - 14
oxygine/src/Sprite.cpp

@@ -70,15 +70,6 @@ namespace oxygine
         changeAnimFrame(f);
         changeAnimFrame(f);
     }
     }
 
 
-    void Sprite::setRow(int row, int column)
-    {
-        const ResAnim* rs = getResAnim();
-        if (column == -1)
-            column = getColumn();
-        setAnimFrame(rs, column, row);
-
-    }
-
 
 
     extern int HIT_TEST_DOWNSCALE;
     extern int HIT_TEST_DOWNSCALE;
 
 
@@ -150,11 +141,22 @@ namespace oxygine
             animFrameChanged(_frame);
             animFrameChanged(_frame);
     }
     }
 
 
-    void Sprite::setColumn(int column, int row)
+    void Sprite::setColumn(int column)
+    {
+        const ResAnim* rs = getResAnim();
+        setAnimFrame(rs, column, getRow());
+    }
+
+    void Sprite::setRow(int row)
+    {
+        const ResAnim* rs = getResAnim();
+        setAnimFrame(rs, getColumn(), row);
+
+    }
+
+    void Sprite::setColumnRow(int column, int row)
     {
     {
         const ResAnim* rs = getResAnim();
         const ResAnim* rs = getResAnim();
-        if (row == -1)
-            row = getRow();
         setAnimFrame(rs, column, row);
         setAnimFrame(rs, column, row);
     }
     }
 
 
@@ -264,6 +266,9 @@ namespace oxygine
                 node.append_attribute("row").set_value(_frame.getRow());
                 node.append_attribute("row").set_value(_frame.getRow());
         }
         }
 
 
+        setAttr(node, "flipX", isFlippedX(), false);
+        setAttr(node, "flipY", isFlippedY(), false);
+
         node.set_name("Sprite");
         node.set_name("Sprite");
     }
     }
 
 
@@ -275,8 +280,9 @@ namespace oxygine
         const char* res = node.attribute("resanim").as_string(0);
         const char* res = node.attribute("resanim").as_string(0);
         if (res)
         if (res)
         {
         {
-            ResAnim* rs = safeCast<ResAnim*>(data->factory->getResAnim(res));
-            setResAnim(rs, node.attribute("col").as_int(0), node.attribute("row").as_int(0));
+            setAnimFrame(data->factory->getFrame(res, node.attribute("column").as_int(0), node.attribute("row").as_int(0)));
         }
         }
+
+        setFlipped(node.attribute("flipX").as_bool(false), node.attribute("flipY").as_bool(false));
     }
     }
 }
 }

+ 3 - 2
oxygine/src/Sprite.h

@@ -37,8 +37,9 @@ namespace oxygine
         /**Takes AnimationFrame from ResAnim and set it as current to Sprite. Shows assert is resanim is null. Using this method is more safe than 'setAnimFrame(const AnimationFrame &f)'*/
         /**Takes AnimationFrame from ResAnim and set it as current to Sprite. Shows assert is resanim is null. Using this method is more safe than 'setAnimFrame(const AnimationFrame &f)'*/
         void                    setAnimFrame(const ResAnim* resanim, int col = 0, int row = 0);
         void                    setAnimFrame(const ResAnim* resanim, int col = 0, int row = 0);
         virtual void            setResAnim(const ResAnim* resanim, int col = 0, int row = 0);
         virtual void            setResAnim(const ResAnim* resanim, int col = 0, int row = 0);
-        void                    setRow(int row, int column = -1);
-        void                    setColumn(int column, int row = -1);
+        void                    setRow(int row);
+        void                    setColumn(int column);
+        void                    setColumnRow(int column, int row);
 
 
         bool                    isOn(const Vector2& localPosition);
         bool                    isOn(const Vector2& localPosition);
 
 

+ 2 - 0
oxygine/src/res/ResAnim.cpp

@@ -80,6 +80,8 @@ namespace oxygine
     {
     {
         _columns = columns;
         _columns = columns;
         _frames.swap(frames);
         _frames.swap(frames);
+        for (size_t i = 0; i < _frames.size(); ++i)
+            _frames[i].setResAnim(this);
         _scaleFactor = scaleFactor;
         _scaleFactor = scaleFactor;
         _appliedScale = appliedScale;
         _appliedScale = appliedScale;
     }
     }

+ 1 - 21
tools/gen_view_code.py

@@ -248,27 +248,7 @@ if __name__ == "__main__":
     parser.add_argument("xml", help="xml file to process")
     parser.add_argument("xml", help="xml file to process")
     parser.add_argument(
     parser.add_argument(
         "-d", "--dest", help="destination folder for generated classes", default=".")
         "-d", "--dest", help="destination folder for generated classes", default=".")
-    """
-    parser.add_argument("-mw", "--max_width", help = "max atlas width", type=int, default = 2048)
-    parser.add_argument("-mh", "--max_height", help = "max atlas height", type=int, default = 2048)
-    parser.add_argument("-s", "--scale", help = "scale factor", type=float, default = 1.0)
-    parser.add_argument("-r", "--resize", help = "downscale/upscale by scale factor", action="store_true", default = False)
-    parser.add_argument("-us", "--upscale", help = "allow upscale. good option for very HD displays with texture compression", action="store_true", default = False)
-    parser.add_argument("-c", "--compression", help = "type of images compression. default is pure rgba8888 packed to png",
-                        choices = ["pvrtc", "etc1", "no"], default = "")
-    parser.add_argument("-np", "--nopng", help = "store images without packing to png",
-                            action="store_true", default = False)
-    parser.add_argument("-q", "--quality", help = "select quality to compressed textures",
-                        choices = ["default", "fast", "best"], default = "default")
-    parser.add_argument("-d", "--dither", help = "added dithering to compressed textures (pvr option)", action="store_true", default = False)
-    #parser.add_argument("--android_sdk", help = "path to android sdk", default = "")
-    parser.add_argument("-debug", "--debug", help = "debug mode", action="store_true", default = False)
-    parser.add_argument("-w", "--warnings", help = "show warnings", action="store_true", default = False)
-    parser.add_argument("-v", "--verbosity", help = "verbosity level. 1 - only errors, 2 - normal. Default value is 2", type=int, default = 2)
-    parser.add_argument("--md5", help = "generates md5 lists for some special files", type=bool, default = False)
-
-    gen2(".", "test.xml", "./", "Qwe", None)
-    """
+    
 
 
     args = parser.parse_args()
     args = parser.parse_args()
     gen2(args.xml, args.dest + "/", None)
     gen2(args.xml, args.dest + "/", None)

+ 3 - 1
tools/others/format.bat

@@ -15,4 +15,6 @@ set astyle=d:\dropbox\tools\AStyle.exe
 
 
 
 
 %astyle% d:\oxygine-billing\examples\*.cpp d:\oxygine-billing\examples\*.h %options%
 %astyle% d:\oxygine-billing\examples\*.cpp d:\oxygine-billing\examples\*.h %options%
-%astyle% d:\oxygine-billing\src\*.cpp d:\oxygine-billing\src\*.h %options%
+%astyle% d:\oxygine-billing\src\*.cpp d:\oxygine-billing\src\*.h %options%
+
+%astyle% d:\oxygine-editor\editor\src\*.cpp d:\oxygine-editor\editor\src\*.h %options%