Skip to content

Commit

Permalink
#5907: initial method to return a vfs::Visibility for an entity class
Browse files Browse the repository at this point in the history
Currently the method returns a constant Visibility::NORMAL since there
is no code to actually parse a visibility from the .def file.
  • Loading branch information
Matthew Mott committed Mar 29, 2022
1 parent 744efce commit 215ec29
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/ieclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "ModResource.h"

#include "imodule.h"
#include "ifilesystem.h"
#include "math/Vector4.h"

#include <vector>
Expand Down Expand Up @@ -132,6 +133,9 @@ class IEntityClass :
/// Get the parent entity class or NULL if there is no parent
virtual const IEntityClass* getParent() const = 0;

/// Get the UI visibility of this entity class
virtual vfs::Visibility getVisibility() const = 0;

/// Query whether this entity class represents a light.
virtual bool isLight() const = 0;

Expand Down
5 changes: 5 additions & 0 deletions radiantcore/eclass/EntityClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ const IEntityClass* EntityClass::getParent() const
return _parent;
}

vfs::Visibility EntityClass::getVisibility() const
{
return _visibility;
}

sigc::signal<void>& EntityClass::changedSignal()
{
return _changedSignal;
Expand Down
4 changes: 4 additions & 0 deletions radiantcore/eclass/EntityClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class EntityClass
// Parent class pointer (or NULL)
EntityClass* _parent = nullptr;

// UI visibility of this entity class
vfs::Visibility _visibility = vfs::Visibility::NORMAL;

// Should this entity type be treated as a light?
bool _isLight = false;

Expand Down Expand Up @@ -107,6 +110,7 @@ class EntityClass
// IEntityClass implementation
const std::string& getName() const override;
const IEntityClass* getParent() const override;
vfs::Visibility getVisibility() const override;
sigc::signal<void>& changedSignal() override;
bool isFixedSize() const override;
AABB getBounds() const override;
Expand Down
9 changes: 9 additions & 0 deletions test/Entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "irendersystemfactory.h"
#include "iselectable.h"
#include "iselection.h"
#include "ifilesystem.h"
#include "iundo.h"
#include "ishaders.h"
#include "icolourscheme.h"
Expand Down Expand Up @@ -1986,6 +1987,14 @@ TEST_F(EntityTest, MovePlayerStart)
EXPECT_EQ(Node_getEntity(playerStart)->getKeyValue("origin"), originalPosition) << "Origin change didn't get undone";
}

TEST_F(EntityTest, GetEClassVisibility)
{
// Normal entity with NORMAL visibility
auto eclass = GlobalEntityClassManager().findClass("info_player_start");
ASSERT_TRUE(eclass);
EXPECT_EQ(eclass->getVisibility(), vfs::Visibility::NORMAL);
}

TEST_F(EntityTest, GetAttributeValue)
{
auto eclass = GlobalEntityClassManager().findClass("attribute_type_test");
Expand Down

0 comments on commit 215ec29

Please sign in to comment.