diff -Nur stuntrally.orig/source/CMakeLists.txt stuntrally//source/CMakeLists.txt
--- stuntrally.orig/source/CMakeLists.txt 2011-07-31 09:08:29.000000000 +0200
+++ stuntrally//source/CMakeLists.txt 2011-08-13 01:19:01.000000000 +0200
@@ -15,7 +15,7 @@
endif()
# Search include files from all source sub directories
-include_directories(btOgre bullet ogre paged-geom road tinyxml vdrift)
+include_directories(btOgre bullet ogre paged-geom road tinyxml vdrift mygui)
# Compile our libraries
foreach(ourlib tinyxml bullet oisb paged-geom)
diff -Nur stuntrally.orig/source/editor/Gui_Util.cpp stuntrally//source/editor/Gui_Util.cpp
--- stuntrally.orig/source/editor/Gui_Util.cpp 2011-07-31 09:08:29.000000000 +0200
+++ stuntrally//source/editor/Gui_Util.cpp 2011-08-13 01:32:56.000000000 +0200
@@ -571,7 +571,7 @@
while (widgets.next())
{
WidgetPtr wp = widgets.current();
- wp->setAlign(Align::Relative);
+ wp->setAlign(WidgetInfo::Relative);
bool tip = wp->isUserString("tip");
if (tip) // if has tooltip string
{
diff -Nur stuntrally.orig/source/editor/OgreApp.h stuntrally//source/editor/OgreApp.h
--- stuntrally.orig/source/editor/OgreApp.h 2011-07-31 09:08:29.000000000 +0200
+++ stuntrally//source/editor/OgreApp.h 2011-08-13 01:24:50.000000000 +0200
@@ -19,6 +19,7 @@
#include <OgrePageManager.h>
#include <MyGUI.h>
+#include "MessageBox/MessageBox.h"
const int ciShadowNumSizes = 4;
diff -Nur stuntrally.orig/source/mygui/BaseLayout/Attribute.h stuntrally//source/mygui/BaseLayout/Attribute.h
--- stuntrally.orig/source/mygui/BaseLayout/Attribute.h 1970-01-01 01:00:00.000000000 +0100
+++ stuntrally//source/mygui/BaseLayout/Attribute.h 2011-08-13 01:27:05.000000000 +0200
@@ -0,0 +1,123 @@
+/*!
+ @file
+ @author Albert Semenov
+ @date 10/2009
+ @module
+*/
+
+#ifndef __ATTRIBUTE_H__
+#define __ATTRIBUTE_H__
+
+namespace attribute
+{
+
+ // êëàññ îáåðòêà äëÿ óäàëåíèÿ äàííûõ èç ñòàòè÷åñêîãî âåêòîðà
+ template <typename Type>
+ struct DataHolder
+ {
+ ~DataHolder()
+ {
+ for (typename Type::iterator item = data.begin(); item != data.end(); ++item)
+ delete (*item).first;
+ }
+
+ Type data;
+ };
+
+ // èíòåðôåéñ äëÿ îáåðòêè ïîëÿ
+ template <typename OwnerType, typename SetterType>
+ struct Field
+ {
+ virtual bool set(OwnerType* _target, typename SetterType::BaseValueType* _value) = 0;
+ virtual const std::string& getFieldTypeName() = 0;
+ };
+
+ // øàáëîí äëÿ îáåðòêè ïîëÿ
+ template <typename OwnerType, typename FieldType, typename SetterType>
+ struct FieldHolder : public Field<OwnerType, SetterType>
+ {
+ FieldHolder(FieldType* OwnerType::* offset) : m_offset(offset) { }
+ FieldType* OwnerType::* const m_offset;
+
+ virtual bool set(OwnerType* _target, typename SetterType::BaseValueType* _value)
+ {
+ _target->*m_offset = SetterType::template convert<FieldType>(_value);
+ return _target->*m_offset != 0;
+ }
+ virtual const std::string& getFieldTypeName()
+ {
+ return FieldType::getClassTypeName();
+ }
+ };
+
+ // øàáëîí äëÿ àòðèáóòà ïîëÿ
+ template <typename OwnerType, typename ValueType, typename SetterType>
+ struct AttributeField
+ {
+ typedef std::pair<Field<OwnerType, SetterType>*, ValueType> BindPair;
+ typedef std::vector<BindPair> VectorBindPair;
+
+ template <typename FieldType>
+ AttributeField(FieldType* OwnerType::* _offset, const ValueType& _value)
+ {
+ getData().push_back(BindPair(new FieldHolder<OwnerType, FieldType, SetterType>(_offset), _value));
+ }
+ static VectorBindPair& getData()
+ {
+ static DataHolder<VectorBindPair> data;
+ return data.data;
+ }
+ };
+
+ // ìàêðîñ äëÿ èíñòàíñèðîâàíèÿ àòðèáóòà ïîëÿ
+#define DECLARE_ATTRIBUTE_FIELD(_name, _type, _setter) \
+ template <typename OwnerType, typename ValueType = _type, typename SetterType = _setter> \
+ struct _name : public attribute::AttributeField<OwnerType, ValueType, SetterType> \
+ { \
+ template <typename FieldType> \
+ _name(FieldType* OwnerType::* _offset, const ValueType& _value) : \
+ AttributeField<OwnerType, ValueType, SetterType>(_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 <typename Type, typename ValueType>
+ struct ClassAttribute
+ {
+ ClassAttribute(const ValueType& _value)
+ {
+ getData() = _value;
+ }
+ static ValueType& getData()
+ {
+ static ValueType data;
+ return data;
+ }
+ };
+
+ // ìàêðîñ äëÿ èíñòàíñèðîâàíèÿ àòðèáóòà êëàññà
+#define DECLARE_ATTRIBUTE_CLASS(_name, _type) \
+ template <typename Type, typename ValueType = _type> \
+ struct _name : public attribute::ClassAttribute<_name<Type>, ValueType> \
+ { \
+ _name(const ValueType& _value) : \
+ ClassAttribute<_name<Type>, ValueType>(_value) { } \
+ }
+
+ // ìàêðîñ äëÿ èíñòàíñèðîâàíèÿ ýêçåìïëÿðà êëàññà
+#define ATTRIBUTE_CLASS(_attribute, _class, _value) \
+ class _class; \
+ static attribute::_attribute<_class> _attribute##_##_class(_value)
+}
+
+#endif // __ATTRIBUTE_H__
diff -Nur stuntrally.orig/source/mygui/BaseLayout/BaseLayout.h stuntrally//source/mygui/BaseLayout/BaseLayout.h
--- stuntrally.orig/source/mygui/BaseLayout/BaseLayout.h 1970-01-01 01:00:00.000000000 +0100
+++ stuntrally//source/mygui/BaseLayout/BaseLayout.h 2011-08-13 01:27:08.000000000 +0200
@@ -0,0 +1,241 @@
+/*!
+ @file
+ @author Albert Semenov
+ @date 07/2008
+ @module
+*/
+
+#ifndef __BASE_LAYOUT_H__
+#define __BASE_LAYOUT_H__
+
+#include <MyGUI.h>
+#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 <typename T>
+ 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<T>(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<T>(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<T>(mMainWidget);
+ }
+
+ template <typename T>
+ 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<MyGUI::Widget>(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<MyGUI::Widget>(_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 <typename Type>
+ void initialiseByAttributes(Type* _owner, MyGUI::Widget* _parent = nullptr, bool _throw = true, bool _createFakeWidgets = true)
+ {
+ initialise(attribute::AttributeLayout<Type>::getData(), _parent, _throw, _createFakeWidgets);
+
+ typename attribute::AttributeFieldWidgetName<Type>::VectorBindPair& data = attribute::AttributeFieldWidgetName<Type>::getData();
+ for (typename attribute::AttributeFieldWidgetName<Type>::VectorBindPair::iterator item = data.begin(); item != data.end(); ++item)
+ {
+ MyGUI::Widget* value = nullptr;
+ assignWidget(value, item->second, _throw, false);
+
+ bool result = item->first->set(_owner, value);
+
+ if (!result && _createFakeWidgets)
+ {
+ value = _createFakeWidgetT(item->first->getFieldTypeName(), mMainWidget);
+ 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 <typename T>
+ T* _createFakeWidget(MyGUI::Widget* _parent)
+ {
+ return static_cast<T*>(_createFakeWidgetT(T::getClassTypeName(), _parent));
+ }
+
+ MyGUI::Widget* _createFakeWidgetT(const std::string& _typeName, MyGUI::Widget* _parent)
+ {
+ if (_parent)
+ return _parent->createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default);
+
+ return MyGUI::Gui::getInstance().createWidgetT(_typeName, MyGUI::SkinManager::getInstance().getDefaultSkin(), MyGUI::IntCoord(), MyGUI::Align::Default, "");
+ }
+
+ public:
+ virtual ~BaseLayout()
+ {
+ shutdown();
+ }
+
+ protected:
+ MyGUI::Widget* mMainWidget;
+
+ private:
+ std::string mPrefix;
+ std::string mLayoutName;
+ MyGUI::VectorWidgetPtr mListWindowRoot;
+ typedef std::vector<BaseLayout*> VectorBasePtr;
+ VectorBasePtr mListBase;
+ };
+
+} // namespace wraps
+
+#endif // __BASE_LAYOUT_H__
diff -Nur stuntrally.orig/source/mygui/BaseLayout/WrapsAttribute.h stuntrally//source/mygui/BaseLayout/WrapsAttribute.h
--- stuntrally.orig/source/mygui/BaseLayout/WrapsAttribute.h 1970-01-01 01:00:00.000000000 +0100
+++ stuntrally//source/mygui/BaseLayout/WrapsAttribute.h 2011-08-13 01:27:11.000000000 +0200
@@ -0,0 +1,47 @@
+/*!
+ @file
+ @author Albert Semenov
+ @date 10/2009
+ @module
+*/
+
+#ifndef __WRAPS_ATTRIBUTE_H__
+#define __WRAPS_ATTRIBUTE_H__
+
+#include <MyGUI.h>
+#include "Attribute.h"
+
+namespace attribute
+{
+
+ struct FieldSetterWidget
+ {
+ typedef MyGUI::Widget BaseValueType;
+
+ template <typename Type>
+ static Type* convert(BaseValueType* _value)
+ {
+ return _value == 0 ? 0 : _value->castType<Type>(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)
+
+}
+
+#endif // __WRAPS_ATTRIBUTE_H__
diff -Nur stuntrally.orig/source/mygui/MessageBox/MessageBox.h stuntrally//source/mygui/MessageBox/MessageBox.h
--- stuntrally.orig/source/mygui/MessageBox/MessageBox.h 1970-01-01 01:00:00.000000000 +0100
+++ stuntrally//source/mygui/MessageBox/MessageBox.h 2011-08-13 01:16:08.000000000 +0200
@@ -0,0 +1,389 @@
+/*!
+ @file
+ @author Albert Semenov
+ @date 12/2010
+*/
+#ifndef __MESSAGE_BOX_H__
+#define __MESSAGE_BOX_H__
+
+#include <MyGUI.h>
+#include "MessageBoxStyle.h"
+#include "BaseLayout/BaseLayout.h"
+
+namespace MyGUI
+{
+ class Message;
+
+ typedef delegates::CMultiDelegate2<Message*, MessageBoxStyle> EventHandle_MessageBoxPtrMessageStyle;
+
+ class Message :
+ public wraps::BaseLayout
+ {
+ public:
+ Message() :
+ wraps::BaseLayout("MessageBox.layout"),
+ mWidgetText(nullptr),
+ mInfoOk(MessageBoxStyle::None),
+ mInfoCancel(MessageBoxStyle::None),
+ mSmoothShow(false),
+ mIcon(nullptr),
+ mLeftOffset1(0),
+ mLeftOffset2(0)
+ {
+ assignWidget(mWidgetText, "Text", false);
+ if (mWidgetText != nullptr)
+ {
+ mOffsetText.set(mMainWidget->getClientCoord().width - mWidgetText->getWidth(), mMainWidget->getClientCoord().height - mWidgetText->getHeight());
+ mLeftOffset2 = mLeftOffset1 = mWidgetText->getLeft();
+ }
+
+ assignWidget(mIcon, "Icon", false);
+ if (mIcon != nullptr)
+ {
+ mLeftOffset2 = mIcon->getRight() + 3;
+ }
+
+ mButtonType = Button::getClassTypeName();
+
+ if (mMainWidget->isUserString("ButtonSkin"))
+ mButtonSkin = mMainWidget->getUserString("ButtonSkin");
+
+ Widget* widget = nullptr;
+ assignWidget(widget, "ButtonPlace", false);
+ if (widget != nullptr)
+ {
+ mButtonOffset.set(widget->getLeft(), mMainWidget->getClientCoord().height - widget->getTop());
+ widget->setVisible(false);
+ }
+
+ assignWidget(widget, "ButtonTemplate", false);
+ if (widget != nullptr)
+ {
+ mButtonSize = widget->getSize();
+ }
+ }
+
+ virtual ~Message()
+ {
+ mWidgetText = nullptr;
+ mIcon = nullptr;
+ }
+
+ /** Set caption text*/
+ void setCaption(const UString& _value)
+ {
+ mMainWidget->castType<Window>()->setCaption(_value);
+ }
+
+ /** Set message text*/
+ void setMessageText(const UString& _value)
+ {
+ if (mWidgetText != nullptr)
+ mWidgetText->setCaption(_value);
+ updateSize();
+ }
+
+ /** Create button with specific name*/
+ MessageBoxStyle addButtonName(const UString& _name)
+ {
+ if (mVectorButton.size() >= MessageBoxStyle::_CountUserButtons)
+ {
+ MYGUI_LOG(Warning, "Too many buttons in message box, ignored");
+ return MessageBoxStyle::None;
+ }
+ // áèò, íîìåð êíîïêè + ñìåùåíèå äî Button1
+ MessageBoxStyle info = MessageBoxStyle(MessageBoxStyle::Enum(MYGUI_FLAG(mVectorButton.size() + MessageBoxStyle::_IndexUserButton1)));
+
+ // çàïîìèíàåì êíîïêè äëÿ îòìåíû è ïîäòâåðæäåíèÿ
+ if (mVectorButton.empty())
+ mInfoOk = info;
+ mInfoCancel = info;
+
+ Widget* widget = mMainWidget->createWidgetT(mButtonType, mButtonSkin, IntCoord(), Align::Left | Align::Bottom);
+ Button* button = widget->castType<Button>();
+ button->eventMouseButtonClick += newDelegate(this, &Message::notifyButtonClick);
+ button->setCaption(_name);
+ button->_setInternalData(info);
+ mVectorButton.push_back(button);
+
+ updateSize();
+ return info;
+ }
+
+ /** Set smooth message showing*/
+ void setSmoothShow(bool _value)
+ {
+ mSmoothShow = _value;
+ if (mSmoothShow)
+ {
+ mMainWidget->setAlpha(ALPHA_MIN);
+ mMainWidget->setVisible(true);
+ mMainWidget->castType<Window>()->setVisibleSmooth(true);
+ }
+ }
+
+ /** Set message icon*/
+ void setMessageIcon(MessageBoxStyle _value)
+ {
+ if (nullptr == mIcon)
+ return;
+
+ if (mIcon->getItemResource() != nullptr)
+ {
+ mIcon->setItemName(getIconName(_value.getIconIndex()));
+ }
+ else
+ {
+ mIcon->setImageIndex(_value.getIconIndex());
+ }
+
+ updateSize();
+ }
+
+ void endMessage(MessageBoxStyle _result)
+ {
+ _destroyMessage(_result);
+ }
+
+ void endMessage()
+ {
+ _destroyMessage(mInfoCancel);
+ }
+
+ /** Create button using MessageBoxStyle*/
+ void setMessageButton(MessageBoxStyle _value)
+ {
+ clearButton();
+
+ std::vector<MessageBoxStyle> buttons = _value.getButtons();
+
+ for (size_t index = 0; index < buttons.size(); ++index)
+ {
+ // êîððåêòèðóåì åå íîìåð
+ MessageBoxStyle info = buttons[index];
+
+ // åñëè áèò åñòü òî ñòàâèì êíîïêó
+ addButtonName(getButtonName(info));
+
+ // âíóòðè àää ñáðàñûâàåòñÿ
+ mVectorButton.back()->_setInternalData(info);
+
+ // ïåðâàÿ êíîïêà
+ if (mVectorButton.size() == 1)
+ mInfoOk = info;
+ // ïîñëåäíÿÿ êíîïêà
+ mInfoCancel = info;
+ }
+
+ updateSize();
+ }
+
+ /** Set message style (button and icon)*/
+ void setMessageStyle(MessageBoxStyle _value)
+ {
+ setMessageButton(_value);
+ setMessageIcon(_value);
+ }
+
+ void setMessageModal(bool _value)
+ {
+ if (_value)
+ InputManager::getInstance().addWidgetModal(mMainWidget);
+ else
+ InputManager::getInstance().removeWidgetModal(mMainWidget);
+ }
+
+ /** Static method for creating message with one command
+ @param
+ _modal if true all other GUI elements will be blocked untill message is closed
+ @param
+ _style any combination of flags from ViewValueInfo
+ @param
+ _button1 ... _button4 specific buttons names
+ */
+ static Message* createMessageBox(
+ const UString& _skinName,
+ const UString& _caption,
+ const UString& _message,
+ MessageBoxStyle _style = MessageBoxStyle::Ok | MessageBoxStyle::IconDefault,
+ const std::string& _layer = "",
+ bool _modal = true,
+ const std::string& _button1 = "",
+ const std::string& _button2 = "",
+ const std::string& _button3 = "",
+ const std::string& _button4 = "")
+ {
+ Message* mess = new Message();
+
+ mess->setCaption(_caption);
+ mess->setMessageText(_message);
+
+ mess->setSmoothShow(true);
+
+ mess->setMessageStyle(_style);
+
+ if (!_button1.empty())
+ {
+ mess->addButtonName(_button1);
+ if (!_button2.empty())
+ {
+ mess->addButtonName(_button2);
+ if (!_button3.empty())
+ {
+ mess->addButtonName(_button3);
+ }
+ }
+ }
+
+ if (_modal)
+ InputManager::getInstance().addWidgetModal(mess->mMainWidget);
+
+ return mess;
+ }
+
+ /*events:*/
+ /** Event : button on message window pressed.\n
+ signature : void method(tools::Message* _sender, MessageBoxStyle _result)\n
+ @param _sender widget that called this event
+ @param _result - id of pressed button
+ */
+ EventHandle_MessageBoxPtrMessageStyle
+ eventMessageBoxResult;
+
+ protected:
+ void updateSize()
+ {
+ ISubWidgetText* text = nullptr;
+ if (mWidgetText != nullptr)
+ text = mWidgetText->getSubWidgetText();
+ IntSize size = text == nullptr ? IntSize() : text->getTextSize();
+ // ìèíèìóì âûñîòà èêîíêè
+ if ((nullptr != mIcon) && (mIcon->getImageIndex() != ITEM_NONE))
+ {
+ if (size.height < mIcon->getHeight())
+ size.height = mIcon->getHeight();
+ size.width += mIcon->getSize().width;
+ }
+ size += mOffsetText;
+ size.width += 3;
+
+ int width = ((int)mVectorButton.size() * mButtonSize.width) + (((int)mVectorButton.size() + 1) * mButtonOffset.width);
+ if (size.width < width)
+ size.width = width;
+
+ int offset = (size.width - width) / 2;
+ offset += mButtonOffset.width;
+
+ size.width += mMainWidget->getWidth() - mMainWidget->getClientCoord().width;
+ size.height += mMainWidget->getHeight() - mMainWidget->getClientCoord().height;
+
+ const IntSize& view = RenderManager::getInstance().getViewSize();
+ mMainWidget->setCoord((view.width - size.width) / 2, (view.height - size.height) / 2, size.width, size.height);
+
+ if (nullptr != mIcon)
+ {
+ if (mWidgetText != nullptr)
+ {
+ if (mIcon->getImageIndex() != ITEM_NONE)
+ mWidgetText->setCoord(mLeftOffset2, mWidgetText->getTop(), mWidgetText->getWidth(), mWidgetText->getHeight());
+ else
+ mWidgetText->setCoord(mLeftOffset1, mWidgetText->getTop(), mWidgetText->getWidth(), mWidgetText->getHeight());
+ }
+ }
+
+ for (std::vector<Button*>::iterator iter = mVectorButton.begin(); iter != mVectorButton.end(); ++iter)
+ {
+ (*iter)->setCoord(offset, mMainWidget->getClientCoord().height - mButtonOffset.height, mButtonSize.width, mButtonSize.height);
+ offset += mButtonOffset.width + mButtonSize.width;
+ }
+ }
+
+ void notifyButtonClick(Widget* _sender)
+ {
+ _destroyMessage(*_sender->_getInternalData<MessageBoxStyle>());
+ }
+
+ void clearButton()
+ {
+ for (std::vector<Button*>::iterator iter = mVectorButton.begin(); iter != mVectorButton.end(); ++iter)
+ WidgetManager::getInstance().destroyWidget(*iter);
+ mVectorButton.clear();
+ }
+
+ /*void onKeyButtonPressed(KeyCode _key, Char _char)
+ {
+ Base::onKeyButtonPressed(_key, _char);
+
+ if ((_key == KeyCode::Return) || (_key == KeyCode::NumpadEnter))
+ _destroyMessage(mInfoOk);
+ else if (_key == KeyCode::Escape)
+ _destroyMessage(mInfoCancel);
+ }*/
+
+ void _destroyMessage(MessageBoxStyle _result)
+ {
+ eventMessageBoxResult(this, _result);
+
+ delete this;
+ }
+
+ UString getButtonName(MessageBoxStyle _style) const
+ {
+ size_t index = _style.getButtonIndex();
+ const char* tag = getButtonTag(index);
+ UString result = LanguageManager::getInstance().replaceTags(utility::toString("#{", tag, "}"));
+ if (result == tag)
+ return getButtonName(index);
+ return result;
+ }
+
+ const char* getIconName(size_t _index) const
+ {
+ static const size_t CountIcons = 4;
+ static const char* IconNames[CountIcons + 1] = { "Info", "Quest", "Error", "Warning", "" };
+ if (_index >= CountIcons)
+ return IconNames[CountIcons];
+ return IconNames[_index];
+ }
+
+ const char* getButtonName(size_t _index) const
+ {
+ static const size_t Count = 9;
+ static const char * Names[Count + 1] = { "Ok", "Yes", "No", "Abort", "Retry", "Ignore", "Cancel", "Try", "Continue", "" };
+ if (_index >= Count)
+ return Names[Count];
+ return Names[_index];
+ }
+
+ const char* getButtonTag(size_t _index) const
+ {
+ static const size_t Count = 9;
+ static const char* Names[Count + 1] = { "MessageBox_Ok", "MessageBox_Yes", "MessageBox_No", "MessageBox_Abort", "MessageBox_Retry", "MessageBox_Ignore", "MessageBox_Cancel", "MessageBox_Try", "MessageBox_Continue", "" };
+ if (_index >= Count)
+ return Names[Count];
+ return Names[_index];
+ }
+
+ private:
+ IntSize mOffsetText;
+ TextBox* mWidgetText;
+
+ std::string mButtonSkin;
+ std::string mButtonType;
+ IntSize mButtonSize;
+ IntSize mButtonOffset;
+
+ std::vector<Button*> mVectorButton;
+ MessageBoxStyle mInfoOk;
+ MessageBoxStyle mInfoCancel;
+ bool mSmoothShow;
+
+ std::string mDefaultCaption;
+ ImageBox* mIcon;
+ int mLeftOffset1;
+ int mLeftOffset2;
+ };
+
+} // namespace MyGUI
+
+#endif // __MESSAGE_BOX_H__
diff -Nur stuntrally.orig/source/mygui/MessageBox/MessageBoxStyle.h stuntrally//source/mygui/MessageBox/MessageBoxStyle.h
--- stuntrally.orig/source/mygui/MessageBox/MessageBoxStyle.h 1970-01-01 01:00:00.000000000 +0100
+++ stuntrally//source/mygui/MessageBox/MessageBoxStyle.h 2011-08-13 01:16:11.000000000 +0200
@@ -0,0 +1,229 @@
+/*!
+ @file
+ @author Albert Semenov
+ @date 10/2010
+*/
+#ifndef __MESSAGE_BOX_STYLE_H__
+#define __MESSAGE_BOX_STYLE_H__
+
+#include <MyGUI.h>
+
+namespace MyGUI
+{
+
+ struct MessageBoxStyle
+ {
+ enum Enum
+ {
+ None = MYGUI_FLAG_NONE,
+ Ok = MYGUI_FLAG(0),
+ Yes = MYGUI_FLAG(1),
+ No = MYGUI_FLAG(2),
+ Abort = MYGUI_FLAG(3),
+ Retry = MYGUI_FLAG(4),
+ Ignore = MYGUI_FLAG(5),
+ Cancel = MYGUI_FLAG(6),
+ Try = MYGUI_FLAG(7),
+ Continue = MYGUI_FLAG(8),
+
+ _IndexUserButton1 = 9, // èíäåêñ ïåðâîé êíîïêè þçåðà
+
+ Button1 = MYGUI_FLAG(_IndexUserButton1),
+ Button2 = MYGUI_FLAG(_IndexUserButton1 + 1),
+ Button3 = MYGUI_FLAG(_IndexUserButton1 + 2),
+ Button4 = MYGUI_FLAG(_IndexUserButton1 + 3),
+
+ _CountUserButtons = 4, // êîëëè÷åñòâî êíîïîê þçåðà
+ _IndexIcon1 = _IndexUserButton1 + _CountUserButtons, // èíäåêñ ïåðâîé èêîíêè
+
+ IconDefault = MYGUI_FLAG(_IndexIcon1),
+
+ IconInfo = MYGUI_FLAG(_IndexIcon1),
+ IconQuest = MYGUI_FLAG(_IndexIcon1 + 1),
+ IconError = MYGUI_FLAG(_IndexIcon1 + 2),
+ IconWarning = MYGUI_FLAG(_IndexIcon1 + 3),
+
+ Icon1 = MYGUI_FLAG(_IndexIcon1),
+ Icon2 = MYGUI_FLAG(_IndexIcon1 + 1),
+ Icon3 = MYGUI_FLAG(_IndexIcon1 + 2),
+ Icon4 = MYGUI_FLAG(_IndexIcon1 + 3),
+ Icon5 = MYGUI_FLAG(_IndexIcon1 + 4),
+ Icon6 = MYGUI_FLAG(_IndexIcon1 + 5),
+ Icon7 = MYGUI_FLAG(_IndexIcon1 + 6),
+ Icon8 = MYGUI_FLAG(_IndexIcon1 + 7)
+ };
+
+ MessageBoxStyle(Enum _value = None) :
+ value(_value)
+ {
+ }
+
+ MessageBoxStyle& operator |= (MessageBoxStyle const& _other)
+ {
+ value = Enum(int(value) | int(_other.value));
+ return *this;
+ }
+
+ friend MessageBoxStyle operator | (Enum const& a, Enum const& b)
+ {
+ return MessageBoxStyle(Enum(int(a) | int(b)));
+ }
+
+ MessageBoxStyle operator | (Enum const& a)
+ {
+ return MessageBoxStyle(Enum(int(value) | int(a)));
+ }
+
+ friend bool operator == (MessageBoxStyle const& a, MessageBoxStyle const& b)
+ {
+ return a.value == b.value;
+ }
+
+ friend bool operator != (MessageBoxStyle const& a, MessageBoxStyle const& b)
+ {
+ return a.value != b.value;
+ }
+
+ friend std::ostream& operator << (std::ostream& _stream, const MessageBoxStyle& _value)
+ {
+ //_stream << _value.print();
+ return _stream;
+ }
+
+ friend std::istream& operator >> (std::istream& _stream, MessageBoxStyle& _value)
+ {
+ std::string value;
+ _stream >> value;
+ _value = parse(value);
+ return _stream;
+ }
+
+ // âîçâðàùàåò èíäåêñ èêîíêè
+ size_t getIconIndex()
+ {
+ size_t index = 0;
+ int num = value >> _IndexIcon1;
+
+ while (num != 0)
+ {
+ if ((num & 1) == 1)
+ return index;
+
+ ++index;
+ num >>= 1;
+ }
+
+ return ITEM_NONE;
+ }
+
+ // âîçâðàùàåò èíäåêñ èêîíêè
+ size_t getButtonIndex()
+ {
+ size_t index = 0;
+ int num = value;
+
+ while (num != 0)
+ {
+ if ((num & 1) == 1)
+ return index;
+
+ ++index;
+ num >>= 1;
+ }
+
+ return ITEM_NONE;
+ }
+
+ // âîçâðàùàåò ñïèñîê êíîïîê
+ std::vector<MessageBoxStyle> getButtons()
+ {
+ std::vector<MessageBoxStyle> buttons;
+
+ size_t index = 0;
+ int num = value;
+ while (index < _IndexIcon1)
+ {
+ if ((num & 1) == 1)
+ {
+ buttons.push_back(MessageBoxStyle::Enum( MYGUI_FLAG(index)));
+ }
+
+ ++index;
+ num >>= 1;
+ }
+
+ return buttons;
+ }
+
+ typedef std::map<std::string, int> MapAlign;
+
+ static MessageBoxStyle parse(const std::string& _value)
+ {
+ MessageBoxStyle result(MessageBoxStyle::Enum(0));
+ const MapAlign& map_names = result.getValueNames();
+ const std::vector<std::string>& vec = utility::split(_value);
+ for (size_t pos = 0; pos < vec.size(); pos++)
+ {
+ MapAlign::const_iterator iter = map_names.find(vec[pos]);
+ if (iter != map_names.end())
+ {
+ result.value = Enum(int(result.value) | int(iter->second));
+ }
+ else
+ {
+ MYGUI_LOG(Warning, "Cannot parse type '" << vec[pos] << "'");
+ }
+ }
+ return result;
+ }
+
+ private:
+ const MapAlign& getValueNames()
+ {
+ static MapAlign map_names;
+
+ if (map_names.empty())
+ {
+ MYGUI_REGISTER_VALUE(map_names, None);
+ MYGUI_REGISTER_VALUE(map_names, Ok);
+ MYGUI_REGISTER_VALUE(map_names, Yes);
+ MYGUI_REGISTER_VALUE(map_names, No);
+ MYGUI_REGISTER_VALUE(map_names, Abort);
+ MYGUI_REGISTER_VALUE(map_names, Retry);
+ MYGUI_REGISTER_VALUE(map_names, Ignore);
+ MYGUI_REGISTER_VALUE(map_names, Cancel);
+ MYGUI_REGISTER_VALUE(map_names, Try);
+ MYGUI_REGISTER_VALUE(map_names, Continue);
+
+ MYGUI_REGISTER_VALUE(map_names, Button1);
+ MYGUI_REGISTER_VALUE(map_names, Button2);
+ MYGUI_REGISTER_VALUE(map_names, Button3);
+ MYGUI_REGISTER_VALUE(map_names, Button4);
+
+ MYGUI_REGISTER_VALUE(map_names, IconDefault);
+
+ MYGUI_REGISTER_VALUE(map_names, IconInfo);
+ MYGUI_REGISTER_VALUE(map_names, IconQuest);
+ MYGUI_REGISTER_VALUE(map_names, IconError);
+ MYGUI_REGISTER_VALUE(map_names, IconWarning);
+
+ MYGUI_REGISTER_VALUE(map_names, Icon1);
+ MYGUI_REGISTER_VALUE(map_names, Icon2);
+ MYGUI_REGISTER_VALUE(map_names, Icon3);
+ MYGUI_REGISTER_VALUE(map_names, Icon4);
+ MYGUI_REGISTER_VALUE(map_names, Icon5);
+ MYGUI_REGISTER_VALUE(map_names, Icon6);
+ MYGUI_REGISTER_VALUE(map_names, Icon7);
+ MYGUI_REGISTER_VALUE(map_names, Icon8);
+ }
+
+ return map_names;
+ }
+
+ private:
+ Enum value;
+ };
+
+} // namespace MyGUI
+
+#endif // __MESSAGE_BOX_STYLE_H__
diff -Nur stuntrally.orig/source/ogre/Gui_Events.cpp stuntrally//source/ogre/Gui_Events.cpp
--- stuntrally.orig/source/ogre/Gui_Events.cpp 2011-07-31 09:08:29.000000000 +0200
+++ stuntrally//source/ogre/Gui_Events.cpp 2011-08-13 01:19:46.000000000 +0200
@@ -8,6 +8,7 @@
#include "SplitScreenManager.h"
#include <MyGUI_PointerManager.h>
+#include "MessageBox/MessageBox.h"
#include <OIS/OIS.h>
#include "../oisb/OISB.h"
#include <boost/filesystem.hpp>
@@ -740,7 +741,7 @@
TR("#{RplVersion}: ") + toStr(rpl.header.ver) + " " + toStr(rpl.header.frameSize) + "B";
if (valRplInfo2) valRplInfo2->setCaption(ss);
}
- //edRplDesc edRplName
+ //edRplDesc edRplName
}
@@ -820,17 +821,17 @@
{
if (!rplList) return;
rplList->removeAllItems(); int ii = 0; bool bFound = false;
-
- strlist li;
- PATHMANAGER::GetFolderIndex((pSet->rpl_listview == 2 ? PATHMANAGER::GetGhostsPath() : PATHMANAGER::GetReplayPath()), li, "rpl");
-
- for (strlist::iterator i = li.begin(); i != li.end(); ++i)
- if (StringUtil::endsWith(*i, ".rpl"))
- {
- String s = *i; s = StringUtil::replaceAll(s,".rpl","");
- if (pSet->rpl_listview != 1 || StringUtil::startsWith(s,pSet->track, false))
+
+ strlist li;
+ PATHMANAGER::GetFolderIndex((pSet->rpl_listview == 2 ? PATHMANAGER::GetGhostsPath() : PATHMANAGER::GetReplayPath()), li, "rpl");
+
+ for (strlist::iterator i = li.begin(); i != li.end(); ++i)
+ if (StringUtil::endsWith(*i, ".rpl"))
+ {
+ String s = *i; s = StringUtil::replaceAll(s,".rpl","");
+ if (pSet->rpl_listview != 1 || StringUtil::startsWith(s,pSet->track, false))
rplList->addItem(s);
- }
+ }
}
diff -Nur stuntrally.orig/source/ogre/OgreGame.h stuntrally//source/ogre/OgreGame.h
--- stuntrally.orig/source/ogre/OgreGame.h 2011-07-31 09:08:29.000000000 +0200
+++ stuntrally//source/ogre/OgreGame.h 2011-08-13 01:21:14.000000000 +0200
@@ -10,6 +10,7 @@
#include "CarReflection.h"
#include <MyGUI.h>
+#include "MessageBox/MessageBox.h"
#include <OgreShadowCameraSetup.h>
namespace Ogre { class SceneNode; class Root; class SceneManager; class RenderWindow; class Viewport; class Light;