mirror of https://github.com/OpenRCT2/OpenRCT2.git
Refactor code to obtain resolutions. (#8215)
This commit is contained in:
parent
df768a3fad
commit
223ae74c6b
|
@ -180,7 +180,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Resolution> GetFullscreenResolutions() override
|
||||
const std::vector<Resolution>& GetFullscreenResolutions() override
|
||||
{
|
||||
UpdateFullscreenResolutions();
|
||||
return _fsResolutions;
|
||||
|
|
|
@ -449,7 +449,6 @@ static void window_options_update_height_markers();
|
|||
|
||||
#pragma region Events
|
||||
|
||||
static void window_options_close(rct_window *w);
|
||||
static void window_options_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_options_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
||||
static void window_options_dropdown(rct_window *w, rct_widgetindex widgetIndex, int32_t dropdownIndex);
|
||||
|
@ -461,7 +460,7 @@ static void window_options_text_input(rct_window *w, rct_widgetindex widgetIndex
|
|||
static void window_options_tooltip(rct_window *w, rct_widgetindex widgetIndex, rct_string_id *stringid);
|
||||
|
||||
static rct_window_event_list window_options_events = {
|
||||
window_options_close,
|
||||
nullptr,
|
||||
window_options_mouseup,
|
||||
nullptr,
|
||||
window_options_mousedown,
|
||||
|
@ -616,9 +615,6 @@ static uint64_t window_options_page_enabled_widgets[] = {
|
|||
|
||||
#pragma endregion
|
||||
|
||||
static struct Resolution* _resolutions = nullptr;
|
||||
static int32_t _numResolutions = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BAC5B
|
||||
|
@ -642,13 +638,6 @@ rct_window* window_options_open()
|
|||
return w;
|
||||
}
|
||||
|
||||
static void window_options_close(rct_window* w)
|
||||
{
|
||||
free(_resolutions);
|
||||
_resolutions = nullptr;
|
||||
_numResolutions = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006BAFCA
|
||||
|
@ -1028,26 +1017,28 @@ static void window_options_mousedown(rct_window* w, rct_widgetindex widgetIndex,
|
|||
{
|
||||
case WIDX_RESOLUTION_DROPDOWN:
|
||||
{
|
||||
_numResolutions = context_get_resolutions(&_resolutions);
|
||||
const auto& resolutions = OpenRCT2::GetContext()->GetUiContext()->GetFullscreenResolutions();
|
||||
|
||||
int32_t selectedResolution = -1;
|
||||
for (int32_t i = 0; i < _numResolutions; i++)
|
||||
for (size_t i = 0; i < resolutions.size(); i++)
|
||||
{
|
||||
struct Resolution* resolution = &_resolutions[i];
|
||||
const Resolution& resolution = resolutions[i];
|
||||
|
||||
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
|
||||
|
||||
uint16_t* args = (uint16_t*)&gDropdownItemsArgs[i];
|
||||
args[0] = STR_RESOLUTION_X_BY_Y;
|
||||
args[1] = resolution->Width;
|
||||
args[2] = resolution->Height;
|
||||
args[1] = resolution.Width;
|
||||
args[2] = resolution.Height;
|
||||
|
||||
if (resolution->Width == gConfigGeneral.fullscreen_width
|
||||
&& resolution->Height == gConfigGeneral.fullscreen_height)
|
||||
selectedResolution = i;
|
||||
if (resolution.Width == gConfigGeneral.fullscreen_width
|
||||
&& resolution.Height == gConfigGeneral.fullscreen_height)
|
||||
{
|
||||
selectedResolution = (int32_t)i;
|
||||
}
|
||||
}
|
||||
|
||||
window_options_show_dropdown(w, widget, _numResolutions);
|
||||
window_options_show_dropdown(w, widget, (int32_t)resolutions.size());
|
||||
|
||||
if (selectedResolution != -1 && selectedResolution < 32)
|
||||
{
|
||||
|
@ -1351,12 +1342,14 @@ static void window_options_dropdown(rct_window* w, rct_widgetindex widgetIndex,
|
|||
{
|
||||
case WIDX_RESOLUTION_DROPDOWN:
|
||||
{
|
||||
struct Resolution* resolution = &_resolutions[dropdownIndex];
|
||||
if (resolution->Width != gConfigGeneral.fullscreen_width
|
||||
|| resolution->Height != gConfigGeneral.fullscreen_height)
|
||||
const auto& resolutions = OpenRCT2::GetContext()->GetUiContext()->GetFullscreenResolutions();
|
||||
|
||||
const Resolution& resolution = resolutions[dropdownIndex];
|
||||
if (resolution.Width != gConfigGeneral.fullscreen_width
|
||||
|| resolution.Height != gConfigGeneral.fullscreen_height)
|
||||
{
|
||||
gConfigGeneral.fullscreen_width = resolution->Width;
|
||||
gConfigGeneral.fullscreen_height = resolution->Height;
|
||||
gConfigGeneral.fullscreen_width = resolution.Width;
|
||||
gConfigGeneral.fullscreen_height = resolution.Height;
|
||||
|
||||
if (gConfigGeneral.fullscreen_mode == static_cast<int32_t>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN))
|
||||
context_set_fullscreen_mode(static_cast<int32_t>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN));
|
||||
|
|
|
@ -1160,15 +1160,6 @@ void context_recreate_window()
|
|||
GetContext()->GetUiContext()->RecreateWindow();
|
||||
}
|
||||
|
||||
int32_t context_get_resolutions(Resolution** outResolutions)
|
||||
{
|
||||
auto resolutions = GetContext()->GetUiContext()->GetFullscreenResolutions();
|
||||
int32_t count = (int32_t)resolutions.size();
|
||||
*outResolutions = Memory::AllocateArray<Resolution>(count);
|
||||
std::copy_n(resolutions.begin(), count, *outResolutions);
|
||||
return count;
|
||||
}
|
||||
|
||||
int32_t context_get_width()
|
||||
{
|
||||
return GetContext()->GetUiContext()->GetWidth();
|
||||
|
|
|
@ -219,7 +219,6 @@ bool context_is_input_active();
|
|||
void context_trigger_resize();
|
||||
void context_set_fullscreen_mode(int32_t mode);
|
||||
void context_recreate_window();
|
||||
int32_t context_get_resolutions(struct Resolution** outResolutions);
|
||||
int32_t context_get_width();
|
||||
int32_t context_get_height();
|
||||
bool context_has_focus();
|
||||
|
|
|
@ -59,9 +59,10 @@ namespace OpenRCT2::Ui
|
|||
void SetFullscreenMode(FULLSCREEN_MODE /*mode*/) override
|
||||
{
|
||||
}
|
||||
std::vector<Resolution> GetFullscreenResolutions() override
|
||||
const std::vector<Resolution>& GetFullscreenResolutions() override
|
||||
{
|
||||
return std::vector<Resolution>();
|
||||
static std::vector<Resolution> res;
|
||||
return res;
|
||||
}
|
||||
bool HasFocus() override
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ namespace OpenRCT2
|
|||
virtual int32_t GetHeight() abstract;
|
||||
virtual int32_t GetScaleQuality() abstract;
|
||||
virtual void SetFullscreenMode(FULLSCREEN_MODE mode) abstract;
|
||||
virtual std::vector<Resolution> GetFullscreenResolutions() abstract;
|
||||
virtual const std::vector<Resolution>& GetFullscreenResolutions() abstract;
|
||||
virtual bool HasFocus() abstract;
|
||||
virtual bool IsMinimised() abstract;
|
||||
virtual bool IsSteamOverlayActive() abstract;
|
||||
|
|
Loading…
Reference in New Issue