Files
@ r10750:3efcb08f2f72
Branch filter:
Location: cpp/openttd-patchpack/source/src/signs_gui.cpp - annotation
r10750:3efcb08f2f72
10.4 KiB
text/x-c
(svn r15083) -Add [NoAI]: added a console command to reload an AI (requested by Zuu)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 | r5751:9b4f4afbf71b r5751:9b4f4afbf71b r9111:983de9c5a848 r6420:01087f989fd1 r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r8107:82461791b7a2 r8107:82461791b7a2 r10208:ef8fcc3dc4ca r10208:ef8fcc3dc4ca r8790:550c9960067a r8790:550c9960067a r5751:9b4f4afbf71b r5751:9b4f4afbf71b r8116:df67d3c5e4fd r8114:866ed489ed98 r8130:bece2e5c7460 r8131:7a50db7be0ff r8139:4fc34c1bc2fb r8224:194097dc7288 r8224:194097dc7288 r9179:660680ae613d r9734:a275a2ebaa53 r10087:330fdda1e960 r5751:9b4f4afbf71b r8264:d493cb51fe8a r8264:d493cb51fe8a r8264:d493cb51fe8a r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r5751:9b4f4afbf71b r9734:a275a2ebaa53 r10647:62911ec68e89 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9316:61233b01525f r9734:a275a2ebaa53 r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9734:a275a2ebaa53 r9316:61233b01525f r10207:a1fc2f2a33db r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9316:61233b01525f r9316:61233b01525f r9316:61233b01525f r5751:9b4f4afbf71b r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9316:61233b01525f r5751:9b4f4afbf71b r5751:9b4f4afbf71b r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r7341:72820788b006 r5893:6c4fd9987e0f r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r5751:9b4f4afbf71b r6247:96e840dbefcc r5751:9b4f4afbf71b r9316:61233b01525f r5751:9b4f4afbf71b r7127:9394e882dc36 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r10182:13ce7c8953d0 r9179:660680ae613d r10182:13ce7c8953d0 r10499:570896340d7a r10182:13ce7c8953d0 r9179:660680ae613d r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r9734:a275a2ebaa53 r9179:660680ae613d r7127:9394e882dc36 r9913:5ef437117969 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r7127:9394e882dc36 r9179:660680ae613d r9305:8a6ac0fa8c78 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r10276:22abdd1aa57a r9897:9cbe1cc406a0 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9897:9cbe1cc406a0 r9179:660680ae613d r9897:9cbe1cc406a0 r9179:660680ae613d r9897:9cbe1cc406a0 r7127:9394e882dc36 r9179:660680ae613d r9913:5ef437117969 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r7127:9394e882dc36 r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9273:0df9c11598cc r9179:660680ae613d r9179:660680ae613d r7127:9394e882dc36 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r10157:85398815e83e r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9734:a275a2ebaa53 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9734:a275a2ebaa53 r9734:a275a2ebaa53 r7127:9394e882dc36 r9179:660680ae613d r9179:660680ae613d r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r7127:9394e882dc36 r9179:660680ae613d r10182:13ce7c8953d0 r9179:660680ae613d r7127:9394e882dc36 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r7127:9394e882dc36 r9285:acbf930223e4 r9179:660680ae613d r9285:acbf930223e4 r9285:acbf930223e4 r10295:c0e73453a31c r10295:c0e73453a31c r10295:c0e73453a31c r10182:13ce7c8953d0 r9179:660680ae613d r7127:9394e882dc36 r10295:c0e73453a31c r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r9285:acbf930223e4 r9179:660680ae613d r7127:9394e882dc36 r9179:660680ae613d r9179:660680ae613d r9179:660680ae613d r7127:9394e882dc36 r10547:46e9c74ed423 r10547:46e9c74ed423 r10547:46e9c74ed423 r10547:46e9c74ed423 r10547:46e9c74ed423 r9179:660680ae613d r7127:9394e882dc36 r7127:9394e882dc36 r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r9764:7294de81e1eb r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7341:72820788b006 r7127:9394e882dc36 r8019:cc25a5b61a28 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r9510:6d2f1c62ff65 r9510:6d2f1c62ff65 r10207:a1fc2f2a33db r10087:330fdda1e960 r9510:6d2f1c62ff65 r9510:6d2f1c62ff65 r9510:6d2f1c62ff65 r9510:6d2f1c62ff65 r9510:6d2f1c62ff65 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r7127:9394e882dc36 r9179:660680ae613d r7127:9394e882dc36 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 r10156:5d97c842d2d7 | /* $Id$ */
/** @file signs_gui.cpp The GUI for signs. */
#include "stdafx.h"
#include "openttd.h"
#include "gui.h"
#include "textbuf_gui.h"
#include "window_gui.h"
#include "company_gui.h"
#include "company_func.h"
#include "signs_base.h"
#include "signs_func.h"
#include "debug.h"
#include "variables.h"
#include "command_func.h"
#include "strings_func.h"
#include "core/alloc_func.hpp"
#include "window_func.h"
#include "map_func.h"
#include "gfx_func.h"
#include "viewport_func.h"
#include "querystring_gui.h"
#include "sortlist_type.h"
#include "string_func.h"
#include "table/strings.h"
#include "table/sprites.h"
struct SignList {
typedef GUIList<const Sign *> GUISignList;
static const Sign *last_sign;
GUISignList signs;
void BuildSignsList()
{
if (!this->signs.NeedRebuild()) return;
DEBUG(misc, 3, "Building sign list");
this->signs.Clear();
const Sign *si;
FOR_ALL_SIGNS(si) *this->signs.Append() = si;
this->signs.Compact();
this->signs.RebuildDone();
}
/** Sort signs by their name */
static int CDECL SignNameSorter(const Sign * const *a, const Sign * const *b)
{
static char buf_cache[64];
char buf[64];
SetDParam(0, (*a)->index);
GetString(buf, STR_SIGN_NAME, lastof(buf));
if (*b != last_sign) {
last_sign = *b;
SetDParam(0, (*b)->index);
GetString(buf_cache, STR_SIGN_NAME, lastof(buf_cache));
}
return strcasecmp(buf, buf_cache);
}
void SortSignsList()
{
if (!this->signs.Sort(&SignNameSorter)) return;
/* Reset the name sorter sort cache */
this->last_sign = NULL;
}
};
const Sign *SignList::last_sign = NULL;
struct SignListWindow : Window, SignList {
SignListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
{
this->vscroll.cap = 12;
this->resize.step_height = 10;
this->resize.height = this->height - 10 * 7; // minimum if 5 in the list
this->signs.ForceRebuild();
this->signs.NeedResort();
this->FindWindowPlacementAndResize(desc);
}
virtual void OnPaint()
{
BuildSignsList();
SortSignsList();
SetVScrollCount(this, this->signs.Length());
SetDParam(0, this->vscroll.count);
this->DrawWidgets();
/* No signs? */
int y = 16; // offset from top of widget
if (this->vscroll.count == 0) {
DrawString(2, y, STR_304A_NONE, TC_FROMSTRING);
return;
}
/* Start drawing the signs */
for (uint16 i = this->vscroll.pos; i < this->vscroll.cap + this->vscroll.pos && i < this->vscroll.count; i++) {
const Sign *si = this->signs[i];
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, 4, y + 1);
SetDParam(0, si->index);
DrawString(22, y, STR_SIGN_NAME, TC_YELLOW);
y += 10;
}
}
virtual void OnClick(Point pt, int widget)
{
if (widget == 3) {
uint32 id_v = (pt.y - 15) / 10;
if (id_v >= this->vscroll.cap) return;
id_v += this->vscroll.pos;
if (id_v >= this->vscroll.count) return;
const Sign *si = this->signs[id_v];
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
}
}
virtual void OnResize(Point new_size, Point delta)
{
this->vscroll.cap += delta.y / 10;
}
virtual void OnInvalidateData(int data)
{
if (data == 0) {
this->signs.ForceRebuild();
} else {
this->signs.ForceResort();
}
}
};
static const Widget _sign_list_widget[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_SIGN_LIST_CAPTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_STICKYBOX, RESIZE_LR, COLOUR_GREY, 346, 357, 0, 13, 0x0, STR_STICKY_BUTTON},
{ WWT_PANEL, RESIZE_RB, COLOUR_GREY, 0, 345, 14, 137, 0x0, STR_NULL},
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 14, 125, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 126, 137, 0x0, STR_RESIZE_BUTTON},
{ WIDGETS_END},
};
static const WindowDesc _sign_list_desc = {
WDP_AUTO, WDP_AUTO, 358, 138, 358, 138,
WC_SIGN_LIST, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
_sign_list_widget,
};
void ShowSignList()
{
AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
}
/**
* Actually rename the sign.
* @param index the sign to rename.
* @param text the new name.
* @return true if the window will already be removed after returning.
*/
static bool RenameSign(SignID index, const char *text)
{
bool remove = StrEmpty(text);
DoCommandP(0, index, 0, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_280C_CAN_T_CHANGE_SIGN_NAME)), NULL, text);
return remove;
}
enum QueryEditSignWidgets {
QUERY_EDIT_SIGN_WIDGET_TEXT = 3,
QUERY_EDIT_SIGN_WIDGET_OK,
QUERY_EDIT_SIGN_WIDGET_CANCEL,
QUERY_EDIT_SIGN_WIDGET_DELETE,
QUERY_EDIT_SIGN_WIDGET_PREVIOUS = QUERY_EDIT_SIGN_WIDGET_DELETE + 2,
QUERY_EDIT_SIGN_WIDGET_NEXT,
};
struct SignWindow : QueryStringBaseWindow, SignList {
SignID cur_sign;
SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_BYTES, desc)
{
this->caption = STR_280B_EDIT_SIGN_TEXT;
this->afilter = CS_ALPHANUMERAL;
this->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
UpdateSignEditWindow(si);
this->FindWindowPlacementAndResize(desc);
}
void UpdateSignEditWindow(const Sign *si)
{
char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0'
/* Display an empty string when the sign hasnt been edited yet */
if (si->name != NULL) {
SetDParam(0, si->index);
GetString(this->edit_str_buf, STR_SIGN_NAME, last_of);
} else {
GetString(this->edit_str_buf, STR_EMPTY, last_of);
}
*last_of = '\0';
this->cur_sign = si->index;
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_LENGTH_SIGN_NAME_PIXELS);
this->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
}
/**
* Returns a pointer to the (alphabetically) previous or next sign of the current sign.
* @param next false if the previous sign is wanted, true if the next sign is wanted
* @return pointer to the previous/next sign
*/
const Sign *PrevNextSign(bool next)
{
/* Rebuild the sign list */
this->signs.ForceRebuild();
this->signs.NeedResort();
this->BuildSignsList();
this->SortSignsList();
/* Search through the list for the current sign, excluding
* - the first sign if we want the previous sign or
* - the last sign if we want the next sign */
uint end = this->signs.Length() - (next ? 1 : 0);
for (uint i = next ? 0 : 1; i < end; i++) {
if (this->cur_sign == this->signs[i]->index) {
/* We've found the current sign, so return the sign before/after it */
return this->signs[i + (next ? 1 : -1)];
}
}
/* If we haven't found the current sign by now, return the last/first sign */
return this->signs[next ? 0 : this->signs.Length() - 1];
}
virtual void OnPaint()
{
SetDParam(0, this->caption);
this->DrawWidgets();
this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
}
virtual void OnClick(Point pt, int widget)
{
switch (widget) {
case QUERY_EDIT_SIGN_WIDGET_PREVIOUS:
case QUERY_EDIT_SIGN_WIDGET_NEXT: {
const Sign *si = this->PrevNextSign(widget == QUERY_EDIT_SIGN_WIDGET_NEXT);
/* Rebuild the sign list */
this->signs.ForceRebuild();
this->signs.NeedResort();
this->BuildSignsList();
this->SortSignsList();
/* Scroll to sign and reopen window */
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
UpdateSignEditWindow(si);
break;
}
case QUERY_EDIT_SIGN_WIDGET_DELETE:
/* Only need to set the buffer to null, the rest is handled as the OK button */
RenameSign(this->cur_sign, "");
/* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
break;
case QUERY_EDIT_SIGN_WIDGET_OK:
if (RenameSign(this->cur_sign, this->text.buf)) break;
/* FALL THROUGH */
case QUERY_EDIT_SIGN_WIDGET_CANCEL:
delete this;
break;
}
}
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
{
EventState state = ES_NOT_HANDLED;
switch (this->HandleEditBoxKey(QUERY_EDIT_SIGN_WIDGET_TEXT, key, keycode, state)) {
default: break;
case HEBR_CONFIRM:
if (RenameSign(this->cur_sign, this->text.buf)) break;
/* FALL THROUGH */
case HEBR_CANCEL: // close window, abandon changes
delete this;
break;
}
return state;
}
virtual void OnMouseLoop()
{
this->HandleEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
}
virtual void OnOpenOSKWindow(int wid)
{
ShowOnScreenKeyboard(this, wid, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK);
}
};
static const Widget _query_sign_edit_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 259, 0, 13, STR_012D, STR_NULL },
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 259, 14, 29, STR_NULL, STR_NULL },
{ WWT_EDITBOX, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 27, STR_SIGN_OSKTITLE, STR_NULL }, // Text field
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 60, 30, 41, STR_012F_OK, STR_NULL },
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 61, 120, 30, 41, STR_012E_CANCEL, STR_NULL },
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 121, 180, 30, 41, STR_0290_DELETE, STR_NULL },
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 181, 237, 30, 41, STR_NULL, STR_NULL },
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 238, 248, 30, 41, STR_6819, STR_PREVIOUS_SIGN_TOOLTIP },
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 249, 259, 30, 41, STR_681A, STR_NEXT_SIGN_TOOLTIP },
{ WIDGETS_END },
};
static const WindowDesc _query_sign_edit_desc = {
190, 170, 260, 42, 260, 42,
WC_QUERY_STRING, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
_query_sign_edit_widgets,
};
void HandleClickOnSign(const Sign *si)
{
if (_ctrl_pressed && si->owner == _local_company) {
RenameSign(si->index, NULL);
return;
}
ShowRenameSignWindow(si);
}
void ShowRenameSignWindow(const Sign *si)
{
/* Delete all other edit windows and the save window */
DeleteWindowById(WC_QUERY_STRING, 0);
DeleteWindowById(WC_SAVELOAD, 0);
new SignWindow(&_query_sign_edit_desc, si);
}
void DeleteRenameSignWindow(SignID sign)
{
SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, 0));
if (w != NULL && w->cur_sign == sign) delete w;
}
|