tryuj fgj fdgh fgh


SUBMITTED BY: Guest

DATE: Nov. 7, 2013, 9:30 p.m.

FORMAT: C++

SIZE: 4.8 kB

HITS: 1369

  1. #include "UserInterface.h"
  2. UserInterface::UserInterface(tgui::Window* pWindow)
  3. {
  4. window = pWindow;
  5. rect.setPosition(0, 500);
  6. rect.setFillColor(sf::Color(50,50,50));
  7. rect.setPosition(0, 500);
  8. rect.setSize(sf::Vector2f(800, 100));
  9. }
  10. void UserInterface::loadUI()
  11. {
  12. // MAIN MENU
  13. tgui::Label* creationLabel = window->add<tgui::Label>("CreationLabel");
  14. creationLabel->setText("General");
  15. creationLabel->setPosition(20, 510);
  16. creationLabel->setSize(100, 20);
  17. creationLabel->setTextSize(14);
  18. tgui::Button* newMapButton = window->add<tgui::Button>("SaveMap");
  19. newMapButton->load("TGUI/objects/Button/Black");
  20. newMapButton->setSize(100, 20);
  21. newMapButton->setPosition(20, 530);
  22. newMapButton->setText("Save Map");
  23. newMapButton->callbackID = 1;
  24. tgui::Button* loadMapButton = window->copy(newMapButton, "LoadMap");
  25. loadMapButton->setPosition(20, 560);
  26. loadMapButton->setText("Load Map");
  27. loadMapButton->callbackID = 2;
  28. tgui::Button* predefEventButton = window->copy(newMapButton, "EditEvents");
  29. predefEventButton->setPosition(160, 530);
  30. predefEventButton->setText("Edit Events");
  31. predefEventButton->setSize(180, 20);
  32. predefEventButton->callbackID = 3;
  33. tgui::Button* makeEventButton = window->copy(newMapButton, "MakeEvent");
  34. makeEventButton->setPosition(160, 560);
  35. makeEventButton->setText("Add Event to Map");
  36. makeEventButton->setSize(180, 20);
  37. makeEventButton->callbackID = 4;
  38. tgui::Checkbox* collisionBox = window->add<tgui::Checkbox>("ShowCollisionLayer");
  39. collisionBox->load("TGUI/objects/Checkbox/Black");
  40. collisionBox->setPosition(350, 530);
  41. collisionBox->setText(" Show Collision Layer");
  42. collisionBox->setTextSize(14);
  43. collisionBox->setSize(15, 15);
  44. tgui::Checkbox* dCollisionBox = window->copy(collisionBox, "DrawCollisionLayer");
  45. dCollisionBox->setPosition(350, 560);
  46. dCollisionBox->setText(" Draw on Collision Layer");
  47. tgui::Button* toggleTileButton = window->copy(newMapButton, "ToggleTiles");
  48. toggleTileButton->setPosition(540, 530);
  49. toggleTileButton->setText("Toggle Tile List");
  50. toggleTileButton->setSize(180, 20);
  51. toggleTileButton->callbackID = 6;
  52. tgui::Button* propertiesButton = window->copy(newMapButton, "Properties");
  53. propertiesButton->setPosition(540, 560);
  54. propertiesButton->setText("Map Properties");
  55. propertiesButton->setSize(180, 20);
  56. propertiesButton->callbackID = 7;
  57. }
  58. void UserInterface::adjustUI(sf::Event& event)
  59. {
  60. // MAIN MENU
  61. tgui::Button* newMapButton = window->get<tgui::Button>("SaveMap");
  62. tgui::Button* loadMapButton = window->get<tgui::Button>("LoadMap");
  63. tgui::Label* creationLabel = window->get<tgui::Label>("CreationLabel");
  64. tgui::Checkbox* collisionBox = window->get<tgui::Checkbox>("ShowCollisionLayer");
  65. tgui::Checkbox* dCollisionBox = window->get<tgui::Checkbox>("DrawCollisionLayer");
  66. tgui::Button* predefEventButton = window->get<tgui::Button>("EditEvents");
  67. tgui::Button* makeEventButton = window->get<tgui::Button>("MakeEvent");
  68. tgui::Button* toggleTileButton = window->get<tgui::Button>("ToggleTiles");
  69. tgui::Button* propertiesButton = window->get<tgui::Button>("Properties");
  70. creationLabel->setPosition(20, event.size.height - 90);
  71. newMapButton->setPosition(20, event.size.height - 70);
  72. loadMapButton->setPosition(20, event.size.height - 40);
  73. collisionBox->setPosition(350, event.size.height - 70);
  74. dCollisionBox->setPosition(350, event.size.height - 40);
  75. predefEventButton->setPosition(160, event.size.height - 70);
  76. makeEventButton->setPosition(160, event.size.height - 40);
  77. toggleTileButton->setPosition(540, event.size.height - 70);
  78. propertiesButton->setPosition(540, event.size.height - 40);
  79. rect.setPosition(0, event.size.height - 100);
  80. rect.setSize(sf::Vector2f(event.size.width, 100));
  81. }
  82. void UserInterface::handleCallback(tgui::Callback& callback)
  83. {
  84. // Make sure tha callback comes from the button
  85. if (callback.callbackID == 1)
  86. {
  87. // Make sure the button was pressed
  88. if (callback.trigger == tgui::Callback::mouseClick)
  89. {
  90. }
  91. }
  92. }
  93. bool UserInterface::abortClick(int x, int y)
  94. {
  95. // TODO
  96. }
  97. void UserInterface::drawBackground()
  98. {
  99. window->draw(rect);
  100. }

comments powered by Disqus