#pragma once
#include "Utils/MemoryUtils.h"
#include "Client.h"

#include "SDK/BedrockTextureData.h"

namespace Hooks {
	class MinecraftUIRenderContexts {
	private:
		typedef void(__thiscall* MinecraftUIRenderContext_drawText_)(MinecraftUIRenderContext*, void*, glm::vec4, std::string32*, ImColor&, float, float, void*, void*);
		typedef void(__thiscall* MinecraftUIRenderContext_drawImage_)(MinecraftUIRenderContext*, BedrockTextureData*, glm::vec2&, glm::vec2&, glm::vec2&, glm::vec2&, bool unk);
		inline static MinecraftUIRenderContext_drawText_ minecraftuirendercontext_drawtext;
		inline static MinecraftUIRenderContext_drawImage_ minecraftuirendercontext_drawimage;

		static auto callback_drawtext(MinecraftUIRenderContext* _this, void* font, glm::vec4 pos, std::string32* str, ImColor& color, float alpha, float alinm, void* data, void* caret) -> void;
		static auto callback_drawimage(MinecraftUIRenderContext* _this, BedrockTextureData* data, glm::vec2& imagepos, glm::vec2& imagedimension, glm::vec2& uvpos, glm::vec2& uvsize, bool unk) -> void;
	public:
		inline static int state = -1;
		static void Init(MinecraftUIRenderContext* argment) {
			auto ptr = *(uintptr_t**)(argment);

			state = Utils::Memory::CreateHook(reinterpret_cast<void*>(ptr[5]), (void*)&callback_drawtext, &minecraftuirendercontext_drawtext);
			if (state != 0)
				state = Utils::Memory::CreateHook(reinterpret_cast<void*>(ptr[7]), (void*)&callback_drawimage, &minecraftuirendercontext_drawimage);

			if (state == 0)
				MessageBoxA(0, _("The program was terminated due to an error.\nError code: 1-15"), _("Valkyrie"), MB_ICONERROR);
			else
				std::cout << _("Test 1-15... OK\n");
		}
	};
}
