279 lines
13 KiB
C++
Executable File
279 lines
13 KiB
C++
Executable File
/**
|
|
* @RDE_HEADER@
|
|
* PDM Custom functions (extends pdmm_dtc_impl.cpp/.h)
|
|
* $Id$
|
|
* $HeadURL$
|
|
* $Author$
|
|
* Created by Iuliana Ojog, SLSE, 2016-11-26
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QHash>
|
|
#include <QJsonObject>
|
|
#include <QVector>
|
|
#include <ProjectDataManagement/pdm_dtc_impl.h>
|
|
|
|
//-------------------------------------------------------------------------------------------------------------
|
|
namespace ProjectDataManagement
|
|
{
|
|
namespace Interface
|
|
{
|
|
class DtcImplCustom final : public Interface::DtcImpl
|
|
{
|
|
|
|
enum UleisClassOffset
|
|
{
|
|
None = 0,
|
|
Grandparent = 0,
|
|
ShortTimeChild1 = 1500,
|
|
ShortTimeChild2 = 1600,
|
|
ShortTimeChild3 = 1700,
|
|
ShortTimeChild4 = 1800,
|
|
ShortTimeChild5 = 1900,
|
|
|
|
DirectImpactGrandparent = 2000,
|
|
TopAttackGrandparent = 2000,
|
|
DirectImpactChild = 3000,
|
|
TopAttackChild = 3000,
|
|
BurstOfFireParent = 4000,
|
|
BurstOfFireChild = 5000,
|
|
AirBurstParent = 6000,
|
|
AirBurstChild = 7000,
|
|
UnarmedParent = 8000,
|
|
UnarmedChild = 9000,
|
|
FireAndForgetParent = 12000,
|
|
FireAndForgetChild = 13000,
|
|
ShortTimeScanningParent = 22000,
|
|
ShortTimeScanningChild = 23000
|
|
};
|
|
|
|
Q_OBJECT
|
|
public:
|
|
explicit DtcImplCustom(const std::shared_ptr<DDSConnector::DdsConnector> &ddsConnector);
|
|
|
|
// custom procs, body must be implemented by user
|
|
// Might need a "baseChargesForGearClass" later on...
|
|
QVector<ProjectDataManagement::ChargeType> chargesForGearClass(GearClass gearClass) override;
|
|
QVector<ProjectDataManagement::IgniterType> ignitersForChargeType(int chargeTypeId) override;
|
|
QVector<ProjectDataManagement::ChargeTypeIgniterTypeIgniterFunction> igniterFunctionsForChargeTypeIgniterType(int chargeTypeId, int igniterTypeId) override;
|
|
QVector<ProjectDataManagement::LoadType> loadsForChargeType(int chargeTypeId) override;
|
|
QVector<TargetSubType> targetSubTypesForTargetType(int targetType) override;
|
|
|
|
double expansionFactor(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
double impactRadius(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
double impactEdgeLength(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isDryFire(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int mineClass(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool canBeThrown(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool canBeCreated(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isIed(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isReactivatable(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isSmart(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int maxEffectShows(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isSmoke(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isVisible(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isIndirect(int chargeTypeId) override;
|
|
int searchRadius(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool showHitline(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int remainingTasCode(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int secondaryRemainingTasCode(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int segments(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isLine(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isFromMineLayer(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isMineLaying(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
QJsonObject mineLayingPattern(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int height(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isLaserGuidable(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isUasDroppable(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isJamming(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
QVector<int> spacing(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
VolatilityType volatilityTypeId(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
int hazardDistance(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
QVector<CasEffect> casEffects(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
GearClass gearClassFromChargeTypeId(int chargeTypeId) override;
|
|
QVector<int> gearTypeIdFromChargeTypeId(int chargeTypeId) override;
|
|
int chargeTypeIdFromLegacyId(GearClass gearClass, int legacyId) override;
|
|
bool isGmlrs(int chargeTypeId) override;
|
|
bool isDm72(int chargeTypeId) override;
|
|
bool isRocket(int chargeTypeId) override;
|
|
|
|
ChargeTypeIgniterTypeIgniterFunction getChargeTypeIgniterTypeIgniterFunction(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
ChargeTypeLoadType getChargeTypeLoadType(int chargeTypeId, int loadTypeId) override;
|
|
|
|
bool canRestock(int gearTypeId) override;
|
|
bool canSetDefaults(int gearTypeId) override;
|
|
int maxCharges(int gearTypeId) override;
|
|
int cadence(int gearTypeId) override;
|
|
int getAdlerWeaponSystemId(int gearTypeId) override;
|
|
int factoryDefault(int gearTypeId, int chargeTypeId) override;
|
|
int maxCharge(int gearTypeId, int chargeTypeId) override;
|
|
bool isAtMine(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
bool isApMine(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
double getLethalRadius(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
double getNonLethalRadius(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
double getMaxRange(int chargeTypeId, int gearTypeId) override;
|
|
ProjectDataManagement::BuildingChargeEffect getBuildingChargeEffectByChargeTypeId(int chargeTypeId) override;
|
|
bool isVirtuallyFireable(int chargeTypeId) override;
|
|
bool isAdlerChargeType(int chargeTypeId) override;
|
|
int getAmountFireMarkers(int firePurposeId) override;
|
|
bool getWithDurationFirePurpose(int firePurposeId) override;
|
|
|
|
// get Adler names/ids
|
|
int getTargetTypeIdFromAdlerTargetType(const QString &typ) override;
|
|
int getTargetSubTypeIdFromAdlerTargetSubType(const QString &subTyp) override;
|
|
int getChargeTypeIdFromAdlerCharges(const QString &geschosssorte) override;
|
|
int getIgniterTypeIdFromAdlerIgniter(const QString &zuender) override;
|
|
int getIgniterFunctionIdFromAdlerIgniterFunction(const QString &zuenderFunktion) override;
|
|
int getLoadTypeIdFromAdlerLoad(const QString &ladung) override;
|
|
QString adlerTargetTypeName(int targetTypeId) override;
|
|
QString adlerTargetSubTypeName(int targetSubTypeId) override;
|
|
QString adlerChargeTypeName(int chargeTypeId) override;
|
|
QString adlerIgniterTypeName(int igniterTypeId) override;
|
|
QString adlerIgniterFunctionName(int igniterFunctionId) override;
|
|
QString adlerLoadTypeName(int loadTypeId) override;
|
|
|
|
QString trBiteComponentTextName(int biteComponentId) override;
|
|
QString trCanComponentStringName(int canComponentId) override;
|
|
QString trChargeTypeShortName(int chargeTypeId, bool omitBaseSuffix = false) override;
|
|
QString trChargeTypeName(int chargeTypeId, bool omitBaseSuffix = false) override;
|
|
QString trFirePurposeName(int firePurposeId) override;
|
|
QString trGearTypeName(int gearTypeId) override;
|
|
QString trIgniterTypeName(int igniterTypeId) override;
|
|
QString trIgniterTypeShortName(int igniterTypeId) override;
|
|
QString trIgniterFunctionName(int igniterFunctionId) override;
|
|
QString trIgniterFunctionShortName(int igniterFunctionId) override;
|
|
QString trLoadTypeName(int loadTypeId) override;
|
|
QString trLoadTypeShortName(int loadTypeId) override;
|
|
QString trTargetTypeName(int targetTypeId) override;
|
|
QString trTargetSubTypeName(int targetSubTypeId) override;
|
|
QString trLanguageHmiName(int languageHmiId) override;
|
|
QString trLanguageXduName(int languageXduId) override;
|
|
QString trNuclearPresetName(int nucularPresetId) override; // "'Nucular'. It's pronounced 'Nucular'!"
|
|
QString trRadioGroupName(int radioGroupId) override;
|
|
QString trVulnerabilityKindName(int vulnerabilityKindId, VulnerabilityClass vulnerabilityClassId) override;
|
|
QString trSanitationMaterialName(int sanitationMaterialId) override;
|
|
|
|
QStringList chargeNames(std::vector<int> &chargeIds) override;
|
|
int getAvailableChargeTypeId(int chargeTypeId /*, bool *bOk = nullptr*/) override;
|
|
ChargeTypeProperty getChargeTypeSpecialProperty(int chargeTypeId, int igniterTypeId, int igniterFunctionId) override;
|
|
QVector<SanitationProcedure> getSanitationProcedures(qint64 procedures) override;
|
|
QStringList sanitationProceduresList(qint64 procedures) override;
|
|
|
|
private:
|
|
struct ChargeTypeIgniterTypeIgniterFunctionProps
|
|
{
|
|
int chargeTypeId = 0;
|
|
int igniterTypeId = 0;
|
|
int igniterFunctionId = 0;
|
|
IgniterFunctionBase igniterFunctionBase = IgniterFunctionBase::IfbImpact;
|
|
int chargeLegacyId = 0;
|
|
double expansionFactor = 0;
|
|
double impactRadius = 0;
|
|
double impactEdgeLength = 0;
|
|
VolatilityType volatilityTypeId = VolatilityType::Unknown;
|
|
int searchRadius = 0;
|
|
bool isSmart = false;
|
|
bool isDryFire = false;
|
|
bool isDus = false;
|
|
int mineClass = 0;
|
|
bool canBeThrown = false;
|
|
bool canBeCreated = true;
|
|
bool isIed = false;
|
|
bool isFromMineLayer = false;
|
|
bool isMineLaying = false;
|
|
QJsonObject mineLayingPattern;
|
|
bool isReactivatable = false;
|
|
bool isSmoke = false;
|
|
int maxEffectShows = 1;
|
|
bool isVisible = true;
|
|
bool isLRF = false;
|
|
bool isLTD = false;
|
|
bool isAP = false;
|
|
bool isAT = false;
|
|
bool isConcrete = false;
|
|
bool showHitline = true;
|
|
int remainingTasCode = 0;
|
|
int secondaryRemainingTasCode = 0;
|
|
int segments = 0;
|
|
bool isLine = false;
|
|
QVector<int> spacing;
|
|
int height = 0;
|
|
int hazardDistance = 0;
|
|
bool isLaserGuidable;
|
|
bool isUasDroppable;
|
|
bool isJamming;
|
|
bool isVirtuallyFireable = false;
|
|
QVector<CasEffect> casEffects;
|
|
bool isAdlerChargeType;
|
|
QString adlerChargeTypeName;
|
|
QString adlerIgniterTypeName;
|
|
QString adlerIgniterFunctionName;
|
|
};
|
|
|
|
struct ChargeTypeLoadTypeProps
|
|
{
|
|
int chargeTypeId = 0;
|
|
int loadTypeId = 0;
|
|
QString adlerLoadTypeName;
|
|
};
|
|
|
|
struct GearTypeProps
|
|
{
|
|
bool canRestock = false;
|
|
bool canSetDefaults = false;
|
|
int maxCharges = -1;
|
|
int adlerWeaponSystemId = -1;
|
|
int cadence = -1;
|
|
};
|
|
|
|
struct GearTypeChargeTypeProps
|
|
{
|
|
int factoryDefault = 0;
|
|
int maxCharge = 0;
|
|
};
|
|
|
|
QString translate(const std::function<PdmBaseName(DtcImplCustom &, qint32)> &getItem, const std::function<QString(const std::string &)> &pdmTranslate, qint32 id);
|
|
QString translateShortChargeType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id);
|
|
QString translateShortIgniterType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id);
|
|
QString translateShortIgniterFunction(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id);
|
|
QString translateShortLoadType(const std::function<QString(const std::string &)> &pdmTranslate, qint32 id);
|
|
|
|
void onChargeTypeChanged(const ChargeType &ct);
|
|
void fillChargeTypeIgniterTypeIgniterFunctionProps();
|
|
void fillChargeTypeLoadTypeProps();
|
|
void onIgniterTypeChanged(const IgniterType &ignType);
|
|
void onIgniterFunctionChanged(const IgniterFunction &ignFunc);
|
|
void onChargeTypeIgniterTypeIgniterFunctionChanged(const ChargeTypeIgniterTypeIgniterFunction &ctitif);
|
|
|
|
ChargeTypeIgniterTypeIgniterFunctionProps chargeTypeIgniterTypeIgniterFunctionProps(int chargeTypeId, int igniterTypeId, int igniterFunctionId);
|
|
DtcImplCustom::ChargeTypeLoadTypeProps chargeTypeLoadTypeProps(int chargeTypeId, int loadTypeId);
|
|
|
|
QString suffix(int chargeTypeId, bool omitBaseSuffix = false);
|
|
static QString offsetName(UleisClassOffset o);
|
|
|
|
void onGearTypeChanged(const GearType >);
|
|
GearTypeProps gearTypeProps(int gearTypeId);
|
|
|
|
void onGearTypeChargeTypeChanged(const GearTypeChargeType >ct);
|
|
GearTypeChargeTypeProps gearTypeChargeTypeProps(int gearTypeChargeTypeId);
|
|
|
|
void setProps(ChargeTypeIgniterTypeIgniterFunctionProps &props, QJsonObject obj);
|
|
void setProps(ChargeTypeLoadTypeProps &props, QJsonObject obj);
|
|
|
|
QJsonObject propertiesToJson(const std::string &properties);
|
|
void mergeProperties(QHash<int, ChargeTypeIgniterTypeIgniterFunctionProps>::iterator &it,
|
|
const QJsonObject &ifProps,
|
|
const QJsonObject &ctProps,
|
|
const QJsonObject &ctitifProps,
|
|
const QJsonObject &itProps);
|
|
|
|
private:
|
|
QHash<int, ChargeTypeIgniterTypeIgniterFunctionProps> m_ctItIfProps;
|
|
QHash<int, ChargeTypeLoadTypeProps> m_ctLtProps;
|
|
QHash<int, GearTypeProps> m_gtProps;
|
|
QHash<int, GearTypeChargeTypeProps> m_gtctProps;
|
|
QString indirectString(bool isIndirect) const;
|
|
};
|
|
} // namespace Interface
|
|
} // namespace ProjectDataManagement
|