Improved theme usability
This commit is contained in:
@@ -45,11 +45,33 @@ public class Theme {
|
|||||||
config.property("Font", FONT);
|
config.property("Font", FONT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* primary by default, accent if true
|
||||||
|
*/
|
||||||
public static int getBg(boolean hover) {
|
public static int getBg(boolean hover) {
|
||||||
return hover ? ACCENT.value : PRIMARY.value;
|
return hover ? ACCENT.value : PRIMARY.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (Foreground) primary by default, accent if true
|
||||||
|
*/
|
||||||
public static int getFg(boolean hover) {
|
public static int getFg(boolean hover) {
|
||||||
return hover ? ACCENT_FG.value : PRIMARY_FG.value;
|
return hover ? ACCENT_FG.value : PRIMARY_FG.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets alpha using 0–255 range.
|
||||||
|
*/
|
||||||
|
public static int withAlpha(int alpha, int color) {
|
||||||
|
alpha = Math.max(0, Math.min(255, alpha));
|
||||||
|
return (color & 0x00FFFFFF) | (alpha << 24);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets alpha using 0.0–1.0 range.
|
||||||
|
*/
|
||||||
|
public static int withAlpha(float alpha, int color) {
|
||||||
|
alpha = Math.max(0f, Math.min(1f, alpha));
|
||||||
|
return withAlpha((int) (alpha * 255f), color);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package org.saturnclient.saturnclient.mixin;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
import org.saturnclient.saturnclient.config.Theme;
|
||||||
import org.saturnclient.ui2.RenderScope;
|
import org.saturnclient.ui2.RenderScope;
|
||||||
import org.saturnclient.ui2.resources.Textures;
|
import org.saturnclient.ui2.resources.Textures;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
@@ -40,10 +41,6 @@ public abstract class SplashOverlayMixin {
|
|||||||
@Shadow(remap = false)
|
@Shadow(remap = false)
|
||||||
private float progress;
|
private float progress;
|
||||||
|
|
||||||
private static int withAlpha(int color, int alpha) {
|
|
||||||
return color & 0xFFFFFF | alpha << 24;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @reason Replace vanilla splash rendering completely but keep exit logic
|
* @reason Replace vanilla splash rendering completely but keep exit logic
|
||||||
*/
|
*/
|
||||||
@@ -80,19 +77,17 @@ public abstract class SplashOverlayMixin {
|
|||||||
if (fadeOutProgress >= 1.0F) {
|
if (fadeOutProgress >= 1.0F) {
|
||||||
renderCurrentScreen(context, mouseX, mouseY, delta);
|
renderCurrentScreen(context, mouseX, mouseY, delta);
|
||||||
int overlayAlpha = computeOverlayAlpha(fadeOutProgress - 1f);
|
int overlayAlpha = computeOverlayAlpha(fadeOutProgress - 1f);
|
||||||
// context.fill(0, 0, screenWidth, screenHeight,
|
|
||||||
// withAlpha(0x53389E, overlayAlpha));
|
|
||||||
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
||||||
withAlpha(0xFFFFFF, overlayAlpha));
|
Theme.withAlpha(0xFFFFFFFF, overlayAlpha));
|
||||||
} else if (reloading) {
|
} else if (reloading) {
|
||||||
if (reloadProgress < 1.0F) {
|
if (reloadProgress < 1.0F) {
|
||||||
renderCurrentScreen(context, mouseX, mouseY, delta);
|
renderCurrentScreen(context, mouseX, mouseY, delta);
|
||||||
}
|
}
|
||||||
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
||||||
withAlpha(0xFFFFFF, alpha));
|
Theme.withAlpha(0xFFFFFFFF, alpha));
|
||||||
} else {
|
} else {
|
||||||
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
scope.drawTexture(Textures.SPLASH, 0, 0, 0, 0, screenWidth, screenHeight,
|
||||||
withAlpha(0xFFFFFF, alpha));
|
Theme.withAlpha(0xFFFFFFFF, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
float u = this.reload.getProgress();
|
float u = this.reload.getProgress();
|
||||||
@@ -120,18 +115,19 @@ public abstract class SplashOverlayMixin {
|
|||||||
/** Draw the main logo centered */
|
/** Draw the main logo centered */
|
||||||
private void drawLogo(RenderScope scope, int screenWidth, int screenHeight, int alpha) {
|
private void drawLogo(RenderScope scope, int screenWidth, int screenHeight, int alpha) {
|
||||||
scope.drawTexture(Textures.LOGO, (screenWidth - 60) / 2, ((screenHeight - 60) / 2) - 20, 0, 0, 60, 60,
|
scope.drawTexture(Textures.LOGO, (screenWidth - 60) / 2, ((screenHeight - 60) / 2) - 20, 0, 0, 60, 60,
|
||||||
withAlpha(0xFFFFFF, alpha));
|
Theme.withAlpha(0xFFFFFFFF, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderProgressBar(RenderScope scope, DrawContext context, int screenWidth, int screenHeight,
|
private void renderProgressBar(RenderScope scope, DrawContext context, int screenWidth, int screenHeight,
|
||||||
int alpha) {
|
int alpha) {
|
||||||
int progressY = ((screenHeight - 5) / 2) + 25;
|
int progressY = ((screenHeight - 5) / 2) + 25;
|
||||||
context.drawBorder((screenWidth - 120) / 2, progressY, 120, 5, withAlpha(0xFFFFFF, alpha));
|
context.drawBorder((screenWidth - 120) / 2, progressY, 120, 5, Theme.withAlpha(0xFFFFFFFF, alpha));
|
||||||
|
|
||||||
int progressWidth = Math.min((int) (progress * 120), 120);
|
int progressWidth = Math.min((int) (progress * 120), 120);
|
||||||
int progressX = (screenWidth - 120) / 2;
|
int progressX = (screenWidth - 120) / 2;
|
||||||
|
|
||||||
context.fill(progressX, progressY, progressX + progressWidth, progressY + 5, withAlpha(0xFFFFFF, alpha));
|
context.fill(progressX, progressY, progressX + progressWidth, progressY + 5,
|
||||||
|
Theme.withAlpha(0xFFFFFFFF, alpha));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Compute overlay alpha from fade progress */
|
/** Compute overlay alpha from fade progress */
|
||||||
|
|||||||
Reference in New Issue
Block a user