From 8d0acd064739a60985ad09844979169ade8850b0 Mon Sep 17 00:00:00 2001 From: letstalkaboutdune <56904240+letstalkaboutdune@users.noreply.github.com> Date: Sat, 24 Dec 2022 09:41:35 -0800 Subject: [PATCH] Added keyboard shortcut to toggle World Screen UI elements (#8211) * AbsoluteUnits - Mongolian Uniques * Added keyboard shortcut to toggle World Screen UI elements Ctrl+U to toggle * Update WorldScreen.kt * Added a pesky space * Remove "Experimental" warning text * Revert "Remove "Experimental" warning text" This reverts commit 3c8456db95202c3f99edb4aceeb4777b19ec3fad. --- android/assets/jsons/Tutorials.json | 2 +- .../jsons/translations/template.properties | 1 + .../com/unciv/ui/worldscreen/WorldScreen.kt | 65 ++++++++++++------- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/android/assets/jsons/Tutorials.json b/android/assets/jsons/Tutorials.json index e3a4154449..b352dc2da4 100644 --- a/android/assets/jsons/Tutorials.json +++ b/android/assets/jsons/Tutorials.json @@ -232,7 +232,7 @@ "If you have a keyboard, some shortcut keys become available. Unit command or improvement picker keys, for example, are shown directly in their corresponding buttons.", "On the world screen the hotkeys are as follows:", "Space or 'N' - Next unit or turn\n'E' - Empire overview (last viewed page)\n'+', '-' - Zoom in / out\nHome - center on capital or open its city screen if already centered", "F1 - Open Civilopedia\nF2 - Empire overview Trades\nF3 - Empire overview Units\nF4 - Empire overview Diplomacy\nF5 - Social policies\nF6 - Technologies\nF7 - Empire overview Cities\nF8 - Victory Progress\nF9 - Empire overview Stats\nF10 - Empire overview Resources\nF11 - Quicksave\nF12 - Quickload", - "Ctrl-R - Toggle tile resource display\nCtrl-Y - Toggle tile yield display\nCtrl-O - Game options\nCtrl-S - Save game\nCtrl-L - Load game" + "Ctrl-R - Toggle tile resource display\nCtrl-Y - Toggle tile yield display\nCtrl-O - Game options\nCtrl-S - Save game\nCtrl-L - Load game\nCtrl-U - Toggle UI (World Screen only)" ] }, { diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index d069ce196d..1de40e1fe1 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1425,6 +1425,7 @@ Pillaging this improvement yields [stats] = Pillaging this improvement yields approximately [stats] = Needs removal of terrain features to be built = Unit type = +Toggle UI (World Screen only) = # Policies diff --git a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt index 748e11ecf2..a8bc2a36ec 100644 --- a/core/src/com/unciv/ui/worldscreen/WorldScreen.kt +++ b/core/src/com/unciv/ui/worldscreen/WorldScreen.kt @@ -133,6 +133,8 @@ class WorldScreen( private val events = EventBus.EventReceiver() + var uiEnabled = true + init { // notifications are right-aligned, they take up only as much space as necessary. @@ -254,6 +256,21 @@ class WorldScreen( globalShortcuts.add(KeyCharAndCode.ctrl('Q')) { game.popScreen() } // WorldScreen is the last screen, so this quits globalShortcuts.add(Input.Keys.NUMPAD_ADD) { this.mapHolder.zoomIn() } // '+' Zoom globalShortcuts.add(Input.Keys.NUMPAD_SUBTRACT) { this.mapHolder.zoomOut() } // '-' Zoom + + globalShortcuts.add(KeyCharAndCode.ctrl('U')){ + uiEnabled = !uiEnabled + topBar.isVisible = uiEnabled + statusButtons.isVisible = uiEnabled + techPolicyAndDiplomacy.isVisible = uiEnabled + tutorialTaskTable.isVisible = uiEnabled + bottomTileInfoTable.isVisible = uiEnabled + unitActionsTable.isVisible = uiEnabled + notificationsScroll.isVisible = uiEnabled + minimapWrapper.isVisible = uiEnabled + bottomUnitTable.isVisible = uiEnabled + battleTable.isVisible = uiEnabled && battleTable.update() != hide() + fogOfWarButton.isVisible = uiEnabled && viewingCiv.isSpectator() + } } private fun addKeyboardListener() { @@ -362,35 +379,37 @@ class WorldScreen( // and we don't get any silly concurrency problems! private fun update() { - displayTutorialsOnUpdate() + if(uiEnabled){ + displayTutorialsOnUpdate() - bottomUnitTable.update() - bottomTileInfoTable.updateTileTable(mapHolder.selectedTile) - bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width - bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height else 0f - battleTable.update() + bottomUnitTable.update() + bottomTileInfoTable.updateTileTable(mapHolder.selectedTile) + bottomTileInfoTable.x = stage.width - bottomTileInfoTable.width + bottomTileInfoTable.y = if (game.settings.showMinimap) minimapWrapper.height else 0f + battleTable.update() - updateSelectedCiv() + updateSelectedCiv() - tutorialTaskTable.clear() - val tutorialTask = getCurrentTutorialTask() - if (tutorialTask == "" || !game.settings.showTutorials || viewingCiv.isDefeated()) { - tutorialTaskTable.isVisible = false - } else { - tutorialTaskTable.isVisible = true - tutorialTaskTable.add(tutorialTask.toLabel() + tutorialTaskTable.clear() + val tutorialTask = getCurrentTutorialTask() + if (tutorialTask == "" || !game.settings.showTutorials || viewingCiv.isDefeated()) { + tutorialTaskTable.isVisible = false + } else { + tutorialTaskTable.isVisible = true + tutorialTaskTable.add(tutorialTask.toLabel() .apply { setAlignment(Align.center) }).pad(10f) - tutorialTaskTable.pack() - tutorialTaskTable.centerX(stage) - tutorialTaskTable.y = topBar.y - tutorialTaskTable.height + tutorialTaskTable.pack() + tutorialTaskTable.centerX(stage) + tutorialTaskTable.y = topBar.y - tutorialTaskTable.height + } + + if (fogOfWar) minimapWrapper.update(selectedCiv) + else minimapWrapper.update(viewingCiv) + + unitActionsTable.update(bottomUnitTable.selectedUnit) + unitActionsTable.y = bottomUnitTable.height } - if (fogOfWar) minimapWrapper.update(selectedCiv) - else minimapWrapper.update(viewingCiv) - - unitActionsTable.update(bottomUnitTable.selectedUnit) - unitActionsTable.y = bottomUnitTable.height - mapHolder.resetArrows() if (UncivGame.Current.settings.showUnitMovements) { val allUnits = gameInfo.civilizations.asSequence().flatMap { it.getCivUnits() }