Re-add scrollbar
This commit is contained in:
@@ -59,6 +59,8 @@ public class ClientSetup {
|
|||||||
ScreenManager.registerFactory(RSContainers.CONTROLLER, ControllerScreen::new);
|
ScreenManager.registerFactory(RSContainers.CONTROLLER, ControllerScreen::new);
|
||||||
ScreenManager.registerFactory(RSContainers.DISK_DRIVE, DiskDriveScreen::new);
|
ScreenManager.registerFactory(RSContainers.DISK_DRIVE, DiskDriveScreen::new);
|
||||||
ScreenManager.registerFactory(RSContainers.GRID, new GridScreenFactory());
|
ScreenManager.registerFactory(RSContainers.GRID, new GridScreenFactory());
|
||||||
|
|
||||||
|
RSKeyBindings.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
@@ -1,7 +1,13 @@
|
|||||||
package com.raoulvdberge.refinedstorage;
|
package com.raoulvdberge.refinedstorage;
|
||||||
|
|
||||||
|
import net.minecraft.client.settings.KeyBinding;
|
||||||
|
import net.minecraft.client.util.InputMappings;
|
||||||
|
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||||
|
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||||
|
import org.lwjgl.glfw.GLFW;
|
||||||
|
|
||||||
public final class RSKeyBindings {
|
public final class RSKeyBindings {
|
||||||
/*public static final KeyBinding FOCUS_SEARCH_BAR = new KeyBinding("key.refinedstorage.focusSearchBar", KeyConflictContext.GUI, Keyboard.KEY_TAB, "Refined Storage");
|
/*
|
||||||
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding("key.refinedstorage.clearGridCraftingMatrix", KeyConflictContext.GUI, KeyModifier.CONTROL, Keyboard.KEY_X, "Refined Storage");
|
public static final KeyBinding CLEAR_GRID_CRAFTING_MATRIX = new KeyBinding("key.refinedstorage.clearGridCraftingMatrix", KeyConflictContext.GUI, KeyModifier.CONTROL, Keyboard.KEY_X, "Refined Storage");
|
||||||
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding("key.refinedstorage.openWirelessGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_GRID = new KeyBinding("key.refinedstorage.openWirelessGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding("key.refinedstorage.openWirelessFluidGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_FLUID_GRID = new KeyBinding("key.refinedstorage.openWirelessFluidGrid", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
@@ -9,14 +15,16 @@ public final class RSKeyBindings {
|
|||||||
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding("key.refinedstorage.openWirelessCraftingMonitor", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
public static final KeyBinding OPEN_WIRELESS_CRAFTING_MONITOR = new KeyBinding("key.refinedstorage.openWirelessCraftingMonitor", KeyConflictContext.IN_GAME, 0, "Refined Storage");
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ClientRegistry.registerKeyBinding(FOCUS_SEARCH_BAR);
|
|
||||||
ClientRegistry.registerKeyBinding(CLEAR_GRID_CRAFTING_MATRIX);
|
ClientRegistry.registerKeyBinding(CLEAR_GRID_CRAFTING_MATRIX);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_FLUID_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_FLUID_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_PORTABLE_GRID);
|
ClientRegistry.registerKeyBinding(OPEN_PORTABLE_GRID);
|
||||||
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_CRAFTING_MONITOR);
|
ClientRegistry.registerKeyBinding(OPEN_WIRELESS_CRAFTING_MONITOR);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
public static final KeyBinding FOCUS_SEARCH_BAR = new KeyBinding("key.refinedstorage.focusSearchBar", KeyConflictContext.GUI, InputMappings.Type.KEYSYM, GLFW.GLFW_KEY_TAB, "Refined Storage");
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
// TODO
|
ClientRegistry.registerKeyBinding(FOCUS_SEARCH_BAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,33 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
|
|
||||||
public class GridOpenHandler implements Runnable {
|
|
||||||
//private MessageGridOpen message;
|
|
||||||
|
|
||||||
//public GridOpenHandler(MessageGridOpen message) {
|
|
||||||
// this.message = message;
|
|
||||||
//}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
PlayerEntity player = Minecraft.getInstance().player;
|
|
||||||
|
|
||||||
//Pair<IGrid, TileEntity> grid = API.instance().getGridManager().createGrid(message.getGridId(), player, message.getStack(), message.getPos());
|
|
||||||
|
|
||||||
//if (grid == null) {
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//GuiGrid gui = new GuiGrid(null, null, grid.getLeft());
|
|
||||||
|
|
||||||
// @Volatile: Just set the windowId: from OpenGuiHandler#process
|
|
||||||
/*TODO player.openContainer = new ContainerGrid(grid.getLeft(), gui, grid.getRight() instanceof TileBase ? (TileBase) grid.getRight() : null, player);
|
|
||||||
player.openContainer.windowId = message.getWindowId();
|
|
||||||
|
|
||||||
gui.inventorySlots = player.openContainer;
|
|
||||||
|
|
||||||
FMLClientHandler.instance().showGuiScreen(gui);*/
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,93 +0,0 @@
|
|||||||
package com.raoulvdberge.refinedstorage.network;
|
|
||||||
|
|
||||||
import com.raoulvdberge.refinedstorage.apiimpl.network.grid.GridOpenHandler;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
|
||||||
import net.minecraftforge.fml.common.network.ByteBufUtils;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
|
|
||||||
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class MessageGridOpen implements IMessage, IMessageHandler<MessageGridOpen, IMessage> {
|
|
||||||
private int windowId;
|
|
||||||
@Nullable
|
|
||||||
private BlockPos pos;
|
|
||||||
@Nullable
|
|
||||||
private ItemStack stack;
|
|
||||||
private int gridId;
|
|
||||||
|
|
||||||
public MessageGridOpen() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public MessageGridOpen(int windowId, @Nullable BlockPos pos, int gridId, @Nullable ItemStack stack) {
|
|
||||||
if (pos == null && stack == null) {
|
|
||||||
throw new IllegalArgumentException("Can't be both null");
|
|
||||||
}
|
|
||||||
|
|
||||||
this.windowId = windowId;
|
|
||||||
this.pos = pos;
|
|
||||||
this.stack = stack;
|
|
||||||
this.gridId = gridId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fromBytes(ByteBuf buf) {
|
|
||||||
windowId = buf.readInt();
|
|
||||||
gridId = buf.readInt();
|
|
||||||
|
|
||||||
if (buf.readBoolean()) {
|
|
||||||
pos = new BlockPos(buf.readInt(), buf.readInt(), buf.readInt());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (buf.readBoolean()) {
|
|
||||||
stack = ByteBufUtils.readItemStack(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void toBytes(ByteBuf buf) {
|
|
||||||
buf.writeInt(windowId);
|
|
||||||
buf.writeInt(gridId);
|
|
||||||
|
|
||||||
buf.writeBoolean(pos != null);
|
|
||||||
if (pos != null) {
|
|
||||||
buf.writeInt(pos.getX());
|
|
||||||
buf.writeInt(pos.getY());
|
|
||||||
buf.writeInt(pos.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.writeBoolean(stack != null);
|
|
||||||
if (stack != null) {
|
|
||||||
ByteBufUtils.writeItemStack(buf, stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getWindowId() {
|
|
||||||
return windowId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public BlockPos getPos() {
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public ItemStack getStack() {
|
|
||||||
return stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getGridId() {
|
|
||||||
return gridId;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IMessage onMessage(MessageGridOpen message, MessageContext ctx) {
|
|
||||||
Minecraft.getMinecraft().addScheduledTask(new GridOpenHandler(message));
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -322,9 +322,9 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
|
|
||||||
tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, true);
|
tabs.drawForeground(x, y - tabs.getHeight(), mouseX, mouseY, true);
|
||||||
|
|
||||||
if (searchField != null) {
|
searchField.render(0, 0, 0);
|
||||||
searchField.render(0, 0, 0);
|
|
||||||
}
|
scrollbar.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -417,6 +417,10 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (scrollbar.mouseClicked(mouseX, mouseY, clickedButton)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
boolean clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
|
boolean clickedClear = clickedButton == 0 && isOverClear(mouseX - guiLeft, mouseY - guiTop);
|
||||||
boolean clickedCreatePattern = clickedButton == 0 && isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop);
|
boolean clickedCreatePattern = clickedButton == 0 && isOverCreatePattern(mouseX - guiLeft, mouseY - guiTop);
|
||||||
|
|
||||||
@@ -484,6 +488,23 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
return super.mouseClicked(mouseX, mouseY, clickedButton);
|
return super.mouseClicked(mouseX, mouseY, clickedButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void mouseMoved(double mx, double my) {
|
||||||
|
scrollbar.mouseMoved(mx, my);
|
||||||
|
|
||||||
|
super.mouseMoved(mx, my);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseReleased(double mx, double my, int button) {
|
||||||
|
return scrollbar.mouseReleased(mx, my, button) || super.mouseReleased(mx, my, button);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mouseScrolled(double x, double y, double delta) {
|
||||||
|
return this.scrollbar.mouseScrolled(x, y, delta) || super.mouseScrolled(x, y, delta);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
public boolean keyPressed(int key, int scanCode, int modifiers) {
|
||||||
if (searchField.keyPressed(key, scanCode, modifiers) || searchField.func_212955_f()) {
|
if (searchField.keyPressed(key, scanCode, modifiers) || searchField.func_212955_f()) {
|
||||||
@@ -514,10 +535,8 @@ public class GridScreen extends BaseScreen<GridContainer> implements IScreenInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateScrollbar() {
|
public void updateScrollbar() {
|
||||||
if (scrollbar != null) {
|
scrollbar.setEnabled(getRows() > getVisibleRows());
|
||||||
scrollbar.setEnabled(getRows() > getVisibleRows());
|
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
||||||
scrollbar.setMaxOffset(getRows() - getVisibleRows());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<IGridSorter> getSorters() {
|
public static List<IGridSorter> getSorters() {
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.raoulvdberge.refinedstorage.screen.widget;
|
package com.raoulvdberge.refinedstorage.screen.widget;
|
||||||
|
|
||||||
|
import com.raoulvdberge.refinedstorage.RSKeyBindings;
|
||||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||||
import net.minecraft.client.gui.FontRenderer;
|
import net.minecraft.client.gui.FontRenderer;
|
||||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||||
@@ -82,14 +83,13 @@ public class SearchWidget extends TextFieldWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO
|
if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKey().getKeyCode() && canLoseFocus) {
|
||||||
if (keyCode == RSKeyBindings.FOCUS_SEARCH_BAR.getKeyCode() && canLoseFocus) {
|
|
||||||
setFocused(!isFocused());
|
setFocused(!isFocused());
|
||||||
|
|
||||||
saveHistory();
|
saveHistory();
|
||||||
|
|
||||||
result = true;
|
result = true;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
listeners.forEach(Runnable::run);
|
listeners.forEach(Runnable::run);
|
||||||
|
Reference in New Issue
Block a user