Skip to content

Commit

Permalink
#5731: Start setting up colour schemes for the texture tool.
Browse files Browse the repository at this point in the history
Since this is supposed to be switched on a per-texture basis, I won't be tying this to the regular colour schemes used for the rest of the views.
  • Loading branch information
codereader committed Sep 27, 2021
1 parent 09d43a7 commit ab075a9
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 0 deletions.
42 changes: 42 additions & 0 deletions include/itexturetoolcolours.h
@@ -0,0 +1,42 @@
#pragma once

#include "imodule.h"
#include "render/Colour4b.h"

namespace textool
{

enum class ColourScheme
{
Light,
Dark,
Colourful,
};

enum class SchemeElement
{
MinorGrid,
MajorGrid,
};

class IColourSchemeManager :
public RegisterableModule
{
public:
virtual ~IColourSchemeManager() {}

// Activates the given scheme
virtual void setActiveScheme(ColourScheme scheme) = 0;

virtual Colour4b getColour(SchemeElement element) = 0;
};

}

constexpr const char* const MODULE_TEXTOOL_COLOURSCHEME_MANAGER("TextureToolColourSchemeManager");

inline textool::IColourSchemeManager& GlobalTextureToolColourSchemeManager()
{
static module::InstanceReference<textool::IColourSchemeManager> _reference(MODULE_TEXTOOL_COLOURSCHEME_MANAGER);
return _reference;
}
1 change: 1 addition & 0 deletions radiant/textool/TexTool.cpp
Expand Up @@ -5,6 +5,7 @@
#include "ieventmanager.h"
#include "icommandsystem.h"
#include "itexturetoolmodel.h"
#include "itexturetoolcolours.h"
#include "imainframe.h"
#include "igl.h"
#include "iundo.h"
Expand Down
1 change: 1 addition & 0 deletions radiantcore/CMakeLists.txt
Expand Up @@ -259,6 +259,7 @@ add_library(radiantcore MODULE
selection/shaderclipboard/ClosestTexturableFinder.cpp
selection/shaderclipboard/ShaderClipboard.cpp
selection/shaderclipboard/Texturable.cpp
selection/textool/ColourSchemeManager.cpp
selection/textool/FaceNode.cpp
selection/textool/Node.cpp
selection/textool/PatchNode.cpp
Expand Down
52 changes: 52 additions & 0 deletions radiantcore/selection/textool/ColourSchemeManager.cpp
@@ -0,0 +1,52 @@
#include "itexturetoolcolours.h"

#include <map>

namespace textool
{

class ColourSchemeManager final :
public IColourSchemeManager
{
private:
using SchemeMap = std::map<SchemeElement, Colour4b>;
std::map<ColourScheme, SchemeMap> _schemes;

ColourScheme _activeScheme;

public:
const std::string& getName() const override
{
static std::string _name(MODULE_TEXTOOL_COLOURSCHEME_MANAGER);
return _name;
}

const StringSet& getDependencies() const override
{
static StringSet _dependencies;
return _dependencies;
}

void initialiseModule(const IApplicationContext& ctx) override
{
_activeScheme = ColourScheme::Light;

// Fill in the default scheme values
_schemes[ColourScheme::Dark] = SchemeMap
{
{ SchemeElement::MajorGrid, { 0, 0, 0, 0 } }
};
}

void setActiveScheme(ColourScheme scheme)
{
_activeScheme = scheme;
}

Colour4b getColour(SchemeElement element)
{
return _schemes[_activeScheme][element];
}
};

}
1 change: 1 addition & 0 deletions tools/msvc/DarkRadiantCore.vcxproj
Expand Up @@ -675,6 +675,7 @@
<ClCompile Include="..\..\radiantcore\selection\textool\FaceNode.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\Node.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\PatchNode.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\ColourSchemeManager.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\TextureToolDragManipulator.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\TextureToolManipulationPivot.cpp" />
<ClCompile Include="..\..\radiantcore\selection\textool\TextureToolRotateManipulator.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc/DarkRadiantCore.vcxproj.filters
Expand Up @@ -1105,6 +1105,9 @@
<ClCompile Include="..\..\radiantcore\selection\textool\Node.cpp">
<Filter>src\selection\textool</Filter>
</ClCompile>
<ClCompile Include="..\..\radiantcore\selection\textool\ColourSchemeManager.cpp">
<Filter>src\selection\textool</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\radiantcore\modulesystem\ModuleLoader.h">
Expand Down
1 change: 1 addition & 0 deletions tools/msvc/include.vcxproj
Expand Up @@ -197,6 +197,7 @@
<ClInclude Include="..\..\include\ispacepartition.h" />
<ClInclude Include="..\..\include\ispeakernode.h" />
<ClInclude Include="..\..\include\istatusbarmanager.h" />
<ClInclude Include="..\..\include\itexturetoolcolours.h" />
<ClInclude Include="..\..\include\itextstream.h" />
<ClInclude Include="..\..\include\itexturetoolmodel.h" />
<ClInclude Include="..\..\include\itexturetoolview.h" />
Expand Down

0 comments on commit ab075a9

Please sign in to comment.