mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-07 03:17:13 +00:00
feat(jui): add brewing stand screen (+ fix enchantment screen not being used)
This commit is contained in:
parent
ed83397c55
commit
3dcc985cd4
BIN
Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png
Normal file
BIN
Minecraft.Assets/Common/res/1_2_2/gui/brewing_stand.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 KiB |
|
|
@ -1,5 +1,7 @@
|
|||
#include "../Platform/stdafx.h"
|
||||
#include "LocalPlayer.h"
|
||||
#include "UI/Screens/BrewingStandScreen.h"
|
||||
#include "UI/Screens/EnchantmentScreen.h"
|
||||
#include "UI/Screens/HopperScreen.h"
|
||||
#include "UI/Screens/HorseInventoryScreen.h"
|
||||
#include "UI/Screens/RepairScreen.h"
|
||||
|
|
@ -645,10 +647,14 @@ bool LocalPlayer::openFireworks(int x, int y, int z) {
|
|||
|
||||
bool LocalPlayer::startEnchanting(int x, int y, int z,
|
||||
const std::wstring& name) {
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
minecraft->setScreen(new EnchantmentScreen(inventory, level, x, y, z));
|
||||
bool success = true;
|
||||
#else
|
||||
bool success =
|
||||
app.LoadEnchantingMenu(GetXboxPad(), inventory, x, y, z, level, name);
|
||||
if (success) ui.PlayUISFX(eSFX_Press);
|
||||
// minecraft.setScreen(new EnchantmentScreen(inventory, level, x, y, z));
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
@ -677,10 +683,14 @@ bool LocalPlayer::openFurnace(std::shared_ptr<FurnaceTileEntity> furnace) {
|
|||
|
||||
bool LocalPlayer::openBrewingStand(
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand) {
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
minecraft->setScreen(new BrewingStandScreen(inventory, brewingStand));
|
||||
bool success = true;
|
||||
#else
|
||||
bool success =
|
||||
app.LoadBrewingStandMenu(GetXboxPad(), inventory, brewingStand);
|
||||
if (success) ui.PlayUISFX(eSFX_Press);
|
||||
// minecraft.setScreen(new BrewingStandScreen(inventory, brewingStand));
|
||||
#endif
|
||||
return success;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -182,6 +182,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = {
|
|||
L"gui/trap",
|
||||
L"gui/hopper",
|
||||
L"gui/enchant",
|
||||
L"gui/brewing_stand",
|
||||
L"title/bg/panorama",
|
||||
L"title/bg/panorama0",
|
||||
L"title/bg/panorama1",
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ typedef enum _TEXTURE_NAME {
|
|||
TN_GUI_TRAP,
|
||||
TN_GUI_HOPPER,
|
||||
TN_GUI_ENCHANT,
|
||||
TN_GUI_BREWING_STAND,
|
||||
TN_TITLE_BG_PANORAMA,
|
||||
TN_TITLE_BG_PANORAMA0,
|
||||
TN_TITLE_BG_PANORAMA1,
|
||||
|
|
|
|||
99
Minecraft.Client/UI/Screens/BrewingStandScreen.cpp
Normal file
99
Minecraft.Client/UI/Screens/BrewingStandScreen.cpp
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
#include "../../Platform/stdafx.h"
|
||||
#include "BrewingStandScreen.h"
|
||||
#include <GL/gl.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include "../../Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../Rendering/Lighting.h"
|
||||
#include "../../Textures/Textures.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.locale.h"
|
||||
#include "../../../Minecraft.World/Containers/BrewingStandMenu.h"
|
||||
#include "../../../Minecraft.World/Containers/Slot.h"
|
||||
#include "../../../Minecraft.Client/Minecraft.h"
|
||||
|
||||
// 4jcraft: referenced from MCP 8.11 (JE 1.6.4) and the existing
|
||||
// container classes
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
ResourceLocation GUI_BREWING_STAND_LOCATION =
|
||||
ResourceLocation(TN_GUI_BREWING_STAND);
|
||||
#endif
|
||||
|
||||
BrewingStandScreen::BrewingStandScreen(
|
||||
std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand)
|
||||
: AbstractContainerScreen(new BrewingStandMenu(inventory, brewingStand)) {
|
||||
this->inventory = inventory;
|
||||
this->brewingStand = brewingStand;
|
||||
this->brewMenu = static_cast<BrewingStandMenu*>(menu);
|
||||
}
|
||||
|
||||
BrewingStandScreen::~BrewingStandScreen() = default;
|
||||
|
||||
void BrewingStandScreen::init() { AbstractContainerScreen::init(); }
|
||||
|
||||
void BrewingStandScreen::removed() { AbstractContainerScreen::removed(); }
|
||||
|
||||
void BrewingStandScreen::renderLabels() {
|
||||
font->draw(brewingStand->getName(),
|
||||
(imageWidth / 2) - (font->width(brewingStand->getName()) / 2), 6,
|
||||
0x404040);
|
||||
font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040);
|
||||
}
|
||||
|
||||
void BrewingStandScreen::renderBg(float a) {
|
||||
#ifdef ENABLE_JAVA_GUIS
|
||||
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
Minecraft::GetInstance()->textures->bindTexture(
|
||||
&GUI_BREWING_STAND_LOCATION);
|
||||
int xo = (width - imageWidth) / 2;
|
||||
int yo = (height - imageHeight) / 2;
|
||||
blit(xo, yo, 0, 0, imageWidth, imageHeight);
|
||||
|
||||
int brewTime = brewingStand->getBrewTime();
|
||||
|
||||
if (brewTime > 0) {
|
||||
int arrowHeight = (int)(28.0f * (1.0f - (float)brewTime / 400.0f));
|
||||
|
||||
if (arrowHeight > 0) {
|
||||
blit(xo + 97, yo + 16 + (28 - arrowHeight), 176, 28 - arrowHeight,
|
||||
9, arrowHeight);
|
||||
}
|
||||
|
||||
int bubbleStep = (brewTime / 2) % 7;
|
||||
int bubbleHeight = 0;
|
||||
|
||||
switch (bubbleStep) {
|
||||
case 0:
|
||||
bubbleHeight = 29;
|
||||
break;
|
||||
case 1:
|
||||
bubbleHeight = 24;
|
||||
break;
|
||||
case 2:
|
||||
bubbleHeight = 20;
|
||||
break;
|
||||
case 3:
|
||||
bubbleHeight = 16;
|
||||
break;
|
||||
case 4:
|
||||
bubbleHeight = 11;
|
||||
break;
|
||||
case 5:
|
||||
bubbleHeight = 6;
|
||||
break;
|
||||
case 6:
|
||||
bubbleHeight = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (bubbleHeight > 0) {
|
||||
blit(xo + 65, yo + 14 + (29 - bubbleHeight), 185, 29 - bubbleHeight,
|
||||
12, bubbleHeight);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrewingStandScreen::render(int xm, int ym, float a) {
|
||||
AbstractContainerScreen::render(xm, ym, a);
|
||||
}
|
||||
23
Minecraft.Client/UI/Screens/BrewingStandScreen.h
Normal file
23
Minecraft.Client/UI/Screens/BrewingStandScreen.h
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "AbstractContainerScreen.h"
|
||||
#include "../../../Minecraft.World/Containers/BrewingStandMenu.h"
|
||||
#include "../../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||
|
||||
class BrewingStandScreen : public AbstractContainerScreen {
|
||||
public:
|
||||
BrewingStandScreen(std::shared_ptr<Inventory> inventory,
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand);
|
||||
virtual ~BrewingStandScreen();
|
||||
|
||||
void init() override;
|
||||
void removed() override;
|
||||
void renderLabels() override;
|
||||
void renderBg(float a) override;
|
||||
void render(int xm, int ym, float a) override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Inventory> inventory;
|
||||
std::shared_ptr<BrewingStandTileEntity> brewingStand;
|
||||
BrewingStandMenu* brewMenu;
|
||||
};
|
||||
Loading…
Reference in a new issue