Skip to content

Commit

Permalink
#5623: Add IMap::EditMode enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed May 24, 2021
1 parent 143b6d5 commit 93fd736
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
12 changes: 12 additions & 0 deletions include/imap.h
Expand Up @@ -110,6 +110,18 @@ class IMap :
/// Returns the signal that is emitted on various events
virtual MapEventSignal signal_mapEvent() const = 0;

enum class EditMode
{
Normal,
Merge,
};

// The currently active edit mode
virtual EditMode getEditMode() = 0;

// Change the edit mode to the specified value
virtual void setEditMode(EditMode mode) = 0;

/**
* Returns the worldspawn node of this map. The worldspawn
* node is NOT created if it doesn't exist yet, so this
Expand Down
16 changes: 15 additions & 1 deletion radiantcore/map/Map.cpp
Expand Up @@ -214,6 +214,17 @@ Map::MapEventSignal Map::signal_mapEvent() const
return _mapEvent;
}

Map::EditMode Map::getEditMode()
{
return _editMode;
}

void Map::setEditMode(EditMode mode)
{
_editMode = mode;
SceneChangeNotify();
}

const scene::INodePtr& Map::getWorldspawn()
{
return _worldSpawnNode;
Expand Down Expand Up @@ -969,7 +980,10 @@ void Map::mergeMap(const cmd::ArgumentList& args)
auto result = scene::merge::GraphComparer::Compare(otherRoot, getRoot());

// Create the merge actions
auto operation = scene::merge::MergeOperation::CreateFromComparisonResult(*result);
_mergeOperation = scene::merge::MergeOperation::CreateFromComparisonResult(*result);

// Switch to merge mode
setEditMode(EditMode::Merge);
}
}
catch (const IMapResource::OperationException& ex)
Expand Down
10 changes: 10 additions & 0 deletions radiantcore/map/Map.h
Expand Up @@ -17,6 +17,7 @@

#include <sigc++/signal.h>
#include "time/StopWatch.h"
#include "scene/merge/MergeOperation.h"

class TextInputStream;

Expand All @@ -31,6 +32,9 @@ class Map :
public IMap,
public scene::Graph::Observer
{
private:
EditMode _editMode;

// The map name
std::string _mapName;

Expand Down Expand Up @@ -62,13 +66,19 @@ class Map :

std::size_t _shutdownListener;

scene::merge::MergeOperation::Ptr _mergeOperation;

private:
std::string getSaveConfirmationText() const;

public:
Map();

MapEventSignal signal_mapEvent() const override;

EditMode getEditMode() override;
void setEditMode(EditMode mode) override;

const scene::INodePtr& getWorldspawn() override;
const scene::INodePtr& findOrInsertWorldspawn() override;
scene::IMapRootNodePtr getRoot() override;
Expand Down
1 change: 0 additions & 1 deletion radiantcore/map/algorithm/Import.cpp
Expand Up @@ -18,7 +18,6 @@
#include "scenelib.h"
#include "entitylib.h"
#include "command/ExecutionFailure.h"
#include "scene/merge/GraphComparer.h"

#include "string/join.h"

Expand Down

0 comments on commit 93fd736

Please sign in to comment.