feat(resource-pack-entry-widgets): do not provide default width/height
All checks were successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/jfmod Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-07-18 19:30:44 +02:00
parent 35295051c8
commit a7836ef624
Signed by: Johannes
GPG Key ID: E76429612C2929F4
3 changed files with 22 additions and 6 deletions

View File

@ -39,9 +39,7 @@ public interface ResourcePackEntryWidget {
* @param pack the pack to render the widget for
* @return the width of the widget
*/
default int getWidth(ResourcePackOrganizer.Pack pack) {
return 20;
}
int getWidth(ResourcePackOrganizer.Pack pack);
/**
* Gets the height of this widget.
@ -50,9 +48,7 @@ public interface ResourcePackEntryWidget {
* @param rowHeight the height of the row containing the widget
* @return the height of the widget
*/
default int getHeight(ResourcePackOrganizer.Pack pack, int rowHeight) {
return 20;
}
int getHeight(ResourcePackOrganizer.Pack pack, int rowHeight);
/**
* Gets the Y position of this widget relative to the top of the row.

View File

@ -10,6 +10,16 @@ public class TestWidget1 implements ResourcePackEntryWidget {
return (int) ((System.currentTimeMillis() % 5_000) / 100 + 10);
}
@Override
public int getHeight(ResourcePackOrganizer.Pack pack, int rowHeight) {
return 16;
}
@Override
public int getY(ResourcePackOrganizer.Pack pack, int rowHeight) {
return 14;
}
@Override
public int getXMargin(ResourcePackOrganizer.Pack pack) {
return (int) (Math.abs((System.currentTimeMillis() % 1_200) / 50 - 12) + 5);

View File

@ -10,6 +10,16 @@ public class TestWidget2 implements ResourcePackEntryWidget {
return System.currentTimeMillis() % 1_000 < 500;
}
@Override
public int getWidth(ResourcePackOrganizer.Pack pack) {
return 20;
}
@Override
public int getHeight(ResourcePackOrganizer.Pack pack, int rowHeight) {
return 20;
}
@Override
public void render(ResourcePackOrganizer.Pack pack, DrawContext context, int x, int y, boolean hovered, float tickDelta) {
context.fill(x, y, x + getWidth(pack), y + getHeight(pack, 20), hovered ? 0x80FF0080 : 0x80FF0000);