Add text color and setI18nText to GuiTextField
This commit is contained in:
@@ -34,6 +34,7 @@ import lombok.Getter;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.util.ReadableColor;
|
||||
import org.lwjgl.util.ReadableDimension;
|
||||
import org.lwjgl.util.ReadablePoint;
|
||||
|
||||
@@ -49,6 +50,9 @@ public abstract class AbstractGuiTextField<T extends AbstractGuiTextField<T>>
|
||||
@Getter
|
||||
private String hint;
|
||||
|
||||
@Getter
|
||||
private ReadableColor textColor;
|
||||
|
||||
public AbstractGuiTextField() {
|
||||
this.wrapped = new net.minecraft.client.gui.GuiTextField(0, Minecraft.getMinecraft().fontRendererObj, 0, 0, 0, 0);
|
||||
}
|
||||
@@ -128,6 +132,11 @@ public abstract class AbstractGuiTextField<T extends AbstractGuiTextField<T>>
|
||||
return getThis();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setI18nText(String text, Object... args) {
|
||||
return setText(I18n.format(text, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText() {
|
||||
return wrapped.text;
|
||||
@@ -224,4 +233,11 @@ public abstract class AbstractGuiTextField<T extends AbstractGuiTextField<T>>
|
||||
public T setI18nHint(String hint, Object... args) {
|
||||
return setHint(I18n.format(hint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public T setTextColor(ReadableColor textColor) {
|
||||
this.textColor = textColor;
|
||||
wrapped.setTextColor(textColor.getAlpha() << 24 | textColor.getRed() << 16 | textColor.getGreen() << 8 | textColor.getBlue());
|
||||
return getThis();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,9 +23,11 @@
|
||||
package de.johni0702.minecraft.gui.element;
|
||||
|
||||
import de.johni0702.minecraft.gui.function.Focusable;
|
||||
import org.lwjgl.util.ReadableColor;
|
||||
|
||||
public interface IGuiTextField<T extends IGuiTextField<T>> extends GuiElement<T>, Focusable<T> {
|
||||
T setText(String text);
|
||||
T setI18nText(String text, Object... args);
|
||||
String getText();
|
||||
|
||||
int getMaxLength();
|
||||
@@ -38,4 +40,7 @@ public interface IGuiTextField<T extends IGuiTextField<T>> extends GuiElement<T>
|
||||
T setHint(String hint);
|
||||
|
||||
T setI18nHint(String hint, Object... args);
|
||||
|
||||
ReadableColor getTextColor();
|
||||
T setTextColor(ReadableColor textColor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user