-
Notifications
You must be signed in to change notification settings - Fork 14
Add world conversion warning screen #210
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1a4c469
Add world conversion warning screen
SuperSoupr ef58365
unneeded
SuperSoupr d57c69d
bump dep and a little polish
SuperSoupr 13eeafc
Move event handler
SuperSoupr c6ff5da
Merge remote-tracking branch 'upstream/master' into wc-gui
SuperSoupr b0b8367
fix merge issues
SuperSoupr 3330fa2
Merge branch 'master' into wc-gui
FourIsTheNumber d016f3b
Merge remote-tracking branch 'upstream/master' into wc-gui
SuperSoupr b13845d
Add config & warning for when world conversion is disabled
SuperSoupr b37a841
bump forge gtnhlib dep
SuperSoupr a112f30
Clarify config & format conversion disabled message
SuperSoupr 7cee273
oops
SuperSoupr 59d5811
Merge branch 'master' into wc-gui
FourIsTheNumber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/main/java/com/fouristhenumber/utilitiesinexcess/compat/exu/ExtendedConfirmationGui.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.compat.exu; | ||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
||
| import net.minecraft.client.gui.GuiButton; | ||
| import net.minecraft.client.gui.GuiLabel; | ||
| import net.minecraft.client.gui.GuiOptionButton; | ||
| import net.minecraft.util.StatCollector; | ||
|
|
||
| import com.gtnewhorizon.gtnhlib.api.gui.GuiConfirmationWCW; | ||
|
|
||
| import cpw.mods.fml.common.StartupQuery; | ||
|
|
||
| @SuppressWarnings("unused") | ||
| public class ExtendedConfirmationGui extends GuiConfirmationWCW { | ||
|
|
||
| private final List<String> lines; | ||
| private final String warning; | ||
|
|
||
| public ExtendedConfirmationGui(StartupQuery query) { | ||
| super(query); | ||
| lines = new ArrayList<>( | ||
| Arrays.asList( | ||
| query.getText() | ||
| .split("\\\\n"))); | ||
| warning = lines.get(0); | ||
| } | ||
|
|
||
| @Override | ||
| public void initGui() { | ||
| boolean dwc = ExuWorldConversionWarning.doWorldConversion(); | ||
| this.buttonList.add( | ||
| new GuiOptionButton( | ||
| 0, | ||
| this.width / 2 - 155, | ||
| this.height - 58, | ||
| dwc ? StatCollector.translateToLocal("gui.yes") | ||
| : StatCollector.translateToLocal("uie.gui.text.continue"))); | ||
| this.buttonList.add( | ||
| new GuiOptionButton( | ||
| 1, | ||
| this.width / 2 - 155 + 160, | ||
| this.height - 58, | ||
| dwc ? StatCollector.translateToLocal("gui.no") | ||
| : StatCollector.translateToLocal("uie.gui.text.cancel"))); | ||
| } | ||
|
|
||
| private static byte colorTick = 0; | ||
|
|
||
| @Override | ||
| public void drawScreen(int mouseX, int mouseY, float partialTicks) { | ||
| this.drawDefaultBackground(); | ||
|
|
||
| colorTick++; | ||
|
|
||
| String color = Math.abs(colorTick % 16) >= 8 ? "§4§l" : "§c§l"; | ||
| lines.set(0, "§kABC§r " + color + warning + " §r§kCBA"); | ||
|
|
||
| int spaceAvailable = this.height - 58 - 20; | ||
| int spaceRequired = Math.min(spaceAvailable, 10 + 10 * lines.size()); | ||
|
|
||
| int offset = 10 + (spaceAvailable - spaceRequired) / 2; // vertically centered | ||
| for (String line : lines) { | ||
| if (offset >= spaceAvailable) { | ||
| this.drawCenteredString(this.fontRendererObj, "...", this.width / 2, offset, 0xFFFFFF); | ||
| break; | ||
| } else { | ||
| if (!line.isEmpty()) | ||
| this.drawCenteredString(this.fontRendererObj, line, this.width / 2, offset, 0xFFFFFF); | ||
| offset += 10; | ||
| } | ||
| } | ||
|
|
||
| for (GuiButton button : this.buttonList) { | ||
| button.drawButton(this.mc, mouseX, mouseY); | ||
| } | ||
|
|
||
| for (GuiLabel label : this.labelList) { | ||
| label.func_146159_a(this.mc, mouseX, mouseY); | ||
| } | ||
| } | ||
| } |
58 changes: 58 additions & 0 deletions
58
...main/java/com/fouristhenumber/utilitiesinexcess/compat/exu/ExuWorldConversionWarning.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.fouristhenumber.utilitiesinexcess.compat.exu; | ||
|
|
||
| import net.minecraft.util.StatCollector; | ||
|
|
||
| import com.fouristhenumber.utilitiesinexcess.compat.Mods; | ||
| import com.fouristhenumber.utilitiesinexcess.config.OtherConfig; | ||
| import com.gtnewhorizon.gtnhlib.api.gui.GuiConfirmationWCW; | ||
| import com.gtnewhorizon.gtnhlib.api.gui.IWorldConversionWarning; | ||
|
|
||
| import cpw.mods.fml.common.StartupQuery; | ||
| import cpw.mods.fml.common.event.FMLMissingMappingsEvent; | ||
| import cpw.mods.fml.relauncher.Side; | ||
| import cpw.mods.fml.relauncher.SideOnly; | ||
|
|
||
| public class ExuWorldConversionWarning implements IWorldConversionWarning { | ||
|
|
||
| public static boolean show = false; | ||
|
|
||
| @Override | ||
| public boolean shouldShow() { | ||
| return show; | ||
| } | ||
|
|
||
| @Override | ||
| public String getServerMessage() { | ||
| return doWorldConversion() ? StatCollector.translateToLocal("uie.world_conversion.warning_enabled.server") | ||
| : StatCollector.translateToLocal("uie.world_conversion.warning_disabled.server"); | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| @Override | ||
| public String getClientMessage() { | ||
| return doWorldConversion() ? StatCollector.translateToLocal("uie.world_conversion.warning_enabled.client") | ||
| : StatCollector.translateToLocal("uie.world_conversion.warning_disabled.client"); | ||
| } | ||
|
|
||
| @SideOnly(Side.CLIENT) | ||
| @Override | ||
| public GuiConfirmationWCW getGui(StartupQuery startupQuery) { | ||
| return new ExtendedConfirmationGui(startupQuery); | ||
| } | ||
|
|
||
| public static boolean doWorldConversion() { | ||
| return OtherConfig.enableWorldConversion && !Mods.ExtraUtilities.isLoaded() && Mods.Postea.isLoaded(); | ||
| } | ||
|
|
||
| public static void onMissingMapping(FMLMissingMappingsEvent event) { | ||
| if (!OtherConfig.enableWorldConversionWarning) return; | ||
| if (ExuWorldConversionWarning.show) return; | ||
|
|
||
| for (FMLMissingMappingsEvent.MissingMapping mapping : event.getAll()) { | ||
| if (mapping.name.startsWith("ExtraUtilities")) { | ||
| ExuWorldConversionWarning.show = true; | ||
| return; | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.