outputmap: added parent property for client, so it can access the object the outputmap belongs to.
Dieser Commit ist enthalten in:
Ursprung
4d76dc8891
Commit
80b08cb02a
@ -89,6 +89,12 @@ SwitchTile::SwitchTile(World& world, std::string_view _id)
|
||||
m_interfaceItems.add(onValueChanged);
|
||||
}
|
||||
|
||||
void SwitchTile::addToWorld()
|
||||
{
|
||||
outputMap->parentObject.setValueInternal(shared_from_this());
|
||||
Tile::addToWorld();
|
||||
}
|
||||
|
||||
void SwitchTile::worldEvent(WorldState worldState, WorldEvent worldEvent)
|
||||
{
|
||||
Tile::worldEvent(worldState, worldEvent);
|
||||
|
||||
@ -38,6 +38,7 @@ class SwitchTile : public Tile
|
||||
CREATE_DEF(SwitchTile)
|
||||
|
||||
protected:
|
||||
void addToWorld() final;
|
||||
void worldEvent(WorldState worldState, WorldEvent worldEvent) final;
|
||||
|
||||
public:
|
||||
|
||||
@ -74,6 +74,12 @@ DecouplerRailTile::DecouplerRailTile(World& world, std::string_view _id)
|
||||
});
|
||||
}
|
||||
|
||||
void DecouplerRailTile::addToWorld()
|
||||
{
|
||||
outputMap->parentObject.setValueInternal(shared_from_this());
|
||||
StraightRailTile::addToWorld();
|
||||
}
|
||||
|
||||
void DecouplerRailTile::worldEvent(WorldState worldState, WorldEvent worldEvent)
|
||||
{
|
||||
StraightRailTile::worldEvent(worldState, worldEvent);
|
||||
|
||||
@ -40,6 +40,7 @@ class DecouplerRailTile final : public StraightRailTile
|
||||
void setState(DecouplerState value, bool skipAction = false);
|
||||
|
||||
protected:
|
||||
void addToWorld() final;
|
||||
void worldEvent(WorldState worldState, WorldEvent worldEvent) final;
|
||||
|
||||
public:
|
||||
|
||||
@ -133,6 +133,12 @@ bool SignalRailTile::reserve(const std::shared_ptr<BlockPath>& blockPath, bool d
|
||||
return true;
|
||||
}
|
||||
|
||||
void SignalRailTile::addToWorld()
|
||||
{
|
||||
outputMap->parentObject.setValueInternal(shared_from_this());
|
||||
StraightRailTile::addToWorld();
|
||||
}
|
||||
|
||||
void SignalRailTile::worldEvent(WorldState state, WorldEvent event)
|
||||
{
|
||||
StraightRailTile::worldEvent(state, event);
|
||||
|
||||
@ -46,6 +46,7 @@ class SignalRailTile : public StraightRailTile
|
||||
|
||||
SignalRailTile(World& world, std::string_view _id, TileId tileId_);
|
||||
|
||||
void addToWorld() override;
|
||||
void worldEvent(WorldState state, WorldEvent event) override;
|
||||
|
||||
void boardModified() override;
|
||||
|
||||
@ -83,6 +83,12 @@ bool TurnoutRailTile::release(bool dryRun)
|
||||
return true;
|
||||
}
|
||||
|
||||
void TurnoutRailTile::addToWorld()
|
||||
{
|
||||
outputMap->parentObject.setValueInternal(shared_from_this());
|
||||
RailTile::addToWorld();
|
||||
}
|
||||
|
||||
void TurnoutRailTile::worldEvent(WorldState state, WorldEvent event)
|
||||
{
|
||||
RailTile::worldEvent(state, event);
|
||||
|
||||
@ -40,6 +40,7 @@ class TurnoutRailTile : public RailTile
|
||||
protected:
|
||||
TurnoutRailTile(World& world, std::string_view _id, TileId tileId_, size_t connectors);
|
||||
|
||||
void addToWorld() override;
|
||||
void worldEvent(WorldState state, WorldEvent event) override;
|
||||
|
||||
bool isValidPosition(TurnoutPosition value);
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
|
||||
OutputMap::OutputMap(Object& _parent, std::string_view parentPropertyName)
|
||||
: SubObject(_parent, parentPropertyName)
|
||||
, parentObject{this, "parent", nullptr, PropertyFlags::Constant | PropertyFlags::NoStore | PropertyFlags::NoScript}
|
||||
, interface{this, "interface", nullptr, PropertyFlags::ReadWrite | PropertyFlags::Store | PropertyFlags::NoScript,
|
||||
[this](const std::shared_ptr<OutputController>& /*newValue*/)
|
||||
{
|
||||
@ -287,6 +288,8 @@ OutputMap::OutputMap(Object& _parent, std::string_view parentPropertyName)
|
||||
auto& world = getWorld(&_parent);
|
||||
const bool editable = contains(world.state.value(), WorldState::Edit);
|
||||
|
||||
m_interfaceItems.add(parentObject);
|
||||
|
||||
Attributes::addDisplayName(interface, DisplayName::Hardware::interface);
|
||||
Attributes::addEnabled(interface, editable);
|
||||
Attributes::addObjectList(interface, world.outputControllers);
|
||||
|
||||
@ -82,6 +82,7 @@ class OutputMap : public SubObject
|
||||
virtual void updateStateFromOutput();
|
||||
|
||||
public:
|
||||
ObjectProperty<Object> parentObject; // UI needs access to parent object
|
||||
ObjectProperty<OutputController> interface;
|
||||
Property<OutputChannel> channel;
|
||||
VectorProperty<uint32_t> addresses;
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren