From 6152dbf4bd2e8341945e6a7faf1fdfef3bb4e76c Mon Sep 17 00:00:00 2001 From: ZeaS Date: Wed, 5 Apr 2017 19:44:55 +0800 Subject: [PATCH] Add option to force using default font fix some bugs: - crash by fetching space character bitmap - etcpak edge error - gsotSimple may cause something wrong in trans effect some ui improving for skin support --- readme.md | 2 + src/core/environ/ui/FileSelectorForm.cpp | 12 ++-- src/core/environ/ui/FileSelectorForm.h | 4 +- src/core/environ/ui/InGameMenuForm.cpp | 17 ++++-- src/core/environ/ui/InGameMenuForm.h | 2 +- src/core/environ/ui/PreferenceConfig.h | 69 ++++++++++------------ src/core/environ/ui/PreferenceForm.cpp | 15 +++-- src/core/environ/ui/PreferenceForm.h | 13 ++-- src/core/environ/ui/SeletListForm.cpp | 9 ++- src/core/visual/FontSystem.cpp | 2 + src/core/visual/FreeTypeFontRasterizer.cpp | 9 ++- src/core/visual/LayerIntf.cpp | 7 +-- src/core/visual/ogl/RenderManager_ogl.cpp | 4 +- src/core/visual/ogl/etcpak.cpp | 4 +- 14 files changed, 96 insertions(+), 73 deletions(-) diff --git a/readme.md b/readme.md index 01d74187..20751b8a 100644 --- a/readme.md +++ b/readme.md @@ -8,3 +8,5 @@ Video playback module modified from [kodi](https://github.com/xbmc/xbmc) Some string code from [glibc](https://www.gnu.org/s/libc) and [Apple Libc](https://opensource.apple.com/source/Libc). Real-time texture codec modified from [etcpak](https://bitbucket.org/wolfpld/etcpak.git), [pvrtccompressor](https://bitbucket.org/jthlim/pvrtccompressor), [astcrt](https://github.com/daoo/astcrt) + +Android storage accessing code from [AmazeFileManager](https://github.com/arpitkh96/AmazeFileManager) diff --git a/src/core/environ/ui/FileSelectorForm.cpp b/src/core/environ/ui/FileSelectorForm.cpp index 7230c75d..d2122946 100644 --- a/src/core/environ/ui/FileSelectorForm.cpp +++ b/src/core/environ/ui/FileSelectorForm.cpp @@ -218,7 +218,7 @@ void TVPBaseFileSelectorForm::onCellLongPress(int idx) LocaleConfigManager::GetInstance()->initText(reader.findController("titleCopy")); LocaleConfigManager::GetInstance()->initText(reader.findController("titleCut")); LocaleConfigManager::GetInstance()->initText(reader.findController("titlePaste")); - LocaleConfigManager::GetInstance()->initText(reader.findController("titleUnpack", false)); + LocaleConfigManager::GetInstance()->initText(reader.findController("titleUnpack")); LocaleConfigManager::GetInstance()->initText(reader.findController("titleRepack", false)); LocaleConfigManager::GetInstance()->initText(reader.findController("titleDelete")); LocaleConfigManager::GetInstance()->initText(reader.findController("titleSendTo")); @@ -385,7 +385,7 @@ TVPBaseFileSelectorForm::FileItemCellImpl* TVPBaseFileSelectorForm::FetchCell(Fi CellModel->retain(); } bool selected = _selectedFileIndex.find(idx) != _selectedFileIndex.end(); - CellModel->setInfo(CurrentDirList[idx], selected, !_selectedFileIndex.empty()); + CellModel->setInfo(idx, CurrentDirList[idx], selected, !_selectedFileIndex.empty()); return CellModel; } @@ -420,7 +420,7 @@ Size TVPBaseFileSelectorForm::tableCellSizeForIndex(TableView *table, ssize_t id if (!CellTemplateForSize) { CellTemplateForSize = FetchCell(nullptr, table, idx); } else { - CellTemplateForSize->setInfo(CurrentDirList[idx], false, false); + CellTemplateForSize->setInfo(idx, CurrentDirList[idx], false, false); } info.CellSize = CellTemplateForSize->getContentSize(); } @@ -783,9 +783,11 @@ void TVPBaseFileSelectorForm::FileItemCellImpl::initFromFile(const char * filena } }); } + BgOdd = reader.findController("bg_odd", false); + BgEven = reader.findController("bg_even", false); } -void TVPBaseFileSelectorForm::FileItemCellImpl::setInfo(const FileInfo &info, bool selected, bool showSelect) { +void TVPBaseFileSelectorForm::FileItemCellImpl::setInfo(int idx, const FileInfo &info, bool selected, bool showSelect) { if (FileNameNode) { FileNameNode->ignoreContentAdaptWithSize(true); FileNameNode->setTextAreaSize(CellTextAreaSize); @@ -801,6 +803,8 @@ void TVPBaseFileSelectorForm::FileItemCellImpl::setInfo(const FileInfo &info, bo if (showSelect) SelectBox->setSelected(selected); ui::Helper::doLayout(_root); _set = true; + if (BgOdd) BgOdd->setVisible((idx + 1) & 1); + if (BgEven) BgEven->setVisible(idx & 1); } void TVPBaseFileSelectorForm::FileItemCellImpl::onClicked(cocos2d::Ref* p) { diff --git a/src/core/environ/ui/FileSelectorForm.h b/src/core/environ/ui/FileSelectorForm.h index f088ca2c..b7b8c796 100644 --- a/src/core/environ/ui/FileSelectorForm.h +++ b/src/core/environ/ui/FileSelectorForm.h @@ -107,7 +107,7 @@ class TVPBaseFileSelectorForm : public iTVPBaseForm, public cocos2d::extension:: void initFromFile(const char * filename, float width); - void setInfo(const FileInfo &info, bool selected, bool showSelect); + void setInfo(int idx, const FileInfo &info, bool selected, bool showSelect); void reset() { _set = false; @@ -127,7 +127,7 @@ class TVPBaseFileSelectorForm : public iTVPBaseForm, public cocos2d::extension:: bool _set; cocos2d::Size OrigCellModelSize, CellTextAreaSize, OrigCellTextSize; cocos2d::ui::Text *FileNameNode; - cocos2d::Node *DirIcon, *_root; + cocos2d::Node *DirIcon, *_root, *BgOdd, *BgEven; cocos2d::ui::CheckBox *SelectBox; FileItemCell *_owner; }; diff --git a/src/core/environ/ui/InGameMenuForm.cpp b/src/core/environ/ui/InGameMenuForm.cpp index 24a911a8..28b3b9f1 100644 --- a/src/core/environ/ui/InGameMenuForm.cpp +++ b/src/core/environ/ui/InGameMenuForm.cpp @@ -5,6 +5,7 @@ #include "ui/UIText.h" #include "MenuItemImpl.h" #include "ui/UIHelper.h" +#include "tjsGlobalStringMap.h" using namespace cocos2d; using namespace cocos2d::ui; @@ -47,19 +48,23 @@ void TVPInGameMenuForm::initMenu(const std::string& title, tTJSNI_MenuItem *item } int count = item->GetChildren().size(); + int idx = 0; + ttstr seperator = TJS::TJSMapGlobalStringMap(TJS_W("-")); for (int i = 0; i < count; ++i) { tTJSNI_MenuItem *subitem = static_cast(item->GetChildren().at(i)); ttstr caption; subitem->GetCaption(caption); if (caption.IsEmpty() || caption == TJS_W("+")) continue; - _list->pushBackCustomItem(createMenuItem(subitem, caption.AsStdString())); + _list->pushBackCustomItem(createMenuItem(idx, subitem, caption.AsStdString())); + if(caption != seperator) + ++idx; } } -cocos2d::ui::Widget * TVPInGameMenuForm::createMenuItem(tTJSNI_MenuItem *item, const std::string &caption) { +cocos2d::ui::Widget * TVPInGameMenuForm::createMenuItem(int idx, tTJSNI_MenuItem *item, const std::string &caption) { iPreferenceItem *ret = nullptr; const Size &size = _list->getContentSize(); if (!item->GetChildren().empty()) { - ret = CreatePreferenceItem(size, caption); + ret = CreatePreferenceItem(idx, size, caption); ret->addClickEventListener([=](Ref*){ TVPMainScene::GetInstance()->pushUIForm(create(caption, item)); }); @@ -69,7 +74,7 @@ cocos2d::ui::Widget * TVPInGameMenuForm::createMenuItem(tTJSNI_MenuItem *item, c item->OnClick(); TVPMainScene::GetInstance()->popAllUIForm(); }; - ret = CreatePreferenceItem(size, caption, + ret = CreatePreferenceItem(idx, size, caption, [=](tPreferenceItemCheckBox* item) { item->_getter = getter; item->_setter = setter; @@ -77,7 +82,7 @@ cocos2d::ui::Widget * TVPInGameMenuForm::createMenuItem(tTJSNI_MenuItem *item, c } else if (item->GetChecked()) { auto getter = [=]()->bool{ return item->GetChecked(); }; auto setter = [=](bool b){ item->OnClick(); }; - ret = CreatePreferenceItem(size, caption, + ret = CreatePreferenceItem(idx, size, caption, [=](tPreferenceItemCheckBox* item) { item->_getter = getter; item->_setter = setter; @@ -91,7 +96,7 @@ cocos2d::ui::Widget * TVPInGameMenuForm::createMenuItem(tTJSNI_MenuItem *item, c ui::Helper::doLayout(root); return root; } else { - ret = CreatePreferenceItem(size, caption); + ret = CreatePreferenceItem(idx, size, caption); ret->addClickEventListener([=](Ref*){ TVPMainScene::GetInstance()->scheduleOnce( std::bind(&TVPMainScene::popAllUIForm, TVPMainScene::GetInstance()), 0, "close_menu"); diff --git a/src/core/environ/ui/InGameMenuForm.h b/src/core/environ/ui/InGameMenuForm.h index dc135992..98b2e036 100644 --- a/src/core/environ/ui/InGameMenuForm.h +++ b/src/core/environ/ui/InGameMenuForm.h @@ -13,7 +13,7 @@ class TVPInGameMenuForm : public iTVPBaseForm { void initMenu(const std::string& title, tTJSNI_MenuItem *item); private: - cocos2d::ui::Widget *createMenuItem(tTJSNI_MenuItem *item, const std::string &caption); + cocos2d::ui::Widget *createMenuItem(int idx, tTJSNI_MenuItem *item, const std::string &caption); cocos2d::ui::ListView *_list; cocos2d::ui::Button *_title; diff --git a/src/core/environ/ui/PreferenceConfig.h b/src/core/environ/ui/PreferenceConfig.h index 68eda1cb..e6e18f0a 100644 --- a/src/core/environ/ui/PreferenceConfig.h +++ b/src/core/environ/ui/PreferenceConfig.h @@ -9,9 +9,9 @@ static Size PrefListSize; class tTVPPreferenceInfoConstant : public iTVPPreferenceInfo { public: tTVPPreferenceInfoConstant(const std::string &cap) : iTVPPreferenceInfo(cap, "") {} - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - return CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption)); + return CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption)); } }; @@ -19,15 +19,12 @@ class tTVPPreferenceInfoCheckBox : public tTVPPreferenceInfo { public: tTVPPreferenceInfoCheckBox(const std::string &cap, const std::string &key, bool defval) : tTVPPreferenceInfo(cap, key, defval) {} - virtual iPreferenceItem *createItem() override { - GlobalConfigManager *mgr = GlobalConfigManager::GetInstance(); + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - return CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption), - [mgr, this](tPreferenceItemCheckBox* item) { - item->_getter = std::bind(&GlobalConfigManager::GetValue, mgr, Key, DefaultValue); - item->_setter = [this](bool v){ - GlobalConfigManager::GetInstance()->SetValueInt(Key, v); - }; + return CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption), + [this](tPreferenceItemCheckBox* item) { + item->_getter = std::bind(&PreferenceGetValueBool, Key, DefaultValue); + item->_setter = std::bind(&PreferenceSetValueBool, Key, std::placeholders::_1); }); } }; @@ -37,12 +34,12 @@ class tTVPPreferenceInfoSelectList : public tTVPPreferenceInfo, tPr tTVPPreferenceInfoSelectList(const std::string &cap, const std::string &key, const std::string &defval, const std::initializer_list > &listinfo) : tTVPPreferenceInfo(cap, key, defval), ListInfo(listinfo){} - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - return CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption), + return CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption), [this](tPreferenceItemSelectList* item) { item->initInfo(this); - item->_getter = std::bind(&GlobalConfigManager::GetValue, GlobalConfigManager::GetInstance(), Key, DefaultValue); + item->_getter = std::bind(&PreferenceGetValueString, Key, DefaultValue); item->_setter = [this](std::string v){ onSetValue(v); }; }); } @@ -50,7 +47,7 @@ class tTVPPreferenceInfoSelectList : public tTVPPreferenceInfo, tPr return ListInfo; } virtual void onSetValue(const std::string &v) { - GlobalConfigManager::GetInstance()->SetValue(Key, v); + PreferenceSetValueString(Key, v); } std::vector > ListInfo; }; @@ -99,14 +96,12 @@ class tTVPPreferenceInfoSelectFile : public tTVPPreferenceInfo { tTVPPreferenceInfoSelectFile(const std::string &cap, const std::string &key, const std::string &defval) : tTVPPreferenceInfo(cap, key, defval) {} - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - return CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption), + return CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption), [this](tPreferenceItemFileSelect* item) { - item->_getter = std::bind(&GlobalConfigManager::GetValue, GlobalConfigManager::GetInstance(), Key, DefaultValue); - item->_setter = [this](std::string v) { - GlobalConfigManager::GetInstance()->SetValue(Key, v); - }; + item->_getter = std::bind(&PreferenceGetValueString, Key, DefaultValue); + item->_setter = std::bind(&PreferenceSetValueString, Key, std::placeholders::_1); }); } }; @@ -115,16 +110,16 @@ class tTVPPreferenceInfoRendererSubPref : public iTVPPreferenceInfo { public: tTVPPreferenceInfoRendererSubPref(const std::string &cap) { Caption = cap; } // Key is useless static tPreferenceScreen* GetSubPreferenceInfo() { - std::string renderer = GlobalConfigManager::GetInstance()->GetValue("renderer", "software"); + std::string renderer = PreferenceGetValueString("renderer", "software"); if (renderer == "opengl") return &OpenglOptPreference; else if (renderer == "software") return &SoftRendererOptPreference; return nullptr; } - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - iPreferenceItem *ret = CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption)); + iPreferenceItem *ret = CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption)); ret->addClickEventListener([](Ref*) { TVPMainScene::GetInstance()->pushUIForm(TVPGlobalPreferenceForm::create(GetSubPreferenceInfo())); }); @@ -141,9 +136,9 @@ class tTVPPreferenceInfoSubPref : public iTVPPreferenceInfo { { Caption = title; } - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - iPreferenceItem *ret = CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption)); + iPreferenceItem *ret = CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption)); ret->addClickEventListener([this](Ref*){ TVPMainScene::GetInstance()->pushUIForm(TVPGlobalPreferenceForm::create(&Preference)); }); @@ -156,15 +151,14 @@ class tTVPPreferenceInfoSliderIcon : public tTVPPreferenceInfo { public: tTVPPreferenceInfoSliderIcon(const std::string &cap, const std::string &key, float defval) : tTVPPreferenceInfo(cap, key, defval) {} - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - GlobalConfigManager *mgr = GlobalConfigManager::GetInstance(); tPreferenceItemCursorSlider * ret = new tPreferenceItemCursorSlider(DefaultValue, TVPMainScene::convertCursorScale); ret->autorelease(); - ret->_getter = std::bind(&GlobalConfigManager::GetValue, mgr, Key, DefaultValue); - ret->_setter = std::bind(&GlobalConfigManager::SetValueFloat, mgr, Key, std::placeholders::_1); - ret->initFromInfo(PrefListSize, locmgr->GetText(Caption)); + ret->_getter = std::bind(&PreferenceGetValueFloat, Key, DefaultValue); + ret->_setter = std::bind(&PreferenceSetValueFloat, Key, std::placeholders::_1); + ret->initFromInfo(idx, PrefListSize, locmgr->GetText(Caption)); return ret; } }; @@ -180,15 +174,13 @@ class tTVPPreferenceInfoSliderText : public tTVPPreferenceInfo { return buf; } - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - GlobalConfigManager *mgr = GlobalConfigManager::GetInstance(); - tPreferenceItemTextSlider * ret = new tPreferenceItemTextSlider(DefaultValue, convertPercentScale); ret->autorelease(); - ret->_getter = std::bind(&GlobalConfigManager::GetValue, mgr, Key, DefaultValue); - ret->_setter = std::bind(&GlobalConfigManager::SetValueFloat, mgr, Key, std::placeholders::_1); - ret->initFromInfo(PrefListSize, locmgr->GetText(Caption)); + ret->_getter = std::bind(&PreferenceGetValueFloat, Key, DefaultValue); + ret->_setter = std::bind(&PreferenceSetValueFloat, Key, std::placeholders::_1); + ret->initFromInfo(idx, PrefListSize, locmgr->GetText(Caption)); return ret; } }; @@ -196,9 +188,9 @@ class tTVPPreferenceInfoSliderText : public tTVPPreferenceInfo { class tTVPPreferenceInfoFetchSDCardPermission : public iTVPPreferenceInfo { public: tTVPPreferenceInfoFetchSDCardPermission(const std::string &cap) : iTVPPreferenceInfo(cap, "") {} - virtual iPreferenceItem *createItem() override { + virtual iPreferenceItem *createItem(int idx) override { LocaleConfigManager *locmgr = LocaleConfigManager::GetInstance(); - tPreferenceItemConstant* ret = CreatePreferenceItem(PrefListSize, locmgr->GetText(Caption)); + tPreferenceItemConstant* ret = CreatePreferenceItem(idx, PrefListSize, locmgr->GetText(Caption)); ret->setTouchEnabled(true); ret->addClickEventListener([](Ref*) { TVPFetchSDCardPermission(); @@ -219,6 +211,7 @@ static void initAllConfig() { }), new tTVPPreferenceInfoRendererSubPref("preference_renderer_opt"), new tTVPPreferenceInfoSelectFile("preference_default_font", "default_font", ""), + new tTVPPreferenceInfoCheckBox("preference_force_def_font", "force_default_font", false), #ifdef CC_TARGET_OS_IPHONE new tTVPPreferenceInfoSelectList("preference_mem_limit", "memusage", "high", { #else diff --git a/src/core/environ/ui/PreferenceForm.cpp b/src/core/environ/ui/PreferenceForm.cpp index 0215f21a..d70e0e91 100644 --- a/src/core/environ/ui/PreferenceForm.cpp +++ b/src/core/environ/ui/PreferenceForm.cpp @@ -21,9 +21,10 @@ void TVPPreferenceForm::initPref(const tPreferenceScreen *config) { Config = config; PrefList->removeAllItems(); LocaleConfigManager::GetInstance()->initText(_title, config->Title); - for (auto info : config->Preferences) { + for (int idx = 0; idx < config->Preferences.size(); ++idx) { + auto info = config->Preferences[idx]; if (info) { - PrefList->pushBackCustomItem(info->createItem()); + PrefList->pushBackCustomItem(info->createItem(idx)); } } Widget *nullcell = new Widget(); @@ -51,7 +52,7 @@ void tPreferenceScreen::clear() { Preferences.clear(); } -void iPreferenceItem::initFromInfo(Size size, const std::string& title) { +void iPreferenceItem::initFromInfo(int idx, Size size, const std::string& title) { init(); CSBReader reader; Node * root = reader.Load(getUIFileName()); @@ -62,6 +63,10 @@ void iPreferenceItem::initFromInfo(Size size, const std::string& title) { addChild(root); _title = static_cast(reader.findController("title")); if (!title.empty()) _title->setString(title); + BgOdd = reader.findController("bg_odd", false); + BgEven = reader.findController("bg_even", false); + if (BgOdd) BgOdd->setVisible((idx + 1) & 1); + if (BgEven) BgEven->setVisible(idx & 1); initController(reader); } @@ -257,7 +262,7 @@ TVPCustomPreferenceForm * TVPCustomPreferenceForm::create(const std::string &tid const std::function(int)> &getter, const std::function&)> &setter) { TVPCustomPreferenceForm *ret = new TVPCustomPreferenceForm; - ret->initFromFile("ui/NaviBar.csb", "ui/ListView.csb", "ui/BottomBar.csb"); + ret->initFromFile("ui/NaviBar.csb", "ui/ListView.csb", nullptr); ret->initFromInfo(tid_title, count, getter, setter); ret->autorelease(); return ret; @@ -296,7 +301,7 @@ void TVPCustomPreferenceForm::initFromInfo(const std::string &tid_title, int cou _setter(i, val); }; item->autorelease(); - item->initFromInfo(size, nullptr); + item->initFromInfo(i, size, nullptr); _listview->pushBackCustomItem(item); } Widget *nullcell = new Widget(); diff --git a/src/core/environ/ui/PreferenceForm.h b/src/core/environ/ui/PreferenceForm.h index 59c4ea7d..f4102e51 100644 --- a/src/core/environ/ui/PreferenceForm.h +++ b/src/core/environ/ui/PreferenceForm.h @@ -25,7 +25,7 @@ class iPreferenceItem; class iTVPPreferenceInfo { public: - virtual iPreferenceItem *createItem() = 0; + virtual iPreferenceItem *createItem(int idx) = 0; virtual void InitDefaultConfig() {} virtual tPreferenceScreen* GetSubScreenInfo() { return nullptr; } @@ -73,12 +73,13 @@ class TVPPreferenceForm : public iTVPBaseForm { class iPreferenceItem : public cocos2d::ui::Widget { public: - void initFromInfo(cocos2d::Size size, const std::string& title); // not tid + void initFromInfo(int idx, cocos2d::Size size, const std::string& title); // not tid protected: virtual void initController(const NodeMap &allNodes) = 0; virtual const char *getUIFileName() const = 0; cocos2d::ui::Text *_title; + cocos2d::Node *BgOdd, *BgEven; }; template @@ -90,19 +91,19 @@ class tPreferenceItem : public iPreferenceItem { }; template // factory function -T* CreatePreferenceItem(const cocos2d::Size &size, const std::string &title, const std::function &initer) { +T* CreatePreferenceItem(int idx, const cocos2d::Size &size, const std::string &title, const std::function &initer) { T *ret = new T; ret->autorelease(); initer(ret); - ret->initFromInfo(size, title); + ret->initFromInfo(idx, size, title); return ret; } template -T* CreatePreferenceItem(const cocos2d::Size &size, const std::string &title) { +T* CreatePreferenceItem(int idx, const cocos2d::Size &size, const std::string &title) { T *ret = new T; ret->autorelease(); - ret->initFromInfo(size, title); + ret->initFromInfo(idx, size, title); return ret; } diff --git a/src/core/environ/ui/SeletListForm.cpp b/src/core/environ/ui/SeletListForm.cpp index cfedd271..81040b04 100644 --- a/src/core/environ/ui/SeletListForm.cpp +++ b/src/core/environ/ui/SeletListForm.cpp @@ -61,7 +61,8 @@ void TVPSelectListForm::initWithInfo(const std::vector &info, const Size size = pageView->getViewSize(); bool size_set = false; int selectedIdx = 0; - for (const std::string &str : info) { + for (int idx = 0; idx < info.size(); ++idx) { + const std::string &str = info[idx]; CSBReader reader; Widget *cell = static_cast(reader.Load(FileName_Cell)); if (!size_set) { @@ -70,6 +71,12 @@ void TVPSelectListForm::initWithInfo(const std::vector &info, const size_set = true; } Text *text = static_cast(reader.findController("text")); + + Node *BgOdd = reader.findController("bg_odd", false); + Node *BgEven = reader.findController("bg_even", false); + if (BgOdd) BgOdd->setVisible((idx + 1) & 1); + if (BgEven) BgEven->setVisible(idx & 1); + cell->setContentSize(size); ui::Helper::doLayout(cell); LocaleConfigManager::GetInstance()->initText(text, str); diff --git a/src/core/visual/FontSystem.cpp b/src/core/visual/FontSystem.cpp index 4199a3ff..10660a40 100644 --- a/src/core/visual/FontSystem.cpp +++ b/src/core/visual/FontSystem.cpp @@ -6,6 +6,7 @@ #include "StringUtil.h" #include "MsgIntf.h" #include +#include "ConfigManager/IndividualConfigManager.h" extern void TVPGetAllFontList(std::vector& list); extern const ttstr &TVPGetDefaultFontName(); @@ -63,6 +64,7 @@ ttstr FontSystem::GetBeingFont(ttstr fonts) { vfont = false; } + bool force_default_font = IndividualConfigManager::GetInstance()->GetValue("force_default_font", false); bool prev_empty_name = false; while(fonts!=TJS_W("")) { ttstr fontname; diff --git a/src/core/visual/FreeTypeFontRasterizer.cpp b/src/core/visual/FreeTypeFontRasterizer.cpp index a6b9db2e..de31490b 100644 --- a/src/core/visual/FreeTypeFontRasterizer.cpp +++ b/src/core/visual/FreeTypeFontRasterizer.cpp @@ -18,6 +18,7 @@ void FreeTypeFontRasterizer::ApplyFallbackFace() if (!FaceFallback && Face && Face->GetFontName() != TVPGetDefaultFontName()) { FaceFallback = new tFreeTypeFace(TVPGetDefaultFontName(), 0); } + if (!FaceFallback) return; FaceFallback->SetHeight(CurrentFont.Height < 0 ? -CurrentFont.Height : CurrentFont.Height); if (CurrentFont.Flags & TVP_TF_ITALIC) { FaceFallback->SetOption(TVP_TF_ITALIC); @@ -144,6 +145,12 @@ tjs_int FreeTypeFontRasterizer::GetAscentHeight() { if( Face ) return Face->GetAscent(); return 0; } +static bool isUnicodeSpace(char16_t ch) +{ + return (ch >= 0x0009 && ch <= 0x000D) || ch == 0x0020 || ch == 0x0085 || ch == 0x00A0 || ch == 0x1680 + || (ch >= 0x2000 && ch <= 0x200A) || ch == 0x2028 || ch == 0x2029 || ch == 0x202F + || ch == 0x205F || ch == 0x3000; +} //--------------------------------------------------------------------------- tTVPCharacterData* FreeTypeFontRasterizer::GetBitmap( const tTVPFontAndCharacterData & font, tjs_int aofsx, tjs_int aofsy ) { if( font.Antialiased ) { @@ -159,7 +166,7 @@ tTVPCharacterData* FreeTypeFontRasterizer::GetBitmap( const tTVPFontAndCharacter //Face->ClearOption( TVP_FACE_OPTIONS_FORCE_AUTO_HINTING ); } tTVPCharacterData* data = Face->GetGlyphFromCharcode(font.Character); - if (!data) { + if (!data && !isUnicodeSpace(font.Character)) { ApplyFallbackFace(); if (FaceFallback) { data = FaceFallback->GetGlyphFromCharcode(font.Character); diff --git a/src/core/visual/LayerIntf.cpp b/src/core/visual/LayerIntf.cpp index ffe0efca..c7d0429d 100644 --- a/src/core/visual/LayerIntf.cpp +++ b/src/core/visual/LayerIntf.cpp @@ -299,11 +299,7 @@ void TVPTempBitmapHolderRelease() //--------------------------------------------------------------------------- // global options //--------------------------------------------------------------------------- -#ifdef _DEBUG tTVPGraphicSplitOperationType TVPGraphicSplitOperationType = gsotNone; -#else -tTVPGraphicSplitOperationType TVPGraphicSplitOperationType = gsotSimple; -#endif bool TVPDefaultHoldAlpha = false; //--------------------------------------------------------------------------- @@ -469,7 +465,8 @@ tTJSNI_BaseLayer::Construct(tjs_int numparams, tTJSVariant **param, if(lay) { Manager = lay->GetManager(); - Manager->AddRef(); // lock manager + if (Manager) + Manager->AddRef(); // lock manager } // register to parent layer diff --git a/src/core/visual/ogl/RenderManager_ogl.cpp b/src/core/visual/ogl/RenderManager_ogl.cpp index 6c07502a..4f0ef3f8 100644 --- a/src/core/visual/ogl/RenderManager_ogl.cpp +++ b/src/core/visual/ogl/RenderManager_ogl.cpp @@ -2360,8 +2360,8 @@ class TVPRenderManager_OpenGL : public iTVPRenderManager { uint8_t *pixel = nullptr; int tw, th; size_t pvrsize; GLenum texfmt; - tw = w; - th = h; + tw = (w + 3) & ~3; + th = (h + 3) & ~3; if (isOpaque) { pixel = (uint8_t *)ETCPacker::convert(dib, w, h, pitch, true, pvrsize); texfmt = GL_COMPRESSED_RGB8_ETC2; diff --git a/src/core/visual/ogl/etcpak.cpp b/src/core/visual/ogl/etcpak.cpp index d2ad16e1..03c5ec0c 100644 --- a/src/core/visual/ogl/etcpak.cpp +++ b/src/core/visual/ogl/etcpak.cpp @@ -2177,7 +2177,7 @@ void* convert(const void *_pixel, int w, int h, int pitch, bool etc2, size_t &da line += pitch; } *(uint64*)(dline) = _f_rgb_etc2((uint8*)buf); - sline += 16; + sline += pitch * 4; dline += dpitch; } } @@ -2278,7 +2278,7 @@ void* convertWithAlpha(const void *_pixel, int w, int h, int pitch, size_t &data compressBlockAlphaFast(abuf, dline); *(uint64*)(dline + 8) = _f_rgb_etc2((uint8*)buf); dline += dpitch; - sline += 16; + sline += pitch * 4; } } if (edgeh) {