Fixes and enhancements from my MCPE repository. (https://github.com/mschiller890/mcpe64)

This commit is contained in:
Michal Schiller
2026-03-10 19:31:40 +01:00
parent 0c97ceb340
commit 2fc323639a
69 changed files with 2509 additions and 639 deletions

View File

@@ -283,8 +283,7 @@ SelectWorldScreen::SelectWorldScreen()
bHeader (0, "Select world"),
bWorldView(4, ""),
worldsList(NULL),
_hasStartedLevel(false),
_state(_STATE_DEFAULT)
_hasStartedLevel(false)
{
bDelete.active = false;
@@ -349,9 +348,9 @@ void SelectWorldScreen::setupPositions() {
void SelectWorldScreen::buttonClicked(Button* button)
{
if (button->id == bCreate.id) {
if (_state == _STATE_DEFAULT && !_hasStartedLevel) {
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_CREATE_NEW_WORLD);
_state = _STATE_CREATEWORLD;
if (!_hasStartedLevel) {
std::string name = getUniqueLevelName("World");
minecraft->setScreen(new SimpleChooseLevelScreen(name));
}
}
if (button->id == bDelete.id) {
@@ -392,9 +391,10 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
void SelectWorldScreen::tick()
{
#if 0
if (_state == _STATE_CREATEWORLD) {
#if defined(RPI)
std::string levelId = getUniqueLevelName("perf");
std::string levelId = getUniqueLevelName("World");
//int seed = Util::hashCode("/r/Minecraft");
LevelSettings settings(getEpochTimeS(), GameType::Creative);
minecraft->selectLevel(levelId, levelId, settings);
@@ -402,7 +402,7 @@ void SelectWorldScreen::tick()
minecraft->setScreen(new ProgressScreen());
_hasStartedLevel = true;
#elif defined(PLATFORM_DESKTOP)
std::string name = getUniqueLevelName("perf");
std::string name = getUniqueLevelName("World");
minecraft->setScreen(new SimpleChooseLevelScreen(name));
#else
int status = minecraft->platform()->getUserInputStatus();
@@ -461,14 +461,15 @@ void SelectWorldScreen::tick()
worldsList->hasPickedLevel = false;
return;
}
#endif
worldsList->tick();
if (worldsList->hasPickedLevel) {
if (worldsList->pickedIndex == worldsList->levels.size()) {
worldsList->hasPickedLevel = false;
minecraft->platform()->createUserInput(DialogDefinitions::DIALOG_CREATE_NEW_WORLD);
_state = _STATE_CREATEWORLD;
std::string name = getUniqueLevelName("World");
minecraft->setScreen(new SimpleChooseLevelScreen(name));
} else {
minecraft->selectLevel(worldsList->pickedLevel.id, worldsList->pickedLevel.name, LevelSettings::None());
minecraft->hostMultiplayer();

View File

@@ -112,9 +112,6 @@ private:
bool _mouseHasBeenUp;
bool _hasStartedLevel;
int _state;
static const int _STATE_DEFAULT = 0;
static const int _STATE_CREATEWORLD = 1;
//LevelStorageSource* levels;
};
};

View File

@@ -22,6 +22,62 @@
#include "../DialogDefinitions.h"
#include "../SimpleChooseLevelScreen.h"
//
// Buy Button implementation
//
BuyButton::BuyButton(int id)
: super(id, "")
{
ImageDef def;
// Setup the source rectangle
def.setSrc(IntRectangle(64, 182, 190, 55));
def.width = 75;//rc.w / 3;
def.height = 75 * (55.0f / 190.0f);//rc.h / 3;
def.name = "gui/gui.png";
setImageDef(def, true);
}
void BuyButton::render(Minecraft* minecraft, int xm, int ym) {
glColor4f2(1, 1, 1, 1);
bool hovered = active && (minecraft->useTouchscreen()? (xm >= x && ym >= y && xm < x + width && ym < y + height) : false);
renderBg(minecraft, xm, ym);
TextureId texId = (_imageDef.name.length() > 0)? minecraft->textures->loadAndBindTexture(_imageDef.name) : Textures::InvalidId;
if ( Textures::isTextureIdValid(texId) ) {
const ImageDef& d = _imageDef;
Tesselator& t = Tesselator::instance;
t.begin();
if (!active) t.color(0xff808080);
else if (hovered||selected) t.color(0xffcccccc);
//else t.color(0xffe0e0e0);
else t.color(0xffffffff);
float hx = ((float) d.width) * 0.5f;
float hy = ((float) d.height) * 0.5f;
const float cx = ((float)x+d.x) + hx;
const float cy = ((float)y+d.y) + hy;
if (hovered) {
hx *= 0.95f;
hy *= 0.95f;
}
const TextureData* td = minecraft->textures->getTemporaryTextureData(texId);
const IntRectangle* src = _imageDef.getSrc();
if (td != NULL && src != NULL) {
float u0 = (src->x) / (float)td->w;
float u1 = (src->x+src->w) / (float)td->w;
float v0 = (src->y) / (float)td->h;
float v1 = (src->y+src->h) / (float)td->h;
t.vertexUV(cx-hx, cy-hy, blitOffset, u0, v0);
t.vertexUV(cx-hx, cy+hy, blitOffset, u0, v1);
t.vertexUV(cx+hx, cy+hy, blitOffset, u1, v1);
t.vertexUV(cx+hx, cy-hy, blitOffset, u1, v0);
}
t.draw();
}
}
namespace Touch {
//
@@ -32,7 +88,8 @@ namespace Touch {
StartMenuScreen::StartMenuScreen()
: bHost( 2, "Start Game"),
bJoin( 3, "Join Game"),
bOptions( 4, "Options")
bOptions( 4, "Options"),
bBuy( 5)
{
ImageDef def;
bJoin.width = 75;
@@ -61,19 +118,21 @@ void StartMenuScreen::init()
buttons.push_back(&bJoin);
buttons.push_back(&bOptions);
//buttons.push_back(&bTest);
tabButtons.push_back(&bHost);
tabButtons.push_back(&bJoin);
tabButtons.push_back(&bOptions);
#ifdef DEMO_MODE
buttons.push_back(&bBuy);
tabButtons.push_back(&bBuy);
#endif
copyright = "\xffMojang AB";//. Do not distribute!";
#ifdef PRE_ANDROID23
std::string versionString = Common::getGameVersionString("j");
#else
std::string versionString = Common::getGameVersionString();
#endif
// always show base version string
std::string versionString = Common::getGameVersionString();
#ifdef DEMO_MODE
#ifdef __APPLE__
@@ -103,31 +162,26 @@ void StartMenuScreen::setupPositions() {
bOptions.y = yBase;
//#endif
//bTest.x = 0; //width - bTest.w;
//bTest.y = height - bTest.h;
// Center buttons
bJoin.x = 0*buttonWidth + (int)(1*spacing);
bHost.x = 1*buttonWidth + (int)(2*spacing);
bOptions.x = 2*buttonWidth + (int)(3*spacing);
//bBuy.y = bOptions.y - bBuy.h - 6;
//bBuy.x = bOptions.x + bOptions.w - bBuy.w;
bBuy.y = height - bBuy.height - 3;
bBuy.x = (width - bBuy.width) / 2;
copyrightPosX = width - minecraft->font->width(copyright) - 1;
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
}
void StartMenuScreen::tick() {
Screen::tick();
_updateLicense();
}
void StartMenuScreen::buttonClicked(::Button* button) {
//if (button->id == bTest.id) {
// minecraft->selectLevel("Broken", "Broken", 1317199248);
// minecraft->hostMultiplayer();
// minecraft->setScreen(new ProgressScreen());
//}
if (button->id == bHost.id)
{
#if defined(DEMO_MODE) || defined(APPLE_DEMO_PROMOTION)
@@ -149,6 +203,11 @@ void StartMenuScreen::buttonClicked(::Button* button) {
{
minecraft->setScreen(new OptionsScreen());
}
if (button->id == bBuy.id)
{
minecraft->platform()->buyGame();
//minecraft->setScreen(new BuyGameScreen());
}
}
bool StartMenuScreen::isInGameScreen() { return false; }
@@ -187,6 +246,10 @@ void StartMenuScreen::render( int xm, int ym, float a )
drawString(font, version, versionPosX, (int)(y+h)+2, /*50,*/ 0xffcccccc);//0x666666);
drawString(font, copyright, copyrightPosX, height - 10, 0xffffff);
glColor4f2(1, 1, 1, 1);
if (Textures::isTextureIdValid(minecraft->textures->loadAndBindTexture("gui/logo/github.png")))
blit(2, height - 10, 0, 0, 8, 8, 256, 256);
drawString(font, "Kolyah35/minecraft-pe-0.6.1", 12, height - 10, 0xffcccccc);
//patch->draw(t, 0, 20);
}
Screen::render(xm, ym, a);
@@ -210,9 +273,21 @@ void StartMenuScreen::_updateLicense()
}
}
void StartMenuScreen::mouseClicked(int x, int y, int buttonNum) {
const int logoX = 2;
const int logoW = 8 + 2 + font->width("Kolyah35/minecraft-pe-0.6.1");
const int logoY = height - 10;
const int logoH = 10;
if (x >= logoX && x <= logoX + logoW && y >= logoY && y <= logoY + logoH)
minecraft->platform()->openURL("https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1");
else
Screen::mouseClicked(x, y, buttonNum);
}
bool StartMenuScreen::handleBackEvent( bool isDown ) {
minecraft->quit();
return true;
}
};
} // namespace Touch

View File

@@ -5,6 +5,14 @@
#include "../../components/LargeImageButton.h"
#include "../../components/TextBox.h"
class BuyButton: public ImageButton {
typedef ImageButton super;
public:
BuyButton(int id);
void render(Minecraft* minecraft, int xm, int ym);
};
namespace Touch {
class StartMenuScreen: public Screen
@@ -20,6 +28,7 @@ public:
void render(int xm, int ym, float a);
void buttonClicked(Button* button);
virtual void mouseClicked(int x, int y, int buttonNum);
bool handleBackEvent(bool isDown);
bool isInGameScreen();
private:
@@ -28,6 +37,7 @@ private:
LargeImageButton bHost;
LargeImageButton bJoin;
LargeImageButton bOptions;
BuyButton bBuy;
std::string copyright;
int copyrightPosX;