forked from Clones/Controlify
✏️ Credit Andrew Grant in the carousel screen
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
package dev.isxander.controlify.gui.components;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.PlainTextButton;
|
||||
import net.minecraft.client.gui.navigation.ScreenRectangle;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FakePositionPlainTextButton extends PlainTextButton {
|
||||
private ScreenRectangle fakePosition;
|
||||
|
||||
public FakePositionPlainTextButton(int x, int y, int width, int height, Component content, OnPress empty, Font font) {
|
||||
super(x, y, width, height, content, empty, font);
|
||||
}
|
||||
|
||||
public FakePositionPlainTextButton(Component text, Font font, int x, int y, Button.OnPress onPress) {
|
||||
this(x, y, font.width(text.getVisualOrderText()), font.lineHeight, text, onPress, font);
|
||||
}
|
||||
|
||||
public void setFakePosition(ScreenRectangle fakePosition) {
|
||||
this.fakePosition = fakePosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull ScreenRectangle getRectangle() {
|
||||
return isFocused() ? super.getRectangle() : fakePosition;
|
||||
}
|
||||
}
|
@ -8,9 +8,11 @@ import dev.isxander.controlify.api.buttonguide.ButtonGuidePredicate;
|
||||
import dev.isxander.controlify.api.buttonguide.ButtonRenderPosition;
|
||||
import dev.isxander.controlify.controller.Controller;
|
||||
import dev.isxander.controlify.controller.sdl2.SDL2NativesManager;
|
||||
import dev.isxander.controlify.gui.components.FakePositionPlainTextButton;
|
||||
import dev.isxander.controlify.screenop.ScreenControllerEventListener;
|
||||
import dev.isxander.controlify.utils.Animator;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.gui.ComponentPath;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
@ -79,6 +81,13 @@ public class ControllerCarouselScreen extends Screen implements ScreenController
|
||||
protected void init() {
|
||||
refreshControllers();
|
||||
|
||||
var artCreditText = Component.translatable("controlify.gui.carousel.art_credit", Component.literal("Andrew Grant"))
|
||||
.withStyle(ChatFormatting.DARK_GRAY);
|
||||
var artCreditBtn = this.addRenderableWidget(new FakePositionPlainTextButton(artCreditText, font, width - font.width(artCreditText) - 3, 3, btn -> {
|
||||
Util.getPlatform().openUri("https://github.com/Andrew6rant");
|
||||
}));
|
||||
artCreditBtn.setFakePosition(new ScreenRectangle(0, height, width, 1));
|
||||
|
||||
GridLayout grid = new GridLayout().columnSpacing(10);
|
||||
GridLayout.RowHelper rowHelper = grid.createRowHelper(2);
|
||||
globalSettingsButton = rowHelper.addChild(Button.builder(Component.translatable("controlify.gui.global_settings.title"), btn -> minecraft.setScreen(GlobalSettingsScreenFactory.createGlobalSettingsScreen(this))).build());
|
||||
|
@ -67,7 +67,7 @@ public class SubmitUnknownControllerScreen extends Screen {
|
||||
int allHeight = font.lineHeight + titleBottomPadding + content.getHeight() + checkboxPadding + checkboxHeight + checkboxPadding + buttonHeight + nameFieldPaddingTop + nameFieldHeight + errorPadding + font.lineHeight;
|
||||
|
||||
int y = this.height / 2 - allHeight / 2;
|
||||
this.addRenderableWidget(createStringWidget(this.getTitle(), font, 25, y));
|
||||
this.addRenderableWidget(ClientUtils.createStringWidget(this.getTitle(), font, 25, y));
|
||||
y += font.lineHeight + titleBottomPadding;
|
||||
|
||||
content.setY(y);
|
||||
|
20
src/main/java/dev/isxander/controlify/utils/ClientUtils.java
Normal file
20
src/main/java/dev/isxander/controlify/utils/ClientUtils.java
Normal file
@ -0,0 +1,20 @@
|
||||
package dev.isxander.controlify.utils;
|
||||
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.PlainTextButton;
|
||||
import net.minecraft.client.gui.components.StringWidget;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public final class ClientUtils {
|
||||
private ClientUtils() {
|
||||
}
|
||||
|
||||
public static StringWidget createStringWidget(Component text, Font font, int x, int y) {
|
||||
return new StringWidget(x, y, font.width(text.getVisualOrderText()), font.lineHeight, text, font);
|
||||
}
|
||||
|
||||
public static PlainTextButton createPlainTextButton(Component text, Font font, int x, int y, Button.OnPress onPress) {
|
||||
return new PlainTextButton(x, y, font.width(text.getVisualOrderText()), font.lineHeight, text, onPress, font);
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
"controlify.gui.carousel.entry.settings": "Settings",
|
||||
"controlify.gui.carousel.entry.use": "Use",
|
||||
"controlify.gui.carousel.entry.in_use": "Currently in use",
|
||||
"controlify.gui.carousel.art_credit": "Controller art by %s.",
|
||||
|
||||
"controlify.gui.global_settings.title": "Global Settings",
|
||||
"controlify.gui.load_vibration_natives": "Load Natives",
|
||||
@ -281,7 +282,7 @@
|
||||
|
||||
"controlify.controller_submission.title": "Unknown Controller Submission",
|
||||
"controlify.controller_submission.message": "Please submit some of your controller info to Controlify's database to get it added in a future update.\n\nControlify sends the following information:\n- Your controller's vendor & product IDs\n- Your controller's GUID\n- The name of your controller (in the box below)\n- The version of Controlify you are currently on\n\nThis is completely anonymous and doesn't store any of your personal or account information.",
|
||||
"controlify.controller_submission.dont_show_again": "Do not show for this controller again",
|
||||
"controlify.controller_submission.operational_checkbox": "Does your controller work with Controlify?",
|
||||
"controlify.controller_submission.submit": "Submit Data",
|
||||
"controlify.controller_submission.skip": "Skip",
|
||||
"controlify.controller_submission.name_hint": "Controller name",
|
||||
|
Reference in New Issue
Block a user