Refactor and write some helpers for window
This commit is contained in:
parent
9d3d4a6c2b
commit
6d63e99f6d
|
@ -28,7 +28,9 @@ namespace openloco::ui
|
|||
uint16_t var_83E;
|
||||
uint8_t pad_840[0x85A - 0x840];
|
||||
uint16_t var_85A;
|
||||
uint8_t pad_85C[0x886 - 0x85C];
|
||||
uint8_t pad_85C[0x882 - 0x85C];
|
||||
uint8_t type; // 0x882
|
||||
uint8_t pad_883[0x886 - 0x883];
|
||||
uint8_t colours[2];
|
||||
};
|
||||
};
|
||||
|
|
|
@ -11,6 +11,18 @@ namespace openloco::ui::windowmgr
|
|||
}
|
||||
|
||||
loco_global<uint8_t, 0x005233B6> _current_modal_type;
|
||||
loco_global_array<window, 12, 0x011370AC> _windows;
|
||||
loco_global<window *, 0x0113D754> _windows_end;
|
||||
|
||||
window * get(size_t index)
|
||||
{
|
||||
return &_windows.get()[index];
|
||||
}
|
||||
|
||||
size_t num_windows()
|
||||
{
|
||||
return ((uintptr_t)*_windows_end - (uintptr_t)_windows.get()) / sizeof(window);
|
||||
}
|
||||
|
||||
window_type current_modal_type()
|
||||
{
|
||||
|
|
|
@ -7,9 +7,11 @@ namespace openloco::ui
|
|||
{
|
||||
enum class window_type
|
||||
{
|
||||
town = 33,
|
||||
industry = 34,
|
||||
window_39 = 39,
|
||||
text_input = 51,
|
||||
load_game = 52,
|
||||
prompt_browse = 52,
|
||||
prompt_ok_cancel = 54,
|
||||
undefined = 255
|
||||
};
|
||||
|
@ -19,6 +21,8 @@ namespace openloco::ui::windowmgr
|
|||
{
|
||||
window_type current_modal_type();
|
||||
void current_modal_type(window_type type);
|
||||
window * get(size_t index);
|
||||
size_t num_windows();
|
||||
|
||||
void update();
|
||||
void resize();
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace openloco::ui::windows
|
|||
std::strcpy(_text_input_buffer, baseName.c_str());
|
||||
|
||||
sub_446A93();
|
||||
auto window = windowmgr::create_window_centred(window_type::load_game, 500, 380, 0x1202, (void *)0x004FB308);
|
||||
auto window = windowmgr::create_window_centred(window_type::prompt_browse, 500, 380, 0x1202, (void *)0x004FB308);
|
||||
if (window != nullptr)
|
||||
{
|
||||
window->widgets = (widget *)0x0050AD58;
|
||||
|
@ -81,7 +81,7 @@ namespace openloco::ui::windows
|
|||
sub_4CEB67(LOCO_GLOBAL(0x0050ADAC, int16_t) - LOCO_GLOBAL(0x0050ADAA, int16_t));
|
||||
window->colours[0] = colour::black;
|
||||
window->colours[1] = colour::saturated_green;
|
||||
windowmgr::current_modal_type(window_type::load_game);
|
||||
windowmgr::current_modal_type(window_type::prompt_browse);
|
||||
prompt_tick_loop(
|
||||
[]()
|
||||
{
|
||||
|
@ -92,7 +92,7 @@ namespace openloco::ui::windows
|
|||
windowmgr::update();
|
||||
LOCO_CALLPROC_X(0x004C98CF);
|
||||
LOCO_CALLPROC_X(0x004CF63B);
|
||||
return windowmgr::find(window_type::load_game) != nullptr;
|
||||
return windowmgr::find(window_type::prompt_browse) != nullptr;
|
||||
});
|
||||
windowmgr::current_modal_type(window_type::undefined);
|
||||
std::strcpy(szPath, _directory);
|
||||
|
|
Loading…
Reference in New Issue