UIMLCraftingProgress.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include "UIMLCraftingProgress.h"
  2. #include "Globals.h"
  3. #include "UIMLProgressAndStateView.h"
  4. #include "UIMLUtils.h"
  5. UIMLCraftingProgressElement::UIMLCraftingProgressElement()
  6. : UIMLElement()
  7. {}
  8. bool UIMLCraftingProgressElement::isApplicableFor(
  9. Framework::XML::Element& element)
  10. {
  11. return element.getName().istGleich("craftingProgress");
  12. }
  13. Framework::Zeichnung* UIMLCraftingProgressElement::parseElement(
  14. Framework::XML::Element& element, Framework::UIMLContainer& generalFactory)
  15. {
  16. int addressLength = 0;
  17. int* address = getUIMLTargetAddress(
  18. element.getAttributeValue("target"), addressLength);
  19. UIMLProgressAndStateView* view
  20. = new UIMLProgressAndStateView(element.getAttributeValue("id"),
  21. element.getAttributeValue("background"),
  22. element.getAttributeValue("foreground"),
  23. address,
  24. addressLength,
  25. 1,
  26. 3,
  27. "Progress: ",
  28. " ticks");
  29. Framework::Text direction = element.getAttributeValue("direction");
  30. view->setStyle(UIMLProgressAndStateView::Style::Sichtbar
  31. | UIMLProgressAndStateView::Style::Erlaubt);
  32. if (direction.istGleich("TOP") || direction.istGleich("BOTTOM"))
  33. {
  34. view->addStyle(UIMLProgressAndStateView::Style::Vertical);
  35. }
  36. if (direction.istGleich("TOP") || direction.istGleich("LEFT"))
  37. {
  38. view->addStyle(UIMLProgressAndStateView::Style::Reversed);
  39. }
  40. return view;
  41. }
  42. bool UIMLCraftingProgressElement::updateElement(
  43. Framework::XML::Element& element,
  44. Framework::Zeichnung& z,
  45. Framework::UIMLContainer& generalFactory)
  46. {
  47. return false; // No update needed for this element
  48. }