Добавить доступный интерфейс этапа 3

This commit is contained in:
2026-08-18 16:29:08 +03:00
parent dcb16ef4d0
commit 21775542d5
11 changed files with 854 additions and 23 deletions
@@ -0,0 +1,69 @@
package com.projectsacrifice.game;
public final class AccessibilitySettings {
private enum TextSize {
STANDARD("Standard", 1f),
LARGE("Large", 1.25f);
final String label;
final float scale;
TextSize(String label, float scale) {
this.label = label;
this.scale = scale;
}
}
private final TextSize textSize;
private final boolean highContrastEnabled;
private AccessibilitySettings(TextSize textSize, boolean highContrastEnabled) {
this.textSize = textSize;
this.highContrastEnabled = highContrastEnabled;
}
public static AccessibilitySettings defaults() {
return new AccessibilitySettings(TextSize.STANDARD, false);
}
static AccessibilitySettings restore(int textSizeIndex, boolean highContrastEnabled) {
TextSize[] values = TextSize.values();
TextSize restored = textSizeIndex >= 0 && textSizeIndex < values.length
? values[textSizeIndex] : TextSize.STANDARD;
return new AccessibilitySettings(restored, highContrastEnabled);
}
public String textSizeLabel() {
return textSize.label;
}
public float textScale() {
return textSize.scale;
}
public float canvasTextSize(float baseSize) {
return baseSize * textSize.scale;
}
public AccessibilitySettings nextTextSize() {
TextSize[] values = TextSize.values();
return new AccessibilitySettings(values[(textSize.ordinal() + 1) % values.length],
highContrastEnabled);
}
public boolean highContrastEnabled() {
return highContrastEnabled;
}
public String highContrastLabel() {
return highContrastEnabled ? "On" : "Off";
}
public AccessibilitySettings toggleHighContrast() {
return new AccessibilitySettings(textSize, !highContrastEnabled);
}
int textSizeIndex() {
return textSize.ordinal();
}
}