|
@@ -1,5 +1,7 @@
|
|
|
package com.blamejared.controlling.client.gui;
|
|
|
|
|
|
+import com.blamejared.controlling.Controlling;
|
|
|
+import com.mojang.blaze3d.platform.GlStateManager;
|
|
|
import net.minecraft.client.*;
|
|
|
import net.minecraft.client.gui.IGuiEventListener;
|
|
|
import net.minecraft.client.gui.screen.*;
|
|
@@ -12,6 +14,7 @@ import net.minecraft.util.Util;
|
|
|
import net.minecraftforge.api.distmarker.*;
|
|
|
import org.lwjgl.glfw.GLFW;
|
|
|
|
|
|
+import java.util.Random;
|
|
|
import java.util.function.Predicate;
|
|
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
@@ -32,9 +35,11 @@ public class GuiNewControls extends ControlsScreen {
|
|
|
private Button buttonConflicting;
|
|
|
private GuiCheckBox buttonKey;
|
|
|
private GuiCheckBox buttonCat;
|
|
|
-
|
|
|
+ private Button patreonButton;
|
|
|
private boolean confirmingReset = false;
|
|
|
|
|
|
+ private String name;
|
|
|
+
|
|
|
public GuiNewControls(Screen screen, GameSettings settings) {
|
|
|
super(screen, settings);
|
|
|
this.parentScreen = screen;
|
|
@@ -120,6 +125,37 @@ public class GuiNewControls extends ControlsScreen {
|
|
|
p_213126_1_.setMessage(I18n.format("options.sort") + ": " + sortOrder.getName());
|
|
|
filterKeys();
|
|
|
}));
|
|
|
+ name = Controlling.PATRON_LIST.stream().skip(Controlling.PATRON_LIST.isEmpty() ? 0 : new Random().nextInt(Controlling.PATRON_LIST.size())).findFirst().orElse("");
|
|
|
+ patreonButton = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24 - 24, 150 / 2, 20, "Patreon", p_onPress_1_ -> {
|
|
|
+ Util.getOSType().openURI("https://patreon.com/jaredlll08?s=controllingmod");
|
|
|
+ }) {
|
|
|
+ private boolean wasHovered;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void render(int p_render_1_, int p_render_2_, float p_render_3_) {
|
|
|
+ if(this.visible) {
|
|
|
+ this.isHovered = p_render_1_ >= this.x && p_render_2_ >= this.y && p_render_1_ < this.x + this.width && p_render_2_ < this.y + this.height;
|
|
|
+ if(this.wasHovered != this.isHovered()) {
|
|
|
+ if(this.isHovered()) {
|
|
|
+ if(this.isFocused()) {
|
|
|
+ this.nextNarration = Util.milliTime() + 200L;
|
|
|
+ } else {
|
|
|
+ this.nextNarration = Util.milliTime() + 750L;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.nextNarration = Long.MAX_VALUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(this.visible) {
|
|
|
+ this.renderButton(p_render_1_, p_render_2_, p_render_3_);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.narrate();
|
|
|
+ this.wasHovered = this.isHovered();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
lastSearch = "";
|
|
|
displayMode = DisplayMode.ALL;
|
|
|
searchType = SearchType.NAME;
|
|
@@ -201,7 +237,16 @@ public class GuiNewControls extends ControlsScreen {
|
|
|
}
|
|
|
|
|
|
String text = I18n.format("options.search");
|
|
|
+ GlStateManager.disableLighting();
|
|
|
font.drawString(text, this.width / 2 - (155 / 2) - (font.getStringWidth(text) / 2), this.height - 29 - 39, 16777215);
|
|
|
+ GlStateManager.enableLighting();
|
|
|
+
|
|
|
+ if(patreonButton.isHovered()) {
|
|
|
+ GlStateManager.disableLighting();
|
|
|
+ String str = "Join " + name + " and other patrons!";
|
|
|
+ renderTooltip(str, mouseX, mouseY);
|
|
|
+ GlStateManager.enableLighting();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public boolean mouseClicked(double mx, double my, int mb) {
|
|
@@ -260,7 +305,7 @@ public class GuiNewControls extends ControlsScreen {
|
|
|
public boolean keyPressed(int p_keyPressed_1_, int p_keyPressed_2_, int p_keyPressed_3_) {
|
|
|
if(!search.isFocused() && this.buttonId == null) {
|
|
|
if(hasControlDown()) {
|
|
|
- if(InputMappings.isKeyDown(Minecraft.getInstance().func_228018_at_().getHandle(), GLFW.GLFW_KEY_F)) {
|
|
|
+ if(InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_F)) {
|
|
|
search.setFocused2(true);
|
|
|
return true;
|
|
|
}
|