Dialog.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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->setStyle(UIMLView::Style::Erlaubt | UIMLView::Style::Sichtbar);
  16. view->setMausEreignis(_ret1ME);
  17. view->addKnownElement(new InventoryElement());
  18. view->addKnownElement(new EquipmentElement());
  19. view->addKnownElement(new CraftingGridElement());
  20. view->setUIML(xml);
  21. view->setSize((int)xml->getAttributeValue("width"), (int)xml->getAttributeValue("height"));
  22. name = xml->getAttributeValue("id");
  23. view->layout();
  24. addMember(view);
  25. 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 | Fenster::Style::MEIgnoreInside);
  26. setKBgFarbe(0xA0000000);
  27. setTBgFarbe(0xA0000000);
  28. setSBgFarbe(0xA0000000);
  29. setSize(view->getBreite() + 4, view->getHeight() + 24);
  30. setPosition(window->zBildschirm()->getBackBufferSize() / 2 - getSize() / 2);
  31. setRBreite(2);
  32. setClosingMe([onClose, this](void* p, void* o, MausEreignis me)
  33. {
  34. if (me.id == ME_RLinks)
  35. onClose(this);
  36. return 1;
  37. });
  38. setRFarbe(0xFF52525E);
  39. setTitel(xml->getAttributeValue("title"));
  40. setTSchriftZ(dynamic_cast<Schrift*>(uiFactory.initParam.schrift->getThis()));
  41. zTTextFeld()->setSize(0, 20);
  42. zTTextFeld()->addStyle(TextFeld::Style::Center);
  43. setTastaturEreignis(_ret1TE);
  44. }
  45. UIMLDialog::~UIMLDialog()
  46. {}
  47. void UIMLDialog::api(char* message)
  48. {
  49. short idLen = *(short*)message;
  50. char* id = new char[idLen + 1];
  51. memcpy(id, message + 2, idLen);
  52. id[idLen] = 0;
  53. NetworkAPIProcessor* processor = dynamic_cast<NetworkAPIProcessor*>(view->zZeichnungById(id));
  54. if (processor)
  55. processor->api(message + 2 + idLen);
  56. delete[] id;
  57. }
  58. const Framework::Text& UIMLDialog::getName() const
  59. {
  60. return name;
  61. }