#pragma once
#ifndef _IMGUI_MANAGER_H_
#define _IMGUI_MANAGER_H_

#include "Logger.h"
#include "sceneManager.h"

#include <imgui.h>
#include <imgui_impl_dx11.h>
#include <imgui_impl_win32.h>
#include <windows.h>
#include <deque>
#include "rendertextureclass.h"

class ApplicationClass;

class imguiManager
{
public:
	imguiManager();
	~imguiManager();

	bool Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext);
	void Shutdown();
	void Render(ApplicationClass* app);
	void NewFrame();
	void SetupDockspace(ApplicationClass* app);

	// Widgets
	void WidgetSpeedSlider(float* speed);
	void WidgetButton();
	void WidgetFPS();
	void WidgetAddObject(ApplicationClass* app);

	void WidgetObjectWindow(ApplicationClass* app);
	void WidgetTerrainWindow(ApplicationClass* app);
	void WidgetLightWindow(ApplicationClass* app);
	void WidgetEngineSettingsWindow(ApplicationClass* app);
	void WidgetRenderWindow(ApplicationClass* app, ImVec2 availableSize);
	void WidgetLogWindow(ApplicationClass* app);

	bool ImGuiWidgetRenderer(ApplicationClass* app);

	void SetWindowSize(ImVec2 size) { windowSize = size; }
	ImVec2 GetWindowSize() const { return windowSize; }

	// Shader toggles

	bool m_EnableCelShading;

private:

	// --------------------------------------------- //
	// ----------------- Functions ----------------- //
	// --------------------------------------------- //

	// --------------------------------------------- //
	// ----------------- Variables ----------------- //
	// --------------------------------------------- //

	
	bool showObjectWindow;
	bool showTerrainWindow;
	bool showLightWindow;
	bool showOldSceneWindow;
	bool showEngineSettingsWindow;
	bool showLogWindow;

	bool m_isPhyiscsEnabled = false;

	ImGuiIO* io;

	ID3D11Device* m_device;
	ID3D11DeviceContext* m_deviceContext;
	ImVec2 windowSize;

	RenderTextureClass* m_renderTexture;

	const std::deque<Logger::LogEntry>& logBuffer = Logger::Get().GetLogBuffer();
};

#endif