mirror of
https://github.com/yairm210/Unciv.git
synced 2024-12-22 23:34:24 +07:00
Removed Scenarios button, since the new game screen handles scenarios better
This commit is contained in:
parent
1962af4507
commit
a020a2a797
@ -169,12 +169,6 @@ class MainMenuScreen: BaseScreen(), RecreateOnResize {
|
||||
{ game.pushScreen(ModManagementScreen()) }
|
||||
column2.add(modsTable).row()
|
||||
|
||||
if (game.files.getScenarioFiles().any()){
|
||||
val scenarioTable = getMenuButton("Scenarios", "OtherIcons/Scenarios", KeyboardBinding.Scenarios)
|
||||
{ game.pushScreen(ScenarioScreen()) }
|
||||
column2.add(scenarioTable).row()
|
||||
}
|
||||
|
||||
val optionsTable = getMenuButton("Options", "OtherIcons/Options", KeyboardBinding.MainMenuOptions)
|
||||
{ openOptionsPopup() }
|
||||
optionsTable.onLongPress { openOptionsPopup(withDebug = true) }
|
||||
|
@ -1,65 +0,0 @@
|
||||
package com.unciv.ui.screens.mainmenuscreen
|
||||
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import com.unciv.logic.UncivShowableException
|
||||
import com.unciv.models.translations.tr
|
||||
import com.unciv.ui.components.extensions.enable
|
||||
import com.unciv.ui.components.input.KeyCharAndCode
|
||||
import com.unciv.ui.components.input.keyShortcuts
|
||||
import com.unciv.ui.components.input.onActivation
|
||||
import com.unciv.ui.components.input.onDoubleClick
|
||||
import com.unciv.ui.popups.ToastPopup
|
||||
import com.unciv.ui.screens.pickerscreens.PickerScreen
|
||||
import com.unciv.ui.screens.savescreens.VerticalFileListScrollPane
|
||||
import com.unciv.utils.Concurrency
|
||||
import com.unciv.utils.launchOnGLThread
|
||||
|
||||
class ScenarioScreen: PickerScreen(disableScroll = true) {
|
||||
private val scenarioScrollPane = VerticalFileListScrollPane()
|
||||
|
||||
private var scenarioToLoad: FileHandle? = null
|
||||
|
||||
/** Caches the mod names while the getScenarioFiles Sequence is iterated */
|
||||
private val sourceMods = mutableMapOf<FileHandle, String>()
|
||||
|
||||
init {
|
||||
scenarioScrollPane.onChange(::selectScenario)
|
||||
scenarioScrollPane.onDoubleClick(action = ::loadSelectedScenario)
|
||||
topTable.defaults().pad(5f)
|
||||
topTable.add(scenarioScrollPane).grow().row()
|
||||
|
||||
rightSideButton.setText("Choose scenario")
|
||||
rightSideButton.onActivation(::loadSelectedScenario)
|
||||
rightSideButton.keyShortcuts.add(KeyCharAndCode.RETURN)
|
||||
|
||||
setDefaultCloseAction()
|
||||
|
||||
scenarioScrollPane.update(
|
||||
game.files.getScenarioFiles().map {
|
||||
sourceMods[it.first] = it.second.name
|
||||
it.first
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
private fun selectScenario(file: FileHandle) {
|
||||
descriptionLabel.setText(sourceMods[file]?.let { "Mod: [$it]".tr() })
|
||||
scenarioToLoad = file
|
||||
rightSideButton.setText(file.name())
|
||||
rightSideButton.enable()
|
||||
}
|
||||
|
||||
private fun loadSelectedScenario() {
|
||||
val file = scenarioToLoad ?: return
|
||||
Concurrency.run("LoadScenario") {
|
||||
try {
|
||||
val scenario = game.files.loadScenario(file)
|
||||
game.loadGame(scenario)
|
||||
} catch (ex: UncivShowableException) {
|
||||
launchOnGLThread {
|
||||
ToastPopup("{Error loading scenario:}\n{${ex.message}}", this@ScenarioScreen)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user