mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-16 11:22:54 +00:00
feat(jui): add hopper screen
This commit is contained in:
parent
b854af49c6
commit
5ac7f23577
BIN
Minecraft.Assets/Common/res/1_2_2/gui/hopper.png
Normal file
BIN
Minecraft.Assets/Common/res/1_2_2/gui/hopper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.2 KiB |
|
|
@ -1,5 +1,6 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "LocalPlayer.h"
|
||||
#include "UI/Screens/HopperScreen.h"
|
||||
#include "UI/Screens/HorseInventoryScreen.h"
|
||||
#include "UI/Screens/RepairScreen.h"
|
||||
#include "User.h"
|
||||
|
|
@ -586,9 +587,13 @@ bool LocalPlayer::openContainer(std::shared_ptr<Container> container) {
|
|||
}
|
||||
|
||||
bool LocalPlayer::openHopper(std::shared_ptr<HopperTileEntity> container) {
|
||||
// minecraft->setScreen(new HopperScreen(inventory, container));
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
minecraft->setScreen(new HopperScreen(inventory, container));
|
||||
bool success = true;
|
||||
#else
|
||||
bool success = app.LoadHopperMenu(GetXboxPad(), inventory, container);
|
||||
if (success) ui.PlayUISFX(eSFX_Press);
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -180,6 +180,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = {
|
|||
L"gui/horse",
|
||||
L"gui/anvil",
|
||||
L"gui/trap",
|
||||
L"gui/hopper",
|
||||
L"title/bg/panorama",
|
||||
L"title/bg/panorama0",
|
||||
L"title/bg/panorama1",
|
||||
|
|
|
|||
|
|
@ -162,6 +162,7 @@ typedef enum _TEXTURE_NAME {
|
|||
TN_GUI_HORSE,
|
||||
TN_GUI_ANVIL,
|
||||
TN_GUI_TRAP,
|
||||
TN_GUI_HOPPER,
|
||||
TN_TITLE_BG_PANORAMA,
|
||||
TN_TITLE_BG_PANORAMA0,
|
||||
TN_TITLE_BG_PANORAMA1,
|
||||
|
|
|
|||
|
|
@ -155,7 +155,9 @@ void CreateWorldScreen::buttonClicked(Button* button) {
|
|||
app.DebugPrintf("CreateWorldScreen::buttonClicked START\n");
|
||||
if (!button->active) return;
|
||||
if (button->id == 1) {
|
||||
app.DebugPrintf("CreateWorldScreen::buttonClicked 'Cancel' minecraft->setScreen(lastScreen)\n");
|
||||
app.DebugPrintf(
|
||||
"CreateWorldScreen::buttonClicked 'Cancel' "
|
||||
"minecraft->setScreen(lastScreen)\n");
|
||||
minecraft->setScreen(lastScreen);
|
||||
} else if (button->id == 0) {
|
||||
minecraft->setScreen(
|
||||
|
|
|
|||
37
Minecraft.Client/UI/Screens/HopperScreen.cpp
Normal file
37
Minecraft.Client/UI/Screens/HopperScreen.cpp
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "HopperScreen.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
#include "../../Player/LocalPlayer.h"
|
||||
#include "../Font.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.inventory.h"
|
||||
#include "../../../Minecraft.World/Containers/HopperMenu.h"
|
||||
|
||||
// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing
|
||||
// container classes
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
ResourceLocation GUI_HOPPER_LOCATION = ResourceLocation(TN_GUI_HOPPER);
|
||||
#endif
|
||||
|
||||
HopperScreen::HopperScreen(std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> hopper)
|
||||
: AbstractContainerScreen(new HopperMenu(inventory, hopper)) {
|
||||
this->hopper = hopper;
|
||||
this->inventory = inventory;
|
||||
imageHeight = 133;
|
||||
}
|
||||
|
||||
void HopperScreen::renderLabels() {
|
||||
font->draw(hopper->getName(), 8, 6, 0x404040);
|
||||
font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
void HopperScreen::renderBg(float a) {
|
||||
// 4J Unused
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
glColor4f(1, 1, 1, 1);
|
||||
minecraft->textures->bindTexture(&GUI_HOPPER_LOCATION);
|
||||
int xo = (width - imageWidth) / 2;
|
||||
int yo = (height - imageHeight) / 2;
|
||||
this->blit(xo, yo, 0, 0, imageWidth, imageHeight);
|
||||
#endif
|
||||
}
|
||||
21
Minecraft.Client/UI/Screens/HopperScreen.h
Normal file
21
Minecraft.Client/UI/Screens/HopperScreen.h
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
#include <memory>
|
||||
#include "AbstractContainerScreen.h"
|
||||
|
||||
class HopperTileEntity;
|
||||
class MinecartHopper;
|
||||
class Inventory;
|
||||
|
||||
class HopperScreen : public AbstractContainerScreen {
|
||||
public:
|
||||
HopperScreen(std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<Container> hopper);
|
||||
|
||||
protected:
|
||||
virtual void renderLabels();
|
||||
virtual void renderBg(float a);
|
||||
|
||||
private:
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
std::shared_ptr<Container> hopper;
|
||||
};
|
||||
Loading…
Reference in a new issue