#ifndef CSM_WORLD_INFOSELECTWRAPPER_H #define CSM_WORLD_INFOSELECTWRAPPER_H #include #include #include #include #include namespace CSMWorld { class ConstInfoSelectWrapper { public: enum ComparisonType { Comparison_Boolean, Comparison_Integer, Comparison_Numeric, Comparison_None }; static const char* FunctionEnumStrings[]; static const char* RelationEnumStrings[]; ConstInfoSelectWrapper(const ESM::DialogueCondition& select); ESM::DialogueCondition::Function getFunctionName() const; ESM::DialogueCondition::Comparison getRelationType() const; ComparisonType getComparisonType() const; bool hasVariable() const; const std::string& getVariableName() const; bool conditionIsAlwaysTrue() const; bool conditionIsNeverTrue() const; QVariant getValue() const; std::string toString() const; protected: void updateHasVariable(); void updateComparisonType(); std::pair getConditionIntRange() const; std::pair getConditionFloatRange() const; std::pair getValidIntRange() const; std::pair getValidFloatRange() const; template bool rangeContains(Type1 value, std::pair range) const; template bool rangesOverlap(std::pair range1, std::pair range2) const; template bool rangeFullyContains(std::pair containing, std::pair test) const; template bool rangesMatch(std::pair range1, std::pair range2) const; template bool conditionIsAlwaysTrue(std::pair conditionRange, std::pair validRange) const; template bool conditionIsNeverTrue(std::pair conditionRange, std::pair validRange) const; ComparisonType mComparisonType; bool mHasVariable; private: const ESM::DialogueCondition& mConstSelect; }; // Wrapper for DialogueCondition that can modify the wrapped select struct class InfoSelectWrapper : public ConstInfoSelectWrapper { public: InfoSelectWrapper(ESM::DialogueCondition& select); // Wrapped SelectStruct will not be modified until update() is called void setFunctionName(ESM::DialogueCondition::Function name); void setRelationType(ESM::DialogueCondition::Comparison type); void setVariableName(const std::string& name); void setValue(int value); void setValue(float value); private: ESM::DialogueCondition& mSelect; void writeRule(); }; } #endif