Skip to content

Commit

Permalink
#5231: Move the "Refresh Materials" command to the UI module since it…
Browse files Browse the repository at this point in the history
…'s coordinating more than one thing.

Remove PreferenceSystem dependency from material manager.
  • Loading branch information
codereader committed May 9, 2020
1 parent 77d4f04 commit 229fa4f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
19 changes: 0 additions & 19 deletions radiant/shaders/Doom3ShaderSystem.cpp
Expand Up @@ -308,20 +308,6 @@ TableDefinitionPtr Doom3ShaderSystem::getTableForName(const std::string& name)
return _library->getTableForName(name);
}

void Doom3ShaderSystem::refreshShadersCmd(const cmd::ArgumentList& args)
{
// Disable screen updates for the scope of this function
IScopedScreenUpdateBlockerPtr blocker = GlobalMainFrame().getScopedScreenUpdateBlocker(_("Processing..."), _("Loading Shaders"));

// Reload the Shadersystem, this will also trigger an
// OpenGLRenderSystem unrealise/realise sequence as the rendersystem
// is attached to this class as Observer
// We can't do this refresh() operation in a thread it seems due to context binding
refresh();

GlobalMainFrame().updateAllWindows();
}

const std::string& Doom3ShaderSystem::getName() const
{
static std::string _name(MODULE_SHADERSYSTEM);
Expand All @@ -337,7 +323,6 @@ const StringSet& Doom3ShaderSystem::getDependencies() const
_dependencies.insert(MODULE_VIRTUALFILESYSTEM);
_dependencies.insert(MODULE_XMLREGISTRY);
_dependencies.insert(MODULE_GAMEMANAGER);
_dependencies.insert(MODULE_PREFERENCESYSTEM);
}

return _dependencies;
Expand All @@ -347,10 +332,6 @@ void Doom3ShaderSystem::initialiseModule(const ApplicationContext& ctx)
{
rMessage() << getName() << "::initialiseModule called" << std::endl;

GlobalCommandSystem().addCommand("RefreshShaders",
std::bind(&Doom3ShaderSystem::refreshShadersCmd, this, std::placeholders::_1));
GlobalEventManager().addCommand("RefreshShaders", "RefreshShaders");

construct();
realise();

Expand Down
3 changes: 0 additions & 3 deletions radiant/shaders/Doom3ShaderSystem.h
Expand Up @@ -128,9 +128,6 @@ class Doom3ShaderSystem :
// For methods accessing the ShaderLibrary the parser thread must be done
void ensureDefsLoaded();

// The "Flush & Reload Shaders" command target
void refreshShadersCmd(const cmd::ArgumentList& args);

// Unloads all the existing shaders and calls activeShadersChangedNotify()
void freeShaders();

Expand Down
20 changes: 20 additions & 0 deletions radiant/ui/UserInterfaceModule.cpp
Expand Up @@ -5,6 +5,8 @@
#include "ifilter.h"
#include "iorthocontextmenu.h"
#include "ieventmanager.h"
#include "imainframe.h"
#include "ishaders.h"

#include "wxutil/menu/CommandMenuItem.h"
#include "wxutil/MultiMonitor.h"
Expand Down Expand Up @@ -129,6 +131,20 @@ void UserInterfaceModule::shutdownModule()
{
}

void UserInterfaceModule::refreshShadersCmd(const cmd::ArgumentList& args)
{
// Disable screen updates for the scope of this function
auto blocker = GlobalMainFrame().getScopedScreenUpdateBlocker(_("Processing..."), _("Loading Shaders"));

// Reload the Shadersystem, this will also trigger an
// OpenGLRenderSystem unrealise/realise sequence as the rendersystem
// is attached to this class as Observer
// We can't do this refresh() operation in a thread it seems due to context binding
GlobalMaterialManager().refresh();

GlobalMainFrame().updateAllWindows();
}

void UserInterfaceModule::registerUICommands()
{
TexTool::registerCommands();
Expand Down Expand Up @@ -157,6 +173,9 @@ void UserInterfaceModule::registerUICommands()
GlobalCommandSystem().addCommand("EntityClassTree", EClassTree::ShowDialog);
GlobalCommandSystem().addCommand("EntityList", EntityList::toggle);

GlobalCommandSystem().addCommand("RefreshShaders",
std::bind(&UserInterfaceModule::refreshShadersCmd, this, std::placeholders::_1));

// ----------------------- Bind Events ---------------------------------------

GlobalEventManager().addCommand("ProjectSettings", "ProjectSettings");
Expand All @@ -183,6 +202,7 @@ void UserInterfaceModule::registerUICommands()
GlobalEventManager().addCommand("ExportSelectedAsModelDialog", "ExportSelectedAsModelDialog");
GlobalEventManager().addCommand("EntityClassTree", "EntityClassTree");
GlobalEventManager().addCommand("EntityList", "EntityList");
GlobalEventManager().addCommand("RefreshShaders", "RefreshShaders");
}

// Static module registration
Expand Down
2 changes: 2 additions & 0 deletions radiant/ui/UserInterfaceModule.h
Expand Up @@ -2,6 +2,7 @@

#include "imodule.h"
#include "iorthocontextmenu.h"
#include "icommandsystem.h"

namespace ui
{
Expand All @@ -25,6 +26,7 @@ class UserInterfaceModule :

private:
void registerUICommands();
void refreshShadersCmd(const cmd::ArgumentList& args);
};

}

0 comments on commit 229fa4f

Please sign in to comment.