2009-01-12 17:11:45 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
/** @file script_sign.hpp Everything to query and build signs. */
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#ifndef SCRIPT_SIGN_HPP
|
|
|
|
#define SCRIPT_SIGN_HPP
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-12-19 21:00:40 +00:00
|
|
|
#include "script_company.hpp"
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_error.hpp"
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all sign related functions.
|
2011-12-19 20:59:29 +00:00
|
|
|
* @api ai game
|
2009-01-12 17:11:45 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptSign : public ScriptObject {
|
2009-01-12 17:11:45 +00:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* All sign related error messages.
|
|
|
|
*/
|
|
|
|
enum ErrorMessages {
|
|
|
|
|
|
|
|
/** Base for sign building related errors */
|
2011-11-29 23:15:35 +00:00
|
|
|
ERR_SIGN_BASE = ScriptError::ERR_CAT_SIGN << ScriptError::ERR_CAT_BIT_SIZE,
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/** Too many signs have been placed */
|
2009-04-21 23:40:56 +00:00
|
|
|
ERR_SIGN_TOO_MANY_SIGNS, // [STR_ERROR_TOO_MANY_SIGNS]
|
2009-01-12 17:11:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Checks whether the given sign index is valid.
|
|
|
|
* @param sign_id The index to check.
|
|
|
|
* @return True if and only if the sign is valid.
|
|
|
|
*/
|
|
|
|
static bool IsValidSign(SignID sign_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the name of a sign.
|
|
|
|
* @param sign_id The sign to set the name for.
|
2011-12-19 21:06:06 +00:00
|
|
|
* @param name The name for the sign (can be either a raw string, or a ScriptText object).
|
2009-01-12 17:11:45 +00:00
|
|
|
* @pre IsValidSign(sign_id).
|
2011-12-19 21:06:06 +00:00
|
|
|
* @pre name != NULL && len(name) != 0.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return True if and only if the name was changed.
|
|
|
|
*/
|
2011-12-19 21:06:06 +00:00
|
|
|
static bool SetName(SignID sign_id, Text *name);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the sign.
|
|
|
|
* @param sign_id The sign to get the name of.
|
|
|
|
* @pre IsValidSign(sign_id).
|
|
|
|
* @return The name of the sign.
|
|
|
|
*/
|
2009-01-17 15:31:30 +00:00
|
|
|
static char *GetName(SignID sign_id);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
2011-12-19 21:00:40 +00:00
|
|
|
/**
|
|
|
|
* Get the owner of a sign.
|
|
|
|
* @param sign_id The sign to get the owner of.
|
|
|
|
* @pre IsValidSign(sign_id).
|
|
|
|
* @return The owner the sign has.
|
|
|
|
* @api -ai
|
|
|
|
*/
|
|
|
|
static ScriptCompany::CompanyID GetOwner(SignID sign_id);
|
|
|
|
|
2009-01-12 17:11:45 +00:00
|
|
|
/**
|
|
|
|
* Gets the location of the sign.
|
|
|
|
* @param sign_id The sign to get the location of.
|
|
|
|
* @pre IsValidSign(sign_id).
|
|
|
|
* @return The location of the sign.
|
|
|
|
*/
|
|
|
|
static TileIndex GetLocation(SignID sign_id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Builds a sign on the map.
|
|
|
|
* @param location The place to build the sign.
|
2011-12-19 21:06:06 +00:00
|
|
|
* @param name The text to place on the sign (can be either a raw string, or a ScriptText object).
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptMap::IsValidTile(location).
|
2011-12-19 21:06:06 +00:00
|
|
|
* @pre name != NULL && len(name) != 0.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @exception ScriptSign::ERR_SIGN_TOO_MANY_SIGNS
|
2009-01-12 17:11:45 +00:00
|
|
|
* @return The SignID of the build sign (use IsValidSign() to check for validity).
|
|
|
|
* In test-mode it returns 0 if successful, or any other value to indicate
|
|
|
|
* failure.
|
|
|
|
*/
|
2011-12-19 21:06:06 +00:00
|
|
|
static SignID BuildSign(TileIndex location, Text *name);
|
2009-01-12 17:11:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a sign from the map.
|
|
|
|
* @param sign_id The sign to remove.
|
|
|
|
* @pre IsValidSign(sign_id).
|
|
|
|
* @return True if and only if the sign has been removed.
|
|
|
|
*/
|
|
|
|
static bool RemoveSign(SignID sign_id);
|
|
|
|
};
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_SIGN_HPP */
|