2013-09-13 22:20:20 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 cocos2d-x.org
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __CCSGUIREADER_H__
|
|
|
|
#define __CCSGUIREADER_H__
|
|
|
|
|
2013-10-16 16:48:39 +08:00
|
|
|
#include "gui/UIWidget.h"
|
2013-12-24 20:33:55 +08:00
|
|
|
#include "cocostudio/DictionaryHelper.h"
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocostudio {
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
#define kCCSVersion 1.0
|
2014-01-04 14:23:40 +08:00
|
|
|
|
2014-01-04 15:17:36 +08:00
|
|
|
class GUIReader : public cocos2d::Object
|
2013-09-13 22:20:20 +08:00
|
|
|
{
|
|
|
|
public:
|
2014-01-04 14:23:40 +08:00
|
|
|
CC_DEPRECATED_ATTRIBUTE static GUIReader* shareReader() { return GUIReader::getInstance(); };
|
|
|
|
CC_DEPRECATED_ATTRIBUTE static void purgeGUIReader() { GUIReader::destroyInstance(); };
|
|
|
|
|
|
|
|
static GUIReader* getInstance();
|
|
|
|
static void destroyInstance();
|
2013-09-13 22:20:20 +08:00
|
|
|
|
2013-12-23 15:02:52 +08:00
|
|
|
cocos2d::gui::Widget* widgetFromJsonFile(const char* fileName);
|
2013-09-13 22:20:20 +08:00
|
|
|
int getVersionInteger(const char* str);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2013-11-07 21:26:56 +08:00
|
|
|
void storeFileDesignSize(const char* fileName, const cocos2d::Size &size);
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
*/
|
2013-11-07 21:26:56 +08:00
|
|
|
const cocos2d::Size getFileDesignSize(const char* fileName) const;
|
2014-01-04 14:23:40 +08:00
|
|
|
|
2013-09-13 22:20:20 +08:00
|
|
|
protected:
|
2014-01-04 14:23:40 +08:00
|
|
|
GUIReader();
|
|
|
|
~GUIReader();
|
|
|
|
|
2013-09-13 22:20:20 +08:00
|
|
|
std::string m_strFilePath;
|
2013-12-24 10:41:01 +08:00
|
|
|
cocos2d::ValueMap _fileDesignSizes;
|
|
|
|
|
2013-09-13 22:20:20 +08:00
|
|
|
};
|
|
|
|
|
2013-11-11 18:22:14 +08:00
|
|
|
class WidgetPropertiesReader : public cocos2d::Object
|
|
|
|
{
|
|
|
|
public:
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName)=0;
|
|
|
|
virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& data) = 0;
|
2013-11-11 18:22:14 +08:00
|
|
|
protected:
|
|
|
|
std::string m_strFilePath;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class WidgetPropertiesReader0250 : public WidgetPropertiesReader
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
WidgetPropertiesReader0250(){};
|
|
|
|
virtual ~WidgetPropertiesReader0250(){};
|
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName);
|
|
|
|
virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& dic);
|
|
|
|
virtual void setPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual void setColorPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForButtonFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForCheckBoxFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForImageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelAtlasFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelBMFontFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLoadingBarFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForSliderFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForTextFieldFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual void setPropsForLayoutFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForScrollViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
class WidgetPropertiesReader0300 : public WidgetPropertiesReader
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
WidgetPropertiesReader0300(){};
|
|
|
|
virtual ~WidgetPropertiesReader0300(){};
|
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual cocos2d::gui::Widget* createWidget(const rapidjson::Value& dic, const char* fullPath, const char* fileName);
|
|
|
|
virtual cocos2d::gui::Widget* widgetFromJsonDictionary(const rapidjson::Value& dic);
|
|
|
|
virtual void setPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget*,const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual void setColorPropsForWidgetFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForButtonFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForCheckBoxFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForImageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelAtlasFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLabelBMFontFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForLoadingBarFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForSliderFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForTextFieldFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
|
2013-12-26 12:55:52 +08:00
|
|
|
virtual void setPropsForLayoutFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForPageViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForScrollViewFromJsonDictionary(cocos2d::gui::Widget* widget,const rapidjson::Value& options);
|
|
|
|
virtual void setPropsForListViewFromJsonDictionary(cocos2d::gui::Widget* widget, const rapidjson::Value& options);
|
2013-11-11 18:22:14 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|
2013-09-13 22:20:20 +08:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* defined(__CCSGUIReader__) */
|