mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-19 18:32:54 +00:00
feat(jui): add horse inventory screen
This commit is contained in:
parent
3f2c6e0012
commit
65ff6a97f0
BIN
Minecraft.Assets/Common/res/1_2_2/gui/horse.png
Normal file
BIN
Minecraft.Assets/Common/res/1_2_2/gui/horse.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.5 KiB |
|
|
@ -1,5 +1,6 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "LocalPlayer.h"
|
||||
#include "UI/Screens/HorseInventoryScreen.h"
|
||||
#include "User.h"
|
||||
#include "../Input/Input.h"
|
||||
#include "../GameState/StatsCounter.h"
|
||||
|
|
@ -599,10 +600,14 @@ bool LocalPlayer::openHopper(std::shared_ptr<MinecartHopper> container) {
|
|||
|
||||
bool LocalPlayer::openHorseInventory(std::shared_ptr<EntityHorse> horse,
|
||||
std::shared_ptr<Container> container) {
|
||||
// minecraft->setScreen(new HorseInventoryScreen(inventory, container,
|
||||
// horse));
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
minecraft->setScreen(new HorseInventoryScreen(inventory, container,
|
||||
horse));
|
||||
bool success = true;
|
||||
#else
|
||||
bool success = app.LoadHorseMenu(GetXboxPad(), inventory, container, horse);
|
||||
if (success) ui.PlayUISFX(eSFX_Press);
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = {
|
|||
|
||||
// 4jcraft: 1.6.4 java UI
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
L"gui/horse",
|
||||
L"title/bg/panorama",
|
||||
#endif
|
||||
// L"item/christmas",
|
||||
|
|
|
|||
|
|
@ -159,6 +159,7 @@ typedef enum _TEXTURE_NAME {
|
|||
|
||||
// 4jcraft: 1.6.4 java UI
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
TN_GUI_HORSE,
|
||||
TN_TITLE_BG_PANORAMA,
|
||||
#endif
|
||||
// TN_TILE_XMAS_CHEST,
|
||||
|
|
|
|||
100
Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp
Normal file
100
Minecraft.Client/UI/Screens/HorseInventoryScreen.cpp
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "HorseInventoryScreen.h"
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../Rendering/EntityRenderers/EntityRenderDispatcher.h"
|
||||
#include "../../Rendering/Lighting.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.locale.h"
|
||||
#include "../../../Minecraft.World/Containers/HorseInventoryMenu.h"
|
||||
|
||||
// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing InventoryScreen
|
||||
|
||||
ResourceLocation GUI_HORSE_LOCATION = ResourceLocation(TN_GUI_HORSE);
|
||||
|
||||
HorseInventoryScreen::HorseInventoryScreen(
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> horseContainer,
|
||||
std::shared_ptr<EntityHorse> horse)
|
||||
: AbstractContainerScreen(
|
||||
new HorseInventoryMenu(inventory, horseContainer, horse)) {
|
||||
xMouse = yMouse = 0.0f; // 4J added
|
||||
|
||||
this->inventory = inventory;
|
||||
this->horseContainer = horseContainer;
|
||||
this->horse = horse;
|
||||
this->passEvents = false;
|
||||
}
|
||||
|
||||
void HorseInventoryScreen::init() { AbstractContainerScreen::init(); }
|
||||
|
||||
void HorseInventoryScreen::renderLabels() {
|
||||
font->draw(horseContainer->getName(), 8, 6, 0x404040);
|
||||
font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
void HorseInventoryScreen::render(int xm, int ym, float a) {
|
||||
AbstractContainerScreen::render(xm, ym, a);
|
||||
this->xMouse = (float)xm;
|
||||
this->yMouse = (float)ym;
|
||||
}
|
||||
|
||||
void HorseInventoryScreen::renderBg(float a) {
|
||||
// 4J Unused
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
glColor4f(1, 1, 1, 1);
|
||||
minecraft->textures->bindTexture(&GUI_HORSE_LOCATION);
|
||||
|
||||
int xo = (width - imageWidth) / 2;
|
||||
int yo = (height - imageHeight) / 2;
|
||||
blit(xo, yo, 0, 0, imageWidth, imageHeight);
|
||||
|
||||
if (horse->isChestedHorse()) {
|
||||
blit(xo + 79, yo + 17, 0, imageHeight, 90, 54);
|
||||
}
|
||||
|
||||
if (horse->canWearArmor()) {
|
||||
blit(xo + 7, yo + 35, 0, imageHeight + 54, 18, 18);
|
||||
}
|
||||
|
||||
glEnable(GL_RESCALE_NORMAL);
|
||||
glEnable(GL_COLOR_MATERIAL);
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef((float)xo + 51, (float)yo + 60, 50);
|
||||
float ss = 30;
|
||||
glScalef(-ss, ss, ss);
|
||||
glRotatef(180, 0, 0, 1);
|
||||
|
||||
float oybr = horse->yBodyRot;
|
||||
float oyr = horse->yRot;
|
||||
float oxr = horse->xRot;
|
||||
float oyh = horse->yHeadRot;
|
||||
float oyhp = horse->yHeadRotO;
|
||||
|
||||
float xd = (xo + 51) - xMouse;
|
||||
float yd = (yo + 75 - 50) - yMouse;
|
||||
|
||||
glRotatef(45 + 90, 0, 1, 0);
|
||||
Lighting::turnOn();
|
||||
glRotatef(-45 - 90, 0, 1, 0);
|
||||
|
||||
glRotatef(-(float)atan(yd / 40.0f) * 20, 1, 0, 0);
|
||||
|
||||
horse->yBodyRot = (float)atan(xd / 40.0f) * 20;
|
||||
horse->yRot = (float)atan(xd / 40.0f) * 40;
|
||||
horse->xRot = -(float)atan(yd / 40.0f) * 20;
|
||||
horse->yHeadRot = (float)atan(xd / 40.0f) * 40;
|
||||
horse->yHeadRotO = (float)atan(xd / 40.0f) * 40;
|
||||
glTranslatef(0, horse->heightOffset, 0);
|
||||
EntityRenderDispatcher::instance->playerRotY = 180;
|
||||
EntityRenderDispatcher::instance->render(horse, 0, 0, 0, 0, 1);
|
||||
horse->yBodyRot = oybr;
|
||||
horse->yRot = oyr;
|
||||
horse->xRot = oxr;
|
||||
horse->yHeadRot = oyh;
|
||||
horse->yHeadRotO = oyhp;
|
||||
glPopMatrix();
|
||||
Lighting::turnOff();
|
||||
glDisable(GL_RESCALE_NORMAL);
|
||||
#endif
|
||||
}
|
||||
22
Minecraft.Client/UI/Screens/HorseInventoryScreen.h
Normal file
22
Minecraft.Client/UI/Screens/HorseInventoryScreen.h
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
#include "AbstractContainerScreen.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.entity.animal.h"
|
||||
|
||||
class HorseInventoryScreen : public AbstractContainerScreen {
|
||||
public:
|
||||
HorseInventoryScreen(std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> horseContainer,
|
||||
std::shared_ptr<EntityHorse> horse);
|
||||
|
||||
virtual void init() override;
|
||||
virtual void renderLabels() override;
|
||||
virtual void renderBg(float a) override;
|
||||
virtual void render(int xm, int ym, float a) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
std::shared_ptr<Container> horseContainer;
|
||||
std::shared_ptr<EntityHorse> horse;
|
||||
float xMouse, yMouse;
|
||||
};
|
||||
Loading…
Reference in a new issue