Alloy furnace - Config tab

Doesn't work yet.
Also added tooltips on tabs.
This commit is contained in:
Emmanuel BENOîT 2016-06-25 22:55:15 +02:00
parent 204afb153a
commit ee736975b2
4 changed files with 41 additions and 19 deletions

Binary file not shown.

View file

@ -3,6 +3,9 @@ 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;
@ -16,6 +19,7 @@ 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,19 +31,22 @@ public class TBAlloyFurnaceGui
{
@SideOnly( Side.CLIENT )
private static enum Tab {
MAIN( 207 , 0 , 1 ) ,
CONFIG( 191 , 0 , 2 );
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 )
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;
}
}
@ -84,7 +91,8 @@ public class TBAlloyFurnaceGui
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_2.png" ) ,
new ResourceLocation( Mmm.ID , "textures/gui/alloy_furnace_3.png" ) ,
};
private static final TBAlloyFurnaceGui.Tab TABS[] = TBAlloyFurnaceGui.Tab.values( );
@ -140,7 +148,8 @@ public class TBAlloyFurnaceGui
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( "gui.mmm.select_recipe" ) );
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 );
@ -163,13 +172,22 @@ public class TBAlloyFurnaceGui
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.CONFIG;
final boolean visible = this.selectedTab == Tab.RECIPE;
this.bNext.visible = this.bPrevious.visible = this.bConfirm.visible = visible;
this.tfSearch.setVisible( visible );
@ -270,27 +288,28 @@ public class TBAlloyFurnaceGui
super.mouseClicked( mouseX , mouseY , mouseButton );
for ( final TBAlloyFurnaceGui.Tab tab : TBAlloyFurnaceGui.Tab.values( ) ) {
if ( this.selectedTab == tab ) {
continue;
}
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;
if ( mouseX >= tabX && mouseY >= tabY && mouseX <= tabX + TBAlloyFurnaceGui.TAB_WIDTH
&& mouseY <= tabY + TBAlloyFurnaceGui.TAB_HEIGHT ) {
if ( this.selectedTab != tab && this.isInTab( tab , mouseX , mouseY ) ) {
this.selectTab( tab );
return;
}
}
if ( this.selectedTab == Tab.CONFIG ) {
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
@ -310,7 +329,7 @@ public class TBAlloyFurnaceGui
return;
}
MAlloyRecipe selected = this.currentRecipe == -1 ? null : this.recipes.get( this.currentRecipe );
final MAlloyRecipe selected = this.currentRecipe == -1 ? null : this.recipes.get( this.currentRecipe );
final ArrayList< MAlloyRecipe > fullList = MAlloyRecipe.REGISTRY.getRecipes( );
this.searchString = newText;
if ( "".equals( newText ) ) {

View file

@ -1,4 +1,4 @@
gui.mmm.select_recipe=Select Recipe
gui.mmm.configure=Configure
@ -17,6 +17,9 @@ tile.mmm.materials.ore.cuprite.name=Cuprite Ore
item.mmm.tech.base.alloy_furnace.name=Alloy Furnace
container.mmm.alloy_furnace.contents=Furnace Contents
container.mmm.alloy_furnace.recipe=Alloy Selection
container.mmm.alloy_furnace.select=Select Alloy
item.mmm.tech.tools.copper.shovel.name=Copper Shovel

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB