Skip to content

Commit

Permalink
Merge branch 'maint/2.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Mott committed Aug 25, 2021
2 parents 9ede377 + 1ee2c2c commit 075b3d9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 6 additions & 0 deletions debian/changelog
@@ -1,3 +1,9 @@
darkradiant (2.13.0~focal4) focal; urgency=medium

* Fix for incorrect entity/brush colours in canvas windows.

-- Matthew Mott <orbweaver3d@gmail.com> Tue, 24 Aug 2021 19:45:54 +0100

darkradiant (2.13.0~focal1) focal; urgency=medium

* New major release on all platforms.
Expand Down
11 changes: 9 additions & 2 deletions include/ieclasscolours.h
Expand Up @@ -27,8 +27,15 @@ class IColourManager :
// The colour is given in RGB values with each component in the interval [0..1].
virtual void addOverrideColour(const std::string& eclass, const Vector3& colour) = 0;

// Applies a possible colour override to the given entity class
virtual void applyColours(IEntityClass& eclass) = 0;
/**
* \brief Applies a possible colour override to the given entity class.
*
* If an override was found, the entity class's colour will be changed with
* setColour().
*
* \return true if an override was found, false otherwise.
*/
virtual bool applyColours(IEntityClass& eclass) = 0;

// Visit each override definition with the given functor
virtual void foreachOverrideColour(const std::function<void(const std::string&, const Vector3&)>& functor) = 0;
Expand Down
7 changes: 3 additions & 4 deletions radiantcore/eclass/EClassColourManager.cpp
Expand Up @@ -12,16 +12,15 @@ void EClassColourManager::addOverrideColour(const std::string& eclass, const Vec
_overrideChangedSignal.emit(eclass, false); // false ==> colour added
}

void EClassColourManager::applyColours(IEntityClass& eclass)
bool EClassColourManager::applyColours(IEntityClass& eclass)
{
auto foundOverride = _overrides.find(eclass.getName());

if (foundOverride != _overrides.end())
{
rDebug() << "Applying colour " << foundOverride->second << " to eclass " << eclass.getName() << std::endl;

eclass.setColour(foundOverride->second);
return true;
}
return false;
}

void EClassColourManager::foreachOverrideColour(
Expand Down
2 changes: 1 addition & 1 deletion radiantcore/eclass/EClassColourManager.h
Expand Up @@ -17,7 +17,7 @@ class EClassColourManager :
// IColourManager implementation

void addOverrideColour(const std::string& eclass, const Vector3& colour) override;
void applyColours(IEntityClass& eclass) override;
bool applyColours(IEntityClass& eclass) override;
void foreachOverrideColour(const std::function<void(const std::string&, const Vector3&)>& functor) override;
void removeOverrideColour(const std::string& eclass) override;
void clearOverrideColours() override;
Expand Down
4 changes: 0 additions & 4 deletions radiantcore/eclass/EClassManager.cpp
Expand Up @@ -207,12 +207,8 @@ void EClassManager::applyColours()
GlobalEclassColourManager().foreachOverrideColour([&](const std::string& eclass, const Vector3& colour)
{
auto foundEclass = _entityClasses.find(string::to_lower_copy(eclass));

if (foundEclass != _entityClasses.end())
{
rDebug() << "Applying colour " << colour << " to eclass " << eclass << std::endl;
foundEclass->second->setColour(colour);
}
});
}

Expand Down
13 changes: 8 additions & 5 deletions radiantcore/eclass/EntityClass.cpp
@@ -1,6 +1,7 @@
#include "EntityClass.h"

#include "itextstream.h"
#include "ieclasscolours.h"
#include "os/path.h"
#include "string/convert.h"

Expand Down Expand Up @@ -112,16 +113,18 @@ void EntityClass::setColour(const Vector3& colour)

void EntityClass::resetColour()
{
// An override colour which matches this exact class is final, and overrides
// everything else
if (GlobalEclassColourManager().applyColours(*this))
return;

// Look for an editor_color on this class only
const EntityClassAttribute& attr = getAttribute("editor_color", false);
if (!attr.getValue().empty())
{
return setColour(string::convert<Vector3>(attr.getValue()));
}

// If there is a parent, use its getColour() directly, rather than its
// editor_color attribute, to take into account overrides through the
// EClassColourManager
// If there is a parent, inherit its getColour() directly, which takes into
// account any EClassColourManager overrides at the parent level.
if (_parent)
return setColour(_parent->getColour());

Expand Down

0 comments on commit 075b3d9

Please sign in to comment.