From 3ea4f8bc82c67fbfec6da10d1990bcbb87aaae6c Mon Sep 17 00:00:00 2001 From: Yair Morgenstern Date: Fri, 6 Dec 2019 10:12:16 +0200 Subject: [PATCH] Resolved #1420 - Menu in the map editor no longer opens multiple times on subsequent clicks --- android/assets/mods/myFirstMod/jsons/Units.json | 13 +++++++++++++ android/build.gradle | 2 +- ...pEditorOptionsTable.kt => MapEditorMenuPopup.kt} | 2 +- core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt | 6 ++++-- 4 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 android/assets/mods/myFirstMod/jsons/Units.json rename core/src/com/unciv/ui/mapeditor/{MapEditorOptionsTable.kt => MapEditorMenuPopup.kt} (98%) diff --git a/android/assets/mods/myFirstMod/jsons/Units.json b/android/assets/mods/myFirstMod/jsons/Units.json new file mode 100644 index 0000000000..524362ba8e --- /dev/null +++ b/android/assets/mods/myFirstMod/jsons/Units.json @@ -0,0 +1,13 @@ +[ + { + name:"Warrior", + unitType:"Melee", + movement:2, + strength:12, + cost: 40, + hurryCostModifier:20, + obsoleteTech:"Metal Casting", + upgradesTo:"Swordsman", + attackSound:"nonmetalhit" + } +] \ No newline at end of file diff --git a/android/build.gradle b/android/build.gradle index d7b193fa85..b9b46e203d 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -41,7 +41,7 @@ android { release { // Don't add local save files and fonts to release, obviously aaptOptions { - ignoreAssetsPattern "!SaveFiles:!fonts:!maps:!music" + ignoreAssetsPattern "!SaveFiles:!fonts:!maps:!music:!mods" } minifyEnabled false diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt similarity index 98% rename from core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt rename to core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt index a5ec98da09..b9a64a7044 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorOptionsTable.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorMenuPopup.kt @@ -18,7 +18,7 @@ import com.unciv.ui.utils.onClick import com.unciv.ui.worldscreen.optionstable.DropBox import com.unciv.ui.worldscreen.optionstable.PopupTable -class MapEditorOptionsTable(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){ +class MapEditorMenuPopup(mapEditorScreen: MapEditorScreen): PopupTable(mapEditorScreen){ init{ val mapNameEditor = TextField(mapEditorScreen.mapName, skin) mapNameEditor.addListener{ mapEditorScreen.mapName=mapNameEditor.text; true } diff --git a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt index 815f968016..68a5e6b959 100644 --- a/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt +++ b/core/src/com/unciv/ui/mapeditor/MapEditorScreen.kt @@ -65,9 +65,11 @@ class MapEditorScreen(): CameraStageBaseScreen(){ stage.addActor(showHideEditorOptionsButton) - val optionsMenuButton = TextButton("Options".tr(), skin) + val optionsMenuButton = TextButton("Menu".tr(), skin) optionsMenuButton.onClick { - MapEditorOptionsTable(this) + if(stage.actors.any { it is MapEditorMenuPopup }) + return@onClick // already open + MapEditorMenuPopup(this) } optionsMenuButton.label.setFontSize(24) optionsMenuButton.labelCell.pad(20f)