2016-11-10 19:50:01 +01:00
/ *
* This file ( " GuiMainPage.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
*
2018-05-10 11:38:58 +02:00
* Â © 2015 - 2017 Ellpeck
2016-11-10 19:50:01 +01:00
* /
2020-09-09 16:49:01 +02:00
package de.ellpeck.actuallyadditions.booklet.gui ;
2016-11-10 19:50:01 +01:00
2019-05-02 09:10:29 +02:00
import java.io.IOException ;
import java.util.ArrayList ;
import java.util.List ;
2016-11-10 19:50:01 +01:00
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI ;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry ;
2020-09-09 16:48:43 +02:00
import de.ellpeck.actuallyadditions.common.ActuallyAdditions ;
2020-09-09 16:49:01 +02:00
import de.ellpeck.actuallyadditions.booklet.InitBooklet ;
import de.ellpeck.actuallyadditions.booklet.button.EntryButton ;
2020-09-09 16:48:43 +02:00
import de.ellpeck.actuallyadditions.common.config.GuiConfiguration ;
import de.ellpeck.actuallyadditions.common.data.PlayerData ;
import de.ellpeck.actuallyadditions.common.data.PlayerData.PlayerSave ;
import de.ellpeck.actuallyadditions.common.inventory.gui.TexturedButton ;
import de.ellpeck.actuallyadditions.common.network.PacketHandlerHelper ;
import de.ellpeck.actuallyadditions.common.util.StringUtil ;
import de.ellpeck.actuallyadditions.common.util.Util ;
2016-11-10 21:07:15 +01:00
import net.minecraft.client.gui.GuiButton ;
2016-11-10 19:50:01 +01:00
import net.minecraft.client.gui.GuiScreen ;
2016-11-10 23:37:40 +01:00
import net.minecraft.item.ItemStack ;
2016-11-12 15:09:30 +01:00
import net.minecraft.util.math.MathHelper ;
import net.minecraft.util.text.TextFormatting ;
2016-11-10 22:06:58 +01:00
import net.minecraftforge.fml.relauncher.Side ;
import net.minecraftforge.fml.relauncher.SideOnly ;
2016-11-10 19:50:01 +01:00
2017-06-17 00:48:49 +02:00
//TODO Fix achievement button
2016-11-10 22:06:58 +01:00
@SideOnly ( Side . CLIENT )
2019-05-02 09:10:29 +02:00
public class GuiMainPage extends GuiBooklet {
private static final String [ ] QUOTES = new String [ ] { " Actually Additions, to me, is quite magical in a way.@Saphrym " , " Actually quite cool. Lots of nice little additions.@Direwolf20 " , " Mod Dev quite rude and arrogant@Bubb1e0seven " , " A whimsical breath of fresh air in a stuffy tech-mod world.@mezz " , " User-friendly :3@TheMeeep " , " A lot of stuff, some of it really good.@Narubion " , " I like the bookmarks.@Vazkii " , " It's got some stuff I guess.@Ellpeck " , " Actually Additions should be included in every new modpack that includes any form of tech.@YasminEndusa " , " A mod that basically lets you do what ever the heck you want.@Ristelle " , " TINY TORCHES!! BABY TORCHES!! Somebody actually finally did it!!@Soaryn " , " Balanced mod wich makes things different - in a good way.@garantiertnicht " , " The mod everyone needs, but not everyone knows@Brewpl " , " The in-game documentation is the best I’ ve seen. I especially love the JEI integration. Even a derp like me can figure it out.@dannydjdk " , " The second best mod I've ever used.@mmaas44 " , " The Fermenting Barrel is one of my favorite textures.@amadornes " , " Smiley Clouds is the reason for fascism in 2016.@raoulvdberge " , " The worms are an awesome idea!@greenking " , " Can I use that mod in my pack?@Ibraheem " , " Hello, love the mod.@SuntannedDuck2 " , " Quick! Have all the fun before they nerf it!@JuddMan03 " , " I have a feeling Actually Additions is also like Extra Utilities with Random things smashed together why is it...@lesslighter " , " Leaf eater... munchdew... hummm@EiOs " , " There is no such thing as canola seeds.@AlBoVa " , " This mod is cancer, BRUTAL EXPENSIVE POWER usage..Just, cancer.@KoJo " , " Spaghetti is spaghetti, and noodles are noodles.@robsonld04 " , " The Actually Additions name is actually true. It's actually great!@asiekierka " , " Such a great mod@jsdeveloper " , " That mod is kind of funny.@Anonymous " , " Actually Additions is a lot of fun.@Anonymous " , " Is Actually Additions still fugly?@Anonymous " , " I like it, but it's so small.@Anonymous " , " It has a couple of blocks I like, but overall it's just a mess.@Anonymous " , " Direwolf's 1.10 playthrough is just him shilling Actually Additions@Anonymous " , " We thought about sending the author a bunch of pizzas to his adress@Anonymous " , " It's op as heck.@billofbong0 " , " Actually AdditionsってマイクラMODすごく良いのに日本人で遊んでる人あんまいないっぽい@stay_uk " , " Actually Additions is OP. Not like my favorite combination of mods, Project E + Magic Crops + Draconic Evolution.@Anonymous " , " To be perfectly honest, I never actually realized how much content Actually Additions has before.@Ellpeck " , " I don't blame you, I actually downgraded to Actually Additions.@PvtSeaCow " , " It is lonely because there is no device to fly items with the laser in the 1.7.10 version.@Google Translate " , " 始めまして。日本人です。このMODは本当に素晴らしい! ただ、1.7.10ヴァージョンだと、レーザーでアイテムを飛ばす装置がないので寂しいです。@Anonymous " , " Some verses found in older translations, such as the KJV were actually additions made by later copyists.@Pat_Joel " , " I can't place filters into Laser Relays, but the mod is very cool.@LP_Jakob " , " Am I good enough to be an Actually Additions tool?@deanwhufc " } ;
2016-11-17 16:25:47 +01:00
2017-06-17 00:48:49 +02:00
//private TexturedButton achievementButton;
2016-11-17 17:36:00 +01:00
private TexturedButton configButton ;
2016-11-12 15:09:30 +01:00
private GuiButton tutorialButton ;
private boolean showTutorial ;
2016-11-17 16:25:47 +01:00
private String bookletName ;
2016-12-23 21:38:39 +01:00
private String bookletEdition ;
2016-11-17 16:25:47 +01:00
private List < String > quote ;
private String quoteGuy ;
2019-05-02 09:10:29 +02:00
public GuiMainPage ( GuiScreen previousScreen ) {
2016-11-10 21:07:15 +01:00
super ( previousScreen , null ) ;
2016-11-10 19:50:01 +01:00
}
2019-05-02 09:10:29 +02:00
private static List < IBookletEntry > getDisplayedEntries ( ) {
2019-02-27 19:53:05 +01:00
List < IBookletEntry > displayed = new ArrayList < > ( ) ;
2017-04-01 19:40:39 +02:00
2019-05-02 09:10:29 +02:00
for ( IBookletEntry entry : ActuallyAdditionsAPI . BOOKLET_ENTRIES ) {
if ( entry . visibleOnFrontPage ( ) ) {
2017-04-01 19:40:39 +02:00
displayed . add ( entry ) ;
}
}
return displayed ;
}
2016-11-10 19:50:01 +01:00
@Override
2019-05-02 09:10:29 +02:00
public void initGui ( ) {
2016-11-10 19:50:01 +01:00
super . initGui ( ) ;
2016-11-12 15:09:30 +01:00
int flavor = 1 ;
2019-05-02 09:10:29 +02:00
if ( this . mc . world . rand . nextFloat ( ) < = 0 . 1 ) {
2016-11-26 21:32:27 +01:00
flavor = MathHelper . getInt ( this . mc . world . rand , 2 , 7 ) ;
2016-11-12 15:09:30 +01:00
}
2019-05-02 09:10:29 +02:00
this . bookletName = " info. " + ActuallyAdditions . MODID + " .booklet.manualName.1. " + flavor ;
2016-11-12 15:09:30 +01:00
2016-11-26 21:32:27 +01:00
String usedQuote = QUOTES [ this . mc . world . rand . nextInt ( QUOTES . length ) ] ;
2016-11-17 16:25:47 +01:00
String [ ] quoteSplit = usedQuote . split ( " @ " ) ;
2019-05-02 09:10:29 +02:00
if ( quoteSplit . length = = 2 ) {
2017-06-29 18:30:02 +02:00
this . quote = this . fontRenderer . listFormattedStringToWidth ( quoteSplit [ 0 ] , 120 ) ;
2016-11-17 16:25:47 +01:00
this . quoteGuy = quoteSplit [ 1 ] ;
}
2016-12-23 21:38:39 +01:00
String playerName = this . mc . player . getName ( ) ;
2019-05-02 09:10:29 +02:00
if ( playerName . equalsIgnoreCase ( " dqmhose " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Pants Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " TwoOfEight " ) | | playerName . equalsIgnoreCase ( " BootyToast " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Illustrator's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " KittyVanCat " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Cat's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " canitzp " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " P's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " direwolf20 " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Edition 20 " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " dannydjdk " ) | | playerName . equalsIgnoreCase ( " andrew_period " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Derp's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " mezz " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Just Enough Editions " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " amadornes " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Beard's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " raoul " ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Giraffe's Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " ellpeck " ) | | playerName . equalsIgnoreCase ( " profprospector " ) ) {
2016-12-23 21:38:39 +01:00
String [ ] colors = new String [ 15 ] ;
2019-05-02 09:10:29 +02:00
for ( int i = 0 ; i < colors . length ; i + + ) {
colors [ i ] = TextFormatting . fromColorIndex ( this . mc . world . rand . nextInt ( 15 ) ) . toString ( ) + TextFormatting . ITALIC ;
2016-12-23 21:38:39 +01:00
}
2019-05-02 09:10:29 +02:00
this . bookletEdition = String . format ( " %sC%so%sl%so%sr%sf%su%sl %sE%sd%si%st%si%so%sn " , ( Object [ ] ) colors ) ;
} else if ( playerName . equalsIgnoreCase ( " oitsjustjose " ) ) {
2016-12-28 15:23:30 +01:00
this . bookletEdition = " oitsjustanedition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " xbony2 " ) ) {
2016-12-28 15:31:14 +01:00
this . bookletEdition = " Naughty Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " themattabase " ) ) {
2016-12-31 18:10:36 +01:00
this . bookletEdition = " Withered Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " robsonld04 " ) ) {
2017-01-13 23:53:40 +01:00
this . bookletEdition = " Modpack Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " snowshock35 " ) ) {
2017-02-04 18:34:19 +01:00
this . bookletEdition = " Edition 35 " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " asiekierka " ) ) {
2018-05-10 11:38:58 +02:00
this . bookletEdition = " ‽ Edition " ;
2019-05-02 09:10:29 +02:00
} else if ( playerName . equalsIgnoreCase ( " elucent " ) ) {
2017-02-23 23:46:55 +01:00
this . bookletEdition = " " ;
2019-05-02 09:10:29 +02:00
} else {
if ( Util . isDevVersion ( ) ) {
2016-12-23 21:38:39 +01:00
this . bookletEdition = " Dev's Edition " ;
2019-05-02 09:10:29 +02:00
} else {
this . bookletEdition = StringUtil . localize ( " info. " + ActuallyAdditions . MODID + " .booklet.edition " ) + " " + Util . getMajorModVersion ( ) ;
2016-12-23 21:38:39 +01:00
}
}
2019-02-27 19:53:05 +01:00
List < String > configText = new ArrayList < > ( ) ;
2019-05-02 09:10:29 +02:00
configText . add ( TextFormatting . GOLD + StringUtil . localize ( " booklet. " + ActuallyAdditions . MODID + " .configButton.name " ) ) ;
configText . addAll ( this . fontRenderer . listFormattedStringToWidth ( StringUtil . localizeFormatted ( " booklet. " + ActuallyAdditions . MODID + " .configButton.desc " , ActuallyAdditions . NAME ) . replaceAll ( " \\ \\ n " , " \ n " ) , 200 ) ) ;
this . configButton = new TexturedButton ( RES_LOC_GADGETS , - 388 , this . guiLeft + 16 , this . guiTop + this . ySize - 30 , 188 , 14 , 16 , 16 , configText ) ;
2016-11-20 14:51:21 +01:00
this . buttonList . add ( this . configButton ) ;
2019-02-27 19:53:05 +01:00
List < String > achievementText = new ArrayList < > ( ) ;
2019-05-02 09:10:29 +02:00
achievementText . add ( TextFormatting . GOLD + StringUtil . localize ( " booklet. " + ActuallyAdditions . MODID + " .achievementButton.name " ) ) ;
achievementText . addAll ( this . fontRenderer . listFormattedStringToWidth ( StringUtil . localizeFormatted ( " booklet. " + ActuallyAdditions . MODID + " .achievementButton.desc " , ActuallyAdditions . NAME ) , 200 ) ) ;
2017-06-17 00:48:49 +02:00
//this.achievementButton = new TexturedButton(RES_LOC_GADGETS, -389, this.guiLeft+36, this.guiTop+this.ySize-30, 204, 14, 16, 16, achievementText);
//this.buttonList.add(this.achievementButton);
2016-11-20 14:51:21 +01:00
2016-11-26 21:32:27 +01:00
PlayerSave data = PlayerData . getDataFromPlayer ( this . mc . player ) ;
2019-05-02 09:10:29 +02:00
if ( ! data . didBookTutorial ) {
2016-11-12 15:09:30 +01:00
this . showTutorial = true ;
2019-05-02 09:10:29 +02:00
this . tutorialButton = new GuiButton ( 666666 , this . guiLeft + 140 / 2 - 50 , this . guiTop + 146 , 100 , 20 , " Please click me <3 " ) ;
2016-11-12 15:09:30 +01:00
this . buttonList . add ( this . tutorialButton ) ;
2016-11-20 14:51:21 +01:00
this . configButton . visible = false ;
2017-06-17 00:48:49 +02:00
//this.achievementButton.visible = false;
2016-11-17 20:27:33 +01:00
}
2016-11-17 17:36:00 +01:00
2019-05-02 09:10:29 +02:00
for ( int i = 0 ; i < BUTTONS_PER_PAGE ; i + + ) {
2017-02-18 00:54:58 +01:00
List < IBookletEntry > displayed = getDisplayedEntries ( ) ;
2019-05-02 09:10:29 +02:00
if ( displayed . size ( ) > i ) {
2017-02-18 00:54:58 +01:00
IBookletEntry entry = displayed . get ( i ) ;
2019-05-02 09:10:29 +02:00
this . buttonList . add ( new EntryButton ( this , i , this . guiLeft + 156 , this . guiTop + 11 + i * 13 , 115 , 10 , " - " + entry . getLocalizedNameWithFormatting ( ) , ItemStack . EMPTY ) ) ;
} else {
2016-11-12 15:09:30 +01:00
return ;
2016-11-10 19:50:01 +01:00
}
2016-11-12 15:09:30 +01:00
}
2016-11-10 19:50:01 +01:00
}
2016-11-10 21:07:15 +01:00
@Override
2019-05-02 09:10:29 +02:00
protected void actionPerformed ( GuiButton button ) throws IOException {
if ( button instanceof EntryButton ) {
2017-02-18 00:54:58 +01:00
List < IBookletEntry > displayed = getDisplayedEntries ( ) ;
2019-05-02 09:10:29 +02:00
if ( displayed . size ( ) > button . id ) {
2017-02-18 00:54:58 +01:00
IBookletEntry entry = displayed . get ( button . id ) ;
2019-05-02 09:10:29 +02:00
if ( entry ! = null ) {
2016-11-12 12:26:36 +01:00
this . mc . displayGuiScreen ( new GuiEntry ( this . previousScreen , this , entry , 0 , " " , false ) ) ;
2016-11-10 21:07:15 +01:00
}
}
}
2019-02-27 19:53:05 +01:00
/ * else if ( button = = this . achievementButton ) {
2017-06-17 00:48:49 +02:00
GuiScreen achievements = new GuiAAAchievements ( this , this . mc . player . getStatFileWriter ( ) ) ;
2016-11-17 17:36:00 +01:00
this . mc . displayGuiScreen ( achievements ) ;
2017-06-17 00:48:49 +02:00
} * /
2019-05-02 09:10:29 +02:00
else if ( button = = this . configButton ) {
2016-11-17 17:36:00 +01:00
GuiScreen config = new GuiConfiguration ( this ) ;
this . mc . displayGuiScreen ( config ) ;
2019-05-02 09:10:29 +02:00
} else if ( this . showTutorial & & button = = this . tutorialButton ) {
if ( this . hasBookmarkButtons ( ) ) {
if ( ! isShiftKeyDown ( ) ) {
for ( int i = 0 ; i < InitBooklet . chaptersIntroduction . length ; i + + ) {
2016-11-12 15:09:30 +01:00
this . bookmarkButtons [ i ] . assignedPage = InitBooklet . chaptersIntroduction [ i ] . getAllPages ( ) [ 0 ] ;
}
}
this . showTutorial = false ;
this . tutorialButton . visible = false ;
2016-11-20 14:51:21 +01:00
this . configButton . visible = true ;
2017-06-17 00:48:49 +02:00
//this.achievementButton.visible = true;
2016-11-20 14:51:21 +01:00
2016-11-26 21:32:27 +01:00
PlayerSave data = PlayerData . getDataFromPlayer ( this . mc . player ) ;
2016-11-12 15:09:30 +01:00
data . didBookTutorial = true ;
2017-02-18 00:54:58 +01:00
PacketHandlerHelper . sendPlayerDataToServer ( false , 1 ) ;
2016-11-12 15:09:30 +01:00
}
2019-05-02 09:10:29 +02:00
} else {
2016-11-10 21:07:15 +01:00
super . actionPerformed ( button ) ;
}
}
2016-11-10 23:37:40 +01:00
2016-11-12 15:09:30 +01:00
@Override
2019-05-02 09:10:29 +02:00
public void drawScreenPre ( int mouseX , int mouseY , float partialTicks ) {
2016-11-12 15:09:30 +01:00
super . drawScreenPre ( mouseX , mouseY , partialTicks ) ;
2019-05-02 09:10:29 +02:00
String strg = TextFormatting . DARK_GREEN + StringUtil . localize ( this . bookletName ) ;
this . fontRenderer . drawString ( strg , this . guiLeft + 72 - this . fontRenderer . getStringWidth ( strg ) / 2 - 3 , this . guiTop + 19 , 0 ) ;
strg = TextFormatting . DARK_GREEN + StringUtil . localize ( " info. " + ActuallyAdditions . MODID + " .booklet.manualName.2 " ) ;
this . fontRenderer . drawString ( strg , this . guiLeft + 72 - this . fontRenderer . getStringWidth ( strg ) / 2 - 3 , this . guiTop + 19 + this . fontRenderer . FONT_HEIGHT , 0 ) ;
2016-11-12 15:09:30 +01:00
2019-05-02 09:10:29 +02:00
strg = TextFormatting . GOLD + TextFormatting . ITALIC . toString ( ) + this . bookletEdition ;
this . fontRenderer . drawString ( strg , this . guiLeft + 72 - this . fontRenderer . getStringWidth ( strg ) / 2 - 3 , this . guiTop + 40 , 0 ) ;
2016-11-12 15:09:30 +01:00
2019-05-02 09:10:29 +02:00
if ( this . showTutorial ) {
String text = TextFormatting . BLUE + " It looks like this is the first time you are using this manual. \ nIf you click the button below, some useful bookmarks will be stored at the bottom of the GUI. You should definitely check them out to get started with " + ActuallyAdditions . NAME + " ! \ nIf you don't want this, shift-click the button. " ;
this . renderSplitScaledAsciiString ( text , this . guiLeft + 11 , this . guiTop + 55 , 0 , false , this . getMediumFontSize ( ) , 120 ) ;
} else if ( this . quote ! = null & & ! this . quote . isEmpty ( ) & & this . quoteGuy ! = null ) {
2016-11-17 16:25:47 +01:00
int quoteSize = this . quote . size ( ) ;
2019-05-02 09:10:29 +02:00
for ( int i = 0 ; i < quoteSize ; i + + ) {
this . renderScaledAsciiString ( TextFormatting . ITALIC + this . quote . get ( i ) , this . guiLeft + 25 , this . guiTop + 90 + i * 8 , 0 , false , this . getMediumFontSize ( ) ) ;
2016-11-17 16:25:47 +01:00
}
2019-05-02 09:10:29 +02:00
this . renderScaledAsciiString ( " - " + this . quoteGuy , this . guiLeft + 60 , this . guiTop + 93 + quoteSize * 8 , 0 , false , this . getLargeFontSize ( ) ) ;
2016-11-17 16:25:47 +01:00
}
2016-11-12 15:09:30 +01:00
}
2016-11-10 23:37:40 +01:00
@Override
2019-05-02 09:10:29 +02:00
public void addOrModifyItemRenderer ( ItemStack renderedStack , int x , int y , float scale , boolean shouldTryTransfer ) {
2016-11-10 23:37:40 +01:00
}
2016-11-10 19:50:01 +01:00
}