Skip to content

Commit

Permalink
#5731: Add theme switch commands
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed Sep 27, 2021
1 parent 3fc073e commit 2cd3a94
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion radiantcore/selection/textool/ColourSchemeManager.cpp
@@ -1,7 +1,10 @@
#include "itexturetoolcolours.h"

#include <map>
#include "icommandsystem.h"
#include "itextstream.h"
#include "module/StaticModule.h"
#include "string/case_conv.h"

namespace textool
{
Expand All @@ -24,7 +27,7 @@ class ColourSchemeManager final :

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

Expand Down Expand Up @@ -62,6 +65,9 @@ class ColourSchemeManager final :
{ SchemeElement::SelectedManipulator, { 1.0f, 0.5f, 0, 1.0f} },
{ SchemeElement::ManipulatorSurface, { 1.0f, 0.2f, 0, 1.0f} },
};

GlobalCommandSystem().addCommand("SwitchTextureToolColourScheme",
sigc::mem_fun(this, &ColourSchemeManager::setColourScheme), { cmd::ARGTYPE_STRING });
}

void setActiveScheme(ColourScheme scheme) override
Expand All @@ -73,6 +79,27 @@ class ColourSchemeManager final :
{
return _schemes[_activeScheme][element];
}

private:
void setColourScheme(const cmd::ArgumentList& args)
{
if (args.size() != 1)
{
rWarning() << "Usage: SwitchTextureToolColourScheme [light|dark]" << std::endl;
return;
}

auto themeName = string::to_lower_copy(args[0].getString());

if (themeName == "dark")
{
setActiveScheme(ColourScheme::Dark);
}
else
{
setActiveScheme(ColourScheme::Light);
}
}
};

module::StaticModule<ColourSchemeManager> _textureToolColourSchemeManager;
Expand Down

0 comments on commit 2cd3a94

Please sign in to comment.