Открыть боковую панель
OpenXRay
xray-16
Коммиты
0f93912a
Коммит
0f93912a
создал
Авг 13, 2023
по автору
xottab-duty
Просмотр файлов
Reworked UI style manager scripting abilities
владелец
6b9e84ce
Изменения
3
Скрыть пробелы
Построчно
Рядом
src/xrUICore/Windows/UIWindow_script.cpp
Просмотр файла @
0f93912a
...
...
@@ -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
;
})
];
...
...
src/xrUICore/ui_styles.cpp
Просмотр файла @
0f93912a
...
...
@@ -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
;
}
src/xrUICore/ui_styles.h
Просмотр файла @
0f93912a
...
...
@@ -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.
Сначала завершите редактирование этого сообщения!
Отмена
Пожалуйста,
зарегистрируйтесь
или
войдите
чтобы прокомментировать