switched from qsettings to json added editng of actors
This commit is contained in:
parent
b04fbfb5bc
commit
df27b622a0
141 changed files with 4402 additions and 5068 deletions
75
src/items/item.h
Normal file
75
src/items/item.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#pragma once
|
||||
#include <QObject>
|
||||
#include <vector>
|
||||
#include <QRandomGenerator>
|
||||
#include <QSettings>
|
||||
#include <QJsonObject>
|
||||
|
||||
#include "../actors/actor.h"
|
||||
#include "../sensors/sensor.h"
|
||||
|
||||
class ItemData
|
||||
{
|
||||
protected:
|
||||
QString name_;
|
||||
uint8_t value_;
|
||||
uint32_t itemId_;
|
||||
|
||||
public:
|
||||
|
||||
ItemData(uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0);
|
||||
|
||||
inline bool operator==(const ItemData& in) const{ return itemId_==in.itemId_; }
|
||||
inline bool operator!=(const ItemData& in) const{ return itemId_!=in.itemId_; }
|
||||
|
||||
uint32_t id() const;
|
||||
|
||||
QString getName() const;
|
||||
void setName(QString name);
|
||||
uint8_t getValue() const;
|
||||
};
|
||||
|
||||
|
||||
class Item: public QObject, public ItemData
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
std::vector< Actor* > actors_;
|
||||
bool actorsActive_ = true;
|
||||
|
||||
public:
|
||||
|
||||
static bool secondaryFlag;
|
||||
SensorStore* sensors_;
|
||||
|
||||
signals:
|
||||
|
||||
void valueChanged(uint8_t value);
|
||||
|
||||
public slots:
|
||||
|
||||
virtual void setValue(uint8_t value);
|
||||
|
||||
public:
|
||||
|
||||
Item(SensorStore* sensors = nullptr, uint32_t itemIdIn = QRandomGenerator::global()->generate(), QString name = "Item", uint8_t value = 0, QObject *parent = nullptr);
|
||||
Item(SensorStore* sensors, const ItemData& itemData, QObject *parent = nullptr);
|
||||
|
||||
std::vector< Actor* >& getActors();
|
||||
bool hasActors();
|
||||
void addActor(Actor* actor);
|
||||
bool removeActor(Actor* actor);
|
||||
bool actorsActive() const;
|
||||
void setActorsActive(bool in);
|
||||
void informValue(uint8_t value);
|
||||
void setSensorStore(SensorStore* sensors){sensors_ = sensors;}
|
||||
SensorStore* getSensorStore(){return sensors_;}
|
||||
|
||||
virtual void store(QJsonObject& json);
|
||||
virtual void load(const QJsonObject& json, const bool preserve = false);
|
||||
|
||||
virtual void store(QString subsecton, QSettings* settings);
|
||||
virtual void load(QString subsecton, QSettings* settings, bool preserve = false);
|
||||
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue