mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-26 00:07:20 +00:00
feat(jui): add merchant screen
This commit is contained in:
46
Minecraft.Client/UI/TradeSwitchButton.cpp
Normal file
46
Minecraft.Client/UI/TradeSwitchButton.cpp
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user