Skip to content

Commit

Permalink
#5622: Add empty MergeMap command registration, no algorithm yet.
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed May 22, 2021
1 parent 281397c commit 2303d33
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
7 changes: 4 additions & 3 deletions install/menu.xml
Expand Up @@ -6,16 +6,17 @@
<menuItem name="open" caption="&amp;Open..." command="OpenMap" />
<menuItem name="openMapFromProject" caption="&amp;Open Map from Project..." command="OpenMapFromProject" />
<menuItem name="import" caption="&amp;Import map..." command="ImportMap" />
<menuItem name="mergeMap" caption="&amp;Merge map..." command="MergeMap" />
<menuItem name="loadprefab" caption="Import &amp;prefab..." command="LoadPrefab" />
<menuSeparator />
<menuItem name="save" caption="&amp;Save" command="SaveMap" />
<menuItem name="saveas" caption="Save &amp;as..." command="SaveMapAs" />
<menuItem name="saveCopyAs" caption="Save &amp;copy as..." command="SaveMapCopyAs" />
<menuSeparator />
<menuItem name="exportMap" caption="&amp;Export Map..." command="ExportMap" />
<menuItem name="saveSelected" caption="&amp;Export selected as Map..." command="SaveSelected" />
<menuItem name="exportMap" caption="Export Map..." command="ExportMap" />
<menuItem name="saveSelected" caption="Export selected as Map..." command="SaveSelected" />
<menuItem name="saveSelectedPrefab" caption="&amp;Export selected as Prefab..." command="SaveSelectedAsPrefab" />
<menuItem name="exportSelectedAsModel" caption="&amp;Export selected as Model..." command="ExportSelectedAsModelDialog" />
<menuItem name="exportSelectedAsModel" caption="Export selected as Model..." command="ExportSelectedAsModelDialog" />
<menuItem name="createCM" caption="Export selected as Collision Model..." command="ExportCollisionModelDialog" />
<menuItem name="saveRegion" caption="Export &amp;Region..." command="SaveRegion" />
<menuSeparator />
Expand Down
24 changes: 24 additions & 0 deletions radiantcore/map/Map.cpp
Expand Up @@ -711,6 +711,7 @@ void Map::registerCommands()
GlobalCommandSystem().addCommand("OpenMap", Map::openMap, { cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL });
GlobalCommandSystem().addCommand("OpenMapFromArchive", Map::openMapFromArchive, { cmd::ARGTYPE_STRING, cmd::ARGTYPE_STRING });
GlobalCommandSystem().addCommand("ImportMap", Map::importMap);
GlobalCommandSystem().addCommand("MergeMap", std::bind(&Map::mergeMap, this, std::placeholders::_1), { cmd::ARGTYPE_STRING | cmd::ARGTYPE_OPTIONAL });
GlobalCommandSystem().addCommand(LOAD_PREFAB_AT_CMD, std::bind(&Map::loadPrefabAt, this, std::placeholders::_1),
{ cmd::ARGTYPE_STRING, cmd::ARGTYPE_VECTOR3, cmd::ARGTYPE_INT|cmd::ARGTYPE_OPTIONAL, cmd::ARGTYPE_INT | cmd::ARGTYPE_OPTIONAL });
GlobalCommandSystem().addCommand("SaveSelectedAsPrefab", Map::saveSelectedAsPrefab);
Expand Down Expand Up @@ -923,6 +924,29 @@ void Map::exportSelected(std::ostream& out, const MapFormatPtr& format)
exporter.exportMap(GlobalSceneGraph().root(), scene::traverseSelected);
}

void Map::mergeMap(const cmd::ArgumentList& args)
{
std::string candidate;

if (!args.empty())
{
candidate = args[0].getString();
}
else
{
// No arguments passed, get the map file name to load
auto fileInfo = MapFileManager::getMapFileSelection(true, _("Select Map File to merge"), filetype::TYPE_MAP);
candidate = fileInfo.fullPath;
}

if (!os::fileOrDirExists(candidate))
{
throw cmd::ExecutionFailure(fmt::format(_("File doesn't exist: {0}"), candidate));
}


}

void Map::emitMapEvent(MapEvent ev)
{
try
Expand Down
2 changes: 2 additions & 0 deletions radiantcore/map/Map.h
Expand Up @@ -246,6 +246,8 @@ class Map :
void loadMapResourceFromPath(const std::string& path);
void loadMapResourceFromArchive(const std::string& archive, const std::string& archiveRelativePath);

void mergeMap(const cmd::ArgumentList& args);

void emitMapEvent(MapEvent ev);

void clearMapResource();
Expand Down

0 comments on commit 2303d33

Please sign in to comment.