Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5231: Split off the eclass colour management from the EClassManager …
…itself, as this is UI-related.
- Loading branch information
1 parent
64de2a3
commit 68b17e1
Showing
9 changed files
with
122 additions
and
40 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
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,75 @@ | ||
#pragma once | ||
|
||
#include <sigc++/functors/mem_fun.h> | ||
#include <sigc++/connection.h> | ||
#include "ieclass.h" | ||
#include "iuimanager.h" | ||
#include "wxutil/event/SingleIdleCallback.h" | ||
|
||
namespace ui | ||
{ | ||
|
||
class EntityClassColourManager : | ||
public wxutil::SingleIdleCallback | ||
{ | ||
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() | ||
{ | ||
_loadedConn.disconnect(); | ||
_reloadedConn.disconnect(); | ||
} | ||
|
||
protected: | ||
void onIdle() override | ||
{ | ||
applyColourScheme(); | ||
} | ||
|
||
private: | ||
void applyColourScheme() | ||
{ | ||
// greebo: Override the eclass colours of two special entityclasses | ||
Vector3 worlspawnColour = ColourSchemes().getColour("default_brush"); | ||
Vector3 lightColour = ColourSchemes().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(); | ||
} | ||
}; | ||
|
||
} |
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