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
6 changes: 0 additions & 6 deletions minecraft/src/main/resources/assets/oneconfig/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -618,7 +595,6 @@ protected void initialize(boolean byConfigManager) {
if (tree == null) {
return;
}
addDependency("uiPixelSize", "useCustomUiSize");
addDependency(
"uiSharpening",
"Reduced-resolution filter",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading