]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - radiant/map.cpp
add an opt-out setting to not write entity and brush number comment on map write
[xonotic/netradiant.git] / radiant / map.cpp
index 06c5f48cf3a47c16a1ecd01035211bbc216f712e..6635265417918242bdac1c47494e54b3568f8a56 100644 (file)
@@ -59,6 +59,7 @@ MapModules &ReferenceAPI_getMapModules();
 #include "cmdlib.h"
 #include "stream/textfilestream.h"
 #include "os/path.h"
+#include "os/file.h"
 #include "uniquenames.h"
 #include "modulesystem/singletonmodule.h"
 #include "modulesystem/moduleregistry.h"
@@ -86,6 +87,8 @@ MapModules &ReferenceAPI_getMapModules();
 #include "brushmodule.h"
 #include "brush.h"
 
+bool g_writeMapComments = true;
+
 class NameObserver {
     UniqueNames &m_names;
     CopiedString m_name;
@@ -1214,7 +1217,7 @@ void Map_Traverse_Selected(scene::Node &root, const scene::Traversable::Walker &
 
 void Map_ExportSelected(TextOutputStream &out, const MapFormat &format)
 {
-    format.writeGraph(GlobalSceneGraph().root(), Map_Traverse_Selected, out);
+    format.writeGraph(GlobalSceneGraph().root(), Map_Traverse_Selected, out, g_writeMapComments);
 }
 
 void Map_Traverse(scene::Node &root, const scene::Traversable::Walker &walker)
@@ -1945,7 +1948,13 @@ const char *getLastMapFolderPath()
     if (g_strLastMapFolder.empty()) {
         GlobalPreferenceSystem().registerPreference("LastMapFolder", make_property_string(g_strLastMapFolder));
         if (g_strLastMapFolder.empty()) {
-            g_strLastMapFolder = g_qeglobals.m_userGamePath;
+            StringOutputStream buffer(1024);
+            buffer << getMapsPath();
+            if (!file_readable(buffer.c_str())) {
+                buffer.clear();
+                buffer << g_qeglobals.m_userGamePath.c_str() << "/";
+            }
+            g_strLastMapFolder = buffer.c_str();
         }
     }
     return g_strLastMapFolder.c_str();
@@ -2289,6 +2298,7 @@ void DoFind()
 void Map_constructPreferences(PreferencesPage &page)
 {
     page.appendCheckBox("", "Load last map on open", g_bLoadLastMap);
+    page.appendCheckBox("", "Add entity and brush number comments on map write", g_writeMapComments);
 }
 
 
@@ -2366,6 +2376,7 @@ void Map_Construct()
     GlobalPreferenceSystem().registerPreference("LastMap", make_property_string(g_strLastMap));
     GlobalPreferenceSystem().registerPreference("LoadLastMap", make_property_string(g_bLoadLastMap));
     GlobalPreferenceSystem().registerPreference("MapInfoDlg", make_property<WindowPosition_String>(g_posMapInfoWnd));
+       GlobalPreferenceSystem().registerPreference("WriteMapComments", make_property_string(g_writeMapComments));
 
     PreferencesDialog_addSettingsPreferences(makeCallbackF(Map_constructPreferences));