2019-11-23 20:27:39 +08:00
|
|
|
/****************************************************************************
|
2019-11-24 23:15:56 +08:00
|
|
|
Copyright (c) 2015-2017 Chukong Technologies Inc.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2022-10-01 16:24:52 +08:00
|
|
|
https://axmolengine.github.io/
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "flatbuffers/flatbuffers.h"
|
2020-10-21 10:12:00 +08:00
|
|
|
#include "WidgetReader/WidgetReader.h"
|
|
|
|
#include "CSParseBinary_generated.h"
|
|
|
|
#include "WidgetReader/TabControlReader/TabControlReader.h"
|
|
|
|
#include "FlatBuffersSerialize.h"
|
|
|
|
#include "ActionTimeline/CSLoader.h"
|
2019-11-23 20:27:39 +08:00
|
|
|
#include "ui/UITabControl.h"
|
|
|
|
#include "platform/CCFileUtils.h"
|
|
|
|
#include "2d/CCSpriteFrameCache.h"
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2019-11-23 20:27:39 +08:00
|
|
|
using namespace cocostudio;
|
|
|
|
using namespace flatbuffers;
|
2022-08-08 18:02:17 +08:00
|
|
|
using namespace ax::ui;
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
IMPLEMENT_CLASS_NODE_READER_INFO(TabControlReader)
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabControlReader::TabControlReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
TabControlReader* TabControlReader::_tabReaderInstance = nullptr;
|
|
|
|
TabControlReader* TabControlReader::getInstance()
|
|
|
|
{
|
|
|
|
if (_tabReaderInstance == nullptr)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
_tabReaderInstance = new TabControlReader();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
return _tabReaderInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabControlReader::destroyInstance()
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AX_SAFE_DELETE(_tabReaderInstance);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
flatbuffers::Offset<flatbuffers::Table> TabControlReader::createOptionsWithFlatBuffers(
|
2021-12-25 10:04:45 +08:00
|
|
|
pugi::xml_node objectData,
|
|
|
|
flatbuffers::FlatBufferBuilder* builder)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
auto temp = WidgetReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
|
2019-11-23 20:27:39 +08:00
|
|
|
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
int headerPlace = 0;
|
|
|
|
int headerWidth = 50;
|
|
|
|
int headerHeight = 20;
|
|
|
|
float selectedTabZoom = 0.0f;
|
|
|
|
int selectedIndex = 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
bool ignoretexturesize = true;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
std::vector<Offset<TabItemOption>> tabItems;
|
|
|
|
auto attribute = objectData.first_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view attriname = attribute.name();
|
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (attriname == "HeaderPlace")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
auto placeStr = value.data();
|
2019-11-23 20:27:39 +08:00
|
|
|
if (strcmp(placeStr, "TOP") == 0)
|
|
|
|
headerPlace = 0;
|
|
|
|
else if (strcmp(placeStr, "LEFT") == 0)
|
|
|
|
headerPlace = 1;
|
|
|
|
else if (strcmp(placeStr, "BOTTOM") == 0)
|
|
|
|
headerPlace = 2;
|
|
|
|
else if (strcmp(placeStr, "RIGHT") == 0)
|
|
|
|
headerPlace = 3;
|
|
|
|
}
|
|
|
|
else if (attriname == "HeaderWidth")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
headerWidth = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (attriname == "HeaderHeight")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
headerHeight = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (attriname == "SelectedTabZoom")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
selectedTabZoom = atof(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (attriname == "SelectedTabIndex")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
selectedIndex = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (attriname == "IgnoreHeaderTextureSize")
|
|
|
|
{
|
|
|
|
ignoretexturesize = FLATSTR_TO_BOOL(value);
|
|
|
|
}
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
bool containChildrenElement = false;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto child = objectData.first_child();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (child)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
if ("Children"sv == child.name())
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
containChildrenElement = true;
|
|
|
|
break;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (containChildrenElement)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
child = child.first_child(); // first child
|
2019-11-23 20:27:39 +08:00
|
|
|
bool hasItem = true;
|
|
|
|
while (child && hasItem)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
pugi::xml_attribute childattribute = child.first_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (childattribute)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
auto attriname = childattribute.name();
|
|
|
|
auto value = childattribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (attriname == "ctype")
|
|
|
|
{
|
|
|
|
if (value.compare("TabItemObjectData") == 0)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
auto itemOption =
|
|
|
|
TabItemReader::getInstance()->createTabItemOptionWithFlatBuffers(child, builder);
|
2022-08-09 09:54:53 +08:00
|
|
|
tabItems.emplace_back(itemOption);
|
2019-11-23 20:27:39 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
hasItem = false;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
break;
|
|
|
|
}
|
2019-11-24 23:15:56 +08:00
|
|
|
childattribute = childattribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
auto options =
|
|
|
|
CreateTabControlOption(*builder, nodeOptions, headerPlace, headerWidth, headerHeight, selectedTabZoom,
|
|
|
|
selectedIndex, ignoretexturesize, builder->CreateVector(tabItems));
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
return *(Offset<Table>*)(&options);
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void TabControlReader::setPropsWithFlatBuffers(ax::Node* node, const flatbuffers::Table* nodeOption)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
auto tabControl = static_cast<ax::ui::TabControl*>(node);
|
2021-12-25 10:04:45 +08:00
|
|
|
auto options = (flatbuffers::TabControlOption*)nodeOption;
|
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int headerPlace = options->headerPlace();
|
|
|
|
tabControl->ignoreHeadersTextureSize(options->ignoreHeaderTextureSize() != 0);
|
2022-08-08 18:02:17 +08:00
|
|
|
tabControl->setHeaderDockPlace((ax::ui::TabControl::Dock)headerPlace);
|
2019-11-23 20:27:39 +08:00
|
|
|
tabControl->setHeaderWidth(options->headerWidth());
|
|
|
|
tabControl->setHeaderHeight(options->headerHeight());
|
|
|
|
tabControl->setHeaderSelectedZoom(options->selectedTabZoom());
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int tabItemCount = options->tabItems()->size();
|
|
|
|
for (int i = 0; i < tabItemCount; i++)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
auto item = options->tabItems()->Get(i);
|
|
|
|
auto header = TabHeaderReader::getInstance()->createNodeWithFlatBuffers((Table*)item->header());
|
2019-11-23 20:27:39 +08:00
|
|
|
auto container = CSLoader::getInstance()->nodeWithFlatBuffers(item->container());
|
|
|
|
tabControl->insertTab(i, (TabHeader*)header, (Layout*)container);
|
|
|
|
}
|
|
|
|
tabControl->setSelectTab(options->selectedTabIndex());
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::Node* TabControlReader::createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
auto node = ax::ui::TabControl::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
auto taboptions = (flatbuffers::TabControlOption*)nodeOptions;
|
|
|
|
setPropsWithFlatBuffers(node, nodeOptions);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
auto nodereader = WidgetReader::getInstance();
|
|
|
|
nodereader->setPropsWithFlatBuffers(node, (Table*)taboptions->nodeOptions());
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabControlReader::~TabControlReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabHeaderReader::TabHeaderReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabHeaderReader::~TabHeaderReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
|
|
|
TabHeaderReader* TabHeaderReader::_tabheaderReaderInstance = nullptr;
|
|
|
|
TabHeaderReader* TabHeaderReader::getInstance()
|
|
|
|
{
|
|
|
|
if (_tabheaderReaderInstance == nullptr)
|
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
_tabheaderReaderInstance = new TabHeaderReader();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
return _tabheaderReaderInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabHeaderReader::destroyInstance()
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AX_SAFE_DELETE(_tabheaderReaderInstance);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
flatbuffers::Offset<flatbuffers::Table> TabHeaderReader::createOptionsWithFlatBuffers(
|
2021-12-25 10:04:45 +08:00
|
|
|
pugi::xml_node objectData,
|
|
|
|
flatbuffers::FlatBufferBuilder* builder)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
auto temp = WidgetReader::getInstance()->createOptionsWithFlatBuffers(objectData, builder);
|
2019-11-23 20:27:39 +08:00
|
|
|
auto nodeOptions = *(Offset<WidgetOptions>*)(&temp);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int fontsize = 12;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string text;
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::Color4B textColor(255, 255, 255, 255);
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string fontName;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int backgroundboxResourceType = 0;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backgroundboxPath;
|
|
|
|
std::string backgroundboxPlistFile;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int backGroundBoxSelectedResourceType = 0;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backGroundBoxSelectedPath;
|
|
|
|
std::string backGroundBoxSelectedPlistFile;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int frontCrossResourceType = 0;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string frontCrossPath;
|
|
|
|
std::string frontCrossPlistFile;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int backGroundBoxDisabledResourceType = 0;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backGroundBoxDisabledPath;
|
|
|
|
std::string backGroundBoxDisabledPlistFile;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
int frontCrossDisabledResourceType = 0;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string frontCrossDisabledPath;
|
|
|
|
std::string frontCrossDisabledPlistFile;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string fontResourcePath;
|
|
|
|
std::string fontResourcePlistFile;
|
2019-11-23 20:27:39 +08:00
|
|
|
int fontResourceResourceType = 0;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
auto attribute = objectData.first_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view attriname = attribute.name();
|
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (attriname.compare("FontSize") == 0)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
fontsize = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (attriname.compare("TitleText") == 0)
|
|
|
|
{
|
|
|
|
text = value;
|
|
|
|
}
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
auto child = objectData.first_child();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (child)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view name = child.name();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "TextColor")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "R")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
textColor.r = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (name == "G")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
textColor.g = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else if (name == "B")
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
textColor.b = atoi(value.data());
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "NormalBackFileData")
|
|
|
|
{
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string texture;
|
|
|
|
std::string texturePng;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
backgroundboxPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
backgroundboxResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
backgroundboxPlistFile = value;
|
2021-12-25 10:04:45 +08:00
|
|
|
texture = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (backgroundboxResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2022-08-09 09:54:53 +08:00
|
|
|
fbs->_textures.emplace_back(builder->CreateString(texture));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "PressedBackFileData")
|
|
|
|
{
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string texture;
|
|
|
|
std::string texturePng;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
backGroundBoxSelectedPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
backGroundBoxSelectedResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
backGroundBoxSelectedPlistFile = value;
|
2021-12-25 10:04:45 +08:00
|
|
|
texture = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (backGroundBoxSelectedResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2022-08-09 09:54:53 +08:00
|
|
|
fbs->_textures.emplace_back(builder->CreateString(texture));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "NodeNormalFileData")
|
|
|
|
{
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string texture;
|
|
|
|
std::string texturePng;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
frontCrossPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
frontCrossResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
frontCrossPlistFile = value;
|
2021-12-25 10:04:45 +08:00
|
|
|
texture = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (frontCrossResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2022-08-09 09:54:53 +08:00
|
|
|
fbs->_textures.emplace_back(builder->CreateString(texture));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "DisableBackFileData")
|
|
|
|
{
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string texture;
|
|
|
|
std::string texturePng;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledPlistFile = value;
|
2021-12-25 10:04:45 +08:00
|
|
|
texture = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (backGroundBoxDisabledResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2022-08-09 09:54:53 +08:00
|
|
|
fbs->_textures.emplace_back(builder->CreateString(texture));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "NodeDisableFileData")
|
|
|
|
{
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string texture;
|
|
|
|
std::string texturePng;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
frontCrossDisabledPath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
frontCrossDisabledResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
frontCrossDisabledPlistFile = value;
|
2021-12-25 10:04:45 +08:00
|
|
|
texture = value;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (frontCrossDisabledResourceType == 1)
|
|
|
|
{
|
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
2022-08-09 09:54:53 +08:00
|
|
|
fbs->_textures.emplace_back(builder->CreateString(texture));
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (name == "FontResource")
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = child.first_attribute();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
while (attribute)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
name = attribute.name();
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view value = attribute.value();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (name == "Path")
|
|
|
|
{
|
|
|
|
fontResourcePath = value;
|
|
|
|
}
|
|
|
|
else if (name == "Type")
|
|
|
|
{
|
|
|
|
fontResourceResourceType = getResourceType(value);
|
|
|
|
}
|
|
|
|
else if (name == "Plist")
|
|
|
|
{
|
|
|
|
fontResourcePlistFile = value;
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
attribute = attribute.next_attribute();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
Color f_textColor(255, textColor.r, textColor.g, textColor.b);
|
2021-12-25 10:04:45 +08:00
|
|
|
auto option = CreateTabHeaderOption(
|
|
|
|
*builder, nodeOptions,
|
|
|
|
CreateResourceData(*builder, builder->CreateString(fontResourcePath),
|
|
|
|
builder->CreateString(fontResourcePlistFile), fontResourceResourceType),
|
|
|
|
fontsize, builder->CreateString(text), &f_textColor,
|
|
|
|
CreateResourceData(*builder, builder->CreateString(backgroundboxPath),
|
|
|
|
builder->CreateString(backgroundboxPlistFile), backgroundboxResourceType),
|
|
|
|
CreateResourceData(*builder, builder->CreateString(backGroundBoxSelectedPath),
|
|
|
|
builder->CreateString(backGroundBoxSelectedPlistFile), backGroundBoxSelectedResourceType),
|
|
|
|
CreateResourceData(*builder, builder->CreateString(backGroundBoxDisabledPath),
|
|
|
|
builder->CreateString(backGroundBoxDisabledPlistFile), backGroundBoxDisabledResourceType),
|
|
|
|
CreateResourceData(*builder, builder->CreateString(frontCrossPath), builder->CreateString(frontCrossPlistFile),
|
|
|
|
frontCrossResourceType),
|
|
|
|
CreateResourceData(*builder, builder->CreateString(frontCrossDisabledPath),
|
|
|
|
builder->CreateString(frontCrossDisabledPlistFile), frontCrossDisabledResourceType));
|
|
|
|
|
|
|
|
return *(Offset<Table>*)(&option);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void TabHeaderReader::setPropsWithFlatBuffers(ax::Node* node, const flatbuffers::Table* nodeOption)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
auto header = static_cast<ax::ui::TabHeader*>(node);
|
2019-11-23 20:27:39 +08:00
|
|
|
auto options = (flatbuffers::TabHeaderOption*)nodeOption;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
header->setTitleFontSize(options->fontSize());
|
|
|
|
header->setTitleText(options->titleText()->c_str());
|
|
|
|
auto textColor = options->textColor();
|
|
|
|
Color4B titleColor(textColor->r(), textColor->g(), textColor->b(), textColor->a());
|
|
|
|
header->setTitleColor(titleColor);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
auto resourceData = options->fontRes();
|
2021-12-25 10:04:45 +08:00
|
|
|
bool fileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string errorFilePath;
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string path = resourceData->path()->c_str();
|
|
|
|
if (path != "")
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(path))
|
|
|
|
{
|
|
|
|
fileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
errorFilePath = path;
|
2021-12-25 10:04:45 +08:00
|
|
|
fileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (fileExist)
|
|
|
|
{
|
|
|
|
header->setTitleFontName(path);
|
|
|
|
}
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
bool backGroundFileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backGroundErrorFilePath;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto backGroundDic = options->normalBackFile();
|
|
|
|
int backGroundType = backGroundDic->resourceType();
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string backGroundTexturePath = backGroundDic->path()->c_str();
|
|
|
|
switch (backGroundType)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(backGroundTexturePath))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backGroundErrorFilePath = backGroundTexturePath;
|
|
|
|
backGroundFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::string plist = backGroundDic->plistFile()->c_str();
|
2022-08-03 09:53:53 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundTexturePath);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
backGroundFileExist = true;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
backGroundErrorFilePath = textureFileName;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundErrorFilePath = plist;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundFileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (backGroundFileExist)
|
|
|
|
{
|
|
|
|
header->loadTextureBackGround(backGroundTexturePath, (Widget::TextureResType)backGroundType);
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
// load background selected image
|
2019-11-23 20:27:39 +08:00
|
|
|
bool backGroundSelectedfileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backGroundSelectedErrorFilePath;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto backGroundSelectedDic = options->pressBackFile();
|
|
|
|
int backGroundSelectedType = backGroundSelectedDic->resourceType();
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string backGroundSelectedTexturePath = backGroundSelectedDic->path()->c_str();
|
|
|
|
switch (backGroundSelectedType)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(backGroundSelectedTexturePath))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundSelectedfileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backGroundSelectedErrorFilePath = backGroundSelectedTexturePath;
|
|
|
|
backGroundSelectedfileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::string plist = backGroundSelectedDic->plistFile()->c_str();
|
2022-08-03 09:53:53 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundSelectedTexturePath);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (spriteFrame)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundSelectedfileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
backGroundSelectedErrorFilePath = textureFileName;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundSelectedErrorFilePath = plist;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundSelectedfileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (backGroundSelectedfileExist)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
header->loadTextureBackGroundSelected(backGroundSelectedTexturePath,
|
2022-08-08 18:02:17 +08:00
|
|
|
(ax::ui::Widget::TextureResType)backGroundSelectedType);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
// load frontCross image
|
2019-11-23 20:27:39 +08:00
|
|
|
bool frontCrossFileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string frontCrossErrorFilePath;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto frontCrossDic = options->crossNormalFile();
|
|
|
|
int frontCrossType = frontCrossDic->resourceType();
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string frontCrossFileName = frontCrossDic->path()->c_str();
|
|
|
|
switch (frontCrossType)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(frontCrossFileName))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frontCrossErrorFilePath = frontCrossFileName;
|
|
|
|
frontCrossFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::string plist = frontCrossDic->plistFile()->c_str();
|
2022-08-03 09:53:53 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(frontCrossFileName);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
frontCrossFileExist = true;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
frontCrossErrorFilePath = textureFileName;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossErrorFilePath = plist;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossFileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (frontCrossFileExist)
|
|
|
|
{
|
|
|
|
header->loadTextureFrontCross(frontCrossFileName, (Widget::TextureResType)frontCrossType);
|
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
// load backGroundBoxDisabledData
|
2019-11-23 20:27:39 +08:00
|
|
|
bool backGroundBoxDisabledFileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string backGroundBoxDisabledErrorFilePath;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto backGroundDisabledDic = options->disableBackFile();
|
|
|
|
int backGroundDisabledType = backGroundDisabledDic->resourceType();
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string backGroundDisabledFileName = backGroundDisabledDic->path()->c_str();
|
|
|
|
switch (backGroundDisabledType)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(backGroundDisabledFileName))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundBoxDisabledFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledErrorFilePath = backGroundDisabledFileName;
|
|
|
|
backGroundBoxDisabledFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::string plist = backGroundDisabledDic->plistFile()->c_str();
|
2022-08-03 09:53:53 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(backGroundDisabledFileName);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledFileExist = true;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
backGroundBoxDisabledErrorFilePath = textureFileName;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundBoxDisabledErrorFilePath = plist;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
backGroundBoxDisabledFileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (backGroundBoxDisabledFileExist)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
header->loadTextureBackGroundDisabled(backGroundDisabledFileName,
|
|
|
|
(Widget::TextureResType)backGroundDisabledType);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/// load frontCrossDisabledData
|
2019-11-23 20:27:39 +08:00
|
|
|
bool frontCrossDisabledFileExist = false;
|
2020-08-04 10:55:30 +08:00
|
|
|
std::string frontCrossDisabledErrorFilePath;
|
2021-12-25 10:04:45 +08:00
|
|
|
auto frontCrossDisabledDic = options->crossDisableFile();
|
|
|
|
int frontCrossDisabledType = frontCrossDisabledDic->resourceType();
|
2019-11-23 20:27:39 +08:00
|
|
|
std::string frontCrossDisabledFileName = frontCrossDisabledDic->path()->c_str();
|
|
|
|
switch (frontCrossDisabledType)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
if (FileUtils::getInstance()->isFileExist(frontCrossDisabledFileName))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossDisabledFileExist = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frontCrossDisabledErrorFilePath = frontCrossDisabledFileName;
|
|
|
|
frontCrossDisabledFileExist = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
std::string plist = frontCrossDisabledDic->plistFile()->c_str();
|
2022-08-03 09:53:53 +08:00
|
|
|
SpriteFrame* spriteFrame = SpriteFrameCache::getInstance()->findFrame(frontCrossDisabledFileName);
|
2021-12-25 10:04:45 +08:00
|
|
|
if (spriteFrame)
|
|
|
|
{
|
|
|
|
frontCrossDisabledFileExist = true;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
else
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (FileUtils::getInstance()->isFileExist(plist))
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
ValueMap value = FileUtils::getInstance()->getValueMapFromFile(plist);
|
|
|
|
ValueMap metadata = value["metadata"].asValueMap();
|
|
|
|
std::string textureFileName = metadata["textureFileName"].asString();
|
|
|
|
if (!FileUtils::getInstance()->isFileExist(textureFileName))
|
|
|
|
{
|
|
|
|
frontCrossDisabledErrorFilePath = textureFileName;
|
|
|
|
}
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossDisabledErrorFilePath = plist;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
frontCrossDisabledFileExist = false;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
if (frontCrossDisabledFileExist)
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
header->loadTextureFrontCrossDisabled(frontCrossDisabledFileName,
|
|
|
|
(Widget::TextureResType)frontCrossDisabledType);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::Node* TabHeaderReader::createNodeWithFlatBuffers(const flatbuffers::Table* nodeOptions)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2022-08-08 18:02:17 +08:00
|
|
|
auto node = ax::ui::TabHeader::create();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
auto taboptions = (flatbuffers::TabHeaderOption*)nodeOptions;
|
|
|
|
setPropsWithFlatBuffers(node, nodeOptions);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
auto nodereader = WidgetReader::getInstance();
|
|
|
|
nodereader->setPropsWithFlatBuffers(node, (Table*)taboptions->nodeOptions());
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
2021-12-31 15:49:45 +08:00
|
|
|
int TabHeaderReader::getResourceType(std::string_view key)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
if (key == "Normal" || key == "Default")
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
return 0;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
FlatBuffersSerialize* fbs = FlatBuffersSerialize::getInstance();
|
|
|
|
if (fbs->_isSimulator)
|
|
|
|
{
|
|
|
|
if (key == "MarkedSubImage")
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabItemReader::TabItemReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
TabItemReader::~TabItemReader() {}
|
2019-11-23 20:27:39 +08:00
|
|
|
TabItemReader* TabItemReader::_tabItemReaderInstance = nullptr;
|
|
|
|
TabItemReader* TabItemReader::getInstance()
|
|
|
|
{
|
|
|
|
if (_tabItemReaderInstance == nullptr)
|
|
|
|
{
|
2021-12-08 00:11:53 +08:00
|
|
|
_tabItemReaderInstance = new TabItemReader();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
return _tabItemReaderInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
void TabItemReader::destroyInstance()
|
|
|
|
{
|
2022-07-16 10:43:05 +08:00
|
|
|
AX_SAFE_DELETE(_tabItemReaderInstance);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
flatbuffers::Offset<flatbuffers::TabItemOption> TabItemReader::createTabItemOptionWithFlatBuffers(
|
2021-12-25 10:04:45 +08:00
|
|
|
pugi::xml_node objectData,
|
|
|
|
flatbuffers::FlatBufferBuilder* builder)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
flatbuffers::Offset<Table> header;
|
|
|
|
flatbuffers::Offset<NodeTree> container;
|
2019-11-24 23:15:56 +08:00
|
|
|
pugi::xml_node containerData;
|
|
|
|
pugi::xml_node containerChildrenData;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-24 23:15:56 +08:00
|
|
|
auto child = objectData.first_child();
|
2019-11-23 20:27:39 +08:00
|
|
|
while (child)
|
|
|
|
{
|
2021-12-31 15:49:45 +08:00
|
|
|
std::string_view attriname = child.name();
|
|
|
|
if (attriname.compare("Children"sv) == 0)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
containerChildrenData = child;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-31 15:49:45 +08:00
|
|
|
if (attriname.compare("Header"sv) == 0)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
header = TabHeaderReader::getInstance()->createOptionsWithFlatBuffers(child, builder);
|
|
|
|
}
|
2021-12-31 15:49:45 +08:00
|
|
|
else if (attriname.compare("Container"sv) == 0)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
containerData = child;
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2019-11-24 23:15:56 +08:00
|
|
|
child = child.next_sibling();
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
if (containerChildrenData != nullptr)
|
|
|
|
{
|
2019-11-24 23:15:56 +08:00
|
|
|
containerData.append_copy(containerChildrenData);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
container = FlatBuffersSerialize::getInstance()->createNodeTree(containerData, "PanelObjectData");
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
auto options = CreateTabItemOption(*builder, *(Offset<flatbuffers::TabHeaderOption>*)(&header), container);
|
|
|
|
return *(&options);
|
2019-11-23 20:27:39 +08:00
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void TabItemReader::setPropsWithFlatBuffers(ax::Node* /*node*/, const flatbuffers::Table* /*nodeOption*/)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
ax::Node* TabItemReader::createNodeWithFlatBuffers(const flatbuffers::Table* /*nodeOptions*/)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
|
|
|
// do nothing
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
flatbuffers::Offset<flatbuffers::Table> TabItemReader::createOptionsWithFlatBuffers(
|
2021-12-25 10:04:45 +08:00
|
|
|
pugi::xml_node /*objectData*/,
|
|
|
|
flatbuffers::FlatBufferBuilder* /*builder*/)
|
2019-11-23 20:27:39 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-11-23 20:27:39 +08:00
|
|
|
// nothing
|
|
|
|
return flatbuffers::Offset<flatbuffers::Table>();
|
|
|
|
}
|