mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-20 15:03:32 +00:00
Added mouse wheel support to the world selection screen.
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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user