Adds initial intermediate qt6 porting state
This commit is contained in:
11247 files changed
+1891537
No files matched your search
Executable
+201
@@ -0,0 +1,201 @@
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
|
||||
|
||||
#include <NGLLogger/NGLLoggerBootstrap.h>
|
||||
|
||||
#include <QXmlStreamReader>
|
||||
#include <QVector>
|
||||
#include <QUrl>
|
||||
|
||||
namespace BuildingControlUnit
|
||||
{
|
||||
|
||||
class HandelEffect;
|
||||
|
||||
enum EffectType
|
||||
{
|
||||
|
||||
ET_Unset = 0,
|
||||
ET_Relay = 1,
|
||||
ET_BackgroundSound = 2,
|
||||
ET_BsmFlash = 3,
|
||||
};
|
||||
|
||||
enum EffectOverride
|
||||
{
|
||||
EO_Auto = -1,
|
||||
EO_Off = 0,
|
||||
EO_On = 1,
|
||||
};
|
||||
|
||||
enum ActionType
|
||||
{
|
||||
AT_Off = 0,
|
||||
AT_On = 1,
|
||||
AT_Infinite = 2,
|
||||
AT_Flash = 3
|
||||
};
|
||||
|
||||
enum ActionClass
|
||||
{
|
||||
AC_Unset,
|
||||
AC_Standard,
|
||||
AC_Repeat,
|
||||
AC_Pause,
|
||||
AC_Bsm
|
||||
};
|
||||
|
||||
enum Category
|
||||
{
|
||||
CT_Default = 0,
|
||||
CT_BGS_Bahnhof = 1,
|
||||
CT_BGS_Personen = 2,
|
||||
CT_BGS_Sonstige = 3,
|
||||
CT_BGS_Stadt = 4,
|
||||
CT_BGS_Testsounds = 5,
|
||||
CT_BGS_Aircrafts = 6,
|
||||
CT_BGS_Battlefields = 7,
|
||||
CT_BGS_Boats = 8,
|
||||
CT_BGS_Explosions = 9,
|
||||
CT_BGS_Helicopter = 10,
|
||||
CT_BGS_Motors_and_urban_traffic = 11,
|
||||
CT_BGS_InsideBuildings = 12,
|
||||
CT_BGS_Vehicles = 13
|
||||
|
||||
};
|
||||
|
||||
class Action
|
||||
{
|
||||
public:
|
||||
Action(ActionClass ac = AC_Unset)
|
||||
: aclass(ac)
|
||||
{}
|
||||
|
||||
ActionClass aclass = AC_Unset;
|
||||
ActionType atype = AT_Off;
|
||||
QUrl url;
|
||||
QString comment;
|
||||
};
|
||||
|
||||
class RepeatAction : public Action
|
||||
{
|
||||
public:
|
||||
RepeatAction()
|
||||
: Action(AC_Repeat)
|
||||
{}
|
||||
|
||||
|
||||
int count = -1;
|
||||
QVector<Action *> actions;
|
||||
};
|
||||
|
||||
class PauseAction : public Action
|
||||
{
|
||||
public:
|
||||
PauseAction()
|
||||
: Action(AC_Pause)
|
||||
{}
|
||||
|
||||
int pause = 0;
|
||||
};
|
||||
|
||||
class BsmAction : public Action
|
||||
{
|
||||
public:
|
||||
bool isNull() const { return (count == 0 && pause == 0 && pulses == 0); }
|
||||
int count = 0;
|
||||
int pause = 0;
|
||||
int choplength = 0;
|
||||
int pulses = 0;
|
||||
int pulseduration = 0;
|
||||
BsmAction() : Action(AC_Bsm) {}
|
||||
};
|
||||
|
||||
class Range
|
||||
{
|
||||
public:
|
||||
inline bool fits(int value) const { return (min <= value && value <= max); }
|
||||
|
||||
int min = 0;
|
||||
int max = 100;
|
||||
bool restartOnChange = false;
|
||||
QVector<Action *> actions;
|
||||
};
|
||||
|
||||
class Effect
|
||||
{
|
||||
public:
|
||||
|
||||
Range* getRangeByDamagePercent(int damagePercent) const;
|
||||
|
||||
EffectType effectType = ET_Unset;
|
||||
Category category = CT_Default;
|
||||
int id = 0;
|
||||
QString name;
|
||||
QVector<Range *> ranges;
|
||||
HandelEffect *effectHandler = nullptr;
|
||||
EffectOverride override = EO_Auto;
|
||||
|
||||
const QVector<Range *> constRanges() const { return ranges; }
|
||||
};
|
||||
|
||||
struct XmlContents
|
||||
{
|
||||
QVector<Effect *> effects;
|
||||
int hitSoundVolume = 50;
|
||||
|
||||
int bgSoundVolume = 50;
|
||||
QString username;
|
||||
QString password;
|
||||
int port = 80;
|
||||
int updateRelayState = 1000;
|
||||
|
||||
const QVector<Effect *> constEffects() const { return effects; }
|
||||
|
||||
QString toString() const
|
||||
{
|
||||
QString str(QStringLiteral("User: %1, Password: %2, Port: %3, BGSound Vol: %4, HitSound Vol: %5, No of Effects: %6"));
|
||||
return str.arg(username, password).arg(port).arg(bgSoundVolume).arg(hitSoundVolume).arg(effects.count());
|
||||
}
|
||||
};
|
||||
|
||||
class XmlReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit XmlReader(QObject *parent = nullptr);
|
||||
~XmlReader() = default;
|
||||
|
||||
static QUrl createPreparedUrl(const XmlContents &contents, const QString &hostname = QString());
|
||||
|
||||
bool init(const QString &effectConfigFile);
|
||||
XmlContents contents() const { return m_contents; }
|
||||
|
||||
private:
|
||||
void createHttpRequests();
|
||||
static QString categoryName(Category c);
|
||||
|
||||
Effect *parseEffect(QXmlStreamReader &xml);
|
||||
Range *parseRange(QXmlStreamReader &xml);
|
||||
Action *parseAction(QXmlStreamReader &xml);
|
||||
PauseAction *parsePauseAction(QXmlStreamReader &xml);
|
||||
RepeatAction *parseRepeatAction(QXmlStreamReader &xml);
|
||||
BsmAction* parseBsmAction(QXmlStreamReader &xml);
|
||||
Action *parseStandardAction(QXmlStreamReader &xml);
|
||||
|
||||
void generateUrls(const Effect *e, const QVector<Action *> &actions);
|
||||
void generateUrl(const Effect *e, Action *a);
|
||||
|
||||
XmlContents m_contents;
|
||||
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user