2007-01-21 12:35:35 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file signs_gui.cpp The GUI for signs. */
|
2007-04-04 01:35:16 +00:00
|
|
|
|
2007-01-21 12:35:35 +00:00
|
|
|
#include "stdafx.h"
|
2008-09-30 20:51:04 +00:00
|
|
|
#include "company_gui.h"
|
|
|
|
#include "company_func.h"
|
2008-03-31 07:25:49 +00:00
|
|
|
#include "signs_base.h"
|
|
|
|
#include "signs_func.h"
|
2007-01-21 12:35:35 +00:00
|
|
|
#include "debug.h"
|
2007-12-21 21:50:46 +00:00
|
|
|
#include "command_func.h"
|
2007-12-21 19:49:27 +00:00
|
|
|
#include "strings_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2007-12-26 11:45:43 +00:00
|
|
|
#include "map_func.h"
|
2008-01-09 09:45:45 +00:00
|
|
|
#include "gfx_func.h"
|
|
|
|
#include "viewport_func.h"
|
2008-05-11 12:26:20 +00:00
|
|
|
#include "querystring_gui.h"
|
2008-07-29 10:26:48 +00:00
|
|
|
#include "sortlist_type.h"
|
2008-09-07 16:22:55 +00:00
|
|
|
#include "string_func.h"
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
struct SignList {
|
|
|
|
typedef GUIList<const Sign *> GUISignList;
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
static const Sign *last_sign;
|
|
|
|
GUISignList signs;
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
void BuildSignsList()
|
|
|
|
{
|
|
|
|
if (!this->signs.NeedRebuild()) return;
|
|
|
|
|
|
|
|
DEBUG(misc, 3, "Building sign list");
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
this->signs.Clear();
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
const Sign *si;
|
|
|
|
FOR_ALL_SIGNS(si) *this->signs.Append() = si;
|
|
|
|
|
|
|
|
this->signs.Compact();
|
|
|
|
this->signs.RebuildDone();
|
2007-01-21 12:35:35 +00:00
|
|
|
}
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
/** Sort signs by their name */
|
2009-01-10 00:31:47 +00:00
|
|
|
static int CDECL SignNameSorter(const Sign * const *a, const Sign * const *b)
|
2008-07-29 10:26:48 +00:00
|
|
|
{
|
|
|
|
static char buf_cache[64];
|
|
|
|
char buf[64];
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
SetDParam(0, (*a)->index);
|
|
|
|
GetString(buf, STR_SIGN_NAME, lastof(buf));
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
if (*b != last_sign) {
|
|
|
|
last_sign = *b;
|
|
|
|
SetDParam(0, (*b)->index);
|
|
|
|
GetString(buf_cache, STR_SIGN_NAME, lastof(buf_cache));
|
|
|
|
}
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
return strcasecmp(buf, buf_cache);
|
|
|
|
}
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
void SortSignsList()
|
|
|
|
{
|
|
|
|
if (!this->signs.Sort(&SignNameSorter)) return;
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
/* Reset the name sorter sort cache */
|
|
|
|
this->last_sign = NULL;
|
|
|
|
}
|
|
|
|
};
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
const Sign *SignList::last_sign = NULL;
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2009-03-28 17:39:03 +00:00
|
|
|
/** Enum referring to the widgets of the sign list window */
|
|
|
|
enum SignListWidgets {
|
|
|
|
SLW_CLOSEBOX = 0,
|
|
|
|
SLW_CAPTION,
|
|
|
|
SLW_STICKY,
|
|
|
|
SLW_LIST,
|
|
|
|
SLW_SCROLLBAR,
|
|
|
|
SLW_RESIZE,
|
|
|
|
};
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
struct SignListWindow : Window, SignList {
|
2008-05-19 09:45:24 +00:00
|
|
|
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
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
this->signs.ForceRebuild();
|
|
|
|
this->signs.NeedResort();
|
|
|
|
|
2008-05-19 09:45:24 +00:00
|
|
|
this->FindWindowPlacementAndResize(desc);
|
2007-01-21 12:35:35 +00:00
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
|
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-07-29 10:26:48 +00:00
|
|
|
BuildSignsList();
|
|
|
|
SortSignsList();
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
SetVScrollCount(this, this->signs.Length());
|
2008-05-19 09:45:24 +00:00
|
|
|
|
|
|
|
SetDParam(0, this->vscroll.count);
|
|
|
|
this->DrawWidgets();
|
|
|
|
|
|
|
|
/* No signs? */
|
2009-03-28 17:39:03 +00:00
|
|
|
int y = this->widget[SLW_LIST].top + 2; // offset from top of widget
|
2008-05-19 09:45:24 +00:00
|
|
|
if (this->vscroll.count == 0) {
|
2009-04-21 23:40:56 +00:00
|
|
|
DrawString(this->widget[SLW_LIST].left + 2, this->widget[SLW_LIST].right, y, STR_STATION_LIST_NONE, TC_FROMSTRING);
|
2008-05-19 09:45:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Start drawing the signs */
|
|
|
|
for (uint16 i = this->vscroll.pos; i < this->vscroll.cap + this->vscroll.pos && i < this->vscroll.count; i++) {
|
2008-07-29 10:26:48 +00:00
|
|
|
const Sign *si = this->signs[i];
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2009-03-28 17:39:03 +00:00
|
|
|
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, this->widget[SLW_LIST].left + 4, y + 1);
|
2008-05-19 09:45:24 +00:00
|
|
|
|
|
|
|
SetDParam(0, si->index);
|
2009-03-28 17:39:03 +00:00
|
|
|
DrawString(this->widget[SLW_LIST].left + 22, this->widget[SLW_LIST].right, y, STR_SIGN_NAME, TC_YELLOW);
|
2008-05-19 09:45:24 +00:00
|
|
|
y += 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
2009-03-28 17:39:03 +00:00
|
|
|
if (widget == SLW_LIST) {
|
|
|
|
uint32 id_v = (pt.y - this->widget[SLW_LIST].top - 1) / 10;
|
2008-05-19 09:45:24 +00:00
|
|
|
|
|
|
|
if (id_v >= this->vscroll.cap) return;
|
|
|
|
id_v += this->vscroll.pos;
|
|
|
|
if (id_v >= this->vscroll.count) return;
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
const Sign *si = this->signs[id_v];
|
2008-05-19 09:45:24 +00:00
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-29 09:49:11 +00:00
|
|
|
virtual void OnResize(Point delta)
|
2008-05-19 09:45:24 +00:00
|
|
|
{
|
|
|
|
this->vscroll.cap += delta.y / 10;
|
|
|
|
}
|
2008-07-29 10:26:48 +00:00
|
|
|
|
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
{
|
|
|
|
if (data == 0) {
|
|
|
|
this->signs.ForceRebuild();
|
|
|
|
} else {
|
|
|
|
this->signs.ForceResort();
|
|
|
|
}
|
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
};
|
2007-01-21 12:35:35 +00:00
|
|
|
|
|
|
|
static const Widget _sign_list_widget[] = {
|
2009-04-21 23:40:56 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW},
|
|
|
|
{ WWT_CAPTION, RESIZE_RIGHT, COLOUR_GREY, 11, 345, 0, 13, STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS},
|
2008-07-31 17:45:52 +00:00
|
|
|
{ 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},
|
2009-04-21 23:40:56 +00:00
|
|
|
{ WWT_SCROLLBAR, RESIZE_LRB, COLOUR_GREY, 346, 357, 14, 125, 0x0, STR_TOOLTIP_VSCROLL_BAR_SCROLLS_LIST},
|
2008-07-31 17:45:52 +00:00
|
|
|
{ WWT_RESIZEBOX, RESIZE_LRTB, COLOUR_GREY, 346, 357, 126, 137, 0x0, STR_RESIZE_BUTTON},
|
2007-01-21 12:35:35 +00:00
|
|
|
{ WIDGETS_END},
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _sign_list_desc(
|
2007-07-27 12:49:04 +00:00
|
|
|
WDP_AUTO, WDP_AUTO, 358, 138, 358, 138,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SIGN_LIST, WC_NONE,
|
2007-01-21 12:35:35 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON | WDF_RESIZABLE,
|
2009-03-15 15:12:06 +00:00
|
|
|
_sign_list_widget
|
|
|
|
);
|
2007-01-21 12:35:35 +00:00
|
|
|
|
|
|
|
|
2007-03-07 11:47:46 +00:00
|
|
|
void ShowSignList()
|
2007-01-21 12:35:35 +00:00
|
|
|
{
|
2008-05-19 09:45:24 +00:00
|
|
|
AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
|
2007-01-21 12:35:35 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-09-23 20:12:13 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2008-09-23 20:12:13 +00:00
|
|
|
bool remove = StrEmpty(text);
|
2009-04-21 23:40:56 +00:00
|
|
|
DoCommandP(0, index, 0, CMD_RENAME_SIGN | (StrEmpty(text) ? CMD_MSG(STR_ERROR_CAN_T_DELETE_SIGN) : CMD_MSG(STR_ERROR_CAN_T_CHANGE_SIGN_NAME)), NULL, text);
|
2008-09-23 20:12:13 +00:00
|
|
|
return remove;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2009-04-26 08:33:47 +00:00
|
|
|
/** Widget numbers of the query sign edit window. */
|
2007-06-30 17:51:50 +00:00
|
|
|
enum QueryEditSignWidgets {
|
2009-04-26 08:33:47 +00:00
|
|
|
QUERY_EDIT_SIGN_WIDGET_CLOSEBOX,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_CAPTION,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_PANEL,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_TEXT,
|
2007-06-30 17:51:50 +00:00
|
|
|
QUERY_EDIT_SIGN_WIDGET_OK,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_CANCEL,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_DELETE,
|
2009-04-26 08:33:47 +00:00
|
|
|
QUERY_EDIT_SIGN_WIDGET_FILL,
|
|
|
|
QUERY_EDIT_SIGN_WIDGET_PREVIOUS,
|
2007-06-30 17:51:50 +00:00
|
|
|
QUERY_EDIT_SIGN_WIDGET_NEXT,
|
|
|
|
};
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
struct SignWindow : QueryStringBaseWindow, SignList {
|
2008-05-11 12:26:20 +00:00
|
|
|
SignID cur_sign;
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-08-13 06:05:01 +00:00
|
|
|
SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_BYTES, desc)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2009-04-21 23:40:56 +00:00
|
|
|
this->caption = STR_EDIT_SIGN_CAPTION;
|
2008-05-11 12:26:20 +00:00
|
|
|
this->afilter = CS_ALPHANUMERAL;
|
|
|
|
this->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
UpdateSignEditWindow(si);
|
2009-02-09 01:22:29 +00:00
|
|
|
this->SetFocusedWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2008-05-18 22:11:46 +00:00
|
|
|
this->FindWindowPlacementAndResize(desc);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
void UpdateSignEditWindow(const Sign *si)
|
|
|
|
{
|
2008-10-22 19:12:10 +00:00
|
|
|
char *last_of = &this->edit_str_buf[this->edit_str_size - 1]; // points to terminating '\0'
|
2008-08-11 22:08:56 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
/* Display an empty string when the sign hasnt been edited yet */
|
|
|
|
if (si->name != NULL) {
|
|
|
|
SetDParam(0, si->index);
|
2008-08-11 22:08:56 +00:00
|
|
|
GetString(this->edit_str_buf, STR_SIGN_NAME, last_of);
|
2008-05-11 12:26:20 +00:00
|
|
|
} else {
|
2008-08-11 22:08:56 +00:00
|
|
|
GetString(this->edit_str_buf, STR_EMPTY, last_of);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2008-08-11 22:08:56 +00:00
|
|
|
*last_of = '\0';
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
this->cur_sign = si->index;
|
2008-08-13 06:05:01 +00:00
|
|
|
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, MAX_LENGTH_SIGN_NAME_PIXELS);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
this->InvalidateWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2009-02-09 01:22:29 +00:00
|
|
|
this->SetFocusedWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-09-16 19:18:22 +00:00
|
|
|
/**
|
|
|
|
* 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];
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
SetDParam(0, this->caption);
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2008-05-11 12:26:20 +00:00
|
|
|
this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
{
|
|
|
|
switch (widget) {
|
2008-09-16 19:18:22 +00:00
|
|
|
case QUERY_EDIT_SIGN_WIDGET_PREVIOUS:
|
2008-05-11 12:26:20 +00:00
|
|
|
case QUERY_EDIT_SIGN_WIDGET_NEXT: {
|
2008-09-16 19:18:22 +00:00
|
|
|
const Sign *si = this->PrevNextSign(widget == QUERY_EDIT_SIGN_WIDGET_NEXT);
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
/* Rebuild the sign list */
|
|
|
|
this->signs.ForceRebuild();
|
|
|
|
this->signs.NeedResort();
|
|
|
|
this->BuildSignsList();
|
|
|
|
this->SortSignsList();
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
/* Scroll to sign and reopen window */
|
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
|
UpdateSignEditWindow(si);
|
2008-07-29 10:26:48 +00:00
|
|
|
break;
|
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
case QUERY_EDIT_SIGN_WIDGET_DELETE:
|
|
|
|
/* Only need to set the buffer to null, the rest is handled as the OK button */
|
2008-09-16 19:05:38 +00:00
|
|
|
RenameSign(this->cur_sign, "");
|
|
|
|
/* don't delete this, we are deleted in Sign::~Sign() -> DeleteRenameSignWindow() */
|
|
|
|
break;
|
2008-05-11 12:26:20 +00:00
|
|
|
|
|
|
|
case QUERY_EDIT_SIGN_WIDGET_OK:
|
2008-09-23 20:12:13 +00:00
|
|
|
if (RenameSign(this->cur_sign, this->text.buf)) break;
|
2008-05-11 12:26:20 +00:00
|
|
|
/* FALL THROUGH */
|
|
|
|
|
|
|
|
case QUERY_EDIT_SIGN_WIDGET_CANCEL:
|
|
|
|
delete this;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-05-17 23:11:06 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
2008-05-17 23:11:06 +00:00
|
|
|
EventState state = ES_NOT_HANDLED;
|
|
|
|
switch (this->HandleEditBoxKey(QUERY_EDIT_SIGN_WIDGET_TEXT, key, keycode, state)) {
|
2008-10-25 19:59:11 +00:00
|
|
|
default: break;
|
|
|
|
|
|
|
|
case HEBR_CONFIRM:
|
2008-09-23 20:12:13 +00:00
|
|
|
if (RenameSign(this->cur_sign, this->text.buf)) break;
|
2008-05-11 12:26:20 +00:00
|
|
|
/* FALL THROUGH */
|
|
|
|
|
2008-10-25 19:59:11 +00:00
|
|
|
case HEBR_CANCEL: // close window, abandon changes
|
2008-05-11 12:26:20 +00:00
|
|
|
delete this;
|
|
|
|
break;
|
|
|
|
}
|
2008-05-17 23:11:06 +00:00
|
|
|
return state;
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
this->HandleEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2007-06-30 17:51:50 +00:00
|
|
|
}
|
2009-01-03 13:59:05 +00:00
|
|
|
|
|
|
|
virtual void OnOpenOSKWindow(int wid)
|
|
|
|
{
|
|
|
|
ShowOnScreenKeyboard(this, wid, QUERY_EDIT_SIGN_WIDGET_CANCEL, QUERY_EDIT_SIGN_WIDGET_OK);
|
|
|
|
}
|
2008-05-11 12:26:20 +00:00
|
|
|
};
|
2007-06-30 17:51:50 +00:00
|
|
|
|
|
|
|
static const Widget _query_sign_edit_widgets[] = {
|
2009-04-26 08:33:47 +00:00
|
|
|
{ WWT_CLOSEBOX, RESIZE_NONE, COLOUR_GREY, 0, 10, 0, 13, STR_BLACK_CROSS, STR_TOOLTIP_CLOSE_WINDOW}, // QUERY_EDIT_SIGN_WIDGET_CLOSEBOX
|
|
|
|
{ WWT_CAPTION, RESIZE_NONE, COLOUR_GREY, 11, 259, 0, 13, STR_QUERY_CAPTION, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_CAPTION
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 0, 259, 14, 29, STR_NULL, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_PANEL
|
|
|
|
{ WWT_EDITBOX, RESIZE_NONE, COLOUR_GREY, 2, 257, 16, 27, STR_SIGN_OSKTITLE, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_TEXT (Text field)
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 0, 60, 30, 41, STR_QUERY_OK, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_OK
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 61, 120, 30, 41, STR_QUERY_CANCEL, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_CANCEL
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 121, 180, 30, 41, STR_TOWN_VIEW_DELETE_BUTTON, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_DELETE
|
|
|
|
{ WWT_PANEL, RESIZE_NONE, COLOUR_GREY, 181, 237, 30, 41, STR_NULL, STR_NULL }, // QUERY_EDIT_SIGN_WIDGET_FILL
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 238, 248, 30, 41, STR_ARROW_LEFT_SMALL, STR_PREVIOUS_SIGN_TOOLTIP }, // QUERY_EDIT_SIGN_WIDGET_PREVIOUS
|
|
|
|
{ WWT_TEXTBTN, RESIZE_NONE, COLOUR_GREY, 249, 259, 30, 41, STR_ARROW_RIGHT_SMALL, STR_NEXT_SIGN_TOOLTIP }, // QUERY_EDIT_SIGN_WIDGET_NEXT
|
2007-06-30 17:51:50 +00:00
|
|
|
{ WIDGETS_END },
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _query_sign_edit_desc(
|
2007-07-27 12:49:04 +00:00
|
|
|
190, 170, 260, 42, 260, 42,
|
2007-06-30 17:51:50 +00:00
|
|
|
WC_QUERY_STRING, WC_NONE,
|
2009-02-04 16:59:41 +00:00
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_CONSTRUCTION,
|
2009-03-15 15:12:06 +00:00
|
|
|
_query_sign_edit_widgets
|
|
|
|
);
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2008-06-12 22:29:42 +00:00
|
|
|
void HandleClickOnSign(const Sign *si)
|
|
|
|
{
|
2008-09-30 20:39:50 +00:00
|
|
|
if (_ctrl_pressed && si->owner == _local_company) {
|
2008-09-07 16:22:55 +00:00
|
|
|
RenameSign(si->index, NULL);
|
2008-06-12 22:29:42 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
ShowRenameSignWindow(si);
|
|
|
|
}
|
|
|
|
|
2007-06-30 17:51:50 +00:00
|
|
|
void ShowRenameSignWindow(const Sign *si)
|
|
|
|
{
|
2009-02-09 01:22:29 +00:00
|
|
|
/* Delete all other edit windows */
|
2007-06-30 17:51:50 +00:00
|
|
|
DeleteWindowById(WC_QUERY_STRING, 0);
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
new SignWindow(&_query_sign_edit_desc, si);
|
2007-06-30 17:51:50 +00:00
|
|
|
}
|
2008-09-16 19:05:38 +00:00
|
|
|
|
|
|
|
void DeleteRenameSignWindow(SignID sign)
|
|
|
|
{
|
|
|
|
SignWindow *w = dynamic_cast<SignWindow *>(FindWindowById(WC_QUERY_STRING, 0));
|
|
|
|
|
|
|
|
if (w != NULL && w->cur_sign == sign) delete w;
|
|
|
|
}
|