]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge branch 'illwieckz/files'
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 30 Jul 2017 04:11:48 +0000 (14:11 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 30 Jul 2017 04:13:32 +0000 (14:13 +1000)
1  2 
CMakeLists.txt
radiant/map.cpp

diff --combined CMakeLists.txt
index 0a242efc89615fe11bef945634dbd35a3df14bd9,1dbdb887ec1d2deb67ac5a88a211c640bc2eeb92..587152162741bd156a37f5600bd441cea3aa2e66
@@@ -16,6 -16,7 +16,7 @@@ set(NetRadiant_VERSION "${NetRadiant_VE
  
  file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_MAJOR" ${NetRadiant_VERSION_MAJOR})
  file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_MINOR" ${NetRadiant_VERSION_MINOR})
+ file(WRITE "${PROJECT_BINARY_DIR}/RADIANT_PATCH" ${NetRadiant_VERSION_PATCH})
  
  set(RADIANT_ABOUTMSG "Custom build" CACHE STRING "About message")
  
@@@ -68,6 -69,7 +69,7 @@@ set(GTK_NS "GTK2" CACHE STRING "GTK var
  add_definitions(-DRADIANT_VERSION="${NetRadiant_VERSION}")
  add_definitions(-DRADIANT_MAJOR_VERSION="${NetRadiant_VERSION_MAJOR}")
  add_definitions(-DRADIANT_MINOR_VERSION="${NetRadiant_VERSION_MINOR}")
+ add_definitions(-DRADIANT_PATCH_VERSION="${NetRadiant_VERSION_PATCH}")
  
  add_definitions(-DRADIANT_ABOUTMSG="${NetRadiant_ABOUT}")
  
@@@ -143,7 -145,7 +145,7 @@@ if (BUILD_RADIANT
  endif ()
  
  if (CMAKE_EXECUTABLE_SUFFIX)
 -    set(RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
 +    string(REGEX REPLACE "^[.]" "" RADIANT_EXECUTABLE ${CMAKE_EXECUTABLE_SUFFIX})
  else ()
      execute_process(
              COMMAND uname -m
diff --combined radiant/map.cpp
index bdc7841e3ae292ecf99551dfa41014498963973c,9978092e01472eb37e0841714299931c0bf30bb2..147cfa98762e7842f734be9f8fdedbc02e839b1f
@@@ -39,7 -39,6 +39,6 @@@ MapModules& ReferenceAPI_getMapModules(
  #include "ifilesystem.h"
  #include "namespace.h"
  #include "moduleobserver.h"
- #include "moduleobservers.h"
  
  #include <set>
  
@@@ -82,6 -81,7 +81,7 @@@
  #include "xywindow.h"
  #include "mainframe.h"
  #include "preferences.h"
+ #include "preferencesystem.h"
  #include "referencecache.h"
  #include "mru.h"
  #include "commands.h"
@@@ -406,29 -406,6 +406,6 @@@ float g_MinWorldCoord = -64 * 1024
  void AddRegionBrushes( void );
  void RemoveRegionBrushes( void );
  
- /* Map open/close observers */
- ModuleObservers g_mapPathObservers;
- class MapFileObserver : public ModuleObserver
- {
- void realise() {
-               // Refresh VFS to apply new pak filtering based on mapname
-               // needed for daemon dpk vfs
-               VFS_Refresh();
- }
- void unrealise() { }
- };
- MapFileObserver g_mapFileObserver;
- void BindMapFileObservers(){
-       g_mapPathObservers.attach( g_mapFileObserver );
- }
- void UnBindMapFileObservers(){
-       g_mapPathObservers.detach( g_mapFileObserver );
- }
  
  
  /*
@@@ -448,7 -425,6 +425,6 @@@ void Map_Free()
  
        g_currentMap = 0;
        Brush_unlatchPreferences();
-       g_mapPathObservers.unrealise();
  }
  
  class EntityFindByClassname : public scene::Graph::Walker
@@@ -947,6 -923,8 +923,8 @@@ ScopeTimer( const char* message 
  }
  };
  
+ CopiedString g_strLastFolder = "";
  /*
     ================
     Map_LoadFile
@@@ -957,6 -935,9 +935,9 @@@ void Map_LoadFile( const char *filenam
        globalOutputStream() << "Loading map from " << filename << "\n";
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Map" );
  
+       MRU_AddFile( filename );
+       g_strLastFolder = g_path_get_dirname( filename );
        {
                ScopeTimer timer( "map load" );
  
                        }
                        Brush_toggleFormat( i );
                        g_map.m_name = filename;
-                       g_mapPathObservers.realise();
                        Map_UpdateTitle( g_map );
                        g_map.m_resource = GlobalReferenceCache().capture( g_map.m_name.c_str() );
                        if ( format ) {
        Map_StartPosition();
  
        g_currentMap = &g_map;
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
  }
  
  class Excluder
@@@ -1205,15 -1189,16 +1189,16 @@@ void Map_RenameAbsolute( const char* ab
  
        g_map.m_resource->detach( g_map );
        GlobalReferenceCache().release( g_map.m_name.c_str() );
-       g_mapPathObservers.unrealise();
  
        g_map.m_resource = resource;
  
        g_map.m_name = absolute;
-       g_mapPathObservers.realise();
        Map_UpdateTitle( g_map );
  
        g_map.m_resource->attach( g_map );
+       // refresh VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Refresh();
  }
  
  void Map_Rename( const char* filename ){
@@@ -1248,7 -1233,6 +1233,6 @@@ void Map_New()
        //globalOutputStream() << "Map_New\n";
  
        g_map.m_name = "unnamed.map";
-       g_mapPathObservers.realise();
        Map_UpdateTitle( g_map );
  
        {
        FocusViews( g_vector3_identity, 0 );
  
        g_currentMap = &g_map;
+       // restart VFS to apply new pak filtering based on mapname
+       // needed for daemon DPK VFS
+       VFS_Restart();
  }
  
  extern void ConstructRegionBrushes( scene::Node * brushes[6], const Vector3 &region_mins, const Vector3 &region_maxs );
@@@ -1509,6 -1497,8 +1497,8 @@@ void Map_RegionBrush( void )
  bool Map_ImportFile( const char* filename ){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Loading Map" );
  
+       g_strLastFolder = g_path_get_dirname( filename );
        bool success = false;
  
        if ( extension_equal( path_get_extension( filename ), "bsp" ) ) {
@@@ -1612,7 -1602,13 +1602,13 @@@ tryDecompile
   */
  bool Map_SaveFile( const char* filename ){
        ScopeDisableScreenUpdates disableScreenUpdates( "Processing...", "Saving Map" );
-       return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       bool success = MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse, filename );
+       if ( success ) {
+               // refresh VFS to apply new pak filtering based on mapname
+               // needed for daemon DPK VFS
+               VFS_Refresh();
+       }
+       return success;
  }
  
  //
@@@ -1805,16 -1801,26 +1801,26 @@@ const char* getMapsPath()
        return g_mapsPath.c_str();
  }
  
+ const char* getLastFolderPath(){
+       if (g_strLastFolder.empty()) {
+               GlobalPreferenceSystem().registerPreference( "LastFolder", CopiedStringImportStringCaller( g_strLastFolder ), CopiedStringExportStringCaller( g_strLastFolder ) );
+               if (g_strLastFolder.empty()) {
+                       g_strLastFolder = g_qeglobals.m_userGamePath;
+               }
+       }
+       return g_strLastFolder.c_str();
+ }
  const char* map_open( const char* title ){
-       return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), true, false, false );
+       return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false );
  }
  
  const char* map_import( const char* title ){
-       return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getMapsPath(), MapFormat::Name(), false, true, false );
+       return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false );
  }
  
  const char* map_save( const char* title ){
-       return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getMapsPath(), MapFormat::Name(), false, false, true );
 -      return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), TRUE, title, getLastFolderPath(), MapFormat::Name(), false, true, false );
++      return file_dialog( GTK_WIDGET( MainFrame_getWindow() ), FALSE, title, getLastFolderPath(), MapFormat::Name(), false, false, true );
  }
  
  void OpenMap(){
  
        const char* filename = map_open( "Open Map" );
  
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
                MRU_AddFile( filename );
                Map_RegionOff();
                Map_Free();
  void ImportMap(){
        const char* filename = map_import( "Import Map" );
  
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
                UndoableCommand undo( "mapImport" );
                Map_ImportFile( filename );
        }
  bool Map_SaveAs(){
        const char* filename = map_save( "Save Map" );
  
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
+               g_strLastFolder = g_path_get_dirname( filename );
                MRU_AddFile( filename );
                Map_Rename( filename );
                return Map_Save();
@@@ -1868,7 -1875,8 +1875,8 @@@ void SaveMap()
  void ExportMap(){
        const char* filename = map_save( "Export Selection" );
  
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
+               g_strLastFolder = g_path_get_dirname( filename );
                Map_SaveSelected( filename );
        }
  }
  void SaveRegion(){
        const char* filename = map_save( "Export Region" );
  
-       if ( filename != 0 ) {
+       if ( filename != NULL ) {
+               g_strLastFolder = g_path_get_dirname( filename );
                Map_SaveRegion( filename );
        }
  }
@@@ -2171,8 -2180,6 +2180,6 @@@ void unrealise()
  
  MapModuleObserver g_MapModuleObserver;
  
- #include "preferencesystem.h"
  CopiedString g_strLastMap;
  bool g_bLoadLastMap = false;