Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main/java/com/cleanroommc/modularui/drawable/UITexture.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.cleanroommc.modularui.drawable;

import com.cleanroommc.modularui.ModularUI;
import com.cleanroommc.modularui.api.ITheme;
import com.cleanroommc.modularui.api.drawable.IDrawable;
import com.cleanroommc.modularui.screen.viewport.GuiContext;
import com.cleanroommc.modularui.theme.WidgetTheme;
Expand Down Expand Up @@ -141,7 +142,17 @@ public void draw(float x, float y, float width, float height) {
GuiDraw.drawTexture(this.location, x, y, x + width, y + height, this.u0, this.v0, this.u1, this.v1);
}

@Deprecated
public void drawSubArea(float x, float y, float width, float height, float uStart, float vStart, float uEnd, float vEnd) {
drawSubArea(x, y, width, height, uStart, vStart, uEnd, vEnd, WidgetTheme.getDefault());
}

public void drawSubArea(float x, float y, float width, float height, float uStart, float vStart, float uEnd, float vEnd, WidgetTheme widgetTheme) {
if (canApplyTheme()) {
Color.setGlColor(widgetTheme.getColor());
} else {
Color.setGlColorOpaque(Color.WHITE.main);
}
GuiDraw.drawTexture(this.location, x, y, x + width, y + height, lerpU(uStart), lerpV(vStart), lerpU(uEnd), lerpV(vEnd));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
float progress = getCurrentProgress();
if (this.fullTexture[0] != null && progress > 0) {
if (this.direction == Direction.CIRCULAR_CW) {
drawCircular(progress);
drawCircular(progress, widgetTheme);
return;
}
if (progress >= 1) {
Expand Down Expand Up @@ -91,7 +91,7 @@ public void draw(ModularGuiContext context, WidgetTheme widgetTheme) {
y = getArea().height - height;
break;
}
this.fullTexture[0].drawSubArea(x, y, width, height, u0, v0, u1, v1);
this.fullTexture[0].drawSubArea(x, y, width, height, u0, v0, u1, v1, widgetTheme);
}
}
}
Expand All @@ -103,7 +103,7 @@ public float getProgressUV(float uv) {
return (float) (Math.floor(uv * this.imageSize) / this.imageSize);
}

private void drawCircular(float progress) {
private void drawCircular(float progress, WidgetTheme widgetTheme) {
float[] subAreas = {
getProgressUV(MathHelper.clamp(progress / 0.25f, 0, 1)),
getProgressUV(MathHelper.clamp((progress - 0.25f) / 0.25f, 0, 1)),
Expand All @@ -118,31 +118,33 @@ private void drawCircular(float progress) {
0, getArea().height - progressScaled,
halfWidth, progressScaled,
0.0f, 1.0f - progressScaled / halfHeight,
1.0f, 1.0f
1.0f, 1.0f, widgetTheme
); // BL, draw UP

progressScaled = subAreas[1] * halfWidth;
this.fullTexture[1].drawSubArea(
0, 0,
progressScaled, halfHeight,
0.0f, 0.0f,
progressScaled / (halfWidth), 1.0f
progressScaled / (halfWidth), 1.0f,
widgetTheme
); // TL, draw RIGHT

progressScaled = subAreas[2] * halfHeight;
this.fullTexture[2].drawSubArea(
halfWidth, 0,
halfWidth, progressScaled,
0.0f, 0.0f,
1.0f, progressScaled / halfHeight
1.0f, progressScaled / halfHeight,
widgetTheme
); // TR, draw DOWN

progressScaled = subAreas[3] * halfWidth;
this.fullTexture[3].drawSubArea(
getArea().width - progressScaled, halfHeight,
progressScaled, halfHeight,
1.0f - progressScaled / halfWidth, 0.0f,
1.0f, 1.0f
1.0f, 1.0f, widgetTheme
); // BR, draw LEFT
}

Expand Down