feat: Implement showPartySelectionGUI routine

This commit is contained in:
Vsevolod Kremianskii 2020-10-22 09:58:33 +07:00
parent ea16a4060f
commit 456663f383
7 changed files with 113 additions and 23 deletions

View file

@ -279,6 +279,7 @@ set(GAME_HEADERS
src/game/gui/hud.h
src/game/gui/loadscreen.h
src/game/gui/mainmenu.h
src/game/gui/partyselect.h
src/game/gui/selectoverlay.h
src/game/object/area.h
src/game/object/creature.h
@ -334,6 +335,7 @@ set(GAME_SOURCES
src/game/gui/hud.cpp
src/game/gui/loadscreen.cpp
src/game/gui/mainmenu.cpp
src/game/gui/partyselect.cpp
src/game/gui/selectoverlay.cpp
src/game/object/area.cpp
src/game/object/creature.cpp

View file

@ -149,13 +149,16 @@ void Game::loadModule(const string &name, const PartyConfiguration &party, strin
loadHUD();
}
if (!_dialog) {
loadDialogGui();
loadDialog();
}
if (!_container) {
loadContainerGui();
loadContainer();
}
if (!_equipment) {
loadEquipmentGui();
loadEquipment();
}
if (!_partySelection) {
loadPartySelection();
}
_ticks = SDL_GetTicks();
_screen = GameScreen::InGame;
@ -254,21 +257,26 @@ void Game::loadHUD() {
_hud->load();
}
void Game::loadDialogGui() {
void Game::loadDialog() {
_dialog.reset(new Dialog(this, _version, _options.graphics));
_dialog->load();
}
void Game::loadContainerGui() {
void Game::loadContainer() {
_container.reset(new Container(this, _version, _options.graphics));
_container->load();
}
void Game::loadEquipmentGui() {
void Game::loadEquipment() {
_equipment.reset(new Equipment(this, _version, _options.graphics));
_equipment->load();
}
void Game::loadPartySelection() {
_partySelection.reset(new PartySelection(_version, _options.graphics));
_partySelection->load();
}
GUI *Game::getScreenGUI() const {
switch (_screen) {
case GameScreen::MainMenu:
@ -285,6 +293,8 @@ GUI *Game::getScreenGUI() const {
return _container.get();
case GameScreen::Equipment:
return _equipment.get();
case GameScreen::PartySelection:
return _partySelection.get();
default:
return nullptr;
}
@ -400,6 +410,10 @@ void Game::openContainer(SpatialObject *container) {
_screen = GameScreen::Container;
}
void Game::openPartySelection() {
_screen = GameScreen::PartySelection;
}
void Game::scheduleModuleTransition(const string &moduleName, const string &entry) {
_nextModule = moduleName;
_nextEntry = entry;

View file

@ -39,6 +39,7 @@
#include "gui/hud.h"
#include "gui/loadscreen.h"
#include "gui/mainmenu.h"
#include "gui/partyselect.h"
#include "object/module.h"
#include "object/objectfactory.h"
#include "object/spatial.h"
@ -63,16 +64,17 @@ public:
int run();
void openMainMenu();
void startCharacterGeneration();
void loadModule(const std::string &name, const PartyConfiguration &party, std::string entry = "");
void quit();
void openInGame();
void startDialog(SpatialObject &owner, const std::string &resRef);
void openContainer(SpatialObject *container);
void scheduleModuleTransition(const std::string &moduleName, const std::string &entry);
void onCameraChanged(CameraType camera);
void openContainer(SpatialObject *container);
void openEquipment();
void openInGame();
void openMainMenu();
void openPartySelection();
void scheduleModuleTransition(const std::string &moduleName, const std::string &entry);
void startCharacterGeneration();
void startDialog(SpatialObject &owner, const std::string &resRef);
void quit();
bool handle(const SDL_Event &event) override;
@ -137,6 +139,7 @@ private:
std::unique_ptr<Dialog> _dialog;
std::unique_ptr<Container> _container;
std::unique_ptr<Equipment> _equipment;
std::unique_ptr<PartySelection> _partySelection;
// END GUI
@ -183,9 +186,10 @@ private:
void loadLoadingScreen();
void loadCharacterGeneration();
void loadHUD();
void loadDialogGui();
void loadContainerGui();
void loadEquipmentGui();
void loadDialog();
void loadContainer();
void loadEquipment();
void loadPartySelection();
// END Loading
@ -203,12 +207,6 @@ private:
void withLoadingScreen(const std::function<void()> &block);
// END Helper methods
// Event handlers
void onDialogFinished();
// END Event handlers
};
} // namespace game

View file

@ -0,0 +1,39 @@
/*
* Copyright © 2020 Vsevolod Kremianskii
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "partyselect.h"
using namespace reone::gui;
using namespace reone::render;
using namespace reone::resource;
namespace reone {
namespace game {
PartySelection::PartySelection(GameVersion version, const GraphicsOptions &opts) : GUI(version, opts) {
_resRef = getResRef("partyselection");
_backgroundType = BackgroundType::Menu;
}
void PartySelection::load() {
GUI::load();
}
} // namespace game
} // namespace reone

View file

@ -0,0 +1,35 @@
/*
* Copyright © 2020 Vsevolod Kremianskii
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include "../../system/gui/gui.h"
namespace reone {
namespace game {
class PartySelection : public gui::GUI {
public:
PartySelection(resource::GameVersion version, const render::GraphicsOptions &opts);
void load() override;
};
} // namespace game
} // namespace reone

View file

@ -369,6 +369,7 @@ Variable RoutineManager::addAvailableNPCByTemplate(const vector<Variable> &args,
}
Variable RoutineManager::showPartySelectionGUI(const vector<Variable> &args, ExecutionContext &ctx) {
_game->openPartySelection();
return Variable();
}

View file

@ -42,7 +42,8 @@ enum class GameScreen {
InGame,
Dialog,
Container,
Equipment
Equipment,
PartySelection
};
enum class Gender {