Коммит 0f93912a создал по автору xottab-duty's avatar xottab-duty
Просмотр файлов

Reworked UI style manager scripting abilities

владелец 6b9e84ce
......@@ -60,15 +60,10 @@ SCRIPT_EXPORT(UIStyleManager, (),
.def("GetAllStyles", &UIStyleManager::GetToken, return_stl_iterator())
.def("DefaultStyleIsSet", &UIStyleManager::DefaultStyleIsSet)
.def("GetCurrentStyleId", &UIStyleManager::GetCurrentStyleId)
.def("SetStyle", &UIStyleManager::SetupStyle)
.def("SetStyle", +[](UIStyleManager* self, u32 styleID, bool reloadUI)
{
self->SetupStyle(styleID);
if (reloadUI)
self->Reset();
}),
.def("GetCurrentStyleName", &UIStyleManager::GetCurrentStyleName)
.def("SetStyle", &UIStyleManager::SetStyle)
.def("SetupStyle", &UIStyleManager::SetupStyle)
.def("ResetUI", &UIStyleManager::Reset),
def("GetUIStyleManager", +[] { return UIStyles; })
];
......
......@@ -103,3 +103,29 @@ void UIStyleManager::Reset()
if (shouldHideMainMenu)
g_pGamePersistent->m_pMainMenu->Activate(false);
}
bool UIStyleManager::SetStyle(pcstr name, bool reloadUI)
{
for (const auto& token : m_token)
{
if (0 == xr_strcmp(token.name, name))
{
SetupStyle(token.id);
if (reloadUI)
Reset();
return true;
}
}
return false;
}
pcstr UIStyleManager::GetCurrentStyleName() const
{
for (const auto& token : m_token)
{
if (token.id == m_style_id)
return token.name;
}
VERIFY(!"Could retrieve current style name!");
return nullptr;
}
......@@ -11,6 +11,11 @@ public:
void SetupStyle(u32 styleID);
void Reset();
bool SetStyle(pcstr name, bool reloadUI);
[[nodiscard]]
pcstr GetCurrentStyleName() const;
[[nodiscard]]
auto GetCurrentStyleId() const
{
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать