diff --git a/android/assets/jsons/Tutorials.json b/android/assets/jsons/Tutorials.json index a921081454..3c72091510 100644 --- a/android/assets/jsons/Tutorials.json +++ b/android/assets/jsons/Tutorials.json @@ -481,7 +481,11 @@ {"text":"Reveal known resources on world screen","header":5,"color":"#fa0"}, {"text":"In the Resources overview, click on a resource icon to center the world screen on tiles already discovered and providing this resource."}, {"text":"Alternatively, click on the \"Unimproved\" number to center the world screen only on owned tiles where the resource is not improved."}, - {"text":"If more than one tile is available, click repeatedly on the notification to cycle through all of them."} + {"text":"If more than one tile is available, click repeatedly on the notification to cycle through all of them."}, + {}, + {"text":"External links","header":5,"color":"#fa0"}, + {"text":"External links support right-click or long press to copy the link to the clipboard instead of launching the browser."}, + {"text":"Example: The 'Open Github page' button on the Mod management screen."} ] } ] diff --git a/android/assets/jsons/translations/template.properties b/android/assets/jsons/translations/template.properties index c5a1aa5465..0e23114dd9 100644 --- a/android/assets/jsons/translations/template.properties +++ b/android/assets/jsons/translations/template.properties @@ -1830,6 +1830,7 @@ Mods of mods = Mod info and options = Next page = Open Github page = +Link copied to clipboard = Permanent audiovisual mod = Installed = Downloaded! = diff --git a/core/src/com/unciv/Constants.kt b/core/src/com/unciv/Constants.kt index 0300785b7c..6caa47a2d1 100644 --- a/core/src/com/unciv/Constants.kt +++ b/core/src/com/unciv/Constants.kt @@ -106,4 +106,10 @@ object Constants { const val defaultFontSize = 18 const val headingFontSize = 24 + + /** URL to the root of the Unciv repository, including trailing slash */ + // Note: Should the project move, this covers external links, but not comments e.g. mentioning issues + const val uncivRepoURL = "https://github.com/yairm210/Unciv/" + /** URL to the wiki, including trailing slash */ + const val wikiURL = "https://yairm210.github.io/Unciv/" } diff --git a/core/src/com/unciv/ui/components/widgets/LanguageTable.kt b/core/src/com/unciv/ui/components/widgets/LanguageTable.kt index 0dc555022a..32f5f088dd 100644 --- a/core/src/com/unciv/ui/components/widgets/LanguageTable.kt +++ b/core/src/com/unciv/ui/components/widgets/LanguageTable.kt @@ -59,7 +59,7 @@ internal class LanguageTable(val language:String, val percentComplete: Int) : Ta text = "Please note that translations are a community-based work in progress and are" + " INCOMPLETE! The percentage shown is how much of the language is translated in-game." + " If you want to help translating the game into your language, click here.", - link = "https://yairm210.github.io/Unciv/Other/Translating/", + link = "${Constants.wikiURL}Translating/", size = 15 ) add(MarkupRenderer.render(listOf(translationDisclaimer),expectedWidth)).pad(5f).row() diff --git a/core/src/com/unciv/ui/crashhandling/CrashScreen.kt b/core/src/com/unciv/ui/crashhandling/CrashScreen.kt index 886b483396..9d8ddf02bd 100644 --- a/core/src/com/unciv/ui/crashhandling/CrashScreen.kt +++ b/core/src/com/unciv/ui/crashhandling/CrashScreen.kt @@ -192,7 +192,7 @@ class CrashScreen(val exception: Throwable) : BaseScreen() { ) .onClick { if (copied) { - Gdx.net.openURI("https://github.com/yairm210/Unciv/issues") + Gdx.net.openURI("${Constants.uncivRepoURL}issues") } else { ToastPopup( "Please copy the error report first.", diff --git a/core/src/com/unciv/ui/popups/options/AboutTab.kt b/core/src/com/unciv/ui/popups/options/AboutTab.kt index 46396b1f10..2c8a9e412f 100644 --- a/core/src/com/unciv/ui/popups/options/AboutTab.kt +++ b/core/src/com/unciv/ui/popups/options/AboutTab.kt @@ -1,6 +1,7 @@ package com.unciv.ui.popups.options import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.Constants import com.unciv.UncivGame import com.unciv.ui.screens.civilopediascreen.FormattedLine import com.unciv.ui.screens.civilopediascreen.MarkupRenderer @@ -10,9 +11,10 @@ fun aboutTab(): Table { val lines = sequence { yield(FormattedLine(extraImage = "banner", imageSize = 240f, centered = true)) yield(FormattedLine()) - yield(FormattedLine("{Version}: ${UncivGame.VERSION.toNiceString()}", link = "https://github.com/yairm210/Unciv/blob/master/changelog.md#$versionAnchor")) - yield(FormattedLine("See online Readme", link = "https://github.com/yairm210/Unciv/blob/master/README.md#unciv---foss-civ-v-for-androiddesktop")) - yield(FormattedLine("Visit repository", link = "https://github.com/yairm210/Unciv")) + yield(FormattedLine("{Version}: ${UncivGame.VERSION.toNiceString()}", link = "${Constants.uncivRepoURL}blob/master/changelog.md#$versionAnchor")) + yield(FormattedLine("See online Readme", link = "${Constants.uncivRepoURL}blob/master/README.md#unciv---foss-civ-v-for-androiddesktop")) + yield(FormattedLine("Visit repository", link = Constants.uncivRepoURL)) + yield(FormattedLine("Visit the wiki", link = Constants.wikiURL)) } return MarkupRenderer.render(lines.asIterable()).pad(20f) } diff --git a/core/src/com/unciv/ui/screens/civilopediascreen/MarkupRenderer.kt b/core/src/com/unciv/ui/screens/civilopediascreen/MarkupRenderer.kt index 154d8cda7a..197e8cc0f8 100644 --- a/core/src/com/unciv/ui/screens/civilopediascreen/MarkupRenderer.kt +++ b/core/src/com/unciv/ui/screens/civilopediascreen/MarkupRenderer.kt @@ -3,9 +3,11 @@ package com.unciv.ui.screens.civilopediascreen import com.badlogic.gdx.Gdx import com.badlogic.gdx.scenes.scene2d.ui.Table import com.badlogic.gdx.utils.Align -import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.components.extensions.addSeparator import com.unciv.ui.components.input.onClick +import com.unciv.ui.components.input.onRightClick +import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.screens.civilopediascreen.MarkupRenderer.render /** Makes [renderer][render] available outside [ICivilopediaText] */ @@ -51,10 +53,14 @@ object MarkupRenderer { actor.onClick { linkAction(line.link) } - else if (line.linkType == FormattedLine.LinkType.External) + else if (line.linkType == FormattedLine.LinkType.External) { actor.onClick { Gdx.net.openURI(line.link) } + actor.onRightClick { + Gdx.app.clipboard.contents = line.link + } + } if (labelWidth == 0f) table.add(actor).align(line.align).row() else diff --git a/core/src/com/unciv/ui/screens/modmanager/ModInfoAndActionPane.kt b/core/src/com/unciv/ui/screens/modmanager/ModInfoAndActionPane.kt index b6f56122cd..2c920e1b9c 100644 --- a/core/src/com/unciv/ui/screens/modmanager/ModInfoAndActionPane.kt +++ b/core/src/com/unciv/ui/screens/modmanager/ModInfoAndActionPane.kt @@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.scenes.scene2d.ui.Image import com.badlogic.gdx.scenes.scene2d.ui.Table +import com.unciv.logic.github.Github import com.unciv.logic.github.GithubAPI import com.unciv.models.metadata.BaseRuleset import com.unciv.models.ruleset.Ruleset @@ -15,7 +16,8 @@ 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.onClick -import com.unciv.logic.github.Github +import com.unciv.ui.components.input.onRightClick +import com.unciv.ui.popups.ToastPopup import com.unciv.utils.Concurrency import kotlin.math.max @@ -87,9 +89,15 @@ internal class ModInfoAndActionPane : Table() { // offer link to open the repo itself in a browser if (repoUrl.isNotEmpty()) { - add("Open Github page".toTextButton().onClick { + val githubButton = "Open Github page".toTextButton() + githubButton.onClick { Gdx.net.openURI(repoUrl) - }).row() + } + githubButton.onRightClick { + Gdx.app.clipboard.contents = repoUrl + ToastPopup("Link copied to clipboard", stage) + } + add(githubButton).row() } // display "updated" date diff --git a/core/src/com/unciv/ui/screens/multiplayerscreens/MultiplayerHelpers.kt b/core/src/com/unciv/ui/screens/multiplayerscreens/MultiplayerHelpers.kt index 37c43287e0..3a540e29bf 100644 --- a/core/src/com/unciv/ui/screens/multiplayerscreens/MultiplayerHelpers.kt +++ b/core/src/com/unciv/ui/screens/multiplayerscreens/MultiplayerHelpers.kt @@ -1,15 +1,16 @@ package com.unciv.ui.screens.multiplayerscreens import com.badlogic.gdx.Gdx +import com.unciv.Constants import com.unciv.UncivGame import com.unciv.logic.multiplayer.OnlineMultiplayer import com.unciv.logic.multiplayer.OnlineMultiplayerGame import com.unciv.models.translations.tr -import com.unciv.ui.popups.Popup -import com.unciv.ui.screens.savescreens.LoadGameScreen -import com.unciv.ui.screens.basescreen.BaseScreen import com.unciv.ui.components.extensions.formatShort import com.unciv.ui.components.extensions.toCheckBox +import com.unciv.ui.popups.Popup +import com.unciv.ui.screens.basescreen.BaseScreen +import com.unciv.ui.screens.savescreens.LoadGameScreen import com.unciv.utils.Concurrency import com.unciv.utils.launchOnGLThread import java.time.Duration @@ -61,7 +62,7 @@ object MultiplayerHelpers { "Consider using a custom server instead." ).colspan(2).row() dropboxWarning.addButton("Open Documentation") { - Gdx.net.openURI("https://yairm210.github.io/Unciv/Other/Multiplayer/#hosting-a-multiplayer-server") + Gdx.net.openURI("${Constants.wikiURL}Other/Multiplayer/#hosting-a-multiplayer-server") }.colspan(2).row() val checkBox = "Don't show again".toCheckBox()