From 49f2d290ab40e218ed031696523dae065f019b42 Mon Sep 17 00:00:00 2001 From: Saad Nadeem Date: Mon, 14 Sep 2026 01:57:24 -0400 Subject: [PATCH] fix(ui): remove UI scaling config --- .../assets/oneconfig/lang/en_us.json | 6 ----- .../oneconfig/internal/OneConfigConfig.java | 24 ------------------- .../oneconfig/internal/ui/themes/Provider.kt | 16 ++++--------- .../assets/oneconfig/en_default.lang | 4 ---- .../ui/themes/PixelGridScaleTest.java | 15 ------------ 5 files changed, 4 insertions(+), 61 deletions(-) diff --git a/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json b/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json index 7ac3e849f..417e3d7e4 100644 --- a/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json +++ b/minecraft/src/main/resources/assets/oneconfig/lang/en_us.json @@ -52,12 +52,6 @@ "oneconfig.preferences.pause_game.title": "Pause Game", "oneconfig.preferences.pause_game.description": "Pause singleplayer worlds while the OneConfig menu is open.", - "oneconfig.preferences.use_custom_ui_size.title": "Set UI size manually", - "oneconfig.preferences.use_custom_ui_size.description": "Size the OneConfig menu yourself instead of fitting it to the window.", - - "oneconfig.preferences.ui_pixel_size.title": "UI size", - "oneconfig.preferences.ui_pixel_size.description": "How many screen pixels wide one pixel of the menu is drawn. Whole sizes are the sharpest.", - "oneconfig.preferences.reduced_res_filter.title": "Reduced-resolution filter", "oneconfig.preferences.reduced_res_filter.description": "Counteracts blur when the game renders at a reduced resolution (e.g. Sodium Extra's 'Reduce Resolution on macOS'). Only takes effect when the display is upscaling a reduced framebuffer. 'Sharpen' softly crisps the whole menu; 'Harden edges' aliases text/edges so they survive the upscale like Minecraft's font (crisper text, but blockier corners).", "oneconfig.preferences.reduced_res_filter.off": "Off", diff --git a/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java b/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java index 87b9c46a0..0d88bc69c 100644 --- a/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java +++ b/modules/internal/src/main/java/org/polyfrost/oneconfig/internal/OneConfigConfig.java @@ -258,29 +258,6 @@ public class OneConfigConfig extends Config { ) public static boolean pauseGame = false; - @Switch( - title = "oneconfig.preferences.use_custom_ui_size.title", - titleTranslation = true, - subcategory = "oneconfig.preferences.category.gui", - subcategoryTranslation = true, - description = "oneconfig.preferences.use_custom_ui_size.description", - descriptionTranslation = true - ) - public static boolean useCustomUiSize = false; - - @Slider( - title = "oneconfig.preferences.ui_pixel_size.title", - titleTranslation = true, - subcategory = "oneconfig.preferences.category.gui", - subcategoryTranslation = true, - min = 1f, - max = 4f, - step = 0.5f, - description = "oneconfig.preferences.ui_pixel_size.description", - descriptionTranslation = true - ) - public static float uiPixelSize = 2f; - @Dropdown( title = "oneconfig.preferences.reduced_res_filter.title", titleTranslation = true, @@ -618,7 +595,6 @@ protected void initialize(boolean byConfigManager) { if (tree == null) { return; } - addDependency("uiPixelSize", "useCustomUiSize"); addDependency( "uiSharpening", "Reduced-resolution filter", diff --git a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/themes/Provider.kt b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/themes/Provider.kt index 58f697eb0..aef2e01a6 100644 --- a/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/themes/Provider.kt +++ b/modules/internal/src/main/kotlin/org/polyfrost/oneconfig/internal/ui/themes/Provider.kt @@ -23,7 +23,6 @@ import androidx.compose.ui.graphics.toArgb import org.polyfrost.compose.render.PolyColor import org.polyfrost.oneconfig.api.notifications.v1.NotificationTheme import org.polyfrost.oneconfig.api.platform.v1.Platform -import org.polyfrost.oneconfig.internal.OneConfigConfig import org.polyfrost.oneconfig.internal.ThemeConfig import org.polyfrost.oneconfig.internal.ui.DESIGN_HEIGHT_DP import org.polyfrost.oneconfig.internal.ui.DESIGN_WIDTH_DP @@ -50,8 +49,6 @@ private const val EM_STEP_PX = 5f private const val MIN_EM_PX = 10f -private const val GLYPH_PIXELS_PER_EM = 10f - private fun scrollbarStyle(theme: UITheme) = ScrollbarStyle( minimalHeight = 24.dp, thickness = 8.dp, @@ -70,13 +67,9 @@ fun pixelGridScale(scale: Float, max: Float, anchorSp: Float = GRID_ANCHOR_SP): if (scale <= 0f) return scale val density = LocalDensity.current val anchorPx = anchorSp * density.fontScale * density.density * scale * surfaceRatio() - return scale * snapScaleToPixelGrid(anchorPx, max / scale, chosenEmPx()) + return scale * snapScaleToPixelGrid(anchorPx, max / scale) } -private fun chosenEmPx(): Float? = - if (OneConfigConfig.useCustomUiSize) OneConfigConfig.uiPixelSize.coerceIn(1f, 4f) * GLYPH_PIXELS_PER_EM - else null - @Composable private fun pixelGridDensity(designWidth: Dp, designHeight: Dp): Density { val density = LocalDensity.current @@ -93,14 +86,13 @@ private fun pixelGridDensity(designWidth: Dp, designHeight: Dp): Density { } } -@JvmOverloads -internal fun snapScaleToPixelGrid(anchorPx: Float, max: Float, chosenEm: Float? = null): Float { +internal fun snapScaleToPixelGrid(anchorPx: Float, max: Float): Float { if (anchorPx <= 0f) return 1f val fits = floor(anchorPx * max / EM_STEP_PX) * EM_STEP_PX val nearest = round(anchorPx / EM_STEP_PX) * EM_STEP_PX - val em = chosenEm ?: maxOf(nearest, fits) + val em = maxOf(nearest, fits) val scale = em.coerceAtLeast(MIN_EM_PX) / anchorPx - return if (chosenEm != null || scale <= max) scale else max + return if (scale <= max) scale else max } @Composable diff --git a/modules/internal/src/main/resources/assets/oneconfig/en_default.lang b/modules/internal/src/main/resources/assets/oneconfig/en_default.lang index d31a46b15..78ca2235f 100644 --- a/modules/internal/src/main/resources/assets/oneconfig/en_default.lang +++ b/modules/internal/src/main/resources/assets/oneconfig/en_default.lang @@ -51,10 +51,6 @@ oneconfig.preferences.sidebar_opacity.title=Sidebar Opacity oneconfig.preferences.sidebar_opacity.description=How opaque the OneConfig sidebar background is. 0 = fully transparent, 100 = fully opaque. oneconfig.preferences.pause_game.title=Pause Game oneconfig.preferences.pause_game.description=Pause singleplayer worlds while the OneConfig menu is open. -oneconfig.preferences.use_custom_ui_size.title=Set UI size manually -oneconfig.preferences.use_custom_ui_size.description=Size the OneConfig menu yourself instead of fitting it to the window. -oneconfig.preferences.ui_pixel_size.title=UI size -oneconfig.preferences.ui_pixel_size.description=How many screen pixels wide one pixel of the menu is drawn. Whole sizes are the sharpest. oneconfig.preferences.opening_behavior.title=Opening Behavior oneconfig.preferences.opening_behavior.description=Which page to open when the OneConfig menu is launched. oneconfig.preferences.opening_behavior.previous_page=Previous page diff --git a/modules/internal/src/test/java/org/polyfrost/oneconfig/internal/ui/themes/PixelGridScaleTest.java b/modules/internal/src/test/java/org/polyfrost/oneconfig/internal/ui/themes/PixelGridScaleTest.java index 04ffebc55..cc2bfbf42 100644 --- a/modules/internal/src/test/java/org/polyfrost/oneconfig/internal/ui/themes/PixelGridScaleTest.java +++ b/modules/internal/src/test/java/org/polyfrost/oneconfig/internal/ui/themes/PixelGridScaleTest.java @@ -93,21 +93,6 @@ void minecraftsSmallestWindowStillLeavesItsMargin() { assertEquals(1f, ProviderKt.snapScaleToPixelGrid(7.7355f, 1f), 1e-4f); } - @Test - void aChosenSizeReplacesWhateverTheWindowWouldHavePicked() { - assertEquals(20f / ANCHOR_PX, ProviderKt.snapScaleToPixelGrid(ANCHOR_PX, FIT_1080P, 20f), 1e-4f); - } - - @Test - void aChosenSizeIsHonouredEvenWhenItOverflowsTheWindow() { - assertEquals(40f / ANCHOR_PX, ProviderKt.snapScaleToPixelGrid(ANCHOR_PX, FIT_1080P, 40f), 1e-4f); - } - - @Test - void aChosenSizeStillCannotGoBelowOnePixelPerGlyphPixel() { - assertEquals(10f / ANCHOR_PX, ProviderKt.snapScaleToPixelGrid(ANCHOR_PX, FIT_1080P, 5f), 1e-4f); - } - @Test void aDegenerateAnchorIsLeftAlone() { assertEquals(1f, ProviderKt.snapScaleToPixelGrid(0f, 2f), 1e-4f);