RecipieOutput.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "RecipieOutput.h"
  2. #include <XML.h>
  3. #include "Globals.h"
  4. #include "ItemType.h"
  5. #include "UIMLToolTip.h"
  6. RecipieOutputElement::RecipieOutputElement()
  7. : Framework::UIMLElement()
  8. {}
  9. //! prüft, ob dieses UIML Element für ein bestimmtes xml Element zuständig
  10. //! ist
  11. bool RecipieOutputElement::isApplicableFor(Framework::XML::Element& element)
  12. {
  13. return element.getName().isEqual("output");
  14. }
  15. //! erstellt eine neue Drawable zu einem gegebenen xml Element
  16. Framework::Drawable* RecipieOutputElement::parseElement(
  17. Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
  18. {
  19. SlotInfo info;
  20. info.itemCount = (int)element.getAttributeValue("amount");
  21. int itemType = (int)element.getAttributeValue("itemType");
  22. info.hp = (float)(double)element.getAttributeValue("hp");
  23. info.maxHp = (float)(double)element.getAttributeValue("maxHp");
  24. info.durability = (float)(double)element.getAttributeValue("durability");
  25. info.maxDurability
  26. = (float)(double)element.getAttributeValue("maxDurability");
  27. info.zItem = zItemType(itemType)->zIcon();
  28. return new RecipieOutput(info, element.zChild(0)->toString());
  29. }
  30. bool RecipieOutputElement::updateElement(Framework::XML::Element& element,
  31. Framework::Drawable& z,
  32. Framework::UIMLContainer& generalFactory)
  33. {
  34. return false;
  35. }
  36. //! wendet die layout parameter zu einer Drawable an
  37. void RecipieOutputElement::layout(Framework::XML::Element& element,
  38. Framework::Drawable& z,
  39. int pWidth,
  40. int pHeight,
  41. Framework::UIMLContainer& generalLayouter)
  42. {
  43. UIMLElement::layout(element, z, pWidth, pHeight, generalLayouter);
  44. z.setWidth(50);
  45. z.setHeight(50);
  46. }
  47. RecipieOutput::RecipieOutput(SlotInfo info, Framework::Text toolTipUIML)
  48. : info(info)
  49. {
  50. setStyle(Framework::Drawable::Style::Allowed
  51. | Framework::Drawable::Style::Visible);
  52. UIMLToolTip* tip = new UIMLToolTip();
  53. tip->setUIML(toolTipUIML);
  54. tip->setWarten(0.5);
  55. setToolTipZ(tip);
  56. }
  57. void RecipieOutput::render(Framework::Image& rObj)
  58. {
  59. DrawableBackground::render(rObj);
  60. if (!rObj.setDrawOptions(pos.x, pos.y, gr.x, gr.y)) return;
  61. info.render(-1, -1, rObj, 0, 0);
  62. rObj.releaseDrawOptions();
  63. }