guiscenemanager.cpp 1.5 KB

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