From 5f5eea806761cd92708e9e31af7cf53919227dae Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 1 May 2011 21:06:13 +0200 Subject: [PATCH 1/8] also support SavedGames on Win32 --- radiant/mainframe.cpp | 47 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 4b580bc3..9dc8faf1 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -186,6 +186,11 @@ void VFS_Destroy() #ifdef WIN32 #include +const GUID qFOLDERID_SavedGames = {0x4C5C32FF, 0xBB9D, 0x43b0, {0xB5, 0xB4, 0x2D, 0x72, 0xE5, 0x4E, 0xAA, 0xA4}}; +#define qREFKNOWNFOLDERID GUID +#define qKF_FLAG_CREATE 0x8000 +#define qKF_FLAG_NO_ALIAS 0x1000 +static HRESULT (WINAPI *qSHGetKnownFolderPath) (qREFKNOWNFOLDERID rfid, DWORD dwFlags, HANDLE hToken, PWSTR *ppszPath); #endif void HomePaths_Realise() { @@ -220,19 +225,43 @@ void HomePaths_Realise() { StringOutputStream path(256); TCHAR mydocsdir[MAX_PATH + 1]; - if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir)) - { - path << DirectoryCleaned(mydocsdir) << "My Games/" << (prefix+1) << "/"; - // win32: only add it if it already exists - if(file_is_directory(path.c_str())) - g_qeglobals.m_userEnginePath = path.c_str(); - else - g_qeglobals.m_userEnginePath = EnginePath_get(); - } + wchar_t *mydocsdirw; + HMODULE shfolder = LoadLibrary("shfolder.dll"); + if(shfolder) + qSHGetKnownFolderPath = GetProcAddress("SHGetFolderPathA"); else + qSHGetKnownFolderPath = NULL; + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); + do { + if(qSHGetKnownFolderPath && qSHGetKnownFolderPath(qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw) == S_OK) + { + memset(mydocsdir, 0, sizeof(mydocsdir)); + wctombs(mydocsdir, mydocsdirw, sizeof(mydocsdir)-1); + CoTaskMemFree(mydocsdirw); + path << DirectoryCleaned(mydocsdir) << (prefix+1) << "/"; + if(file_is_directory(path.c_str())) + { + g_qeglobals.m_userEnginePath = path.c_str(); + break; + } + } + if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir)) + { + path << DirectoryCleaned(mydocsdir) << "My Games/" << (prefix+1) << "/"; + // win32: only add it if it already exists + if(file_is_directory(path.c_str())) + { + g_qeglobals.m_userEnginePath = path.c_str(); + break; + } + } g_qeglobals.m_userEnginePath = EnginePath_get(); } + while(0); + CoUninitialize(); + if(shfolder) + FreeLibrary(shfolder); } else #endif From 5725b104cc583bf653ce45f02d1ce6c18960963e Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 1 May 2011 21:17:23 +0200 Subject: [PATCH 2/8] improve path finding logic --- radiant/mainframe.cpp | 90 +++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 47 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index 9dc8faf1..bddb333e 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -194,60 +194,53 @@ static HRESULT (WINAPI *qSHGetKnownFolderPath) (qREFKNOWNFOLDERID rfid, DWORD dw #endif void HomePaths_Realise() { + do + { + const char* prefix = g_pGameDescription->getKeyValue("prefix"); + if(!string_empty(prefix)) + { + StringOutputStream path(256); + #if defined(__APPLE__) - const char* prefix = g_pGameDescription->getKeyValue("prefix"); - if(!string_empty(prefix)) - { - StringOutputStream path(256); - path << DirectoryCleaned(g_get_home_dir()) << "Library/Application Support" << (prefix+1) << "/"; - if(!file_is_directory(path.c_str())) - { path.clear(); - path << DirectoryCleaned(g_get_home_dir()) << prefix << "/"; - } - g_qeglobals.m_userEnginePath = path.c_str(); - Q_mkdir(g_qeglobals.m_userEnginePath.c_str()); - } - else -#elif defined(POSIX) - const char* prefix = g_pGameDescription->getKeyValue("prefix"); - if(!string_empty(prefix)) - { - StringOutputStream path(256); - path << DirectoryCleaned(g_get_home_dir()) << prefix << "/"; - g_qeglobals.m_userEnginePath = path.c_str(); - Q_mkdir(g_qeglobals.m_userEnginePath.c_str()); - } - else -#elif defined(WIN32) - const char* prefix = g_pGameDescription->getKeyValue("prefix"); - if(!string_empty(prefix)) - { - StringOutputStream path(256); - TCHAR mydocsdir[MAX_PATH + 1]; - wchar_t *mydocsdirw; - HMODULE shfolder = LoadLibrary("shfolder.dll"); - if(shfolder) - qSHGetKnownFolderPath = GetProcAddress("SHGetFolderPathA"); - else - qSHGetKnownFolderPath = NULL; - CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - do - { + path << DirectoryCleaned(g_get_home_dir()) << "Library/Application Support" << (prefix+1) << "/"; + if(file_is_directory(path.c_str())) + { + g_qeglobals.m_userEnginePath = path.c_str(); + break; + } +#endif + +#if defined(WIN32) + TCHAR mydocsdir[MAX_PATH + 1]; + wchar_t *mydocsdirw; + HMODULE shfolder = LoadLibrary("shfolder.dll"); + if(shfolder) + qSHGetKnownFolderPath = GetProcAddress("SHGetFolderPathA"); + else + qSHGetKnownFolderPath = NULL; + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); if(qSHGetKnownFolderPath && qSHGetKnownFolderPath(qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw) == S_OK) { memset(mydocsdir, 0, sizeof(mydocsdir)); wctombs(mydocsdir, mydocsdirw, sizeof(mydocsdir)-1); CoTaskMemFree(mydocsdirw); + path.clear(); path << DirectoryCleaned(mydocsdir) << (prefix+1) << "/"; if(file_is_directory(path.c_str())) { g_qeglobals.m_userEnginePath = path.c_str(); + CoUninitialize(); + FreeLibrary(shfolder); break; } } + CoUninitialize(); + if(shfolder) + FreeLibrary(shfolder); if(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, mydocsdir)) { + path.clear(); path << DirectoryCleaned(mydocsdir) << "My Games/" << (prefix+1) << "/"; // win32: only add it if it already exists if(file_is_directory(path.c_str())) @@ -256,18 +249,21 @@ void HomePaths_Realise() break; } } - g_qeglobals.m_userEnginePath = EnginePath_get(); - } - while(0); - CoUninitialize(); - if(shfolder) - FreeLibrary(shfolder); - } - else #endif - { + +#if defined(POSIX) + path.clear(); + path << DirectoryCleaned(g_get_home_dir()) << prefix << "/"; + g_qeglobals.m_userEnginePath = path.c_str(); + break; +#endif + } + g_qeglobals.m_userEnginePath = EnginePath_get(); } + while(0); + + Q_mkdir(g_qeglobals.m_userEnginePath.c_str()); { StringOutputStream path(256); From 1486221a62743455c60b097ffac607f7720dee2a Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 1 May 2011 21:26:26 +0200 Subject: [PATCH 3/8] fix compile on arch linux --- libs/memory/allocator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/memory/allocator.h b/libs/memory/allocator.h index c513d708..ebaeeb5b 100644 --- a/libs/memory/allocator.h +++ b/libs/memory/allocator.h @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define INCLUDED_MEMORY_ALLOCATOR_H #include +#include #if 0 From 5f301ec16ec3c7997380d449bdeffac07d10a572 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 1 May 2011 21:36:07 +0200 Subject: [PATCH 4/8] more includes --- contrib/bobtoolz/DPatch.h | 1 + contrib/bobtoolz/DShape.h | 1 + 2 files changed, 2 insertions(+) diff --git a/contrib/bobtoolz/DPatch.h b/contrib/bobtoolz/DPatch.h index 5a956f92..a10773d6 100644 --- a/contrib/bobtoolz/DPatch.h +++ b/contrib/bobtoolz/DPatch.h @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #define AFX_DPATCH_H__26C6B083_CE5B_420B_836B_1DDA733C04CE__INCLUDED_ #include +#include typedef struct { diff --git a/contrib/bobtoolz/DShape.h b/contrib/bobtoolz/DShape.h index 3c4ed75e..29bca7fc 100644 --- a/contrib/bobtoolz/DShape.h +++ b/contrib/bobtoolz/DShape.h @@ -28,6 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #pragma once #endif // _MSC_VER > 1000 +#include #include "mathlib.h" #include "DMap.h" class DBrush; From 1e5ac483a52ed1d72726fe74d9f5b875659a79f4 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Tue, 3 May 2011 08:09:22 +0200 Subject: [PATCH 5/8] get SHGetKnownFolderPath the right way --- radiant/mainframe.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/radiant/mainframe.cpp b/radiant/mainframe.cpp index bddb333e..d168c77d 100644 --- a/radiant/mainframe.cpp +++ b/radiant/mainframe.cpp @@ -216,11 +216,11 @@ void HomePaths_Realise() wchar_t *mydocsdirw; HMODULE shfolder = LoadLibrary("shfolder.dll"); if(shfolder) - qSHGetKnownFolderPath = GetProcAddress("SHGetFolderPathA"); + qSHGetKnownFolderPath = GetProcAddress("SHGetKnownFolderPath"); else qSHGetKnownFolderPath = NULL; CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); - if(qSHGetKnownFolderPath && qSHGetKnownFolderPath(qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw) == S_OK) + if(qSHGetKnownFolderPath && qSHGetKnownFolderPath(&qFOLDERID_SavedGames, qKF_FLAG_CREATE | qKF_FLAG_NO_ALIAS, NULL, &mydocsdirw) == S_OK) { memset(mydocsdir, 0, sizeof(mydocsdir)); wctombs(mydocsdir, mydocsdirw, sizeof(mydocsdir)-1); From 34403fc1f48245da67064faf9c22127b801b5305 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 9 May 2011 06:49:43 +0200 Subject: [PATCH 6/8] fix typo --- tools/quake3/q3map2/path_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/quake3/q3map2/path_init.c b/tools/quake3/q3map2/path_init.c index 224a518e..d55da4a9 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -109,7 +109,7 @@ char *LokiGetHomeDir( qboolean *usedot ) #ifdef __APPLE__ { - static char foo[MAX_OSPATH]; + static char foo[MAX_OS_PATH]; snprintf(foo, sizeof(foo), "%s/Library/Application Support", home); if(access(foo, X_OK) == 0) { From 5dcc40cfdb2469e8c9282f4e37565710d0b1bdcf Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sat, 14 May 2011 18:37:52 +0200 Subject: [PATCH 7/8] support more locations for pixbufloader-bmp --- install-dylibs.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install-dylibs.sh b/install-dylibs.sh index 798a7d14..9f4e3e2b 100755 --- a/install-dylibs.sh +++ b/install-dylibs.sh @@ -24,19 +24,25 @@ finkgetdeps() finkgetdeps "$INSTALLDIR/radiant.$EXE" echo Warning: this only works if only ONE version of gtk-2.0 and pango is installed -for LIB in "$MACLIBDIR"/gtk-2.0/*/loaders/libpixbufloader-bmp.so; do +LAST= +for LIB in "$MACLIBDIR"/gtk-2.0/*/loaders/libpixbufloader-bmp.so "$MACLIBDIR"/gdk-pixbuf-2.0/*/loaders/libpixbufloader-bmp.so; do + [ -f "$LIB" ] || continue LAST=$LIB done cp -L "$LAST" "$INSTALLDIR" finkgetdeps "$LAST" +LAST= for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-fc.so; do + [ -f "$LIB" ] || continue LAST=$LIB done cp -L "$LAST" "$INSTALLDIR" finkgetdeps "$LAST" +LAST= for LIB in "$MACLIBDIR"/pango/*/modules/pango-basic-x.so; do + [ -f "$LIB" ] || continue LAST=$LIB done cp -L "$LAST" "$INSTALLDIR" From 32c2fd3b6229504f780d729bbd67dc88f42614b3 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Sun, 15 May 2011 22:18:14 +0200 Subject: [PATCH 8/8] radiant: make shift-middle, and ctrl-middle also paste not only shift-ctrl-middle --- radiant/selection.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/radiant/selection.cpp b/radiant/selection.cpp index 3b477990..d2283d45 100644 --- a/radiant/selection.cpp +++ b/radiant/selection.cpp @@ -3872,7 +3872,9 @@ const ModifierFlags c_modifier_toggle_face = c_modifier_toggle | c_modifier_face const ModifierFlags c_modifier_replace_face = c_modifier_replace | c_modifier_face; const ButtonIdentifier c_button_texture = c_buttonMiddle; -const ModifierFlags c_modifier_apply_texture = c_modifierControl | c_modifierShift; +const ModifierFlags c_modifier_apply_texture1 = c_modifierControl | c_modifierShift; +const ModifierFlags c_modifier_apply_texture2 = c_modifierControl; +const ModifierFlags c_modifier_apply_texture3 = c_modifierShift; const ModifierFlags c_modifier_copy_texture = c_modifierNone; class Selector_ @@ -4094,7 +4096,7 @@ public: ConstructSelectionTest(scissored, SelectionBoxForPoint(&devicePosition[0], &m_selector.m_epsilon[0])); SelectionVolume volume(scissored); - if(modifiers == c_modifier_apply_texture) + if(modifiers == c_modifier_apply_texture1 || modifiers == c_modifier_apply_texture2 || modifiers == c_modifier_apply_texture3) { Scene_applyClosestTexture(volume); }