mirror of https://github.com/axmolengine/axmol.git
Merge pull request #13801 from chengstory/OptimizateDoLayout
Move "ui::Helper::DoLayout" to "CreateNode"。
This commit is contained in:
commit
dbe3e062bc
|
@ -295,6 +295,30 @@ Node* CSLoader::createNode(const std::string &filename, const ccNodeLoadCallback
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Node* CSLoader::createNodeWithVisibleSize(const std::string& filename)
|
||||||
|
{
|
||||||
|
auto node = createNode(filename);
|
||||||
|
if (node != nullptr)
|
||||||
|
{
|
||||||
|
Size frameSize = Director::getInstance()->getVisibleSize();
|
||||||
|
node->setContentSize(frameSize);
|
||||||
|
ui::Helper::doLayout(node);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
Node* CSLoader::createNodeWithVisibleSize(const std::string &filename, const ccNodeLoadCallback &callback)
|
||||||
|
{
|
||||||
|
auto node = createNode(filename, callback);
|
||||||
|
if (node != nullptr)
|
||||||
|
{
|
||||||
|
Size frameSize = Director::getInstance()->getVisibleSize();
|
||||||
|
node->setContentSize(frameSize);
|
||||||
|
ui::Helper::doLayout(node);
|
||||||
|
}
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
std::string CSLoader::getExtentionName(const std::string& name)
|
std::string CSLoader::getExtentionName(const std::string& name)
|
||||||
{
|
{
|
||||||
std::string result = "";
|
std::string result = "";
|
||||||
|
@ -551,7 +575,7 @@ void CSLoader::initNode(Node* node, const rapidjson::Value& json)
|
||||||
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255);
|
GLubyte red = (GLubyte)DICTOOL->getIntValue_json(json, RED, 255);
|
||||||
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255);
|
GLubyte green = (GLubyte)DICTOOL->getIntValue_json(json, GREEN, 255);
|
||||||
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255);
|
GLubyte blue = (GLubyte)DICTOOL->getIntValue_json(json, BLUE, 255);
|
||||||
int zorder = DICTOOL->getIntValue_json(json, ZORDER);
|
int zorder = DICTOOL->getIntValue_json(json, ZORDER);
|
||||||
int tag = DICTOOL->getIntValue_json(json, TAG);
|
int tag = DICTOOL->getIntValue_json(json, TAG);
|
||||||
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
|
int actionTag = DICTOOL->getIntValue_json(json, ACTION_TAG);
|
||||||
bool visible = DICTOOL->getBooleanValue_json(json, VISIBLE);
|
bool visible = DICTOOL->getBooleanValue_json(json, VISIBLE);
|
||||||
|
|
|
@ -81,6 +81,8 @@ public:
|
||||||
static cocos2d::Node* createNode(const std::string& filename, const ccNodeLoadCallback& callback);
|
static cocos2d::Node* createNode(const std::string& filename, const ccNodeLoadCallback& callback);
|
||||||
static cocos2d::Node* createNode(const Data data);
|
static cocos2d::Node* createNode(const Data data);
|
||||||
static cocos2d::Node* createNode(const Data data, const ccNodeLoadCallback &callback);
|
static cocos2d::Node* createNode(const Data data, const ccNodeLoadCallback &callback);
|
||||||
|
static cocos2d::Node* createNodeWithVisibleSize(const std::string& filename);
|
||||||
|
static cocos2d::Node* createNodeWithVisibleSize(const std::string& filename, const ccNodeLoadCallback& callback);
|
||||||
|
|
||||||
static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename);
|
static cocostudio::timeline::ActionTimeline* createTimeline(const std::string& filename);
|
||||||
static cocostudio::timeline::ActionTimeline* createTimeline(const Data data, const std::string& filename);
|
static cocostudio::timeline::ActionTimeline* createTimeline(const Data data, const std::string& filename);
|
||||||
|
|
|
@ -193,6 +193,28 @@ ccs.load = function(file, path){
|
||||||
return object;
|
return object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analysis of studio JSON file and layout ui widgets by visible size.
|
||||||
|
* The incoming file name, parse out the corresponding object
|
||||||
|
* Temporary support file list:
|
||||||
|
* ui 1.*
|
||||||
|
* node 1.* - 2.*
|
||||||
|
* action 1.* - 2.*
|
||||||
|
* scene 0.* - 1.*
|
||||||
|
* @param {String} file
|
||||||
|
* @param {String} [path=] Resource path
|
||||||
|
* @returns {{node: cc.Node, action: cc.Action}}
|
||||||
|
*/
|
||||||
|
ccs.loadWithVisibleSize = function(file, path){
|
||||||
|
var object = ccs.load(file, path);
|
||||||
|
var size = cc.director.getVisibleSize();
|
||||||
|
if(object.node && size){
|
||||||
|
object.node.setContentSize(size.width, size.height);
|
||||||
|
ccui.helper.doLayout(object.node);
|
||||||
|
}
|
||||||
|
return object;
|
||||||
|
};
|
||||||
|
|
||||||
//Forward compatible interface
|
//Forward compatible interface
|
||||||
|
|
||||||
ccs.actionTimelineCache = {
|
ccs.actionTimelineCache = {
|
||||||
|
|
Loading…
Reference in New Issue