#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"
#include "brushmodule.h"
#include "brush.h"
+bool g_writeMapComments = true;
+
class NameObserver {
UniqueNames &m_names;
CopiedString m_name;
void Map_LoadFile(const char *filename)
{
+ g_map.m_name = filename;
+
+ // refresh VFS to apply new pak filtering based on mapname
+ // needed for daemon DPK VFS
+ VFS_Refresh();
+
globalOutputStream() << "Loading map from " << filename << "\n";
ScopeDisableScreenUpdates disableScreenUpdates("Processing...", "Loading Map");
Map_Free();
}
Brush_toggleFormat(i);
- g_map.m_name = filename;
Map_UpdateTitle(g_map);
+
g_map.m_resource = GlobalReferenceCache().capture(g_map.m_name.c_str());
if (format) {
format->wrongFormat = false;
Map_StartPosition();
g_currentMap = &g_map;
-
- // refresh VFS to apply new pak filtering based on mapname
- // needed for daemon DPK VFS
- VFS_Refresh();
}
class Excluder {
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)
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();
void Map_constructPreferences(PreferencesPage &page)
{
- page.appendCheckBox("", "Load last map on open", g_bLoadLastMap);
+ page.appendCheckBox("", "Load last map at startup", g_bLoadLastMap);
+ page.appendCheckBox("", "Add entity and brush number comments on map write", g_writeMapComments);
}
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));