RecipieIngredient.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #pragma once
  2. #include <TextFeld.h>
  3. #include <UIMLView.h>
  4. class LogicTree;
  5. class RecipieIngredientElement : public Framework::UIMLElement
  6. {
  7. private:
  8. LogicTree* parse(Framework::XML::Element* zElement);
  9. public:
  10. RecipieIngredientElement();
  11. //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
  12. //! ist
  13. bool isApplicableFor(Framework::XML::Element& element) override;
  14. //! erstellt eine neue Zeichnung zu einem gegebenen xml Element
  15. Framework::Zeichnung* parseElement(Framework::XML::Element& element,
  16. Framework::UIMLContainer& generalFactory) override;
  17. bool updateElement(Framework::XML::Element& element,
  18. Framework::Zeichnung& z,
  19. Framework::UIMLContainer& generalFactory) override;
  20. //! wendet die layout parameter zu einer Zeichnung an
  21. void layout(Framework::XML::Element& element,
  22. Framework::Zeichnung& z,
  23. int pWidth,
  24. int pHeight,
  25. Framework::UIMLContainer& generalLayouter) override;
  26. };
  27. class RecipieIngredient : public Framework::ZeichnungHintergrund
  28. {
  29. private:
  30. Framework::RCArray<Framework::Bild> icons;
  31. Framework::RCArray<Framework::Text> toolTips;
  32. Framework::Array<int> itemTypes;
  33. Framework::TextFeld* toolTip;
  34. int currentIconIndex;
  35. double timtUntilNextIcon;
  36. int amount;
  37. public:
  38. RecipieIngredient(int amount);
  39. void addPossibleItem(
  40. Framework::Bild* icon, Framework::Text* toolTip, int itemType);
  41. bool tick(double tickVal) override;
  42. void render(Framework::Bild& rObj) override;
  43. void doMausEreignis(Framework::MausEreignis& me, bool userRet) override;
  44. };
  45. enum class AttributeOperator
  46. {
  47. Equals,
  48. NotEquals,
  49. GreaterThan,
  50. GreaterThanOrEquals,
  51. LessThan,
  52. LessThanOrEquals
  53. };
  54. class Requirement : public Framework::ReferenceCounter
  55. {
  56. private:
  57. Framework::Text attribute;
  58. Framework::Text value;
  59. AttributeOperator op;
  60. public:
  61. Requirement(
  62. Framework::Text attribute, Framework::Text value, AttributeOperator op);
  63. void negate();
  64. Requirement* clone();
  65. bool contradicts(Requirement* zOther);
  66. bool merge(Requirement* zOther);
  67. int getItemType();
  68. Framework::Text getDescription();
  69. };
  70. class RequirementSet : public Framework::ReferenceCounter
  71. {
  72. private:
  73. Framework::RCArray<Requirement> requirements;
  74. public:
  75. RequirementSet();
  76. void addRequirement(Requirement* zReq);
  77. RequirementSet* clone();
  78. void addRequirements(RequirementSet* zOther);
  79. void negate(LogicTree* zNode);
  80. bool isNoneMatch() const;
  81. bool isAnyMatch() const;
  82. Framework::Text renderToTooltip() const;
  83. Framework::Bild* getIcon() const;
  84. int getItemType() const;
  85. };
  86. enum class LogicalOperator
  87. {
  88. AND,
  89. OR
  90. };
  91. class LogicTree : public Framework::ReferenceCounter
  92. {
  93. private:
  94. LogicalOperator op;
  95. RequirementSet* requirementSet;
  96. Framework::RCArray<LogicTree> children;
  97. Framework::RCArray<RequirementSet>* multiply(
  98. Framework::RCArray<RequirementSet>* a,
  99. Framework::RCArray<RequirementSet>* b);
  100. public:
  101. LogicTree(LogicalOperator op, RequirementSet* set);
  102. ~LogicTree();
  103. void addChildren(LogicTree* tree);
  104. LogicTree* clone();
  105. void negate();
  106. Framework::RCArray<RequirementSet>* resolve();
  107. };