mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Added option to select font size (#7238)
This commit is contained in:
parent
8047278d80
commit
51ba657b75
@ -722,6 +722,7 @@ Translation files are generated successfully. =
|
|||||||
Fastlane files are generated successfully. =
|
Fastlane files are generated successfully. =
|
||||||
Please note that translations are a community-based work in progress and are INCOMPLETE! The percentage shown is how much of the language is translated in-game. If you want to help translating the game into your language, click here. =
|
Please note that translations are a community-based work in progress and are INCOMPLETE! The percentage shown is how much of the language is translated in-game. If you want to help translating the game into your language, click here. =
|
||||||
Font family =
|
Font family =
|
||||||
|
Font size multiplier =
|
||||||
Default Font =
|
Default Font =
|
||||||
You need to restart the game for this change to take effect. =
|
You need to restart the game for this change to take effect. =
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ open class AndroidLauncher : AndroidApplication() {
|
|||||||
val androidParameters = UncivGameParameters(
|
val androidParameters = UncivGameParameters(
|
||||||
version = BuildConfig.VERSION_NAME,
|
version = BuildConfig.VERSION_NAME,
|
||||||
crashReportSysInfo = CrashReportSysInfoAndroid,
|
crashReportSysInfo = CrashReportSysInfoAndroid,
|
||||||
fontImplementation = NativeFontAndroid(Fonts.ORIGINAL_FONT_SIZE.toInt(), fontFamily),
|
fontImplementation = NativeFontAndroid((Fonts.ORIGINAL_FONT_SIZE * settings.fontSizeMultiplier).toInt(), fontFamily),
|
||||||
customFileLocationHelper = customFileLocationHelper,
|
customFileLocationHelper = customFileLocationHelper,
|
||||||
platformSpecificHelper = platformSpecificHelper
|
platformSpecificHelper = platformSpecificHelper
|
||||||
)
|
)
|
||||||
|
@ -72,6 +72,7 @@ class GameSettings {
|
|||||||
var lastGameSetup: GameSetupInfo? = null
|
var lastGameSetup: GameSetupInfo? = null
|
||||||
|
|
||||||
var fontFamily: String = Fonts.DEFAULT_FONT_FAMILY
|
var fontFamily: String = Fonts.DEFAULT_FONT_FAMILY
|
||||||
|
var fontSizeMultiplier: Float = 1f
|
||||||
|
|
||||||
/** Maximum zoom-out of the map - performance heavy */
|
/** Maximum zoom-out of the map - performance heavy */
|
||||||
var maxWorldZoomOut = 2f
|
var maxWorldZoomOut = 2f
|
||||||
|
@ -65,6 +65,8 @@ fun advancedTab(
|
|||||||
|
|
||||||
addFontFamilySelect(this, settings, optionsPopup.selectBoxMinWidth, onFontChange)
|
addFontFamilySelect(this, settings, optionsPopup.selectBoxMinWidth, onFontChange)
|
||||||
|
|
||||||
|
addFontSizeMultiplier(this, settings, onFontChange)
|
||||||
|
|
||||||
addTranslationGeneration(this, optionsPopup)
|
addTranslationGeneration(this, optionsPopup)
|
||||||
|
|
||||||
addSetUserId(this, settings)
|
addSetUserId(this, settings)
|
||||||
@ -87,8 +89,7 @@ private fun addAutosaveTurnsSelectBox(table: Table, settings: GameSettings) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private
|
private fun addFontFamilySelect(table: Table, settings: GameSettings, selectBoxMinWidth: Float, onFontChange: () -> Unit) {
|
||||||
fun addFontFamilySelect(table: Table, settings: GameSettings, selectBoxMinWidth: Float, onFontChange: () -> Unit) {
|
|
||||||
table.add("Font family".toLabel()).left().fillX()
|
table.add("Font family".toLabel()).left().fillX()
|
||||||
val selectCell = table.add()
|
val selectCell = table.add()
|
||||||
table.row()
|
table.row()
|
||||||
@ -131,6 +132,29 @@ fun addFontFamilySelect(table: Table, settings: GameSettings, selectBoxMinWidth:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun addFontSizeMultiplier(
|
||||||
|
table: Table,
|
||||||
|
settings: GameSettings,
|
||||||
|
onFontChange: () -> Unit
|
||||||
|
) {
|
||||||
|
table.add("Font size multiplier".toLabel()).left().fillX()
|
||||||
|
|
||||||
|
val fontSizeSlider = UncivSlider(
|
||||||
|
0.7f, 1.5f, 0.05f,
|
||||||
|
initial = settings.fontSizeMultiplier
|
||||||
|
) {
|
||||||
|
settings.fontSizeMultiplier = it
|
||||||
|
settings.save()
|
||||||
|
}
|
||||||
|
fontSizeSlider.onChange {
|
||||||
|
if (!fontSizeSlider.isDragging) {
|
||||||
|
Fonts.resetFont(settings.fontFamily)
|
||||||
|
onFontChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.add(fontSizeSlider).pad(5f).row()
|
||||||
|
}
|
||||||
|
|
||||||
private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
|
private fun addMaxZoomSlider(table: Table, settings: GameSettings) {
|
||||||
table.add("Max zoom out".tr()).left().fillX()
|
table.add("Max zoom out".tr()).left().fillX()
|
||||||
val maxZoomSlider = UncivSlider(
|
val maxZoomSlider = UncivSlider(
|
||||||
|
@ -174,7 +174,7 @@ object Fonts {
|
|||||||
try {
|
try {
|
||||||
val fontImplementationClass = UncivGame.Current.fontImplementation!!::class.java
|
val fontImplementationClass = UncivGame.Current.fontImplementation!!::class.java
|
||||||
val fontImplementationConstructor = fontImplementationClass.constructors.first()
|
val fontImplementationConstructor = fontImplementationClass.constructors.first()
|
||||||
val newFontImpl = fontImplementationConstructor.newInstance(ORIGINAL_FONT_SIZE.toInt(), newFamily)
|
val newFontImpl = fontImplementationConstructor.newInstance((ORIGINAL_FONT_SIZE * UncivGame.Current.settings.fontSizeMultiplier).toInt(), newFamily)
|
||||||
if (newFontImpl is NativeFontImplementation)
|
if (newFontImpl is NativeFontImplementation)
|
||||||
UncivGame.Current.fontImplementation = newFontImpl
|
UncivGame.Current.fontImplementation = newFontImpl
|
||||||
} catch (ex: Exception) {}
|
} catch (ex: Exception) {}
|
||||||
|
@ -57,7 +57,7 @@ internal object DesktopLauncher {
|
|||||||
val desktopParameters = UncivGameParameters(
|
val desktopParameters = UncivGameParameters(
|
||||||
versionFromJar,
|
versionFromJar,
|
||||||
cancelDiscordEvent = { discordTimer?.cancel() },
|
cancelDiscordEvent = { discordTimer?.cancel() },
|
||||||
fontImplementation = NativeFontDesktop(Fonts.ORIGINAL_FONT_SIZE.toInt(), settings.fontFamily),
|
fontImplementation = NativeFontDesktop((Fonts.ORIGINAL_FONT_SIZE * settings.fontSizeMultiplier).toInt(), settings.fontFamily),
|
||||||
customFileLocationHelper = CustomFileLocationHelperDesktop(),
|
customFileLocationHelper = CustomFileLocationHelperDesktop(),
|
||||||
crashReportSysInfo = CrashReportSysInfoDesktop(),
|
crashReportSysInfo = CrashReportSysInfoDesktop(),
|
||||||
platformSpecificHelper = platformSpecificHelper,
|
platformSpecificHelper = platformSpecificHelper,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user