aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2022-03-02 12:47:17 +0800
committershedaniel <daniel@shedaniel.me>2022-03-02 12:47:17 +0800
commit523550c7b255ec92a398a58b6051ca47b20049a4 (patch)
tree1c34ce31e1d0365d15ddf572a1547901ec5c39ba /runtime
parentbb3d8036bbed702a731126656a868f751d31a2e2 (diff)
downloadRoughlyEnoughItems-523550c7b255ec92a398a58b6051ca47b20049a4.tar.gz
RoughlyEnoughItems-523550c7b255ec92a398a58b6051ca47b20049a4.tar.bz2
RoughlyEnoughItems-523550c7b255ec92a398a58b6051ca47b20049a4.zip
Remove config button tooltip
Diffstat (limited to 'runtime')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java35
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EmptyMenuEntry.java58
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java70
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java2
4 files changed, 144 insertions, 21 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
index 1eb87a6ce..a34423cb0 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/ScreenOverlayImpl.java
@@ -67,9 +67,7 @@ import me.shedaniel.rei.impl.client.gui.craftable.CraftableFilter;
import me.shedaniel.rei.impl.client.gui.dragging.CurrentDraggingStack;
import me.shedaniel.rei.impl.client.gui.modules.Menu;
import me.shedaniel.rei.impl.client.gui.modules.MenuEntry;
-import me.shedaniel.rei.impl.client.gui.modules.entries.SeparatorMenuEntry;
-import me.shedaniel.rei.impl.client.gui.modules.entries.SubMenuEntry;
-import me.shedaniel.rei.impl.client.gui.modules.entries.ToggleMenuEntry;
+import me.shedaniel.rei.impl.client.gui.modules.entries.*;
import me.shedaniel.rei.impl.client.gui.widget.*;
import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField;
import me.shedaniel.rei.impl.common.util.Weather;
@@ -330,23 +328,7 @@ public class ScreenOverlayImpl extends ScreenOverlay {
}
})
.focusable(false)
- .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y))
- .tooltipSupplier(button -> {
- List<Component> tooltips = new ArrayList<>();
- tooltips.add(new TranslatableComponent("text.rei.config_tooltip"));
- tooltips.add(new ImmutableTextComponent(" "));
- if (!ClientHelper.getInstance().isCheating())
- tooltips.add(new TranslatableComponent("text.rei.cheating_disabled"));
- else if (!ClientHelperImpl.getInstance().hasOperatorPermission()) {
- if (minecraft.gameMode.hasInfiniteItems())
- tooltips.add(new TranslatableComponent("text.rei.cheating_limited_creative_enabled"));
- else tooltips.add(new TranslatableComponent("text.rei.cheating_enabled_no_perms"));
- } else if (ClientHelperImpl.getInstance().hasPermissionToUsePackets())
- tooltips.add(new TranslatableComponent("text.rei.cheating_enabled"));
- else
- tooltips.add(new TranslatableComponent("text.rei.cheating_limited_enabled"));
- return tooltips.toArray(new Component[0]);
- }),
+ .containsMousePredicate((button, point) -> button.getBounds().contains(point) && isNotInExclusionZones(point.x, point.y)),
Widgets.createDrawableWidget((helper, matrices, mouseX, mouseY, delta) -> {
helper.setBlitOffset(helper.getBlitOffset() + 1);
RenderSystem.setShaderTexture(0, CHEST_GUI_TEXTURE);
@@ -418,6 +400,19 @@ public class ScreenOverlayImpl extends ScreenOverlay {
config::isCheating,
config::setCheating
),
+ new EmptyMenuEntry(4),
+ new TextMenuEntry(() -> {
+ if (!ClientHelper.getInstance().isCheating())
+ return new TranslatableComponent("text.rei.cheating_disabled");
+ else if (!ClientHelperImpl.getInstance().hasOperatorPermission()) {
+ if (minecraft.gameMode.hasInfiniteItems())
+ return new TranslatableComponent("text.rei.cheating_limited_creative_enabled");
+ else return new TranslatableComponent("text.rei.cheating_enabled_no_perms");
+ } else if (ClientHelperImpl.getInstance().hasPermissionToUsePackets())
+ return new TranslatableComponent("text.rei.cheating_enabled");
+ else
+ return new TranslatableComponent("text.rei.cheating_limited_enabled");
+ }),
new SeparatorMenuEntry(),
ToggleMenuEntry.ofDeciding(new TranslatableComponent("text.rei.config.menu.dark_theme"),
config::isUsingDarkTheme,
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EmptyMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EmptyMenuEntry.java
new file mode 100644
index 000000000..4ccfa4414
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/EmptyMenuEntry.java
@@ -0,0 +1,58 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.client.gui.modules.entries;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.rei.impl.client.gui.modules.AbstractMenuEntry;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+
+import java.util.Collections;
+import java.util.List;
+
+public class EmptyMenuEntry extends AbstractMenuEntry {
+ public int height;
+
+ public EmptyMenuEntry(int height) {
+ this.height = height;
+ }
+
+ @Override
+ public int getEntryWidth() {
+ return 0;
+ }
+
+ @Override
+ public int getEntryHeight() {
+ return height;
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ }
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java
new file mode 100644
index 000000000..69740e383
--- /dev/null
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/TextMenuEntry.java
@@ -0,0 +1,70 @@
+/*
+ * This file is licensed under the MIT License, part of Roughly Enough Items.
+ * Copyright (c) 2018, 2019, 2020, 2021, 2022 shedaniel
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package me.shedaniel.rei.impl.client.gui.modules.entries;
+
+import com.mojang.blaze3d.vertex.PoseStack;
+import me.shedaniel.rei.impl.client.gui.modules.AbstractMenuEntry;
+import net.minecraft.client.gui.components.events.GuiEventListener;
+import net.minecraft.network.chat.Component;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.function.Supplier;
+
+public class TextMenuEntry extends AbstractMenuEntry {
+ public final Supplier<Component> text;
+ public Component lastText;
+ public int lastTextWidth;
+
+ public TextMenuEntry(Supplier<Component> text) {
+ this.text = text;
+ this.lastText = text.get();
+ this.lastTextWidth = Math.max(0, font.width(lastText));
+ }
+
+ private int getTextWidth() {
+ return lastTextWidth;
+ }
+
+ @Override
+ public int getEntryWidth() {
+ return getTextWidth() + 4;
+ }
+
+ @Override
+ public int getEntryHeight() {
+ return 12;
+ }
+
+ @Override
+ public List<? extends GuiEventListener> children() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
+ font.draw(matrices, lastText = text.get(), getX() + 2, getY() + 2, 8947848);
+ this.lastTextWidth = Math.max(0, font.width(lastText));
+ }
+}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java
index 121773736..505ce9c6d 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/modules/entries/ToggleMenuEntry.java
@@ -75,7 +75,7 @@ public class ToggleMenuEntry extends AbstractMenuEntry {
@Override
public int getEntryWidth() {
- return getTextWidth() + 4 + 6;
+ return getTextWidth() + 4 + 8;
}
@Override