From 3651c9e97985830930125ffb94bbaff96b363841 Mon Sep 17 00:00:00 2001 From: Petr Ohlidal Date: Mon, 21 Feb 2022 16:12:28 +0100 Subject: [PATCH] :wastebasket: Removed dead MyGUI helper sources. --- source/main/CMakeLists.txt | 5 - source/main/gui/mygui/Attribute.h | 139 -------------- source/main/gui/mygui/BaseLayout.h | 245 ------------------------- source/main/gui/mygui/Dialog.cpp | 75 -------- source/main/gui/mygui/Dialog.h | 73 -------- source/main/gui/mygui/GuiPanelBase.h | 90 --------- source/main/gui/mygui/WrapsAttribute.h | 66 ------- 7 files changed, 693 deletions(-) delete mode 100644 source/main/gui/mygui/Attribute.h delete mode 100644 source/main/gui/mygui/BaseLayout.h delete mode 100644 source/main/gui/mygui/Dialog.cpp delete mode 100644 source/main/gui/mygui/Dialog.h delete mode 100644 source/main/gui/mygui/GuiPanelBase.h delete mode 100644 source/main/gui/mygui/WrapsAttribute.h diff --git a/source/main/CMakeLists.txt b/source/main/CMakeLists.txt index 545721215b..c8ee440f71 100644 --- a/source/main/CMakeLists.txt +++ b/source/main/CMakeLists.txt @@ -115,11 +115,6 @@ set(SOURCE_FILES gui/imgui/imstb_rectpack.h gui/imgui/imstb_textedit.h gui/imgui/imstb_truetype.h - gui/mygui/Attribute.h - gui/mygui/BaseLayout.h - gui/mygui/Dialog.{h,cpp} - gui/mygui/GuiPanelBase.h - gui/mygui/WrapsAttribute.h gui/panels/GUI_AngelScriptExamples.{h,cpp} gui/panels/GUI_ConsoleView.{h,cpp} gui/panels/GUI_ConsoleWindow.{h,cpp} diff --git a/source/main/gui/mygui/Attribute.h b/source/main/gui/mygui/Attribute.h deleted file mode 100644 index a7ff9b8392..0000000000 --- a/source/main/gui/mygui/Attribute.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -/// @file -/// @author Albert Semenov -/// @date 10/2009 - -#pragma once - -#include "Application.h" - -namespace attribute { - -// класс обертка для удаления данных из статического вектора -template -struct DataHolder -{ - ~DataHolder() - { - for (typename Type::iterator item = data.begin(); item != data.end(); ++item) - delete (*item).first; - } - - Type data; -}; - -// интерфейс для обертки поля -template -struct Field -{ - virtual void set(OwnerType* _target, typename SetterType::BaseValueType* _value) = 0; -}; - -// шаблон для обертки поля -template -struct FieldHolder : public Field -{ - FieldHolder(FieldType* OwnerType::* offset) : m_offset(offset) - { - } - - FieldType* OwnerType::* const m_offset; - - virtual void set(OwnerType* _target, typename SetterType::BaseValueType* _value) - { - _target ->* m_offset = SetterType::template convert(_value); - // _target->*m_offset = (_value == 0 ? 0 : _value->castType::template(false));//SetterType::convert(_value); - } -}; - -// шаблон для атрибута поля -template -struct AttributeField -{ - typedef std::pair*, ValueType> BindPair; - typedef std::vector VectorBindPair; - - template - AttributeField(FieldType* OwnerType::* _offset, const ValueType& _value) - { - getData().push_back(BindPair(new FieldHolder(_offset), _value)); - } - - static VectorBindPair& getData() - { - static DataHolder data; - return data.data; - } -}; - -// макрос для инстансирования атрибута поля -#define DECLARE_ATTRIBUTE_FIELD(_name, _type, _setter) \ - template \ - struct _name : public attribute::AttributeField \ - { \ - template \ - _name(FieldType* OwnerType::* _offset, const ValueType& _value) : \ - AttributeField(_offset, _value) { } \ - } - -// макрос для инстансирования экземпляра атрибута -#define ATTRIBUTE_FIELD(_attribute, _class, _field, _value) \ - struct _attribute##_##_field \ - { \ - _attribute##_##_field() \ - { \ - static attribute::_attribute<_class> bind(&_class::_field, _value); \ - } \ - } _attribute##_##_field - - // шаблон для атрибута класса - template - struct ClassAttribute - { - ClassAttribute(const ValueType& _value) - { - getData() = _value; - } - - static ValueType& getData() - { - static ValueType data; - return data; - } - }; - - // макрос для инстансирования атрибута класса -#define DECLARE_ATTRIBUTE_CLASS(_name, _type) \ - template \ - struct _name : public attribute::ClassAttribute<_name, ValueType> \ - { \ - _name(const ValueType& _value) : \ - ClassAttribute<_name, ValueType>(_value) { } \ - } - - // макрос для инстансирования экземпляра класса -#define ATTRIBUTE_CLASS(_attribute, _class, _value) \ - class _class; \ - static attribute::_attribute<_class> _attribute##_##_class(_value) - - -} // namespace attribute diff --git a/source/main/gui/mygui/BaseLayout.h b/source/main/gui/mygui/BaseLayout.h deleted file mode 100644 index 5cdba4ccdc..0000000000 --- a/source/main/gui/mygui/BaseLayout.h +++ /dev/null @@ -1,245 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -/// @file -/// @author Albert Semenov -/// @date 07/2008 - -#pragma once - -#include "Application.h" -#include -#include "WrapsAttribute.h" - -namespace wraps { - -class BaseLayout -{ -protected: - BaseLayout() : mMainWidget(nullptr) - { - } - - BaseLayout(const std::string& _layout, MyGUI::Widget* _parent = nullptr) : mMainWidget(nullptr) - { - initialise(_layout, _parent); - } - - template - void assignWidget(T* & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) - { - _widget = nullptr; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) - { - MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); - if (nullptr != find) - { - T* cast = find->castType(false); - if (nullptr != cast) - { - _widget = cast; - } - else - { - MYGUI_LOG(Warning, "Widget with name '" << _name << "' have wrong type ('" << - find->getTypeName() << "instead of '" << T::getClassTypeName() << "'). [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); - if (_createFakeWidgets) - _widget = _createFakeWidget(mMainWidget); - } - - return; - } - } - MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign widget with name '" << _name << "'. [" << mLayoutName << "]"); - if (_createFakeWidgets) - _widget = _createFakeWidget(mMainWidget); - } - - template - void assignBase(T* & _widget, const std::string& _name, bool _throw = true, bool _createFakeWidgets = true) - { - _widget = nullptr; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) - { - MyGUI::Widget* find = (*iter)->findWidget(mPrefix + _name); - if (nullptr != find) - { - _widget = new T(find); - mListBase.push_back(_widget); - return; - } - } - - MYGUI_LOG(Warning, "Widget with name '" << _name << "' not found. [" << mLayoutName << "]"); - MYGUI_ASSERT( ! _throw, "Can't assign base widget with name '" << _name << "'. [" << mLayoutName << "]"); - if (_createFakeWidgets) - { - _widget = new T(_createFakeWidget(mMainWidget)); - mListBase.push_back(_widget); - } - } - - void initialise(const std::string& _layout, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) - { - const std::string MAIN_WINDOW1 = "_Main"; - const std::string MAIN_WINDOW2 = "Root"; - mLayoutName = _layout; - - // оборачиваем - if (mLayoutName.empty()) - { - mMainWidget = _parent; - } - // загружаем лейаут на виджет - else - { - mPrefix = MyGUI::utility::toString(this, "_"); - mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix, _parent); - - const std::string mainName1 = mPrefix + MAIN_WINDOW1; - const std::string mainName2 = mPrefix + MAIN_WINDOW2; - for (MyGUI::VectorWidgetPtr::iterator iter = mListWindowRoot.begin(); iter != mListWindowRoot.end(); ++iter) - { - if ((*iter)->getName() == mainName1 || (*iter)->getName() == mainName2) - { - mMainWidget = (*iter); - - snapToParent(mMainWidget); - - break; - } - } - - if (mMainWidget == nullptr) - { - MYGUI_LOG(Warning, "Root widget with name '" << MAIN_WINDOW1 << "' or '" << MAIN_WINDOW2 << "' not found. [" << mLayoutName << "]"); - MYGUI_ASSERT(_throw, "No root widget. ['" << mLayoutName << "]"); - if (_createFakeWidgets) - mMainWidget = _createFakeWidget(_parent); - } - } - } - - void shutdown() - { - // удаляем все классы - for (VectorBasePtr::reverse_iterator iter = mListBase.rbegin(); iter != mListBase.rend(); ++iter) - delete (*iter); - mListBase.clear(); - - // удаляем все рутовые виджеты - MyGUI::LayoutManager::getInstance().unloadLayout(mListWindowRoot); - mListWindowRoot.clear(); - } - - template - void initialiseByAttributes(Type* _owner, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true) - { - initialise(attribute::AttributeLayout::getData(), _parent, _throw, _createFakeWidgets); - - typename attribute::AttributeFieldWidgetName::VectorBindPair& data = attribute::AttributeFieldWidgetName::getData(); - for (typename attribute::AttributeFieldWidgetName::VectorBindPair::iterator item = data.begin(); item != data.end(); ++item) - { - MyGUI::Widget* value = 0; - assignWidget(value, item->second, _throw, _createFakeWidgets); - - item->first->set(_owner, value); - } - } - -private: - void snapToParent(MyGUI::Widget* _child) - { - if (_child->isUserString("SnapTo")) - { - MyGUI::Align align = MyGUI::Align::parse(_child->getUserString("SnapTo")); - - MyGUI::IntCoord coord = _child->getCoord(); - MyGUI::IntSize size = _child->getParentSize(); - - if (align.isHStretch()) - { - coord.left = 0; - coord.width = size.width; - } - else if (align.isLeft()) - { - coord.left = 0; - } - else if (align.isRight()) - { - coord.left = size.width - coord.width; - } - else - { - coord.left = (size.width - coord.width) / 2; - } - - if (align.isVStretch()) - { - coord.top = 0; - coord.height = size.height; - } - else if (align.isTop()) - { - coord.top = 0; - } - else if (align.isBottom()) - { - coord.top = size.height - coord.height; - } - else - { - coord.top = (size.height - coord.height) / 2; - } - - _child->setCoord(coord); - } - } - - template - T* _createFakeWidget(MyGUI::Widget* _parent) - { - if (_parent) - return _parent->createWidget(MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default); - - return MyGUI::Gui::getInstance().createWidget(MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default, ""); - } - -public: - virtual ~BaseLayout() - { - shutdown(); - } - -public: - MyGUI::Widget* mMainWidget; - -private: - std::string mPrefix; - std::string mLayoutName; - MyGUI::VectorWidgetPtr mListWindowRoot; - typedef std::vector VectorBasePtr; - VectorBasePtr mListBase; -}; - -} // namespace wraps diff --git a/source/main/gui/mygui/Dialog.cpp b/source/main/gui/mygui/Dialog.cpp deleted file mode 100644 index 86579756de..0000000000 --- a/source/main/gui/mygui/Dialog.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - Copyright 2013-2014 Petr Ohlidal - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -// This file was ported from MyGUI project (MIT licensed) -// https://github.com/MyGUI/mygui -// http://mygui.info/ - -/// @file -/// @author Albert Semenov -/// @date 09/2008 - -#include "Dialog.h" - -using namespace RoR; -using namespace GUI; - -Dialog::Dialog() : - wraps::BaseLayout(), - mModal(false) -{ -} - -Dialog::Dialog(const std::string& _layout) : - wraps::BaseLayout(_layout), - mModal(false) -{ -} - -Dialog::~Dialog() -{ -} - -void Dialog::doModal() -{ - MYGUI_ASSERT(mModal != true, "Already modal mode"); - mModal = true; - - MyGUI::InputManager::getInstance().addWidgetModal(mMainWidget); - MyGUI::LayerManager::getInstance().upLayerItem(mMainWidget); - - onDoModal(); - - mMainWidget->setVisible(true); -} - -void Dialog::endModal() -{ - MYGUI_ASSERT(mModal != false, "Already modal mode"); - mModal = false; - - mMainWidget->setVisible(false); - - MyGUI::InputManager::getInstance().removeWidgetModal(mMainWidget); - - onEndModal(); -} - diff --git a/source/main/gui/mygui/Dialog.h b/source/main/gui/mygui/Dialog.h deleted file mode 100644 index 3719d90120..0000000000 --- a/source/main/gui/mygui/Dialog.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - Copyright 2013-2014 Petr Ohlidal - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -// This file was ported from MyGUI project (MIT licensed) -// https://github.com/MyGUI/mygui -// http://mygui.info/ - -/// @file -/// @author Albert Semenov -/// @date 09/2008 - -#pragma once - -#include -#include "BaseLayout.h" - -namespace RoR { -namespace GUI { - -class Dialog : - public wraps::BaseLayout -{ -public: - typedef MyGUI::delegates::CDelegate2 EventHandle_Result; - -public: - Dialog(); - Dialog(const std::string& _layout); - virtual ~Dialog(); - - void doModal(); - void endModal(); - - bool isModal() - { - return mModal; - } - - EventHandle_Result eventEndDialog; - -protected: - virtual void onDoModal() - { - } - - virtual void onEndModal() - { - } - -private: - bool mModal; -}; - -} // namespace GUI -} // namespace RoR diff --git a/source/main/gui/mygui/GuiPanelBase.h b/source/main/gui/mygui/GuiPanelBase.h deleted file mode 100644 index b3a5234e32..0000000000 --- a/source/main/gui/mygui/GuiPanelBase.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - Copyright 2013-2014 Petr Ohlidal - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -/// @file -/// @author Petr Ohlidal -/// @date 12/2014 - -#pragma once - -#include -#include // Forward declarations -#include - -namespace RoR -{ - -class GuiPanelBase -{ - friend class RoR::GUIManager; - -public: - GuiPanelBase(MyGUI::Window* main_widget): - m_panel_widget(main_widget), - m_is_temporarily_hidden(false) - {} - - inline void Show() - { - m_panel_widget->setVisible(true); - m_is_temporarily_hidden = false; - } - - inline void HideTemporarily() - { - if (m_panel_widget->getVisible()) - { - m_panel_widget->setVisible(false); - m_is_temporarily_hidden = true; - } - } - - inline void ShowIfHiddenTemporarily() - { - if (m_is_temporarily_hidden) - { - Show(); - } - } - - inline void Hide() { m_panel_widget->setVisible(false); } - inline bool IsVisible() const { return m_panel_widget->getVisible(); } - inline int GetWidthPixels() const { return GetSizePixels().width; } - inline int GetHeightPixels() const { return GetSizePixels().height; } - - inline void SetPosition(int x_pixels, int y_pixels) { m_panel_widget->setPosition(x_pixels, y_pixels); } - inline void SetWidth(int width_pixels) { m_panel_widget->setSize(width_pixels, GetHeightPixels()); } - inline void SetHeight(int height_pixels) { m_panel_widget->setSize(GetWidthPixels(), height_pixels); } - - inline MyGUI::IntSize GetSizePixels() const { return m_panel_widget->getSize(); } - - inline void CenterToScreen() - { - MyGUI::IntSize parentSize = m_panel_widget->getParentSize(); - SetPosition((parentSize.width - GetWidthPixels()) / 2, (parentSize.height - GetHeightPixels()) / 2); - } - -protected: - MyGUI::Window* m_panel_widget; - bool m_is_temporarily_hidden; -}; - -} // namespace RoR diff --git a/source/main/gui/mygui/WrapsAttribute.h b/source/main/gui/mygui/WrapsAttribute.h deleted file mode 100644 index eba180b0d7..0000000000 --- a/source/main/gui/mygui/WrapsAttribute.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This source file is part of Rigs of Rods - Copyright 2005-2012 Pierre-Michel Ricordel - Copyright 2007-2012 Thomas Fischer - - For more information, see http://www.rigsofrods.org/ - - Rigs of Rods is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License version 3, as - published by the Free Software Foundation. - - Rigs of Rods is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with Rigs of Rods. If not, see . -*/ - -/// @file -/// @author Albert Semenov -/// @date 10/2009 -/// @module - - -#pragma once - -#include "Application.h" -#include -#include "Attribute.h" - -namespace attribute -{ - -struct FieldSetterWidget -{ - typedef MyGUI::Widget BaseValueType; - - template - static Type* convert(BaseValueType* _value) - { - return _value == 0 ? 0 : _value->castType(false); - } -}; - -DECLARE_ATTRIBUTE_FIELD(AttributeFieldWidgetName, std::string, FieldSetterWidget); - -#define ATTRIBUTE_FIELD_WIDGET_NAME(_class, _field, _value) \ - ATTRIBUTE_FIELD(AttributeFieldWidgetName, _class, _field, _value) - - - -DECLARE_ATTRIBUTE_CLASS(AttributeSize, MyGUI::IntSize); - -#define ATTRIBUTE_CLASS_SIZE(_class, _value) \ - ATTRIBUTE_CLASS(AttributeSize, _class, _value) - - -DECLARE_ATTRIBUTE_CLASS(AttributeLayout, std::string); - -#define ATTRIBUTE_CLASS_LAYOUT(_class, _value) \ - ATTRIBUTE_CLASS(AttributeLayout, _class, _value) - -} -