guiscenemanager.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #include "gui/guiscenemanager.h"
  2. #include "gui/gui.h"
  3. #include "gui/detatchedwidget.h"
  4. #include "gui/mainmenu.h"
  5. #include "gui/playervsplayerintro.h"
  6. GuiSceneManager::GuiSceneManager(QObject *parent) : QObject(parent) {
  7. gui_ = new GUI();
  8. gui_->show();
  9. current_scene_ = "none";
  10. registerScene("main_menu", new MainMenu(gui_->mainContentScene()));
  11. registerScene("pvp_intro", new PlayerVsPlayerIntro(gui_->mainContentScene()));
  12. registerScene("recruit_army", new RecruitmentScene(gui_->mainContentScene()));
  13. changeScene("main_menu");
  14. }
  15. GuiSceneManager::~GuiSceneManager() {}
  16. bool GuiSceneManager::registerScene(QString scene_name, Scene* name) {
  17. if (scene_name == "none")
  18. return false;
  19. if (scenes_.count(scene_name) != 0) {
  20. delete name;
  21. return false;
  22. }
  23. scenes_[scene_name] = name;
  24. return true;
  25. }
  26. bool GuiSceneManager::changeScene(QString scene_name, QString args) {
  27. if (scene_name == current_scene_ || scene_name == "main_window") {
  28. return false;
  29. }
  30. if (current_scene_ != "none")
  31. scenes_[current_scene_]->hide();
  32. scenes_[scene_name]->parseArgs(args);
  33. scenes_[scene_name]->show();
  34. current_scene_ = scene_name;
  35. return true;
  36. }
  37. void GuiSceneManager::createDetachedScene(QString scene_name) {
  38. /// TO BE DONE!!!
  39. }
  40. void GuiSceneManager::destroyDetachedScene(QString scene_name) {
  41. /// TO BE DONE!!!
  42. }