#include "client/gui/Crosshair.h"

#include "client/Client.h"
#include "client/render/loader/TextureLoader.h"
#include <imgui.h>

namespace blitz {
namespace gui {

CrossHair::CrossHair(Client* client) : GuiWidget(nullptr, client) {
	m_CrossHairTexture = TextureLoader::LoadGLTexture("crosshair.png");
}

void CrossHair::Render() {
	if (!m_Client->IsConnected())
		return;

	static const ImVec2 crossHairSize = {40, 40};

	ImGui::SetNextWindowPos({0, 0});
	ImGui::Begin("CrossHair", nullptr, GetWindowFullScreenFlags() | ImGuiWindowFlags_NoInputs);
	ImGui::SetCursorPosX(ImGui::GetIO().DisplaySize.x / 2.0f - crossHairSize.x / 2.0f);
	ImGui::SetCursorPosY(ImGui::GetIO().DisplaySize.y / 2.0f - crossHairSize.y / 2.0f);
	ImGui::Image(reinterpret_cast<ImTextureID>(m_CrossHairTexture), crossHairSize);
	ImGui::End();
}

}  // namespace gui
}  // namespace blitz
