Proportional scrolling
This commit is contained in:
@@ -40,6 +40,7 @@ public class GuiController extends GuiBase {
|
||||
@Override
|
||||
public void update(int x, int y) {
|
||||
scrollbar.setCanScroll(getRows() > VISIBLE_ROWS);
|
||||
scrollbar.setScrollDelta((float) scrollbar.getScrollbarHeight() / (float) getRows());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -117,6 +117,7 @@ public class GuiGrid extends GuiBase {
|
||||
}
|
||||
|
||||
scrollbar.setCanScroll(getRows() > getVisibleRows());
|
||||
scrollbar.setScrollDelta((float) scrollbar.getScrollbarHeight() / (float) getRows());
|
||||
}
|
||||
|
||||
public int getOffset() {
|
||||
|
||||
@@ -10,6 +10,8 @@ public class Scrollbar {
|
||||
private int scrollbarWidth;
|
||||
private int scrollbarHeight;
|
||||
|
||||
private float scrollDelta = 15f;
|
||||
|
||||
private float currentScroll;
|
||||
private boolean wasClicking = false;
|
||||
private boolean isScrolling = false;
|
||||
@@ -21,6 +23,14 @@ public class Scrollbar {
|
||||
this.scrollbarHeight = scrollbarHeight;
|
||||
}
|
||||
|
||||
public int getScrollbarWidth() {
|
||||
return scrollbarWidth;
|
||||
}
|
||||
|
||||
public int getScrollbarHeight() {
|
||||
return scrollbarHeight;
|
||||
}
|
||||
|
||||
public void setCanScroll(boolean canScroll) {
|
||||
this.canScroll = canScroll;
|
||||
}
|
||||
@@ -49,6 +59,10 @@ public class Scrollbar {
|
||||
currentScroll = newCurrentScroll;
|
||||
}
|
||||
|
||||
public void setScrollDelta(float delta) {
|
||||
this.scrollDelta = delta;
|
||||
}
|
||||
|
||||
public void draw(GuiBase gui) {
|
||||
gui.bindTexture("icons.png");
|
||||
gui.drawTexture(gui.getGuiLeft() + x, gui.getGuiTop() + y + (int) currentScroll, canScroll() ? 232 : 244, 0, 12, 15);
|
||||
@@ -64,12 +78,10 @@ public class Scrollbar {
|
||||
|
||||
wheel = Math.max(Math.min(-wheel, 1), -1);
|
||||
|
||||
float delta = 15;
|
||||
|
||||
if (wheel == -1) {
|
||||
setCurrentScroll(currentScroll - delta);
|
||||
setCurrentScroll(currentScroll - scrollDelta);
|
||||
} else if (wheel == 1) {
|
||||
setCurrentScroll(currentScroll + delta);
|
||||
setCurrentScroll(currentScroll + scrollDelta);
|
||||
}
|
||||
|
||||
boolean down = Mouse.isButtonDown(0);
|
||||
|
||||
@@ -460,6 +460,7 @@ public class TileController extends TileBase implements IEnergyReceiver, INetwor
|
||||
|
||||
buf.writeInt(machines.size());
|
||||
|
||||
// @TODO: This won't work clientside for far machines, send itemstacks instead!
|
||||
for (TileMachine machine : machines) {
|
||||
buf.writeInt(machine.getPos().getX());
|
||||
buf.writeInt(machine.getPos().getY());
|
||||
|
||||
@@ -147,7 +147,7 @@ public class TileGrid extends TileMachine implements IGrid {
|
||||
|
||||
for (ItemStack craftedItem : craftedItemsList) {
|
||||
if (!player.inventory.addItemStackToInventory(craftedItem.copy())) {
|
||||
if (isConnected() && controller.push(craftedItem.copy())) {
|
||||
if (controller != null && controller.push(craftedItem.copy())) {
|
||||
// NO OP
|
||||
} else {
|
||||
InventoryUtils.dropStack(player.worldObj, craftedItem, player.getPosition().getX(), player.getPosition().getY(), player.getPosition().getZ());
|
||||
|
||||
Reference in New Issue
Block a user