12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- #include "gui/GuiSceneManager.h"
- #include "gui/GUI.h"
- #include "gui/MainMenu.h"
- #include "hotseatgame/gui/RecruitmentScene.h"
- #include "hotseatgame/gui/PlayerVsPlayerIntro.h"
- #include "hotseatgame/gui/PreBattleScene.h"
- #include "hotseatgame/gui/HotSeatGame.h"
- #include <QResource>
- #include <QApplication>
- #include <QFontDatabase>
- GuiSceneManager::GuiSceneManager(QObject *parent) : QObject(parent) {
- gui_ = new GUI();
- gui_->show();
- current_scene_ = "none";
- QResource::registerResource(QApplication::applicationDirPath() + "/res/gui_data.gtr");
- QResource::registerResource(QApplication::applicationDirPath() + "/res/unit_data.gtr");
- QResource::registerResource(QApplication::applicationDirPath() + "/res/spell_data.gtr");
- QResource::registerResource(QApplication::applicationDirPath() + "/res/effect_data.gtr");
- QFontDatabase::addApplicationFont(":/../assets/fonts/barocco-initial.ttf");
- QFontDatabase::addApplicationFont(":/../assets/fonts/viking-cyr.ttf");
- registerScene("main_menu", new MainMenu(gui_->mainContentScene()));
- registerScene("pvp_intro", new PlayerVsPlayerIntro(gui_->mainContentScene()));
- registerScene("recruit_army", new RecruitmentScene(gui_->mainContentScene()));
- registerScene("prebattle", new PreBattleScene(gui_->mainContentScene()));
- registerScene("hotseatgame", new HotSeatGame());
- changeScene("main_menu");
- }
- GuiSceneManager::~GuiSceneManager() {}
- bool GuiSceneManager::registerScene(QString scene_name, Scene* scene) {
- if (scene_name == "none")
- return false;
- if (scenes_.count(scene_name) != 0) {
- delete scene;
- return false;
- }
- scenes_[scene_name] = scene;
- return true;
- }
- bool GuiSceneManager::changeScene(QString scene_name, QString args) {
- if (scene_name == "main_window") {
- return false;
- }
- if (current_scene_ != "none")
- scenes_[current_scene_]->hide();
- scenes_[scene_name]->parseArgs(args);
- scenes_[scene_name]->init();
- scenes_[scene_name]->show();
- current_scene_ = scene_name;
- return true;
- }
- bool GuiSceneManager::hideMainWindow() {
- gui_->hide();
- return true;
- }
- bool GuiSceneManager::showMainWindow() {
- gui_->show();
- return true;
- }
- bool GuiSceneManager::hideDetachedScene(QString scene_name) {
- if (scenes_.count(scene_name) == 0 || !scenes_[scene_name])
- return false;
- scenes_[scene_name]->hide();
- return true;
- }
- bool GuiSceneManager::showDetachedScene(QString scene_name, QString args) {
- if (scenes_.count(scene_name) == 0 || !scenes_[scene_name])
- return false;
- scenes_[scene_name]->parseArgs(args);
- scenes_[scene_name]->init();
- scenes_[scene_name]->show();
- return true;
- }
|