From 0c55d70b5d7ed27319f7d848fe8aead052c07948 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 7 Dec 2021 04:22:45 +0200
Subject: [PATCH 42/42] Lua: Add support for creating featured text links

See osdn #43343

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/scriptcore/api_game_methods.c | 56 ++++++++++++++++++++++++++++
 common/scriptcore/api_game_methods.h |  7 ++++
 common/scriptcore/tolua_game.pkg     | 13 +++++++
 3 files changed, 76 insertions(+)

diff --git a/common/scriptcore/api_game_methods.c b/common/scriptcore/api_game_methods.c
index 7b68a2856a..66736c0a99 100644
--- a/common/scriptcore/api_game_methods.c
+++ b/common/scriptcore/api_game_methods.c
@@ -24,6 +24,7 @@
 #include "calendar.h"
 #include "citizens.h"
 #include "culture.h"
+#include "featured_text.h"
 #include "game.h"
 #include "government.h"
 #include "improvement.h"
@@ -1256,3 +1257,58 @@ City_List_Link *api_methods_city_list_next_link(lua_State *L,
 
   return city_list_link_next(cl_link);
 }
+
+/**********************************************************************//**
+  Return featured text link of the tile.
+**************************************************************************/
+const char *api_methods_tile_link(lua_State *L, Tile *ptile)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, ptile, NULL);
+
+  return tile_link(ptile);
+}
+
+/**********************************************************************//**
+  Return featured text link of the unit tile.
+**************************************************************************/
+const char *api_methods_unit_tile_link(lua_State *L, Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, punit, NULL);
+
+  return unit_tile_link(punit);
+}
+
+/**********************************************************************//**
+  Return featured text link of the city tile.
+**************************************************************************/
+const char *api_methods_city_tile_link(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, NULL);
+
+  return city_tile_link(pcity);
+}
+
+/**********************************************************************//**
+  Return featured text link of the unit.
+**************************************************************************/
+const char *api_methods_unit_link(lua_State *L, Unit *punit)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, punit, NULL);
+
+  return unit_link(punit);
+}
+
+/**********************************************************************//**
+  Return featured text link of the city.
+**************************************************************************/
+const char *api_methods_city_link(lua_State *L, City *pcity)
+{
+  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_SELF(L, pcity, NULL);
+
+  return city_link(pcity);
+}
diff --git a/common/scriptcore/api_game_methods.h b/common/scriptcore/api_game_methods.h
index fc823c61fc..bacc9077af 100644
--- a/common/scriptcore/api_game_methods.h
+++ b/common/scriptcore/api_game_methods.h
@@ -180,6 +180,13 @@ City *api_methods_city_list_link_data(lua_State *L, City_List_Link *link);
 City_List_Link *api_methods_city_list_next_link(lua_State *L,
                                                 City_List_Link *link);
 
+/* Featured text */
+const char *api_methods_tile_link(lua_State *L, Tile *ptile);
+const char *api_methods_unit_link(lua_State *L, Unit *punit);
+const char *api_methods_unit_tile_link(lua_State *L, Unit *punit);
+const char *api_methods_city_link(lua_State *L, City *pcity);
+const char *api_methods_city_tile_link(lua_State *L, City *pcity);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/common/scriptcore/tolua_game.pkg b/common/scriptcore/tolua_game.pkg
index 27429d49da..9aa7bfd90f 100644
--- a/common/scriptcore/tolua_game.pkg
+++ b/common/scriptcore/tolua_game.pkg
@@ -231,6 +231,11 @@ module City {
     @ is_capital(lua_State *L, City *self);
   bool api_methods_is_primary_capital
     @ is_primary_capital(lua_State *L, City *self);
+
+  const char *api_methods_city_link
+    @ link_text(lua_State *L, City *self);
+  const char *api_methods_city_tile_link
+    @ tile_link_text(lua_State *L, City *self);
 }
 
 $[
@@ -255,6 +260,11 @@ module Unit {
     @ is_on_possible_city_tile (lua_State *L, Unit *self);
   Direction *api_methods_unit_orientation_get
     @ facing(lua_State *L, Unit *self);
+
+  const char *api_methods_unit_link
+    @ link_text(lua_State *L, Unit *self);
+  const char *api_methods_unit_tile_link
+    @ tile_link_text(lua_State *L, Unit *self);
 }
 
 module methods_private {
@@ -287,6 +297,9 @@ module Tile {
       @ x (lua_State *L, Tile *self);
     int api_methods_tile_map_y
       @ y (lua_State *L, Tile *self);
+
+    const char *api_methods_tile_link
+      @ link_text(lua_State *L, Tile *self);
   }
 
   City *api_methods_tile_city
-- 
2.33.0