feat: Add support code for levelling up
This commit is contained in:
parent
670b2f5936
commit
415f3c80d2
15 changed files with 135 additions and 16 deletions
|
@ -404,6 +404,7 @@ set(GAME_HEADERS
|
|||
src/game/gui/ingame/map.h
|
||||
src/game/gui/ingame/messages.h
|
||||
src/game/gui/ingame/options.h
|
||||
src/game/gui/levelup.h
|
||||
src/game/gui/loadscreen.h
|
||||
src/game/gui/mainmenu.h
|
||||
src/game/gui/partyselect.h
|
||||
|
@ -501,6 +502,7 @@ set(GAME_SOURCES
|
|||
src/game/gui/ingame/map.cpp
|
||||
src/game/gui/ingame/messages.cpp
|
||||
src/game/gui/ingame/options.cpp
|
||||
src/game/gui/levelup.cpp
|
||||
src/game/gui/loadscreen.cpp
|
||||
src/game/gui/mainmenu.cpp
|
||||
src/game/gui/partyselect.cpp
|
||||
|
|
|
@ -200,6 +200,9 @@ void Game::loadModule(const string &name, string entry) {
|
|||
if (!_partySelect) {
|
||||
loadPartySelection();
|
||||
}
|
||||
if (!_levelUp) {
|
||||
loadLevelUp();
|
||||
}
|
||||
|
||||
Models::instance().invalidateCache();
|
||||
Walkmeshes::instance().invalidateCache();
|
||||
|
@ -392,6 +395,11 @@ void Game::loadSaveLoad() {
|
|||
_saveLoad->load();
|
||||
}
|
||||
|
||||
void Game::loadLevelUp() {
|
||||
_levelUp.reset(new LevelUpMenu(this));
|
||||
_levelUp->load();
|
||||
}
|
||||
|
||||
void Game::loadInGame() {
|
||||
_inGame.reset(new InGameMenu(this));
|
||||
_inGame->load();
|
||||
|
@ -417,6 +425,8 @@ GUI *Game::getScreenGUI() const {
|
|||
return _partySelect.get();
|
||||
case GameScreen::SaveLoad:
|
||||
return _saveLoad.get();
|
||||
case GameScreen::LevelUp:
|
||||
return _levelUp.get();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -615,10 +625,15 @@ void Game::openPartySelection(const PartySelection::Context &ctx) {
|
|||
void Game::openSaveLoad(SaveLoad::Mode mode) {
|
||||
setCursorType(CursorType::Default);
|
||||
_saveLoad->setMode(mode);
|
||||
_saveLoad->update();
|
||||
_saveLoad->refresh();
|
||||
changeScreen(GameScreen::SaveLoad);
|
||||
}
|
||||
|
||||
void Game::openLevelUp() {
|
||||
setCursorType(CursorType::Default);
|
||||
changeScreen(GameScreen::LevelUp);
|
||||
}
|
||||
|
||||
void Game::scheduleModuleTransition(const string &moduleName, const string &entry) {
|
||||
_nextModule = moduleName;
|
||||
_nextEntry = entry;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "gui/dialog.h"
|
||||
#include "gui/hud.h"
|
||||
#include "gui/ingame/ingame.h"
|
||||
#include "gui/levelup.h"
|
||||
#include "gui/loadscreen.h"
|
||||
#include "gui/mainmenu.h"
|
||||
#include "gui/partyselect.h"
|
||||
|
@ -138,6 +139,7 @@ public:
|
|||
void openInGameMenu(InGameMenu::Tab tab);
|
||||
void openContainer(const std::shared_ptr<SpatialObject> &container);
|
||||
void openPartySelection(const PartySelection::Context &ctx);
|
||||
void openLevelUp();
|
||||
|
||||
void startCharacterGeneration();
|
||||
void startDialog(const std::shared_ptr<SpatialObject> &owner, const std::string &resRef);
|
||||
|
@ -185,7 +187,8 @@ private:
|
|||
Dialog,
|
||||
Container,
|
||||
PartySelection,
|
||||
SaveLoad
|
||||
SaveLoad,
|
||||
LevelUp
|
||||
};
|
||||
|
||||
boost::filesystem::path _path;
|
||||
|
@ -227,6 +230,7 @@ private:
|
|||
std::unique_ptr<Container> _container;
|
||||
std::unique_ptr<PartySelection> _partySelect;
|
||||
std::unique_ptr<SaveLoad> _saveLoad;
|
||||
std::unique_ptr<LevelUpMenu> _levelUp;
|
||||
|
||||
// END GUI
|
||||
|
||||
|
@ -287,6 +291,7 @@ private:
|
|||
void loadMainMenu();
|
||||
void loadPartySelection();
|
||||
void loadSaveLoad();
|
||||
void loadLevelUp();
|
||||
|
||||
// END Loading
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void AbilitiesMenu::load() {
|
|||
disableControl("BTN_FEATS");
|
||||
}
|
||||
|
||||
void AbilitiesMenu::updatePortraits() {
|
||||
void AbilitiesMenu::refreshPortraits() {
|
||||
if (_version != GameVersion::KotOR) return;
|
||||
|
||||
Party &party = _game->party();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
void load() override;
|
||||
|
||||
void updatePortraits();
|
||||
void refreshPortraits();
|
||||
|
||||
private:
|
||||
Game *_game { nullptr };
|
||||
|
|
|
@ -94,12 +94,17 @@ void CharacterMenu::load() {
|
|||
hideControl("LBL_EXPERIENCE_STAT");
|
||||
hideControl("LBL_NEEDED_XP");
|
||||
|
||||
disableControl("BTN_LEVELUP");
|
||||
disableControl("BTN_AUTO");
|
||||
disableControl("BTN_SCRIPTS");
|
||||
}
|
||||
|
||||
void CharacterMenu::updatePortraits() {
|
||||
void CharacterMenu::update(float dt) {
|
||||
shared_ptr<Creature> leader(_game->party().leader());
|
||||
setControlVisible("BTN_LEVELUP", leader->isLevelUpPending());
|
||||
setControlVisible("BTN_AUTO", leader->isLevelUpPending());
|
||||
}
|
||||
|
||||
void CharacterMenu::refreshPortraits() {
|
||||
if (_version != GameVersion::KotOR) return;
|
||||
|
||||
Party &party = _game->party();
|
||||
|
@ -116,6 +121,8 @@ void CharacterMenu::updatePortraits() {
|
|||
void CharacterMenu::onClick(const string &control) {
|
||||
if (control == "BTN_EXIT") {
|
||||
_game->openInGame();
|
||||
} else if (control == "BTN_LEVELUP") {
|
||||
_game->openLevelUp();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,9 @@ public:
|
|||
CharacterMenu(Game *game);
|
||||
|
||||
void load() override;
|
||||
void update(float dt) override;
|
||||
|
||||
void updatePortraits();
|
||||
void refreshPortraits();
|
||||
|
||||
private:
|
||||
Game *_game { nullptr };
|
||||
|
|
|
@ -190,17 +190,17 @@ void InGameMenu::updateTabButtons() {
|
|||
}
|
||||
|
||||
void InGameMenu::openInventory() {
|
||||
_inventory->updatePortraits();
|
||||
_inventory->refreshPortraits();
|
||||
changeTab(Tab::Inventory);
|
||||
}
|
||||
|
||||
void InGameMenu::openCharacter() {
|
||||
_character->updatePortraits();
|
||||
_character->refreshPortraits();
|
||||
changeTab(Tab::Character);
|
||||
}
|
||||
|
||||
void InGameMenu::openAbilities() {
|
||||
_abilities->updatePortraits();
|
||||
_abilities->refreshPortraits();
|
||||
changeTab(Tab::Abilities);
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ void InventoryMenu::load() {
|
|||
setControlFocusable("BTN_CHANGE2", false);
|
||||
}
|
||||
|
||||
void InventoryMenu::updatePortraits() {
|
||||
void InventoryMenu::refreshPortraits() {
|
||||
if (_version != GameVersion::KotOR) return;
|
||||
|
||||
Party &party = _game->party();
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
void load() override;
|
||||
|
||||
void updatePortraits();
|
||||
void refreshPortraits();
|
||||
|
||||
private:
|
||||
Game *_game { nullptr };
|
||||
|
|
44
src/game/gui/levelup.cpp
Normal file
44
src/game/gui/levelup.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021 The reone project contributors
|
||||
*
|
||||
* 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 "levelup.h"
|
||||
|
||||
#include "../game.h"
|
||||
|
||||
using namespace reone::gui;
|
||||
|
||||
namespace reone {
|
||||
|
||||
namespace game {
|
||||
|
||||
LevelUpMenu::LevelUpMenu(Game *game) :
|
||||
GUI(game->version(), game->options().graphics),
|
||||
_game(game) {
|
||||
|
||||
_resRef = getResRef("leveluppnl");
|
||||
_backgroundType = BackgroundType::Menu;
|
||||
}
|
||||
|
||||
void LevelUpMenu::onClick(const std::string &control) {
|
||||
if (control == "BTN_BACK") {
|
||||
_game->openInGame();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
40
src/game/gui/levelup.h
Normal file
40
src/game/gui/levelup.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2020-2021 The reone project contributors
|
||||
*
|
||||
* 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 "../../gui/gui.h"
|
||||
|
||||
namespace reone {
|
||||
|
||||
namespace game {
|
||||
|
||||
class Game;
|
||||
|
||||
class LevelUpMenu : public gui::GUI {
|
||||
public:
|
||||
LevelUpMenu(Game *game);
|
||||
|
||||
private:
|
||||
Game *_game;
|
||||
|
||||
void onClick(const std::string &control) override;
|
||||
};
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
|
@ -79,7 +79,7 @@ void SaveLoad::load() {
|
|||
protoItem.setHilightColor(_defaultHilightColor);
|
||||
}
|
||||
|
||||
void SaveLoad::update() {
|
||||
void SaveLoad::refresh() {
|
||||
string panelName(Resources::instance().getString(_mode == Mode::Save ? kStrRefSaveGame : kStrRefLoadGame));
|
||||
|
||||
Control &lblPanelName = getControl("LBL_PANELNAME");
|
||||
|
@ -157,7 +157,7 @@ void SaveLoad::onClick(const string &control) {
|
|||
saveIdx = getNewSaveIndex();
|
||||
}
|
||||
saveGame(saveIdx);
|
||||
update();
|
||||
refresh();
|
||||
break;
|
||||
default:
|
||||
if (saveIdx != -1) {
|
||||
|
@ -169,7 +169,7 @@ void SaveLoad::onClick(const string &control) {
|
|||
int saveIdx = getSelectedSaveIndex();
|
||||
if (saveIdx != -1) {
|
||||
deleteGame(saveIdx);
|
||||
update();
|
||||
refresh();
|
||||
}
|
||||
} else if (control == "BTN_BACK") {
|
||||
ListBox &lbGames = getControl<ListBox>("LB_GAMES");
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
|
||||
void load() override;
|
||||
|
||||
void update();
|
||||
void refresh();
|
||||
|
||||
void setMode(Mode mode);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#include "gui.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "../common/log.h"
|
||||
#include "../render/mesh/quad.h"
|
||||
#include "../render/shaders.h"
|
||||
|
@ -44,6 +46,9 @@ string GUI::getResRef(const string &base) const {
|
|||
}
|
||||
|
||||
void GUI::load() {
|
||||
if (_resRef.empty()) {
|
||||
throw logic_error("resRef must not be empty");
|
||||
}
|
||||
info("GUI: load " + _resRef);
|
||||
|
||||
shared_ptr<GffStruct> gui(Resources::instance().getGFF(_resRef, ResourceType::Gui));
|
||||
|
|
Loading…
Reference in a new issue