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
7 changed files
with
101 additions
and
11 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
58 changes: 58 additions & 0 deletions
58
.../kitten-heart/src/main/java/net/pixaurora/kitten_cube/impl/ui/widget/TiledBackground.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,58 @@ | ||
package net.pixaurora.kitten_cube.impl.ui.widget; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Point; | ||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
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.screen.align.Alignment; | ||
import net.pixaurora.kitten_cube.impl.ui.screen.align.AlignmentStrategy; | ||
import net.pixaurora.kitten_cube.impl.ui.texture.Texture; | ||
|
||
public class TiledBackground implements Widget { | ||
private final Texture texture; | ||
private List<Point> posToDrawAt; | ||
|
||
public TiledBackground(Texture texture) { | ||
this.texture = texture; | ||
} | ||
|
||
@Override | ||
public void draw(GuiDisplay gui, Point mousePos) { | ||
for (Point pos : posToDrawAt) { | ||
gui.draw(this.texture, pos); | ||
} | ||
} | ||
|
||
@Override | ||
public void onWindowUpdate(Size window) { | ||
Size texture = this.texture.size(); | ||
|
||
Size tileCounts = Size.of((int) Math.ceil((float) window.width() / texture.width()), | ||
(int) Math.ceil((float) window.height() / texture.height())); | ||
|
||
this.posToDrawAt = new ArrayList<>(); | ||
for (int tileY = 0; tileY <= tileCounts.height(); tileY++) { | ||
for (int tileX = 0; tileX <= tileCounts.width(); tileX++) { | ||
this.posToDrawAt.add(Point.of(tileX * texture.width(), tileY * texture.height())); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Optional<AlignmentStrategy> alignmentMethod() { | ||
return Optional.of(Alignment.TOP_LEFT); | ||
} | ||
|
||
@Override | ||
public void onClick(Point mousePos, MouseButton button) { | ||
} | ||
|
||
@Override | ||
public boolean isWithinBounds(Point mousePos) { | ||
return false; | ||
} | ||
} |
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
23 changes: 23 additions & 0 deletions
23
...heart/src/main/java/net/pixaurora/kitten_heart/impl/ui/screen/KitTunesScreenTemplate.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,23 @@ | ||
package net.pixaurora.kitten_heart.impl.ui.screen; | ||
|
||
import net.pixaurora.kitten_cube.impl.math.Size; | ||
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.texture.Texture; | ||
import net.pixaurora.kitten_cube.impl.ui.widget.TiledBackground; | ||
import net.pixaurora.kitten_heart.impl.KitTunes; | ||
|
||
public abstract class KitTunesScreenTemplate extends ReturnToPreviousScreen { | ||
public static final Texture backgroundTile = Texture | ||
.of(KitTunes.resource("textures/gui/sprites/background/tile.png"), Size.of(16, 16)); | ||
|
||
public KitTunesScreenTemplate(Screen previous) { | ||
super(previous); | ||
} | ||
|
||
@Override | ||
protected void addBackground() { | ||
this.addWidget(new TiledBackground(backgroundTile)); | ||
} | ||
|
||
} |
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
Binary file added
BIN
+177 Bytes
src/main/resources/assets/kit_tunes/textures/gui/sprites/background/tile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.