mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Check if platform has a file picker
This commit is contained in:
@@ -70,6 +70,11 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
STUB();
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
IPlatformUiContext* CreatePlatformUiContext()
|
||||
|
||||
@@ -250,6 +250,12 @@ namespace OpenRCT2::Ui
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
std::string dummy;
|
||||
return GetDialogApp(&dummy) != DIALOG_TYPE::NONE;
|
||||
}
|
||||
|
||||
private:
|
||||
static DIALOG_TYPE GetDialogApp(std::string* executablePath)
|
||||
{
|
||||
|
||||
@@ -197,6 +197,11 @@ namespace OpenRCT2::Ui
|
||||
return result;
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
HWND GetHWND(SDL_Window* window)
|
||||
{
|
||||
|
||||
@@ -624,6 +624,11 @@ public:
|
||||
return _platformUiContext->ShowDirectoryDialog(_window, title);
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
return _platformUiContext->HasFilePicker();
|
||||
}
|
||||
|
||||
IWindowManager* GetWindowManager() override
|
||||
{
|
||||
return _windowManager;
|
||||
|
||||
@@ -38,6 +38,8 @@ namespace OpenRCT2
|
||||
virtual void OpenURL(const std::string& url) abstract;
|
||||
virtual std::string ShowFileDialog(SDL_Window* window, const FileDialogDesc& desc) abstract;
|
||||
virtual std::string ShowDirectoryDialog(SDL_Window* window, const std::string& title) abstract;
|
||||
|
||||
virtual bool HasFilePicker() const abstract;
|
||||
};
|
||||
|
||||
std::unique_ptr<IUiContext> CreateUiContext(const std::shared_ptr<IPlatformEnvironment>& env);
|
||||
|
||||
@@ -156,6 +156,11 @@ namespace OpenRCT2::Ui
|
||||
}
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
static int32_t Execute(const std::string& command, std::string* output = nullptr)
|
||||
{
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <openrct2/ride/TrackDesign.h>
|
||||
#include <openrct2/scenario/Scenario.h>
|
||||
#include <openrct2/title/TitleScreen.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include <openrct2/util/Util.h>
|
||||
#include <openrct2/windows/Intent.h>
|
||||
#include <openrct2/world/Park.h>
|
||||
@@ -252,7 +253,8 @@ rct_window* window_loadsave_open(int32_t type, const char* defaultName, loadsave
|
||||
return nullptr;
|
||||
|
||||
// Bypass the lot?
|
||||
if (gConfigGeneral.use_native_browse_dialog)
|
||||
auto hasFilePicker = OpenRCT2::GetContext()->GetUiContext()->HasFilePicker();
|
||||
if (gConfigGeneral.use_native_browse_dialog && hasFilePicker)
|
||||
{
|
||||
if (browse(isSave, path, sizeof(path)))
|
||||
{
|
||||
@@ -273,6 +275,13 @@ rct_window* window_loadsave_open(int32_t type, const char* defaultName, loadsave
|
||||
w->min_height = WH / 2;
|
||||
w->max_width = WW * 2;
|
||||
w->max_height = WH * 2;
|
||||
|
||||
if (!hasFilePicker)
|
||||
{
|
||||
w->enabled_widgets &= ~(1 << WIDX_BROWSE);
|
||||
w->disabled_widgets |= (1 << WIDX_BROWSE);
|
||||
window_loadsave_widgets[WIDX_BROWSE].type = WWT_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
const char* pattern = getFilterPatternByType(type, isSave);
|
||||
|
||||
@@ -575,6 +575,13 @@ static void window_options_common_invalidate_before(rct_window* w)
|
||||
window_options_set_pressed_tab(w);
|
||||
|
||||
w->disabled_widgets = 0;
|
||||
auto hasFilePicker = OpenRCT2::GetContext()->GetUiContext()->HasFilePicker();
|
||||
if (!hasFilePicker)
|
||||
{
|
||||
w->enabled_widgets &= ~WIDX_ALWAYS_NATIVE_LOADSAVE;
|
||||
w->disabled_widgets |= WIDX_ALWAYS_NATIVE_LOADSAVE;
|
||||
w->widgets[WIDX_ALWAYS_NATIVE_LOADSAVE].type = WWT_EMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
static void window_options_common_invalidate_after(rct_window* w)
|
||||
|
||||
@@ -198,6 +198,11 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
delete _windowManager;
|
||||
}
|
||||
|
||||
bool HasFilePicker() const override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
std::shared_ptr<IUiContext> CreateDummyUiContext()
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace OpenRCT2
|
||||
virtual void OpenURL(const std::string& url) abstract;
|
||||
virtual std::string ShowFileDialog(const FileDialogDesc& desc) abstract;
|
||||
virtual std::string ShowDirectoryDialog(const std::string& title) abstract;
|
||||
virtual bool HasFilePicker() const abstract;
|
||||
|
||||
// Input
|
||||
virtual const CursorState* GetCursorState() abstract;
|
||||
|
||||
Reference in New Issue
Block a user