Working on game state
This commit is contained in:
1 parent
b01e970554
commit
2807d82d51
12 files changed
+501
-445
No files matched your search
+14
-59
@@ -4,7 +4,7 @@
|
||||
#include "render/TextureManager.h"
|
||||
#include "UiManager.h"
|
||||
#include "items/Item.h"
|
||||
#include "quest/QuestJournal.h"
|
||||
#include "GameState.h"
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <string>
|
||||
@@ -14,7 +14,7 @@ namespace ZL {
|
||||
|
||||
extern const char* CONST_ZIP_FILE;
|
||||
|
||||
enum class GameState {
|
||||
enum class GameUiState {
|
||||
MainMenu,
|
||||
About,
|
||||
Gameplay,
|
||||
@@ -23,29 +23,12 @@ namespace ZL {
|
||||
PhoneScreen
|
||||
};
|
||||
|
||||
enum class TutorialStep {
|
||||
Step0, // Dialogue hint: "click to advance"
|
||||
Step1, // Camera rotation hint
|
||||
Step2, // Floor tap / walk hint
|
||||
Step3, // Pinch-zoom hint
|
||||
Step4, // Pick-up item hint
|
||||
Step5, // Post-pickup reaction (sub-state: which items were collected)
|
||||
Step6, // Tutorial complete — both phone and journal opened
|
||||
};
|
||||
|
||||
class MenuManager {
|
||||
public:
|
||||
UiManager uiManager;
|
||||
UiManager topUiManager;
|
||||
ZL::Quest::QuestJournal questJournal;
|
||||
std::unordered_map<std::string, int>& globalInts;
|
||||
|
||||
// Global night mode state — persists across location transitions.
|
||||
bool isNight = false;
|
||||
bool isDawn = false; // sub-variant of night: brighter pink ambient, same lighting
|
||||
|
||||
|
||||
MenuManager(Renderer& iRenderer, std::unordered_map<std::string, int>& globalInts);
|
||||
MenuManager(Renderer& iRenderer, GameState& gameState);
|
||||
|
||||
void setup(Inventory& inv, const std::string& zipFile);
|
||||
|
||||
@@ -57,15 +40,15 @@ namespace ZL {
|
||||
void closeQuestJournal();
|
||||
void toggleQuestJournal();
|
||||
|
||||
bool isInventoryOpen() const { return state == GameState::Inventory; }
|
||||
bool isQuestJournalOpen() const { return state == GameState::QuestJournal; }
|
||||
bool isInventoryOpen() const { return uiState_ == GameUiState::Inventory; }
|
||||
bool isQuestJournalOpen() const { return uiState_ == GameUiState::QuestJournal; }
|
||||
|
||||
void showMainMenu();
|
||||
bool isMainMenuOpen() const { return state == GameState::MainMenu; }
|
||||
bool isMainMenuOpen() const { return uiState_ == GameUiState::MainMenu; }
|
||||
|
||||
void openPhoneScreen();
|
||||
void closePhoneScreen();
|
||||
bool isPhoneScreenOpen() const { return state == GameState::PhoneScreen; }
|
||||
bool isPhoneScreenOpen() const { return uiState_ == GameUiState::PhoneScreen; }
|
||||
void closePhoneEntirely();
|
||||
|
||||
void tutorialShowTaxiHint();
|
||||
@@ -73,7 +56,7 @@ namespace ZL {
|
||||
void setChatUnread(int chatIndex, bool unread, const std::string& previewMsg = "");
|
||||
|
||||
void spendMoney(int amount);
|
||||
int getMoney() const { return money_; }
|
||||
int getMoney() const { return gameState_.money; }
|
||||
|
||||
std::function<void()> startGameFunc;
|
||||
std::function<void(const std::string&)> startDialogueFunc;
|
||||
@@ -106,12 +89,12 @@ namespace ZL {
|
||||
void showToast(const std::string& iconPath, const std::string& text);
|
||||
void update(float deltaMs);
|
||||
|
||||
TutorialStep tutorialStep = TutorialStep::Step0;
|
||||
|
||||
protected:
|
||||
Renderer& renderer;
|
||||
|
||||
private:
|
||||
GameState& gameState_;
|
||||
|
||||
void enterGameplay();
|
||||
void refreshQuestJournalUi();
|
||||
void selectQuestByIndex(int index);
|
||||
@@ -153,25 +136,12 @@ namespace ZL {
|
||||
static constexpr float TOAST_FADE_MS = 1000.0f;
|
||||
static constexpr float TOAST_VISIBLE_MS = 2000.0f;
|
||||
|
||||
GameState state = GameState::Gameplay;
|
||||
GameUiState uiState_ = GameUiState::Gameplay;
|
||||
Inventory* inventory = nullptr;
|
||||
//std::string zipFile_;
|
||||
int inventorySelectedIndex_ = -1;
|
||||
|
||||
enum class UniIntTutorialState { Step10, Step11, DarklandsActive, DarklandsStep13, DarklandsFull };
|
||||
UniIntTutorialState uniIntTutorialState_ = UniIntTutorialState::Step10;
|
||||
std::string currentLocationName_;
|
||||
bool currentIsDarklands_ = false;
|
||||
|
||||
bool tutorialPhonePickedUp = false;
|
||||
bool tutorialJournalPickedUp = false;
|
||||
//bool tutorialPhoneScreenOpened = false;
|
||||
bool tutorialPhoneChatScreenOpened = false;
|
||||
bool tutorialJournalScreenOpened = false;
|
||||
bool tutorialMessengerScreenOpened = false;
|
||||
//bool tutorialTaxiScreenOpened = false;
|
||||
|
||||
bool tutorialNeedOpenTaxiScreen = false;
|
||||
int selectedQuestIndex = -1;
|
||||
std::vector<std::string> visibleQuestIds;
|
||||
|
||||
std::shared_ptr<UiNode> hudRoot;
|
||||
std::shared_ptr<UiNode> hudStep1Root;
|
||||
@@ -190,11 +160,9 @@ namespace ZL {
|
||||
std::shared_ptr<UiNode> hudUniIntDarkFullRoot;
|
||||
std::shared_ptr<UiNode> hudUniExtDarkRoot;
|
||||
|
||||
|
||||
std::shared_ptr<UiNode> hudCutsceneRoot_;
|
||||
std::shared_ptr<UiNode> hudTopHintRoot_;
|
||||
|
||||
|
||||
std::shared_ptr<UiNode> phoneMainRoot;
|
||||
std::shared_ptr<UiNode> phoneMainHintARoot;
|
||||
std::shared_ptr<UiNode> phoneMainHintBRoot;
|
||||
@@ -221,27 +189,14 @@ namespace ZL {
|
||||
std::shared_ptr<Texture> texItemSelected_;
|
||||
std::shared_ptr<Texture> texItemTransparent_;
|
||||
|
||||
float currentPlayerHp_ = 200.f;
|
||||
float currentPlayerMaxHp_ = 200.f;
|
||||
void applyCurrentHealthBar();
|
||||
|
||||
int selectedQuestIndex = -1;
|
||||
std::vector<std::string> visibleQuestIds;
|
||||
|
||||
bool chatUnread_[3] = { true, true, true };
|
||||
std::string chatPreviewMsg_[3]; // empty = keep JSON hardcoded text
|
||||
int money_ = 5500;
|
||||
|
||||
// Phone chat state
|
||||
// Phone chat UI state (transient — rebuilt from gameState_.chatHistory on open)
|
||||
struct PhoneChatBubbleInfo {
|
||||
std::string nodeName;
|
||||
float height;
|
||||
};
|
||||
std::vector<PhoneChatBubbleInfo> phoneChatVisibleBubbles_;
|
||||
|
||||
// Per-chat message history (max 5 messages each)
|
||||
struct StoredChatMessage { std::string text; bool incoming; };
|
||||
std::vector<StoredChatMessage> chatHistory_[3];
|
||||
int activeChatIndex_ = -1;
|
||||
|
||||
// Preloaded bubble textures
|
||||
|
||||
Reference in new issue
Block a user