mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-12 08:49:22 +07:00
[code quality] Reorg, clean up and comment a few things (#10527)
* UncivGame is a pure class file again, GUI split off * Purify GameSettings step 1 - non-multiplayer nested classes * Purify GameSettings step 2 - multiplayer nested classes * Purify GameParameters - BaseRuleset to own file * Rework WindowState to centralize minimum/maximum treatment * Rename MultiplayerTurnNotifierDesktop to UncivWindowListener * Clarifications on what the WindowListener actually does (and now the attention-getting does something on non-Windows too)
This commit is contained in:
@ -11,7 +11,6 @@ import com.badlogic.gdx.utils.Align
|
||||
import com.unciv.logic.GameInfo
|
||||
import com.unciv.logic.IsPartOfGameInfoSerialization
|
||||
import com.unciv.logic.UncivShowableException
|
||||
import com.unciv.logic.civilization.Civilization
|
||||
import com.unciv.logic.civilization.PlayerType
|
||||
import com.unciv.logic.files.UncivFiles
|
||||
import com.unciv.logic.multiplayer.OnlineMultiplayer
|
||||
@ -38,10 +37,7 @@ import com.unciv.ui.screens.basescreen.BaseScreen
|
||||
import com.unciv.ui.screens.mainmenuscreen.MainMenuScreen
|
||||
import com.unciv.ui.screens.savescreens.LoadGameScreen
|
||||
import com.unciv.ui.screens.worldscreen.PlayerReadyScreen
|
||||
import com.unciv.ui.screens.worldscreen.UndoHandler.Companion.clearUndoCheckpoints
|
||||
import com.unciv.ui.screens.worldscreen.WorldMapHolder
|
||||
import com.unciv.ui.screens.worldscreen.WorldScreen
|
||||
import com.unciv.ui.screens.worldscreen.unit.UnitTable
|
||||
import com.unciv.utils.Concurrency
|
||||
import com.unciv.utils.DebugUtils
|
||||
import com.unciv.utils.Display
|
||||
@ -57,78 +53,6 @@ import java.util.UUID
|
||||
import kotlinx.coroutines.CancellationException
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
object GUI {
|
||||
|
||||
fun setUpdateWorldOnNextRender() {
|
||||
UncivGame.Current.worldScreen?.shouldUpdate = true
|
||||
}
|
||||
|
||||
fun pushScreen(screen: BaseScreen) {
|
||||
UncivGame.Current.pushScreen(screen)
|
||||
}
|
||||
|
||||
fun resetToWorldScreen() {
|
||||
UncivGame.Current.resetToWorldScreen()
|
||||
}
|
||||
|
||||
fun getSettings(): GameSettings {
|
||||
return UncivGame.Current.settings
|
||||
}
|
||||
|
||||
fun isWorldLoaded(): Boolean {
|
||||
return UncivGame.Current.worldScreen != null
|
||||
}
|
||||
|
||||
fun isMyTurn(): Boolean {
|
||||
if (!UncivGame.isCurrentInitialized() || !isWorldLoaded()) return false
|
||||
return UncivGame.Current.worldScreen!!.isPlayersTurn
|
||||
}
|
||||
|
||||
fun isAllowedChangeState(): Boolean {
|
||||
return UncivGame.Current.worldScreen!!.canChangeState
|
||||
}
|
||||
|
||||
fun getWorldScreen(): WorldScreen {
|
||||
return UncivGame.Current.worldScreen!!
|
||||
}
|
||||
|
||||
fun getWorldScreenIfActive(): WorldScreen? {
|
||||
return UncivGame.Current.getWorldScreenIfActive()
|
||||
}
|
||||
|
||||
fun getMap(): WorldMapHolder {
|
||||
return UncivGame.Current.worldScreen!!.mapHolder
|
||||
}
|
||||
|
||||
fun getUnitTable(): UnitTable {
|
||||
return UncivGame.Current.worldScreen!!.bottomUnitTable
|
||||
}
|
||||
|
||||
fun getViewingPlayer(): Civilization {
|
||||
return UncivGame.Current.worldScreen!!.viewingCiv
|
||||
}
|
||||
|
||||
fun getSelectedPlayer(): Civilization {
|
||||
return UncivGame.Current.worldScreen!!.selectedCiv
|
||||
}
|
||||
|
||||
/** Disable Undo (as in: forget the way back, but allow future undo checkpoints) */
|
||||
fun clearUndoCheckpoints() {
|
||||
UncivGame.Current.worldScreen?.clearUndoCheckpoints()
|
||||
}
|
||||
|
||||
private var keyboardAvailableCache: Boolean? = null
|
||||
/** Tests availability of a physical keyboard */
|
||||
val keyboardAvailable: Boolean
|
||||
get() {
|
||||
// defer decision if Gdx.input not yet initialized
|
||||
if (keyboardAvailableCache == null && Gdx.input != null)
|
||||
keyboardAvailableCache = Gdx.input.isPeripheralAvailable(Input.Peripheral.HardwareKeyboard)
|
||||
return keyboardAvailableCache ?: false
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
open class UncivGame(val isConsoleMode: Boolean = false) : Game(), PlatformSpecific {
|
||||
|
||||
var deepLinkedMultiplayerGame: String? = null
|
||||
|
Reference in New Issue
Block a user