Added "Search box mode" button to the Crafter Manager. Fixes #1755
This commit is contained in:
@@ -26,6 +26,7 @@ NOTE: Worlds that used Refined Storage 1.5.x are fully compatible with Refined S
|
||||
- Prevent accidental Grid scrollbar click after clicking JEI recipe transfer button (raoulvdberge)
|
||||
- Added a missing config option for Crafter Manager energy usage (raoulvdberge)
|
||||
- Added support for Disk Drive / Storage Block storage and capacity to OC integration (zangai)
|
||||
- Added "Search box mode" button to the Crafter Manager (raoulvdberge)
|
||||
- If an Interface is configured to expose the entire network storage (by configuring no export slots), it will no longer expose the entire RS storage, due to performance issues (raoulvdberge)
|
||||
- The Portable Grid no longer exposes a inventory for crossmod interaction, due to performance issues (raoulvdberge)
|
||||
- The Crafting Monitor is now resizable and its size can be configured (stretched, small, medium, large) (raoulvdberge)
|
||||
|
@@ -13,8 +13,10 @@ public class NetworkNodeCrafterManager extends NetworkNode {
|
||||
public static final String ID = "crafter_manager";
|
||||
|
||||
private static final String NBT_SIZE = "Size";
|
||||
private static final String NBT_SEARCH_BOX_MODE = "SearchBoxMode";
|
||||
|
||||
private int size = IGrid.SIZE_STRETCH;
|
||||
private int searchBoxMode = IGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
|
||||
public NetworkNodeCrafterManager(World world, BlockPos pos) {
|
||||
super(world, pos);
|
||||
@@ -49,6 +51,7 @@ public class NetworkNodeCrafterManager extends NetworkNode {
|
||||
super.writeConfiguration(tag);
|
||||
|
||||
tag.setInteger(NBT_SIZE, size);
|
||||
tag.setInteger(NBT_SEARCH_BOX_MODE, searchBoxMode);
|
||||
|
||||
return tag;
|
||||
}
|
||||
@@ -60,6 +63,18 @@ public class NetworkNodeCrafterManager extends NetworkNode {
|
||||
if (tag.hasKey(NBT_SIZE)) {
|
||||
size = tag.getInteger(NBT_SIZE);
|
||||
}
|
||||
|
||||
if (tag.hasKey(NBT_SEARCH_BOX_MODE)) {
|
||||
searchBoxMode = tag.getInteger(NBT_SEARCH_BOX_MODE);
|
||||
}
|
||||
}
|
||||
|
||||
public int getSearchBoxMode() {
|
||||
return world.isRemote ? TileCrafterManager.SEARCH_BOX_MODE.getValue() : searchBoxMode;
|
||||
}
|
||||
|
||||
public void setSearchBoxMode(int searchBoxMode) {
|
||||
this.searchBoxMode = searchBoxMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -5,10 +5,7 @@ import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.apiimpl.network.node.NetworkNodeCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.container.ContainerCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.container.slot.SlotCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.Scrollbar;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonGridSize;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.SideButtonRedstoneMode;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.TextFieldSearch;
|
||||
import com.raoulvdberge.refinedstorage.gui.control.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.util.RenderUtils;
|
||||
@@ -33,6 +30,10 @@ public class GuiCrafterManager extends GuiBase implements IResizableDisplay {
|
||||
this.crafterManager = crafterManager;
|
||||
}
|
||||
|
||||
public NetworkNodeCrafterManager getCrafterManager() {
|
||||
return crafterManager;
|
||||
}
|
||||
|
||||
public void setContainer(ContainerCrafterManager container) {
|
||||
this.container = container;
|
||||
this.inventorySlots = container;
|
||||
@@ -95,6 +96,7 @@ public class GuiCrafterManager extends GuiBase implements IResizableDisplay {
|
||||
@Override
|
||||
public void init(int x, int y) {
|
||||
addSideButton(new SideButtonRedstoneMode(this, TileCrafterManager.REDSTONE_MODE));
|
||||
addSideButton(new SideButtonCrafterManagerSearchBoxMode(this));
|
||||
addSideButton(new SideButtonGridSize(this, () -> crafterManager.getSize(), size -> TileDataManager.setParameter(TileCrafterManager.SIZE, size)));
|
||||
|
||||
this.scrollbar = new Scrollbar(174, getTopHeight(), 12, (getVisibleRows() * 18) - 2);
|
||||
@@ -112,6 +114,7 @@ public class GuiCrafterManager extends GuiBase implements IResizableDisplay {
|
||||
if (searchField == null) {
|
||||
searchField = new TextFieldSearch(0, fontRenderer, sx, sy, 88 - 6);
|
||||
searchField.addListener(() -> container.initSlots(null));
|
||||
searchField.setMode(crafterManager.getSearchBoxMode());
|
||||
} else {
|
||||
searchField.x = sx;
|
||||
searchField.y = sy;
|
||||
@@ -203,4 +206,8 @@ public class GuiCrafterManager extends GuiBase implements IResizableDisplay {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TextFieldSearch getSearchField() {
|
||||
return searchField;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiBase;
|
||||
import com.raoulvdberge.refinedstorage.gui.GuiCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||
import com.raoulvdberge.refinedstorage.tile.TileCrafterManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SideButtonCrafterManagerSearchBoxMode extends SideButton {
|
||||
public SideButtonCrafterManagerSearchBoxMode(GuiCrafterManager gui) {
|
||||
super(gui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode") + "\n" + TextFormatting.GRAY + GuiBase.t("sidebutton.refinedstorage:grid.search_box_mode." + ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawButtonIcon(int x, int y) {
|
||||
int mode = ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode();
|
||||
|
||||
gui.drawTexture(x, y, mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED ? 16 : 0, 96, 16, 16);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed() {
|
||||
int mode = ((GuiCrafterManager) gui).getCrafterManager().getSearchBoxMode();
|
||||
|
||||
if (mode == IGrid.SEARCH_BOX_MODE_NORMAL) {
|
||||
mode = IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED;
|
||||
} else if (mode == IGrid.SEARCH_BOX_MODE_NORMAL_AUTOSELECTED) {
|
||||
if (IntegrationJEI.isLoaded()) {
|
||||
mode = IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED;
|
||||
} else {
|
||||
mode = IGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
}
|
||||
} else if (mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED) {
|
||||
mode = IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED;
|
||||
} else if (mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED) {
|
||||
mode = IGrid.SEARCH_BOX_MODE_NORMAL;
|
||||
}
|
||||
|
||||
TileDataManager.setParameter(TileCrafterManager.SEARCH_BOX_MODE, mode);
|
||||
}
|
||||
}
|
@@ -43,6 +43,6 @@ public class SideButtonGridSearchBoxMode extends SideButton {
|
||||
|
||||
((GuiGrid) gui).getGrid().onSearchBoxModeChanged(mode);
|
||||
|
||||
((GuiGrid) gui).updateSearchFieldFocus(mode);
|
||||
((GuiGrid) gui).getSearchField().setMode(mode);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,9 @@
|
||||
package com.raoulvdberge.refinedstorage.gui.control;
|
||||
|
||||
import com.raoulvdberge.refinedstorage.RSKeyBindings;
|
||||
import com.raoulvdberge.refinedstorage.api.network.grid.IGrid;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.RSJEIPlugin;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraftforge.fml.common.ObfuscationReflectionHelper;
|
||||
@@ -11,18 +14,25 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class TextFieldSearch extends GuiTextField {
|
||||
private static final List<String> SEARCH_HISTORY = new ArrayList<>();
|
||||
private static final List<String> HISTORY = new ArrayList<>();
|
||||
|
||||
private int searchHistoryIndex = -1;
|
||||
private int mode;
|
||||
private int historyIndex = -1;
|
||||
|
||||
private List<Runnable> listeners = new LinkedList<>();
|
||||
|
||||
public TextFieldSearch(int componentId, FontRenderer fontRenderer, int x, int y, int width) {
|
||||
super(componentId, fontRenderer, x, y, width, fontRenderer.FONT_HEIGHT);
|
||||
|
||||
setEnableBackgroundDrawing(false);
|
||||
setVisible(true);
|
||||
setTextColor(16777215);
|
||||
this.setEnableBackgroundDrawing(false);
|
||||
this.setVisible(true);
|
||||
this.setTextColor(16777215);
|
||||
|
||||
this.listeners.add(() -> {
|
||||
if (IntegrationJEI.isLoaded() && (mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || mode == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
||||
RSJEIPlugin.INSTANCE.getRuntime().getIngredientFilter().setFilterText(getText());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void addListener(Runnable listener) {
|
||||
@@ -83,24 +93,28 @@ public class TextFieldSearch extends GuiTextField {
|
||||
result = true;
|
||||
}
|
||||
|
||||
if (result) {
|
||||
listeners.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void updateSearchHistory(int delta) {
|
||||
if (SEARCH_HISTORY.isEmpty()) {
|
||||
if (HISTORY.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (searchHistoryIndex == -1) {
|
||||
searchHistoryIndex = SEARCH_HISTORY.size();
|
||||
if (historyIndex == -1) {
|
||||
historyIndex = HISTORY.size();
|
||||
}
|
||||
|
||||
searchHistoryIndex += delta;
|
||||
historyIndex += delta;
|
||||
|
||||
if (searchHistoryIndex < 0) {
|
||||
searchHistoryIndex = 0;
|
||||
} else if (searchHistoryIndex > SEARCH_HISTORY.size() - 1) {
|
||||
searchHistoryIndex = SEARCH_HISTORY.size() - 1;
|
||||
if (historyIndex < 0) {
|
||||
historyIndex = 0;
|
||||
} else if (historyIndex > HISTORY.size() - 1) {
|
||||
historyIndex = HISTORY.size() - 1;
|
||||
|
||||
if (delta == 1) {
|
||||
setText("");
|
||||
@@ -111,18 +125,25 @@ public class TextFieldSearch extends GuiTextField {
|
||||
}
|
||||
}
|
||||
|
||||
setText(SEARCH_HISTORY.get(searchHistoryIndex));
|
||||
setText(HISTORY.get(historyIndex));
|
||||
|
||||
listeners.forEach(Runnable::run);
|
||||
}
|
||||
|
||||
private void saveHistory() {
|
||||
if (!SEARCH_HISTORY.isEmpty() && SEARCH_HISTORY.get(SEARCH_HISTORY.size() - 1).equals(getText())) {
|
||||
if (!HISTORY.isEmpty() && HISTORY.get(HISTORY.size() - 1).equals(getText())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getText().trim().isEmpty()) {
|
||||
SEARCH_HISTORY.add(getText());
|
||||
HISTORY.add(getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void setMode(int mode) {
|
||||
this.mode = mode;
|
||||
|
||||
this.setCanLoseFocus(!IGrid.isSearchBoxModeWithAutoselection(mode));
|
||||
this.setFocused(IGrid.isSearchBoxModeWithAutoselection(mode));
|
||||
}
|
||||
}
|
||||
|
@@ -17,8 +17,6 @@ import com.raoulvdberge.refinedstorage.gui.grid.stack.IGridStack;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewFluid;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.GridViewItem;
|
||||
import com.raoulvdberge.refinedstorage.gui.grid.view.IGridView;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.IntegrationJEI;
|
||||
import com.raoulvdberge.refinedstorage.integration.jei.RSJEIPlugin;
|
||||
import com.raoulvdberge.refinedstorage.network.*;
|
||||
import com.raoulvdberge.refinedstorage.tile.data.TileDataManager;
|
||||
import com.raoulvdberge.refinedstorage.tile.grid.TileGrid;
|
||||
@@ -30,7 +28,6 @@ import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -114,13 +111,8 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
|
||||
if (searchField == null) {
|
||||
searchField = new TextFieldSearch(0, fontRenderer, sx, sy, 88 - 6);
|
||||
searchField.addListener(() -> {
|
||||
view.sort();
|
||||
|
||||
updateJEI();
|
||||
});
|
||||
|
||||
updateSearchFieldFocus(grid.getSearchBoxMode());
|
||||
searchField.addListener(view::sort);
|
||||
searchField.setMode(grid.getSearchBoxMode());
|
||||
} else {
|
||||
searchField.x = sx;
|
||||
searchField.y = sy;
|
||||
@@ -624,10 +616,6 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
if (checkHotbarKeys(keyCode)) {
|
||||
// NO OP
|
||||
} else if (searchField.textboxKeyTyped(character, keyCode)) {
|
||||
updateJEI();
|
||||
|
||||
view.sort();
|
||||
|
||||
keyHandled = true;
|
||||
} else if (keyCode == RSKeyBindings.CLEAR_GRID_CRAFTING_MATRIX.getKeyCode()) {
|
||||
RS.INSTANCE.network.sendToServer(new MessageGridClear());
|
||||
@@ -636,20 +624,7 @@ public class GuiGrid extends GuiBase implements IResizableDisplay {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateJEI() {
|
||||
if (IntegrationJEI.isLoaded() && (grid.getSearchBoxMode() == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED || grid.getSearchBoxMode() == IGrid.SEARCH_BOX_MODE_JEI_SYNCHRONIZED_AUTOSELECTED)) {
|
||||
RSJEIPlugin.INSTANCE.getRuntime().getIngredientFilter().setFilterText(searchField.getText());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSearchFieldFocus(int mode) {
|
||||
if (searchField != null) {
|
||||
searchField.setCanLoseFocus(!IGrid.isSearchBoxModeWithAutoselection(mode));
|
||||
searchField.setFocused(IGrid.isSearchBoxModeWithAutoselection(mode));
|
||||
}
|
||||
}
|
||||
|
||||
public GuiTextField getSearchField() {
|
||||
public TextFieldSearch getSearchField() {
|
||||
return searchField;
|
||||
}
|
||||
|
||||
|
@@ -16,9 +16,16 @@ public class TileCrafterManager extends TileNode<NetworkNodeCrafterManager> {
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, GuiBase::initGui));
|
||||
public static final TileDataParameter<Integer, TileCrafterManager> SEARCH_BOX_MODE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSearchBoxMode(), (t, v) -> {
|
||||
if (IGrid.isValidSearchBoxMode(v)) {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiCrafterManager.class, crafterManager -> crafterManager.getSearchField().setMode(p)));
|
||||
|
||||
public TileCrafterManager() {
|
||||
dataManager.addWatchedParameter(SIZE);
|
||||
dataManager.addWatchedParameter(SEARCH_BOX_MODE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -42,7 +42,7 @@ public class TileGrid extends TileNode<NetworkNodeGrid> {
|
||||
t.getNode().setSearchBoxMode(v);
|
||||
t.getNode().markDirty();
|
||||
}
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getSearchField().setMode(p)));
|
||||
public static final TileDataParameter<Integer, TileGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, t -> t.getNode().getSize(), (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.getNode().setSize(v);
|
||||
|
@@ -81,7 +81,7 @@ public class TilePortableGrid extends TileBase implements IGrid, IPortableGrid,
|
||||
t.setSearchBoxMode(v);
|
||||
t.markDirty();
|
||||
}
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.updateSearchFieldFocus(p)));
|
||||
}, (initial, p) -> GuiBase.executeLater(GuiGrid.class, grid -> grid.getSearchField().setMode(p)));
|
||||
public static final TileDataParameter<Integer, TilePortableGrid> SIZE = new TileDataParameter<>(DataSerializers.VARINT, 0, TilePortableGrid::getSize, (t, v) -> {
|
||||
if (IGrid.isValidSize(v)) {
|
||||
t.setSize(v);
|
||||
|
Reference in New Issue
Block a user