/// \brief Read a map graph into \p root from \p outputStream, using \p entityTable to create entities.
virtual void readGraph( scene::Node& root, TextInputStream& inputStream, EntityCreator& entityTable ) const = 0;
/// \brief Write the map graph obtained by applying \p traverse to \p root into \p outputStream.
-virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream ) const = 0;
+virtual void writeGraph( scene::Node& root, GraphTraversalFunc traverse, TextOutputStream& outputStream, bool writeComments ) const = 0;
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
writer.writeToken("Version");
writer.writeInteger(MapVersion());
writer.nextLine();
- Map_Write(root, traverse, writer, false);
+ Map_Write(root, traverse, writer, false, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
writer.writeToken("Version");
writer.writeInteger(MapVersion());
writer.nextLine();
- Map_Write(root, traverse, writer, false);
+ Map_Write(root, traverse, writer, false, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
- Map_Write(root, traverse, writer, false);
+ Map_Write(root, traverse, writer, false, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
- Map_Write(root, traverse, writer, true);
+ Map_Write(root, traverse, writer, true, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
- Map_Write(root, traverse, writer, true);
+ Map_Write(root, traverse, writer, true, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
TokenWriter &writer = GlobalScripLibModule::getTable().m_pfnNewSimpleTokenWriter(outputStream);
- Map_Write(root, traverse, writer, true);
+ Map_Write(root, traverse, writer, true, writeComments);
writer.release();
}
};
tokeniser.release();
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
}
};
mutable Stack<bool> m_stack;
TokenWriter &m_writer;
bool m_ignorePatches;
+ bool m_writeComments;
public:
- WriteTokensWalker(TokenWriter &writer, bool ignorePatches)
- : m_writer(writer), m_ignorePatches(ignorePatches)
+ WriteTokensWalker(TokenWriter &writer, bool ignorePatches, bool writeComments)
+ : m_writer(writer), m_ignorePatches(ignorePatches), m_writeComments(writeComments)
{
}
Entity *entity = Node_getEntity(node);
if (entity != 0) {
- m_writer.writeToken("//");
- m_writer.writeToken("entity");
- m_writer.writeUnsigned(g_count_entities++);
- m_writer.nextLine();
+ if (m_writeComments) {
+ m_writer.writeToken("//");
+ m_writer.writeToken("entity");
+ m_writer.writeUnsigned(g_count_entities++);
+ m_writer.nextLine();
+ }
m_writer.writeToken("{");
m_writer.nextLine();
MapExporter *exporter = Node_getMapExporter(node);
if (exporter != 0
&& !(m_ignorePatches && Node_isPatch(node))) {
- m_writer.writeToken("//");
- m_writer.writeToken("brush");
- m_writer.writeUnsigned(g_count_brushes++);
- m_writer.nextLine();
+ if (m_writeComments) {
+ m_writer.writeToken("//");
+ m_writer.writeToken("brush");
+ m_writer.writeUnsigned(g_count_brushes++);
+ m_writer.nextLine();
+ }
exporter->exportTokens(m_writer);
}
}
};
-void Map_Write(scene::Node &root, GraphTraversalFunc traverse, TokenWriter &writer, bool ignorePatches)
+void Map_Write(scene::Node &root, GraphTraversalFunc traverse, TokenWriter &writer, bool ignorePatches, bool writeComments)
{
g_count_entities = 0;
- traverse(root, WriteTokensWalker(writer, ignorePatches));
+ traverse(root, WriteTokensWalker(writer, ignorePatches, writeComments));
}
#include "imap.h"
-void Map_Write(scene::Node &root, GraphTraversalFunc traverse, TokenWriter &writer, bool ignorePatches);
+void Map_Write(scene::Node &root, GraphTraversalFunc traverse, TokenWriter &writer, bool ignorePatches, bool writeComments);
#endif
Map_Read(root, inputStream, entityTable);
}
- void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream) const
+ void writeGraph(scene::Node &root, GraphTraversalFunc traverse, TextOutputStream &outputStream, bool writeComments) const
{
Map_Write(root, traverse, outputStream);
}
#include "brushmodule.h"
#include "brush.h"
+bool g_writeMapComments = true;
+
class NameObserver {
UniqueNames &m_names;
CopiedString m_name;
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)
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);
}
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));
#include "map.h"
#include "filetypes.h"
+extern bool g_writeMapComments;
bool References_Saved();
if (!file.failed()) {
globalOutputStream() << "success\n";
ScopeDisableScreenUpdates disableScreenUpdates(path_get_filename_start(filename), "Saving Map");
- format.writeGraph(root, traverse, file);
+ format.writeGraph(root, traverse, file, g_writeMapComments);
return true;
}