mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
chore: code cleanup
This commit is contained in:
@ -108,10 +108,6 @@ class CivInfoStatsForNextTurn(val civInfo: Civilization) {
|
||||
transportationUpkeep.add(Stat.valueOf(unique.params[1]), unique.params[0].toFloat())
|
||||
}
|
||||
}
|
||||
// backwards compatible
|
||||
if (road.hasUnique(UniqueType.OldImprovementMaintenance, StateForConditionals(civInfo, tile = tile))) {
|
||||
transportationUpkeep.add(Stat.Gold, tile.getUnpillagedRoad().upkeep.toFloat())
|
||||
}
|
||||
}
|
||||
}
|
||||
// tabulate neutral roads
|
||||
|
@ -103,13 +103,13 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
}
|
||||
|
||||
private fun getTilesExertingZoneOfControl(tile: Tile, civInfo: Civilization) = sequence {
|
||||
for (tile in tile.neighbors) {
|
||||
if (tile.isCityCenter() && civInfo.isAtWarWith(tile.getOwner()!!)) {
|
||||
yield(tile)
|
||||
for (neighbor in tile.neighbors) {
|
||||
if (neighbor.isCityCenter() && civInfo.isAtWarWith(neighbor.getOwner()!!)) {
|
||||
yield(neighbor)
|
||||
}
|
||||
else if (tile.militaryUnit != null && civInfo.isAtWarWith(tile.militaryUnit!!.civ)) {
|
||||
if (tile.militaryUnit!!.type.isWaterUnit() || (unit.type.isLandUnit() && !tile.militaryUnit!!.isEmbarked()))
|
||||
yield(tile)
|
||||
else if (neighbor.militaryUnit != null && civInfo.isAtWarWith(neighbor.militaryUnit!!.civ)) {
|
||||
if (neighbor.militaryUnit!!.type.isWaterUnit() || (unit.type.isLandUnit() && !neighbor.militaryUnit!!.isEmbarked()))
|
||||
yield(neighbor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -561,8 +561,6 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
DefensiveBonus("Gives a defensive bonus of [relativeAmount]%", UniqueTarget.Improvement),
|
||||
ImprovementMaintenance("Costs [amount] [stat] per turn when in your territory", UniqueTarget.Improvement), // Roads
|
||||
ImprovementAllMaintenance("Costs [amount] [stat] per turn", UniqueTarget.Improvement), // Roads
|
||||
@Deprecated("as of 4.3.9", ReplaceWith("Costs [amount] [stats] per turn when in your territory"))
|
||||
OldImprovementMaintenance("Costs [amount] gold per turn when in your territory", UniqueTarget.Improvement), // unused
|
||||
DamagesAdjacentEnemyUnits("Adjacent enemy units ending their turn take [amount] damage", UniqueTarget.Improvement),
|
||||
|
||||
GreatImprovement("Great Improvement", UniqueTarget.Improvement),
|
||||
@ -735,6 +733,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
|
||||
// region DEPRECATED AND REMOVED
|
||||
|
||||
@Deprecated("as of 4.3.9", ReplaceWith("Costs [amount] [stats] per turn when in your territory"), DeprecationLevel.ERROR)
|
||||
OldImprovementMaintenance("Costs [amount] gold per turn when in your territory", UniqueTarget.Improvement),
|
||||
@Deprecated("as of 4.3.4", ReplaceWith("[+1 Happiness] per [2] social policies adopted"), DeprecationLevel.ERROR)
|
||||
HappinessPer2Policies("Provides 1 happiness per 2 additional social policies adopted", UniqueTarget.Global),
|
||||
@Deprecated("as of 4.3.6", ReplaceWith("[+1 Happiness] for every known Natural Wonder"), DeprecationLevel.ERROR)
|
||||
|
@ -62,16 +62,8 @@ data class KeyCharAndCode(val char: Char, val code: Int) {
|
||||
/** Guaranteed to be ignored by [KeyShortcutDispatcher] and never to be generated for an actual event, used as fallback to ensure no action is taken */
|
||||
val UNKNOWN = KeyCharAndCode(Input.Keys.UNKNOWN)
|
||||
|
||||
// Kludges because we got crashes: java.lang.NoSuchMethodError: 'int kotlin.CharCodeKt.access$getCode$p(char)'
|
||||
//TODO fixed by removing UncivServer from the desktop module - clean up comments and all uses
|
||||
fun Char.toCode() = code
|
||||
// try { code } catch (ex: Throwable) { null }
|
||||
// ?: try { @Suppress("DEPRECATION") toInt() } catch (ex: Throwable) { null }
|
||||
// ?: 0
|
||||
fun Int.makeChar() = Char(this)
|
||||
// try { Char(this) } catch (ex: Throwable) { null }
|
||||
// ?: try { toChar() } catch (ex: Throwable) { null }
|
||||
// ?: Char.MIN_VALUE
|
||||
|
||||
/** mini-factory for control codes - case insensitive */
|
||||
fun ctrl(letter: Char) = KeyCharAndCode((letter.toCode() and 31).makeChar(),0)
|
||||
|
@ -190,7 +190,11 @@ private fun addTurnCheckerOptions(
|
||||
): RefreshSelect? {
|
||||
val settings = optionsPopup.settings
|
||||
|
||||
optionsPopup.addCheckbox(tab, "Enable out-of-game turn notifications", settings.multiplayer::turnCheckerEnabled)
|
||||
optionsPopup.addCheckbox(
|
||||
tab,
|
||||
"Enable out-of-game turn notifications",
|
||||
settings.multiplayer::turnCheckerEnabled
|
||||
)
|
||||
|
||||
if (!settings.multiplayer.turnCheckerEnabled) return null
|
||||
|
||||
|
@ -9,7 +9,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener
|
||||
import com.badlogic.gdx.utils.Array
|
||||
import com.unciv.GUI
|
||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.logic.event.EventBus
|
||||
import com.unciv.models.UncivSound
|
||||
@ -20,15 +19,16 @@ import com.unciv.models.metadata.SettingsPropertyChanged
|
||||
import com.unciv.models.metadata.SettingsPropertyUncivSoundChanged
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.TabbedPager
|
||||
import com.unciv.ui.components.extensions.center
|
||||
import com.unciv.ui.components.extensions.onChange
|
||||
import com.unciv.ui.components.extensions.toCheckBox
|
||||
import com.unciv.ui.components.extensions.toGdxArray
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||
import com.unciv.utils.concurrency.Concurrency
|
||||
import com.unciv.utils.concurrency.withGLContext
|
||||
@ -169,12 +169,13 @@ class OptionsPopup(
|
||||
else table.add(checkbox).left()
|
||||
}
|
||||
|
||||
fun addCheckbox(table: Table,
|
||||
text: String,
|
||||
settingsProperty: KMutableProperty0<Boolean>,
|
||||
updateWorld: Boolean = false,
|
||||
newRow: Boolean = true,
|
||||
action: (Boolean) -> Unit = {}) {
|
||||
fun addCheckbox(
|
||||
table: Table,
|
||||
text: String,
|
||||
settingsProperty: KMutableProperty0<Boolean>,
|
||||
updateWorld: Boolean = false,
|
||||
action: (Boolean) -> Unit = {}
|
||||
) {
|
||||
addCheckbox(table, text, settingsProperty.get(), updateWorld) {
|
||||
action(it)
|
||||
settingsProperty.set(it)
|
||||
|
@ -11,7 +11,6 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table
|
||||
import com.badlogic.gdx.scenes.scene2d.ui.TextButton
|
||||
import com.badlogic.gdx.utils.Align
|
||||
import com.badlogic.gdx.utils.SerializationException
|
||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||
import com.unciv.UncivGame
|
||||
import com.unciv.json.fromJsonFile
|
||||
import com.unciv.json.json
|
||||
@ -20,16 +19,9 @@ import com.unciv.models.ruleset.Ruleset
|
||||
import com.unciv.models.ruleset.RulesetCache
|
||||
import com.unciv.models.tilesets.TileSetCache
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.screens.pickerscreens.ModManagementOptions.SortType
|
||||
import com.unciv.ui.popups.ConfirmPopup
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.popups.ToastPopup
|
||||
import com.unciv.ui.components.AutoScrollPane
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.components.ExpanderTab
|
||||
import com.unciv.ui.components.KeyCharAndCode
|
||||
import com.unciv.ui.screens.basescreen.RecreateOnResize
|
||||
import com.unciv.ui.components.UncivTextField
|
||||
import com.unciv.ui.components.WrappableLabel
|
||||
import com.unciv.ui.components.extensions.UncivDateFormat.formatDate
|
||||
@ -44,6 +36,14 @@ import com.unciv.ui.components.extensions.onClick
|
||||
import com.unciv.ui.components.extensions.toCheckBox
|
||||
import com.unciv.ui.components.extensions.toLabel
|
||||
import com.unciv.ui.components.extensions.toTextButton
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
import com.unciv.ui.popups.ConfirmPopup
|
||||
import com.unciv.ui.popups.Popup
|
||||
import com.unciv.ui.popups.ToastPopup
|
||||
import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.screens.basescreen.RecreateOnResize
|
||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||
import com.unciv.ui.screens.pickerscreens.ModManagementOptions.SortType
|
||||
import com.unciv.utils.Log
|
||||
import com.unciv.utils.concurrency.Concurrency
|
||||
import com.unciv.utils.concurrency.launchOnGLThread
|
||||
@ -346,16 +346,26 @@ class ModManagementScreen(
|
||||
* @param repo: the repository instance as received from the GitHub api
|
||||
*/
|
||||
private fun addModInfoToActionTable(repo: Github.Repo) {
|
||||
addModInfoToActionTable(repo.name, repo.html_url, repo.pushed_at, repo.owner.login, repo.size)
|
||||
addModInfoToActionTable(repo.html_url, repo.pushed_at, repo.owner.login, repo.size)
|
||||
}
|
||||
/** Recreate the information part of the right-hand column
|
||||
* @param modName: The mod name (name from the RuleSet)
|
||||
* @param modOptions: The ModOptions as enriched by us with GitHub metadata when originally downloaded
|
||||
*/
|
||||
private fun addModInfoToActionTable(modName: String, modOptions: ModOptions) {
|
||||
addModInfoToActionTable(modName, modOptions.modUrl, modOptions.lastUpdated, modOptions.author, modOptions.modSize)
|
||||
addModInfoToActionTable(
|
||||
modOptions.modUrl,
|
||||
modOptions.lastUpdated,
|
||||
modOptions.author,
|
||||
modOptions.modSize
|
||||
)
|
||||
}
|
||||
private fun addModInfoToActionTable(modName: String, repoUrl: String, updatedAt: String, author: String, modSize: Int) {
|
||||
private fun addModInfoToActionTable(
|
||||
repoUrl: String,
|
||||
updatedAt: String,
|
||||
author: String,
|
||||
modSize: Int
|
||||
) {
|
||||
// remember selected mod - for now needed only to display a background-fetched image while the user is watching
|
||||
|
||||
// Display metadata
|
||||
|
Reference in New Issue
Block a user