Skip to content

Commit

Permalink
Add LinkAction (yairm210#12542)
Browse files Browse the repository at this point in the history
* Add LinkAction

* fix generated stuff (tested in desktop)
  • Loading branch information
touhidurrr authored Dec 2, 2024
1 parent 8a376de commit b1f1998
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/com/unciv/logic/civilization/NotificationActions.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.unciv.logic.civilization

import com.badlogic.gdx.Gdx
import com.badlogic.gdx.math.Vector2
import com.badlogic.gdx.utils.Json
import com.badlogic.gdx.utils.JsonValue
Expand Down Expand Up @@ -182,6 +183,13 @@ class EspionageAction : NotificationAction {
}
}

class LinkAction(private val url: String = "") : NotificationAction {
override fun execute(worldScreen: WorldScreen) {
if (url.isNotEmpty()) {
Gdx.net.openURI(url);
}
}
}

@Suppress("PrivatePropertyName") // These names *must* match their class name, see below
internal class NotificationActionsDeserializer {
Expand All @@ -206,13 +214,14 @@ internal class NotificationActionsDeserializer {
private val OverviewAction: OverviewAction? = null
private val PolicyAction: PolicyAction? = null
private val EspionageAction: EspionageAction? = null
private val LinkAction: LinkAction? = null

fun read(json: Json, jsonData: JsonValue): List<NotificationAction> {
json.readFields(this, jsonData)
return listOfNotNull(
LocationAction, TechAction, CityAction, DiplomacyAction, MayaLongCountAction,
MapUnitAction, CivilopediaAction, PromoteUnitAction, OverviewAction, PolicyAction,
EspionageAction
EspionageAction, LinkAction
)
}
}

0 comments on commit b1f1998

Please sign in to comment.