2016-07-23 19:20:53 +02:00
/ *
* This file ( " FilterSettingsGui.java " ) is part of the Actually Additions mod for Minecraft .
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http : //ellpeck.de/actaddlicense
* View the source code at https : //github.com/Ellpeck/ActuallyAdditions
*
* © 2015 - 2016 Ellpeck
* /
package de.ellpeck.actuallyadditions.mod.inventory.gui ;
import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiInputter.SmallerButton ;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings ;
import de.ellpeck.actuallyadditions.mod.util.ModUtil ;
import de.ellpeck.actuallyadditions.mod.util.StringUtil ;
import net.minecraft.client.Minecraft ;
import net.minecraft.client.gui.Gui ;
import net.minecraft.client.gui.GuiButton ;
import net.minecraft.util.text.TextFormatting ;
import net.minecraftforge.fml.client.config.GuiUtils ;
import net.minecraftforge.fml.relauncher.Side ;
import net.minecraftforge.fml.relauncher.SideOnly ;
import java.util.ArrayList ;
import java.util.Collections ;
import java.util.List ;
@SideOnly ( Side . CLIENT )
public class FilterSettingsGui extends Gui {
private final FilterSettings theSettings ;
public SmallerButton whitelistButton ;
public SmallerButton metaButton ;
public SmallerButton nbtButton ;
2016-11-17 14:56:26 +01:00
public SmallerButton modButton ;
2016-07-24 18:58:08 +02:00
public SmallerButton oredictButton ;
2016-07-23 19:20:53 +02:00
public FilterSettingsGui ( FilterSettings settings , int x , int y , List < GuiButton > buttonList ) {
this . theSettings = settings ;
2016-11-17 14:56:26 +01:00
this . whitelistButton = new SmallerButton ( this . theSettings . whitelistButtonId , x , y , " " , true ) ;
2016-07-23 19:20:53 +02:00
buttonList . add ( this . whitelistButton ) ;
2016-11-26 21:32:27 +01:00
y + = 14 ;
2016-11-17 14:56:26 +01:00
this . metaButton = new SmallerButton ( this . theSettings . metaButtonId , x , y , " " , true ) ;
2016-07-23 19:20:53 +02:00
buttonList . add ( this . metaButton ) ;
2016-11-26 21:32:27 +01:00
y + = 14 ;
2016-11-17 14:56:26 +01:00
this . nbtButton = new SmallerButton ( this . theSettings . nbtButtonId , x , y , " " , true ) ;
2016-07-23 19:20:53 +02:00
buttonList . add ( this . nbtButton ) ;
2016-11-26 21:32:27 +01:00
y + = 14 ;
2016-11-17 14:56:26 +01:00
this . oredictButton = new SmallerButton ( this . theSettings . oredictButtonId , x , y , " " , true ) ;
2016-07-24 18:58:08 +02:00
buttonList . add ( this . oredictButton ) ;
2016-11-26 21:32:27 +01:00
y + = 15 ;
2016-11-17 14:56:26 +01:00
this . modButton = new SmallerButton ( this . theSettings . modButtonId , x , y , " " , true ) ;
buttonList . add ( this . modButton ) ;
2016-07-24 18:58:08 +02:00
2016-07-23 19:20:53 +02:00
this . update ( ) ;
}
public void update ( ) {
2016-11-17 14:56:26 +01:00
this . whitelistButton . displayString = ( this . theSettings . isWhitelist ? TextFormatting . DARK_GREEN : TextFormatting . RED ) + " WH " ;
this . metaButton . displayString = ( this . theSettings . respectMeta ? TextFormatting . DARK_GREEN : TextFormatting . RED ) + " ME " ;
this . nbtButton . displayString = ( this . theSettings . respectNBT ? TextFormatting . DARK_GREEN : TextFormatting . RED ) + " NB " ;
this . modButton . displayString = ( this . theSettings . respectMod ? TextFormatting . DARK_GREEN : TextFormatting . RED ) + " MO " ;
this . oredictButton . displayString = ( this . theSettings . respectOredict = = 0 ? TextFormatting . RED : ( this . theSettings . respectOredict = = 1 ? TextFormatting . GREEN : TextFormatting . DARK_GREEN ) ) + " OR " ;
2016-07-23 19:20:53 +02:00
}
public void drawHover ( int mouseX , int mouseY ) {
Minecraft mc = Minecraft . getMinecraft ( ) ;
if ( this . whitelistButton . isMouseOver ( ) ) {
List < String > list = new ArrayList < String > ( ) ;
list . add ( TextFormatting . BOLD + ( this . theSettings . isWhitelist ? StringUtil . localize ( " info. " + ModUtil . MOD_ID + " .gui.whitelist " ) : StringUtil . localize ( " info. " + ModUtil . MOD_ID + " .gui.blacklist " ) ) ) ;
list . addAll ( mc . fontRendererObj . listFormattedStringToWidth ( StringUtil . localizeFormatted ( " info. " + ModUtil . MOD_ID + " .gui.whitelistInfo " ) , 200 ) ) ;
GuiUtils . drawHoveringText ( list , mouseX , mouseY , mc . displayWidth , mc . displayHeight , - 1 , mc . fontRendererObj ) ;
}
else if ( this . metaButton . isMouseOver ( ) ) {
GuiUtils . drawHoveringText ( Collections . singletonList ( TextFormatting . BOLD + ( this . theSettings . respectMeta ? " Respecting " : " Ignoring " ) + " Metadata " ) , mouseX , mouseY , mc . displayWidth , mc . displayHeight , - 1 , mc . fontRendererObj ) ;
}
else if ( this . nbtButton . isMouseOver ( ) ) {
GuiUtils . drawHoveringText ( Collections . singletonList ( TextFormatting . BOLD + ( this . theSettings . respectNBT ? " Respecting " : " Ignoring " ) + " NBT " ) , mouseX , mouseY , mc . displayWidth , mc . displayHeight , - 1 , mc . fontRendererObj ) ;
2016-11-17 14:56:26 +01:00
}
else if ( this . modButton . isMouseOver ( ) ) {
List < String > list = new ArrayList < String > ( ) ;
list . add ( TextFormatting . BOLD + " Mod Mode " + ( this . theSettings . respectMod ? " On " : " Off " ) ) ;
list . addAll ( mc . fontRendererObj . listFormattedStringToWidth ( " If this is enabled, the filter will compare the mods items come from " + TextFormatting . RED + " instead of comparing the items themselves " + TextFormatting . RESET + " . This can be useful for storage systems with mod-based chests. \ nCan also be combined with the other options, but that normally isn't very useful. " , 200 ) ) ;
GuiUtils . drawHoveringText ( list , mouseX , mouseY , mc . displayWidth , mc . displayHeight , - 1 , mc . fontRendererObj ) ;
2016-07-23 19:20:53 +02:00
}
2016-07-24 18:58:08 +02:00
else if ( this . oredictButton . isMouseOver ( ) ) {
List < String > list = new ArrayList < String > ( ) ;
list . add ( TextFormatting . BOLD + ( this . theSettings . respectOredict = = 0 ? " Ignoring " : ( this . theSettings . respectOredict = = 1 ? " Soft Respecting " : " Hard Respecting " ) ) + " OreDictionary " ) ;
String type = null ;
if ( this . theSettings . respectOredict = = 1 ) {
type = " only one " ;
}
else if ( this . theSettings . respectOredict = = 2 ) {
type = " all " ;
}
if ( type ! = null ) {
list . addAll ( mc . fontRendererObj . listFormattedStringToWidth ( " The item being passed only has to contain " + TextFormatting . DARK_GREEN + type + TextFormatting . RESET + " of the OreDictionary tags of the item in the filter. " , 200 ) ) ;
}
GuiUtils . drawHoveringText ( list , mouseX , mouseY , mc . displayWidth , mc . displayHeight , - 1 , mc . fontRendererObj ) ;
}
2016-07-23 19:20:53 +02:00
}
}