1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
#ifndef _2430e622_7ed5_481e_91df_1a6805bc9e49_
#define _2430e622_7ed5_481e_91df_1a6805bc9e49_
#include <sstream>
#include "WidgetContainer.h"
namespace tools
{
using Event_ChangeWidgets = MyGUI::delegates::MultiDelegate<>;
using Event_ChangeWidgetCoord =
MyGUI::delegates::MultiDelegate<MyGUI::Widget*, const MyGUI::IntCoord&, std::string_view>;
using VectorWidgetContainer = std::vector<WidgetContainer*>;
using EnumeratorWidgetContainer = MyGUI::Enumerator<VectorWidgetContainer>;
class EditorWidgets : public MyGUI::IUnlinkWidget
{
MYGUI_SINGLETON_DECLARATION(EditorWidgets);
public:
EditorWidgets();
void initialise();
void shutdown();
bool load(const MyGUI::UString& _fileName);
bool save(const MyGUI::UString& _fileName);
void clear();
void loadxmlDocument(MyGUI::xml::Document* doc, bool _testMode = false);
MyGUI::xml::Document* savexmlDocument();
WidgetContainer* find(MyGUI::Widget* _widget);
WidgetContainer* find(std::string_view _name);
void add(WidgetContainer* _container);
void remove(MyGUI::Widget* _widget);
void remove(WidgetContainer* _container);
bool tryToApplyProperty(
MyGUI::Widget* _widget,
std::string_view _key,
std::string_view _value,
bool _testMode = false);
void onSetWidgetCoord(MyGUI::Widget* _widget, const MyGUI::IntCoord& _value, std::string_view _owner) const;
void invalidateWidgets();
EnumeratorWidgetContainer getWidgets();
std::string_view getSkinReplace(std::string_view _skinName);
const MyGUI::UString& getCurrentFileName() const;
const MyGUI::UString& getCurrentItemName() const;
Event_ChangeWidgets eventChangeWidgets;
Event_ChangeWidgetCoord eventChangeWidgetCoord;
void _unlinkWidget(MyGUI::Widget* _widget) override;
MyGUI::MapString& getCodeGeneratorSettings();
private:
WidgetContainer* _find(MyGUI::Widget* _widget, std::string_view _name, std::vector<WidgetContainer*> _widgets);
void parseWidget(MyGUI::xml::ElementEnumerator& _widget, MyGUI::Widget* _parent, bool _testMode = false);
void serialiseWidget(WidgetContainer* _container, MyGUI::xml::ElementPtr _node, bool _compatibility = false);
void loadIgnoreParameters(MyGUI::xml::ElementPtr _node, std::string_view _file, MyGUI::Version _version);
void loadSkinReplace(MyGUI::xml::ElementPtr _node, std::string_view _file, MyGUI::Version _version);
void notifyFrameStarted(float _time);
void destroyAllWidgets();
bool isSkinExist(std::string_view _skinName);
bool checkTemplate(std::string_view _skinName);
bool loadFromProject(const MyGUI::UString& _fileName, size_t _index);
bool saveToProject(const MyGUI::UString& _fileName, size_t _index);
bool unbind(WidgetContainer* _container);
void loadWidgetsFromXmlNode(MyGUI::xml::ElementPtr _root, bool _testMode = false);
void saveWidgetsToXmlNode(MyGUI::xml::ElementPtr _root, bool _compatibility = false);
void loadCodeGeneratorSettings(MyGUI::xml::ElementPtr _sectorNode);
void saveCodeGeneratorSettings(MyGUI::xml::ElementPtr _rootNode);
private:
bool mWidgetsChanged{false};
using VectorString = std::vector<std::string>;
VectorString mIgnoreParameters;
VectorWidgetContainer mWidgets;
MyGUI::MapString mSkinReplaces;
MyGUI::UString mCurrentFileName;
MyGUI::UString mCurrentItemName;
MyGUI::MapString mCodeGeneratorSettings;
};
}
#endif
|