Update readme.md
[openttd-joker.git] / src / script / api / script_sign.hpp
blobe7bc0bbad9b27c7a1a66660f0c10850a4e273a16
1 /* $Id: script_sign.hpp 23636 2011-12-19 21:06:06Z truebrain $ */
3 /*
4 * This file is part of OpenTTD.
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 */
10 /** @file script_sign.hpp Everything to query and build signs. */
12 #ifndef SCRIPT_SIGN_HPP
13 #define SCRIPT_SIGN_HPP
15 #include "script_company.hpp"
16 #include "script_error.hpp"
18 /**
19 * Class that handles all sign related functions.
20 * @api ai game
22 class ScriptSign : public ScriptObject {
23 public:
24 /**
25 * All sign related error messages.
27 enum ErrorMessages {
29 /** Base for sign building related errors */
30 ERR_SIGN_BASE = ScriptError::ERR_CAT_SIGN << ScriptError::ERR_CAT_BIT_SIZE,
32 /** Too many signs have been placed */
33 ERR_SIGN_TOO_MANY_SIGNS, // [STR_ERROR_TOO_MANY_SIGNS]
36 /**
37 * Checks whether the given sign index is valid.
38 * @param sign_id The index to check.
39 * @return True if and only if the sign is valid.
41 static bool IsValidSign(SignID sign_id);
43 /**
44 * Set the name of a sign.
45 * @param sign_id The sign to set the name for.
46 * @param name The name for the sign (can be either a raw string, or a ScriptText object).
47 * @pre IsValidSign(sign_id).
48 * @pre name != nullptr && len(name) != 0.
49 * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
50 * @return True if and only if the name was changed.
52 static bool SetName(SignID sign_id, Text *name);
54 /**
55 * Get the name of the sign.
56 * @param sign_id The sign to get the name of.
57 * @pre IsValidSign(sign_id).
58 * @return The name of the sign.
60 static char *GetName(SignID sign_id);
62 /**
63 * Get the owner of a sign.
64 * @param sign_id The sign to get the owner of.
65 * @pre IsValidSign(sign_id).
66 * @return The owner the sign has.
67 * @api -ai
69 static ScriptCompany::CompanyID GetOwner(SignID sign_id);
71 /**
72 * Gets the location of the sign.
73 * @param sign_id The sign to get the location of.
74 * @pre IsValidSign(sign_id).
75 * @return The location of the sign.
77 static TileIndex GetLocation(SignID sign_id);
79 /**
80 * Builds a sign on the map.
81 * @param location The place to build the sign.
82 * @param name The text to place on the sign (can be either a raw string, or a ScriptText object).
83 * @pre ScriptMap::IsValidTile(location).
84 * @pre name != nullptr && len(name) != 0.
85 * @exception ScriptSign::ERR_SIGN_TOO_MANY_SIGNS
86 * @return The SignID of the build sign (use IsValidSign() to check for validity).
87 * In test-mode it returns 0 if successful, or any other value to indicate
88 * failure.
90 static SignID BuildSign(TileIndex location, Text *name);
92 /**
93 * Removes a sign from the map.
94 * @param sign_id The sign to remove.
95 * @pre IsValidSign(sign_id).
96 * @return True if and only if the sign has been removed.
98 static bool RemoveSign(SignID sign_id);
101 #endif /* SCRIPT_SIGN_HPP */