mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' of https://github.com/cocos2d/cocos2d-x into v3_strip
This commit is contained in:
commit
dc00158d72
|
@ -21,6 +21,7 @@ cocos2d-x-3.3-rc1 ??
|
|||
[FIX] Scale9Sprite: if scale and flip property are set at the same time, the result would be wrong
|
||||
[FIX] Scene: setScale() doesn't work as expected
|
||||
[FIX] Sprite3D: did not create attached sprite from cache
|
||||
[FIX] UI: Text: invoke ignoreContentAdatpSize(false) will cause wrong effect
|
||||
[FIX] VideoPlayer: showed in wrong place on Android v2.3.x
|
||||
[FIX] WebView: showed in wrong place on Android v2.3.x
|
||||
[FIX] WP: back key behaviour and Director::getInstance()->end() works not correctly
|
||||
|
|
|
@ -34,7 +34,7 @@ project (Cocos2d-X)
|
|||
# The version number
|
||||
set(COCOS2D_X_VERSION 3.3.0-rc1)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
|
||||
include(CocosBuildHelpers)
|
||||
|
||||
message(${BUILDING_STRING})
|
||||
|
|
|
@ -117,7 +117,7 @@ bool Director::init(void)
|
|||
_accumDt = 0.0f;
|
||||
_frameRate = 0.0f;
|
||||
_FPSLabel = _drawnBatchesLabel = _drawnVerticesLabel = nullptr;
|
||||
_totalFrames = _frames = 0;
|
||||
_totalFrames = 0;
|
||||
_lastUpdate = new struct timeval;
|
||||
|
||||
// paused ?
|
||||
|
@ -430,7 +430,13 @@ void Director::setNextDeltaTimeZero(bool nextDeltaTimeZero)
|
|||
{
|
||||
_nextDeltaTimeZero = nextDeltaTimeZero;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// FIXME TODO
|
||||
// Matrix code MUST NOT be part of the Director
|
||||
// MUST BE moved outide.
|
||||
// Why the Director must have this code ?
|
||||
//
|
||||
void Director::initMatrixStack()
|
||||
{
|
||||
while (!_modelViewMatrixStack.empty())
|
||||
|
@ -1069,22 +1075,26 @@ void Director::showStats()
|
|||
{
|
||||
static unsigned long prevCalls = 0;
|
||||
static unsigned long prevVerts = 0;
|
||||
static float prevDeltaTime = 0.016; // 60FPS
|
||||
static const float FPS_FILTER = 0.05;
|
||||
|
||||
++_frames;
|
||||
_accumDt += _deltaTime;
|
||||
|
||||
if (_displayStats && _FPSLabel && _drawnBatchesLabel && _drawnVerticesLabel)
|
||||
{
|
||||
char buffer[30];
|
||||
|
||||
float dt = _deltaTime * FPS_FILTER + (1-FPS_FILTER) * prevDeltaTime;
|
||||
prevDeltaTime = dt;
|
||||
|
||||
// Probably we don't need this anymore since
|
||||
// the framerate is using a low-pass filter
|
||||
// to make the FPS stable
|
||||
if (_accumDt > CC_DIRECTOR_STATS_INTERVAL)
|
||||
{
|
||||
_frameRate = _frames / _accumDt;
|
||||
_frames = 0;
|
||||
_accumDt = 0;
|
||||
|
||||
sprintf(buffer, "%.1f / %.3f", _frameRate, _secondsPerFrame);
|
||||
sprintf(buffer, "%.1f / %.3f", 1/dt, _secondsPerFrame);
|
||||
_FPSLabel->setString(buffer);
|
||||
_accumDt = 0;
|
||||
}
|
||||
|
||||
auto currentCalls = (unsigned long)_renderer->getDrawnBatches();
|
||||
|
@ -1101,8 +1111,8 @@ void Director::showStats()
|
|||
prevVerts = currentVerts;
|
||||
}
|
||||
|
||||
Mat4 identity = Mat4::IDENTITY;
|
||||
|
||||
Mat4 identity = Mat4::IDENTITY;
|
||||
_drawnVerticesLabel->visit(_renderer, identity, 0);
|
||||
_drawnBatchesLabel->visit(_renderer, identity, 0);
|
||||
_FPSLabel->visit(_renderer, identity, 0);
|
||||
|
@ -1111,10 +1121,16 @@ void Director::showStats()
|
|||
|
||||
void Director::calculateMPF()
|
||||
{
|
||||
static float prevSecondsPerFrame = 0;
|
||||
static const float MPF_FILTER = 0.05;
|
||||
|
||||
struct timeval now;
|
||||
gettimeofday(&now, nullptr);
|
||||
|
||||
_secondsPerFrame = (now.tv_sec - _lastUpdate->tv_sec) + (now.tv_usec - _lastUpdate->tv_usec) / 1000000.0f;
|
||||
|
||||
_secondsPerFrame = _secondsPerFrame * MPF_FILTER + (1-MPF_FILTER) * prevSecondsPerFrame;
|
||||
prevSecondsPerFrame = _secondsPerFrame;
|
||||
}
|
||||
|
||||
// returns the FPS image data pointer and len
|
||||
|
|
|
@ -461,7 +461,6 @@ protected:
|
|||
|
||||
/* How many frames were called since the director started */
|
||||
unsigned int _totalFrames;
|
||||
unsigned int _frames;
|
||||
float _secondsPerFrame;
|
||||
|
||||
/* The running scene */
|
||||
|
|
|
@ -78,7 +78,10 @@
|
|||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
--
|
||||
-- Set the rendering size of the text, you should call this method<br>
|
||||
-- along with calling `ignoreContentAdaptWithSize(false)`, otherwise the text area<br>
|
||||
-- size is caculated by the real size of the text content<br>
|
||||
-- param size The text rendering area size
|
||||
-- @function [parent=#Text] setTextAreaSize
|
||||
-- @param self
|
||||
-- @param #size_table size
|
||||
|
|
|
@ -76,7 +76,8 @@ bool Text::init()
|
|||
Text* Text::create(const std::string &textContent, const std::string &fontName, int fontSize)
|
||||
{
|
||||
Text *text = new (std::nothrow) Text;
|
||||
if (text && text->init(textContent, fontName, fontSize)) {
|
||||
if (text && text->init(textContent, fontName, fontSize))
|
||||
{
|
||||
text->autorelease();
|
||||
return text;
|
||||
}
|
||||
|
@ -87,8 +88,10 @@ Text* Text::create(const std::string &textContent, const std::string &fontName,
|
|||
bool Text::init(const std::string &textContent, const std::string &fontName, int fontSize)
|
||||
{
|
||||
bool ret = true;
|
||||
do {
|
||||
if (!Widget::init()) {
|
||||
do
|
||||
{
|
||||
if (!Widget::init())
|
||||
{
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
@ -129,10 +132,12 @@ ssize_t Text::getStringLength()const
|
|||
|
||||
void Text::setFontSize(int size)
|
||||
{
|
||||
if (_type == Type::SYSTEM) {
|
||||
if (_type == Type::SYSTEM)
|
||||
{
|
||||
_labelRenderer->setSystemFontSize(size);
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
TTFConfig config = _labelRenderer->getTTFConfig();
|
||||
config.fontSize = size;
|
||||
_labelRenderer->setTTFConfig(config);
|
||||
|
@ -157,7 +162,8 @@ void Text::setFontName(const std::string& name)
|
|||
_labelRenderer->setTTFConfig(config);
|
||||
_type = Type::TTF;
|
||||
}
|
||||
else{
|
||||
else
|
||||
{
|
||||
_labelRenderer->setSystemFontName(name);
|
||||
if (_type == Type::TTF)
|
||||
{
|
||||
|
@ -183,6 +189,10 @@ Text::Type Text::getType() const
|
|||
void Text::setTextAreaSize(const Size &size)
|
||||
{
|
||||
_labelRenderer->setDimensions(size.width,size.height);
|
||||
if (!_ignoreSize)
|
||||
{
|
||||
_customSize=size;
|
||||
}
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
@ -195,8 +205,6 @@ const Size& Text::getTextAreaSize()const
|
|||
void Text::setTextHorizontalAlignment(TextHAlignment alignment)
|
||||
{
|
||||
_labelRenderer->setHorizontalAlignment(alignment);
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
TextHAlignment Text::getTextHorizontalAlignment()const
|
||||
|
@ -207,8 +215,6 @@ TextHAlignment Text::getTextHorizontalAlignment()const
|
|||
void Text::setTextVerticalAlignment(TextVAlignment alignment)
|
||||
{
|
||||
_labelRenderer->setVerticalAlignment(alignment);
|
||||
updateContentSizeWithTextureSize(_labelRenderer->getContentSize());
|
||||
_labelRendererAdaptDirty = true;
|
||||
}
|
||||
|
||||
TextVAlignment Text::getTextVerticalAlignment()const
|
||||
|
|
|
@ -149,6 +149,13 @@ public:
|
|||
*/
|
||||
virtual std::string getDescription() const override;
|
||||
|
||||
/**
|
||||
* Set the rendering size of the text, you should call this method
|
||||
* along with calling `ignoreContentAdaptWithSize(false)`, otherwise the text area
|
||||
* size is caculated by the real size of the text content
|
||||
* @param size The text rendering area size
|
||||
*
|
||||
*/
|
||||
void setTextAreaSize(const Size &size);
|
||||
|
||||
const Size& getTextAreaSize()const;
|
||||
|
|
|
@ -12,15 +12,8 @@ def get_num_of_cpu():
|
|||
''' The build process can be accelerated by running multiple concurrent job processes using the -j-option.
|
||||
'''
|
||||
try:
|
||||
platform = sys.platform
|
||||
if platform == 'win32':
|
||||
if 'NUMBER_OF_PROCESSORS' in os.environ:
|
||||
return int(os.environ['NUMBER_OF_PROCESSORS'])
|
||||
else:
|
||||
return 1
|
||||
else:
|
||||
from numpy.distutils import cpuinfo
|
||||
return cpuinfo.cpu._getNCPUs()
|
||||
import multiprocessing
|
||||
return multiprocessing.cpu_count()
|
||||
except Exception:
|
||||
print "Can't know cpuinfo, use default 1 cpu"
|
||||
return 1
|
||||
|
|
|
@ -535,13 +535,13 @@ void TextWritePlist::onEnter()
|
|||
auto loadDict = __Dictionary::createWithContentsOfFile(fullPath.c_str());
|
||||
auto loadDictInDict = (__Dictionary*)loadDict->objectForKey("dictInDict, Hello World");
|
||||
auto boolValue = (__String*)loadDictInDict->objectForKey("bool");
|
||||
CCLOG("%s",boolValue->getCString());
|
||||
log("%s",boolValue->getCString());
|
||||
auto floatValue = (__String*)loadDictInDict->objectForKey("float");
|
||||
CCLOG("%s",floatValue->getCString());
|
||||
log("%s",floatValue->getCString());
|
||||
auto intValue = (__String*)loadDictInDict->objectForKey("integer");
|
||||
CCLOG("%s",intValue->getCString());
|
||||
log("%s",intValue->getCString());
|
||||
auto doubleValue = (__String*)loadDictInDict->objectForKey("double");
|
||||
CCLOG("%s",doubleValue->getCString());
|
||||
log("%s",doubleValue->getCString());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -163,7 +163,7 @@ g_guisTests[] =
|
|||
UISceneManager* sceneManager = UISceneManager::sharedUISceneManager();
|
||||
sceneManager->setCurrentUISceneId(kUITextTest);
|
||||
sceneManager->setMinUISceneId(kUITextTest);
|
||||
sceneManager->setMaxUISceneId(kUITextTest_TTF);
|
||||
sceneManager->setMaxUISceneId(kUITextTest_IgnoreConentSize);
|
||||
Scene* scene = sceneManager->currentUIScene();
|
||||
Director::getInstance()->replaceScene(scene);
|
||||
}
|
||||
|
|
|
@ -185,10 +185,9 @@ bool UIPageViewButtonTest::init()
|
|||
return false;
|
||||
}
|
||||
|
||||
void UIPageViewButtonTest::onButtonClicked(Ref* pSender, Widget::TouchEventType type)
|
||||
void UIPageViewButtonTest::onButtonClicked(Ref* sender, Widget::TouchEventType type)
|
||||
{
|
||||
Button *btn = (Button*)pSender;
|
||||
CCLOG("button %s clicked", btn->getName().c_str());
|
||||
log("button %s clicked", static_cast<Button*>(sender)->getName().c_str());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ static const char* s_testArray[] =
|
|||
"UITextTest_LineWrap",
|
||||
"UILabelTest_Effect",
|
||||
"UITextTest_TTF",
|
||||
"UITextTest_IgnoreConentSize",
|
||||
"UITextBMFontTest",
|
||||
|
||||
"UITextFieldTest",
|
||||
|
@ -272,7 +273,8 @@ Scene *UISceneManager::currentUIScene()
|
|||
|
||||
case kUITextTest_TTF:
|
||||
return UITextTest_TTF::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
|
||||
case kUITextTest_IgnoreConentSize:
|
||||
return UITextTest_IgnoreConentSize::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
case kUITextFieldTest:
|
||||
return UITextFieldTest::sceneWithTitle(s_testArray[_currentUISceneId]);
|
||||
|
||||
|
|
|
@ -60,9 +60,10 @@ enum
|
|||
kUITextAtlasTest,
|
||||
kUITextTest,
|
||||
kUITextTest_LineWrap,
|
||||
|
||||
kUILabelTest_Effect,
|
||||
kUITextTest_TTF,
|
||||
kUITextTest_IgnoreConentSize,
|
||||
|
||||
kUITextBMFontTest,
|
||||
kUITextFieldTest,
|
||||
kUITextFieldTest_MaxLength,
|
||||
|
|
|
@ -141,6 +141,53 @@ bool UITextTest_TTF::init()
|
|||
text->setPosition(Vec2(widgetSize.width / 2.0f, widgetSize.height / 2.0f + text->getContentSize().height / 4.0f));
|
||||
_uiLayer->addChild(text);
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// UITextTest_IgnoreConentSize
|
||||
|
||||
bool UITextTest_IgnoreConentSize::init()
|
||||
{
|
||||
if (UIScene::init())
|
||||
{
|
||||
Size widgetSize = _widget->getContentSize();
|
||||
|
||||
Text* leftText = Text::create("ignore conent",
|
||||
"fonts/Marker Felt.ttf",10);
|
||||
leftText->setPosition(Vec2(widgetSize.width / 2.0f - 50,
|
||||
widgetSize.height / 2.0f));
|
||||
leftText->ignoreContentAdaptWithSize(false);
|
||||
leftText->setTextAreaSize(Size(60,60));
|
||||
leftText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
|
||||
leftText->setTouchScaleChangeEnabled(true);
|
||||
leftText->setTouchEnabled(true);
|
||||
_uiLayer->addChild(leftText);
|
||||
|
||||
|
||||
Text* rightText = Text::create("ignore conent",
|
||||
"fonts/Marker Felt.ttf",10);
|
||||
rightText->setPosition(Vec2(widgetSize.width / 2.0f + 50,
|
||||
widgetSize.height / 2.0f));
|
||||
rightText->setString("Text line with break\nText line with break\nText line with break\nText line with break\n");
|
||||
//note: setTextAreaSize must be used with ignoreContentAdaptWithSize(false)
|
||||
rightText->setTextAreaSize(Size(100,30));
|
||||
rightText->ignoreContentAdaptWithSize(false);
|
||||
_uiLayer->addChild(rightText);
|
||||
|
||||
|
||||
auto halighButton = Button::create();
|
||||
halighButton->setTitleText("Alignment Right");
|
||||
halighButton->addClickEventListener([=](Ref*){
|
||||
leftText->setTextHorizontalAlignment(TextHAlignment::RIGHT);
|
||||
rightText->setTextHorizontalAlignment(TextHAlignment::RIGHT);
|
||||
});
|
||||
halighButton->setPosition(Vec2(widgetSize.width/2 - 50,
|
||||
widgetSize.height/2 - 50));
|
||||
_uiLayer->addChild(halighButton);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -65,4 +65,12 @@ protected:
|
|||
UI_SCENE_CREATE_FUNC(UITextTest_TTF)
|
||||
};
|
||||
|
||||
class UITextTest_IgnoreConentSize : public UIScene
|
||||
{
|
||||
public:
|
||||
bool init();
|
||||
protected:
|
||||
UI_SCENE_CREATE_FUNC(UITextTest_IgnoreConentSize)
|
||||
};
|
||||
|
||||
#endif /* defined(__TestCpp__UITextTest__) */
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
void RefPtrTest::onEnter()
|
||||
{
|
||||
UnitTestDemo::onEnter();
|
||||
|
||||
|
||||
#if DEBUG
|
||||
// TEST(constructors)
|
||||
{
|
||||
// Default constructor
|
||||
|
@ -313,6 +314,9 @@ void RefPtrTest::onEnter()
|
|||
CC_ASSERT(theString->getReferenceCount() == 2);
|
||||
CC_ASSERT(theString->compare("Hello world!") == 0);
|
||||
}
|
||||
#else
|
||||
log("RefPtr tests are not executed in release mode");
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string RefPtrTest::subtitle() const
|
||||
|
|
|
@ -697,7 +697,8 @@ void ValueTest::constFunc(const Value& value) const
|
|||
|
||||
// UTFConversionTest
|
||||
|
||||
static const int TEST_CODE_NUM = 11;
|
||||
// FIXME: made as define to prevent compile warnings in release mode. Better is to be a `const static int`
|
||||
#define TEST_CODE_NUM 11
|
||||
|
||||
static const char16_t __utf16Code[] =
|
||||
{
|
||||
|
@ -818,8 +819,7 @@ static void doUTFConversion()
|
|||
CCASSERT(StringUtils::getCharacterCountInUTF8String(originalUTF8) == TEST_CODE_NUM, "StringUtils::getCharacterCountInUTF8String failed");
|
||||
|
||||
//---------------------------
|
||||
int lastIndex = StringUtils::getIndexOfLastNotChar16(vec3, 0x2009);
|
||||
CCASSERT(lastIndex == (vec1.size()-1), "StringUtils::getIndexOfLastNotChar16 failed");
|
||||
CCASSERT(StringUtils::getIndexOfLastNotChar16(vec3, 0x2009) == (vec1.size()-1), "StringUtils::getIndexOfLastNotChar16 failed");
|
||||
|
||||
//---------------------------
|
||||
CCASSERT(originalUTF16.length() == TEST_CODE_NUM, "The length of the original utf16 string isn't equal to TEST_CODE_NUM");
|
||||
|
|
Loading…
Reference in New Issue