1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- #include "gui/guiscenemanager.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) {
- window_ = new QMainWindow(nullptr, Qt::Window | Qt::FramelessWindowHint);
- window_->setWindowTitle("Супер-мега-клёвая-игрушка-название-которой-мы-ещё-не-придумали");
- window_->setWindowState(Qt::WindowFullScreen);
- window_->show();
- current_scene_ = "none";
- QResource::registerResource(QApplication::applicationDirPath() + "/res/game_ui_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());
- registerScene("pvp_intro", new PlayerVsPlayerIntro());
- registerScene("recruit_army", new RecruitmentScene());
- registerScene("prebattle", new PreBattleScene());
- 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_]->deinit();
- scenes_[current_scene_]->hide();
- window_->takeCentralWidget();
- }
- scenes_[scene_name]->parseArgs(args);
- scenes_[scene_name]->init();
- window_->setCentralWidget(scenes_[scene_name]);
- scenes_[scene_name]->show();
- current_scene_ = scene_name;
- return true;
- }
|