Sfoglia il codice sorgente

Merge pull request #1314 from seanpaultaylor/next

Makes GTK non-optional for PlatformLinux displayFileDialog.
Sean Taylor 12 anni fa
parent
commit
dff5e9f383

+ 8 - 8
gameplay/CMakeLists.txt

@@ -622,16 +622,16 @@ include_directories(
     ../external-deps/glew/include
 )
 
-option(WITH_GTK_EXTENSIONS "Add GTK extensions to GamePlay" ON)
-if(WITH_GTK_EXTENSIONS)
-   add_definitions(-DUSE_GTK_EXTENSIONS=1)
-   find_package(PkgConfig REQUIRED)
-   pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
-   include_directories(${GTK3_INCLUDE_DIRS})
-   add_definitions(${GTK3_CFLAGS_OTHER})
-endif()
+IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
 
+find_package(PkgConfig REQUIRED)
+pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
+include_directories(${GTK3_INCLUDE_DIRS})
+add_definitions(${GTK3_CFLAGS_OTHER})
 add_definitions(-D__linux__)
+
+ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+
 add_definitions(-lstdc++)
 
 add_library(gameplay STATIC

+ 0 - 23
gameplay/src/Base.h

@@ -303,29 +303,6 @@ typedef GLuint RenderBufferHandle;
 #else
     typedef unsigned int GamepadHandle;
 #endif
-
-#if defined(__QNX__) && defined(GP_USE_SOCIAL)
-    typedef void* SocialPlayerHandle;
-    typedef void* SocialAchievementHandle;
-    typedef void* SocialScoreHandle;
-    typedef void* SocialChallengeHandle;
-#elif defined(WIN32)
-    typedef unsigned long SocialPlayerHandle;
-    typedef unsigned long SocialAchievementHandle;
-    typedef unsigned long SocialScoreHandle;
-    typedef unsigned long SocialChallengeHandle;
-#elif defined(__APPLE__)
-    typedef void* SocialPlayerHandle;
-    typedef void* SocialAchievementHandle;
-    typedef void* SocialScoreHandle;
-    typedef void* SocialChallengeHandle;
-#else
-    typedef unsigned int SocialPlayerHandle;
-    typedef unsigned int SocialAchievementHandle;
-    typedef unsigned int SocialScoreHandle;
-    typedef unsigned int SocialChallengeHandle;
-#endif
-
 }
 
 /**

+ 1 - 4
gameplay/src/PlatformLinux.cpp

@@ -1676,7 +1676,6 @@ std::string Platform::displayFileDialog(size_t mode, const char* title, const ch
 {
     std::string filename="";
 
-#ifdef USE_GTK_EXTENSIONS
     if (!gtk_init_check(NULL,NULL))
         return "";
 
@@ -1694,7 +1693,6 @@ std::string Platform::displayFileDialog(size_t mode, const char* title, const ch
     GtkFileFilter *filter = gtk_file_filter_new();
     std::istringstream f(filterExtensions);
     std::string s;
-    std::string descStr = filterDescription;
     std::string extStr;
     while (std::getline(f, s, ';'))
     {
@@ -1724,7 +1722,7 @@ std::string Platform::displayFileDialog(size_t mode, const char* title, const ch
         gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), "untitled");
     }
 
-    // Finally, show the dialog
+    // Show the dialog
     if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
     {
         char *szFilename;
@@ -1737,7 +1735,6 @@ std::string Platform::displayFileDialog(size_t mode, const char* title, const ch
 
     // Since we are not using gtk_main(), this will let the dialog close
     while (gtk_events_pending ()) gtk_main_iteration ();
-#endif
 
     return filename;
 }

+ 73 - 73
gameplay/src/PlatformWindows.cpp

@@ -9,7 +9,7 @@
 #include "ScriptController.h"
 #include <GL/wglew.h>
 #include <windowsx.h>
-#include <Commdlg.h>
+#include <Commdlg.h>
 #include <shellapi.h>
 #ifdef GP_USE_GAMEPAD
 #include <XInput.h>
@@ -346,7 +346,7 @@ LRESULT CALLBACK __WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
     switch (msg)
     {
     case WM_CLOSE:
-        DestroyWindow(__hwnd);
+        exit(0);
         return 0;
 
     case WM_DESTROY:
@@ -1355,77 +1355,77 @@ bool Platform::launchURL(const char* url)
     return (r > 32);
 }
 
-std::string Platform::displayFileDialog(size_t mode, const char* title, const char* filterDescription, const char* filterExtensions, const char* initialDirectory)
-{
-    std::string filename;
-    OPENFILENAMEA ofn;
-    memset(&ofn, 0, sizeof(ofn));
-
-    // Set initial directory
-    std::string initialDirectoryStr;
-    char currentDir[256];
-    if (initialDirectory == NULL)
-    {
-        char currentDir[512];
-        GetCurrentDirectoryA(512, currentDir);
-        initialDirectoryStr = currentDir;
-    }
-    else
-    {
-        initialDirectoryStr = initialDirectory;
-    }
-
-    // Filter on extensions
-    std::istringstream f(filterExtensions);
-    std::string s;
-    unsigned int count = 0;
-    std::string descStr = filterDescription;
-    descStr += " (";
-    std::string extStr = "";
-    while (std::getline(f, s, ';'))
-    {
-        if (count > 0)
-            extStr += ";";
-        extStr += "*.";
-        extStr += s;
-        count++;
-    }
-    descStr += extStr;
-    descStr += ")";
-    char filter[1024];
-    memset(filter, 0, 1024);
-    strcpy(filter, descStr.c_str());
-    strcpy(filter + descStr.length() + 1, extStr.c_str());
-
-    char szFileName[512] = "";
-    ofn.lpstrFile = szFileName;
-    ofn.lStructSize = sizeof(ofn);
-    ofn.hwndOwner = GetForegroundWindow();
-    ofn.lpstrTitle = title;
-    ofn.lpstrFilter = filter;
-    ofn.lpstrInitialDir = initialDirectoryStr.c_str();
-    ofn.nMaxFile = 512;
-    ofn.lpstrDefExt = filter;
-
-    if (mode == FileSystem::OPEN)
-    {
-        ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
-        GetOpenFileNameA(&ofn);
-    }
-    else
-    {
-        ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
-        GetSaveFileNameA(&ofn);
-    }
-
-    filename = szFileName;
-        
-    if (initialDirectory == NULL)
-        SetCurrentDirectoryA(currentDir);
-
-    return filename;
+std::string Platform::displayFileDialog(size_t mode, const char* title, const char* filterDescription, const char* filterExtensions, const char* initialDirectory)
+{
+    std::string filename;
+    OPENFILENAMEA ofn;
+    memset(&ofn, 0, sizeof(ofn));
+
+    // Set initial directory
+    std::string initialDirectoryStr;
+    char currentDir[256];
+    if (initialDirectory == NULL)
+    {
+        char currentDir[512];
+        GetCurrentDirectoryA(512, currentDir);
+        initialDirectoryStr = currentDir;
+    }
+    else
+    {
+        initialDirectoryStr = initialDirectory;
+    }
+
+    // Filter on extensions
+    std::istringstream f(filterExtensions);
+    std::string s;
+    unsigned int count = 0;
+    std::string descStr = filterDescription;
+    descStr += " (";
+    std::string extStr = "";
+    while (std::getline(f, s, ';'))
+    {
+        if (count > 0)
+            extStr += ";";
+        extStr += "*.";
+        extStr += s;
+        count++;
+    }
+    descStr += extStr;
+    descStr += ")";
+    char filter[1024];
+    memset(filter, 0, 1024);
+    strcpy(filter, descStr.c_str());
+    strcpy(filter + descStr.length() + 1, extStr.c_str());
+
+    char szFileName[512] = "";
+    ofn.lpstrFile = szFileName;
+    ofn.lStructSize = sizeof(ofn);
+    ofn.hwndOwner = GetForegroundWindow();
+    ofn.lpstrTitle = title;
+    ofn.lpstrFilter = filter;
+    ofn.lpstrInitialDir = initialDirectoryStr.c_str();
+    ofn.nMaxFile = 512;
+    ofn.lpstrDefExt = filter;
+
+    if (mode == FileSystem::OPEN)
+    {
+        ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST;
+        GetOpenFileNameA(&ofn);
+    }
+    else
+    {
+        ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+        GetSaveFileNameA(&ofn);
+    }
+
+    filename = szFileName;
+        
+    if (initialDirectory == NULL)
+        SetCurrentDirectoryA(currentDir);
+
+    return filename;
+}
+
 }
 
-}
-
 #endif