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
|
|
|
|
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? */
|
|
|
|
int y = 16; // offset from top of widget
|
|
|
|
if (this->vscroll.count == 0) {
|
2009-03-22 14:39:20 +00:00
|
|
|
DrawString(2, 346, y, STR_304A_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
|
|
|
|
2008-09-30 20:39:50 +00:00
|
|
|
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, 4, y + 1);
|
2008-05-19 09:45:24 +00:00
|
|
|
|
|
|
|
SetDParam(0, si->index);
|
2009-03-22 14:39:20 +00:00
|
|
|
DrawString(22, 346, y, STR_SIGN_NAME, TC_YELLOW);
|
2008-05-19 09:45:24 +00:00
|
|
|
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;
|
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnResize(Point new_size, Point delta)
|
|
|
|
{
|
|
|
|
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[] = {
|
2008-07-31 17:45:52 +00:00
|
|
|
{ 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},
|
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);
|
2008-12-28 14:37:19 +00:00
|
|
|
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);
|
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
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
{
|
|
|
|
this->caption = STR_280B_EDIT_SIGN_TEXT;
|
|
|
|
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[] = {
|
2008-07-31 17:45:52 +00:00
|
|
|
{ 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 },
|
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;
|
|
|
|
}
|