mirror of https://github.com/axmolengine/axmol.git
Modify some extensions for string_view
This commit is contained in:
parent
5ba5049146
commit
b63f815488
|
@ -80,8 +80,7 @@ FontAtlas* FontAtlasCache::getFontAtlasTTF(const _ttfConfig* config)
|
|||
auto tempAtlas = font->newFontAtlas();
|
||||
if (tempAtlas)
|
||||
{
|
||||
_atlasMap[atlasName] = tempAtlas;
|
||||
return _atlasMap[atlasName];
|
||||
return _atlasMap.emplace(atlasName, tempAtlas).first->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -291,6 +291,13 @@ public:
|
|||
return _data.erase(position);
|
||||
}
|
||||
|
||||
iterator erase(iterator position)
|
||||
{
|
||||
CCASSERT(position != _data.cend(), "Invalid iterator!");
|
||||
position->second->release();
|
||||
return _data.erase(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes an element with an iterator from the Map<K, V> container.
|
||||
*
|
||||
|
|
|
@ -22,7 +22,7 @@ struct string_hash
|
|||
|
||||
size_t operator()(const char* str) const { return hash_type{}(str); }
|
||||
size_t operator()(std::string_view str) const { return hash_type{}(str); }
|
||||
size_t operator()(std::string const& str) const { return hash_type{}(str); }
|
||||
size_t operator()(const std::string& str) const { return hash_type{}(str); }
|
||||
};
|
||||
|
||||
struct equal_to
|
||||
|
@ -51,7 +51,7 @@ inline auto set_item(_Cont& cont, std::string_view key, _Valty&& _Val)
|
|||
{
|
||||
typename _Cont::iterator it = cont.find(key);
|
||||
if (it != cont.end())
|
||||
it.value() = std::move(_Val);
|
||||
it->second = std::move(_Val);
|
||||
else
|
||||
it = cont.emplace(std::string{key}, std::forward<_Valty>(_Val)).first;
|
||||
return it;
|
||||
|
|
|
@ -638,7 +638,7 @@ std::string FileUtils::getPathForFilename(std::string_view filename,
|
|||
std::string_view searchPath) const
|
||||
{
|
||||
auto file = filename;
|
||||
std::string file_path = "";
|
||||
std::string_view file_path = hlookup::empty_sv;
|
||||
size_t pos = filename.find_last_of('/');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
|
|
|
@ -84,17 +84,9 @@ static void _checkWorkingPath()
|
|||
WCHAR utf16Path[CC_MAX_PATH] = {0};
|
||||
int nNum = GetCurrentDirectoryW(CC_MAX_PATH - 2, utf16Path);
|
||||
|
||||
s_workingPath.reserve(nNum + 1);
|
||||
s_workingPath.assign(utf16Path, nNum);
|
||||
|
||||
//char utf8WorkingDir[CC_MAX_PATH] = {0};
|
||||
//nNum =
|
||||
// WideCharToMultiByte(CP_UTF8, 0, utf16Path, nNum, utf8WorkingDir, sizeof(utf8WorkingDir), nullptr, nullptr);
|
||||
//if (nNum < (CC_MAX_PATH - 2))
|
||||
//{
|
||||
// utf8WorkingDir[nNum] = '\\';
|
||||
// utf8WorkingDir[nNum + 1] = '\0';
|
||||
// s_workingPath = convertPathFormatToUnixStyle(utf8WorkingDir);
|
||||
//}
|
||||
s_workingPath.push_back('\\');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -581,7 +581,7 @@ std::string_view Animation::getLastAnimationName() const
|
|||
return DEFAULT_NAME;
|
||||
}
|
||||
|
||||
void Animation::setAnimations(const std::map<std::string, AnimationData*>& value)
|
||||
void Animation::setAnimations(const hlookup::string_map<AnimationData*>& value)
|
||||
{
|
||||
if (_animations == value)
|
||||
{
|
||||
|
|
|
@ -64,7 +64,7 @@ private:
|
|||
float _inheritTimeScale;
|
||||
std::vector<std::string> _animationNames;
|
||||
std::vector<AnimationState*> _animationStates;
|
||||
std::map<std::string, AnimationData*> _animations;
|
||||
hlookup::string_map<AnimationData*> _animations;
|
||||
Armature* _armature;
|
||||
AnimationConfig* _animationConfig;
|
||||
AnimationState* _lastAnimationState;
|
||||
|
@ -441,8 +441,8 @@ public:
|
|||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
inline const std::map<std::string, AnimationData*>& getAnimations() const { return _animations; }
|
||||
void setAnimations(const std::map<std::string, AnimationData*>& value);
|
||||
inline const hlookup::string_map<AnimationData*>& getAnimations() const { return _animations; }
|
||||
void setAnimations(const hlookup::string_map<AnimationData*>& value);
|
||||
/**
|
||||
* - An AnimationConfig instance that can be used quickly.
|
||||
* @see dragonBones.AnimationConfig
|
||||
|
|
|
@ -83,7 +83,7 @@ void AnimationState::_onClear()
|
|||
void AnimationState::_updateTimelines()
|
||||
{
|
||||
{ // Update constraint timelines.
|
||||
std::map<std::string, std::vector<ConstraintTimelineState*>> constraintTimelines;
|
||||
hlookup::string_map<std::vector<ConstraintTimelineState*>> constraintTimelines;
|
||||
for (const auto timeline : _constraintTimelines) // Create constraint timelines map.
|
||||
{
|
||||
constraintTimelines[timeline->constraint->getName()].push_back(timeline);
|
||||
|
@ -137,7 +137,7 @@ void AnimationState::_updateTimelines()
|
|||
void AnimationState::_updateBoneAndSlotTimelines()
|
||||
{
|
||||
{ // Update bone timelines.
|
||||
std::map<std::string, std::vector<BoneTimelineState*>> boneTimelines;
|
||||
hlookup::string_map<std::vector<BoneTimelineState*>> boneTimelines;
|
||||
for (const auto timeline : _boneTimelines) // Create bone timelines map.
|
||||
{
|
||||
boneTimelines[timeline->bone->getName()].push_back(timeline);
|
||||
|
@ -238,7 +238,7 @@ void AnimationState::_updateBoneAndSlotTimelines()
|
|||
}
|
||||
|
||||
{ // Update slot timelines.
|
||||
std::map<std::string, std::vector<SlotTimelineState*>> slotTimelines;
|
||||
hlookup::string_map<std::vector<SlotTimelineState*>> slotTimelines;
|
||||
std::vector<unsigned> ffdFlags;
|
||||
for (const auto timeline : _slotTimelines) // Create slot timelines map.
|
||||
{
|
||||
|
@ -760,7 +760,7 @@ void AnimationState::addBoneMask(std::string_view boneName, bool recursive)
|
|||
|
||||
if (std::find(_boneMask.cbegin(), _boneMask.cend(), boneName) == _boneMask.cend())
|
||||
{
|
||||
_boneMask.push_back(boneName);
|
||||
_boneMask.push_back(std::string{boneName});
|
||||
}
|
||||
|
||||
if (recursive) // Add recursive mixing.
|
||||
|
@ -770,7 +770,7 @@ void AnimationState::addBoneMask(std::string_view boneName, bool recursive)
|
|||
if (std::find(_boneMask.cbegin(), _boneMask.cend(), bone->getName()) == _boneMask.cend() &&
|
||||
currentBone->contains(bone))
|
||||
{
|
||||
_boneMask.push_back(bone->getName());
|
||||
_boneMask.push_back(std::string{bone->getName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -816,7 +816,7 @@ void AnimationState::removeBoneMask(std::string_view boneName, bool recursive)
|
|||
|
||||
if (!currentBone->contains(bone))
|
||||
{
|
||||
_boneMask.push_back(bone->getName());
|
||||
_boneMask.push_back(std::string{bone->getName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -251,7 +251,7 @@ private:
|
|||
std::vector<SlotTimelineState*> _slotTimelines;
|
||||
std::vector<ConstraintTimelineState*> _constraintTimelines;
|
||||
std::vector<std::pair<TimelineState*, BaseTimelineType>> _poseTimelines;
|
||||
std::map<std::string, BonePose*> _bonePoses;
|
||||
hlookup::string_map<BonePose*> _bonePoses;
|
||||
Armature* _armature;
|
||||
ZOrderTimelineState* _zOrderTimeline;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
|
@ -33,6 +33,7 @@
|
|||
#include <functional>
|
||||
#include <sstream>
|
||||
#include <assert.h>
|
||||
#include "base/hlookup.h"
|
||||
// dragonBones assert
|
||||
#define DRAGONBONES_ASSERT(cond, msg) \
|
||||
do \
|
||||
|
@ -359,15 +360,15 @@ inline int indexOf(const std::vector<T>& vector, const T& value)
|
|||
return -1;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* mapFind(const std::map<std::string, T*>& map, std::string_view key)
|
||||
template <class Cont>
|
||||
inline auto mapFind(Cont& map, std::string_view key)
|
||||
{
|
||||
auto iterator = map.find(key);
|
||||
return (iterator != map.end()) ? iterator->second : nullptr;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
inline T* mapFindB(std::map<std::string, T>& map, std::string_view key)
|
||||
template <class Cont>
|
||||
inline auto mapFindB(Cont& map, std::string_view key)
|
||||
{
|
||||
auto iterator = map.find(key);
|
||||
return (iterator != map.end()) ? &iterator->second : nullptr;
|
||||
|
|
|
@ -47,7 +47,7 @@ bool BaseFactory::_fillBuildArmaturePackage(BuildArmaturePackage& dataPackage,
|
|||
std::string_view skinName,
|
||||
std::string_view textureAtlasName) const
|
||||
{
|
||||
std::string mapName = dragonBonesName;
|
||||
auto mapName = dragonBonesName;
|
||||
DragonBonesData* dragonBonesData = nullptr;
|
||||
ArmatureData* armatureData = nullptr;
|
||||
|
||||
|
@ -141,7 +141,7 @@ void BaseFactory::_buildSlots(const BuildArmaturePackage& dataPackage, Armature*
|
|||
return;
|
||||
}
|
||||
|
||||
std::map<std::string, std::vector<DisplayData*>*> skinSlots;
|
||||
hlookup::string_map<std::vector<DisplayData*>*> skinSlots;
|
||||
for (auto& pair : defaultSkin->displays)
|
||||
{
|
||||
auto& displays = pair.second;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
|
@ -68,8 +68,8 @@ public:
|
|||
bool autoSearch;
|
||||
|
||||
protected:
|
||||
std::map<std::string, DragonBonesData*> _dragonBonesDataMap;
|
||||
std::map<std::string, std::vector<TextureAtlasData*>> _textureAtlasDataMap;
|
||||
hlookup::string_map<DragonBonesData*> _dragonBonesDataMap;
|
||||
hlookup::string_map<std::vector<TextureAtlasData*>> _textureAtlasDataMap;
|
||||
DragonBones* _dragonBones;
|
||||
DataParser* _dataParser;
|
||||
|
||||
|
@ -550,14 +550,14 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
inline const std::map<std::string, std::vector<TextureAtlasData*>>& getAllTextureAtlasData() const
|
||||
inline const hlookup::string_map<std::vector<TextureAtlasData*>>& getAllTextureAtlasData() const
|
||||
{
|
||||
return _textureAtlasDataMap;
|
||||
}
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
inline const std::map<std::string, DragonBonesData*>& getAllDragonBonesData() const { return _dragonBonesDataMap; }
|
||||
inline const hlookup::string_map<DragonBonesData*>& getAllDragonBonesData() const { return _dragonBonesDataMap; }
|
||||
/**
|
||||
* - An Worldclock instance updated by engine.
|
||||
* @version DragonBones 5.7
|
||||
|
|
|
@ -78,7 +78,7 @@ void AnimationConfig::addBoneMask(Armature* armature, std::string_view boneName,
|
|||
|
||||
if (std::find(boneMask.cbegin(), boneMask.cend(), boneName) == boneMask.cend()) // Add mixing
|
||||
{
|
||||
boneMask.push_back(boneName);
|
||||
boneMask.push_back(std::string{boneName});
|
||||
}
|
||||
|
||||
if (recursive) // Add recursive mixing.
|
||||
|
@ -88,7 +88,7 @@ void AnimationConfig::addBoneMask(Armature* armature, std::string_view boneName,
|
|||
if (std::find(boneMask.cbegin(), boneMask.cend(), bone->getName()) == boneMask.cend() &&
|
||||
currentBone->contains(bone))
|
||||
{
|
||||
boneMask.push_back(bone->getName());
|
||||
boneMask.push_back(std::string{bone->getName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void AnimationConfig::removeBoneMask(Armature* armature, std::string_view boneNa
|
|||
|
||||
if (!currentBone->contains(bone))
|
||||
{
|
||||
boneMask.push_back(bone->getName());
|
||||
boneMask.push_back(std::string{bone->getName()});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,23 +126,23 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, std::vector<TimelineData*>> boneTimelines;
|
||||
hlookup::string_map<std::vector<TimelineData*>> boneTimelines;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, std::vector<TimelineData*>> slotTimelines;
|
||||
hlookup::string_map<std::vector<TimelineData*>> slotTimelines;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, std::vector<TimelineData*>> constraintTimelines;
|
||||
hlookup::string_map<std::vector<TimelineData*>> constraintTimelines;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, std::vector<int>> boneCachedFrameIndices;
|
||||
hlookup::string_map<std::vector<int>> boneCachedFrameIndices;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, std::vector<int>> slotCachedFrameIndices;
|
||||
hlookup::string_map<std::vector<int>> slotCachedFrameIndices;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
|
|
@ -113,23 +113,23 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, BoneData*> bones;
|
||||
hlookup::string_map<BoneData*> bones;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, SlotData*> slots;
|
||||
hlookup::string_map<SlotData*> slots;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, ConstraintData*> constraints;
|
||||
hlookup::string_map<ConstraintData*> constraints;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, SkinData*> skins;
|
||||
hlookup::string_map<SkinData*> skins;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, AnimationData*> animations;
|
||||
hlookup::string_map<AnimationData*> animations;
|
||||
/**
|
||||
* - The default skin data.
|
||||
* @version DragonBones 4.5
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
* @version DragonBones 3.0
|
||||
* @language zh_CN
|
||||
*/
|
||||
inline BoneData* getBone(std::string_view boneName) const { return mapFind<BoneData>(bones, boneName); }
|
||||
inline BoneData* getBone(std::string_view boneName) const { return mapFind(bones, boneName); }
|
||||
/**
|
||||
* - Get a specific slot data.
|
||||
* @param slotName - The slot name.
|
||||
|
@ -236,13 +236,13 @@ public:
|
|||
* @version DragonBones 3.0
|
||||
* @language zh_CN
|
||||
*/
|
||||
inline SlotData* getSlot(std::string_view slotName) const { return mapFind<SlotData>(slots, slotName); }
|
||||
inline SlotData* getSlot(std::string_view slotName) const { return mapFind(slots, slotName); }
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
inline ConstraintData* getConstraint(std::string_view constraintName) const
|
||||
{
|
||||
return mapFind<ConstraintData>(constraints, constraintName);
|
||||
return mapFind(constraints, constraintName);
|
||||
}
|
||||
/**
|
||||
* - Get a specific skin data.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, ArmatureData*> armatures;
|
||||
hlookup::string_map<ArmatureData*> armatures;
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
@ -160,7 +160,7 @@ public:
|
|||
*/
|
||||
inline ArmatureData* getArmature(std::string_view armatureName) const
|
||||
{
|
||||
return mapFind<ArmatureData>(armatures, armatureName);
|
||||
return mapFind(armatures, armatureName);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
std::vector<DisplayData*>* getDisplays(std::string_view slotName) { return mapFindB(displays, slotName); }
|
||||
|
||||
public: // For WebAssembly. TODO parent
|
||||
const std::map<std::string, std::vector<DisplayData*>>& getSlotDisplays() const { return displays; }
|
||||
const hlookup::string_map<std::vector<DisplayData*>>& getSlotDisplays() const { return displays; }
|
||||
};
|
||||
|
||||
DRAGONBONES_NAMESPACE_END
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
std::map<std::string, TextureData*> textures;
|
||||
hlookup::string_map<TextureData*> textures;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
|
@ -100,13 +100,16 @@ public:
|
|||
/**
|
||||
* @private
|
||||
*/
|
||||
inline TextureData* getTexture(std::string_view textureName) const { return mapFind(textures, textureName); }
|
||||
inline TextureData* getTexture(std::string_view textureName) const
|
||||
{
|
||||
return mapFind(textures, textureName);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void _onClear() override;
|
||||
|
||||
public: // For WebAssembly.
|
||||
const std::map<std::string, TextureData*>& getTextures() const { return textures; }
|
||||
const hlookup::string_map<TextureData*>& getTextures() const { return textures; }
|
||||
};
|
||||
/**
|
||||
* @internal
|
||||
|
|
|
@ -127,7 +127,7 @@ const char* DataParser::DEFAULT_NAME = "default";
|
|||
|
||||
TextureFormat DataParser::_getTextureFormat(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "rgba8888")
|
||||
|
@ -160,7 +160,7 @@ TextureFormat DataParser::_getTextureFormat(std::string_view value)
|
|||
|
||||
ArmatureType DataParser::_getArmatureType(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "armature")
|
||||
|
@ -181,7 +181,7 @@ ArmatureType DataParser::_getArmatureType(std::string_view value)
|
|||
|
||||
DisplayType DataParser::_getDisplayType(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "image")
|
||||
|
@ -206,7 +206,7 @@ DisplayType DataParser::_getDisplayType(std::string_view value)
|
|||
|
||||
BoundingBoxType DataParser::_getBoundingBoxType(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "rectangle")
|
||||
|
@ -227,7 +227,7 @@ BoundingBoxType DataParser::_getBoundingBoxType(std::string_view value)
|
|||
|
||||
ActionType DataParser::_getActionType(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "play")
|
||||
|
@ -248,7 +248,7 @@ ActionType DataParser::_getActionType(std::string_view value)
|
|||
|
||||
BlendMode DataParser::_getBlendMode(std::string_view value)
|
||||
{
|
||||
auto lower = value;
|
||||
std::string lower{value};
|
||||
std::transform(lower.begin(), lower.end(), lower.begin(), ::tolower);
|
||||
|
||||
if (lower == "normal")
|
||||
|
|
|
@ -93,7 +93,7 @@ protected:
|
|||
return dragonBones::to_string(rawData[key].GetDouble());
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
return std::string{defaultValue};
|
||||
}
|
||||
|
||||
inline static int _getParameter(const rapidjson::Value& rawData, std::size_t index, int defaultValue)
|
||||
|
@ -125,7 +125,7 @@ protected:
|
|||
return rawData[(int)index].GetString();
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
return std::string{defaultValue};
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -160,10 +160,10 @@ private:
|
|||
std::vector<const rapidjson::Value*> _cacheRawMeshes;
|
||||
std::vector<MeshDisplayData*> _cacheMeshes;
|
||||
std::vector<ActionFrame> _actionFrames;
|
||||
std::map<std::string, const rapidjson::Value*> _weightSlotPose;
|
||||
std::map<std::string, const rapidjson::Value*> _weightBonePoses;
|
||||
std::map<std::string, std::vector<BoneData*>> _cacheBones;
|
||||
std::map<std::string, std::vector<ActionData*>> _slotChildActions;
|
||||
hlookup::string_map<const rapidjson::Value*> _weightSlotPose;
|
||||
hlookup::string_map<const rapidjson::Value*> _weightBonePoses;
|
||||
hlookup::string_map<std::vector<BoneData*>> _cacheBones;
|
||||
hlookup::string_map<std::vector<ActionData*>> _slotChildActions;
|
||||
|
||||
public:
|
||||
JSONDataParser()
|
||||
|
|
|
@ -224,8 +224,8 @@ protected:
|
|||
|
||||
std::function<void(Frame*)> _frameEventListener;
|
||||
std::function<void()> _lastFrameListener;
|
||||
std::map<int, std::map<std::string, std::function<void()>>> _frameEndCallFuncs;
|
||||
std::map<std::string, AnimationInfo> _animationInfos;
|
||||
std::map<int, hlookup::string_map<std::function<void()>>> _frameEndCallFuncs;
|
||||
hlookup::string_map<AnimationInfo> _animationInfos;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
|
|
@ -136,9 +136,9 @@ void ActionTimelineCache::removeAction(std::string_view fileName)
|
|||
|
||||
ActionTimeline* ActionTimelineCache::createAction(std::string_view filename)
|
||||
{
|
||||
std::string path = filename;
|
||||
auto path = filename;
|
||||
size_t pos = path.find_last_of('.');
|
||||
std::string suffix = path.substr(pos + 1, path.length());
|
||||
auto suffix = path.substr(pos + 1, path.length());
|
||||
|
||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||
|
||||
|
@ -183,8 +183,7 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFile(std::string_vie
|
|||
return loadAnimationActionWithContent(fileName, contentStr);
|
||||
}
|
||||
|
||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(std::string_view fileName,
|
||||
std::string_view content)
|
||||
ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(std::string_view fileName, std::string_view content)
|
||||
{
|
||||
// if already exists an action with filename, then return this action
|
||||
ActionTimeline* action = _animationActions.at(fileName);
|
||||
|
@ -192,7 +191,7 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithContent(std::string_
|
|||
return action;
|
||||
|
||||
rapidjson::Document doc;
|
||||
doc.Parse<0>(content.c_str());
|
||||
doc.Parse<0>(content.data(), content.length());
|
||||
if (doc.HasParseError())
|
||||
{
|
||||
CCLOG("GetParseError %d\n", doc.GetParseError());
|
||||
|
@ -442,7 +441,7 @@ ActionTimeline* ActionTimelineCache::loadAnimationActionWithFlatBuffersFile(std:
|
|||
if (action)
|
||||
return action;
|
||||
|
||||
std::string path = fileName;
|
||||
auto path = fileName;
|
||||
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
|
||||
|
@ -462,7 +461,7 @@ ActionTimeline* ActionTimelineCache::loadAnimationWithDataBuffer(const cocos2d::
|
|||
if (action)
|
||||
return action;
|
||||
|
||||
std::string path = fileName;
|
||||
auto path = fileName;
|
||||
|
||||
std::string fullPath = FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||
|
||||
|
|
|
@ -128,8 +128,8 @@ protected:
|
|||
typedef std::function<Frame*(const rapidjson::Value& json)> FrameCreateFunc;
|
||||
typedef std::pair<std::string, FrameCreateFunc> Pair;
|
||||
|
||||
std::unordered_map<std::string, FrameCreateFunc> _funcs;
|
||||
cocos2d::Map<std::string, ActionTimeline*> _animationActions;
|
||||
hlookup::string_map<FrameCreateFunc> _funcs;
|
||||
cocos2d::StringMap<ActionTimeline*> _animationActions;
|
||||
};
|
||||
|
||||
NS_TIMELINE_END
|
||||
|
|
|
@ -75,20 +75,20 @@ bool BoneNode::init()
|
|||
setProgramState(new cocos2d::backend::ProgramState(program), false);
|
||||
pipelineDescriptor.programState = _programState;
|
||||
|
||||
_mvpLocation = _programState->getUniformLocation("u_MVPMatrix");
|
||||
_mvpLocation = _programState->getUniformLocation("u_MVPMatrix"sv);
|
||||
|
||||
auto vertexLayout = _programState->getVertexLayout();
|
||||
const auto& attributeInfo = _programState->getProgram()->getActiveAttributes();
|
||||
auto iter = attributeInfo.find("a_position");
|
||||
auto iter = attributeInfo.find("a_position"sv);
|
||||
if (iter != attributeInfo.end())
|
||||
{
|
||||
vertexLayout->setAttribute("a_position", iter->second.location, cocos2d::backend::VertexFormat::FLOAT3, 0,
|
||||
vertexLayout->setAttribute("a_position"sv, iter->second.location, cocos2d::backend::VertexFormat::FLOAT3, 0,
|
||||
false);
|
||||
}
|
||||
iter = attributeInfo.find("a_color");
|
||||
iter = attributeInfo.find("a_color"sv);
|
||||
if (iter != attributeInfo.end())
|
||||
{
|
||||
vertexLayout->setAttribute("a_color", iter->second.location, cocos2d::backend::VertexFormat::FLOAT4,
|
||||
vertexLayout->setAttribute("a_color"sv, iter->second.location, cocos2d::backend::VertexFormat::FLOAT4,
|
||||
3 * sizeof(float), false);
|
||||
}
|
||||
vertexLayout->setLayout(7 * sizeof(float));
|
||||
|
@ -152,7 +152,7 @@ void BoneNode::removeFromBoneList(BoneNode* bone)
|
|||
{
|
||||
auto subBones = bone->getAllSubBones();
|
||||
subBones.pushBack(bone);
|
||||
for (auto& subBone : subBones)
|
||||
for (auto subBone : subBones)
|
||||
{
|
||||
if (subBone->_rootSkeleton == nullptr)
|
||||
continue;
|
||||
|
@ -186,7 +186,7 @@ void BoneNode::addToBoneList(BoneNode* bone)
|
|||
{
|
||||
auto subBones = bone->getAllSubBones();
|
||||
subBones.pushBack(bone);
|
||||
for (auto& subBone : subBones)
|
||||
for (auto subBone : subBones)
|
||||
{
|
||||
subBone->_rootSkeleton = _rootSkeleton;
|
||||
auto bonename = subBone->getName();
|
||||
|
@ -198,8 +198,8 @@ void BoneNode::addToBoneList(BoneNode* bone)
|
|||
_rootSkeleton->_subBonesOrderDirty = true;
|
||||
}
|
||||
else
|
||||
CCLOG("already has a bone named %s in skeleton %s", bonename.c_str(),
|
||||
_rootSkeleton->getName().c_str());
|
||||
CCLOG("already has a bone named %s in skeleton %s", bonename.data(),
|
||||
_rootSkeleton->getName().data());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -298,7 +298,7 @@ void SkeletonNode::batchDrawAllSubBones()
|
|||
#endif // CC_STUDIO_ENABLED_VIEW
|
||||
}
|
||||
|
||||
void SkeletonNode::changeSkins(const std::map<std::string, std::string>& boneSkinNameMap)
|
||||
void SkeletonNode::changeSkins(const hlookup::string_map<std::string>& boneSkinNameMap)
|
||||
{
|
||||
for (auto& boneskin : boneSkinNameMap)
|
||||
{
|
||||
|
@ -327,14 +327,14 @@ BoneNode* SkeletonNode::getBoneNode(std::string_view boneName)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
const cocos2d::Map<std::string, BoneNode*>& SkeletonNode::getAllSubBonesMap() const
|
||||
const cocos2d::StringMap<BoneNode*>& SkeletonNode::getAllSubBonesMap() const
|
||||
{
|
||||
return _subBonesMap;
|
||||
}
|
||||
|
||||
void SkeletonNode::addSkinGroup(std::string groupName, std::map<std::string, std::string> boneSkinNameMap)
|
||||
void SkeletonNode::addSkinGroup(std::string groupName, hlookup::string_map<std::string> boneSkinNameMap)
|
||||
{
|
||||
_skinGroupMap.emplace(groupName, boneSkinNameMap);
|
||||
_skinGroupMap.emplace(groupName, std::move(boneSkinNameMap));
|
||||
}
|
||||
|
||||
void SkeletonNode::checkSubBonesDirty()
|
||||
|
|
|
@ -49,13 +49,13 @@ public:
|
|||
/**
|
||||
*get All bones in this skeleton, <bone's name, BoneNode>
|
||||
*/
|
||||
const cocos2d::Map<std::string, BoneNode*>& getAllSubBonesMap() const;
|
||||
const cocos2d::StringMap<BoneNode*>& getAllSubBonesMap() const;
|
||||
|
||||
/**
|
||||
*@brief: change displays
|
||||
*@param: boneSkinNameMap, map <name of bone, name of skin to display which added to bone>
|
||||
*/
|
||||
void changeSkins(const std::map<std::string, std::string>& boneSkinNameMap);
|
||||
void changeSkins(const hlookup::string_map<std::string>& boneSkinNameMap);
|
||||
|
||||
/**
|
||||
*@brief: change displays
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
*@param: groupName, key
|
||||
*@param: boneSkinNameMap, map <name of bone, name of skin to display which added to bone>
|
||||
*/
|
||||
void addSkinGroup(std::string groupName, std::map<std::string, std::string> boneSkinNameMap);
|
||||
void addSkinGroup(std::string groupName, hlookup::string_map<std::string> boneSkinNameMap);
|
||||
|
||||
cocos2d::Rect getBoundingBox() const override;
|
||||
|
||||
|
@ -86,7 +86,7 @@ protected:
|
|||
virtual void draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform, uint32_t flags) override;
|
||||
|
||||
protected:
|
||||
cocos2d::Map<std::string, BoneNode*> _subBonesMap;
|
||||
cocos2d::StringMap<BoneNode*> _subBonesMap;
|
||||
|
||||
private:
|
||||
struct VertexData
|
||||
|
@ -98,7 +98,7 @@ private:
|
|||
cocos2d::Vec2 _squareVertices[8];
|
||||
VertexData _vertexData[8];
|
||||
|
||||
std::map<std::string, std::map<std::string, std::string>>
|
||||
hlookup::string_map<hlookup::string_map<std::string> >
|
||||
_skinGroupMap; // map< suit name, map< bone name, skin name> >
|
||||
CC_DISALLOW_COPY_AND_ASSIGN(SkeletonNode);
|
||||
|
||||
|
|
|
@ -282,9 +282,9 @@ void CSLoader::init()
|
|||
|
||||
Node* CSLoader::createNode(std::string_view filename)
|
||||
{
|
||||
std::string path = filename;
|
||||
auto path = filename;
|
||||
size_t pos = path.find_last_of('.');
|
||||
std::string suffix = path.substr(pos + 1, path.length());
|
||||
auto suffix = path.substr(pos + 1, path.length());
|
||||
|
||||
CSLoader* load = CSLoader::getInstance();
|
||||
|
||||
|
@ -302,9 +302,9 @@ Node* CSLoader::createNode(std::string_view filename)
|
|||
|
||||
Node* CSLoader::createNode(std::string_view filename, const ccNodeLoadCallback& callback)
|
||||
{
|
||||
std::string path = filename;
|
||||
auto path = filename;
|
||||
size_t pos = path.find_last_of('.');
|
||||
std::string suffix = path.substr(pos + 1, path.length());
|
||||
auto suffix = path.substr(pos + 1, path.length());
|
||||
|
||||
CSLoader* load = CSLoader::getInstance();
|
||||
|
||||
|
@ -340,18 +340,18 @@ Node* CSLoader::createNodeWithVisibleSize(std::string_view filename, const ccNod
|
|||
return node;
|
||||
}
|
||||
|
||||
std::string CSLoader::getExtentionName(std::string_view name)
|
||||
std::string_view CSLoader::getExtentionName(std::string_view name)
|
||||
{
|
||||
std::string path = name;
|
||||
auto path = name;
|
||||
size_t pos = path.find_last_of('.');
|
||||
std::string result = path.substr(pos + 1, path.length());
|
||||
auto result = path.substr(pos + 1, path.length());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
ActionTimeline* CSLoader::createTimeline(std::string_view filename)
|
||||
{
|
||||
std::string suffix = getExtentionName(filename);
|
||||
auto suffix = getExtentionName(filename);
|
||||
|
||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||
|
||||
|
@ -369,7 +369,7 @@ ActionTimeline* CSLoader::createTimeline(std::string_view filename)
|
|||
|
||||
ActionTimeline* CSLoader::createTimeline(const Data& data, std::string_view filename)
|
||||
{
|
||||
std::string suffix = getExtentionName(filename);
|
||||
auto suffix = getExtentionName(filename);
|
||||
|
||||
ActionTimelineCache* cache = ActionTimelineCache::getInstance();
|
||||
|
||||
|
@ -379,7 +379,7 @@ ActionTimeline* CSLoader::createTimeline(const Data& data, std::string_view file
|
|||
}
|
||||
else if (suffix == "json" || suffix == "ExportJson")
|
||||
{
|
||||
std::string content((char*)data.getBytes(), data.getSize());
|
||||
std::string_view content((char*)data.getBytes(), data.getSize());
|
||||
return cache->createActionFromContent(filename, content);
|
||||
}
|
||||
|
||||
|
@ -417,7 +417,7 @@ Node* CSLoader::createNodeFromJson(std::string_view filename)
|
|||
{
|
||||
if (_recordJsonPath)
|
||||
{
|
||||
std::string jsonPath = filename.substr(0, filename.find_last_of('/') + 1);
|
||||
auto jsonPath = filename.substr(0, filename.find_last_of('/') + 1);
|
||||
GUIReader::getInstance()->setFilePath(jsonPath);
|
||||
|
||||
_jsonPath = jsonPath;
|
||||
|
@ -448,7 +448,7 @@ Node* CSLoader::loadNodeWithFile(std::string_view fileName)
|
|||
Node* CSLoader::loadNodeWithContent(std::string_view content)
|
||||
{
|
||||
rapidjson::Document doc;
|
||||
doc.Parse<0>(content.c_str());
|
||||
doc.Parse<0>(content.data(), content.length());
|
||||
if (doc.HasParseError())
|
||||
{
|
||||
CCLOG("GetParseError %d\n", doc.GetParseError());
|
||||
|
@ -760,10 +760,10 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
|
|||
|
||||
if (isWidget(classname))
|
||||
{
|
||||
std::string readerName = getGUIClassName(classname);
|
||||
std::string readerName{getGUIClassName(classname)};
|
||||
readerName.append("Reader");
|
||||
|
||||
std::string guiClassName = getGUIClassName(classname);
|
||||
std::string_view guiClassName = getGUIClassName(classname);
|
||||
widget = dynamic_cast<Widget*>(ObjectFactory::getInstance()->createObject(guiClassName));
|
||||
// fix memory leak for v3.3
|
||||
// widget->retain();
|
||||
|
@ -785,7 +785,7 @@ Node* CSLoader::loadWidget(const rapidjson::Value& json)
|
|||
|
||||
//
|
||||
// 1st., custom widget parse properties of parent widget with parent widget reader
|
||||
std::string readerName = getWidgetReaderClassName(widget);
|
||||
std::string_view readerName = getWidgetReaderClassName(widget);
|
||||
WidgetReaderProtocol* reader =
|
||||
dynamic_cast<WidgetReaderProtocol*>(ObjectFactory::getInstance()->createObject(readerName));
|
||||
if (reader && widget)
|
||||
|
@ -990,7 +990,7 @@ inline void CSLoader::reconstructNestNode(cocos2d::Node* node)
|
|||
else
|
||||
{
|
||||
_rootNode = _callbackHandlers.back();
|
||||
CCLOG("after pop back _rootNode name = %s", _rootNode->getName().c_str());
|
||||
CCLOG("after pop back _rootNode name = %s", _rootNode->getName().data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ Node* CSLoader::nodeWithFlatBuffersFile(std::string_view fileName, const ccNodeL
|
|||
|
||||
if (buf.isNull())
|
||||
{
|
||||
CCLOG("CSLoader::nodeWithFlatBuffersFile - failed read file: %s", fileName.c_str());
|
||||
CCLOG("CSLoader::nodeWithFlatBuffersFile - failed read file: %s", fileName.data());
|
||||
CC_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1144,7 +1144,7 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree* nodetree, const
|
|||
{
|
||||
classname = customClassName;
|
||||
}
|
||||
std::string readername = getGUIClassName(classname);
|
||||
std::string readername{getGUIClassName(classname)};
|
||||
readername.append("Reader");
|
||||
|
||||
NodeReaderProtocol* reader =
|
||||
|
@ -1178,8 +1178,8 @@ Node* CSLoader::nodeWithFlatBuffers(const flatbuffers::NodeTree* nodetree, const
|
|||
Widget* widget = dynamic_cast<Widget*>(node);
|
||||
if (widget)
|
||||
{
|
||||
std::string callbackName = widget->getCallbackName();
|
||||
std::string callbackType = widget->getCallbackType();
|
||||
auto callbackName = widget->getCallbackName();
|
||||
auto callbackType = widget->getCallbackType();
|
||||
|
||||
bindCallback(callbackName, callbackType, widget, _rootNode);
|
||||
}
|
||||
|
@ -1288,7 +1288,7 @@ bool CSLoader::bindCallback(std::string_view callbackName,
|
|||
}
|
||||
}
|
||||
|
||||
CCLOG("callBackName %s cannot be found", callbackName.c_str());
|
||||
CCLOG("callBackName %s cannot be found", callbackName.data());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -1315,40 +1315,42 @@ bool CSLoader::isCustomWidget(std::string_view type)
|
|||
return false;
|
||||
}
|
||||
|
||||
std::string CSLoader::getGUIClassName(std::string_view name)
|
||||
std::string_view CSLoader::getGUIClassName(std::string_view name)
|
||||
{
|
||||
std::string convertedClassName = name;
|
||||
std::string_view convertedClassName;
|
||||
if (name == "Panel")
|
||||
{
|
||||
convertedClassName = "Layout";
|
||||
convertedClassName = "Layout"sv;
|
||||
}
|
||||
else if (name == "TextArea")
|
||||
{
|
||||
convertedClassName = "Text";
|
||||
convertedClassName = "Text"sv;
|
||||
}
|
||||
else if (name == "TextButton")
|
||||
{
|
||||
convertedClassName = "Button";
|
||||
convertedClassName = "Button"sv;
|
||||
}
|
||||
else if (name == "Label")
|
||||
{
|
||||
convertedClassName = "Text";
|
||||
convertedClassName = "Text"sv;
|
||||
}
|
||||
else if (name == "LabelAtlas")
|
||||
{
|
||||
convertedClassName = "TextAtlas";
|
||||
convertedClassName = "TextAtlas"sv;
|
||||
}
|
||||
else if (name == "LabelBMFont")
|
||||
{
|
||||
convertedClassName = "TextBMFont";
|
||||
convertedClassName = "TextBMFont"sv;
|
||||
}
|
||||
else
|
||||
convertedClassName = name;
|
||||
|
||||
return convertedClassName;
|
||||
}
|
||||
|
||||
std::string CSLoader::getWidgetReaderClassName(Widget* widget)
|
||||
std::string_view CSLoader::getWidgetReaderClassName(Widget* widget)
|
||||
{
|
||||
std::string readerName;
|
||||
std::string_view readerName;
|
||||
|
||||
// 1st., custom widget parse properties of parent widget with parent widget reader
|
||||
if (dynamic_cast<Button*>(widget))
|
||||
|
@ -1408,6 +1410,8 @@ std::string CSLoader::getWidgetReaderClassName(Widget* widget)
|
|||
{
|
||||
readerName = "WidgetReader";
|
||||
}
|
||||
else
|
||||
readerName = hlookup::empty_sv;
|
||||
|
||||
return readerName;
|
||||
}
|
||||
|
@ -1495,7 +1499,7 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree* nod
|
|||
}
|
||||
else
|
||||
{
|
||||
std::string readername = getGUIClassName(classname);
|
||||
std::string readername{getGUIClassName(classname)};
|
||||
readername.append("Reader");
|
||||
|
||||
NodeReaderProtocol* reader =
|
||||
|
@ -1508,8 +1512,8 @@ Node* CSLoader::nodeWithFlatBuffersForSimulator(const flatbuffers::NodeTree* nod
|
|||
Widget* widget = dynamic_cast<Widget*>(node);
|
||||
if (widget)
|
||||
{
|
||||
std::string callbackName = widget->getCallbackName();
|
||||
std::string callbackType = widget->getCallbackType();
|
||||
auto callbackName = widget->getCallbackName();
|
||||
auto callbackType = widget->getCallbackType();
|
||||
|
||||
bindCallback(callbackName, callbackType, widget, _rootNode);
|
||||
}
|
||||
|
|
|
@ -147,11 +147,11 @@ protected:
|
|||
bool isWidget(std::string_view type);
|
||||
bool isCustomWidget(std::string_view type);
|
||||
|
||||
std::string getGUIClassName(std::string_view name);
|
||||
std::string getWidgetReaderClassName(cocos2d::ui::Widget* widget);
|
||||
std::string_view getGUIClassName(std::string_view name);
|
||||
std::string_view getWidgetReaderClassName(cocos2d::ui::Widget* widget);
|
||||
|
||||
inline void reconstructNestNode(cocos2d::Node* node);
|
||||
static inline std::string getExtentionName(std::string_view name);
|
||||
static inline std::string_view getExtentionName(std::string_view name);
|
||||
|
||||
typedef std::function<cocos2d::Node*(const rapidjson::Value& json)> NodeCreateFunc;
|
||||
typedef std::pair<std::string, NodeCreateFunc> Pair;
|
||||
|
|
|
@ -190,7 +190,7 @@ void ActionNode::initWithDictionary(const rapidjson::Value& dic, Ref* root)
|
|||
|
||||
int ActionNode::valueToInt(std::string_view value)
|
||||
{
|
||||
return atoi(value.c_str());
|
||||
return atoi(value.data());
|
||||
}
|
||||
bool ActionNode::valueToBool(std::string_view value)
|
||||
{
|
||||
|
@ -206,7 +206,7 @@ bool ActionNode::valueToBool(std::string_view value)
|
|||
}
|
||||
float ActionNode::valueToFloat(std::string_view value)
|
||||
{
|
||||
return utils::atof(value.c_str());
|
||||
return utils::atof(value.data());
|
||||
}
|
||||
|
||||
void ActionNode::initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* cocoNode, cocos2d::Ref* root)
|
||||
|
|
|
@ -186,7 +186,7 @@ void ActionObject::initWithBinary(CocoLoader* cocoLoader, stExpCocoNode* cocoNod
|
|||
|
||||
int ActionObject::valueToInt(std::string_view value)
|
||||
{
|
||||
return atoi(value.c_str());
|
||||
return atoi(value.data());
|
||||
}
|
||||
bool ActionObject::valueToBool(std::string_view value)
|
||||
{
|
||||
|
@ -202,7 +202,7 @@ bool ActionObject::valueToBool(std::string_view value)
|
|||
}
|
||||
float ActionObject::valueToFloat(std::string_view value)
|
||||
{
|
||||
return utils::atof(value.c_str());
|
||||
return utils::atof(value.data());
|
||||
}
|
||||
|
||||
void ActionObject::addActionNode(ActionNode* node)
|
||||
|
|
|
@ -294,7 +294,7 @@ void Armature::changeBoneParent(Bone* bone, std::string_view parentName)
|
|||
}
|
||||
}
|
||||
|
||||
const cocos2d::Map<std::string, Bone*>& Armature::getBoneDic() const
|
||||
const cocos2d::StringMap<Bone*>& Armature::getBoneDic() const
|
||||
{
|
||||
return _boneDic;
|
||||
}
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
* Get Armature's bone dictionary
|
||||
* @return Armature's bone dictionary
|
||||
*/
|
||||
const cocos2d::Map<std::string, Bone*>& getBoneDic() const;
|
||||
const cocos2d::StringMap<Bone*>& getBoneDic() const;
|
||||
|
||||
/**
|
||||
* This boundingBox will calculate all bones' boundingBox every time
|
||||
|
@ -258,7 +258,7 @@ protected:
|
|||
|
||||
mutable bool _armatureTransformDirty;
|
||||
|
||||
cocos2d::Map<std::string, Bone*>
|
||||
cocos2d::StringMap<Bone*>
|
||||
_boneDic; //! The dictionary of the bones, include all bones in the armature, no matter it is the direct bone
|
||||
//! or the indirect bone. It is different from m_pChindren.
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ void ArmatureAnimation::setSpeedScale(float speedScale)
|
|||
|
||||
_processScale = !_movementData ? _speedScale : _speedScale * _movementData->scale;
|
||||
|
||||
const Map<std::string, Bone*>& map = _armature->getBoneDic();
|
||||
auto& map = _armature->getBoneDic();
|
||||
for (auto& element : map)
|
||||
{
|
||||
Bone* bone = element.second;
|
||||
|
@ -212,7 +212,7 @@ void ArmatureAnimation::play(std::string_view animationName, int durationTo, int
|
|||
MovementBoneData* movementBoneData = nullptr;
|
||||
_tweenList.clear();
|
||||
|
||||
const Map<std::string, Bone*>& map = _armature->getBoneDic();
|
||||
auto& map = _armature->getBoneDic();
|
||||
for (auto& element : map)
|
||||
{
|
||||
Bone* bone = element.second;
|
||||
|
|
|
@ -43,8 +43,8 @@ enum MovementEventType
|
|||
class Armature;
|
||||
class Bone;
|
||||
|
||||
typedef void (cocos2d::Ref::*SEL_MovementEventCallFunc)(Armature*, MovementEventType, const std::string&);
|
||||
typedef void (cocos2d::Ref::*SEL_FrameEventCallFunc)(Bone*, const std::string&, int, int);
|
||||
typedef void (cocos2d::Ref::*SEL_MovementEventCallFunc)(Armature*, MovementEventType, std::string_view);
|
||||
typedef void (cocos2d::Ref::*SEL_FrameEventCallFunc)(Bone*, std::string_view, int, int);
|
||||
|
||||
#define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR)
|
||||
#define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR)
|
||||
|
|
|
@ -122,7 +122,7 @@ void ArmatureDataManager::addArmatureData(std::string_view id,
|
|||
{
|
||||
if (RelativeData* data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->armatures.push_back(id);
|
||||
data->armatures.push_back(std::string{id});
|
||||
}
|
||||
|
||||
_armarureDatas.insert(id, armatureData);
|
||||
|
@ -144,7 +144,7 @@ void ArmatureDataManager::addAnimationData(std::string_view id,
|
|||
{
|
||||
if (RelativeData* data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->animations.push_back(id);
|
||||
data->animations.push_back(std::string{id});
|
||||
}
|
||||
|
||||
_animationDatas.insert(id, animationData);
|
||||
|
@ -166,7 +166,7 @@ void ArmatureDataManager::addTextureData(std::string_view id,
|
|||
{
|
||||
if (RelativeData* data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->textures.push_back(id);
|
||||
data->textures.push_back(std::string{id});
|
||||
}
|
||||
|
||||
_textureDatas.insert(id, textureData);
|
||||
|
@ -230,7 +230,7 @@ void ArmatureDataManager::addSpriteFrameFromFile(std::string_view plistPath,
|
|||
{
|
||||
if (RelativeData* data = getRelativeData(configFilePath))
|
||||
{
|
||||
data->plistFiles.push_back(plistPath);
|
||||
data->plistFiles.push_back(std::string{plistPath});
|
||||
}
|
||||
SpriteFrameCacheHelper::getInstance()->addSpriteFrameFromFile(plistPath, imagePath);
|
||||
}
|
||||
|
@ -240,15 +240,15 @@ bool ArmatureDataManager::isAutoLoadSpriteFile()
|
|||
return _autoLoadSpriteFile;
|
||||
}
|
||||
|
||||
const cocos2d::Map<std::string, ArmatureData*>& ArmatureDataManager::getArmatureDatas() const
|
||||
const cocos2d::StringMap<ArmatureData*>& ArmatureDataManager::getArmatureDatas() const
|
||||
{
|
||||
return _armarureDatas;
|
||||
}
|
||||
const cocos2d::Map<std::string, AnimationData*>& ArmatureDataManager::getAnimationDatas() const
|
||||
const cocos2d::StringMap<AnimationData*>& ArmatureDataManager::getAnimationDatas() const
|
||||
{
|
||||
return _animationDatas;
|
||||
}
|
||||
const cocos2d::Map<std::string, TextureData*>& ArmatureDataManager::getTextureDatas() const
|
||||
const cocos2d::StringMap<TextureData*>& ArmatureDataManager::getTextureDatas() const
|
||||
{
|
||||
return _textureDatas;
|
||||
}
|
||||
|
|
|
@ -179,9 +179,9 @@ public:
|
|||
*/
|
||||
bool isAutoLoadSpriteFile();
|
||||
|
||||
const cocos2d::Map<std::string, ArmatureData*>& getArmatureDatas() const;
|
||||
const cocos2d::Map<std::string, AnimationData*>& getAnimationDatas() const;
|
||||
const cocos2d::Map<std::string, TextureData*>& getTextureDatas() const;
|
||||
const cocos2d::StringMap<ArmatureData*>& getArmatureDatas() const;
|
||||
const cocos2d::StringMap<AnimationData*>& getAnimationDatas() const;
|
||||
const cocos2d::StringMap<TextureData*>& getTextureDatas() const;
|
||||
|
||||
public:
|
||||
void addRelativeData(std::string_view configFilePath);
|
||||
|
@ -193,25 +193,25 @@ private:
|
|||
* @key std::string
|
||||
* @value ArmatureData *
|
||||
*/
|
||||
cocos2d::Map<std::string, ArmatureData*> _armarureDatas;
|
||||
cocos2d::StringMap<ArmatureData*> _armarureDatas;
|
||||
|
||||
/**
|
||||
* @brief save animation datas
|
||||
* @key std::string
|
||||
* @value AnimationData *
|
||||
*/
|
||||
cocos2d::Map<std::string, AnimationData*> _animationDatas;
|
||||
cocos2d::StringMap<AnimationData*> _animationDatas;
|
||||
|
||||
/**
|
||||
* @brief save texture datas
|
||||
* @key std::string
|
||||
* @value TextureData *
|
||||
*/
|
||||
cocos2d::Map<std::string, TextureData*> _textureDatas;
|
||||
cocos2d::StringMap<TextureData*> _textureDatas;
|
||||
|
||||
bool _autoLoadSpriteFile;
|
||||
|
||||
std::unordered_map<std::string, RelativeData> _relativeDatas;
|
||||
hlookup::string_map<RelativeData> _relativeDatas;
|
||||
};
|
||||
|
||||
} // namespace cocostudio
|
||||
|
|
|
@ -77,12 +77,12 @@ int ComAttribute::getInt(std::string_view key, int def) const
|
|||
return v.asInt();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.data()))
|
||||
{
|
||||
return def;
|
||||
}
|
||||
|
||||
return DICTOOL->getIntValue_json(_doc, key.c_str());
|
||||
return DICTOOL->getIntValue_json(_doc, key.data());
|
||||
}
|
||||
|
||||
float ComAttribute::getFloat(std::string_view key, float def) const
|
||||
|
@ -93,11 +93,11 @@ float ComAttribute::getFloat(std::string_view key, float def) const
|
|||
return v.asFloat();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.data()))
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return DICTOOL->getFloatValue_json(_doc, key.c_str());
|
||||
return DICTOOL->getFloatValue_json(_doc, key.data());
|
||||
}
|
||||
|
||||
bool ComAttribute::getBool(std::string_view key, bool def) const
|
||||
|
@ -108,12 +108,12 @@ bool ComAttribute::getBool(std::string_view key, bool def) const
|
|||
return v.asBool();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.data()))
|
||||
{
|
||||
return def;
|
||||
}
|
||||
|
||||
return DICTOOL->getBooleanValue_json(_doc, key.c_str());
|
||||
return DICTOOL->getBooleanValue_json(_doc, key.data());
|
||||
}
|
||||
|
||||
std::string ComAttribute::getString(std::string_view key, std::string_view def) const
|
||||
|
@ -124,12 +124,12 @@ std::string ComAttribute::getString(std::string_view key, std::string_view def)
|
|||
return v.asString();
|
||||
}
|
||||
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.c_str()))
|
||||
if (!DICTOOL->checkObjectExist_json(_doc, key.data()))
|
||||
{
|
||||
return def;
|
||||
return std::string{def};
|
||||
}
|
||||
|
||||
return DICTOOL->getStringValue_json(_doc, key.c_str());
|
||||
return DICTOOL->getStringValue_json(_doc, key.data());
|
||||
}
|
||||
|
||||
ComAttribute* ComAttribute::create()
|
||||
|
|
|
@ -276,19 +276,15 @@ void DataReaderHelper::addDataFromFile(std::string_view filePath)
|
|||
return;
|
||||
}
|
||||
}
|
||||
_configFileList.push_back(filePath);
|
||||
_configFileList.push_back(std::string{filePath});
|
||||
|
||||
//! find the base file path
|
||||
std::string basefilePath = filePath;
|
||||
size_t pos = basefilePath.find_last_of('/');
|
||||
std::string basefilePath;
|
||||
size_t pos = filePath.find_last_of('/');
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
basefilePath = basefilePath.substr(0, pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
basefilePath = "";
|
||||
basefilePath = filePath.substr(0, pos + 1);
|
||||
}
|
||||
|
||||
std::string fileExtension = cocos2d::FileUtils::getInstance()->getFileExtension(filePath);
|
||||
|
@ -346,19 +342,15 @@ void DataReaderHelper::addDataFromFileAsync(std::string_view imagePath,
|
|||
return;
|
||||
}
|
||||
}
|
||||
_configFileList.push_back(filePath);
|
||||
_configFileList.push_back(std::string{filePath});
|
||||
|
||||
//! find the base file path
|
||||
std::string basefilePath = filePath;
|
||||
size_t pos = basefilePath.find_last_of('/');
|
||||
std::string basefilePath;
|
||||
size_t pos = filePath.find_last_of('/');
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
basefilePath = basefilePath.substr(0, pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
basefilePath = "";
|
||||
basefilePath = filePath.substr(0, pos + 1);
|
||||
}
|
||||
|
||||
// lazy init
|
||||
|
@ -506,7 +498,8 @@ void DataReaderHelper::removeConfigFile(std::string_view configFile)
|
|||
void DataReaderHelper::addDataFromCache(std::string_view pFileContent, DataInfo* dataInfo)
|
||||
{
|
||||
pugi::xml_document document;
|
||||
document.load_string(pFileContent.c_str());
|
||||
pugi::xml_parse_result ret = document.load_buffer(pFileContent.data(), pFileContent.length());
|
||||
if(!ret) return;
|
||||
|
||||
auto root = document.document_element();
|
||||
dataInfo->flashToolVersion = root.attribute(VERSION).as_float();
|
||||
|
@ -1119,12 +1112,12 @@ ContourData* DataReaderHelper::decodeContour(pugi::xml_node& contourXML, DataInf
|
|||
void DataReaderHelper::addDataFromJsonCache(std::string_view fileContent, DataInfo* dataInfo)
|
||||
{
|
||||
rapidjson::Document json;
|
||||
rapidjson::StringStream stream(fileContent.c_str());
|
||||
rapidjson::StringStream stream(fileContent.data());
|
||||
|
||||
if (fileContent.size() >= 3)
|
||||
{
|
||||
// Skip BOM if exists
|
||||
const unsigned char* c = (const unsigned char*)fileContent.c_str();
|
||||
const unsigned char* c = (const unsigned char*)fileContent.data();
|
||||
unsigned bom = c[0] | (c[1] << 8) | (c[2] << 16);
|
||||
|
||||
if (bom == 0xBFBBEF) // UTF8 BOM
|
||||
|
|
|
@ -139,13 +139,15 @@ Color4B BaseData::getColor()
|
|||
std::string DisplayData::changeDisplayToTexture(std::string_view displayName)
|
||||
{
|
||||
// remove .xxx
|
||||
std::string textureName = displayName;
|
||||
size_t startPos = textureName.find_last_of(".");
|
||||
std::string textureName;
|
||||
size_t startPos = displayName.find_last_of(".");
|
||||
|
||||
if (startPos != std::string::npos)
|
||||
{
|
||||
textureName = textureName.erase(startPos);
|
||||
textureName.assign(displayName.data(), startPos); // textureName = textureName.erase(startPos);
|
||||
}
|
||||
else
|
||||
textureName = displayName;
|
||||
|
||||
return textureName;
|
||||
}
|
||||
|
|
|
@ -286,7 +286,7 @@ public:
|
|||
|
||||
public:
|
||||
std::string name;
|
||||
cocos2d::Map<std::string, BoneData*> boneDataDic;
|
||||
cocos2d::StringMap<BoneData*> boneDataDic;
|
||||
float dataVersion;
|
||||
};
|
||||
|
||||
|
@ -446,7 +446,7 @@ public:
|
|||
* @key std::string_view
|
||||
* @value MovementBoneData *
|
||||
*/
|
||||
cocos2d::Map<std::string, MovementBoneData*> movBoneDataDic;
|
||||
cocos2d::StringMap<MovementBoneData*> movBoneDataDic;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -477,7 +477,7 @@ public:
|
|||
|
||||
public:
|
||||
std::string name;
|
||||
cocos2d::Map<std::string, MovementData*> movementDataDic;
|
||||
cocos2d::StringMap<MovementData*> movementDataDic;
|
||||
std::vector<std::string> movementNames;
|
||||
};
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ void DisplayManager::addDisplay(Node* display, int index)
|
|||
skin->setBone(_bone);
|
||||
displayData = SpriteDisplayData::create();
|
||||
|
||||
DisplayFactory::initSpriteDisplay(_bone, decoDisplay, skin->getDisplayName().c_str(), skin);
|
||||
DisplayFactory::initSpriteDisplay(_bone, decoDisplay, skin->getDisplayName().data(), skin);
|
||||
|
||||
if (SpriteDisplayData* spriteDisplayData = (SpriteDisplayData*)decoDisplay->getDisplayData())
|
||||
{
|
||||
|
|
|
@ -311,7 +311,7 @@ std::string WidgetPropertiesReader::getWidgetReaderClassName(Widget* widget)
|
|||
|
||||
std::string WidgetPropertiesReader::getGUIClassName(std::string_view name)
|
||||
{
|
||||
std::string convertedClassName = name;
|
||||
std::string convertedClassName;
|
||||
if (name == "Panel")
|
||||
{
|
||||
convertedClassName = "Layout";
|
||||
|
@ -336,6 +336,8 @@ std::string WidgetPropertiesReader::getGUIClassName(std::string_view name)
|
|||
{
|
||||
convertedClassName = "TextBMFont";
|
||||
}
|
||||
else
|
||||
convertedClassName = name;
|
||||
|
||||
return convertedClassName;
|
||||
}
|
||||
|
@ -429,7 +431,7 @@ Widget* GUIReader::widgetFromBinaryFile(const char* fileName)
|
|||
std::string WidgetPropertiesReader::getWidgetReaderClassName(std::string_view classname)
|
||||
{
|
||||
// create widget reader to parse properties of widget
|
||||
std::string readerName = classname;
|
||||
std::string readerName;
|
||||
if (readerName == "Panel")
|
||||
{
|
||||
readerName = "Layout";
|
||||
|
@ -454,6 +456,8 @@ std::string WidgetPropertiesReader::getWidgetReaderClassName(std::string_view cl
|
|||
{
|
||||
readerName = "TextBMFont";
|
||||
}
|
||||
else
|
||||
readerName = classname;
|
||||
readerName.append("Reader");
|
||||
return readerName;
|
||||
}
|
||||
|
@ -1643,10 +1647,10 @@ void WidgetPropertiesReader0300::setPropsForAllCustomWidgetFromJsonDictionary(st
|
|||
{
|
||||
GUIReader* guiReader = GUIReader::getInstance();
|
||||
|
||||
std::map<std::string, Ref*>* object_map = guiReader->getParseObjectMap();
|
||||
hlookup::string_map<Ref*>* object_map = guiReader->getParseObjectMap();
|
||||
Ref* object = (*object_map)[classType];
|
||||
|
||||
std::map<std::string, SEL_ParseEvent>* selector_map = guiReader->getParseCallBackMap();
|
||||
hlookup::string_map<SEL_ParseEvent>* selector_map = guiReader->getParseCallBackMap();
|
||||
SEL_ParseEvent selector = (*selector_map)[classType];
|
||||
|
||||
if (object && selector)
|
||||
|
|
|
@ -50,7 +50,7 @@ struct stExpCocoNode;
|
|||
|
||||
#define kCCSVersion 1.0
|
||||
|
||||
typedef void (cocos2d::Ref::*SEL_ParseEvent)(const std::string&, cocos2d::Ref*, const rapidjson::Value&);
|
||||
typedef void (cocos2d::Ref::*SEL_ParseEvent)(std::string_view, cocos2d::Ref*, const rapidjson::Value&);
|
||||
#define parseselector(_SELECTOR) (SEL_ParseEvent)(&_SELECTOR)
|
||||
|
||||
class CCS_DLL GUIReader : public cocos2d::Ref
|
||||
|
@ -96,9 +96,9 @@ protected:
|
|||
std::string m_strFilePath;
|
||||
cocos2d::ValueMap _fileDesignSizes;
|
||||
|
||||
typedef std::map<std::string, SEL_ParseEvent> ParseCallBackMap;
|
||||
typedef hlookup::string_map<SEL_ParseEvent> ParseCallBackMap;
|
||||
ParseCallBackMap _mapParseSelector;
|
||||
typedef std::map<std::string, Ref*> ParseObjectMap;
|
||||
typedef hlookup::string_map<Ref*> ParseObjectMap;
|
||||
ParseObjectMap _mapObject;
|
||||
|
||||
public:
|
||||
|
|
|
@ -161,7 +161,7 @@ cocos2d::Node* SceneReader::createNodeWithSceneFile(
|
|||
}
|
||||
else
|
||||
{
|
||||
log("read file [%s] error!\n", fileName.c_str());
|
||||
log("read file [%s] error!\n", fileName.data());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ bool Skin::initWithSpriteFrameName(std::string_view spriteFrameName)
|
|||
}
|
||||
else
|
||||
{
|
||||
CCLOG("Can't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName.c_str());
|
||||
CCLOG("Can't find CCSpriteFrame with %s. Please check your .plist file", spriteFrameName.data());
|
||||
ret = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
SpriteFrameCacheHelper();
|
||||
~SpriteFrameCacheHelper();
|
||||
|
||||
std::map<std::string, std::vector<cocos2d::SpriteFrame*>> _usingSpriteFrames;
|
||||
hlookup::string_map<std::vector<cocos2d::SpriteFrame*>> _usingSpriteFrames;
|
||||
static SpriteFrameCacheHelper* _spriteFrameCacheHelper;
|
||||
};
|
||||
|
||||
|
|
|
@ -31,4 +31,6 @@
|
|||
# define CCS_DLL
|
||||
#endif
|
||||
|
||||
#include "base/hlookup.h"
|
||||
|
||||
#endif /* __CCEXTENSIONEXPORT_H__*/
|
|
@ -453,7 +453,7 @@ int FlatBuffersSerialize::getResourceType(std::string key)
|
|||
|
||||
std::string FlatBuffersSerialize::getGUIClassName(std::string_view name)
|
||||
{
|
||||
std::string convertedClassName = name;
|
||||
std::string convertedClassName;
|
||||
if (name == "Panel")
|
||||
{
|
||||
convertedClassName = "Layout";
|
||||
|
@ -478,6 +478,8 @@ std::string FlatBuffersSerialize::getGUIClassName(std::string_view name)
|
|||
{
|
||||
convertedClassName = "TextBMFont";
|
||||
}
|
||||
else
|
||||
convertedClassName = name;
|
||||
|
||||
return convertedClassName;
|
||||
}
|
||||
|
@ -1560,7 +1562,7 @@ std::string FlatBuffersSerialize::serializeFlatBuffersWithXMLFileForLanguageData
|
|||
hasKeyReaded = true;
|
||||
}
|
||||
// Record corresponding text.
|
||||
else if (strcmp(languageName.c_str(), childElement.name()) == 0)
|
||||
else if (languageName == childElement.name())
|
||||
{
|
||||
const char* langText = childElement.text().as_string();
|
||||
if (langText && langText[0] != '\0')
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
void removeAllUnusedData(void);
|
||||
|
||||
public:
|
||||
std::map<std::string, SkeletonData*> _cacheTable;
|
||||
hlookup::string_map<SkeletonData*> _cacheTable;
|
||||
void (*_reportError)(const char* pszFormat, ...);
|
||||
};
|
||||
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
void removeAllUnusedData(void);
|
||||
|
||||
public:
|
||||
std::map<std::string, SkeletonData*> _cacheTable;
|
||||
hlookup::string_map<SkeletonData*> _cacheTable;
|
||||
void (*_reportError)(const char* pszFormat, ...);
|
||||
};
|
||||
|
||||
|
|
|
@ -4,15 +4,15 @@
|
|||
namespace cocostudio
|
||||
{
|
||||
WidgetCallBackHandlerProtocol::~WidgetCallBackHandlerProtocol() {}
|
||||
cocos2d::ui::Widget::ccWidgetTouchCallback WidgetCallBackHandlerProtocol::onLocateTouchCallback(const std::string&)
|
||||
cocos2d::ui::Widget::ccWidgetTouchCallback WidgetCallBackHandlerProtocol::onLocateTouchCallback(std::string_view)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::ui::Widget::ccWidgetClickCallback WidgetCallBackHandlerProtocol::onLocateClickCallback(const std::string&)
|
||||
cocos2d::ui::Widget::ccWidgetClickCallback WidgetCallBackHandlerProtocol::onLocateClickCallback(std::string_view)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
cocos2d::ui::Widget::ccWidgetEventCallback WidgetCallBackHandlerProtocol::onLocateEventCallback(const std::string&)
|
||||
cocos2d::ui::Widget::ccWidgetEventCallback WidgetCallBackHandlerProtocol::onLocateEventCallback(std::string_view)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -241,5 +241,5 @@ std::string ArmatureNodeReader::getArmatureName(std::string_view exporJsonPath)
|
|||
|
||||
if (start == -1)
|
||||
start = 0;
|
||||
return exporJsonPath.substr(start, end - start);
|
||||
return std::string{exporJsonPath.substr(start, end - start)};
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ cocos2d::ui::Layout* (*aLayout)();
|
|||
cocos2d::ui::ScrollView* (*aScrollView)();
|
||||
cocos2d::ui::ListView* (*aListView)();
|
||||
cocos2d::ui::PageView* (*aPageView)();
|
||||
cocos2d::ParticleSystemQuad* (*aParticleSystemQuad)(const std::string&);
|
||||
cocos2d::ParticleSystemQuad* (*aParticleSystemQuad)(std::string_view);
|
||||
cocos2d::Node* (*aArmatureNode)();
|
||||
cocostudio::timeline::SkeletonNode* (*aSkeletonNode)();
|
||||
cocostudio::timeline::BoneNode* (*aBoneNode)();
|
||||
|
|
|
@ -168,7 +168,7 @@ CCS_DLL extern cocos2d::ui::PageView* (*aPageView)();
|
|||
CCS_DLL extern cocos2d::Node* (*aArmatureNode)();
|
||||
CCS_DLL extern cocostudio::timeline::SkeletonNode* (*aSkeletonNode)();
|
||||
CCS_DLL extern cocostudio::timeline::BoneNode* (*aBoneNode)();
|
||||
CCS_DLL extern cocos2d::ParticleSystemQuad* (*aParticleSystemQuad)(const std::string&);
|
||||
CCS_DLL extern cocos2d::ParticleSystemQuad* (*aParticleSystemQuad)(std::string_view);
|
||||
CCS_DLL extern cocos2d::Node* (*aNestingNode)(std::string);
|
||||
|
||||
///// 3d objects /////
|
||||
|
|
|
@ -97,7 +97,7 @@ void TextAtlasReader::setPropsFromJsonDictionary(Widget* widget, const rapidjson
|
|||
{
|
||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
std::string_view jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
|
||||
TextAtlas* labelAtlas = static_cast<TextAtlas*>(widget);
|
||||
// bool sv = DICTOOL->checkObjectExist_json(options, P_StringValue);
|
||||
|
@ -112,7 +112,7 @@ void TextAtlasReader::setPropsFromJsonDictionary(Widget* widget, const rapidjson
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
std::string tp_c = jsonPath;
|
||||
std::string tp_c {jsonPath};
|
||||
const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path);
|
||||
const char* cmf_tp = tp_c.append(cmfPath).c_str();
|
||||
labelAtlas->setProperty(DICTOOL->getStringValue_json(options, P_StringValue, "12345678"), cmf_tp,
|
||||
|
|
|
@ -82,7 +82,7 @@ void TextBMFontReader::setPropsFromJsonDictionary(Widget* widget, const rapidjso
|
|||
{
|
||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
std::string_view jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
|
||||
TextBMFont* labelBMFont = static_cast<TextBMFont*>(widget);
|
||||
|
||||
|
@ -92,7 +92,7 @@ void TextBMFontReader::setPropsFromJsonDictionary(Widget* widget, const rapidjso
|
|||
{
|
||||
case 0:
|
||||
{
|
||||
std::string tp_c = jsonPath;
|
||||
std::string tp_c { jsonPath };
|
||||
const char* cmfPath = DICTOOL->getStringValue_json(cmftDic, P_Path);
|
||||
const char* cmf_tp = tp_c.append(cmfPath).c_str();
|
||||
labelBMFont->setFntFile(cmf_tp);
|
||||
|
|
|
@ -101,9 +101,9 @@ void TextFieldReader::setPropsFromJsonDictionary(Widget* widget, const rapidjson
|
|||
|
||||
textField->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize, 20));
|
||||
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "");
|
||||
std::string fontFilePath = jsonPath.append(fontName);
|
||||
std::string fontFilePath{GUIReader::getInstance()->getFilePath()};
|
||||
auto fontName = DICTOOL->getStringValue_json(options, P_FontName, "");
|
||||
fontFilePath.append(fontName);
|
||||
if (FileUtils::getInstance()->isFileExist(fontFilePath))
|
||||
textField->setFontName(fontFilePath);
|
||||
else
|
||||
|
|
|
@ -57,7 +57,7 @@ void TextReader::setPropsFromBinary(cocos2d::ui::Widget* widget, CocoLoader* coc
|
|||
|
||||
Text* label = static_cast<Text*>(widget);
|
||||
|
||||
std::string binaryFilePath = GUIReader::getInstance()->getFilePath();
|
||||
std::string binaryFilePath{GUIReader::getInstance()->getFilePath()};
|
||||
|
||||
for (int i = 0; i < cocoNode->GetChildNum(); ++i)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ void TextReader::setPropsFromJsonDictionary(Widget* widget, const rapidjson::Val
|
|||
{
|
||||
WidgetReader::setPropsFromJsonDictionary(widget, options);
|
||||
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
std::string fontFilePath{GUIReader::getInstance()->getFilePath()};
|
||||
|
||||
Text* label = static_cast<Text*>(widget);
|
||||
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, P_TouchScaleEnable);
|
||||
|
@ -106,9 +106,9 @@ void TextReader::setPropsFromJsonDictionary(Widget* widget, const rapidjson::Val
|
|||
|
||||
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize, 20));
|
||||
|
||||
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "");
|
||||
auto fontName = DICTOOL->getStringValue_json(options, P_FontName, "");
|
||||
|
||||
std::string fontFilePath = jsonPath.append(fontName);
|
||||
fontFilePath.append(fontName);
|
||||
if (FileUtils::getInstance()->isFileExist(fontFilePath))
|
||||
{
|
||||
label->setFontName(fontFilePath);
|
||||
|
|
|
@ -98,7 +98,7 @@ WidgetReader::WidgetReader()
|
|||
, _opacity(255)
|
||||
, _isAdaptScreen(false)
|
||||
{
|
||||
valueToInt = [=](std::string_view str) -> int { return atoi(str.c_str()); };
|
||||
valueToInt = [=](std::string_view str) -> int { return atoi(str.data()); };
|
||||
|
||||
valueToBool = [=](std::string_view str) -> bool {
|
||||
int intValue = valueToInt(str);
|
||||
|
@ -112,7 +112,7 @@ WidgetReader::WidgetReader()
|
|||
}
|
||||
};
|
||||
|
||||
valueToFloat = [=](std::string_view str) -> float { return utils::atof(str.c_str()); };
|
||||
valueToFloat = [=](std::string_view str) -> float { return utils::atof(str.data()); };
|
||||
}
|
||||
|
||||
WidgetReader::~WidgetReader() {}
|
||||
|
@ -306,14 +306,14 @@ std::string WidgetReader::getResourcePath(const rapidjson::Value& dict,
|
|||
std::string_view key,
|
||||
cocos2d::ui::Widget::TextureResType texType)
|
||||
{
|
||||
std::string jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
const char* imageFileName = DICTOOL->getStringValue_json(dict, key.c_str());
|
||||
std::string_view jsonPath = GUIReader::getInstance()->getFilePath();
|
||||
const char* imageFileName = DICTOOL->getStringValue_json(dict, key.data());
|
||||
std::string imageFileName_tp;
|
||||
if (nullptr != imageFileName)
|
||||
{
|
||||
if (texType == ui::Widget::TextureResType::LOCAL)
|
||||
{
|
||||
imageFileName_tp = jsonPath + imageFileName;
|
||||
imageFileName_tp.append(jsonPath).append(imageFileName);
|
||||
}
|
||||
else if (texType == ui::Widget::TextureResType::PLIST)
|
||||
{
|
||||
|
@ -339,14 +339,14 @@ std::string WidgetReader::getResourcePath(CocoLoader* cocoLoader,
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string binaryPath = GUIReader::getInstance()->getFilePath();
|
||||
std::string_view binaryPath = GUIReader::getInstance()->getFilePath();
|
||||
|
||||
std::string imageFileName_tp;
|
||||
if (!backgroundValue.empty())
|
||||
{
|
||||
if (texType == ui::Widget::TextureResType::LOCAL)
|
||||
{
|
||||
imageFileName_tp = binaryPath + backgroundValue;
|
||||
imageFileName_tp.append(binaryPath).append(backgroundValue);
|
||||
}
|
||||
else if (texType == ui::Widget::TextureResType::PLIST)
|
||||
{
|
||||
|
@ -942,18 +942,17 @@ Node* WidgetReader::createNodeWithFlatBuffers(const flatbuffers::Table* widgetOp
|
|||
|
||||
std::string WidgetReader::getResourcePath(std::string_view path, cocos2d::ui::Widget::TextureResType texType)
|
||||
{
|
||||
std::string filePath = GUIReader::getInstance()->getFilePath();
|
||||
const char* imageFileName = path.c_str();
|
||||
std::string_view filePath = GUIReader::getInstance()->getFilePath();
|
||||
std::string imageFileName_tp;
|
||||
if (nullptr != imageFileName && 0 != strcmp("", imageFileName))
|
||||
if (!path.empty())
|
||||
{
|
||||
if (texType == ui::Widget::TextureResType::LOCAL)
|
||||
{
|
||||
imageFileName_tp = filePath + imageFileName;
|
||||
imageFileName_tp.append(filePath).append(path);
|
||||
}
|
||||
else if (texType == ui::Widget::TextureResType::PLIST)
|
||||
{
|
||||
imageFileName_tp = imageFileName;
|
||||
imageFileName_tp.assign(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -79,9 +79,9 @@ protected:
|
|||
void beginSetBasicProperties(cocos2d::ui::Widget* widget);
|
||||
void endSetBasicProperties(cocos2d::ui::Widget* widget);
|
||||
|
||||
std::function<int(const std::string&)> valueToInt;
|
||||
std::function<bool(const std::string&)> valueToBool;
|
||||
std::function<float(const std::string&)> valueToFloat;
|
||||
std::function<int(std::string_view)> valueToInt;
|
||||
std::function<bool(std::string_view)> valueToBool;
|
||||
std::function<float(std::string_view)> valueToFloat;
|
||||
|
||||
float _sizePercentX;
|
||||
float _sizePercentY;
|
||||
|
|
|
@ -97,7 +97,7 @@ bool HelloWorld::init()
|
|||
}
|
||||
|
||||
// add "HelloWorld" splash screen"
|
||||
auto sprite = Sprite::create("HelloWorld.png");
|
||||
auto sprite = Sprite::create("HelloWorld.png"sv);
|
||||
if (sprite == nullptr)
|
||||
{
|
||||
problemLoading("'HelloWorld.png'");
|
||||
|
|
Loading…
Reference in New Issue