iOS Support (#113)

undefined
This commit is contained in:
Brent
2024-01-22 09:22:41 -06:00
committed by GitHub
parent 90a15340b1
commit afe875e4fa
109 changed files with 6523 additions and 1105 deletions

View File

@@ -1,7 +1,7 @@
/********************************************************************
Minecraft: Pocket Edition - Decompilation Project
Copyright (C) 2023 iProgramInCpp
The following code is licensed under the BSD 1 clause license.
SPDX-License-Identifier: BSD-1-Clause
********************************************************************/
@@ -108,9 +108,9 @@ void Gui::renderVignette(float a2, int a3, int a4)
Tesselator& t = Tesselator::instance;
t.begin();
t.vertexUV(0.0f, a4, -90.0f, 0.0f, 1.0f);
t.vertexUV(a3, a4, -90.0f, 1.0f, 1.0f);
t.vertexUV(a3, 0.0f, -90.0f, 1.0f, 0.0f);
t.vertexUV(0.0f, a4, -90.0f, 0.0f, 1.0f);
t.vertexUV(a3, a4, -90.0f, 1.0f, 1.0f);
t.vertexUV(a3, 0.0f, -90.0f, 1.0f, 0.0f);
t.vertexUV(0.0f, 0.0f, -90.0f, 0.0f, 0.0f);
t.draw();
@@ -134,7 +134,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
if (!m->m_pLevel || !m->m_pLocalPlayer)
return;
bool isTouchscreen = m->isTouchscreen();
//bool isTouchscreen = m->isTouchscreen();
field_4 = -90.0f;
@@ -150,7 +150,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
field_4 = -90.0f;
int width = Minecraft::width * InvGuiScale,
int width = Minecraft::width * InvGuiScale,
height = Minecraft::height * InvGuiScale;
#ifdef ENH_TRANSPARENT_HOTBAR
@@ -166,7 +166,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
blit(cenX - hotbarWidth / 2, height - 22, 0, 0, hotbarWidth, 22, 0, 0);
// selection mark
blit(cenX - 1 - hotbarWidth / 2 + 20 * pInventory->m_SelectedHotbarSlot, height - 23, 0, 22, 24, 22, 0, 0);
blit(cenX - 1 - hotbarWidth / 2 + 20 * pInventory->m_selectedHotbarSlot, height - 23, 0, 22, 24, 22, 0, 0);
m->m_pTextures->loadAndBindTexture("gui/icons.png");
@@ -187,7 +187,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
else
{
// if needed, draw feedback
// NOTE: real Minecraft PE takes it directly from the gamemode as "current progress" and
// "last progress". Well guess what? The game mode in question updates our field_8 with
// the pre-interpolated break progress! Isn't that awesome?!
@@ -298,8 +298,8 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
if (m->m_pLocalPlayer->isUnderLiquid(Material::water))
{
int breathRaw = m->m_pLocalPlayer->field_BC;
int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f));
int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull;
int breathFull = int(ceilf((float(breathRaw - 2) * 10.0f) / 300.0f));
int breathMeter = int(ceilf((float(breathRaw) * 10.0f) / 300.0f)) - breathFull;
int bubbleX = cenX - 191;
int bubbleY = height - 19;
@@ -334,7 +334,7 @@ void Gui::render(float f, bool bHaveScreen, int mouseX, int mouseY)
slotX += 20;
}
slotX = cenX - hotbarWidth / 2 + 3;
for (int i = 0; i < nSlots - diff; i++)
{
@@ -460,7 +460,7 @@ void Gui::handleKeyPressed(int keyCode)
if (m_pMinecraft->getOptions()->isKey(KM_SLOT_R, keyCode))
{
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
if (*slot <= maxItems)
(*slot)++;
@@ -469,7 +469,7 @@ void Gui::handleKeyPressed(int keyCode)
}
if (m_pMinecraft->getOptions()->isKey(KM_SLOT_L, keyCode))
{
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_SelectedHotbarSlot;
int* slot = &m_pMinecraft->m_pLocalPlayer->m_pInventory->m_selectedHotbarSlot;
if (*slot > 0)
(*slot)--;
@@ -490,10 +490,10 @@ void Gui::handleKeyPressed(int keyCode)
void Gui::renderMessages(bool bShowAll)
{
//int width = Minecraft::width * InvGuiScale,
int height = Minecraft::height * InvGuiScale;
int height = Minecraft::height * InvGuiScale;
int topEdge = height - 49;
for (int i = 0; i < int(m_guiMessages.size()); i++)
{
GuiMessage& msg = m_guiMessages[i];
@@ -503,7 +503,7 @@ void Gui::renderMessages(bool bShowAll)
int bkgdColor = 0x7F000000, textColor = 0xFFFFFFFF;
float fade = 1.0f;
if (!bShowAll)
{
fade = 10.0f * (1.0f - (float(msg.field_18) / 200.0f));
@@ -553,4 +553,4 @@ RectangleArea Gui::getRectangleArea(bool b)
Minecraft::height - 24.0f / InvGuiScale,
centerX + hotbarWidthHalf,
Minecraft::height);
}
}

View File

@@ -123,7 +123,7 @@ float WorldSelectionList::getPos(float f)
if (field_D8 != 1)
return RolledSelectionList::getPos(f);
return Lerp(WorldSelectionList_Static1(field_54, field_58, field_5C, field_60),
return Mth::Lerp(WorldSelectionList_Static1(field_54, field_58, field_5C, field_60),
WorldSelectionList_Static1(field_54 + 1.0f, field_58, field_5C, field_60),
f);
}

View File

@@ -7,12 +7,14 @@
********************************************************************/
#include "IngameBlockSelectionScreen.hpp"
#include "PauseScreen.hpp"
#include "client/app/Minecraft.hpp"
#include "client/renderer/entity/ItemRenderer.hpp"
std::string g_sNotAvailableInDemoVersion = "Not available in the demo version";
IngameBlockSelectionScreen::IngameBlockSelectionScreen()
IngameBlockSelectionScreen::IngameBlockSelectionScreen() :
m_btnPause(0, "Pause")
{
m_selectedSlot = 0;
}
@@ -69,6 +71,14 @@ bool IngameBlockSelectionScreen::isAllowed(int slot)
void IngameBlockSelectionScreen::init()
{
m_btnPause.m_width = 40;
m_btnPause.m_xPos = 0;
m_btnPause.m_yPos = 0;
#if TARGET_OS_IPHONE != 0
if (m_pMinecraft->isTouchscreen())
m_buttons.push_back(&m_btnPause);
#endif
Inventory* pInv = getInventory();
int nItems = pInv->getNumItems();
@@ -148,8 +158,16 @@ void IngameBlockSelectionScreen::render(int x, int y, float f)
glEnable(GL_DEPTH_TEST);
}
void IngameBlockSelectionScreen::buttonClicked(Button* pButton)
{
if (pButton->m_buttonId == m_btnPause.m_buttonId)
m_pMinecraft->setScreen(new PauseScreen);
}
void IngameBlockSelectionScreen::mouseClicked(int x, int y, int type)
{
Screen::mouseClicked(x, y, type);
// not a left click
if (type != 1)
return;
@@ -161,6 +179,8 @@ void IngameBlockSelectionScreen::mouseClicked(int x, int y, int type)
void IngameBlockSelectionScreen::mouseReleased(int x, int y, int type)
{
Screen::mouseReleased(x, y, type);
// not a left click
if (type != 1)
return;

View File

@@ -31,11 +31,13 @@ public:
virtual void init() override;
virtual void render(int x, int y, float f) override;
virtual void buttonClicked(Button*) override;
virtual void mouseClicked(int x, int y, int type) override;
virtual void mouseReleased(int x, int y, int type) override;
virtual void removed() override;
private:
int m_selectedSlot;
Button m_btnPause;
};

View File

@@ -63,7 +63,7 @@ bool JoinGameScreen::handleBackEvent(bool b)
void JoinGameScreen::init()
{
const int BUTTON_WIDTH = 100;
const int BUTTON_WIDTH = 84;
m_btnBack.m_yPos = m_btnJoin.m_yPos = m_btnDirectConnect.m_yPos = m_height - 27;
m_btnBack.m_width = m_btnJoin.m_width = BUTTON_WIDTH;

View File

@@ -13,7 +13,7 @@
#include "SelectWorldScreen.hpp"
#include "JoinGameScreen.hpp"
#if defined(_WIN32) || defined(TARGET_OS_MAC)
#if defined(_WIN32) || (defined(TARGET_OS_MAC) && TARGET_OS_IPHONE == 0)
#define CAN_QUIT
#endif
@@ -75,7 +75,7 @@ const char* gSplashes[] =
"Minecraft!",
"Yaaay!",
"Multiplayer!",
"Not yet touch compatible!",// "Touch compatible!",
"Touch compatible!",
"Undocumented!",
"Ingots!",
"Exploding creepers!",
@@ -600,27 +600,27 @@ void StartMenuScreen::draw3dTitle(float f)
{
glPushMatrix();
glTranslatef(0.4f, 0.6f, -12.0f);
if (i == 0)
switch (i)
{
glClear(GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0f, -0.5f, -0.5f);
glEnable(GL_BLEND);
//force set alpha
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
case 0:
glClear(GL_DEPTH_BUFFER_BIT);
glTranslatef(0.0f, -0.5f, -0.5f);
glEnable(GL_BLEND);
//force set alpha
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
if (i == 1)
{
glDisable(GL_BLEND);
glClear(GL_DEPTH_BUFFER_BIT);
//revert
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
if (i == 2)
{
glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_COLOR, GL_ONE);
case 1:
glDisable(GL_BLEND);
glClear(GL_DEPTH_BUFFER_BIT);
//revert
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
break;
case 2:
glEnable(GL_BLEND);
//glBlendFunc(GL_SRC_COLOR, GL_ONE);
break;
}
glScalef(1.0f, -1.0f, 1.0f);
@@ -646,8 +646,7 @@ void StartMenuScreen::draw3dTitle(float f)
glPushMatrix();
TitleTile* pTTile = m_pTiles[y * Width + x];
// @TODO: After merging the iOS port, change to Mth::Lerp
float z = Lerp(pTTile->lastHeight, pTTile->height, f);
float z = Mth::Lerp(pTTile->lastHeight, pTTile->height, f);
float scale = 1.0f;
float bright = 1.0f;
float rotation = 180.0f;