From 855b2959a1a0d50cd756345f4afa9fa8d83820e8 Mon Sep 17 00:00:00 2001 From: SomeTroglodyte <63000004+SomeTroglodyte@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:02:36 +0200 Subject: [PATCH] Fix Map Editor double map holders after ruleset change (#10047) * Fix Map Editor double map holders after ruleset change * Fix buttons are vertical in AskFitMapToRulesetPopup * Sort imports over mapeditor package --- core/src/com/unciv/ui/popups/Popup.kt | 4 ++-- .../mapeditorscreen/MapEditorFilesTable.kt | 8 ++++---- .../mapeditorscreen/MapEditorMainTabs.kt | 2 +- .../mapeditorscreen/MapEditorScreen.kt | 1 - .../mapeditorscreen/MapEditorToolsDrawer.kt | 1 - .../tabs/MapEditorGenerateTab.kt | 20 +++++++++---------- .../mapeditorscreen/tabs/MapEditorLoadTab.kt | 18 ++++++++--------- .../mapeditorscreen/tabs/MapEditorModsTab.kt | 20 +++++++++---------- .../tabs/MapEditorOptionsTab.kt | 8 ++++---- .../mapeditorscreen/tabs/MapEditorSaveTab.kt | 16 +++++++-------- .../mapeditorscreen/tabs/MapEditorViewTab.kt | 2 +- 11 files changed, 49 insertions(+), 51 deletions(-) diff --git a/core/src/com/unciv/ui/popups/Popup.kt b/core/src/com/unciv/ui/popups/Popup.kt index a90a0d6ee7..130ac7d94e 100644 --- a/core/src/com/unciv/ui/popups/Popup.kt +++ b/core/src/com/unciv/ui/popups/Popup.kt @@ -292,10 +292,10 @@ open class Popup( return bottomTable.add(button) } fun addButton(text: String, key: Char, style: TextButtonStyle? = null, action: () -> Unit) - = addButton(text, KeyCharAndCode(key), style, action).apply { row() } + = addButton(text, KeyCharAndCode(key), style, action) @Suppress("unused") // Keep the offer to pass an Input.keys value fun addButton(text: String, key: Int, style: TextButtonStyle? = null, action: () -> Unit) - = addButton(text, KeyCharAndCode(key), style, action).apply { row() } + = addButton(text, KeyCharAndCode(key), style, action) fun addButton(text: String, binding: KeyboardBinding, style: TextButtonStyle? = null, action: () -> Unit): Cell { val button = text.toTextButton(style) button.onActivation(binding = binding) { action() } diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorFilesTable.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorFilesTable.kt index 44ae98542e..f0356e4b1d 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorFilesTable.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorFilesTable.kt @@ -8,13 +8,13 @@ import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.scenes.scene2d.ui.TextButton import com.unciv.logic.files.MapSaver import com.unciv.models.ruleset.RulesetCache -import com.unciv.ui.images.ImageGetter -import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.components.extensions.pad +import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.input.keyShortcuts import com.unciv.ui.components.input.onClick import com.unciv.ui.components.input.onDoubleClick -import com.unciv.ui.components.extensions.pad -import com.unciv.ui.components.extensions.toLabel +import com.unciv.ui.images.ImageGetter +import com.unciv.ui.screens.basescreen.BaseScreen class MapEditorFilesTable( initWidth: Float, diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorMainTabs.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorMainTabs.kt index 9ffd5646f9..d0be83e736 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorMainTabs.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorMainTabs.kt @@ -1,7 +1,7 @@ package com.unciv.ui.screens.mapeditorscreen -import com.unciv.ui.components.input.KeyCharAndCode import com.unciv.ui.components.TabbedPager +import com.unciv.ui.components.input.KeyCharAndCode import com.unciv.ui.images.ImageGetter import com.unciv.ui.screens.mapeditorscreen.tabs.MapEditorEditTab import com.unciv.ui.screens.mapeditorscreen.tabs.MapEditorGenerateTab diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorScreen.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorScreen.kt index f77ef49dfc..c8fb5151eb 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorScreen.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorScreen.kt @@ -231,7 +231,6 @@ class MapEditorScreen(map: TileMap? = null): BaseScreen(), RecreateOnResize { tileMap.ruleset = newRuleset ruleset = newRuleset } - mapHolder = newMapHolder() modsTabNeedsRefresh = false } diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorToolsDrawer.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorToolsDrawer.kt index f8f012dee2..232e7d89b3 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorToolsDrawer.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/MapEditorToolsDrawer.kt @@ -2,7 +2,6 @@ package com.unciv.ui.screens.mapeditorscreen import com.badlogic.gdx.Application import com.badlogic.gdx.Gdx -import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.InputEvent import com.badlogic.gdx.scenes.scene2d.InputListener import com.badlogic.gdx.scenes.scene2d.Stage diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt index 6b3983cd8d..5ce6258413 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorGenerateTab.kt @@ -13,23 +13,23 @@ import com.unciv.logic.map.mapgenerator.MapGenerator import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache import com.unciv.models.translations.tr -import com.unciv.ui.images.ImageGetter -import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen -import com.unciv.ui.screens.mapeditorscreen.MapGeneratorSteps -import com.unciv.ui.screens.newgamescreen.MapParametersTable -import com.unciv.ui.popups.Popup -import com.unciv.ui.popups.ToastPopup -import com.unciv.ui.screens.basescreen.BaseScreen -import com.unciv.ui.components.input.KeyCharAndCode import com.unciv.ui.components.TabbedPager import com.unciv.ui.components.extensions.disable import com.unciv.ui.components.extensions.enable import com.unciv.ui.components.extensions.isEnabled -import com.unciv.ui.components.input.onChange -import com.unciv.ui.components.input.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.components.input.KeyCharAndCode +import com.unciv.ui.components.input.onChange +import com.unciv.ui.components.input.onClick +import com.unciv.ui.images.ImageGetter +import com.unciv.ui.popups.Popup +import com.unciv.ui.popups.ToastPopup +import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen +import com.unciv.ui.screens.mapeditorscreen.MapGeneratorSteps +import com.unciv.ui.screens.newgamescreen.MapParametersTable import com.unciv.utils.Concurrency import com.unciv.utils.Log diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorLoadTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorLoadTab.kt index 72082a2993..fb28e4751c 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorLoadTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorLoadTab.kt @@ -5,24 +5,24 @@ import com.badlogic.gdx.files.FileHandle import com.badlogic.gdx.graphics.Color import com.badlogic.gdx.scenes.scene2d.ui.Table import com.unciv.logic.MissingModsException -import com.unciv.logic.files.MapSaver import com.unciv.logic.UncivShowableException +import com.unciv.logic.files.MapSaver import com.unciv.models.ruleset.RulesetCache import com.unciv.models.translations.tr -import com.unciv.ui.screens.mapeditorscreen.MapEditorFilesTable -import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen -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.input.KeyCharAndCode import com.unciv.ui.components.TabbedPager import com.unciv.ui.components.extensions.isEnabled +import com.unciv.ui.components.extensions.toTextButton +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.extensions.toTextButton +import com.unciv.ui.popups.ConfirmPopup import com.unciv.ui.popups.LoadingPopup +import com.unciv.ui.popups.Popup +import com.unciv.ui.popups.ToastPopup +import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.screens.mapeditorscreen.MapEditorFilesTable +import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen import com.unciv.utils.Concurrency import com.unciv.utils.Log import kotlinx.coroutines.CoroutineScope diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorModsTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorModsTab.kt index 5725055d4b..a4e707d5b6 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorModsTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorModsTab.kt @@ -7,19 +7,19 @@ import com.badlogic.gdx.utils.Align import com.unciv.Constants import com.unciv.models.ruleset.Ruleset import com.unciv.models.ruleset.RulesetCache +import com.unciv.ui.components.TabbedPager +import com.unciv.ui.components.TranslatedSelectBox +import com.unciv.ui.components.UncivTooltip.Companion.addTooltip +import com.unciv.ui.components.extensions.isEnabled +import com.unciv.ui.components.extensions.toLabel +import com.unciv.ui.components.extensions.toTextButton +import com.unciv.ui.components.input.onChange +import com.unciv.ui.components.input.onClick +import com.unciv.ui.popups.Popup +import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen import com.unciv.ui.screens.mapeditorscreen.TileInfoNormalizer import com.unciv.ui.screens.newgamescreen.ModCheckboxTable -import com.unciv.ui.components.TranslatedSelectBox -import com.unciv.ui.popups.Popup -import com.unciv.ui.screens.basescreen.BaseScreen -import com.unciv.ui.components.TabbedPager -import com.unciv.ui.components.UncivTooltip.Companion.addTooltip -import com.unciv.ui.components.extensions.isEnabled -import com.unciv.ui.components.input.onChange -import com.unciv.ui.components.input.onClick -import com.unciv.ui.components.extensions.toLabel -import com.unciv.ui.components.extensions.toTextButton class MapEditorModsTab( private val editorScreen: MapEditorScreen diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorOptionsTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorOptionsTab.kt index 05a5fdb956..66520e02fa 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorOptionsTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorOptionsTab.kt @@ -13,17 +13,17 @@ import com.unciv.logic.files.MapSaver import com.unciv.logic.map.MapShape import com.unciv.logic.map.MapSize import com.unciv.models.translations.tr -import com.unciv.ui.components.input.KeyCharAndCode import com.unciv.ui.components.TabbedPager import com.unciv.ui.components.UncivSlider import com.unciv.ui.components.extensions.addSeparator import com.unciv.ui.components.extensions.isEnabled -import com.unciv.ui.components.input.keyShortcuts -import com.unciv.ui.components.input.onActivation -import com.unciv.ui.components.input.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.components.input.KeyCharAndCode +import com.unciv.ui.components.input.keyShortcuts +import com.unciv.ui.components.input.onActivation +import com.unciv.ui.components.input.onClick import com.unciv.ui.popups.ToastPopup import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorSaveTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorSaveTab.kt index 21de04cc25..db588eab99 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorSaveTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorSaveTab.kt @@ -9,22 +9,22 @@ import com.unciv.logic.files.MapSaver import com.unciv.logic.map.MapGeneratedMainType import com.unciv.logic.map.TileMap import com.unciv.models.translations.tr -import com.unciv.ui.screens.mapeditorscreen.MapEditorFilesTable -import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen -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.input.KeyCharAndCode import com.unciv.ui.components.TabbedPager import com.unciv.ui.components.UncivTextField import com.unciv.ui.components.extensions.isEnabled +import com.unciv.ui.components.extensions.toTextButton +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.onChange import com.unciv.ui.components.input.onClick -import com.unciv.ui.components.extensions.toTextButton +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.mapeditorscreen.MapEditorFilesTable +import com.unciv.ui.screens.mapeditorscreen.MapEditorScreen import com.unciv.utils.Concurrency import com.unciv.utils.Log import kotlinx.coroutines.CoroutineScope diff --git a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorViewTab.kt b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorViewTab.kt index 0bd1ebde7f..08b329737b 100644 --- a/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorViewTab.kt +++ b/core/src/com/unciv/ui/screens/mapeditorscreen/tabs/MapEditorViewTab.kt @@ -22,10 +22,10 @@ import com.unciv.ui.components.UncivSlider import com.unciv.ui.components.WrappableLabel import com.unciv.ui.components.extensions.addSeparator import com.unciv.ui.components.extensions.darken -import com.unciv.ui.components.input.onClick import com.unciv.ui.components.extensions.pad import com.unciv.ui.components.extensions.toLabel import com.unciv.ui.components.extensions.toTextButton +import com.unciv.ui.components.input.onClick import com.unciv.ui.popups.ToastPopup import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.screens.civilopediascreen.CivilopediaScreen