1/* 2 * This file is part of OpenTTD. 3 * 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. 4 * 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. 5 * 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/>. 6 */ 7 8/** @file script_window.hpp Everything to handle window interaction. */ 9 10#ifndef SCRIPT_WINDOW_HPP 11#define SCRIPT_WINDOW_HPP 12 13#include "script_object.hpp" 14#include "../../window_type.h" 15#include "../../gfx_type.h" 16 17#include "../../widgets/ai_widget.h" 18#include "../../widgets/airport_widget.h" 19#include "../../widgets/autoreplace_widget.h" 20#include "../../widgets/bootstrap_widget.h" 21#include "../../widgets/bridge_widget.h" 22#include "../../widgets/build_vehicle_widget.h" 23#include "../../widgets/cheat_widget.h" 24#include "../../widgets/company_widget.h" 25#include "../../widgets/console_widget.h" 26#include "../../widgets/date_widget.h" 27#include "../../widgets/depot_widget.h" 28#include "../../widgets/dock_widget.h" 29#include "../../widgets/dropdown_widget.h" 30#include "../../widgets/engine_widget.h" 31#include "../../widgets/error_widget.h" 32#include "../../widgets/fios_widget.h" 33#include "../../widgets/framerate_widget.h" 34#include "../../widgets/genworld_widget.h" 35#include "../../widgets/goal_widget.h" 36#include "../../widgets/graph_widget.h" 37#include "../../widgets/group_widget.h" 38#include "../../widgets/highscore_widget.h" 39#include "../../widgets/industry_widget.h" 40#include "../../widgets/intro_widget.h" 41#include "../../widgets/main_widget.h" 42#include "../../widgets/misc_widget.h" 43#include "../../widgets/music_widget.h" 44#include "../../widgets/network_chat_widget.h" 45#include "../../widgets/network_content_widget.h" 46#include "../../widgets/network_widget.h" 47#include "../../widgets/newgrf_debug_widget.h" 48#include "../../widgets/newgrf_widget.h" 49#include "../../widgets/news_widget.h" 50#include "../../widgets/object_widget.h" 51#include "../../widgets/order_widget.h" 52#include "../../widgets/osk_widget.h" 53#include "../../widgets/rail_widget.h" 54#include "../../widgets/road_widget.h" 55#include "../../widgets/screenshot_widget.h" 56#include "../../widgets/settings_widget.h" 57#include "../../widgets/sign_widget.h" 58#include "../../widgets/smallmap_widget.h" 59#include "../../widgets/station_widget.h" 60#include "../../widgets/statusbar_widget.h" 61#include "../../widgets/subsidy_widget.h" 62#include "../../widgets/terraform_widget.h" 63#include "../../widgets/timetable_widget.h" 64#include "../../widgets/toolbar_widget.h" 65#include "../../widgets/town_widget.h" 66#include "../../widgets/transparency_widget.h" 67#include "../../widgets/tree_widget.h" 68#include "../../widgets/vehicle_widget.h" 69#include "../../widgets/viewport_widget.h" 70#include "../../widgets/waypoint_widget.h" 71#include "../../widgets/link_graph_legend_widget.h" 72#include "../../widgets/story_widget.h" 73 74/** 75 * Class that handles window interaction. A Window in OpenTTD has two imporant 76 * values. The WindowClass, and a Window number. The first indicates roughly 77 * which window it is. WC_TOWN_VIEW for example, is the view of a town. 78 * The Window number is a bit more complex, as it depends mostly on the 79 * WindowClass. For example for WC_TOWN_VIEW it is the TownID. In general a 80 * good rule of thumb is: either the number is always 0, or the ID of the 81 * object in question. 82 * In the comment at the widget enum, it is mentioned how the number is used. 83 * 84 * Note, that the detailed window layout is very version specific. 85 * Enum values might be added, changed or removed in future versions without notice 86 * in the changelog, and there won't be any means of compatibility. 87 * 88 * @api game 89 */ 90class ScriptWindow : public ScriptObject { 91public: 92 // @enum WindowNumberEnum ../../window_type.h@ENUM_WINDOWNUMBERENUM@ 93 // @endenum 94 95 // @enum WindowClass ../../window_type.h@ENUM_WINDOWCLASS@ 96 // @endenum 97 98 /** 99 * The colours in the game which you can use for text and highlights. 100 */ 101 enum TextColour { 102 /* Note: these values represent part of the in-game TextColour enum */ 103 TC_BLUE = ::TC_BLUE, ///< Blue colour. 104 TC_SILVER = ::TC_SILVER, ///< Silver colour. 105 TC_GOLD = ::TC_GOLD, ///< Gold colour. 106 TC_RED = ::TC_RED, ///< Red colour. 107 TC_PURPLE = ::TC_PURPLE, ///< Purple colour. 108 TC_LIGHT_BROWN = ::TC_LIGHT_BROWN, ///< Light brown colour. 109 TC_ORANGE = ::TC_ORANGE, ///< Orange colour. 110 TC_GREEN = ::TC_GREEN, ///< Green colour. 111 TC_YELLOW = ::TC_YELLOW, ///< Yellow colour. 112 TC_DARK_GREEN = ::TC_DARK_GREEN, ///< Dark green colour. 113 TC_CREAM = ::TC_CREAM, ///< Cream colour. 114 TC_BROWN = ::TC_BROWN, ///< Brown colour. 115 TC_WHITE = ::TC_WHITE, ///< White colour. 116 TC_LIGHT_BLUE = ::TC_LIGHT_BLUE, ///< Light blue colour. 117 TC_GREY = ::TC_GREY, ///< Grey colour. 118 TC_DARK_BLUE = ::TC_DARK_BLUE, ///< Dark blue colour. 119 TC_BLACK = ::TC_BLACK, ///< Black colour. 120 TC_INVALID = ::TC_INVALID, ///< Invalid colour. 121 }; 122 123 /** 124 * Special number values. 125 */ 126 enum NumberType { 127 NUMBER_ALL = 0xFFFFFFFF, ///< Value to select all windows of a class. 128 }; 129 130 /** 131 * Special widget values. 132 */ 133 enum WidgetType { 134 WIDGET_ALL = 0xFF, ///< Value to select all widgets of a window. 135 }; 136 137 /** 138 * Close a window. 139 * @param window The class of the window to close. 140 * @param number The number of the window to close, or NUMBER_ALL to close all of this class. 141 * @pre !ScriptGame::IsMultiplayer(). 142 */ 143 static void Close(WindowClass window, uint32 number); 144 145 /** 146 * Check if a window is open. 147 * @param window The class of the window to check for. 148 * @param number The number of the window to check for, or NUMBER_ALL to check for any in the class. 149 * @pre !ScriptGame::IsMultiplayer(). 150 * @return True if the window is open. 151 */ 152 static bool IsOpen(WindowClass window, uint32 number); 153 154 /** 155 * Highlight a widget in a window. 156 * @param window The class of the window to highlight a widget in. 157 * @param number The number of the window to highlight a widget in. 158 * @param widget The widget in the window to highlight, or WIDGET_ALL (in combination with TC_INVALID) to disable all widget highlighting on this window. 159 * @param colour The colour of the highlight, or TC_INVALID for disabling. 160 * @pre !ScriptGame::IsMultiplayer(). 161 * @pre number != NUMBER_ALL. 162 * @pre colour < TC_END || (widget == WIDGET_ALL && colour == TC_INVALID). 163 * @pre IsOpen(window, number). 164 */ 165 static void Highlight(WindowClass window, uint32 number, uint8 widget, TextColour colour); 166 167 // @enum .*Widgets ../../widgets/*_widget.h@ENUM_WIDGETS@ 168 // @endenum 169}; 170 171#endif /* SCRIPT_WINDOW_HPP */ 172