Moved Sorting Config Into the World.
This commit is contained in:
parent
1d21f2f925
commit
646dafcc99
|
@ -1,14 +1,14 @@
|
|||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
|
||||
reservedSpace = 73;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
|
@ -8,8 +9,10 @@ import appeng.api.config.SearchBoxMode;
|
|||
import appeng.api.config.Settings;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
|
@ -20,13 +23,17 @@ import appeng.client.me.ItemRepo;
|
|||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
|
||||
MEGuiTextField searchField;
|
||||
|
@ -43,11 +50,19 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
|||
int rows = 0;
|
||||
int maxRows = Integer.MAX_VALUE;
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||
IConfigManager configSrc;
|
||||
|
||||
GuiImgButton ViewBox;
|
||||
GuiImgButton SortByBox;
|
||||
GuiImgButton SortDirBox;
|
||||
|
||||
GuiImgButton searchBoxSettings;
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, null ) );
|
||||
}
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, IStorageMonitorable te, ContainerMEMonitorable c) {
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c) {
|
||||
|
||||
super( c );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
|
@ -55,6 +70,9 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
|||
xSize = 195;
|
||||
ySize = 204;
|
||||
|
||||
configSrc = ((IConfigureableObject) inventorySlots).getConfigManager();
|
||||
((ContainerMEMonitorable) inventorySlots).gui = this;
|
||||
|
||||
if ( te instanceof TileSecurity )
|
||||
myName = GuiText.Security;
|
||||
else if ( te instanceof WirelessTerminalGuiObject )
|
||||
|
@ -124,15 +142,15 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
|||
|
||||
if ( customSortOrder )
|
||||
{
|
||||
buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, AEConfig.instance.settings.getSetting( Settings.SORT_BY ) ) );
|
||||
buttonList.add( SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, configSrc.getSetting( Settings.SORT_BY ) ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
buttonList
|
||||
.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, AEConfig.instance.settings.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
buttonList.add( SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
offset += 20;
|
||||
|
||||
buttonList.add( new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE ) ) );
|
||||
buttonList.add( searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings
|
||||
.getSetting( Settings.SEARCH_MODE ) ) );
|
||||
|
||||
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
|
||||
searchField.setEnableBackgroundDrawing( false );
|
||||
|
@ -162,12 +180,25 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
|||
if ( btn instanceof GuiImgButton )
|
||||
{
|
||||
GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
Enum cv = iBtn.getCurrentValue();
|
||||
|
||||
Enum cv = iBtn.getCurrentValue();
|
||||
Enum next = Platform.nextEnum( cv );
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
|
||||
if ( btn == searchBoxSettings )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
iBtn.set( next );
|
||||
repo.updateView();
|
||||
|
||||
if ( next.getClass() == SearchBoxMode.class )
|
||||
re_init();
|
||||
|
@ -242,13 +273,28 @@ public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource
|
|||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return AEConfig.instance.settings.getSetting( Settings.SORT_BY );
|
||||
return configSrc.getSetting( Settings.SORT_BY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return AEConfig.instance.settings.getSetting( Settings.SORT_DIRECTION );
|
||||
return configSrc.getSetting( Settings.SORT_DIRECTION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
if ( SortByBox != null )
|
||||
SortByBox.set( configSrc.getSetting( Settings.SORT_BY ) );
|
||||
|
||||
if ( SortDirBox != null )
|
||||
SortDirBox.set( configSrc.getSetting( Settings.SORT_DIRECTION ) );
|
||||
|
||||
if ( ViewBox != null )
|
||||
ViewBox.set( configSrc.getSetting( Settings.VIEW_MODE ) );
|
||||
|
||||
repo.updateView();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import java.io.IOException;
|
|||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.core.AELog;
|
||||
|
@ -16,7 +16,7 @@ import appeng.core.sync.packets.PacketValueConfig;
|
|||
public class GuiSecurity extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiSecurity(InventoryPlayer inventoryPlayer, IStorageMonitorable te) {
|
||||
public GuiSecurity(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
|
||||
customSortOrder = false;
|
||||
reservedSpace = 33;
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.inventory.IInventory;
|
|||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.ContainerNull;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotCraftingTerm;
|
||||
|
@ -38,7 +38,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
|
|||
outputSlot.putStack( CraftingManager.getInstance().findMatchingRecipe( ic, getPlayerInv().player.worldObj ) );
|
||||
}
|
||||
|
||||
public ContainerCraftingTerm(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
public ContainerCraftingTerm(InventoryPlayer ip, ITerminalHost montiorable) {
|
||||
super( ip, montiorable, false );
|
||||
ct = (PartCraftingTerminal) montiorable;
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ import net.minecraft.entity.player.InventoryPlayer;
|
|||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.networking.IGrid;
|
||||
|
@ -19,27 +23,45 @@ import appeng.api.networking.security.BaseActionSource;
|
|||
import appeng.api.parts.IPart;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.ItemList;
|
||||
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonitorHandlerReceiver<IAEItemStack>
|
||||
public class ContainerMEMonitorable extends AEBaseContainer implements IConfigManagerHost, IConfigureableObject, IMEMonitorHandlerReceiver<IAEItemStack>
|
||||
{
|
||||
|
||||
final IMEMonitor<IAEItemStack> monitor;
|
||||
final IItemList<IAEItemStack> items = new ItemList<IAEItemStack>();
|
||||
|
||||
protected ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable, boolean bindInventory) {
|
||||
IConfigManager serverCM;
|
||||
IConfigManager clientCM;
|
||||
|
||||
public IConfigManagerHost gui;
|
||||
|
||||
protected ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable, boolean bindInventory) {
|
||||
super( ip, montiorable instanceof TileEntity ? (TileEntity) montiorable : null, montiorable instanceof IPart ? (IPart) montiorable : null );
|
||||
|
||||
clientCM = new ConfigManager( this );
|
||||
|
||||
clientCM.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
clientCM.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
clientCM.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
serverCM = montiorable.getConfigManager();
|
||||
|
||||
monitor = montiorable.getItemInventory();
|
||||
if ( monitor != null )
|
||||
{
|
||||
|
@ -72,7 +94,7 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
bindPlayerInventory( ip, 0, 0 );
|
||||
}
|
||||
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
public ContainerMEMonitorable(InventoryPlayer ip, ITerminalHost montiorable) {
|
||||
this( ip, montiorable, true );
|
||||
}
|
||||
|
||||
|
@ -81,6 +103,28 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
{
|
||||
if ( Platform.isServer() )
|
||||
{
|
||||
for (Enum set : serverCM.getSettings())
|
||||
{
|
||||
Enum sideLocal = serverCM.getSetting( set );
|
||||
Enum sideRemote = clientCM.getSetting( set );
|
||||
|
||||
if ( sideLocal != sideRemote )
|
||||
{
|
||||
clientCM.putSetting( set, sideLocal );
|
||||
for (int j = 0; j < this.crafters.size(); ++j)
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendTo( new PacketValueConfig( set.name(), sideLocal.name() ), (EntityPlayerMP) this.crafters.get( j ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( !items.isEmpty() )
|
||||
{
|
||||
try
|
||||
|
@ -188,4 +232,19 @@ public class ContainerMEMonitorable extends AEBaseContainer implements IMEMonito
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
if ( gui != null )
|
||||
gui.updateSetting( manager, settingName, newValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
if ( Platform.isServer() )
|
||||
return serverCM;
|
||||
return clientCM;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ import net.minecraft.item.ItemStack;
|
|||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ContainerMEPortableCell extends ContainerMEMonitorable
|
||||
|
@ -15,7 +15,7 @@ public class ContainerMEPortableCell extends ContainerMEMonitorable
|
|||
IPortableCell civ;
|
||||
|
||||
public ContainerMEPortableCell(InventoryPlayer ip, IPortableCell montiorable) {
|
||||
super( ip, (IStorageMonitorable) montiorable, false );
|
||||
super( ip, (ITerminalHost) montiorable, false );
|
||||
lockPlayerInventorySlot( ip.currentItem );
|
||||
civ = montiorable;
|
||||
bindPlayerInventory( ip, 0, 0 );
|
||||
|
|
|
@ -10,7 +10,7 @@ import appeng.api.AEApi;
|
|||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.implementations.items.IBiometricCard;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.container.slot.SlotOutput;
|
||||
import appeng.container.slot.SlotRestrictedInput;
|
||||
import appeng.container.slot.SlotRestrictedInput.PlaceableItemType;
|
||||
|
@ -32,7 +32,7 @@ public class ContainerSecurity extends ContainerMEMonitorable implements IAEAppE
|
|||
|
||||
TileSecurity securityBox;
|
||||
|
||||
public ContainerSecurity(InventoryPlayer ip, IStorageMonitorable montiorable) {
|
||||
public ContainerSecurity(InventoryPlayer ip, ITerminalHost montiorable) {
|
||||
super( ip, montiorable, false );
|
||||
|
||||
securityBox = (TileSecurity) montiorable;
|
||||
|
|
|
@ -10,8 +10,6 @@ import appeng.api.config.PowerMultiplier;
|
|||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
|
@ -115,9 +113,9 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
|||
|
||||
// settings.registerSetting( Settings.SEARCH_MODS, YesNo.YES );
|
||||
settings.registerSetting( Settings.SEARCH_TOOLTIPS, YesNo.YES );
|
||||
settings.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
settings.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
settings.registerSetting( Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH );
|
||||
// settings.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
// settings.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
WirelessBaseCost = get( "wireless", "WirelessBaseCost", WirelessBaseCost ).getDouble( WirelessBaseCost );
|
||||
WirelessCostMultiplier = get( "wireless", "WirelessCostMultiplier", WirelessCostMultiplier ).getDouble( WirelessCostMultiplier );
|
||||
|
@ -166,7 +164,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum setting, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum setting, Enum newValue)
|
||||
{
|
||||
for (Enum e : settings.getSettings())
|
||||
{
|
||||
|
|
|
@ -23,7 +23,7 @@ import appeng.api.networking.security.IActionHost;
|
|||
import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.GuiNull;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.ContainerNull;
|
||||
|
@ -82,7 +82,7 @@ public enum GuiBridge implements IGuiHandler
|
|||
|
||||
GUI_WIRELESS(ContainerWireless.class, TileWireless.class, false, SecurityPermissions.BUILD),
|
||||
|
||||
GUI_ME(ContainerMEMonitorable.class, IStorageMonitorable.class, false, null),
|
||||
GUI_ME(ContainerMEMonitorable.class, ITerminalHost.class, false, null),
|
||||
|
||||
GUI_PORTABLE_CELL(ContainerMEPortableCell.class, IPortableCell.class, true, null),
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.io.IOException;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigureableObject;
|
||||
import appeng.container.implementations.ContainerCellWorkbench;
|
||||
import appeng.container.implementations.ContainerLevelEmitter;
|
||||
import appeng.container.implementations.ContainerPriority;
|
||||
|
@ -75,6 +77,60 @@ public class PacketValueConfig extends AppEngPacket
|
|||
ccw.setFuzzy( FuzzyMode.valueOf( Value ) );
|
||||
}
|
||||
}
|
||||
else if ( c instanceof IConfigureableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientPacketData(INetworkInfo network, AppEngPacket packet, EntityPlayer player)
|
||||
{
|
||||
Container c = player.openContainer;
|
||||
|
||||
if ( c instanceof IConfigureableObject )
|
||||
{
|
||||
IConfigManager cm = ((IConfigureableObject) c).getConfigManager();
|
||||
|
||||
for (Enum e : cm.getSettings())
|
||||
{
|
||||
if ( e.name().equals( Name ) )
|
||||
{
|
||||
Enum def = cm.getSetting( e );
|
||||
|
||||
try
|
||||
{
|
||||
cm.putSetting( e, Enum.valueOf( def.getClass(), Value ) );
|
||||
}
|
||||
catch (IllegalArgumentException err)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import appeng.api.storage.StorageChannel;
|
|||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
|
||||
public class WirelessTerminalGuiObject implements IPortableCell
|
||||
|
@ -265,4 +266,10 @@ public class WirelessTerminalGuiObject implements IPortableCell
|
|||
return effectiveItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return wth.getConfigManager( effectiveItem );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
package appeng.items.contents;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.PowerMultiplier;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.items.IAEItemPowerStorage;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.me.storage.CellInventory;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implements IPortableCell
|
||||
{
|
||||
|
@ -51,4 +60,25 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( new IConfigManagerHost() {
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( target );
|
||||
manager.writeToNBT( data );
|
||||
}
|
||||
} );
|
||||
|
||||
out.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
out.readFromNBT( (NBTTagCompound) Platform.openNbtData( target ).copy() );
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,6 +81,10 @@ public class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgr
|
|||
{
|
||||
super.addInformation( par1ItemStack, par2EntityPlayer, par3List, par4 );
|
||||
|
||||
MaterialType mt = getTypeByStack( par1ItemStack );
|
||||
if ( mt == null )
|
||||
return;
|
||||
|
||||
Upgrades u = getType( par1ItemStack );
|
||||
if ( u != null )
|
||||
{
|
||||
|
@ -156,7 +160,14 @@ public class ItemMaterial extends AEBaseItem implements IStorageComponent, IUpgr
|
|||
|
||||
private String nameOf(ItemStack is)
|
||||
{
|
||||
return AEFeatureHandler.getName( ItemMaterial.class, getTypeByStack( is ).name() );
|
||||
if ( is == null )
|
||||
return "null";
|
||||
|
||||
MaterialType mt = getTypeByStack( is );
|
||||
if ( mt == null )
|
||||
return "null";
|
||||
|
||||
return AEFeatureHandler.getName( ItemMaterial.class, mt.name() );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,11 +9,18 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.features.IWirelessTermHandler;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class ToolWirelessTerminal extends AEBasePoweredItem implements IWirelessTermHandler
|
||||
|
@ -87,4 +94,26 @@ public class ToolWirelessTerminal extends AEBasePoweredItem implements IWireless
|
|||
tag.setString( "name", name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager(final ItemStack target)
|
||||
{
|
||||
final ConfigManager out = new ConfigManager( new IConfigManagerHost() {
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
NBTTagCompound data = Platform.openNbtData( target );
|
||||
manager.writeToNBT( data );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
out.registerSetting( Sewttings.SORT_BY, SortOrder.NAME );
|
||||
out.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
out.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
|
||||
out.readFromNBT( (NBTTagCompound) Platform.openNbtData( target ).copy() );
|
||||
return out;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import appeng.api.storage.data.IAEItemStack;
|
|||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
|
@ -85,7 +86,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IStackWatcherHo
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum settingName, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
confgiureWatchers();
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class PartUpgradeable extends PartBasicState implements ISegmentedInvento
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum settingName, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import appeng.api.storage.IMEMonitorHandlerReceiver;
|
|||
import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
|
@ -167,7 +168,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum settingName, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
resetCache( true );
|
||||
host.markForSave();
|
||||
|
|
|
@ -2,20 +2,48 @@ package appeng.parts.reporting;
|
|||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Vec3;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.client.texture.CableBusTextures;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class PartTerminal extends PartMonitor implements IStorageMonitorable
|
||||
public class PartTerminal extends PartMonitor implements ITerminalHost, IConfigManagerHost
|
||||
{
|
||||
|
||||
IConfigManager cm = new ConfigManager( this );
|
||||
|
||||
public PartTerminal(Class clz, ItemStack is) {
|
||||
super( clz, is );
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
super.readFromNBT( data );
|
||||
cm.readFromNBT( data );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
super.writeToNBT( data );
|
||||
cm.writeToNBT( data );
|
||||
}
|
||||
|
||||
public PartTerminal(ItemStack is) {
|
||||
|
@ -24,6 +52,10 @@ public class PartTerminal extends PartMonitor implements IStorageMonitorable
|
|||
frontColored = CableBusTextures.PartTerminal_Colored;
|
||||
frontDark = CableBusTextures.PartTerminal_Dark;
|
||||
frontSolid = CableBusTextures.PartTerminal_Solid;
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
public GuiBridge getGui()
|
||||
|
@ -83,4 +115,16 @@ public class PartTerminal extends PartMonitor implements IStorageMonitorable
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ public class TileCondenser extends AEBaseInvTile implements IAEAppEngInventory,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum settingName, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
addPower( 0 );
|
||||
}
|
||||
|
|
|
@ -17,6 +17,10 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.events.LocatableEventAnnounce;
|
||||
import appeng.api.events.LocatableEventAnnounce.LocatableEvent;
|
||||
import appeng.api.features.ILocatable;
|
||||
|
@ -29,12 +33,13 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
|||
import appeng.api.networking.events.MENetworkSecurityChange;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IStorageMonitorable;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.MEMonitorHandler;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.DimensionalCoord;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.SecurityInventory;
|
||||
import appeng.tile.events.AETileEventHandler;
|
||||
|
@ -43,13 +48,16 @@ import appeng.tile.grid.AENetworkTile;
|
|||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
|
||||
public class TileSecurity extends AENetworkTile implements IStorageMonitorable, IAEAppEngInventory, ILocatable
|
||||
public class TileSecurity extends AENetworkTile implements ITerminalHost, IAEAppEngInventory, ILocatable, IConfigManagerHost
|
||||
{
|
||||
|
||||
private static int diffrence = 0;
|
||||
private IConfigManager cm = new ConfigManager( this );
|
||||
|
||||
private SecurityInventory inventory = new SecurityInventory( this );
|
||||
private MEMonitorHandler<IAEItemStack> securityMonitor = new MEMonitorHandler<IAEItemStack>( inventory );
|
||||
|
@ -133,6 +141,9 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable,
|
|||
@Override
|
||||
public void writeToNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.writeToNBT( data );
|
||||
;
|
||||
|
||||
data.setLong( "securityKey", securityKey );
|
||||
configSlot.writeToNBT( data, "config" );
|
||||
|
||||
|
@ -152,6 +163,8 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable,
|
|||
@Override
|
||||
public void readFromNBT(NBTTagCompound data)
|
||||
{
|
||||
cm.readFromNBT( data );
|
||||
|
||||
securityKey = data.getLong( "securityKey" );
|
||||
configSlot.readFromNBT( data, "config" );
|
||||
|
||||
|
@ -230,6 +243,10 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable,
|
|||
securityKey = System.currentTimeMillis() * 10 + diffrence;
|
||||
if ( diffrence > 10 )
|
||||
diffrence = 0;
|
||||
|
||||
cm.registerSetting( Settings.SORT_BY, SortOrder.NAME );
|
||||
cm.registerSetting( Settings.VIEW_MODE, ViewItems.ALL );
|
||||
cm.registerSetting( Settings.SORT_DIRECTION, SortDir.ASCENDING );
|
||||
}
|
||||
|
||||
public int getOwner()
|
||||
|
@ -277,4 +294,16 @@ public class TileSecurity extends AENetworkTile implements IStorageMonitorable,
|
|||
return gridProxy.isActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IConfigManager getConfigManager()
|
||||
{
|
||||
return cm;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(Enum settingName, Enum newValue)
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
updateTask();
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Set;
|
|||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.core.AELog;
|
||||
|
||||
public class ConfigManager implements IConfigManager
|
||||
{
|
||||
|
@ -21,18 +22,27 @@ public class ConfigManager implements IConfigManager
|
|||
*
|
||||
* @param tagCompound
|
||||
*/
|
||||
@SuppressWarnings("static-access")
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tagCompound)
|
||||
{
|
||||
for (Enum key : Settings.keySet())
|
||||
{
|
||||
String value = tagCompound.getString( key.name() );
|
||||
try
|
||||
{
|
||||
if ( tagCompound.hasKey( key.name() ) )
|
||||
{
|
||||
String value = tagCompound.getString( key.name() );
|
||||
|
||||
Enum oldValue = Settings.get( key );
|
||||
Enum newValue = oldValue.valueOf( oldValue.getClass(), value );
|
||||
Enum oldValue = Settings.get( key );
|
||||
Enum newValue = Enum.valueOf( oldValue.getClass(), value );
|
||||
|
||||
putSetting( key, newValue );
|
||||
putSetting( key, newValue );
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +90,7 @@ public class ConfigManager implements IConfigManager
|
|||
{
|
||||
Enum oldValue = getSetting( settingName );
|
||||
Settings.put( settingName, newValue );
|
||||
target.updateSetting( settingName, newValue );
|
||||
target.updateSetting( this, settingName, newValue );
|
||||
return oldValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package appeng.util;
|
||||
|
||||
public interface IConfigManagerHost {
|
||||
import appeng.api.util.IConfigManager;
|
||||
|
||||
void updateSetting(Enum settingName, Enum newValue);
|
||||
public interface IConfigManagerHost
|
||||
{
|
||||
|
||||
void updateSetting(IConfigManager manager, Enum settingName, Enum newValue);
|
||||
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import appeng.util.inv.ItemSlot;
|
|||
import appeng.util.inv.WrapperMCISidedInventory;
|
||||
import buildcraft.api.inventory.ISpecialInventory;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class InventoryAdaptor implements Iterable<ItemSlot>
|
||||
{
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import appeng.api.config.FuzzyMode;
|
|||
import appeng.util.InventoryAdaptor;
|
||||
import buildcraft.api.inventory.ISpecialInventory;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AdaptorISpecialInventory extends InventoryAdaptor
|
||||
{
|
||||
|
||||
|
|
Loading…
Reference in a new issue