RecipieOutput.cpp 2.0 KB

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