forked from Kolyah35/minecraft-pe-0.6.1
Merge remote-tracking branch 'refs/remotes/origin/main'
This commit is contained in:
@@ -153,6 +153,11 @@ int IngameBlockSelectionScreen::getSlotPosY(int slotY) {
|
||||
return height - 16 - 3 - 22 * 2 - 22 * slotY;
|
||||
}
|
||||
|
||||
int IngameBlockSelectionScreen::getSlotHeight() {
|
||||
// same as non-touch implementation
|
||||
return 22;
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::mouseClicked(int x, int y, int buttonNum) {
|
||||
_pendingClose = _blockList->_clickArea->isInside((float)x, (float)y);
|
||||
if (!_pendingClose)
|
||||
@@ -166,6 +171,24 @@ void IngameBlockSelectionScreen::mouseReleased(int x, int y, int buttonNum) {
|
||||
super::mouseReleased(x, y, buttonNum);
|
||||
}
|
||||
|
||||
void IngameBlockSelectionScreen::mouseWheel(int dx, int dy, int xm, int ym)
|
||||
{
|
||||
if (dy == 0) return;
|
||||
if (_blockList) {
|
||||
float amount = -dy * getSlotHeight();
|
||||
_blockList->scrollBy(0, amount);
|
||||
}
|
||||
int cols = InventoryColumns;
|
||||
int maxIndex = InventorySize - 1;
|
||||
int idx = selectedItem;
|
||||
if (dy > 0) {
|
||||
if (idx >= cols) idx -= cols;
|
||||
} else {
|
||||
if (idx + cols <= maxIndex) idx += cols;
|
||||
}
|
||||
selectedItem = idx;
|
||||
}
|
||||
|
||||
bool IngameBlockSelectionScreen::addItem(const InventoryPane* pane, int itemId)
|
||||
{
|
||||
Inventory* inventory = minecraft->player->inventory;
|
||||
|
||||
@@ -39,12 +39,16 @@ public:
|
||||
protected:
|
||||
virtual void mouseClicked(int x, int y, int buttonNum);
|
||||
virtual void mouseReleased(int x, int y, int buttonNum);
|
||||
|
||||
// also support wheel scrolling
|
||||
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
|
||||
private:
|
||||
void renderDemoOverlay();
|
||||
|
||||
//int getLinearSlotId(int x, int y);
|
||||
int getSlotPosX(int slotX);
|
||||
int getSlotPosY(int slotY);
|
||||
int getSlotHeight();
|
||||
|
||||
private:
|
||||
int selectedItem;
|
||||
|
||||
@@ -129,6 +129,11 @@ void JoinGameScreen::buttonClicked(Button* button)
|
||||
//minecraft->locateMultiplayer();
|
||||
//minecraft->setScreen(new JoinGameScreen());
|
||||
}
|
||||
if(button->id == bJoinByIp.id) {
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
minecraft->screenChooser.setScreen(SCREEN_JOINBYIP);
|
||||
}
|
||||
|
||||
if (button->id == bBack.id)
|
||||
{
|
||||
minecraft->cancelLocateMultiplayer();
|
||||
|
||||
@@ -389,6 +389,26 @@ static char ILLEGAL_FILE_CHARACTERS[] = {
|
||||
'/', '\n', '\r', '\t', '\0', '\f', '`', '?', '*', '\\', '<', '>', '|', '\"', ':'
|
||||
};
|
||||
|
||||
void SelectWorldScreen::mouseWheel(int dx, int dy, int xm, int ym)
|
||||
{
|
||||
if (!worldsList) return;
|
||||
if (dy == 0) return;
|
||||
int num = worldsList->getNumberOfItems();
|
||||
int idx = worldsList->selectedItem;
|
||||
if (dy > 0) {
|
||||
if (idx > 0) {
|
||||
idx--;
|
||||
worldsList->stepLeft();
|
||||
}
|
||||
} else {
|
||||
if (idx < num - 1) {
|
||||
idx++;
|
||||
worldsList->stepRight();
|
||||
}
|
||||
}
|
||||
worldsList->selectedItem = idx;
|
||||
}
|
||||
|
||||
void SelectWorldScreen::tick()
|
||||
{
|
||||
#if 0
|
||||
|
||||
@@ -97,6 +97,9 @@ public:
|
||||
virtual void buttonClicked(Button* button);
|
||||
virtual void keyPressed(int eventKey);
|
||||
|
||||
// support for mouse wheel when desktop code uses touch variant
|
||||
virtual void mouseWheel(int dx, int dy, int xm, int ym) override;
|
||||
|
||||
bool isInGameScreen();
|
||||
private:
|
||||
void loadLevelSource();
|
||||
|
||||
@@ -29,7 +29,8 @@ namespace Touch {
|
||||
StartMenuScreen::StartMenuScreen()
|
||||
: bHost( 2, "Start Game"),
|
||||
bJoin( 3, "Join Game"),
|
||||
bOptions( 4, "Options")
|
||||
bOptions( 4, "Options"),
|
||||
bQuit( 5, "")
|
||||
{
|
||||
ImageDef def;
|
||||
bJoin.width = 75;
|
||||
@@ -58,6 +59,17 @@ void StartMenuScreen::init()
|
||||
buttons.push_back(&bJoin);
|
||||
buttons.push_back(&bOptions);
|
||||
|
||||
// add quit icon (same look as options header)
|
||||
{
|
||||
ImageDef def;
|
||||
def.name = "gui/touchgui.png";
|
||||
def.width = 34;
|
||||
def.height = 26;
|
||||
def.setSrc(IntRectangle(150, 0, (int)def.width, (int)def.height));
|
||||
bQuit.setImageDef(def, true);
|
||||
bQuit.scaleWhenPressed = false;
|
||||
buttons.push_back(&bQuit);
|
||||
}
|
||||
|
||||
tabButtons.push_back(&bHost);
|
||||
tabButtons.push_back(&bJoin);
|
||||
@@ -106,6 +118,10 @@ void StartMenuScreen::setupPositions() {
|
||||
bHost.x = 1*buttonWidth + (int)(2*spacing);
|
||||
bOptions.x = 2*buttonWidth + (int)(3*spacing);
|
||||
|
||||
// quit icon top-right (use size assigned in init)
|
||||
bQuit.x = width - bQuit.width;
|
||||
bQuit.y = 0;
|
||||
|
||||
copyrightPosX = width - minecraft->font->width(copyright) - 1;
|
||||
versionPosX = (width - minecraft->font->width(version)) / 2;// - minecraft->font->width(version) - 2;
|
||||
}
|
||||
@@ -133,6 +149,10 @@ void StartMenuScreen::buttonClicked(::Button* button) {
|
||||
{
|
||||
minecraft->setScreen(new OptionsScreen());
|
||||
}
|
||||
if (button == &bQuit)
|
||||
{
|
||||
minecraft->quit();
|
||||
}
|
||||
}
|
||||
|
||||
bool StartMenuScreen::isInGameScreen() { return false; }
|
||||
@@ -140,6 +160,10 @@ bool StartMenuScreen::isInGameScreen() { return false; }
|
||||
void StartMenuScreen::render( int xm, int ym, float a )
|
||||
{
|
||||
renderBackground();
|
||||
|
||||
// Show current username in the top-left corner
|
||||
std::string username = minecraft->options.username.empty() ? "unknown" : minecraft->options.username;
|
||||
drawString(font, std::string("Username: ") + username, 2, 2, 0xffffffff);
|
||||
|
||||
glEnable2(GL_BLEND);
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "../../Screen.h"
|
||||
#include "../../components/LargeImageButton.h"
|
||||
#include "../../components/ImageButton.h"
|
||||
#include "../../components/TextBox.h"
|
||||
|
||||
namespace Touch {
|
||||
@@ -27,6 +28,7 @@ private:
|
||||
LargeImageButton bHost;
|
||||
LargeImageButton bJoin;
|
||||
LargeImageButton bOptions;
|
||||
ImageButton bQuit; // X close icon
|
||||
|
||||
std::string copyright;
|
||||
int copyrightPosX;
|
||||
|
||||
Reference in New Issue
Block a user