#pragma once
#include "render/Renderer.h"
#include "Environment.h"
#include "render/TextureManager.h"
#include "UiManager.h"
#include "items/Item.h"
#include "quest/QuestJournal.h"
#include <vector>
#include <string>
#include <memory>

namespace ZL {

	extern const char* CONST_ZIP_FILE;

	enum class GameState {
		Gameplay,
		Inventory,
		QuestJournal
	};

	class MenuManager {
	public:
		UiManager uiManager;
		ZL::Quest::QuestJournal questJournal;

		MenuManager(Renderer& iRenderer);

		void setup(Inventory& inv, const std::string& zipFile);

		void openInventory();
		void closeInventory();

		void openQuestJournal();
		void closeQuestJournal();
		void toggleQuestJournal();

		bool isInventoryOpen()    const { return state == GameState::Inventory; }
		bool isQuestJournalOpen() const { return state == GameState::QuestJournal; }

	protected:
		Renderer& renderer;

	private:
		void enterGameplay();
		void refreshQuestJournalUi();
		void selectQuestByIndex(int index);

		GameState state = GameState::Gameplay;
		Inventory* inventory = nullptr;

		std::shared_ptr<UiNode> hudRoot;
		std::shared_ptr<UiNode> inventoryRoot;
		std::shared_ptr<UiNode> questJournalRoot;

		int selectedQuestIndex = -1;
		std::vector<std::string> visibleQuestIds;
	};

} // namespace ZL
