File diff r23496:661d21df67d7 → r23497:a0ab44ebd2fa
src/script/api/script_text.hpp
Show inline comments
 
@@ -24,49 +24,49 @@ public:
 
	/**
 
	 * Convert a ScriptText to a normal string.
 
	 * @return A string (in a static buffer), or NULL.
 
	 * @api -all
 
	 */
 
	virtual const char *GetEncodedText() = 0;
 

	
 
	/**
 
	 * Convert a #ScriptText into a decoded normal string.
 
	 * @return A string (in a static buffer), or NULL.
 
	 * @api -all
 
	 */
 
	const char *GetDecodedText();
 
};
 

	
 
/**
 
 * Internally used class to create a raw text in a Text object.
 
 * @api -all
 
 */
 
class RawText : public Text {
 
public:
 
	RawText(const char *text);
 
	~RawText();
 

	
 
	/* virtual */ const char *GetEncodedText() { return this->text; }
 
	const char *GetEncodedText() override { return this->text; }
 
private:
 
	const char *text;
 
};
 

	
 
/**
 
 * Class that handles all text related functions. You can define a language
 
 *  file in lang/english.txt, in the same format as OpenTTD does, including
 
 *  tags like {BLACK}, {STRING1} etc. The name given to this string is made
 
 *  available to you in ScriptText, for example: ScriptText.STR_NEWS, if your
 
 *  english.txt contains: STR_NEWS    :{BLACK}Welcome {COMPANY}!
 
 *
 
 * In translation files like lang/dutch.txt you can then translate such
 
 *  strings, like: STR_NEWS    :{BLACK}Hallo {COMPANY}!
 
 * When the user has the dutch language selected, it will automatically use
 
 *  the translated string when available. The fallback language is always
 
 *  the english language.
 
 *
 
 * If you use parameters in your strings, you will have to define those
 
 *  parameters, for example like this:
 
 * \code local text = ScriptText(ScriptText.STR_NEWS);
 
 * text.AddParam(1); \endcode
 
 * This will set the {COMPANY} to the name of Company 1. Alternatively you
 
 *  can directly give those arguments to the ScriptText constructor, like this:
 
 * \code local text = ScriptText(ScriptText.STR_NEWS, 1); \endcode