Merge commit '0112f70c05ddfb9c91dacb0829594ab2f285c248' into dotnet7
This commit is contained in:
@@ -11,7 +11,7 @@ typedef struct AAsset AAsset;
|
||||
/// <summary>
|
||||
/// Android platform file object implementation.
|
||||
/// </summary>
|
||||
class AndroidFile : public UnixFile
|
||||
class FLAXENGINE_API AndroidFile : public UnixFile
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Thread object for Android platform.
|
||||
/// </summary>
|
||||
class AndroidThread : public UnixThread
|
||||
class FLAXENGINE_API AndroidThread : public UnixThread
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Implementation of the window class for Android platform.
|
||||
/// </summary>
|
||||
class AndroidWindow : public WindowBase
|
||||
class FLAXENGINE_API AndroidWindow : public WindowBase
|
||||
{
|
||||
friend AndroidPlatform;
|
||||
public:
|
||||
|
||||
@@ -30,7 +30,6 @@ bool LinuxFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringView&
|
||||
const StringAsANSI<> initialDirectoryAnsi(*initialDirectory, initialDirectory.Length());
|
||||
const StringAsANSI<> titleAnsi(*title, title.Length());
|
||||
const char* initDir = initialDirectory.HasChars() ? initialDirectoryAnsi.Get() : ".";
|
||||
char cmd[2048];
|
||||
String xdgCurrentDesktop;
|
||||
StringBuilder fileFilter;
|
||||
Array<String> fileFilterEntries;
|
||||
@@ -39,6 +38,7 @@ bool LinuxFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringView&
|
||||
|
||||
const bool zenitySupported = FileSystem::FileExists(TEXT("/usr/bin/zenity"));
|
||||
const bool kdialogSupported = FileSystem::FileExists(TEXT("/usr/bin/kdialog"));
|
||||
char cmd[2048];
|
||||
if (zenitySupported && (xdgCurrentDesktop != TEXT("KDE") || !kdialogSupported)) // Prefer kdialog when running on KDE
|
||||
{
|
||||
for (int32 i = 1; i < fileFilterEntries.Count(); i += 2)
|
||||
@@ -87,6 +87,51 @@ bool LinuxFileSystem::ShowOpenFileDialog(Window* parentWindow, const StringView&
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LinuxFileSystem::ShowBrowseFolderDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& title, String& path)
|
||||
{
|
||||
const StringAsANSI<> titleAnsi(*title, title.Length());
|
||||
String xdgCurrentDesktop;
|
||||
Platform::GetEnvironmentVariable(TEXT("XDG_CURRENT_DESKTOP"), xdgCurrentDesktop);
|
||||
|
||||
// TODO: support initialDirectory
|
||||
|
||||
const bool zenitySupported = FileSystem::FileExists(TEXT("/usr/bin/zenity"));
|
||||
const bool kdialogSupported = FileSystem::FileExists(TEXT("/usr/bin/kdialog"));
|
||||
char cmd[2048];
|
||||
if (zenitySupported && (xdgCurrentDesktop != TEXT("KDE") || !kdialogSupported)) // Prefer kdialog when running on KDE
|
||||
{
|
||||
sprintf(cmd, "/usr/bin/zenity --modal --file-selection --directory --title=\"%s\" ", titleAnsi.Get());
|
||||
}
|
||||
else if (kdialogSupported)
|
||||
{
|
||||
sprintf(cmd, "/usr/bin/kdialog --getexistingdirectory --title \"%s\" ", titleAnsi.Get());
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG(Error, "Missing file picker (install zenity or kdialog).");
|
||||
return true;
|
||||
}
|
||||
FILE* f = popen(cmd, "r");
|
||||
char buf[2048];
|
||||
fgets(buf, ARRAY_COUNT(buf), f);
|
||||
int result = pclose(f);
|
||||
if (result != 0)
|
||||
return true;
|
||||
|
||||
const char* c = buf;
|
||||
while (*c)
|
||||
{
|
||||
const char* start = c;
|
||||
while (*c != '\n')
|
||||
c++;
|
||||
path = String(start, (int32)(c - start));
|
||||
if (path.HasChars())
|
||||
break;
|
||||
c++;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool LinuxFileSystem::ShowFileExplorer(const StringView& path)
|
||||
{
|
||||
const StringAsANSI<> pathAnsi(*path, path.Length());
|
||||
|
||||
@@ -15,6 +15,7 @@ public:
|
||||
|
||||
// [FileSystemBase]
|
||||
static bool ShowOpenFileDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& filter, bool multiSelect, const StringView& title, Array<String, HeapAllocation>& filenames);
|
||||
static bool ShowBrowseFolderDialog(Window* parentWindow, const StringView& initialDirectory, const StringView& title, String& path);
|
||||
static bool ShowFileExplorer(const StringView& path);
|
||||
static bool CreateDirectory(const StringView& path);
|
||||
static bool DeleteDirectory(const String& path, bool deleteContents = true);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define LINUXINPUT_MAX_GAMEPAD_EVENTS_PER_FRAME 32
|
||||
#define TRIGGER_THRESHOLD 1000
|
||||
|
||||
class LinuxGamepad : public Gamepad
|
||||
class FLAXENGINE_API LinuxGamepad : public Gamepad
|
||||
{
|
||||
public:
|
||||
int fd;
|
||||
|
||||
@@ -2759,6 +2759,30 @@ Window* LinuxPlatform::CreateWindow(const CreateWindowSettings& settings)
|
||||
return New<LinuxWindow>(settings);
|
||||
}
|
||||
|
||||
extern char **environ;
|
||||
|
||||
void LinuxPlatform::GetEnvironmentVariables(Dictionary<String, String, HeapAllocation>& result)
|
||||
{
|
||||
char **s = environ;
|
||||
for (; *s; s++)
|
||||
{
|
||||
char* var = *s;
|
||||
int32 split = -1;
|
||||
for (int32 i = 0; var[i]; i++)
|
||||
{
|
||||
if (var[i] == '=')
|
||||
{
|
||||
split = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (split == -1)
|
||||
result[String(var)] = String::Empty;
|
||||
else
|
||||
result[String(var, split)] = String(var + split + 1);
|
||||
}
|
||||
}
|
||||
|
||||
bool LinuxPlatform::GetEnvironmentVariable(const String& name, String& value)
|
||||
{
|
||||
char* env = getenv(StringAsANSI<>(*name).Get());
|
||||
|
||||
@@ -131,6 +131,7 @@ public:
|
||||
static String GetWorkingDirectory();
|
||||
static bool SetWorkingDirectory(const String& path);
|
||||
static Window* CreateWindow(const CreateWindowSettings& settings);
|
||||
static void GetEnvironmentVariables(Dictionary<String, String, HeapAllocation>& result);
|
||||
static bool GetEnvironmentVariable(const String& name, String& value);
|
||||
static bool SetEnvironmentVariable(const String& name, const String& value);
|
||||
static int32 StartProcess(const StringView& filename, const StringView& args, const StringView& workingDir, bool hiddenWindow = false, bool waitForEnd = false);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Thread object for Linux platform.
|
||||
/// </summary>
|
||||
class LinuxThread : public UnixThread
|
||||
class FLAXENGINE_API LinuxThread : public UnixThread
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Implementation of the window class for Linux platform.
|
||||
/// </summary>
|
||||
class LinuxWindow : public WindowBase
|
||||
class FLAXENGINE_API LinuxWindow : public WindowBase
|
||||
{
|
||||
friend LinuxPlatform;
|
||||
public:
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Thread object for Mac platform.
|
||||
/// </summary>
|
||||
class MacThread : public UnixThread
|
||||
class FLAXENGINE_API MacThread : public UnixThread
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Implementation of the window class for Mac platform.
|
||||
/// </summary>
|
||||
class MacWindow : public WindowBase
|
||||
class FLAXENGINE_API MacWindow : public WindowBase
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
/// <summary>
|
||||
/// Implementation of the window class for Universal Windows Platform (UWP)
|
||||
/// </summary>
|
||||
class UWPWindow : public WindowBase
|
||||
class FLAXENGINE_API UWPWindow : public WindowBase
|
||||
{
|
||||
friend UWPPlatform;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// <summary>
|
||||
/// Unix platform file object implementation.
|
||||
/// </summary>
|
||||
class UnixFile : public FileBase
|
||||
class FLAXENGINE_API UnixFile : public FileBase
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/// <summary>
|
||||
/// Thread object for Unix platform.
|
||||
/// </summary>
|
||||
class UnixThread : public ThreadBase
|
||||
class FLAXENGINE_API UnixThread : public ThreadBase
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// <summary>
|
||||
/// Win32 platform file object implementation
|
||||
/// </summary>
|
||||
class Win32File : public FileBase
|
||||
class FLAXENGINE_API Win32File : public FileBase
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/// <summary>
|
||||
/// Thread object for Win32 platform.
|
||||
/// </summary>
|
||||
class Win32Thread : public ThreadBase
|
||||
class FLAXENGINE_API Win32Thread : public ThreadBase
|
||||
{
|
||||
private:
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/// <summary>
|
||||
/// Implementation of the window class for Windows platform
|
||||
/// </summary>
|
||||
class WindowsWindow : public WindowBase
|
||||
class FLAXENGINE_API WindowsWindow : public WindowBase
|
||||
#if USE_EDITOR
|
||||
, public Windows::IDropTarget
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user