mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
'fix' rest of guis mostly
This commit is contained in:
1 parent
bc2e44ae9a
commit
e7f953881e
24 files changed
+468
-420
No files matched your search
@@ -66,17 +66,13 @@ public abstract class LexiconPage {
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onClosed(IGuiLexiconEntry gui) {}
|
||||
|
||||
/**
|
||||
* Called when a button is pressed, equivalent to GuiScreen.actionPerformed.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) {}
|
||||
|
||||
/**
|
||||
* Called when a key is pressed.
|
||||
*/
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onKeyPressed(char c, int key) {}
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when {@link LexiconEntry#setLexiconPages(LexiconPage...)} is called.
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.SlotItemHandler;
|
||||
@@ -33,9 +34,9 @@ public class GuiFlowerBag extends GuiContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@@ -48,7 +49,7 @@ public class GuiFlowerBag extends GuiContainer {
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
@@ -59,7 +60,8 @@ public class GuiFlowerBag extends GuiContainer {
|
||||
if(slot instanceof SlotItemHandler) {
|
||||
SlotItemHandler slotf = (SlotItemHandler) slot;
|
||||
if(!slotf.getHasStack()) {
|
||||
ItemStack stack = new ItemStack(ModBlocks.flower, 1, slotf.getSlotIndex()); // index matches colors
|
||||
EnumDyeColor color = EnumDyeColor.byId(slotf.getSlotIndex());
|
||||
ItemStack stack = new ItemStack(ModBlocks.getFlower(color));
|
||||
int x = guiLeft + slotf.xPos;
|
||||
int y = guiTop + slotf.yPos;
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
@@ -26,15 +26,15 @@ public class GuiBaubleBox extends GuiContainer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
this.drawDefaultBackground();
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
this.renderHoveredToolTip(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
|
||||
@@ -11,25 +11,20 @@
|
||||
package vazkii.botania.client.gui.lexicon;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.audio.PositionedSoundRecord;
|
||||
import net.minecraft.client.audio.SimpleSound;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.gui.ScaledResolution;
|
||||
import net.minecraft.client.gui.advancements.GuiScreenAdvancements;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.InputMappings;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ChatAllowedCharacters;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.SharedConstants;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.BotaniaTutorialStartEvent;
|
||||
@@ -39,7 +34,6 @@ import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.PersistentVariableHelper;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.core.proxy.ClientProxy;
|
||||
import vazkii.botania.client.gui.GuiBotaniaConfig;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonAchievement;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonBookmark;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonCategory;
|
||||
@@ -60,9 +54,6 @@ import vazkii.botania.common.lexicon.LexiconData;
|
||||
import vazkii.botania.common.lexicon.page.PageText;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.Month;
|
||||
import java.util.ArrayDeque;
|
||||
@@ -83,14 +74,17 @@ public class GuiLexicon extends GuiScreen {
|
||||
|
||||
private static final String TAG_TYPE = "type";
|
||||
|
||||
private static final int[] KONAMI_CODE = { 200, 200, 208, 208, 203, 205, 203, 205, 48, 30 };
|
||||
private static final int[] KONAMI_CODE = {
|
||||
GLFW.GLFW_KEY_UP, GLFW.GLFW_KEY_UP, GLFW.GLFW_KEY_DOWN, GLFW.GLFW_KEY_DOWN,
|
||||
GLFW.GLFW_KEY_LEFT, GLFW.GLFW_KEY_RIGHT, GLFW.GLFW_KEY_LEFT, GLFW.GLFW_KEY_RIGHT,
|
||||
GLFW.GLFW_KEY_B, GLFW.GLFW_KEY_A
|
||||
};
|
||||
|
||||
public static final int BOOKMARK_START = 1337;
|
||||
public static final int NOTES_BUTTON_ID = 1336; // random button tho
|
||||
public static final int MAX_BOOKMARK_COUNT = 8;
|
||||
public static final List<GuiLexicon> bookmarks = new ArrayList<>();
|
||||
public static final List<String> bookmarkKeys = new ArrayList<>();
|
||||
private boolean bookmarksNeedPopulation = false;
|
||||
public boolean bookmarksNeedPopulation = false;
|
||||
|
||||
public static final Queue<LexiconEntry> tutorial = new ArrayDeque<>();
|
||||
|
||||
@@ -104,18 +98,16 @@ public class GuiLexicon extends GuiScreen {
|
||||
private static final int TUTORIAL_ARROW_WIDTH = 10;
|
||||
private static final int TUTORIAL_ARROW_HEIGHT = 12;
|
||||
boolean hasTutorialArrow;
|
||||
int tutorialArrowX, tutorialArrowY;
|
||||
int konamiIndex;
|
||||
int konamiTime;
|
||||
private int tutorialArrowX, tutorialArrowY;
|
||||
private int konamiIndex;
|
||||
private int konamiTime;
|
||||
|
||||
private static final int NOTE_TWEEN_TIME = 5;
|
||||
public static boolean notesEnabled;
|
||||
static int notesMoveTime;
|
||||
private static int notesMoveTime;
|
||||
public String note = "";
|
||||
public String categoryHighlight = "";
|
||||
|
||||
List<LexiconCategory> allCategories;
|
||||
|
||||
String title;
|
||||
final int guiWidth = 146;
|
||||
final int guiHeight = 180;
|
||||
@@ -152,7 +144,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
mc.mainWindow.updateSize();
|
||||
}
|
||||
|
||||
allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
|
||||
List<LexiconCategory> allCategories = new ArrayList<>(BotaniaAPI.getAllCategories());
|
||||
Collections.sort(allCategories);
|
||||
|
||||
lastTime = ClientTickHandler.ticksInGame;
|
||||
@@ -206,7 +198,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
buttons.add(new GuiButtonDoot(-99, left + 100, top + 12));
|
||||
}
|
||||
|
||||
buttons.add(new GuiButtonNotes(this, NOTES_BUTTON_ID, left - 4, top - 4));
|
||||
buttons.add(new GuiButtonNotes(this, 1336, left - 4, top - 4));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -404,98 +396,6 @@ public class GuiLexicon extends GuiScreen {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id >= BOOKMARK_START) {
|
||||
if(par1GuiButton.id >= BOOKMARK_START + MAX_BOOKMARK_COUNT) {
|
||||
if(par1GuiButton instanceof GuiButtonChallengeInfo)
|
||||
mc.displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, this));
|
||||
else mc.displayGuiScreen(new GuiLexiconHistory());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
} else handleBookmark(par1GuiButton);
|
||||
} else if(par1GuiButton instanceof GuiButtonCategory) {
|
||||
LexiconCategory category = ((GuiButtonCategory) par1GuiButton).getCategory();
|
||||
|
||||
mc.displayGuiScreen(new GuiLexiconIndex(category));
|
||||
ClientTickHandler.notifyPageChange();
|
||||
} else switch(par1GuiButton.id) {
|
||||
case -1 :
|
||||
mc.displayGuiScreen(new GuiBotaniaConfig(this));
|
||||
break;
|
||||
case -2 :
|
||||
if(mc.player != null) {
|
||||
GuiScreenAdvancements gui = new GuiScreenAdvancements(this.mc.player.connection.getAdvancementManager());
|
||||
this.mc.displayGuiScreen(gui);
|
||||
ResourceLocation tab = new ResourceLocation(LibMisc.MOD_ID, "main/root");
|
||||
gui.setSelectedTab(mc.player.connection.getAdvancementManager().getAdvancementList().getAdvancement(tab));
|
||||
}
|
||||
break;
|
||||
case -3 :
|
||||
mc.displayGuiScreen(new GuiLexiconChallengesList());
|
||||
break;
|
||||
case -4:
|
||||
int maxAllowed = getMaxAllowedScale();
|
||||
if(PersistentVariableHelper.lexiconGuiScale >= maxAllowed)
|
||||
PersistentVariableHelper.lexiconGuiScale = 2;
|
||||
else PersistentVariableHelper.lexiconGuiScale++;
|
||||
|
||||
PersistentVariableHelper.saveSafe();
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
break;
|
||||
case -98 :
|
||||
if(isShiftKeyDown()) {
|
||||
try {
|
||||
if(Desktop.isDesktopSupported())
|
||||
Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PersistentVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION;
|
||||
PersistentVariableHelper.saveSafe();
|
||||
par1GuiButton.visible = false;
|
||||
par1GuiButton.enabled = false;
|
||||
}
|
||||
|
||||
break;
|
||||
case NOTES_BUTTON_ID :
|
||||
notesEnabled = !notesEnabled;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void handleBookmark(GuiButton par1GuiButton) {
|
||||
boolean modified = false;
|
||||
int i = par1GuiButton.id - BOOKMARK_START;
|
||||
String key = getNotesKey();
|
||||
if(i == bookmarks.size()) {
|
||||
if(!bookmarkKeys.contains(key)) {
|
||||
bookmarks.add(copy());
|
||||
bookmarkKeys.add(key);
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
if(isShiftKeyDown()) {
|
||||
bookmarks.remove(i);
|
||||
bookmarkKeys.remove(i);
|
||||
|
||||
modified = true;
|
||||
} else {
|
||||
GuiLexicon bookmark = bookmarks.get(i).copy();
|
||||
if(!bookmark.getTitle().equals(getTitle())) {
|
||||
Minecraft.getInstance().displayGuiScreen(bookmark);
|
||||
if(bookmark instanceof IParented)
|
||||
((IParented) bookmark).setParent(this);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bookmarksNeedPopulation = true;
|
||||
if(modified)
|
||||
PersistentVariableHelper.saveSafe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesGuiPauseGame() {
|
||||
return false;
|
||||
@@ -508,7 +408,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
return fontRenderer.getStringWidth(b) + 15;
|
||||
}
|
||||
|
||||
String getTitle() {
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -532,7 +432,7 @@ public class GuiLexicon extends GuiScreen {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int getMaxAllowedScale() {
|
||||
public static int getMaxAllowedScale() {
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
return mc.mainWindow.getScaleFactor(0);
|
||||
}
|
||||
@@ -626,32 +526,37 @@ public class GuiLexicon extends GuiScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyPressed(int keyCode, int scanCode, int mods) {
|
||||
handleNoteKey(par1, par2);
|
||||
public boolean charTyped(char codePoint, int mods) {
|
||||
return handleNoteChar(codePoint) || super.charTyped(codePoint, mods);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
if(!notesEnabled && closeScreenOnInvKey() && mc.gameSettings.keyBindInventory.isActiveAndMatches(InputMappings.getInputByCode(keyCode, scanCode))) {
|
||||
mc.displayGuiScreen(null);
|
||||
mc.mouseHelper.grabMouse();
|
||||
return true;
|
||||
}
|
||||
|
||||
if(konamiTime == 0 && par2 == KONAMI_CODE[konamiIndex]) {
|
||||
if(konamiTime == 0 && keyCode == KONAMI_CODE[konamiIndex]) {
|
||||
konamiIndex++;
|
||||
if(konamiIndex >= KONAMI_CODE.length) {
|
||||
mc.getSoundHandler().play(SimpleSound.master(ModSounds.way, 1.0F));
|
||||
konamiIndex = 0;
|
||||
konamiTime = 240;
|
||||
}
|
||||
return true;
|
||||
} else konamiIndex = 0;
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
return super.keyPressed(keyCode, scanCode, mods);
|
||||
}
|
||||
|
||||
public void handleNoteKey(char par1, int par2) {
|
||||
private boolean handleNoteChar(char codePoint) {
|
||||
if(notesEnabled) {
|
||||
Keyboard.enableRepeatEvents(true);
|
||||
mc.keyboardListener.enableRepeatEvents(true);
|
||||
boolean changed = false;
|
||||
|
||||
if(par2 == 14 && note.length() > 0) {
|
||||
if(codePoint == 8 && note.length() > 0) { // backspace
|
||||
if(isCtrlKeyDown())
|
||||
note = "";
|
||||
else {
|
||||
@@ -662,16 +567,18 @@ public class GuiLexicon extends GuiScreen {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if((ChatAllowedCharacters.isAllowedCharacter(par1) || par2 == 28) && note.length() < 250) {
|
||||
note += par2 == 28 ? "<br>" : par1;
|
||||
if((SharedConstants.isAllowedCharacter(codePoint) || codePoint == 0xA) && note.length() < 250) {
|
||||
note += codePoint == 0xA ? "<br>" : codePoint;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if(changed) {
|
||||
notes.put(getNotesKey(), note);
|
||||
PersistentVariableHelper.saveSafe();
|
||||
return true;
|
||||
}
|
||||
} else Keyboard.enableRepeatEvents(false);
|
||||
} else mc.keyboardListener.enableRepeatEvents(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static GuiLexicon create(NBTTagCompound cmp) {
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import vazkii.botania.client.challenge.Challenge;
|
||||
import vazkii.botania.client.challenge.ModChallenges;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
@@ -50,8 +51,23 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented {
|
||||
super.onInitGui();
|
||||
setTitle();
|
||||
|
||||
buttons.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttons.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, ""));
|
||||
buttons.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
buttons.add(completeButton = new GuiButton(13, left + 20, top + guiHeight - 35, guiWidth - 40, 20, "") {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
challenge.complete = !challenge.complete;
|
||||
setCompleteButtonTitle();
|
||||
PersistentVariableHelper.saveSafe();
|
||||
}
|
||||
});
|
||||
setCompleteButtonTitle();
|
||||
}
|
||||
|
||||
@@ -76,15 +92,17 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) throws IOException {
|
||||
if(par2 == 14 && !notesEnabled) // Backspace
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled) {
|
||||
back();
|
||||
else if(par2 == 199) { // Home
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
return true;
|
||||
}
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
return super.keyPressed(keyCode, scanCode, mods);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -96,21 +114,6 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented {
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id >= BOOKMARK_START)
|
||||
super.actionPerformed(par1GuiButton);
|
||||
else if(par1GuiButton.id == 12) {
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
} else if(par1GuiButton.id == 13) {
|
||||
challenge.complete = !challenge.complete;
|
||||
setCompleteButtonTitle();
|
||||
PersistentVariableHelper.saveSafe();
|
||||
} else if(par1GuiButton.id == NOTES_BUTTON_ID)
|
||||
notesEnabled = !notesEnabled;
|
||||
}
|
||||
|
||||
private void setCompleteButtonTitle() {
|
||||
completeButton.displayString = I18n.format(challenge.complete ? "botaniamisc.markNotCompleted" : "botaniamisc.markCompleted");
|
||||
}
|
||||
@@ -133,7 +136,7 @@ public class GuiLexiconChallenge extends GuiLexicon implements IParented {
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ package vazkii.botania.client.gui.lexicon;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import vazkii.botania.client.challenge.Challenge;
|
||||
import vazkii.botania.client.challenge.EnumChallengeLevel;
|
||||
import vazkii.botania.client.challenge.ModChallenges;
|
||||
@@ -38,7 +39,14 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
|
||||
super.onInitGui();
|
||||
title = I18n.format("botaniamisc.challenges");
|
||||
|
||||
buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttons.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
|
||||
int perline = 6;
|
||||
int i = 13;
|
||||
@@ -46,7 +54,7 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
|
||||
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) {
|
||||
int j = 0;
|
||||
for(Challenge c : ModChallenges.challenges.get(level)) {
|
||||
buttonList.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c));
|
||||
buttons.add(new GuiButtonChallengeIcon(i, left + 20 + j % perline * 18, y + j / perline * 17, c, this));
|
||||
i++;
|
||||
j++;
|
||||
}
|
||||
@@ -58,8 +66,6 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
|
||||
public void drawScreenAfterScale(int xCoord, int yCoord, float newPartialTicks) {
|
||||
super.drawScreenAfterScale(xCoord, yCoord, newPartialTicks);
|
||||
|
||||
boolean unicode = fontRenderer.getUnicodeFlag();
|
||||
fontRenderer.setUnicodeFlag(true);
|
||||
for(EnumChallengeLevel level : EnumChallengeLevel.class.getEnumConstants()) {
|
||||
List<Challenge> list = ModChallenges.challenges.get(level);
|
||||
int complete = 0;
|
||||
@@ -69,47 +75,35 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
|
||||
|
||||
fontRenderer.drawString(TextFormatting.BOLD + I18n.format(level.getName()) + TextFormatting.RESET + " (" + complete + "/" + list.size() + ")", left + 20, top + 11 + level.ordinal() * 44, 0);
|
||||
}
|
||||
fontRenderer.setUnicodeFlag(unicode);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) throws IOException {
|
||||
if(par2 == 14 && !notesEnabled) // Backspace
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled) {
|
||||
back();
|
||||
else if(par2 == 199) { // Home
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
return true;
|
||||
}
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
return super.keyPressed(keyCode, scanCode, mods);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
|
||||
if(par3 == 1)
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int mods) {
|
||||
if(mods == GLFW.GLFW_MOUSE_BUTTON_RIGHT) {
|
||||
back();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id >= BOOKMARK_START)
|
||||
super.actionPerformed(par1GuiButton);
|
||||
else if(par1GuiButton.id == 12) {
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
} else if(par1GuiButton instanceof GuiButtonChallengeIcon) {
|
||||
GuiButtonChallengeIcon cbutton = (GuiButtonChallengeIcon) par1GuiButton;
|
||||
mc.displayGuiScreen(new GuiLexiconChallenge(this, cbutton.challenge));
|
||||
} else if(par1GuiButton.id == NOTES_BUTTON_ID)
|
||||
notesEnabled = !notesEnabled;
|
||||
return true;
|
||||
}
|
||||
return super.mouseClicked(mouseX, mouseY, mods);
|
||||
}
|
||||
|
||||
private void back() {
|
||||
if(backButton.enabled) {
|
||||
actionPerformed(backButton);
|
||||
backButton.playPressSound(mc.getSoundHandler());
|
||||
backButton.onClick(backButton.x, backButton.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +118,7 @@ public class GuiLexiconChallengesList extends GuiLexicon implements IParented {
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ import vazkii.botania.client.gui.lexicon.button.GuiButtonShare;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonViewOnline;
|
||||
|
||||
import java.awt.Desktop;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
@@ -76,12 +75,63 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
public void onInitGui() {
|
||||
super.onInitGui();
|
||||
|
||||
buttons.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttons.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false));
|
||||
buttons.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true));
|
||||
buttons.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2));
|
||||
buttons.add(backButton = new GuiButtonBackWithShift(0, left + guiWidth / 2 - 8, top + guiHeight + 2) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
|
||||
mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
buttons.add(leftButton = new GuiButtonPage(1, left, top + guiHeight - 10, false) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
|
||||
page--;
|
||||
entry.pages.get(page).onOpened(GuiLexiconEntry.this);
|
||||
|
||||
ClientTickHandler.notifyPageChange();
|
||||
updatePageButtons();
|
||||
}
|
||||
});
|
||||
buttons.add(rightButton = new GuiButtonPage(2, left + guiWidth - 18, top + guiHeight - 10, true) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
entry.pages.get(page).onClosed(GuiLexiconEntry.this);
|
||||
page++;
|
||||
entry.pages.get(page).onOpened(GuiLexiconEntry.this);
|
||||
|
||||
ClientTickHandler.notifyPageChange();
|
||||
updatePageButtons();
|
||||
}
|
||||
});
|
||||
buttons.add(new GuiButtonShare(3, left + guiWidth - 6, top - 2) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String cmd = "/botania-share " + entry.getUnlocalizedName();
|
||||
|
||||
mc.ingameGUI.getChatGUI().addToSentMessages(cmd);
|
||||
mc.player.sendChatMessage(cmd);
|
||||
}
|
||||
});
|
||||
if(entry.getWebLink() != null)
|
||||
buttons.add(new GuiButtonViewOnline(4, left - 8, top + 12));
|
||||
buttons.add(new GuiButtonViewOnline(4, left - 8, top + 12) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
try {
|
||||
if(Desktop.isDesktopSupported())
|
||||
Desktop.getDesktop().browse(new URI(entry.getWebLink()));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(!GuiLexicon.isValidLexiconGui(this)) {
|
||||
currentOpenLexicon = new GuiLexicon();
|
||||
@@ -113,7 +163,7 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
public String getTitle() {
|
||||
return String.format("%s " + TextFormatting.ITALIC + "(%s/%s)", title, page + 1, entry.pages.size());
|
||||
}
|
||||
|
||||
@@ -127,64 +177,12 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
LexiconPage currentPage = entry.pages.get(page);
|
||||
LexiconPage newPage;
|
||||
|
||||
if(par1GuiButton.id >= BOOKMARK_START)
|
||||
handleBookmark(par1GuiButton);
|
||||
else if(par1GuiButton.id == NOTES_BUTTON_ID)
|
||||
notesEnabled = !notesEnabled;
|
||||
else
|
||||
switch(par1GuiButton.id) {
|
||||
case 0 :
|
||||
currentPage.onClosed(this);
|
||||
mc.displayGuiScreen(GuiScreen.isShiftKeyDown() ? new GuiLexicon() : parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 1 :
|
||||
currentPage.onClosed(this);
|
||||
page--;
|
||||
newPage = entry.pages.get(page);
|
||||
newPage.onOpened(this);
|
||||
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 2 :
|
||||
currentPage.onClosed(this);
|
||||
page++;
|
||||
newPage = entry.pages.get(page);
|
||||
newPage.onOpened(this);
|
||||
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 3 :
|
||||
Minecraft mc = Minecraft.getInstance();
|
||||
String cmd = "/botania-share " + entry.getUnlocalizedName();
|
||||
|
||||
mc.ingameGUI.getChatGUI().addToSentMessages(cmd);
|
||||
mc.player.sendChatMessage(cmd);
|
||||
break;
|
||||
case 4 :
|
||||
try {
|
||||
if(Desktop.isDesktopSupported())
|
||||
Desktop.getDesktop().browse(new URI(entry.getWebLink()));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
updatePageButtons();
|
||||
currentPage.onActionPerformed(this, par1GuiButton);
|
||||
}
|
||||
|
||||
public GuiLexiconEntry setFirstEntry() {
|
||||
firstEntry = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void updatePageButtons() {
|
||||
private void updatePageButtons() {
|
||||
leftButton.enabled = page != 0;
|
||||
rightButton.enabled = page + 1 < entry.pages.size();
|
||||
if(firstEntry)
|
||||
@@ -309,46 +307,48 @@ public class GuiLexiconEntry extends GuiLexicon implements IGuiLexiconEntry, IPa
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) {
|
||||
handleNoteKey(par1, par2);
|
||||
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
LexiconPage page = entry.pages.get(this.page);
|
||||
page.onKeyPressed(par1, par2);
|
||||
if (page.keyPressed(keyCode, scanCode, mods)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(par2 == 1) {
|
||||
if(keyCode == GLFW.GLFW_KEY_ESCAPE) {
|
||||
mc.displayGuiScreen(null);
|
||||
mc.mouseHelper.grabMouse();
|
||||
} else if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up
|
||||
} else if(keyCode == GLFW.GLFW_KEY_LEFT || keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_PAGE_UP)
|
||||
prevPage();
|
||||
else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down
|
||||
else if(keyCode == GLFW.GLFW_KEY_RIGHT || keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_PAGE_DOWN)
|
||||
nextPage();
|
||||
if(par2 == 14 && !notesEnabled) // Backspace
|
||||
if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled)
|
||||
back();
|
||||
else if(par2 == 199) { // Home
|
||||
else if(keyCode == GLFW.GLFW_KEY_HOME) { // Home
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
|
||||
return super.keyPressed(keyCode, scanCode, mods);
|
||||
}
|
||||
|
||||
private void back() {
|
||||
if(backButton.enabled) {
|
||||
actionPerformed(backButton);
|
||||
backButton.playPressSound(mc.getSoundHandler());
|
||||
backButton.onClick(backButton.x, backButton.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if(rightButton.enabled) {
|
||||
actionPerformed(rightButton);
|
||||
rightButton.playPressSound(mc.getSoundHandler());
|
||||
rightButton.onClick(rightButton.x, rightButton.y);
|
||||
updateNote();
|
||||
}
|
||||
}
|
||||
|
||||
private void prevPage() {
|
||||
if(leftButton.enabled) {
|
||||
actionPerformed(leftButton);
|
||||
leftButton.playPressSound(mc.getSoundHandler());
|
||||
leftButton.onClick(leftButton.x, leftButton.y);
|
||||
updateNote();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import org.lwjgl.glfw.GLFW;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.lexicon.LexiconCategory;
|
||||
@@ -29,7 +30,6 @@ import vazkii.botania.client.gui.lexicon.button.GuiButtonInvisible;
|
||||
import vazkii.botania.client.gui.lexicon.button.GuiButtonPage;
|
||||
import vazkii.botania.common.lexicon.DogLexiconEntry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -41,7 +41,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
|
||||
LexiconCategory category;
|
||||
String title;
|
||||
private int page = 0;
|
||||
public int page = 0;
|
||||
|
||||
private int tutPage = -1;
|
||||
|
||||
@@ -71,7 +71,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
}
|
||||
|
||||
@Override
|
||||
String getTitle() {
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
@@ -96,9 +96,34 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
return;
|
||||
}
|
||||
|
||||
buttons.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2));
|
||||
buttons.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false));
|
||||
buttons.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true));
|
||||
buttons.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
buttons.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
page--;
|
||||
updatePageButtons();
|
||||
populateIndex();
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
buttons.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
page++;
|
||||
updatePageButtons();
|
||||
populateIndex();
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
});
|
||||
|
||||
searchField = new GuiTextField(15, fontRenderer, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10);
|
||||
searchField.setCanLoseFocus(false);
|
||||
@@ -134,7 +159,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
return true;
|
||||
|
||||
for(ItemStack stack : e.getDisplayedRecipes()) {
|
||||
String stackName = stack.getDisplayName().toLowerCase().trim();
|
||||
String stackName = stack.getDisplayName().getString().trim();
|
||||
if(stackName.contains(search))
|
||||
return true;
|
||||
}
|
||||
@@ -179,18 +204,12 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
drawTexturedModalRect(left + 134, top + guiHeight - 26, 86, 180, 12, 12);
|
||||
|
||||
if(entriesToDisplay.size() == 1) {
|
||||
boolean unicode = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(true);
|
||||
String s = I18n.format("botaniamisc.enterToView");
|
||||
mc.fontRenderer.drawString(s, left + guiWidth / 2 - mc.fontRenderer.getStringWidth(s) / 2, top + 30, 0x666666);
|
||||
mc.fontRenderer.setUnicodeFlag(unicode);
|
||||
}
|
||||
} else {
|
||||
boolean unicode = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(true);
|
||||
String s = I18n.format("botaniamisc.typeToSearch");
|
||||
mc.fontRenderer.drawString(s, left + 120 - mc.fontRenderer.getStringWidth(s), top + guiHeight - 18, 0x666666);
|
||||
mc.fontRenderer.setUnicodeFlag(unicode);
|
||||
}
|
||||
|
||||
float animationTime = 4F;
|
||||
@@ -220,8 +239,6 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
int x = currentButton.x;
|
||||
int y = currentButton.y;
|
||||
String s = I18n.format(currentEntry.getTagline());
|
||||
boolean unicode = mc.fontRenderer.getUnicodeFlag();
|
||||
mc.fontRenderer.setUnicodeFlag(true);
|
||||
int width = mc.fontRenderer.getStringWidth(s);
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
@@ -231,7 +248,6 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
Gui.drawRect(10, -32, width + 22, -2, 0x44000000);
|
||||
|
||||
drawBookmark(width / 2 + 16, -8, s, true, 0xFFFFFF, 180);
|
||||
mc.fontRenderer.setUnicodeFlag(unicode);
|
||||
|
||||
net.minecraft.client.renderer.RenderHelper.enableGUIStandardItemLighting();
|
||||
GlStateManager.enableRescaleNormal();
|
||||
@@ -271,7 +287,6 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
return;
|
||||
}
|
||||
|
||||
List<GuiButton> buttons = buttonList;
|
||||
for(GuiButton button : buttons) {
|
||||
int id = button.id;
|
||||
int index = id + page * 12;
|
||||
@@ -285,41 +300,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton) {
|
||||
if(par1GuiButton.id >= BOOKMARK_START)
|
||||
handleBookmark(par1GuiButton);
|
||||
else if(par1GuiButton.id == NOTES_BUTTON_ID)
|
||||
notesEnabled = !notesEnabled;
|
||||
else
|
||||
switch(par1GuiButton.id) {
|
||||
case 12 :
|
||||
mc.displayGuiScreen(parent);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 13 :
|
||||
page--;
|
||||
updatePageButtons();
|
||||
populateIndex();
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
case 14 :
|
||||
page++;
|
||||
updatePageButtons();
|
||||
populateIndex();
|
||||
ClientTickHandler.notifyPageChange();
|
||||
break;
|
||||
default :
|
||||
if(par1GuiButton instanceof GuiButtonInvisible && ((GuiButtonInvisible) par1GuiButton).dog)
|
||||
((GuiButtonInvisible) par1GuiButton).click();
|
||||
else {
|
||||
int index = par1GuiButton.id + page * 12;
|
||||
openEntry(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void openEntry(int index) {
|
||||
public void openEntry(int index) {
|
||||
if(index >= entriesToDisplay.size())
|
||||
return;
|
||||
|
||||
@@ -339,54 +320,54 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
parent = gui;
|
||||
}
|
||||
|
||||
private int fx = 0;
|
||||
private boolean swiped = false;
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int x, int y, int button, long time) {
|
||||
if(button == 0 && Math.abs(x - fx) > 100 && mc.gameSettings.touchscreen && !swiped) {
|
||||
double swipe = (x - fx) / Math.max(1, (double) time);
|
||||
if(swipe < 0.5) {
|
||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double dragX, double dragY) {
|
||||
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT && dragX > 100 && mc.gameSettings.touchscreen && !swiped) {
|
||||
// todo 1.13 correct these constants
|
||||
if(dragX < 0.5) {
|
||||
nextPage();
|
||||
swiped = true;
|
||||
} else if(swipe > 0.5) {
|
||||
} else if(dragY > 0.5) {
|
||||
prevPage();
|
||||
swiped = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int par1, int par2, int par3) throws IOException {
|
||||
super.mouseClicked(par1, par2, par3);
|
||||
|
||||
searchField.mouseClicked(par1, par2, par3);
|
||||
fx = par1;
|
||||
switch(par3) {
|
||||
case 1:
|
||||
back();
|
||||
break;
|
||||
case 3:
|
||||
nextPage();
|
||||
break;
|
||||
case 4:
|
||||
prevPage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput() throws IOException {
|
||||
super.handleMouseInput();
|
||||
|
||||
if(Mouse.getEventButton() == 0)
|
||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||
if(button == GLFW.GLFW_MOUSE_BUTTON_LEFT)
|
||||
swiped = false;
|
||||
|
||||
int w = Mouse.getEventDWheel();
|
||||
if (searchField.mouseClicked(mouseX, mouseY, button))
|
||||
return true;
|
||||
|
||||
switch(button) {
|
||||
case 1:
|
||||
back();
|
||||
return true;
|
||||
case 3:
|
||||
nextPage();
|
||||
return true;
|
||||
case 4:
|
||||
prevPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
return super.mouseClicked(mouseX, mouseY, button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean mouseScrolled(double w) {
|
||||
if(w < 0)
|
||||
nextPage();
|
||||
else if(w > 0)
|
||||
prevPage();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -395,55 +376,67 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char par1, int par2) throws IOException {
|
||||
if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up
|
||||
prevPage();
|
||||
else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down
|
||||
nextPage();
|
||||
else if(par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace
|
||||
back();
|
||||
else if(par2 == 199) { // Home
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
} else if(par2 == 28 && entriesToDisplay.size() == 1) // Enter
|
||||
openEntry(0);
|
||||
|
||||
public boolean charTyped(char codePoint, int mods) {
|
||||
if(!notesEnabled) {
|
||||
// todo 1.13 use focus system?
|
||||
String search = searchField.getText();
|
||||
searchField.textboxKeyTyped(par1, par2);
|
||||
searchField.charTyped(codePoint, mods);
|
||||
if(!searchField.getText().equalsIgnoreCase(search))
|
||||
updateAll();
|
||||
return true;
|
||||
}
|
||||
return super.charTyped(codePoint, mods);
|
||||
}
|
||||
|
||||
super.keyTyped(par1, par2);
|
||||
@Override
|
||||
public boolean keyPressed(int keyCode, int scanCode, int mods) {
|
||||
if(keyCode == GLFW.GLFW_KEY_LEFT || keyCode == GLFW.GLFW_KEY_UP || keyCode == GLFW.GLFW_KEY_PAGE_UP) {
|
||||
prevPage();
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_RIGHT || keyCode == GLFW.GLFW_KEY_DOWN || keyCode == GLFW.GLFW_KEY_PAGE_DOWN) {
|
||||
nextPage();
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_BACKSPACE && !notesEnabled && searchField.getText().isEmpty()) {
|
||||
back();
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_HOME) {
|
||||
mc.displayGuiScreen(new GuiLexicon());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
return true;
|
||||
} else if(keyCode == GLFW.GLFW_KEY_ENTER && entriesToDisplay.size() == 1) {
|
||||
openEntry(0);
|
||||
return true;
|
||||
} else {
|
||||
return super.keyPressed(keyCode, scanCode, mods);
|
||||
}
|
||||
}
|
||||
|
||||
private void back() {
|
||||
if(backButton.enabled) {
|
||||
actionPerformed(backButton);
|
||||
backButton.playPressSound(mc.getSoundHandler());
|
||||
backButton.onClick(backButton.x, backButton.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void nextPage() {
|
||||
if(rightButton.enabled) {
|
||||
actionPerformed(rightButton);
|
||||
rightButton.playPressSound(mc.getSoundHandler());
|
||||
rightButton.onClick(rightButton.x, rightButton.y);
|
||||
}
|
||||
}
|
||||
|
||||
private void prevPage() {
|
||||
if(leftButton.enabled) {
|
||||
actionPerformed(leftButton);
|
||||
leftButton.playPressSound(mc.getSoundHandler());
|
||||
leftButton.onClick(leftButton.x, leftButton.y);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(NBTTagCompound cmp) {
|
||||
super.serialize(cmp);
|
||||
cmp.setString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName());
|
||||
cmp.setInteger(TAG_PAGE, page);
|
||||
cmp.putString(TAG_CATEGORY, category == null ? "" : category.getUnlocalizedName());
|
||||
cmp.putInt(TAG_PAGE, page);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -457,7 +450,7 @@ public class GuiLexiconIndex extends GuiLexicon implements IParented {
|
||||
category = cat;
|
||||
break;
|
||||
}
|
||||
page = cmp.getInteger(TAG_PAGE);
|
||||
page = cmp.getInt(TAG_PAGE);
|
||||
setTitle();
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,14 @@
|
||||
package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.advancements.GuiScreenAdvancements;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -27,7 +30,18 @@ public class GuiButtonAchievement extends GuiButtonLexicon {
|
||||
super(id, x, y, 11, 11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if(Minecraft.getInstance().player != null) {
|
||||
GuiScreenAdvancements gui = new GuiScreenAdvancements(Minecraft.getInstance().player.connection.getAdvancementManager());
|
||||
Minecraft.getInstance().displayGuiScreen(gui);
|
||||
ResourceLocation tab = new ResourceLocation(LibMisc.MOD_ID, "main/root");
|
||||
gui.setSelectedTab(Minecraft.getInstance().player.connection.getAdvancementManager().getAdvancementList().getAdvancement(tab));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
|
||||
int k = getHoverState(hovered);
|
||||
|
||||
@@ -22,8 +22,8 @@ import java.util.List;
|
||||
|
||||
public class GuiButtonBack extends GuiButtonLexicon {
|
||||
|
||||
public GuiButtonBack(int par1, int par2, int par3) {
|
||||
super(par1, par2, par3, 18, 9, "");
|
||||
public GuiButtonBack(int id, int x, int y) {
|
||||
super(id, x, y, 18, 9, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.PersistentVariableHelper;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.IParented;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -19,6 +23,39 @@ public class GuiButtonBookmark extends GuiButtonLexicon {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
boolean modified = false;
|
||||
int i = id - GuiLexicon.BOOKMARK_START;
|
||||
String key = gui.getNotesKey();
|
||||
if(i == GuiLexicon.bookmarks.size()) {
|
||||
if(!GuiLexicon.bookmarkKeys.contains(key)) {
|
||||
GuiLexicon.bookmarks.add(gui.copy());
|
||||
GuiLexicon.bookmarkKeys.add(key);
|
||||
modified = true;
|
||||
}
|
||||
} else {
|
||||
if(GuiScreen.isShiftKeyDown()) {
|
||||
GuiLexicon.bookmarks.remove(i);
|
||||
GuiLexicon.bookmarkKeys.remove(i);
|
||||
|
||||
modified = true;
|
||||
} else {
|
||||
GuiLexicon bookmark = GuiLexicon.bookmarks.get(i).copy();
|
||||
if(!bookmark.getTitle().equals(gui.getTitle())) {
|
||||
Minecraft.getInstance().displayGuiScreen(bookmark);
|
||||
if(bookmark instanceof IParented)
|
||||
((IParented) bookmark).setParent(gui);
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gui.bookmarksNeedPopulation = true;
|
||||
if(modified)
|
||||
PersistentVariableHelper.saveSafe();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
gui.drawBookmark(x, y, displayString, false);
|
||||
|
||||
@@ -21,9 +21,11 @@ import org.lwjgl.opengl.ARBShaderObjects;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import vazkii.botania.api.internal.ShaderCallback;
|
||||
import vazkii.botania.api.lexicon.LexiconCategory;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.core.helper.ShaderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconIndex;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.core.handler.ConfigHandler;
|
||||
|
||||
@@ -72,9 +74,16 @@ public class GuiButtonCategory extends GuiButtonLexicon {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexiconIndex(category));
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mx, int my, float partialTicks) {
|
||||
boolean inside = mx >= x && my >= y && mx < x + width && my < y + height;
|
||||
boolean inside = isPressable(mx, my);
|
||||
if(inside)
|
||||
ticksHovered = Math.min(time, ticksHovered + gui.timeDelta);
|
||||
else ticksHovered = Math.max(0F, ticksHovered - gui.timeDelta);
|
||||
|
||||
@@ -16,6 +16,8 @@ import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.challenge.Challenge;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconChallenge;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -24,10 +26,18 @@ import java.util.List;
|
||||
public class GuiButtonChallengeIcon extends GuiButtonLexicon {
|
||||
|
||||
public final Challenge challenge;
|
||||
private final GuiLexicon owner;
|
||||
|
||||
public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge) {
|
||||
public GuiButtonChallengeIcon(int id, int x, int y, Challenge challenge, GuiLexicon owner) {
|
||||
super(id, x, y, 16, 16, "");
|
||||
this.challenge = challenge;
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexiconChallenge(owner, challenge));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,11 @@ package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconEntry;
|
||||
import vazkii.botania.common.lexicon.LexiconData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -28,6 +31,13 @@ public class GuiButtonChallengeInfo extends GuiButtonLexicon {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexiconEntry(LexiconData.challenges, gui));
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
gui.drawBookmark(x, y, displayString, false);
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconChallengesList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -27,6 +28,12 @@ public class GuiButtonChallenges extends GuiButtonLexicon {
|
||||
super(id, x, y, 11, 11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexiconChallengesList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
|
||||
|
||||
@@ -13,8 +13,10 @@ package vazkii.botania.client.gui.lexicon.button;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexiconHistory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.ArrayList;
|
||||
@@ -29,6 +31,13 @@ public class GuiButtonHistory extends GuiButtonLexicon {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexiconHistory());
|
||||
ClientTickHandler.notifyPageChange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
gui.drawBookmark(x, y, displayString, false);
|
||||
|
||||
@@ -43,10 +43,18 @@ public class GuiButtonInvisible extends GuiButtonLexicon {
|
||||
this.gui = gui;
|
||||
}
|
||||
|
||||
public void click() {
|
||||
enableDog = true;
|
||||
PersistentVariableHelper.dog = true;
|
||||
PersistentVariableHelper.saveSafe();
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if (dog) {
|
||||
enableDog = true;
|
||||
PersistentVariableHelper.dog = true;
|
||||
PersistentVariableHelper.saveSafe();
|
||||
} else {
|
||||
// todo 1.13 is this the right place? moved from GuiLexiconIndex.actionPerformed
|
||||
int index = id + gui.page * 12;
|
||||
gui.openEntry(index);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,6 +30,12 @@ public class GuiButtonNotes extends GuiButtonLexicon {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
GuiLexicon.notesEnabled = !GuiLexicon.notesEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int x, int y, float partialTicks) {
|
||||
hovered = x >= this.x && y >= this.y && x < this.x + width && y < this.y + height;
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.GuiBotaniaConfig;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@@ -27,6 +28,12 @@ public class GuiButtonOptions extends GuiButtonLexicon {
|
||||
super(id, x, y, 11, 11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiBotaniaConfig(lexicon));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
|
||||
|
||||
@@ -14,6 +14,7 @@ import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import vazkii.botania.client.core.handler.PersistentVariableHelper;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
|
||||
@@ -27,6 +28,18 @@ public class GuiButtonScaleChange extends GuiButtonLexicon {
|
||||
super(id, x, y, 11, 11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
int maxAllowed = GuiLexicon.getMaxAllowedScale();
|
||||
if(PersistentVariableHelper.lexiconGuiScale >= maxAllowed)
|
||||
PersistentVariableHelper.lexiconGuiScale = 2;
|
||||
else PersistentVariableHelper.lexiconGuiScale++;
|
||||
|
||||
PersistentVariableHelper.saveSafe();
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexicon());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
hovered = mouseX >= x && mouseY >= y && mouseX < x + width && mouseY < y + height;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
package vazkii.botania.client.gui.lexicon.button;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
@@ -18,8 +19,11 @@ import vazkii.botania.client.core.handler.ClientTickHandler;
|
||||
import vazkii.botania.client.core.handler.PersistentVariableHelper;
|
||||
import vazkii.botania.client.core.helper.RenderHelper;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
import vazkii.botania.common.lib.LibMisc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.awt.*;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,6 +33,24 @@ public class GuiButtonUpdateWarning extends GuiButtonLexicon {
|
||||
super(id, x, y, 11, 11, "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if(GuiScreen.isShiftKeyDown()) {
|
||||
try {
|
||||
if(Desktop.isDesktopSupported())
|
||||
Desktop.getDesktop().browse(new URI("http://botaniamod.net/changelog.php#" + PersistentVariableHelper.lastBotaniaVersion.replaceAll("\\.|\\s", "-")));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
PersistentVariableHelper.lastBotaniaVersion = LibMisc.VERSION;
|
||||
PersistentVariableHelper.saveSafe();
|
||||
this.visible = false;
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
if(!visible || !enabled)
|
||||
|
||||
@@ -29,7 +29,19 @@ public class PageGuide extends PageText {
|
||||
|
||||
@Override
|
||||
public void onOpened(IGuiLexiconEntry gui) {
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, I18n.format("botaniamisc.playVideo"));
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, I18n.format("botaniamisc.playVideo")) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if(Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI"));
|
||||
if(Math.random() < 0.01)
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
|
||||
} catch(IOException | URISyntaxException ignored) { }
|
||||
}
|
||||
}
|
||||
};
|
||||
gui.getButtonList().add(button);
|
||||
}
|
||||
|
||||
@@ -38,14 +50,4 @@ public class PageGuide extends PageText {
|
||||
gui.getButtonList().remove(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) {
|
||||
if(button == this.button && Desktop.isDesktopSupported())
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=rx0xyejC6fI"));
|
||||
if(Math.random() < 0.01)
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=dQw4w9WgXcQ"));
|
||||
} catch(IOException | URISyntaxException ignored) { }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -114,7 +114,16 @@ public class PageMultiblock extends LexiconPage {
|
||||
|
||||
@Override
|
||||
public void onOpened(IGuiLexiconEntry gui) {
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr());
|
||||
button = new GuiButton(101, gui.getLeft() + 30, gui.getTop() + gui.getHeight() - 50, gui.getWidth() - 60, 20, getButtonStr()) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if(MultiblockRenderHandler.currentMultiblock == set)
|
||||
MultiblockRenderHandler.setMultiblock(null);
|
||||
else MultiblockRenderHandler.setMultiblock(set);
|
||||
button.displayString = getButtonStr();
|
||||
}
|
||||
};
|
||||
gui.getButtonList().add(button);
|
||||
}
|
||||
|
||||
@@ -128,17 +137,6 @@ public class PageMultiblock extends LexiconPage {
|
||||
gui.getButtonList().remove(button);
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) {
|
||||
if(button == this.button) {
|
||||
if(MultiblockRenderHandler.currentMultiblock == set)
|
||||
MultiblockRenderHandler.setMultiblock(null);
|
||||
else MultiblockRenderHandler.setMultiblock(set);
|
||||
button.displayString = getButtonStr();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void updateScreen() {
|
||||
|
||||
@@ -12,12 +12,10 @@ package vazkii.botania.common.lexicon.page;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import vazkii.botania.api.internal.IGuiLexiconEntry;
|
||||
import vazkii.botania.client.gui.lexicon.GuiLexicon;
|
||||
|
||||
@@ -29,7 +27,7 @@ public class PageTutorial extends PageText {
|
||||
// Turn this on once we have an up to date video
|
||||
private static final boolean VIDEO_ENABLED = true;
|
||||
|
||||
GuiButton buttonText, buttonVideo;
|
||||
private GuiButton buttonText, buttonVideo;
|
||||
|
||||
public PageTutorial(String unlocalizedName) {
|
||||
super(unlocalizedName);
|
||||
@@ -37,9 +35,29 @@ public class PageTutorial extends PageText {
|
||||
|
||||
@Override
|
||||
public void onOpened(IGuiLexiconEntry gui) {
|
||||
buttonText = new GuiButton(101, gui.getLeft() + 20, gui.getTop() + gui.getHeight() - 40, 50, 20, I18n.translateToLocal("botaniamisc.tutorialText"));
|
||||
buttonText = new GuiButton(101, gui.getLeft() + 20, gui.getTop() + gui.getHeight() - 40, 50, 20, I18n.format("botaniamisc.tutorialText")) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
GuiLexicon.startTutorial();
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexicon());
|
||||
Minecraft.getInstance().player.sendMessage(new TextComponentTranslation("botaniamisc.tutorialStarted").setStyle(new Style().setColor(TextFormatting.GREEN)));
|
||||
}
|
||||
};
|
||||
if(VIDEO_ENABLED)
|
||||
buttonVideo = new GuiButton(101, gui.getLeft() + 75, gui.getTop() + gui.getHeight() - 40, 50, 20, I18n.translateToLocal("botaniamisc.tutorialVideo"));
|
||||
buttonVideo = new GuiButton(101, gui.getLeft() + 75, gui.getTop() + gui.getHeight() - 40, 50, 20, I18n.format("botaniamisc.tutorialVideo")) {
|
||||
@Override
|
||||
public void onClick(double mouseX, double mouseY) {
|
||||
super.onClick(mouseX, mouseY);
|
||||
if(Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=D75Aad-5QgQ"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
gui.getButtonList().add(buttonText);
|
||||
if(VIDEO_ENABLED)
|
||||
@@ -60,21 +78,4 @@ public class PageTutorial extends PageText {
|
||||
if(!VIDEO_ENABLED)
|
||||
PageText.renderText(buttonText.x + buttonText.width + 4, buttonText.y - 14, 65, 100, "botaniamisc.noVideo");
|
||||
}
|
||||
|
||||
@Override
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onActionPerformed(IGuiLexiconEntry gui, GuiButton button) {
|
||||
if(button == buttonText) {
|
||||
GuiLexicon.startTutorial();
|
||||
Minecraft.getInstance().displayGuiScreen(new GuiLexicon());
|
||||
Minecraft.getInstance().player.sendMessage(new TextComponentTranslation("botaniamisc.tutorialStarted").setStyle(new Style().setColor(TextFormatting.GREEN)));
|
||||
} else if(button == buttonVideo && Desktop.isDesktopSupported()) {
|
||||
try {
|
||||
Desktop.getDesktop().browse(new URI("https://www.youtube.com/watch?v=D75Aad-5QgQ"));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user