mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-10-26 14:23:57 +00:00
Merge pull request #197 from ForestryMC/nei_tabs
Info tabs push NEI out of the way
This commit is contained in:
commit
40e6301eca
6 files changed
+183
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 ChickenBones
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,38 @@
|
||||
package codechicken.nei;
|
||||
|
||||
public class VisiblityData
|
||||
{
|
||||
public boolean showUtilityButtons = true;
|
||||
public boolean showStateButtons = true;
|
||||
/**
|
||||
* Item panel and associated buttons
|
||||
*/
|
||||
public boolean showItemPanel = true;
|
||||
/**
|
||||
* Item and search section
|
||||
*/
|
||||
public boolean showItemSection = true;
|
||||
/**
|
||||
* Dropdown and Item search field
|
||||
*/
|
||||
public boolean showSearchSection = true;
|
||||
/**
|
||||
* All widgets except options button
|
||||
*/
|
||||
public boolean showWidgets = true;
|
||||
/**
|
||||
* The entire NEI interface, aka hidden
|
||||
*/
|
||||
public boolean showNEI = true;
|
||||
public boolean enableDeleteMode = true;
|
||||
|
||||
public void translateDependancies()
|
||||
{
|
||||
if(!showNEI)
|
||||
showWidgets = false;
|
||||
if(!showWidgets)
|
||||
showItemSection = showUtilityButtons = showStateButtons = false;
|
||||
if(!showItemSection)
|
||||
showSearchSection = showItemPanel = false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* If this is implemented on a gui, it will be automatically registered
|
||||
*/
|
||||
public interface INEIGuiHandler
|
||||
{
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility);
|
||||
|
||||
/**
|
||||
* NEI will give the specified item to the InventoryRange returned if the player's inventory is full.
|
||||
* return null for no range
|
||||
*/
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item);
|
||||
|
||||
/**
|
||||
* @return A list of TaggedInventoryAreas that will be used with the savestates.
|
||||
*/
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui);
|
||||
|
||||
/**
|
||||
* Handles clicks while an itemstack has been dragged from the item panel. Use this to set configurable slots and the like.
|
||||
* Changes made to the stackSize of the dragged stack will be kept
|
||||
* @param gui The current gui instance
|
||||
* @param mousex The x position of the mouse
|
||||
* @param mousey The y position of the mouse
|
||||
* @param draggedStack The stack being dragged from the item panel
|
||||
* @param button The button presed
|
||||
* @return True if the drag n drop was handled. False to resume processing through other routes. The held stack will be deleted if draggedStack.stackSize == 0
|
||||
*/
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button);
|
||||
|
||||
/**
|
||||
* Used to prevent the item panel from drawing on top of other gui elements.
|
||||
* This function will also be called with a 1x1 size rectangle on the mouse position for determining if the given coordinate should override item panel functions such as scrolling
|
||||
* @param x The x coordinate of the rectangle bounding the slot
|
||||
* @param y The y coordinate of the rectangle bounding the slot
|
||||
* @param w The w coordinate of the rectangle bounding the slot
|
||||
* @param h The h coordinate of the rectangle bounding the slot
|
||||
* @return true if the item panel slot within the specified rectangle should not be rendered.
|
||||
*/
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h);
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package codechicken.nei.api;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class TaggedInventoryArea
|
||||
{
|
||||
public HashSet<Integer> slots = new HashSet<Integer>();
|
||||
public String tagName;
|
||||
/**
|
||||
* Only for player inventories.
|
||||
*/
|
||||
private IInventory inventory;
|
||||
/**
|
||||
* Other inventories
|
||||
*/
|
||||
private Container container;
|
||||
|
||||
public TaggedInventoryArea(InventoryPlayer invPlayer)
|
||||
{
|
||||
this("InventoryPlayer", 0, 39, null);
|
||||
inventory = invPlayer;
|
||||
}
|
||||
|
||||
public TaggedInventoryArea(String name, int first, int last, Container container)
|
||||
{
|
||||
this.container = container;
|
||||
tagName = name;
|
||||
for(int i = first; i <= last; i++)
|
||||
slots.add(i);
|
||||
}
|
||||
|
||||
public ItemStack getStackInSlot(int i)
|
||||
{
|
||||
if(inventory != null)
|
||||
return inventory.getStackInSlot(i);
|
||||
return container.getSlot(i).getStack();
|
||||
}
|
||||
|
||||
public boolean isContainer()
|
||||
{
|
||||
return inventory == null;
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,10 @@ import java.awt.Color;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import codechicken.nei.VisiblityData;
|
||||
import codechicken.nei.api.INEIGuiHandler;
|
||||
import codechicken.nei.api.TaggedInventoryArea;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
@@ -45,7 +49,7 @@ import forestry.core.interfaces.IPowerHandler;
|
||||
import forestry.core.proxy.Proxies;
|
||||
import forestry.core.utils.FontColour;
|
||||
|
||||
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
public abstract class GuiForestry<T extends TileForestry> extends GuiContainer implements INEIGuiHandler {
|
||||
|
||||
/* WIDGETS */
|
||||
protected WidgetManager widgetManager;
|
||||
@@ -572,4 +576,22 @@ public abstract class GuiForestry<T extends TileForestry> extends GuiContainer {
|
||||
return tip;
|
||||
}
|
||||
}
|
||||
|
||||
/* NEI */
|
||||
@Override
|
||||
public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisibility) { return null; }
|
||||
@Override
|
||||
public Iterable<Integer> getItemSpawnSlots(GuiContainer gui, ItemStack item) { return null; }
|
||||
@Override
|
||||
public List<TaggedInventoryArea> getInventoryAreas(GuiContainer gui) { return null; }
|
||||
@Override
|
||||
public boolean handleDragNDrop(GuiContainer gui, int mousex, int mousey, ItemStack draggedStack, int button) { return false; }
|
||||
|
||||
@Override
|
||||
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
|
||||
if (gui instanceof GuiForestry)
|
||||
return ((GuiForestry)gui).ledgerManager.ledgerOverlaps(x, y, w, h);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -117,4 +117,8 @@ public class LedgerManager {
|
||||
|
||||
}
|
||||
|
||||
public boolean ledgerOverlaps(int x, int y, int width, int height) {
|
||||
return getAtPosition(x + width, y + height) != null || getAtPosition(x + width, y) != null || getAtPosition(x, y + height) != null || getAtPosition(x, y) != null;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user