From ab075a98fce78612d4d905ed3dc518cd46601ded Mon Sep 17 00:00:00 2001 From: codereader Date: Mon, 27 Sep 2021 06:17:39 +0200 Subject: [PATCH] #5731: Start setting up colour schemes for the texture tool. 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. --- include/itexturetoolcolours.h | 42 +++++++++++++++ radiant/textool/TexTool.cpp | 1 + radiantcore/CMakeLists.txt | 1 + .../selection/textool/ColourSchemeManager.cpp | 52 +++++++++++++++++++ tools/msvc/DarkRadiantCore.vcxproj | 1 + tools/msvc/DarkRadiantCore.vcxproj.filters | 3 ++ tools/msvc/include.vcxproj | 1 + 7 files changed, 101 insertions(+) create mode 100644 include/itexturetoolcolours.h create mode 100644 radiantcore/selection/textool/ColourSchemeManager.cpp diff --git a/include/itexturetoolcolours.h b/include/itexturetoolcolours.h new file mode 100644 index 0000000000..937631f205 --- /dev/null +++ b/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 _reference(MODULE_TEXTOOL_COLOURSCHEME_MANAGER); + return _reference; +} diff --git a/radiant/textool/TexTool.cpp b/radiant/textool/TexTool.cpp index f06186e024..0de159559d 100644 --- a/radiant/textool/TexTool.cpp +++ b/radiant/textool/TexTool.cpp @@ -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" diff --git a/radiantcore/CMakeLists.txt b/radiantcore/CMakeLists.txt index 2260b3c480..8c961043fe 100644 --- a/radiantcore/CMakeLists.txt +++ b/radiantcore/CMakeLists.txt @@ -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 diff --git a/radiantcore/selection/textool/ColourSchemeManager.cpp b/radiantcore/selection/textool/ColourSchemeManager.cpp new file mode 100644 index 0000000000..fc2fe34294 --- /dev/null +++ b/radiantcore/selection/textool/ColourSchemeManager.cpp @@ -0,0 +1,52 @@ +#include "itexturetoolcolours.h" + +#include + +namespace textool +{ + +class ColourSchemeManager final : + public IColourSchemeManager +{ +private: + using SchemeMap = std::map; + std::map _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]; + } +}; + +} diff --git a/tools/msvc/DarkRadiantCore.vcxproj b/tools/msvc/DarkRadiantCore.vcxproj index 7783066036..a4e412a7ca 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj +++ b/tools/msvc/DarkRadiantCore.vcxproj @@ -675,6 +675,7 @@ + diff --git a/tools/msvc/DarkRadiantCore.vcxproj.filters b/tools/msvc/DarkRadiantCore.vcxproj.filters index c70025d90d..85e3eea392 100644 --- a/tools/msvc/DarkRadiantCore.vcxproj.filters +++ b/tools/msvc/DarkRadiantCore.vcxproj.filters @@ -1105,6 +1105,9 @@ src\selection\textool + + src\selection\textool + diff --git a/tools/msvc/include.vcxproj b/tools/msvc/include.vcxproj index 4499f72bb0..234e730a39 100644 --- a/tools/msvc/include.vcxproj +++ b/tools/msvc/include.vcxproj @@ -197,6 +197,7 @@ +