Skip to content

Commit

Permalink
minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
dualface committed Jul 11, 2014
1 parent 4368705 commit 156f57f
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@


#include <algorithm>

#include "LabelReader.h"
#include "../../../GUI/UIWidgets/UILabel.h"

Expand All @@ -13,12 +15,12 @@ IMPLEMENT_CLASS_WIDGET_READER_INFO(LabelReader)

LabelReader::LabelReader()
{

}

LabelReader::~LabelReader()
{

}

LabelReader* LabelReader::getInstance()
Expand All @@ -33,18 +35,18 @@ LabelReader* LabelReader::getInstance()
void LabelReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson::Value &options)
{
WidgetReader::setPropsFromJsonDictionary(widget, options);


std::string jsonPath = GUIReader::shareReader()->getFilePath();

ui::Label* label = (ui::Label*)widget;
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, "touchScaleEnable");
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
const char* text = DICTOOL->getStringValue_json(options, "text","Text Label");
label->setText(text);

label->setFontSize(DICTOOL->getIntValue_json(options, "fontSize",20));

std::string fontName = DICTOOL->getStringValue_json(options, "fontName","微软雅黑");
std::string file_extension = "";
size_t pos = fontName.find_last_of('.');
Expand All @@ -53,7 +55,7 @@ void LabelReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson
file_extension = fontName.substr(pos, fontName.length());
std::transform(file_extension.begin(),file_extension.end(), file_extension.begin(), (int(*)(int))toupper);
}

if (file_extension.compare(".TTF") == 0)
{
std::string fontFilePath = jsonPath.append(fontName);
Expand All @@ -63,7 +65,7 @@ void LabelReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson
{
label->setFontName(fontName);
}

bool aw = DICTOOL->checkObjectExist_json(options, "areaWidth");
bool ah = DICTOOL->checkObjectExist_json(options, "areaHeight");
if (aw && ah)
Expand All @@ -81,25 +83,25 @@ void LabelReader::setPropsFromJsonDictionary(ui::Widget *widget, const rapidjson
{
label->setTextVerticalAlignment((CCVerticalTextAlignment)DICTOOL->getIntValue_json(options, "vAlignment"));
}


WidgetReader::setColorPropsFromJsonDictionary(widget, options);
}

void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pCocoLoader, stExpCocoNode *pCocoNode)
{
this->beginSetBasicProperties(widget);

stExpCocoNode *stChildArray = pCocoNode->GetChildArray(pCocoLoader);

ui::Label* label = static_cast<ui::Label*>(widget);


for (int i = 0; i < pCocoNode->GetChildNum(); ++i) {
std::string key = stChildArray[i].GetName(pCocoLoader);
std::string value = stChildArray[i].GetValue(pCocoLoader);
// CCLOG("Text: key = %s, value = %s", key.c_str(), value.c_str());

if (key == "ignoreSize") {
widget->ignoreContentAdaptWithSize(valueToBool(value));
}else if(key == "sizeType"){
Expand Down Expand Up @@ -147,16 +149,16 @@ void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pC
widget->setZOrder(valueToInt(value));
}else if(key == "layoutParameter"){
stExpCocoNode *layoutCocosNode = stChildArray[i].GetChildArray(pCocoLoader);

LinearLayoutParameter *linearParameter = LinearLayoutParameter::create();
RelativeLayoutParameter *relativeParameter = RelativeLayoutParameter::create();
Margin mg;

int paramType = -1;
for (int j = 0; j < stChildArray[i].GetChildNum(); ++j) {
std::string innerKey = layoutCocosNode[j].GetName(pCocoLoader);
std::string innerValue = layoutCocosNode[j].GetValue(pCocoLoader);

if (innerKey == "type") {
paramType = valueToInt(innerValue);
}else if(innerKey == "gravity"){
Expand All @@ -177,10 +179,10 @@ void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pC
mg.bottom = valueToFloat(innerValue);
}
}

linearParameter->setMargin(mg);
relativeParameter->setMargin(mg);

switch (paramType) {
case 1:
widget->setLayoutParameter(linearParameter);
Expand All @@ -191,7 +193,7 @@ void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pC
break;
}
}

else if (key == "opacity") {
_opacity = valueToInt(value);
}
Expand All @@ -215,7 +217,7 @@ void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pC
else if (key == "touchScaleEnable") {
label->setTouchScaleChangeEnabled(valueToBool(value));
}

else if(key == "text"){
label->setText(value);
}else if(key == "fontSize"){
Expand All @@ -233,7 +235,7 @@ void LabelReader::setPropsFromBinary(cocos2d::ui::Widget *widget, CocoLoader *pC
}else if(key == "vAlignment"){
label->setTextVerticalAlignment((CCVerticalTextAlignment)valueToInt(value));
}

} //end of for loop
this->endSetBasicProperties(widget);
}
Expand Down
Binary file modified player/mac/player.app/Contents/MacOS/player
Binary file not shown.
4 changes: 2 additions & 2 deletions samples/iap4ios/proj.ios/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<string>Icon-72.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>org.cocos2d_x.samples.${PRODUCT_NAME:rfc1034identifier}</string>
<string>org.cocos.quick.samples.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
Expand Down Expand Up @@ -44,7 +44,7 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
Expand Down
6 changes: 3 additions & 3 deletions samples/iap4ios/scripts/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CONFIG_SCREEN_AUTOSCALE = "FIXED_WIDTH"

-- IAP Products ID
STORE_PRODUCTS_ID = {
"com.quick-x.sample.iap4ios.product01",
"com.quick-x.sample.iap4ios.product02",
"com.quick-x.sample.iap4ios.product03",
"org.cocos.quick.samples.iap4ios.product01",
"org.cocos.quick.samples.iap4ios.product02",
"org.cocos.quick.samples.iap4ios.product03",
}

0 comments on commit 156f57f

Please sign in to comment.