Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gtnh logo with wiki button and bug report button in the pause menu #1041

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Add your dependencies here

dependencies {
api("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.41:dev")
api("com.github.GTNewHorizons:GT5-Unofficial:5.09.50.43:dev")
api("com.github.GTNewHorizons:Yamcl:0.6.0:dev")
api("com.github.GTNewHorizons:Baubles:1.0.4:dev")

implementation("com.github.GTNewHorizons:GTNHLib:0.5.15:dev")

compileOnly("com.github.GTNewHorizons:AkashicTome:1.1.7:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:Avaritia:1.54:dev") { transitive = false }
compileOnly("com.github.GTNewHorizons:twilightforest:2.6.34:dev") { transitive = false }
Expand Down
88 changes: 88 additions & 0 deletions src/main/java/com/dreammaster/client/util/GTNHPauseScreen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package com.dreammaster.client.util;

import java.net.URI;

import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiIngameMenu;
import net.minecraft.client.renderer.OpenGlHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraftforge.client.event.GuiScreenEvent;

import org.lwjgl.opengl.GL11;

import com.dreammaster.main.MainRegistry;
import com.gtnewhorizon.gtnhlib.util.FilesUtil;

import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class GTNHPauseScreen {

private static final ResourceLocation GTNH_LOGO = new ResourceLocation(
"dreamcraft",
"textures/icon/GTNH_256x256.png");
private static final int BUG_BUTTON_ID = -161518;
private static final int WIKI_BUTTON_ID = -8998561;

@SuppressWarnings("unchecked")
@SubscribeEvent
public void onInitGui(GuiScreenEvent.InitGuiEvent.Post event) {
if (!(event.gui instanceof GuiIngameMenu)) return;
final int buttonWidth = 80;
event.buttonList.add(
new GuiButton(
BUG_BUTTON_ID,
event.gui.width / 2 - 100 - 10 - buttonWidth,
event.gui.height / 4 + 24 - 16,
buttonWidth,
20,
StatCollector.translateToLocal("dreamcraft.pausemenu.bug")));
event.buttonList.add(
new GuiButton(
WIKI_BUTTON_ID,
event.gui.width / 2 - 100 - 10 - buttonWidth,
event.gui.height / 4 + 24 - 16 + 24,
buttonWidth,
20,
StatCollector.translateToLocal("dreamcraft.pausemenu.wiki")));
// TODO add credits page
}

@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onDrawScreen(GuiScreenEvent.DrawScreenEvent.Post event) {
if (!(event.gui instanceof GuiIngameMenu)) return;
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 1, 0);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
event.gui.mc.getTextureManager().bindTexture(GTNH_LOGO);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
final int drawX = event.gui.width / 2 - 100 - 10 - 80 + (80 - 64) / 2;
final int drawY = event.gui.height / 4 + 24 - 16 - 64;
Gui.func_146110_a(drawX, drawY, 0f, 0f, 64, 64, 64f, 64f);
GL11.glPopMatrix();
}

@SubscribeEvent
public void onActionPerformed(GuiScreenEvent.ActionPerformedEvent.Post event) {
if (!(event.gui instanceof GuiIngameMenu)) return;
if (event.button.id == BUG_BUTTON_ID) {
gtnh$openUrl("https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues");
} else if (event.button.id == WIKI_BUTTON_ID) {
gtnh$openUrl("https://wiki.gtnewhorizons.com/wiki/Main_Page");
}
}

private static void gtnh$openUrl(String address) {
try {
final URI uri = new URI(address);
FilesUtil.openUri(uri);
} catch (Throwable throwable) {
MainRegistry.Logger.error("Couldn't open link", throwable);
}
}

}
7 changes: 7 additions & 0 deletions src/main/java/com/dreammaster/config/CoreModConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public CoreModConfig(File pConfigBaseDirectory, String pModCollectionDirectory,

public boolean OreDictItems_Enabled;
public static boolean ModLoginMessage_Enabled;
public boolean gtnhPauseMenuButtons;
public static String ModPackVersion = Refstrings.MODPACKPACK_VERSION;

public boolean ModHazardousItems_Enabled;
Expand Down Expand Up @@ -57,6 +58,7 @@ public CoreModConfig(File pConfigBaseDirectory, String pModCollectionDirectory,
@Override
protected void PreInit() {
ModLoginMessage_Enabled = true;
gtnhPauseMenuButtons = true;
ModDebugVersionDisplay_Enabled = true;
ModHazardousItems_Enabled = false;
ModCustomToolTips_Enabled = false;
Expand Down Expand Up @@ -99,6 +101,11 @@ protected void Init() {
"Modules",
ModLoginMessage_Enabled,
"Set to true to show login message with modpack version");
gtnhPauseMenuButtons = _mainConfig.getBoolean(
"GTNH Pause menu buttons",
"Modules",
gtnhPauseMenuButtons,
"Set to true to display GTNH buttons in the pause menu");
ModPackVersion = _mainConfig.getString("ModPackVersion", "Modules", ModPackVersion, "Version of the Modpack");
ModDebugVersionDisplay_Enabled = _mainConfig.getBoolean(
"DebugVersionDisplay",
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/dreammaster/main/MainRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import com.dreammaster.baubles.OvenGlove;
import com.dreammaster.baubles.WitherProtectionRing;
import com.dreammaster.block.BlockList;
import com.dreammaster.client.util.GTNHPauseScreen;
import com.dreammaster.command.AllPurposeDebugCommand;
import com.dreammaster.command.CustomDropsCommand;
import com.dreammaster.command.CustomFuelsCommand;
Expand Down Expand Up @@ -112,6 +113,7 @@
name = Refstrings.NAME,
version = Refstrings.VERSION,
dependencies = "required-before:gregtech;" + "required-after:Forge@[10.13.2.1291,);"
+ "required-after:gtnhlib@[0.5.15,);"
+ "required-after:YAMCore@[0.5.76,);"
+ "required-after:Baubles@[1.0.1.10,);"
+ "after:EnderIO;"
Expand Down Expand Up @@ -368,6 +370,10 @@ public void load(FMLInitializationEvent event) {

BWGlassAdder.registerGlasses();

if (CoreConfig.gtnhPauseMenuButtons && event.getSide().isClient()) {
MinecraftForge.EVENT_BUS.register(new GTNHPauseScreen());
}

}

public static Block _mBlockBabyChest = new BlockBabyChest();
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/assets/dreamcraft/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -1748,4 +1748,7 @@ dreamcraft.welcome.click_wiki=Click to open the wiki!
dreamcraft.welcome.report_bug=Please report bugs on Github :
dreamcraft.welcome.click_github=Click to open the Github!
dreamcraft.welcome.visitdiscord=Visit our discord at
dreamcraft.welcome.click_discord=Click to open discord!
dreamcraft.welcome.click_discord=Click to open discord!

dreamcraft.pausemenu.bug=Report a Bug
dreamcraft.pausemenu.wiki=Open the Wiki
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.