#ifndef EDITSCENE_SAVELOADDIALOG_HPP
#define EDITSCENE_SAVELOADDIALOG_HPP
#pragma once

#include <string>
#include <vector>
#include "SaveLoadSystem.hpp"

class EditorApp;

/**
 * ImGui modal dialog for save/load slot selection.
 *
 * Used by both StartupMenuSystem (load mode) and PauseMenuSystem (save mode).
 */
class SaveLoadDialog {
public:
	/**
	 * Mode of operation.
	 */
	enum class Mode { Save, Load };

	/**
	 * Open the dialog. Call this when the user clicks Save/Load.
	 *
	 * @param editorApp The editor app for save/load callbacks.
	 * @param mode      Save or Load mode.
	 */
	static void show(EditorApp *editorApp, Mode mode);

	/**
	 * Render the dialog. Call this every frame from the menu system's
	 * update/render loop.
	 *
	 * @param editorApp The editor app for save/load callbacks.
	 */
	static void render(EditorApp *editorApp);

	/**
	 * Check if the dialog is currently open.
	 */
	static bool isOpen();

	/**
	 * Close the dialog.
	 */
	static void close();

private:
	static bool s_open;
	static Mode s_mode;
	static std::vector<SaveLoadSystem::SaveInfo> s_saves;
	static int s_selectedIndex;
	static char s_slotNameInput[256];
	static bool s_needsRefresh;
	static bool s_showDeleteConfirm;
	static int s_deleteIndex;

	static void refreshSaveList();
	static void doSave(EditorApp *editorApp);
	static void doLoad(EditorApp *editorApp, int index);
};

#endif // EDITSCENE_SAVELOADDIALOG_HPP
