From ad48ab923764087bf66153d1c26ed0eb05a19989 Mon Sep 17 00:00:00 2001 From: truebrain Date: Mon, 19 Dec 2011 21:00:55 +0000 Subject: (svn r23626) -Add: ScriptTown::SetText, which adds custom text to the Town GUI --- src/script/api/game/game_town.hpp.sq | 1 + src/script/api/script_town.cpp | 6 ++++++ src/script/api/script_town.hpp | 10 ++++++++++ 3 files changed, 17 insertions(+) (limited to 'src/script') diff --git a/src/script/api/game/game_town.hpp.sq b/src/script/api/game/game_town.hpp.sq index b5837bc17..ad0dfe428 100644 --- a/src/script/api/game/game_town.hpp.sq +++ b/src/script/api/game/game_town.hpp.sq @@ -40,6 +40,7 @@ void SQGSTown_Register(Squirrel *engine) SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetTownCount, "GetTownCount", 1, "."); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::IsValidTown, "IsValidTown", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetName, "GetName", 2, ".i"); + SQGSTown.DefSQStaticMethod(engine, &ScriptTown::SetText, "SetText", 3, ".i."); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetPopulation, "GetPopulation", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetHouseCount, "GetHouseCount", 2, ".i"); SQGSTown.DefSQStaticMethod(engine, &ScriptTown::GetLocation, "GetLocation", 2, ".i"); diff --git a/src/script/api/script_town.cpp b/src/script/api/script_town.cpp index d213f1d0d..081bccd51 100644 --- a/src/script/api/script_town.cpp +++ b/src/script/api/script_town.cpp @@ -43,6 +43,12 @@ return town_name; } +/* static */ bool ScriptTown::SetText(TownID town_id, const char *text) +{ + EnforcePrecondition(false, IsValidTown(town_id)); + return ScriptObject::DoCommand(::Town::Get(town_id)->xy, town_id, 0, CMD_TOWN_SET_TEXT, text); +} + /* static */ int32 ScriptTown::GetPopulation(TownID town_id) { if (!IsValidTown(town_id)) return -1; diff --git a/src/script/api/script_town.hpp b/src/script/api/script_town.hpp index 0cee78694..d7f0c44f3 100644 --- a/src/script/api/script_town.hpp +++ b/src/script/api/script_town.hpp @@ -127,6 +127,16 @@ public: */ static char *GetName(TownID town_id); + /** + * Set the custom text of a town, shown in the GUI. + * @param town_id The town to set the custom text of. + * @param text The text to set it to. + * @pre IsValidTown(town_id). + * @return True if the action succeeded. + * @api -ai + */ + static bool SetText(TownID town_id, const char *text); + /** * Gets the number of inhabitants in the town. * @param town_id The town to get the population of. -- cgit v1.2.3-70-g09d2