Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5372: Attempt to fix brushes occasionally falling back to their blac…
…k wire shader colour
- Loading branch information
1 parent
eb63eaa
commit df3e421
Showing
11 changed files
with
114 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#include "EntityClassColourManager.h" | ||
|
||
#include <sigc++/functors/mem_fun.h> | ||
#include "ieclass.h" | ||
#include "icolourscheme.h" | ||
#include "UserInterfaceModule.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
EntityClassColourManager::EntityClassColourManager() | ||
{ | ||
_loadedConn = GlobalEntityClassManager().defsLoadedSignal().connect( | ||
sigc::mem_fun(*this, &EntityClassColourManager::onEntityDefsLoaded) | ||
); | ||
_reloadedConn = GlobalEntityClassManager().defsReloadedSignal().connect( | ||
sigc::mem_fun(*this, &EntityClassColourManager::onEntityDefsReloaded) | ||
); | ||
} | ||
|
||
EntityClassColourManager::~EntityClassColourManager() | ||
{ | ||
_loadedConn.disconnect(); | ||
_reloadedConn.disconnect(); | ||
} | ||
|
||
void EntityClassColourManager::applyColourScheme() | ||
{ | ||
// greebo: Override the eclass colours of two special entityclasses | ||
Vector3 worlspawnColour = GlobalColourSchemeManager().getColour("default_brush"); | ||
Vector3 lightColour = GlobalColourSchemeManager().getColour("light_volumes"); | ||
|
||
auto light = GlobalEntityClassManager().findClass("light"); | ||
|
||
if (light) | ||
{ | ||
light->setColour(lightColour); | ||
} | ||
|
||
auto worldspawn = GlobalEntityClassManager().findClass("worldspawn"); | ||
|
||
if (worldspawn) | ||
{ | ||
worldspawn->setColour(worlspawnColour); | ||
} | ||
} | ||
|
||
void EntityClassColourManager::onEntityDefsLoaded() | ||
{ | ||
// Signal might receive us from a worker thread | ||
GetUserInterfaceModule().dispatch([this]() | ||
{ | ||
applyColourScheme(); | ||
}); | ||
} | ||
|
||
void EntityClassColourManager::onEntityDefsReloaded() | ||
{ | ||
// Signal might receive us from a worker thread | ||
GetUserInterfaceModule().dispatch([this]() | ||
{ | ||
applyColourScheme(); | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,26 @@ | ||
#pragma once | ||
|
||
#include <sigc++/functors/mem_fun.h> | ||
#include <sigc++/connection.h> | ||
#include "ieclass.h" | ||
#include "icolourscheme.h" | ||
#include "wxutil/event/SingleIdleCallback.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
class EntityClassColourManager : | ||
public wxutil::SingleIdleCallback | ||
class EntityClassColourManager | ||
{ | ||
private: | ||
sigc::connection _loadedConn; | ||
sigc::connection _reloadedConn; | ||
|
||
public: | ||
EntityClassColourManager() | ||
{ | ||
_loadedConn = GlobalEntityClassManager().defsLoadedSignal().connect( | ||
sigc::mem_fun(*this, &EntityClassColourManager::onEntityDefsLoaded) | ||
); | ||
_reloadedConn = GlobalEntityClassManager().defsReloadedSignal().connect( | ||
sigc::mem_fun(*this, &EntityClassColourManager::onEntityDefsReloaded) | ||
); | ||
} | ||
EntityClassColourManager(); | ||
|
||
~EntityClassColourManager() | ||
{ | ||
_loadedConn.disconnect(); | ||
_reloadedConn.disconnect(); | ||
} | ||
|
||
protected: | ||
void onIdle() override | ||
{ | ||
applyColourScheme(); | ||
} | ||
~EntityClassColourManager(); | ||
|
||
private: | ||
void applyColourScheme() | ||
{ | ||
// greebo: Override the eclass colours of two special entityclasses | ||
Vector3 worlspawnColour = GlobalColourSchemeManager().getColour("default_brush"); | ||
Vector3 lightColour = GlobalColourSchemeManager().getColour("light_volumes"); | ||
|
||
auto light = GlobalEntityClassManager().findClass("light"); | ||
|
||
if (light) | ||
{ | ||
light->setColour(lightColour); | ||
} | ||
|
||
auto worldspawn = GlobalEntityClassManager().findClass("worldspawn"); | ||
|
||
if (worldspawn) | ||
{ | ||
worldspawn->setColour(worlspawnColour); | ||
} | ||
} | ||
|
||
void onEntityDefsLoaded() | ||
{ | ||
requestIdleCallback(); | ||
} | ||
|
||
void onEntityDefsReloaded() | ||
{ | ||
requestIdleCallback(); | ||
} | ||
void applyColourScheme(); | ||
|
||
void onEntityDefsLoaded(); | ||
void onEntityDefsReloaded(); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters