diff --git a/graphics/alloy-furnace-gui-1.xcf b/graphics/alloy-furnace-gui-1.xcf index b1e253c..96351a8 100644 Binary files a/graphics/alloy-furnace-gui-1.xcf and b/graphics/alloy-furnace-gui-1.xcf differ diff --git a/graphics/alloy-furnace-gui-2.xcf b/graphics/alloy-furnace-gui-2.xcf index 6c21c06..5c24f8b 100644 Binary files a/graphics/alloy-furnace-gui-2.xcf and b/graphics/alloy-furnace-gui-2.xcf differ diff --git a/graphics/gui-common.xcf b/graphics/gui-common.xcf new file mode 100644 index 0000000..53d8627 Binary files /dev/null and b/graphics/gui-common.xcf differ diff --git a/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java b/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java index 66b0dbc..a3826ba 100644 --- a/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java +++ b/src/java/mmm/tech/base/TBAlloyFurnaceBlock.java @@ -424,7 +424,7 @@ public class TBAlloyFurnaceBlock } - public static boolean isPowered( int meta ) + public static boolean isPowered( final int meta ) { return ( meta & 8 ) == 8; } diff --git a/src/java/mmm/tech/base/TBAlloyFurnaceContainer.java b/src/java/mmm/tech/base/TBAlloyFurnaceContainer.java index a9266a8..d3c9de7 100644 --- a/src/java/mmm/tech/base/TBAlloyFurnaceContainer.java +++ b/src/java/mmm/tech/base/TBAlloyFurnaceContainer.java @@ -2,16 +2,14 @@ package mmm.tech.base; import mmm.materials.MAlloyRecipe; -import mmm.utils.UContainers; import mmm.utils.UInventoryDisplay; import mmm.utils.UInventoryGrid; -import mmm.utils.slots.USDisplay; -import mmm.utils.slots.USFuel; -import mmm.utils.slots.USOutput; -import mmm.utils.slots.USVisibilityController; +import mmm.utils.gui.UGContainer; +import mmm.utils.gui.UGSlotDisplay; +import mmm.utils.gui.UGSlotFuel; +import mmm.utils.gui.UGSlotOutput; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; -import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntityFurnace; @@ -22,13 +20,12 @@ import net.minecraft.world.World; public class TBAlloyFurnaceContainer - extends Container + extends UGContainer { public final TBAlloyFurnaceTileEntity tileEntity; public final World world; public final BlockPos position; - public final USVisibilityController visibilityController; public final UInventoryGrid input; public final UInventoryGrid fuel; public final UInventoryGrid output; @@ -41,36 +38,29 @@ public class TBAlloyFurnaceContainer this.world = tileEntity.getWorld( ); this.position = tileEntity.getPos( ); - this.visibilityController = new USVisibilityController( this.inventorySlots ); - this.visibilityController.startGroup( ); - UContainers.addPlayerInventory( // - ( i , x , y ) -> this.addSlotToContainer( new Slot( playerInv , i , x , y ) ) , // - 8 , 112 ); + this.addPlayerInventory( Slot::new , playerInv , 8 , 112 ); + this.slotGroups.nextGroup( ); - this.visibilityController.startGroup( ); this.input = tileEntity.input; - UContainers.addGrid( // - ( i , x , y ) -> this.addSlotToContainer( new Slot( this.input , i , x , y ) ) , // + this.addGrid( Slot::new , this.input , // this.input.width , this.input.height , 0 , 12 , 8 ); this.fuel = tileEntity.fuel; - UContainers.addGrid( // - ( i , x , y ) -> this.addSlotToContainer( new USFuel( this.fuel , i , x , y ) ) , // + this.addGrid( UGSlotFuel::new , this.fuel , // this.fuel.width , this.fuel.height , 0 , 80 , 62 ); this.output = tileEntity.output; - UContainers.addGrid( // - ( i , x , y ) -> { - this.addSlotToContainer( new USOutput( playerInv.player , this.output , i , x , y ) ); - } , this.output.width , this.output.height , 0 , 130 , 8 ); + this.addGrid( // + ( inv , i , x , y ) -> new UGSlotOutput( playerInv.player , inv , i , x , y ) , // + this.output , this.output.width , this.output.height , 0 , 130 , 8 ); this.recipe = new UInventoryDisplay( "Recipe" , 7 ); - this.visibilityController.startGroup( ); - UContainers.addGrid( // - ( i , x , y ) -> this.addSlotToContainer( new USDisplay( this.recipe , i , x , y ) ) , // + this.slotGroups.nextGroup( ); + this.addGrid( UGSlotDisplay::new , this.recipe , // 3 , 2 , 0 , 25 , 37 , 8 , 8 ); - this.addSlotToContainer( new USDisplay( this.recipe , 6 , 131 , 49 ) ); + this.addSlotToContainer( new UGSlotDisplay( this.recipe , 6 , 131 , 49 ) ); - this.visibilityController.finalizeGroups( ); - this.visibilityController.hideGroup( 2 ); + this.slotGroups.endGroups( ); + this.slotGroups.showGroup( 0 ); // FIXME remove this + this.slotGroups.showGroup( 1 ); } diff --git a/src/java/mmm/tech/base/TBAlloyFurnaceGui.java b/src/java/mmm/tech/base/TBAlloyFurnaceGui.java index 7705b98..058c9ca 100644 --- a/src/java/mmm/tech/base/TBAlloyFurnaceGui.java +++ b/src/java/mmm/tech/base/TBAlloyFurnaceGui.java @@ -1,25 +1,21 @@ package mmm.tech.base; -import java.io.IOException; import java.util.ArrayList; -import java.util.List; - -import com.google.common.collect.Lists; import mmm.Mmm; import mmm.materials.MAlloyRecipe; import mmm.utils.URegistry; -import net.minecraft.client.Minecraft; +import mmm.utils.gui.A_UGTab; +import mmm.utils.gui.A_UGTabbedContainerScreen; +import mmm.utils.gui.UGArrowButton; import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiTextField; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TextFormatting; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -27,94 +23,190 @@ import net.minecraftforge.fml.relauncher.SideOnly; @SideOnly( Side.CLIENT ) public class TBAlloyFurnaceGui - extends GuiContainer + extends A_UGTabbedContainerScreen< TBAlloyFurnaceContainer > { - @SideOnly( Side.CLIENT ) - private static enum Tab { - MAIN( 191 , 0 , 1 , "container.mmm.alloy_furnace.contents" ) , - RECIPE( 207 , 0 , 2 , "container.mmm.alloy_furnace.recipe" ) , - CONFIG( 223 , 0 , 2 , "gui.mmm.configure" ); - - public final int iconX; - public final int iconY; - public final int slotGroup; - public final String tooltip; - - - private Tab( final int iconX , final int iconY , final int slotGroup , final String tooltip ) - { - this.iconX = iconX; - this.iconY = iconY; - this.slotGroup = slotGroup; - this.tooltip = tooltip; - } - } - - @SideOnly( Side.CLIENT ) - private static class ArrowButton - extends GuiButton - { - private final boolean forward; - - - public ArrowButton( final int buttonID , final int x , final int y , final boolean forward ) - { - super( buttonID , x , y , 12 , 19 , "" ); - this.forward = forward; - } - - - @Override - public void drawButton( final Minecraft mc , final int mouseX , final int mouseY ) - { - if ( this.visible ) { - mc.getTextureManager( ).bindTexture( TBAlloyFurnaceGui.TEXTURES[ 1 ] ); - GlStateManager.color( 1f , 1f , 1f , 1f ); - - int texX = 176; - if ( !this.enabled ) { - texX += this.width * 2; - } else if ( mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width - && mouseY < this.yPosition + this.height ) { - texX += this.width; - } - - int texY = 0; - if ( !this.forward ) { - texY += this.height; - } - - this.drawTexturedModalRect( this.xPosition , this.yPosition , texX , texY , this.width , this.height ); - } - } - } - private static final ResourceLocation TEXTURES[] = { new ResourceLocation( Mmm.ID , "textures/gui/alloy_furnace_1.png" ) , new ResourceLocation( Mmm.ID , "textures/gui/alloy_furnace_2.png" ) , new ResourceLocation( Mmm.ID , "textures/gui/alloy_furnace_3.png" ) , }; - private static final TBAlloyFurnaceGui.Tab TABS[] = TBAlloyFurnaceGui.Tab.values( ); + @SideOnly( Side.CLIENT ) + private static class MainTab + extends A_UGTab + { - private static final int TAB_WIDTH = 26; - private static final int TAB_HEIGHT = 26; - private static final int TAB_BORDER = 4; - private static final int TABS_TEXTURE_X = 176; - private static final int TABS_TEXTURE_Y = 45; - private static final int TAB_ICON_X = 5; - private static final int TAB_ICON_Y = 5; - private static final int TAB_ICON_WIDTH = 16; - private static final int TAB_ICON_HEIGHT = 16; + private MainTab( ) + { + super( ); + this.setBackground( TBAlloyFurnaceGui.TEXTURES[ 0 ] ) // + .setHeight( 194 ) // + .setIconPosition( 191 , 0 )// + .setSlotGroups( 0 , 1 ) // + .setTooltip( "container.mmm.alloy_furnace.contents" ); + } - private final TBAlloyFurnaceContainer container; - private TBAlloyFurnaceGui.Tab selectedTab = Tab.MAIN; + @Override + public void drawBackground( final float partialTicks , final int mouseX , final int mouseY ) + { + super.drawBackground( partialTicks , mouseX , mouseY ); + + final int x = ( this.parent.width - this.parent.getXSize( ) ) / 2; + final int y = ( this.parent.height - this.height ) / 2; + + final TBAlloyFurnaceContainer container = (TBAlloyFurnaceContainer) this.parent.container; + final TileEntity atPos = container.world.getTileEntity( container.position ); + if ( atPos instanceof TBAlloyFurnaceTileEntity ) { + final TBAlloyFurnaceTileEntity te = (TBAlloyFurnaceTileEntity) atPos; + // Burn + if ( te.isBurning( ) ) { + final int burn = te.getBurnProgress( 13 ); + this.drawTexturedModalRect( x + 89 , y + 38 + 13 - burn , 176 , 28 - burn , 14 , burn + 1 ); + } + + // Alloying progress + if ( te.isAlloying( ) ) { + final int alloy = te.getAlloyingProgress( 47 ); + this.drawTexturedModalRect( x + 73 , y + 17 , 176 , 29 , alloy + 1 , 16 ); + } + } + } + + } + + private static class RecipeTab + extends A_UGTab + { + + private UGArrowButton bPrevious; + private UGArrowButton bNext; + private GuiButton bConfirm; + private GuiTextField tfSearch; + + + private RecipeTab( ) + { + super( ); + this.setBackground( TBAlloyFurnaceGui.TEXTURES[ 1 ] ) // + .setHeight( 194 ) // + .setIconPosition( 207 , 0 )// + .setSlotGroups( 0 , 2 ) // + .setTooltip( "container.mmm.alloy_furnace.recipe" ); + } + + + @Override + public void initGui( final int x , final int y ) + { + super.initGui( x , y ); + + this.bPrevious = new UGArrowButton( 1 , 8 + x , 47 + y , false ); + this.bNext = new UGArrowButton( 2 , 156 + x , 47 + y , true ); + this.bConfirm = new GuiButton( 3 , 24 + x , 84 + y , 128 , 20 , + I18n.format( "container.mmm.alloy_furnace.select" ) ); + + this.tfSearch = new GuiTextField( 4 , this.parent.getFontRenderer( ) , 24 + x , 9 + y , 128 , 20 ); + this.tfSearch.setTextColor( 0xffffff ); + this.tfSearch.setDisabledTextColour( 0x7f7f7f ); + this.tfSearch.setEnableBackgroundDrawing( true ); + this.tfSearch.setMaxStringLength( 30 ); + + this.bPrevious.visible = this.bNext.visible = this.bConfirm.visible = false; + this.tfSearch.setVisible( false ); + + this.buttons.add( this.bNext ); + this.buttons.add( this.bPrevious ); + this.buttons.add( this.bConfirm ); + + this.enableButtons( ); + } + + + @Override + public void drawBackground( final float partialTicks , final int mouseX , final int mouseY ) + { + super.drawBackground( partialTicks , mouseX , mouseY ); + GlStateManager.disableBlend( ); + this.tfSearch.drawTextBox( ); + } + + + @Override + public void onSelected( ) + { + super.onSelected( ); + this.tfSearch.setVisible( true ); + this.enableButtons( ); + } + + + @Override + public void onDeselected( ) + { + super.onDeselected( ); + this.tfSearch.setVisible( false ); + } + + + @Override + public void onMouseClicked( final int mouseX , final int mouseY , final int mouseButton ) + { + this.tfSearch.mouseClicked( mouseX , mouseY , mouseButton ); + } + + + @Override + public boolean onKeyTyped( final char typedChar , final int keyCode ) + { + if ( this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { + ( (TBAlloyFurnaceGui) this.parent ).handleFiltering( this.tfSearch.getText( ) ); + return true; + } + return false; + } + + + @Override + public boolean onActionPerformed( final GuiButton button ) + { + final TBAlloyFurnaceGui gui = (TBAlloyFurnaceGui) this.parent; + if ( button == this.bNext ) { + gui.setRecipe( gui.currentRecipe + 1 ); + } else if ( button == this.bPrevious ) { + gui.setRecipe( gui.currentRecipe - 1 ); + } else if ( button == this.bConfirm ) { + final MAlloyRecipe recipe = gui.recipes.get( gui.currentRecipe ); + URegistry.network.sendToServer( // + new TBAlloyFurnaceMessage( gui.container.position , recipe.name , true ) ); + gui.container.tileEntity.recipe = recipe; + } else { + return false; + } + + this.enableButtons( ); + return true; + } + + + private void enableButtons( ) + { + if ( this.bNext == null ) { + return; + } + + final TBAlloyFurnaceGui gui = (TBAlloyFurnaceGui) this.parent; + if ( gui.recipes.isEmpty( ) ) { + this.bNext.enabled = this.bPrevious.enabled = this.bConfirm.enabled = false; + } else { + this.bNext.enabled = gui.currentRecipe < gui.recipes.size( ) - 1; + this.bPrevious.enabled = gui.currentRecipe > 0; + this.bConfirm.enabled = gui.currentRecipe != gui.getRecipeIndex( gui.container.tileEntity.recipe ); + } + } + + } - private ArrowButton bPrevious; - private ArrowButton bNext; - private GuiButton bConfirm; - private GuiTextField tfSearch; private ArrayList< MAlloyRecipe > recipes; private int currentRecipe = 0; private String searchString = ""; @@ -122,86 +214,14 @@ public class TBAlloyFurnaceGui public TBAlloyFurnaceGui( final InventoryPlayer inventoryPlayer , final TBAlloyFurnaceTileEntity tileEntity ) { - super( new TBAlloyFurnaceContainer( inventoryPlayer , tileEntity ) ); + super( new TBAlloyFurnaceContainer( inventoryPlayer , tileEntity ) , TBAlloyFurnaceGui.TEXTURES[ 0 ] , + new MainTab( ) , new RecipeTab( ) ); this.xSize = 176; - this.ySize = 194; - - this.container = (TBAlloyFurnaceContainer) this.inventorySlots; - for ( final TBAlloyFurnaceGui.Tab tab : TBAlloyFurnaceGui.Tab.values( ) ) { - if ( tab != this.selectedTab ) { - this.container.visibilityController.hideGroup( tab.slotGroup ); - } - } - this.recipes = MAlloyRecipe.REGISTRY.getRecipes( ); this.setRecipe( this.getRecipeIndex( tileEntity.recipe ) ); } - @Override - public void initGui( ) - { - super.initGui( ); - - final int x = ( this.width - this.xSize ) / 2; - final int y = ( this.height - this.ySize ) / 2; - - this.bPrevious = new ArrowButton( 1 , 8 + x , 47 + y , false ); - this.bNext = new ArrowButton( 2 , 156 + x , 47 + y , true ); - this.bConfirm = new GuiButton( 3 , 24 + x , 84 + y , 128 , 20 , - I18n.format( "container.mmm.alloy_furnace.select" ) ); - - this.tfSearch = new GuiTextField( 4 , this.fontRendererObj , 24 + x , 9 + y , 128 , 20 ); - this.tfSearch.setTextColor( 0xffffff ); - this.tfSearch.setDisabledTextColour( 0x7f7f7f ); - this.tfSearch.setEnableBackgroundDrawing( true ); - this.tfSearch.setMaxStringLength( 30 ); - - this.bPrevious.visible = this.bNext.visible = this.bConfirm.visible = false; - this.tfSearch.setVisible( false ); - - this.buttonList.add( this.bNext ); - this.buttonList.add( this.bPrevious ); - this.buttonList.add( this.bConfirm ); - - this.enableConfigButtons( ); - } - - - @Override - public void drawScreen( final int mouseX , final int mouseY , final float partialTicks ) - { - super.drawScreen( mouseX , mouseY , partialTicks ); - - for ( final TBAlloyFurnaceGui.Tab tab : TBAlloyFurnaceGui.Tab.values( ) ) { - if ( this.isInTab( tab , mouseX , mouseY ) ) { - final List< String > list = Lists.< String > newArrayList( ); - list.add( TextFormatting.WHITE + I18n.format( tab.tooltip ) ); - this.drawHoveringText( list , mouseX , mouseY ); - break; - } - } - } - - - private void enableConfigButtons( ) - { - if ( this.bNext != null ) { - final boolean visible = this.selectedTab == Tab.RECIPE; - this.bNext.visible = this.bPrevious.visible = this.bConfirm.visible = visible; - this.tfSearch.setVisible( visible ); - - if ( this.recipes.isEmpty( ) ) { - this.bNext.enabled = this.bPrevious.enabled = this.bConfirm.enabled = false; - } else { - this.bNext.enabled = this.currentRecipe < this.recipes.size( ) - 1; - this.bPrevious.enabled = this.currentRecipe > 0; - this.bConfirm.enabled = this.currentRecipe != this.getRecipeIndex( this.container.tileEntity.recipe ); - } - } - } - - private void setRecipe( int index ) { if ( index == -1 && !this.recipes.isEmpty( ) ) { @@ -220,7 +240,7 @@ public class TBAlloyFurnaceGui this.container.setCurrentRecipe( rName , false ); URegistry.network.sendToServer( // new TBAlloyFurnaceMessage( this.container.position , rName , false ) ); - this.enableConfigButtons( ); + ( (RecipeTab) this.tabs[ 1 ] ).enableButtons( ); } @@ -230,101 +250,9 @@ public class TBAlloyFurnaceGui } - @Override - protected void drawGuiContainerBackgroundLayer( final float partialTicks , final int mouseX , final int mouseY ) + private void handleFiltering( final String input ) { - GlStateManager.color( 1f , 1f , 1f , 1f ); - GlStateManager.enableBlend( ); - GlStateManager.disableLighting( ); - - // Inactive tab - this.mc.getTextureManager( ).bindTexture( TBAlloyFurnaceGui.TEXTURES[ 0 ] ); - for ( final TBAlloyFurnaceGui.Tab tab : TBAlloyFurnaceGui.TABS ) { - if ( tab != this.selectedTab ) { - this.drawTab( tab ); - } - } - - // Main panel - this.mc.getTextureManager( ).bindTexture( TBAlloyFurnaceGui.TEXTURES[ this.selectedTab.ordinal( ) ] ); - this.drawTexturedModalRect( this.guiLeft , this.guiTop , 0 , 0 , this.xSize , this.ySize ); - - if ( this.selectedTab == Tab.MAIN ) { - final int x = ( this.width - this.xSize ) / 2; - final int y = ( this.height - this.ySize ) / 2; - - final TileEntity atPos = this.container.world.getTileEntity( this.container.position ); - if ( atPos instanceof TBAlloyFurnaceTileEntity ) { - final TBAlloyFurnaceTileEntity te = (TBAlloyFurnaceTileEntity) atPos; - // Burn - if ( te.isBurning( ) ) { - final int burn = te.getBurnProgress( 13 ); - this.drawTexturedModalRect( x + 89 , y + 38 + 13 - burn , 176 , 28 - burn , 14 , burn + 1 ); - } - - // Alloying progress - if ( te.isAlloying( ) ) { - final int alloy = te.getAlloyingProgress( 47 ); - this.drawTexturedModalRect( x + 73 , y + 17 , 176 , 29 , alloy + 1 , 16 ); - } - } - } else { - GlStateManager.disableBlend( ); - this.tfSearch.drawTextBox( ); - GlStateManager.enableBlend( ); - GlStateManager.color( 1f , 1f , 1f , 1f ); - } - - // Active tab - this.mc.getTextureManager( ).bindTexture( TBAlloyFurnaceGui.TEXTURES[ 0 ] ); - this.drawTab( this.selectedTab ); - } - - - @Override - protected void mouseClicked( final int mouseX , final int mouseY , final int mouseButton ) - throws IOException - { - super.mouseClicked( mouseX , mouseY , mouseButton ); - - for ( final TBAlloyFurnaceGui.Tab tab : TBAlloyFurnaceGui.Tab.values( ) ) { - if ( this.selectedTab != tab && this.isInTab( tab , mouseX , mouseY ) ) { - this.selectTab( tab ); - return; - } - } - - if ( this.selectedTab == Tab.RECIPE ) { - this.tfSearch.mouseClicked( mouseX , mouseY , mouseButton ); - } - } - - - private boolean isInTab( final TBAlloyFurnaceGui.Tab tab , final int mouseX , final int mouseY ) - { - final int tabOffsetX = tab.ordinal( ) * TBAlloyFurnaceGui.TAB_WIDTH; - final int tabX = this.guiLeft + tabOffsetX + TBAlloyFurnaceGui.TAB_BORDER; - final int tabY = this.guiTop - TBAlloyFurnaceGui.TAB_HEIGHT + TBAlloyFurnaceGui.TAB_BORDER; - return mouseX >= tabX && mouseY >= tabY && mouseX <= tabX + TBAlloyFurnaceGui.TAB_WIDTH - && mouseY <= tabY + TBAlloyFurnaceGui.TAB_HEIGHT; - } - - - @Override - protected void keyTyped( final char typedChar , final int keyCode ) - throws IOException - { - if ( this.tfSearch.getVisible( ) && this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { - this.handleFiltering( ); - } else { - super.keyTyped( typedChar , keyCode ); - } - } - - - private void handleFiltering( ) - { - final String newText = this.tfSearch.getText( ).trim( ).toLowerCase( ); + final String newText = input.trim( ).toLowerCase( ); if ( this.searchString.equals( newText ) ) { return; } @@ -359,53 +287,4 @@ public class TBAlloyFurnaceGui } } - - @Override - protected void actionPerformed( final GuiButton button ) - throws IOException - { - if ( button == this.bNext ) { - this.setRecipe( this.currentRecipe + 1 ); - } else if ( button == this.bPrevious ) { - this.setRecipe( this.currentRecipe - 1 ); - } else if ( button == this.bConfirm ) { - final MAlloyRecipe recipe = this.recipes.get( this.currentRecipe ); - URegistry.network.sendToServer( - new TBAlloyFurnaceMessage( this.container.tileEntity.getPos( ) , recipe.name , true ) ); - this.container.tileEntity.recipe = recipe; - } - - this.enableConfigButtons( ); - } - - - private void drawTab( final TBAlloyFurnaceGui.Tab tab ) - { - final boolean selected = this.selectedTab == tab; - final int tabOffsetX = tab.ordinal( ) * TBAlloyFurnaceGui.TAB_WIDTH; - final int tabX = this.guiLeft + tabOffsetX + TBAlloyFurnaceGui.TAB_BORDER; - final int tabY = this.guiTop - TBAlloyFurnaceGui.TAB_HEIGHT + TBAlloyFurnaceGui.TAB_BORDER; - - this.drawTexturedModalRect( tabX , tabY , // - TBAlloyFurnaceGui.TABS_TEXTURE_X , - TBAlloyFurnaceGui.TABS_TEXTURE_Y + ( selected ? TBAlloyFurnaceGui.TAB_HEIGHT : 0 ) , // - TBAlloyFurnaceGui.TAB_WIDTH , TBAlloyFurnaceGui.TAB_HEIGHT ); - - this.zLevel = 100f; - this.drawTexturedModalRect( tabX + TBAlloyFurnaceGui.TAB_ICON_X , tabY + TBAlloyFurnaceGui.TAB_ICON_Y , // - tab.iconX , tab.iconY , // - TBAlloyFurnaceGui.TAB_ICON_WIDTH , TBAlloyFurnaceGui.TAB_ICON_HEIGHT ); - - this.zLevel = 0; - } - - - private void selectTab( final TBAlloyFurnaceGui.Tab tab ) - { - this.container.visibilityController // - .hideGroup( this.selectedTab.slotGroup ) // - .showGroup( tab.slotGroup ); - this.selectedTab = tab; - this.enableConfigButtons( ); - } } diff --git a/src/java/mmm/tech/base/TBAlloyFurnaceTileEntity.java b/src/java/mmm/tech/base/TBAlloyFurnaceTileEntity.java index a82ee5e..936b8cf 100644 --- a/src/java/mmm/tech/base/TBAlloyFurnaceTileEntity.java +++ b/src/java/mmm/tech/base/TBAlloyFurnaceTileEntity.java @@ -59,7 +59,8 @@ public class TBAlloyFurnaceTileEntity @Override - public boolean shouldRefresh( World world , BlockPos pos , IBlockState oldState , IBlockState newSate ) + public boolean shouldRefresh( final World world , final BlockPos pos , final IBlockState oldState , + final IBlockState newSate ) { return ! ( newSate.getBlock( ) instanceof TBAlloyFurnaceBlock ); } diff --git a/src/java/mmm/tech/base/TechBase.java b/src/java/mmm/tech/base/TechBase.java index f21a39e..9e480d1 100644 --- a/src/java/mmm/tech/base/TechBase.java +++ b/src/java/mmm/tech/base/TechBase.java @@ -23,8 +23,8 @@ public class TechBase ALLOY_FURNACE_BLOCK_ACTIVE = new TBAlloyFurnaceBlock( true ); ALLOY_FURNACE_ITEM = new ItemBlockSpecial( TechBase.ALLOY_FURNACE_BLOCK_INACTIVE )// .setMaxStackSize( 16 )// - .setCreativeTab( ALLOY_FURNACE_BLOCK_INACTIVE.getCreativeTabToDisplayOn( ) ); - URegistry.setIdentifiers( ALLOY_FURNACE_ITEM , "tech" , "base" , "alloy_furnace" ); + .setCreativeTab( TechBase.ALLOY_FURNACE_BLOCK_INACTIVE.getCreativeTabToDisplayOn( ) ); + URegistry.setIdentifiers( TechBase.ALLOY_FURNACE_ITEM , "tech" , "base" , "alloy_furnace" ); URegistry.addBlock( TechBase.ALLOY_FURNACE_BLOCK_INACTIVE , TechBase.ALLOY_FURNACE_ITEM ); URegistry.addBlock( TechBase.ALLOY_FURNACE_BLOCK_ACTIVE , null ); GameRegistry.registerTileEntity( TBAlloyFurnaceTileEntity.class , "mmm:tech/base/alloy_furnace" ); diff --git a/src/java/mmm/utils/UContainers.java b/src/java/mmm/utils/UContainers.java deleted file mode 100644 index 1117af1..0000000 --- a/src/java/mmm/utils/UContainers.java +++ /dev/null @@ -1,44 +0,0 @@ -package mmm.utils; - - -public class UContainers -{ - - public static interface SlotAdder - { - public void addSlot( int index , int x , int y ); - } - - - public static void addPlayerInventory( final UContainers.SlotAdder slotAdder , final int x , final int y ) - { - UContainers.addPlayerInventory( slotAdder , x , y , 4 ); - } - - - public static void addPlayerInventory( final UContainers.SlotAdder slotAdder , final int x , final int y , - final int spacing ) - { - UContainers.addGrid( slotAdder , 9 , 3 , 9 , x , y ); // Main inventory - UContainers.addGrid( slotAdder , 9 , 1 , 0 , x , y + spacing + 54 ); // Quick bar - } - - - public static void addGrid( final UContainers.SlotAdder slotAdder , final int columns , final int rows , - final int index , final int x , final int y ) - { - addGrid( slotAdder , columns , rows , index , x , y , 2 , 2 ); - } - - - public static void addGrid( final UContainers.SlotAdder slotAdder , final int columns , final int rows , - final int index , final int x , final int y , int xSpacing , int ySpacing ) - { - for ( int row = 0 , i = 0 ; row < rows ; ++row ) { - for ( int column = 0 ; column < columns ; ++column , ++i ) { - slotAdder.addSlot( index + i , x + column * ( 16 + xSpacing ) , y + row * ( 16 + ySpacing ) ); - } - } - } - -} diff --git a/src/java/mmm/utils/gui/A_UGContainerScreen.java b/src/java/mmm/utils/gui/A_UGContainerScreen.java new file mode 100644 index 0000000..1e67c3f --- /dev/null +++ b/src/java/mmm/utils/gui/A_UGContainerScreen.java @@ -0,0 +1,54 @@ +package mmm.utils.gui; + + +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + + +@SideOnly( Side.CLIENT ) +public abstract class A_UGContainerScreen< CTYPE extends UGContainer > + extends GuiContainer +{ + public final CTYPE container; + + + public A_UGContainerScreen( final CTYPE inventorySlotsIn ) + { + super( inventorySlotsIn ); + this.container = inventorySlotsIn; + } + + + public int getLeft( ) + { + return this.guiLeft; + } + + + public int getTop( ) + { + return this.guiTop; + } + + + public int getXSize( ) + { + return this.xSize; + } + + + public int getYSize( ) + { + return this.ySize; + } + + + public FontRenderer getFontRenderer( ) + { + return this.fontRendererObj; + } + +} diff --git a/src/java/mmm/utils/gui/A_UGTab.java b/src/java/mmm/utils/gui/A_UGTab.java new file mode 100644 index 0000000..f5dadb8 --- /dev/null +++ b/src/java/mmm/utils/gui/A_UGTab.java @@ -0,0 +1,155 @@ +package mmm.utils.gui; + + +import java.util.List; + +import com.google.common.collect.Lists; + +import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + + +@SideOnly( Side.CLIENT ) +public abstract class A_UGTab + extends Gui +{ + protected A_UGTabbedContainerScreen< ? > parent; + protected int ordinal; + protected int[] slotGroups; + protected ResourceLocation background; + protected int height; + protected int iconX; + protected int iconY; + protected String tooltip; + protected List< GuiButton > buttons = Lists.< GuiButton > newArrayList( ); + + + A_UGTab setParent( final A_UGTabbedContainerScreen< ? > parent , int ordinal ) + { + this.parent = parent; + this.ordinal = ordinal; + return this; + } + + + public ResourceLocation getBackground( ) + { + return this.background; + } + + + public A_UGTab setBackground( ResourceLocation background ) + { + this.background = background; + return this; + } + + + public int getHeight( ) + { + return this.height; + } + + + public A_UGTab setHeight( int height ) + { + this.height = height; + return this; + } + + + public int getIconX( ) + { + return this.iconX; + } + + + public int getIconY( ) + { + return this.iconY; + } + + + public A_UGTab setIconPosition( int x , int y ) + { + this.iconX = x; + this.iconY = y; + return this; + } + + + public String getTooltip( ) + { + return this.tooltip; + } + + + public A_UGTab setTooltip( String tooltip ) + { + this.tooltip = tooltip; + return this; + } + + + public A_UGTab setSlotGroups( int... slotGroups ) + { + this.slotGroups = slotGroups; + return this; + } + + + public void initGui( int x , int y ) + { + // EMPTY + } + + + public void drawBackground( float partialTicks , int mouseX , int mouseY ) + { + GlStateManager.color( 1f , 1f , 1f , 1f ); + GlStateManager.enableBlend( ); + GlStateManager.disableLighting( ); + this.parent.mc.getTextureManager( ).bindTexture( this.background ); + this.drawTexturedModalRect( this.parent.getLeft( ) , this.parent.getTop( ) , 0 , 0 , this.parent.getXSize( ) , + this.height ); + } + + + public void onSelected( ) + { + for ( int i = 0 ; i < this.buttons.size( ) ; i++ ) { + this.buttons.get( i ).visible = true; + } + } + + + public void onDeselected( ) + { + for ( int i = 0 ; i < this.buttons.size( ) ; i++ ) { + this.buttons.get( i ).visible = false; + } + } + + + public void onMouseClicked( int mouseX , int mouseY , int mouseButton ) + { + // EMPTY + } + + + public boolean onKeyTyped( final char typedChar , final int keyCode ) + { + return false; + } + + + public boolean onActionPerformed( GuiButton button ) + { + return false; + } +} diff --git a/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java b/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java new file mode 100644 index 0000000..eaab8c1 --- /dev/null +++ b/src/java/mmm/utils/gui/A_UGTabbedContainerScreen.java @@ -0,0 +1,217 @@ +package mmm.utils.gui; + + +import java.io.IOException; +import java.util.List; + +import com.google.common.collect.Lists; + +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.text.TextFormatting; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + + +@SideOnly( Side.CLIENT ) +public abstract class A_UGTabbedContainerScreen< CTYPE extends UGContainer > + extends A_UGContainerScreen< CTYPE > +{ + protected final ResourceLocation mainTexture; + protected final A_UGTab[] tabs; + protected int currentTab; + + + public A_UGTabbedContainerScreen( final CTYPE inventorySlotsIn , final ResourceLocation mainTexture , + final A_UGTab... tabs ) + { + super( inventorySlotsIn ); + + int height = 0; + for ( int i = 0 ; i < tabs.length ; i++ ) { + tabs[ i ].setParent( this , i ); + if ( tabs[ i ].getHeight( ) > height ) { + height = tabs[ i ].getHeight( ); + } + } + + this.tabs = tabs; + this.mainTexture = mainTexture; + this.ySize = height; + this.currentTab = -1; + this.selectTab( 0 ); + } + + + @Override + public void initGui( ) + { + super.initGui( ); + + final int x = ( this.width - this.xSize ) / 2; + final int y = ( this.height - this.ySize ) / 2; + + for ( final A_UGTab tab : this.tabs ) { + tab.buttons.clear( ); + tab.initGui( x , y ); + this.buttonList.addAll( tab.buttons ); + } + } + + + @Override + public void drawScreen( final int mouseX , final int mouseY , final float partialTicks ) + { + super.drawScreen( mouseX , mouseY , partialTicks ); + + for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex++ ) { + if ( this.isInTab( tabIndex , mouseX , mouseY ) ) { + final List< String > list = Lists.< String > newArrayList( ); + list.add( TextFormatting.WHITE + I18n.format( this.tabs[ tabIndex ].tooltip ) ); + this.drawHoveringText( list , mouseX , mouseY ); + break; + } + } + } + + + @Override + protected void drawGuiContainerBackgroundLayer( final float partialTicks , final int mouseX , final int mouseY ) + { + // Inactive tabs + GlStateManager.color( 1f , 1f , 1f , 1f ); + GlStateManager.enableBlend( ); + GlStateManager.disableLighting( ); + this.mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex++ ) { + if ( tabIndex != this.currentTab ) { + this.drawTabBackground( tabIndex ); + } + } + + // Tab panel + this.tabs[ this.currentTab ].drawBackground( partialTicks , mouseX , mouseY ); + GlStateManager.color( 1f , 1f , 1f , 1f ); + GlStateManager.enableBlend( ); + GlStateManager.disableLighting( ); + + // Active tab + this.mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + this.drawTabBackground( this.currentTab ); + + // Tab icons + this.mc.getTextureManager( ).bindTexture( this.mainTexture ); + this.zLevel = 100f; + for ( int tabIndex = 0 ; tabIndex < this.tabs.length ; tabIndex++ ) { + this.drawTabIcon( tabIndex ); + } + } + + + @Override + protected void mouseClicked( final int mouseX , final int mouseY , final int mouseButton ) + throws IOException + { + super.mouseClicked( mouseX , mouseY , mouseButton ); + + for ( int i = 0 ; i < this.tabs.length ; i++ ) { + if ( this.currentTab != i && this.isInTab( i , mouseX , mouseY ) ) { + this.selectTab( i ); + return; + } + } + + this.tabs[ this.currentTab ].onMouseClicked( mouseX , mouseY , mouseButton ); + } + + + @Override + protected void keyTyped( final char typedChar , final int keyCode ) + throws IOException + { + if ( !this.tabs[ this.currentTab ].onKeyTyped( typedChar , keyCode ) ) { + super.keyTyped( typedChar , keyCode ); + } + } + + + @Override + protected void actionPerformed( final GuiButton button ) + throws IOException + { + if ( !this.tabs[ this.currentTab ].onActionPerformed( button ) ) { + this.onContainerActionPerformed( button ); + } + } + + + protected void onContainerActionPerformed( final GuiButton button ) + { + // EMPTY + } + + + protected boolean isInTab( final int tab , final int mouseX , final int mouseY ) + { + final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; + final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; + return mouseX >= tabX && mouseY >= tabY && mouseX <= tabX + GUIUtils.TAB_WIDTH + && mouseY <= tabY + GUIUtils.TAB_HEIGHT; + } + + + protected void drawTabBackground( final int tab ) + { + final boolean selected = this.currentTab == tab; + final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; + final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; + this.drawTexturedModalRect( tabX , tabY , // + GUIUtils.TAB_TEXTURE_X , GUIUtils.TAB_TEXTURE_Y + ( selected ? GUIUtils.TAB_HEIGHT : 0 ) , // + GUIUtils.TAB_WIDTH , GUIUtils.TAB_HEIGHT ); + } + + + protected void drawTabIcon( final int tab ) + { + final int tabOffsetX = tab * GUIUtils.TAB_WIDTH; + final int tabX = this.guiLeft + tabOffsetX + GUIUtils.TAB_BORDER; + final int tabY = this.guiTop - GUIUtils.TAB_HEIGHT + GUIUtils.TAB_BORDER; + this.drawTexturedModalRect( tabX + GUIUtils.TAB_ICON_X , tabY + GUIUtils.TAB_ICON_Y , // + this.tabs[ tab ].getIconX( ) , this.tabs[ tab ].getIconY( ) , // + GUIUtils.TAB_ICON_WIDTH , GUIUtils.TAB_ICON_HEIGHT ); + } + + + protected void selectTab( final int tabIndex ) + { + if ( this.currentTab >= 0 ) { + this.hideCurrentTab( ); + } + + this.currentTab = tabIndex; + final A_UGTab tab = this.tabs[ tabIndex ]; + if ( tab.slotGroups != null ) { + for ( final int sg : tab.slotGroups ) { + this.container.slotGroups.showGroup( sg ); + } + } + tab.onSelected( ); + } + + + private void hideCurrentTab( ) + { + final A_UGTab tab = this.tabs[ this.currentTab ]; + if ( tab.slotGroups != null ) { + for ( final int sg : tab.slotGroups ) { + this.container.slotGroups.hideGroup( sg ); + } + } + tab.onDeselected( ); + } +} diff --git a/src/java/mmm/utils/gui/GUIUtils.java b/src/java/mmm/utils/gui/GUIUtils.java new file mode 100644 index 0000000..fa4f3e3 --- /dev/null +++ b/src/java/mmm/utils/gui/GUIUtils.java @@ -0,0 +1,33 @@ +package mmm.utils.gui; + + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.minecraft.util.ResourceLocation; + + + +public class GUIUtils +{ + static final Logger LOGGER = LogManager.getLogger( ); + + public static final ResourceLocation GUI_TEXTURE = new ResourceLocation( "mmm" , "textures/gui/gui-common.png" ); + + public static final int TAB_TEXTURE_X = 0; + public static final int TAB_TEXTURE_Y = 0; + public static final int TAB_WIDTH = 26; + public static final int TAB_HEIGHT = 26; + + public static final int ABT_TEXTURE_X = 26; + public static final int ABT_TEXTURE_Y = 0; + public static final int ABT_WIDTH = 10; + public static final int ABT_HEIGHT = 15; + + public static final int TAB_BORDER = 4; + public static final int TAB_ICON_X = 5; + public static final int TAB_ICON_Y = 5; + public static final int TAB_ICON_WIDTH = 16; + public static final int TAB_ICON_HEIGHT = 16; + +} diff --git a/src/java/mmm/utils/gui/UGArrowButton.java b/src/java/mmm/utils/gui/UGArrowButton.java new file mode 100644 index 0000000..38693e0 --- /dev/null +++ b/src/java/mmm/utils/gui/UGArrowButton.java @@ -0,0 +1,51 @@ +package mmm.utils.gui; + + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.client.renderer.GlStateManager; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; + + + +@SideOnly( Side.CLIENT ) +public class UGArrowButton + extends GuiButton +{ + public final boolean forward; + + + public UGArrowButton( final int buttonID , final int x , final int y , final boolean forward ) + { + super( buttonID , x , y , GUIUtils.ABT_WIDTH , GUIUtils.ABT_HEIGHT , "" ); + this.forward = forward; + } + + + @Override + public void drawButton( final Minecraft mc , final int mouseX , final int mouseY ) + { + if ( !this.visible ) { + return; + } + mc.getTextureManager( ).bindTexture( GUIUtils.GUI_TEXTURE ); + GlStateManager.color( 1f , 1f , 1f , 1f ); + + int texX = GUIUtils.ABT_TEXTURE_X; + if ( !this.enabled ) { + texX += this.width * 2; + } else if ( mouseX >= this.xPosition && mouseY >= this.yPosition && mouseX < this.xPosition + this.width + && mouseY < this.yPosition + this.height ) { + texX += this.width; + } + + int texY = GUIUtils.ABT_TEXTURE_Y; + if ( !this.forward ) { + texY += this.height; + } + + this.drawTexturedModalRect( this.xPosition , this.yPosition , texX , texY , this.width , this.height ); + } + +} diff --git a/src/java/mmm/utils/gui/UGContainer.java b/src/java/mmm/utils/gui/UGContainer.java new file mode 100644 index 0000000..36c3370 --- /dev/null +++ b/src/java/mmm/utils/gui/UGContainer.java @@ -0,0 +1,62 @@ +package mmm.utils.gui; + + +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; + + + +public abstract class UGContainer + extends Container +{ + + public static interface I_SlotFactory + { + public Slot createSlot( IInventory inv , int index , int x , int y ); + } + + public final UGSlotGroups slotGroups; + + + public UGContainer( ) + { + super( ); + this.slotGroups = new UGSlotGroups( this.inventorySlots ); + this.slotGroups.nextGroup( ); + } + + + public void addPlayerInventory( final I_SlotFactory slotAdder , final IInventory inv , final int x , final int y ) + { + this.addPlayerInventory( slotAdder , inv , x , y , 4 ); + } + + + public void addPlayerInventory( final I_SlotFactory slotAdder , final IInventory inv , final int x , final int y , + final int spacing ) + { + this.addGrid( slotAdder , inv , 9 , 3 , 9 , x , y ); // Main inventory + this.addGrid( slotAdder , inv , 9 , 1 , 0 , x , y + spacing + 54 ); // Quick bar + } + + + public void addGrid( final I_SlotFactory slotAdder , final IInventory inv , final int columns , final int rows , + final int index , final int x , final int y ) + { + this.addGrid( slotAdder , inv , columns , rows , index , x , y , 2 , 2 ); + } + + + public void addGrid( final I_SlotFactory slotAdder , final IInventory inv , final int columns , final int rows , + final int index , final int x , final int y , final int xSpacing , final int ySpacing ) + { + for ( int row = 0 , i = 0 ; row < rows ; ++row ) { + for ( int column = 0 ; column < columns ; ++column , ++i ) { + this.addSlotToContainer( slotAdder.createSlot( inv , index + i , // + x + column * ( 16 + xSpacing ) , y + row * ( 16 + ySpacing ) ) ); + } + } + } + +} diff --git a/src/java/mmm/utils/slots/USDisplay.java b/src/java/mmm/utils/gui/UGSlotDisplay.java similarity index 57% rename from src/java/mmm/utils/slots/USDisplay.java rename to src/java/mmm/utils/gui/UGSlotDisplay.java index 9375080..b863447 100644 --- a/src/java/mmm/utils/slots/USDisplay.java +++ b/src/java/mmm/utils/gui/UGSlotDisplay.java @@ -1,4 +1,4 @@ -package mmm.utils.slots; +package mmm.utils.gui; import net.minecraft.entity.player.EntityPlayer; @@ -9,25 +9,25 @@ import net.minecraft.item.ItemStack; /** An inventory slot that cannot be interacted with */ -public class USDisplay +public class UGSlotDisplay extends Slot { - public USDisplay( IInventory inventoryIn , int index , int xPosition , int yPosition ) + public UGSlotDisplay( final IInventory inventoryIn , final int index , final int xPosition , final int yPosition ) { super( inventoryIn , index , xPosition , yPosition ); } @Override - public boolean isItemValid( ItemStack stack ) + public boolean isItemValid( final ItemStack stack ) { return false; } @Override - public boolean canTakeStack( EntityPlayer playerIn ) + public boolean canTakeStack( final EntityPlayer playerIn ) { return false; } diff --git a/src/java/mmm/utils/slots/USFuel.java b/src/java/mmm/utils/gui/UGSlotFuel.java similarity index 72% rename from src/java/mmm/utils/slots/USFuel.java rename to src/java/mmm/utils/gui/UGSlotFuel.java index de1981f..c95c4f5 100644 --- a/src/java/mmm/utils/slots/USFuel.java +++ b/src/java/mmm/utils/gui/UGSlotFuel.java @@ -1,4 +1,4 @@ -package mmm.utils.slots; +package mmm.utils.gui; import javax.annotation.Nullable; @@ -10,11 +10,11 @@ import net.minecraft.tileentity.TileEntityFurnace; -public class USFuel +public class UGSlotFuel extends Slot { - public USFuel( final IInventory inventoryIn , final int slotIndex , final int xPosition , final int yPosition ) + public UGSlotFuel( final IInventory inventoryIn , final int slotIndex , final int xPosition , final int yPosition ) { super( inventoryIn , slotIndex , xPosition , yPosition ); } diff --git a/src/java/mmm/utils/slots/USVisibilityController.java b/src/java/mmm/utils/gui/UGSlotGroups.java similarity index 82% rename from src/java/mmm/utils/slots/USVisibilityController.java rename to src/java/mmm/utils/gui/UGSlotGroups.java index 1ff51d7..eb83d46 100644 --- a/src/java/mmm/utils/slots/USVisibilityController.java +++ b/src/java/mmm/utils/gui/UGSlotGroups.java @@ -1,4 +1,4 @@ -package mmm.utils.slots; +package mmm.utils.gui; import java.util.List; @@ -8,7 +8,7 @@ import net.minecraft.inventory.Slot; -public class USVisibilityController +public class UGSlotGroups { private final List< Slot > slots; private final IntArrayList firstSlots; @@ -16,21 +16,21 @@ public class USVisibilityController private int[] slotY; - public USVisibilityController( final List< Slot > slots ) + public UGSlotGroups( final List< Slot > slots ) { this.slots = slots; this.firstSlots = new IntArrayList( ); } - public int startGroup( ) + public int nextGroup( ) { this.firstSlots.add( this.slots.size( ) ); return this.firstSlots.size( ) - 1; } - public void finalizeGroups( ) + public void endGroups( ) { final int nSlots = this.slots.size( ); this.slotX = new int[ nSlots ]; @@ -39,11 +39,12 @@ public class USVisibilityController final Slot slot = this.slots.get( i ); this.slotX[ i ] = slot.xDisplayPosition; this.slotY[ i ] = slot.yDisplayPosition; + slot.xDisplayPosition = slot.yDisplayPosition = -4000; } } - public USVisibilityController showGroup( final int index ) + public UGSlotGroups showGroup( final int index ) { final int first = this.firstSlots.getInt( index ); final int last; @@ -63,7 +64,7 @@ public class USVisibilityController } - public USVisibilityController hideGroup( final int index ) + public UGSlotGroups hideGroup( final int index ) { final int first = this.firstSlots.getInt( index ); final int last; diff --git a/src/java/mmm/utils/slots/USOutput.java b/src/java/mmm/utils/gui/UGSlotOutput.java similarity index 88% rename from src/java/mmm/utils/slots/USOutput.java rename to src/java/mmm/utils/gui/UGSlotOutput.java index 16359b3..8799cce 100644 --- a/src/java/mmm/utils/slots/USOutput.java +++ b/src/java/mmm/utils/gui/UGSlotOutput.java @@ -1,4 +1,4 @@ -package mmm.utils.slots; +package mmm.utils.gui; import javax.annotation.Nullable; @@ -10,7 +10,7 @@ import net.minecraft.item.ItemStack; -public class USOutput +public class UGSlotOutput extends Slot { public static interface I_OutputHandler @@ -27,14 +27,14 @@ public class USOutput private int removed; - public USOutput( final EntityPlayer player , final IInventory inventoryIn , final int slotIndex , + public UGSlotOutput( final EntityPlayer player , final IInventory inventoryIn , final int slotIndex , final int xPosition , final int yPosition ) { this( player , inventoryIn , slotIndex , xPosition , yPosition , null ); } - public USOutput( final EntityPlayer player , final IInventory inventoryIn , final int slotIndex , + public UGSlotOutput( final EntityPlayer player , final IInventory inventoryIn , final int slotIndex , final int xPosition , final int yPosition , @Nullable final I_OutputHandler handler ) { super( inventoryIn , slotIndex , xPosition , yPosition ); diff --git a/src/resources/assets/mmm/textures/gui/alloy_furnace_1.png b/src/resources/assets/mmm/textures/gui/alloy_furnace_1.png index 377c33e..38c8631 100644 Binary files a/src/resources/assets/mmm/textures/gui/alloy_furnace_1.png and b/src/resources/assets/mmm/textures/gui/alloy_furnace_1.png differ diff --git a/src/resources/assets/mmm/textures/gui/alloy_furnace_2.png b/src/resources/assets/mmm/textures/gui/alloy_furnace_2.png index 52eba1a..a432ff5 100644 Binary files a/src/resources/assets/mmm/textures/gui/alloy_furnace_2.png and b/src/resources/assets/mmm/textures/gui/alloy_furnace_2.png differ diff --git a/src/resources/assets/mmm/textures/gui/gui-common.png b/src/resources/assets/mmm/textures/gui/gui-common.png new file mode 100644 index 0000000..37da863 Binary files /dev/null and b/src/resources/assets/mmm/textures/gui/gui-common.png differ