Dialog.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include <XML.h>
  2. #include <TextFeld.h>
  3. #include <TastaturEreignis.h>
  4. #include "Dialog.h"
  5. #include "InventoryView.h"
  6. #include "Equipment.h"
  7. #include "CraftingGrid.h"
  8. #include "Globals.h"
  9. using namespace Framework;
  10. UIMLDialog::UIMLDialog(Framework::Text uiml, std::function<void(UIMLDialog* self)> onClose)
  11. : Fenster()
  12. {
  13. XML::Element* xml = new XML::Element(uiml);
  14. view = new UIMLView("<v/>", uiFactory);
  15. view->addKnownElement(new InventoryElement());
  16. view->addKnownElement(new EquipmentElement());
  17. view->addKnownElement(new CraftingGridElement());
  18. view->setUIML(xml);
  19. view->setSize(xml->getAttributeValue("width"), xml->getAttributeValue("height"));
  20. name = xml->getAttributeValue("id");
  21. view->layout();
  22. addMember(view);
  23. setStyle(Fenster::Style::Sichtbar | Fenster::Style::Erlaubt | Fenster::Style::Rahmen | Fenster::Style::BodyHAlpha | Fenster::Style::Beweglich | Fenster::Style::Titel | Fenster::Style::TitelHAlpha | Fenster::Style::Closable | Fenster::Style::ClosingHAlpha | Fenster::Style::ClosingKlickBuffer | Fenster::Style::TitelHintergrund | Fenster::Style::BodyHintergrund | Fenster::Style::ClosingHintergrund);
  24. setKBgFarbe(0xA0000000);
  25. setTBgFarbe(0xA0000000);
  26. setSBgFarbe(0xA0000000);
  27. setSize(view->getBreite() + 4, view->getHeight() + 24);
  28. setPosition(window->zBildschirm()->getBackBufferSize() / 2 - getSize() / 2);
  29. setRBreite(2);
  30. setClosingMe([onClose, this](void* p, void* o, MausEreignis me)
  31. {
  32. if (me.id == ME_RLinks)
  33. onClose(this);
  34. return 1;
  35. });
  36. setRFarbe(0xFF52525E);
  37. setTitel(xml->getAttributeValue("title"));
  38. setTSchriftZ(dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
  39. zTTextFeld()->setSize(0, 20);
  40. zTTextFeld()->addStyle(TextFeld::Style::Center);
  41. setTastaturEreignis(_ret1TE);
  42. }
  43. UIMLDialog::~UIMLDialog()
  44. {}
  45. void UIMLDialog::api(char* message)
  46. {
  47. short idLen = *(short*)message;
  48. char* id = new char[idLen + 1];
  49. memcpy(id, message + 2, idLen);
  50. id[idLen] = 0;
  51. NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(view->zZeichnungById(id));
  52. if (processor)
  53. processor->api(message + 2 + idLen);
  54. delete[] id;
  55. }
  56. const Framework::Text& UIMLDialog::getName() const
  57. {
  58. return name;
  59. }