#pragma once
#include <d3d11.h>

namespace texture
{
	ID3D11ShaderResourceView* xenoware_logo = nullptr;
}

struct s_tab
{
	std::vector<const char*> icon;
	std::vector<const char*> name;
};

static bool once_init = false;


static class c_tabs {

private:

	int current_idx;
	int stored_idx;
	int check_id = 0;





	std::vector<s_tab> tab_selection;

	float content_size;

public:

	c_tabs(std::vector<s_tab> tab_info)
	{
		//current_scroll = 0.f;
		this->current_idx = 0;
		this->check_id = 0;
		this->tab_selection = tab_info;
	}


	int GetCurrentTab()
	{
		return current_idx;
	}


	bool IsTabActive(int id)
	{
		if (bool(this->c_tabs::stored_idx == id) || tab_want_to_change)
			return true;
		else
		{
			ImGui::Dummy(ImVec2(1280, 700));
			return false;
		}
	}

	float GetCurrentScroll()
	{
		return current_scroll;
	}

	void DrawTabs(bool horizontal)
	{
		ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8, 8));
		ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0, 0));
		ImGui::SetCursorPos(ImVec2(8, horizontal ? 8 : 26.f));
		ImGui::BeginChild("Tabs", ImVec2(ImGui::GetContentRegionAvail().x - 8, ImGui::GetContentRegionAvail().y), false, ImGuiWindowFlags_NoScrollbar);
		{
			if (!once_init) {
				this->stored_idx = 0;
				once_init = true;
			}

			ImFont* deafult_fonts[] = { font::default_r, font::default_m, font::default_s };
			ImGui::GetIO().FontDefault = deafult_fonts[c::selected_font];

			if (horizontal) {
				for (int i = 0; i < tab_selection[0].icon.size(); i++)
				{
					if (custom::SquareTab(tab_selection[0].name[i], tab_selection[0].icon[i], &this->c_tabs::stored_idx, i)) {
						tab_want_to_change = true;
						this->c_tabs::stored_idx = i;
						this->c_tabs::current_idx = i;
					}
					ImGui::SameLine();
				}
			}
			else
			{
				for (int i = 0; i < tab_selection[0].icon.size(); i++)
				{
					if (i == 0)
						ImGui::Text(" Aim Helpers");
					else if (i == 1)
						ImGui::Text(" Players & Vision");
					else if (i == 3)
						ImGui::Text(" Misc");
					else if (i == 4)
						ImGui::Text(" Utilities & Settings");

					if (custom::Tab(tab_selection[0].name[i], tab_selection[0].icon[i], &this->c_tabs::stored_idx, i)) {
						tab_want_to_change = true;
						this->c_tabs::stored_idx = i;
						this->c_tabs::current_idx = i;
					}
				}
			}
			//current_scroll = easing->easing_in_out<float>(ImGui::GetID("current_scrool"), true, this->c_tabs::stored_idx * c::bg::size.x, this->c_tabs::stored_idx * c::bg::size.x, ImGui::GetIO().DeltaTime * 20.f, interpolation_type::back);

			current_scroll = ImLerp(current_scroll, this->c_tabs::stored_idx * c::bg::size.x, ImGui::GetIO().DeltaTime * 7.f);


			if (tab_want_to_change) {
				if (abs(current_scroll - (this->c_tabs::stored_idx * c::bg::size.x)) < 8.f)
					tab_want_to_change = false;
			}
			content_size = ImGui::GetCurrentWindow()->ContentSize.x;

		}
		ImGui::EndChild();
		ImGui::PopStyleVar(2);
	}
};