Skip to content

Commit

Permalink
#5746: SurfaceInspector is already listening to TextureChanged messag…
Browse files Browse the repository at this point in the history
…es. CamWnd subscribes to this channel now too.
  • Loading branch information
codereader committed Sep 26, 2021
1 parent d3b22c7 commit e8a5dae
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
12 changes: 12 additions & 0 deletions radiant/camera/CamWnd.cpp
Expand Up @@ -123,6 +123,11 @@ CamWnd::CamWnd(wxWindow* parent) :

_glExtensionsInitialisedNotifier = GlobalRenderSystem().signal_extensionsInitialised().connect(
sigc::mem_fun(this, &CamWnd::onGLExtensionsInitialised));

_textureChangedHandler = GlobalRadiantCore().getMessageBus().addListener(
radiant::IMessage::Type::TextureChanged,
radiant::TypeListener<radiant::TextureChangedMessage>(
sigc::mem_fun(this, &CamWnd::handleTextureChanged)));
}

wxWindow* CamWnd::getMainWidget() const
Expand Down Expand Up @@ -242,6 +247,8 @@ void CamWnd::constructGUIComponents()

CamWnd::~CamWnd()
{
GlobalRadiantCore().getMessageBus().removeListener(_textureChangedHandler);

const wxToolBarToolBase* gridButton = getToolBarToolByLabel(_camToolbar, "drawGridButton");
auto toggleCameraGridEvent = GlobalEventManager().findEvent("ToggleCameraGrid");
toggleCameraGridEvent->disconnectToolItem(gridButton);
Expand Down Expand Up @@ -1389,6 +1396,11 @@ void CamWnd::rotateRightDiscrete()
setCameraAngles(angles);
}

void CamWnd::handleTextureChanged(radiant::TextureChangedMessage& msg)
{
queueDraw();
}

// -------------------------------------------------------------------------------

render::CamRenderer::HighlightShaders CamWnd::_shaders;
Expand Down
5 changes: 5 additions & 0 deletions radiant/camera/CamWnd.h
Expand Up @@ -27,6 +27,7 @@
#include "tools/CameraMouseToolEvent.h"
#include "render/RenderStatistics.h"
#include "render/CamRenderer.h"
#include "messages/TextureChanged.h"

const int CAMWND_MINSIZE_X = 240;
const int CAMWND_MINSIZE_Y = 200;
Expand Down Expand Up @@ -107,6 +108,8 @@ class CamWnd :

IGLFont::Ptr _glFont;

std::size_t _textureChangedHandler;

public:
// Constructor and destructor
CamWnd(wxWindow* parent);
Expand Down Expand Up @@ -253,6 +256,8 @@ class CamWnd :
// Gets called with the accumulated delta values, as buffered by wxutil::DeferredMotionDelta
void onDeferredMotionDelta(int x, int y);
void performFreeMove(int dx, int dy);

void handleTextureChanged(radiant::TextureChangedMessage& msg);
};

/**
Expand Down
11 changes: 1 addition & 10 deletions radiant/ui/UserInterfaceModule.cpp
Expand Up @@ -15,6 +15,7 @@
#include "imousetool.h"
#include "imainframe.h"
#include "ishaders.h"
#include "icameraview.h"

#include "wxutil/menu/CommandMenuItem.h"
#include "wxutil/MultiMonitor.h"
Expand Down Expand Up @@ -200,10 +201,6 @@ void UserInterfaceModule::initialiseModule(const IApplicationContext& ctx)
radiant::TypeListener<radiant::CommandExecutionFailedMessage>(
sigc::mem_fun(this, &UserInterfaceModule::handleCommandExecutionFailure)));

_textureChangedListener = GlobalRadiantCore().getMessageBus().addListener(
radiant::IMessage::Type::TextureChanged,
radiant::TypeListener<radiant::TextureChangedMessage>(UserInterfaceModule::HandleTextureChanged));

_notificationListener = GlobalRadiantCore().getMessageBus().addListener(
radiant::IMessage::Type::Notification,
radiant::TypeListener<radiant::NotificationMessage>(UserInterfaceModule::HandleNotificationMessage));
Expand Down Expand Up @@ -239,7 +236,6 @@ void UserInterfaceModule::shutdownModule()

wxTheApp->Unbind(DISPATCH_EVENT, &UserInterfaceModule::onDispatchEvent, this);

GlobalRadiantCore().getMessageBus().removeListener(_textureChangedListener);
GlobalRadiantCore().getMessageBus().removeListener(_execFailedListener);
GlobalRadiantCore().getMessageBus().removeListener(_notificationListener);

Expand Down Expand Up @@ -438,11 +434,6 @@ void UserInterfaceModule::registerUICommands()
GlobalCommandSystem().addCommand("OpenMapFromProject", ui::MapSelector::OpenMapFromProject);
}

void UserInterfaceModule::HandleTextureChanged(radiant::TextureChangedMessage& msg)
{
SurfaceInspector::update();
}

// Static module registration
module::StaticModule<UserInterfaceModule> userInterfaceModule;

Expand Down
2 changes: 0 additions & 2 deletions radiant/ui/UserInterfaceModule.h
Expand Up @@ -57,7 +57,6 @@ class UserInterfaceModule :
sigc::connection _mapEditModeChangedConn;

std::size_t _execFailedListener;
std::size_t _textureChangedListener;
std::size_t _notificationListener;

std::unique_ptr<MRUMenu> _mruMenu;
Expand Down Expand Up @@ -85,7 +84,6 @@ class UserInterfaceModule :
void refreshShadersCmd(const cmd::ArgumentList& args);

void handleCommandExecutionFailure(radiant::CommandExecutionFailedMessage& msg);
static void HandleTextureChanged(radiant::TextureChangedMessage& msg);
static void HandleNotificationMessage(radiant::NotificationMessage& msg);

void onDispatchEvent(DispatchEvent& evt);
Expand Down

0 comments on commit e8a5dae

Please sign in to comment.