Use YAML files to translate MyGUI's localization tags

This commit is contained in:
Andrei Kortunov 2022-07-04 21:45:44 +04:00
parent dfea7a6d01
commit ccbb5e03fb
37 changed files with 396 additions and 125 deletions

View file

@ -1,9 +1,28 @@
#include "box.hpp"
#include <MyGUI_EditText.h>
#include <MyGUI_LanguageManager.h>
namespace Gui
{
// TODO: Since 3.4.2 MyGUI is supposed to automatically translate tags
// If the 3.4.2 become a required minimum version, the ComboBox class may be removed.
void ComboBox::setPropertyOverride(const std::string& _key, const std::string& _value)
{
#if MYGUI_VERSION >= MYGUI_DEFINE_VERSION(3,4,2)
MyGUI::ComboBox::setPropertyOverride (_key, _value);
#else
if (_key == "AddItem")
{
const std::string value = MyGUI::LanguageManager::getInstance().replaceTags(_value);
MyGUI::ComboBox::setPropertyOverride (_key, value);
}
else
{
MyGUI::ComboBox::setPropertyOverride (_key, _value);
}
#endif
}
void AutoSizedWidget::notifySizeChange (MyGUI::Widget* w)
{

View file

@ -5,11 +5,20 @@
#include <MyGUI_TextBox.h>
#include <MyGUI_EditBox.h>
#include <MyGUI_Button.h>
#include <MyGUI_ComboBox.h>
#include "fontwrapper.hpp"
namespace Gui
{
class ComboBox : public FontWrapper<MyGUI::ComboBox>
{
MYGUI_RTTI_DERIVED( ComboBox )
protected:
void setPropertyOverride(const std::string& _key, const std::string& _value) override;
};
class Button : public FontWrapper<MyGUI::Button>
{
MYGUI_RTTI_DERIVED( Button )

View file

@ -28,6 +28,7 @@ namespace Gui
MyGUI::FactoryManager::getInstance().registerFactory<Gui::NumericEditBox>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::SharedStateButton>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::WindowCaption>("Widget");
MyGUI::FactoryManager::getInstance().registerFactory<Gui::ComboBox>("Widget");
}
}