feat(jui): add merchant screen

This commit is contained in:
Sally Knight
2026-03-29 05:15:30 +03:00
committed by Tropical
parent 32149b7ec3
commit 97c6704d82
9 changed files with 318 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
#include "../../Platform/stdafx.h"
#include "TradeSwitchButton.h"
#include "../Textures/Textures.h"
#include "../Rendering/Tesselator.h"
#include "../../../Minecraft.Client/Minecraft.h"
#include "../../../Minecraft.World/Headers/net.minecraft.locale.h"
#include "../../../Minecraft.World/Containers/MerchantMenu.h"
// 4jcraft: referenced from MCP 8.11 (JE 1.6.4)
#ifdef ENABLE_JAVA_GUIS
// ResourceLocation GUI_VILLAGER_LOCATION = ResourceLocation(TN_GUI_VILLAGER);
extern ResourceLocation GUI_VILLAGER_LOCATION;
#endif
TradeSwitchButton::TradeSwitchButton(int id, int x, int y, bool mirrored)
: Button(id, x, y, 12, 19, L"") {
this->mirrored = mirrored;
}
int TradeSwitchButton::getYImage(bool hovered) { return 0; }
void TradeSwitchButton::renderBg(Minecraft* minecraft, int xm, int ym) {
#ifdef ENABLE_JAVA_GUIS
if (!visible) return;
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
minecraft->textures->bindTexture(&GUI_VILLAGER_LOCATION);
bool hovered = (xm >= x && ym >= y && xm < x + w && ym < y + h);
int textureX = 176;
int textureY = 0;
if (!active) {
textureX += w * 2;
} else if (hovered) {
textureX += w;
}
if (!mirrored) {
textureY += h;
}
blit(x, y, textureX, textureY, w, h);
#endif
}