/******************************************************************************
*	File		-	map_editor.h
*	Author		-	Joey Pollack
*	Date		-	2022/01/31 (y/m/d)
*	Mod Date	-	2022/01/31 (y/m/d)
*	Description	-	The tile map editor tool. Controls subwindows/panels.
******************************************************************************/

#ifndef MAP_EDITOR_H_
#define MAP_EDITOR_H_

#include <vector>
#include <map>
#include <string>
#include <utils/opRes.h>
#include "../../panel_manager.h"
#include <gui/file_browser.h>

namespace lunarium {
    class IGraphics;

    namespace gui {
    class Panel;
    }

namespace editor 
{
    class TileSet;
    class Editor;
    class MapEditor
    {
    public:
        MapEditor();

        OpRes Initialize(Editor* editor);
        void Shutdown();
        void OnTick(double delta);
        bool OnRender(lunarium::IGraphics* g);

        void Open();
        void Close();
        bool IsOpen() const;

        void NewMap();
        OpRes LoadMap(std::string map);
        void SaveMap();
        bool IsMapLoaded() const;

        const std::map<int, TileSet*>* GetTileSets() const;

        
    private:
        bool mIsOpen;
        bool mMapLoaded;
        bool mIsDirty;
        Editor* mpEditor;
        
        PanelManager mPanelManager;

        FileBrowser mFileBrowser;

        int mTileSetNextID;
        std::map<int, TileSet*> mTileSets;

        // Menu Events
        bool mImportTileSet;

    private:
        void DoMenu();
        void HandleMenuEvents();
    };
}}

#endif  // MAP_EDITOR_H_