mirror of https://github.com/axmolengine/axmol.git
sharedXXX -> getInstance, purgeXXX -> destroyInstance.
This commit is contained in:
parent
046384ca1f
commit
ef5ab1b9be
|
@ -44,7 +44,7 @@ GUIReader::~GUIReader()
|
|||
{
|
||||
}
|
||||
|
||||
GUIReader* GUIReader::shareReader()
|
||||
GUIReader* GUIReader::getInstance()
|
||||
{
|
||||
if (!sharedReader)
|
||||
{
|
||||
|
@ -53,7 +53,7 @@ GUIReader* GUIReader::shareReader()
|
|||
return sharedReader;
|
||||
}
|
||||
|
||||
void GUIReader::purgeGUIReader()
|
||||
void GUIReader::destroyInstance()
|
||||
{
|
||||
CC_SAFE_DELETE(sharedReader);
|
||||
}
|
||||
|
@ -171,13 +171,13 @@ Widget* WidgetPropertiesReader0250::createWidget(const rapidjson::Value& data, c
|
|||
float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth");
|
||||
float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight");
|
||||
if (fileDesignWidth <= 0 || fileDesignHeight <= 0) {
|
||||
printf("Read design size error!\n");
|
||||
CCLOGERROR("Read design size error!\n");
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
GUIReader::shareReader()->storeFileDesignSize(fileName, winSize);
|
||||
GUIReader::getInstance()->storeFileDesignSize(fileName, winSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight));
|
||||
GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight));
|
||||
}
|
||||
const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree");
|
||||
Widget* widget = widgetFromJsonDictionary(widgetTree);
|
||||
|
@ -870,13 +870,13 @@ Widget* WidgetPropertiesReader0300::createWidget(const rapidjson::Value& data, c
|
|||
float fileDesignWidth = DICTOOL->getFloatValue_json(data, "designWidth");
|
||||
float fileDesignHeight = DICTOOL->getFloatValue_json(data, "designHeight");
|
||||
if (fileDesignWidth <= 0 || fileDesignHeight <= 0) {
|
||||
printf("Read design size error!\n");
|
||||
CCLOGERROR("Read design size error!\n");
|
||||
Size winSize = Director::getInstance()->getWinSize();
|
||||
GUIReader::shareReader()->storeFileDesignSize(fileName, winSize);
|
||||
GUIReader::getInstance()->storeFileDesignSize(fileName, winSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIReader::shareReader()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight));
|
||||
GUIReader::getInstance()->storeFileDesignSize(fileName, Size(fileDesignWidth, fileDesignHeight));
|
||||
}
|
||||
const rapidjson::Value& widgetTree = DICTOOL->getSubDictionary_json(data, "widgetTree");
|
||||
Widget* widget = widgetFromJsonDictionary(widgetTree);
|
||||
|
|
|
@ -31,27 +31,15 @@
|
|||
namespace cocostudio {
|
||||
|
||||
#define kCCSVersion 1.0
|
||||
class GUIReader : public cocos2d::Object
|
||||
|
||||
class GUIReader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
*/
|
||||
GUIReader();
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
~GUIReader();
|
||||
/**
|
||||
* @js getInstance
|
||||
* @lua getInstance
|
||||
*/
|
||||
static GUIReader* shareReader();
|
||||
/**
|
||||
* @js purge
|
||||
*/
|
||||
static void purgeGUIReader();
|
||||
CC_DEPRECATED_ATTRIBUTE static GUIReader* shareReader() { return GUIReader::getInstance(); };
|
||||
CC_DEPRECATED_ATTRIBUTE static void purgeGUIReader() { GUIReader::destroyInstance(); };
|
||||
|
||||
static GUIReader* getInstance();
|
||||
static void destroyInstance();
|
||||
|
||||
cocos2d::gui::Widget* widgetFromJsonFile(const char* fileName);
|
||||
int getVersionInteger(const char* str);
|
||||
|
@ -63,7 +51,11 @@ public:
|
|||
* @js NA
|
||||
*/
|
||||
const cocos2d::Size getFileDesignSize(const char* fileName) const;
|
||||
|
||||
protected:
|
||||
GUIReader();
|
||||
~GUIReader();
|
||||
|
||||
std::string m_strFilePath;
|
||||
cocos2d::ValueMap _fileDesignSizes;
|
||||
|
||||
|
|
|
@ -374,7 +374,7 @@ Node* SceneReader::createObject(const rapidjson::Value &dict, cocos2d::Node* par
|
|||
}
|
||||
else if(comName != nullptr && strcmp(comName, "GUIComponent") == 0)
|
||||
{
|
||||
Widget* widget= GUIReader::shareReader()->widgetFromJsonFile(pPath.c_str());
|
||||
Widget* widget= GUIReader::getInstance()->widgetFromJsonFile(pPath.c_str());
|
||||
ComRender *pRender = ComRender::create(widget, "GUIComponent");
|
||||
if (pComName != nullptr)
|
||||
{
|
||||
|
@ -460,7 +460,6 @@ void SceneReader::destroyInstance()
|
|||
{
|
||||
DictionaryHelper::destroyInstance();
|
||||
TriggerMng::destroyInstance();
|
||||
_fnSelector = nullptr;
|
||||
CocosDenshion::SimpleAudioEngine::end();
|
||||
CC_SAFE_DELETE(s_sharedReader);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
* @js purge
|
||||
* @lua destroySceneReader
|
||||
*/
|
||||
void destroyInstance();
|
||||
static void destroyInstance();
|
||||
static const char* sceneReaderVersion();
|
||||
cocos2d::Node* createNodeWithSceneFile(const std::string &fileName);
|
||||
void setTarget(const std::function<void(cocos2d::Object* obj, void* doc)>& selector);
|
||||
|
|
|
@ -27,7 +27,7 @@ bool UIScene::init()
|
|||
_uiLayer = Layer::create();
|
||||
addChild(_uiLayer);
|
||||
|
||||
_widget = dynamic_cast<Layout*>(cocostudio::GUIReader::shareReader()->widgetFromJsonFile("cocosgui/UITest/UITest.json"));
|
||||
_widget = dynamic_cast<Layout*>(cocostudio::GUIReader::getInstance()->widgetFromJsonFile("cocosgui/UITest/UITest.json"));
|
||||
_uiLayer->addChild(_widget);
|
||||
|
||||
Size screenSize = Director::getInstance()->getWinSize();
|
||||
|
|
|
@ -228,10 +228,10 @@ void LoadSceneEdtiorFileTest::onEnter()
|
|||
|
||||
void LoadSceneEdtiorFileTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -274,10 +274,10 @@ void SpriteComponentTest::onEnter()
|
|||
|
||||
void SpriteComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -329,10 +329,10 @@ void ArmatureComponentTest::onEnter()
|
|||
|
||||
void ArmatureComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -380,10 +380,10 @@ void UIComponentTest::onEnter()
|
|||
|
||||
void UIComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -450,10 +450,10 @@ void TmxMapComponentTest::onEnter()
|
|||
|
||||
void TmxMapComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -506,10 +506,10 @@ void ParticleComponentTest::onEnter()
|
|||
|
||||
void ParticleComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -557,10 +557,10 @@ void EffectComponentTest::onEnter()
|
|||
|
||||
void EffectComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -619,10 +619,10 @@ void BackgroundComponentTest::onEnter()
|
|||
|
||||
void BackgroundComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -669,10 +669,10 @@ void AttributeComponentTest::onEnter()
|
|||
|
||||
void AttributeComponentTest::onExit()
|
||||
{
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
@ -746,10 +746,10 @@ void TriggerTest::onExit()
|
|||
auto dispatcher = Director::getInstance()->getEventDispatcher();
|
||||
dispatcher->removeEventListener(_touchListener);
|
||||
Device::setAccelerometerEnabled(false);
|
||||
ArmatureDataManager::getInstance()->destroyInstance();
|
||||
SceneReader::getInstance()->destroyInstance();
|
||||
ActionManagerEx::getInstance()->destroyInstance();
|
||||
GUIReader::shareReader()->purgeGUIReader();
|
||||
ArmatureDataManager::destroyInstance();
|
||||
SceneReader::destroyInstance();
|
||||
ActionManagerEx::destroyInstance();
|
||||
GUIReader::destroyInstance();
|
||||
SceneEditorTestLayer::onExit();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue