Skip to content

Commit d8790df

Browse files
committed
disallow quick-save, while in menu/pause
1 parent 56c8dcc commit d8790df

5 files changed

Lines changed: 18 additions & 14 deletions

File tree

game/gothic.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
#include "game/definitions/musicdefinitions.h"
1515
#include "game/definitions/fightaidefinitions.h"
1616
#include "game/definitions/particlesdefinitions.h"
17-
#include "game/serialize.h"
17+
18+
#include "world/objects/npc.h"
1819

1920
#include "utils/fileutil.h"
2021
#include "utils/inifile.h"
@@ -178,6 +179,13 @@ bool Gothic::isInGame() const {
178179
return game!=nullptr;
179180
}
180181

182+
bool Gothic::isInGameAndAlive() const {
183+
auto pl = Gothic::inst().player();
184+
if(pl==nullptr || pl->isDead())
185+
return false;
186+
return isInGame();
187+
}
188+
181189
const World *Gothic::world() const {
182190
if(game)
183191
return game->world();

game/gothic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Gothic final {
4242
auto version() const -> const VersionInfo&;
4343

4444
bool isInGame() const;
45+
bool isInGameAndAlive() const;
4546

4647
std::string_view defaultWorld() const;
4748
std::string_view defaultPlayer() const;

game/mainwindow.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,11 +725,14 @@ void MainWindow::onMarvinKey() {
725725
if(auto camera = Gothic::inst().camera()) {
726726
camera->setMarvinMode(Camera::M_Freeze);
727727
}
728-
} else {
728+
}
729+
else if(Gothic::inst().isInGameAndAlive() && !Gothic::inst().isPause()) {
729730
Gothic::inst().quickSave();
730731
}
731732
#else
732-
Gothic::inst().quickSave();
733+
if(Gothic::inst().isInGameAndAlive() && !Gothic::inst().isPause()) {
734+
Gothic::inst().quickSave();
735+
}
733736
#endif
734737
break;
735738

game/ui/gamemenu.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ GameMenu::GameMenu(MenuRoot &owner, KeyCodec& keyCodec, phoenix::vm &vm, std::st
292292
}
293293
setPosition(int(infoX*float(w())),int(infoY*float(h())));
294294

295-
setSelection(isInGameAndAlive() ? menu->default_ingame : menu->default_outgame);
295+
setSelection(Gothic::inst().isInGameAndAlive() ? menu->default_ingame : menu->default_outgame);
296296
updateValues();
297297
slider = Resources::loadTexture("MENU_SLIDER_POS.TGA");
298298

@@ -708,9 +708,9 @@ bool GameMenu::isSelectable(const std::shared_ptr<phoenix::c_menu_item>& item) {
708708
bool GameMenu::isEnabled(const std::shared_ptr<phoenix::c_menu_item>& item) {
709709
if(item==nullptr)
710710
return false;
711-
if((item->flags & phoenix::c_menu_item_flags::only_ingame) && !isInGameAndAlive())
711+
if((item->flags & phoenix::c_menu_item_flags::only_ingame) && !Gothic::inst().isInGameAndAlive())
712712
return false;
713-
if((item->flags & phoenix::c_menu_item_flags::only_outgame) && isInGameAndAlive())
713+
if((item->flags & phoenix::c_menu_item_flags::only_outgame) && Gothic::inst().isInGameAndAlive())
714714
return false;
715715
return true;
716716
}
@@ -988,13 +988,6 @@ void GameMenu::setDefaultKeys(std::string_view preset) {
988988
keyCodec.setDefaultKeys(preset);
989989
}
990990

991-
bool GameMenu::isInGameAndAlive() {
992-
auto pl = Gothic::inst().player();
993-
if(pl==nullptr || pl->isDead())
994-
return false;
995-
return Gothic::inst().isInGame();
996-
}
997-
998991
bool GameMenu::implUpdateSavThumb(GameMenu::Item& sel) {
999992
const size_t id = saveSlotId(sel);
1000993
if(id==size_t(-1))

game/ui/gamemenu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ class GameMenu : public Tempest::Widget {
118118
void updateVideo();
119119
void setDefaultKeys(std::string_view preset);
120120

121-
static bool isInGameAndAlive();
122121
static QuestStat toStatus(std::string_view str);
123122
static bool isCompatible(const QuestLog::Quest& q, QuestStat st);
124123
static int32_t numQuests(const QuestLog* q, QuestStat st);

0 commit comments

Comments
 (0)