Removed exitEvent from the UncivGameParameters, since Gdx.app.exit() does the same thing :)

This commit is contained in:
Yair Morgenstern 2020-11-04 00:09:11 +02:00
parent 315a55f972
commit 65524cb7dd
7 changed files with 3 additions and 20 deletions

View File

@ -33,7 +33,6 @@ class AndroidLauncher : AndroidApplication() {
val androidParameters = UncivGameParameters( val androidParameters = UncivGameParameters(
version = BuildConfig.VERSION_NAME, version = BuildConfig.VERSION_NAME,
crashReportSender = CrashReportSenderAndroid(this), crashReportSender = CrashReportSenderAndroid(this),
exitEvent = this::finish,
fontImplementation = NativeFontAndroid(ORIGINAL_FONT_SIZE.toInt()), fontImplementation = NativeFontAndroid(ORIGINAL_FONT_SIZE.toInt()),
customSaveLocationHelper = customSaveLocationHelper customSaveLocationHelper = customSaveLocationHelper
) )

View File

@ -27,7 +27,6 @@ class UncivGame(parameters: UncivGameParameters) : Game() {
val version = parameters.version val version = parameters.version
private val crashReportSender = parameters.crashReportSender private val crashReportSender = parameters.crashReportSender
val exitEvent = parameters.exitEvent
val cancelDiscordEvent = parameters.cancelDiscordEvent val cancelDiscordEvent = parameters.cancelDiscordEvent
val fontImplementation = parameters.fontImplementation val fontImplementation = parameters.fontImplementation
val consoleMode = parameters.consoleMode val consoleMode = parameters.consoleMode

View File

@ -6,8 +6,7 @@ import com.unciv.ui.utils.NativeFontImplementation
class UncivGameParameters(val version: String, class UncivGameParameters(val version: String,
val crashReportSender: CrashReportSender? = null, val crashReportSender: CrashReportSender? = null,
val exitEvent: (()->Unit)? = null, val cancelDiscordEvent: (() -> Unit)? = null,
val cancelDiscordEvent: (()->Unit)? = null,
val fontImplementation: NativeFontImplementation? = null, val fontImplementation: NativeFontImplementation? = null,
val consoleMode: Boolean = false, val consoleMode: Boolean = false,
val customSaveLocationHelper: CustomSaveLocationHelper? = null) { val customSaveLocationHelper: CustomSaveLocationHelper? = null) {

View File

@ -689,15 +689,10 @@ class WorldScreen(val viewingCiv:CivilizationInfo) : CameraStageBaseScreen() {
return return
} }
// don't show a dialog, if it can't exit the game
if (game.exitEvent == null) {
return
}
val promptWindow = Popup(this) val promptWindow = Popup(this)
promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr()) promptWindow.addGoodSizedLabel("Do you want to exit the game?".tr())
promptWindow.row() promptWindow.row()
promptWindow.addButton("Yes") { game.exitEvent?.invoke() } promptWindow.addButton("Yes") { Gdx.app.exit() }
promptWindow.addButton("No") { promptWindow.addButton("No") {
promptWindow.close() promptWindow.close()
} }

View File

@ -12,12 +12,7 @@ import com.unciv.models.metadata.GameSpeed
import com.unciv.models.metadata.Player import com.unciv.models.metadata.Player
import com.unciv.models.ruleset.RulesetCache import com.unciv.models.ruleset.RulesetCache
import com.unciv.models.simulation.Simulation import com.unciv.models.simulation.Simulation
import com.unciv.models.simulation.SimulationStep
import com.unciv.models.simulation.formatDuration
import com.unciv.ui.newgamescreen.GameSetupInfo import com.unciv.ui.newgamescreen.GameSetupInfo
import java.time.Duration
import kotlin.concurrent.thread
import kotlin.system.exitProcess
internal object ConsoleLauncher { internal object ConsoleLauncher {
@JvmStatic @JvmStatic
@ -27,7 +22,6 @@ internal object ConsoleLauncher {
val consoleParameters = UncivGameParameters( val consoleParameters = UncivGameParameters(
version, version,
null, null,
{ exitProcess(0) },
null, null,
null, null,
true true

View File

@ -25,7 +25,6 @@ import io.ktor.server.netty.Netty
import java.io.File import java.io.File
import java.util.* import java.util.*
import kotlin.concurrent.timer import kotlin.concurrent.timer
import kotlin.system.exitProcess
internal object DesktopLauncher { internal object DesktopLauncher {
private var discordTimer: Timer? = null private var discordTimer: Timer? = null
@ -48,7 +47,6 @@ internal object DesktopLauncher {
val desktopParameters = UncivGameParameters( val desktopParameters = UncivGameParameters(
versionFromJar, versionFromJar,
exitEvent = { exitProcess(0) },
cancelDiscordEvent = { discordTimer?.cancel() }, cancelDiscordEvent = { discordTimer?.cancel() },
fontImplementation = NativeFontDesktop(ORIGINAL_FONT_SIZE.toInt()), fontImplementation = NativeFontDesktop(ORIGINAL_FONT_SIZE.toInt()),
customSaveLocationHelper = CustomSaveLocationHelperDesktop() customSaveLocationHelper = CustomSaveLocationHelperDesktop()

View File

@ -10,7 +10,6 @@ import com.unciv.models.ruleset.RulesetCache
import com.unciv.models.ruleset.unit.BaseUnit import com.unciv.models.ruleset.unit.BaseUnit
import com.unciv.models.stats.Stat import com.unciv.models.stats.Stat
import com.unciv.models.stats.Stats import com.unciv.models.stats.Stats
import com.unciv.models.translations.tr
import org.junit.Assert import org.junit.Assert
import org.junit.Before import org.junit.Before
import org.junit.Test import org.junit.Test
@ -40,7 +39,7 @@ class BasicTests {
@Test @Test
fun gameIsNotRunWithDebugModes() { fun gameIsNotRunWithDebugModes() {
val params = UncivGameParameters("", null, null) val params = UncivGameParameters("", null)
val game = UncivGame(params) val game = UncivGame(params)
Assert.assertTrue("This test will only pass if the game is not run with debug modes", Assert.assertTrue("This test will only pass if the game is not run with debug modes",
!game.superchargedForDebug !game.superchargedForDebug