#pragma once
#include "Debugger.h"
#include <map>
#include "ImGui/imgui.h"
#include "ImGui/imgui_impl_opengl3.h"
#include "ImGui/imgui_impl_glfw.h"
#include "STB/stb_image.h"

#define NUMBER_OF_LEAF_TEXTURES 13
#define NUMBER_OF_BARK_TEXTURES 13


class GuiManager
{
private:
	GLFWwindow* mp_window;

	bool high_dpi_mode = false;
	bool show_hello_world_window = false;
	bool show_demo_window = false;
	bool show_another_window = false;
	bool show_geometry_modifier_window = false;
	bool show_texture_browser_window = false;
	bool show_texture_loading_notification = false;
	bool show_custom_light_window = false;
	bool show_timeline_window = false;
	bool show_software_information_window = false;
	bool wireframe_mode = false;
	ImVec4 clear_color;

	int fps_ui_right_margin;
	int is_texture_browser_prepared;

public:
	bool m_need_to_open_project;
	bool m_need_to_save_project;
	bool m_need_to_export_obj;
	bool m_need_to_regenerate;
	bool m_need_to_show_leaf;
	bool m_need_to_show_branch;

	int m_iteration;
	float m_tree_size;
	
	float m_branch_tallness;
	float m_branch_shrinkage;
	int m_branch_max_angle;
	int m_branch_angle_turbulence;
	int m_branch_number_of_new_branches_spawned_by_one_trunk;
	int m_branch_number_of_new_branches;
	float m_branch_number_of_new_branches_fluctuation;

	float m_leaf_density;
	int m_leaf_height;

	int m_tree_random_seed;

	int m_leaf_texture_selected_texture_ID;
	int m_bark_texture_selected_texture_ID;

	float light_intensity;
	float light_attenuation;
	float light_position[3]; // x, y, z

	float ambient_color[3]; // r, g, b
	float diffuse_color[3];
	float specular_color[3];

	std::map<unsigned int, unsigned int> m_leaf_texture_list;
	std::map<unsigned int, unsigned int> m_bark_texture_list;


	GuiManager(GLFWwindow* window);
	~GuiManager();

	void DrawGui();
	void DeleteGui();

private:
	void PrepareTextureBrowserPalette();
	unsigned int LoadGuiTexture(const std::string& filepath);

};

