generated from QuiltMC/quilt-template-mod
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
202 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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
10 changes: 10 additions & 0 deletions
10
...heart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/event/WindowUpdateEvent.java
This file contains 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,10 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget.event; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.Screen; | ||
|
||
public interface WindowUpdateEvent { | ||
public Size newWindow(); | ||
|
||
public Screen screen(); | ||
} |
24 changes: 24 additions & 0 deletions
24
...t/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/event/WindowUpdateEventImpl.java
This file contains 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,24 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget.event; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.Screen; | ||
|
||
public class WindowUpdateEventImpl implements WindowUpdateEvent { | ||
private final Size newWindow; | ||
private final Screen screen; | ||
|
||
public WindowUpdateEventImpl(Size newWindow, Screen screen) { | ||
this.newWindow = newWindow; | ||
this.screen = screen; | ||
} | ||
|
||
@Override | ||
public Size newWindow() { | ||
return this.newWindow; | ||
} | ||
|
||
@Override | ||
public Screen screen() { | ||
return this.screen; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...s/kitten-heart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/text/TextField.java
This file contains 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,38 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget.text; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Point; | ||
import net.pixaurora.kitten_cube.impl.ui.controls.MouseButton; | ||
import net.pixaurora.kitten_cube.impl.ui.display.GuiDisplay; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.Widget; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.event.WindowUpdateEvent; | ||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public interface TextField extends Widget { | ||
public static TextField regular() { | ||
return KitTunes.UI_LAYER.newTextField(TextFieldBackground.REGULAR_BACKGROUND); | ||
} | ||
|
||
@Override | ||
default void onWindowUpdate(WindowUpdateEvent event) { | ||
KitTunes.UI_LAYER.addTextField(event.screen(), this); | ||
} | ||
|
||
public String input(); | ||
|
||
public void setPos(int x, int y); | ||
|
||
@Override | ||
default void draw(GuiDisplay gui, Point mousePos) { | ||
this.setPos(gui.alignX(0, 0), gui.alignY(0, 0)); | ||
} | ||
|
||
@Override | ||
default void onClick(Point mousePos, MouseButton button) { | ||
return; | ||
} | ||
|
||
@Override | ||
default boolean isWithinBounds(Point mousePos) { | ||
return false; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...eart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/text/TextFieldBackground.java
This file contains 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,33 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget.text; | ||
|
||
import java.util.function.Function; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
import net.pixaurora.kitten_cube.impl.ui.texture.Texture; | ||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public class TextFieldBackground<T> { | ||
public static final TextFieldBackground<Texture> REGULAR_BACKGROUND = new TextFieldBackground<>( | ||
Texture.of(KitTunes.resource("textures/gui/sprites/widget/text_field/normal.png"), Size.of(200, 20)), | ||
Texture.of(KitTunes.resource("textures/gui/sprites/widget/text_field/highlighted.png"), Size.of(200, 20))); | ||
|
||
private final T normal; | ||
private final T highlighted; | ||
|
||
public TextFieldBackground(T normal, T highlighted) { | ||
this.normal = normal; | ||
this.highlighted = highlighted; | ||
} | ||
|
||
public <G> TextFieldBackground<G> map(Function<T, G> mapFunction) { | ||
return new TextFieldBackground<G>(mapFunction.apply(this.normal), mapFunction.apply(this.highlighted)); | ||
} | ||
|
||
public T normal() { | ||
return normal; | ||
} | ||
|
||
public T getHighlighted() { | ||
return highlighted; | ||
} | ||
} |
This file contains 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 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
33 changes: 33 additions & 0 deletions
33
...en-heart/src/main/java/net/pixaurora/kitten_heart/impl/ui/screen/TextFieldDemoScreen.java
This file contains 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,33 @@ | ||
package net.pixaurora.kitten_heart.impl.ui.screen; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Point; | ||
import net.pixaurora.kitten_cube.impl.text.Component; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.ReturnToPreviousScreen; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.Screen; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.WidgetContainer; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.align.Alignment; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.align.WidgetAnchor; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.button.RectangularButton; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.text.TextField; | ||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public class TextFieldDemoScreen extends ReturnToPreviousScreen { | ||
public TextFieldDemoScreen(Screen previous) { | ||
super(previous); | ||
} | ||
|
||
@Override | ||
protected Alignment alignmentMethod() { | ||
return Alignment.CENTER; | ||
} | ||
|
||
@Override | ||
protected void firstInit() { | ||
WidgetContainer<TextField> textField = this.addWidget(TextField.regular()).anchor(WidgetAnchor.TOP_MIDDLE); | ||
this.addWidget(RectangularButton.vanillaButton(Component.literal("log text field"), | ||
button -> KitTunes.LOGGER.info("Text field input: " + textField.get().input()))) | ||
.anchor(WidgetAnchor.TOP_MIDDLE) | ||
.align(textField.relativeTo(WidgetAnchor.BOTTOM_MIDDLE)) | ||
.at(Point.of(0, 10)); | ||
} | ||
} |
This file contains 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 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