Parcourir la source

Letting image lists set a default color.
Fixing a bug in CheckBox.

Adam Blake il y a 13 ans
Parent
commit
6e9486ed43
4 fichiers modifiés avec 12 ajouts et 8 suppressions
  1. 2 2
      gameplay/src/CheckBox.cpp
  2. 1 1
      gameplay/src/CheckBox.h
  3. 8 4
      gameplay/src/Theme.cpp
  4. 1 1
      gameplay/src/Theme.h

+ 2 - 2
gameplay/src/CheckBox.cpp

@@ -43,7 +43,7 @@ const Vector2& CheckBox::getImageSize() const
 {
     return _imageSize;
 }
-/*
+
 void CheckBox::addListener(Control::Listener* listener, int eventFlags)
 {
     if ((eventFlags & Control::Listener::TEXT_CHANGED) == Control::Listener::TEXT_CHANGED)
@@ -53,7 +53,7 @@ void CheckBox::addListener(Control::Listener* listener, int eventFlags)
     }
 
     Control::addListener(listener, eventFlags);
-}*/
+}
 
 bool CheckBox::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
 {

+ 1 - 1
gameplay/src/CheckBox.h

@@ -61,7 +61,7 @@ public:
      * @param listener The listener to add.
      * @param eventFlags The events to listen for.
      */
-//    virtual void addListener(Control::Listener* listener, int eventFlags);
+    virtual void addListener(Control::Listener* listener, int eventFlags);
 
   //  virtual void animationEvent(AnimationClip* clip, EventType type);
 

+ 8 - 4
gameplay/src/Theme.cpp

@@ -105,7 +105,7 @@ namespace gameplay
             
             if (strcmp(spacename, "image") == 0)
             {
-                theme->_images.push_back(Image::create(tw, th, space));
+                theme->_images.push_back(Image::create(tw, th, space, Vector4::one()));
             }
             else if (strcmp(spacename, "imageList") == 0)
             {
@@ -479,17 +479,21 @@ namespace gameplay
     {
     }
 
-    Theme::Image* Theme::Image::create(float tw, float th, Properties* properties)
+    Theme::Image* Theme::Image::create(float tw, float th, Properties* properties, const Vector4& defaultColor)
     {
         Vector4 regionVector;                
         properties->getVector4("region", &regionVector);
         const Rectangle region(regionVector.x, regionVector.y, regionVector.z, regionVector.w);
 
-        Vector4 color(1, 1, 1, 1);
+        Vector4 color;
         if (properties->exists("color"))
         {
             properties->getColor("color", &color);
         }
+        else
+        {
+            color.set(defaultColor);
+        }
 
         Image* image = new Image(tw, th, region, color);
         const char* id = properties->getId();
@@ -570,7 +574,7 @@ namespace gameplay
         Properties* space = properties->getNextNamespace();
         while (space != NULL)
         {
-            Image* image = Image::create(tw, th, space);
+            Image* image = Image::create(tw, th, space, color);
             imageList->_images.push_back(image);
             space = properties->getNextNamespace();
         }

+ 1 - 1
gameplay/src/Theme.h

@@ -204,7 +204,7 @@ public:
         Image(float tw, float th, const Rectangle& region, const Vector4& color);
         ~Image();
 
-        static Image* create(float tw, float th, Properties* properties);
+        static Image* create(float tw, float th, Properties* properties, const Vector4& defaultColor);
 
         std::string _id;
         UVs _uvs;