2007-01-21 12:35:35 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
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"
|
2010-01-15 16:41:15 +00:00
|
|
|
#include "core/geometry_func.hpp"
|
2010-08-16 16:15:22 +00:00
|
|
|
#include "hotkeys.h"
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-01-13 01:21:35 +00:00
|
|
|
#include "table/strings.h"
|
2009-09-04 22:03:21 +00:00
|
|
|
#include "table/sprites.h"
|
2008-01-13 01:21:35 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
/**
|
|
|
|
* Contains the necessary information to decide if a sign should
|
|
|
|
* be filtered out or not. This struct is sent as parameter to the
|
|
|
|
* sort functions of the GUISignList.
|
|
|
|
*/
|
|
|
|
struct FilterInfo {
|
|
|
|
const char *string; ///< String to match sign names against
|
|
|
|
bool case_sensitive; ///< Should case sensitive matching be used?
|
|
|
|
};
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
struct SignList {
|
2010-08-16 16:15:22 +00:00
|
|
|
/**
|
|
|
|
* A GUIList contains signs and uses a custom data structure called #FilterInfo for
|
|
|
|
* passing data to the sort functions.
|
|
|
|
*/
|
|
|
|
typedef GUIList<const Sign *, FilterInfo> 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
|
|
|
|
2010-12-05 22:25:08 +00:00
|
|
|
char filter_string[MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH]; ///< The match string to be used when the GUIList is (re)-sorted.
|
|
|
|
static bool match_case; ///< Should case sensitive matching be used?
|
2010-08-16 16:15:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a SignList with filtering disabled by default.
|
|
|
|
*/
|
|
|
|
SignList()
|
|
|
|
{
|
|
|
|
filter_string[0] = '\0';
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
this->FilterSignList();
|
2008-07-29 10:26:48 +00:00
|
|
|
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
|
|
|
|
2010-11-27 22:52:12 +00:00
|
|
|
int r = strnatcmp(buf, buf_cache); // Sort by name (natural sorting).
|
2010-06-22 08:01:38 +00:00
|
|
|
|
|
|
|
return r != 0 ? r : ((*a)->index - (*b)->index);
|
2008-07-29 10:26:48 +00:00
|
|
|
}
|
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;
|
|
|
|
}
|
2010-08-16 16:15:22 +00:00
|
|
|
|
|
|
|
/** Filter sign list by sign name (case sensitive setting in FilterInfo) */
|
|
|
|
static bool CDECL SignNameFilter(const Sign * const *a, FilterInfo filter_info)
|
|
|
|
{
|
|
|
|
/* Get sign string */
|
2010-12-05 22:25:08 +00:00
|
|
|
char buf1[MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH];
|
2010-08-16 16:15:22 +00:00
|
|
|
SetDParam(0, (*a)->index);
|
|
|
|
GetString(buf1, STR_SIGN_NAME, lastof(buf1));
|
|
|
|
|
|
|
|
return (filter_info.case_sensitive ? strstr(buf1, filter_info.string) : strcasestr(buf1, filter_info.string)) != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Filter out signs from the sign list that does not match the name filter */
|
|
|
|
void FilterSignList()
|
|
|
|
{
|
|
|
|
FilterInfo filter_info = {this->filter_string, this->match_case};
|
|
|
|
this->signs.Filter(&SignNameFilter, filter_info);
|
|
|
|
}
|
2008-07-29 10:26:48 +00:00
|
|
|
};
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
const Sign *SignList::last_sign = NULL;
|
2010-08-16 16:15:22 +00:00
|
|
|
bool SignList::match_case = false;
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
/** Enum referring to the widgets in the sign list window */
|
2009-03-28 17:39:03 +00:00
|
|
|
enum SignListWidgets {
|
|
|
|
SLW_CAPTION,
|
|
|
|
SLW_LIST,
|
|
|
|
SLW_SCROLLBAR,
|
2010-08-16 16:15:22 +00:00
|
|
|
SLW_FILTER_TEXT, ///< Text box for typing a filter string
|
|
|
|
SLW_FILTER_MATCH_CASE_BTN, ///< Button to toggle if case sensitive filtering should be used
|
|
|
|
SLW_FILTER_CLEAR_BTN, ///< Button to clear the filter
|
2009-03-28 17:39:03 +00:00
|
|
|
};
|
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
/** Enum referring to the Hotkeys in the sign list window */
|
|
|
|
enum SignListHotkeys {
|
|
|
|
SLHK_FOCUS_FILTER_BOX, ///< Focus the edit box for editing the filter string
|
|
|
|
};
|
|
|
|
|
|
|
|
struct SignListWindow : QueryStringBaseWindow, SignList {
|
|
|
|
int text_offset; ///< Offset of the sign text relative to the left edge of the SLW_LIST widget.
|
2010-08-12 08:37:01 +00:00
|
|
|
Scrollbar *vscroll;
|
2009-09-04 22:03:21 +00:00
|
|
|
|
2010-12-05 22:25:08 +00:00
|
|
|
SignListWindow(const WindowDesc *desc, WindowNumber window_number) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
|
2008-05-19 09:45:24 +00:00
|
|
|
{
|
2010-08-12 08:37:01 +00:00
|
|
|
this->CreateNestedTree(desc);
|
|
|
|
this->vscroll = this->GetScrollbar(SLW_SCROLLBAR);
|
|
|
|
this->FinishInitNested(desc, window_number);
|
2010-08-16 16:15:22 +00:00
|
|
|
this->SetWidgetLoweredState(SLW_FILTER_MATCH_CASE_BTN, SignList::match_case);
|
|
|
|
|
|
|
|
/* Initialize the text edit widget */
|
|
|
|
this->afilter = CS_ALPHANUMERAL;
|
2010-12-05 22:25:08 +00:00
|
|
|
InitializeTextBuffer(&this->text, this->edit_str_buf, MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS, MAX_LENGTH_SIGN_NAME_PIXELS);
|
2010-08-16 16:15:22 +00:00
|
|
|
ClearFilterTextWidget();
|
|
|
|
|
|
|
|
/* Initialize the filtering variables */
|
|
|
|
this->SetFilterString("");
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2009-09-04 22:03:21 +00:00
|
|
|
/* Create initial list. */
|
|
|
|
this->signs.ForceRebuild();
|
|
|
|
this->signs.ForceResort();
|
|
|
|
this->BuildSignsList();
|
|
|
|
this->SortSignsList();
|
2010-08-12 08:37:01 +00:00
|
|
|
this->vscroll->SetCount(this->signs.Length());
|
2007-01-21 12:35:35 +00:00
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
/**
|
|
|
|
* Empties the string buffer that is edited by the filter text edit widget.
|
|
|
|
* It also triggers the redraw of the widget so it become visible that the string has been made empty.
|
|
|
|
*/
|
|
|
|
void ClearFilterTextWidget()
|
|
|
|
{
|
|
|
|
this->edit_str_buf[0] = '\0';
|
|
|
|
UpdateTextBufferSize(&this->text);
|
|
|
|
|
|
|
|
this->SetWidgetDirty(SLW_FILTER_TEXT);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function sets the filter string of the sign list. The contents of
|
|
|
|
* the edit widget is not updated by this function. Depending on if the
|
|
|
|
* new string is zero-length or not the clear button is made
|
|
|
|
* disabled/enabled. The sign list is updated according to the new filter.
|
|
|
|
*/
|
|
|
|
void SetFilterString(const char *new_filter_string)
|
|
|
|
{
|
|
|
|
/* check if there is a new filter string */
|
|
|
|
if (!StrEmpty(new_filter_string)) {
|
|
|
|
/* Copy new filter string */
|
|
|
|
strecpy(this->filter_string, new_filter_string, lastof(this->filter_string));
|
|
|
|
|
|
|
|
this->signs.SetFilterState(true);
|
|
|
|
|
|
|
|
this->EnableWidget(SLW_FILTER_CLEAR_BTN);
|
|
|
|
} else {
|
|
|
|
/* There is no new string -> clear this->filter_string */
|
|
|
|
this->filter_string[0] = '\0';
|
|
|
|
|
|
|
|
this->signs.SetFilterState(false);
|
|
|
|
this->DisableWidget(SLW_FILTER_CLEAR_BTN);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Repaint the clear button since its disabled state may have changed */
|
|
|
|
this->SetWidgetDirty(SLW_FILTER_CLEAR_BTN);
|
|
|
|
|
|
|
|
/* Rebuild the list of signs */
|
|
|
|
this->InvalidateData();
|
|
|
|
}
|
|
|
|
|
2008-05-19 09:45:24 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
|
|
|
this->DrawWidgets();
|
2010-08-16 16:15:22 +00:00
|
|
|
if (!this->IsShaded()) this->DrawEditBox(SLW_FILTER_TEXT);
|
2009-09-04 22:03:21 +00:00
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2009-09-04 22:03:21 +00:00
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case SLW_LIST: {
|
2009-09-05 10:53:26 +00:00
|
|
|
uint y = r.top + WD_FRAMERECT_TOP; // Offset from top of widget.
|
2009-09-04 22:03:21 +00:00
|
|
|
/* No signs? */
|
2010-08-12 08:37:01 +00:00
|
|
|
if (this->vscroll->GetCount() == 0) {
|
2009-09-05 10:53:26 +00:00
|
|
|
DrawString(r.left + WD_FRAMETEXT_LEFT, r.right, y, STR_STATION_LIST_NONE);
|
2009-09-04 22:03:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-13 09:56:25 +00:00
|
|
|
bool rtl = _current_text_dir == TD_RTL;
|
2009-11-22 14:40:25 +00:00
|
|
|
int sprite_offset_y = (FONT_HEIGHT_NORMAL - 10) / 2 + 1;
|
2009-11-18 21:27:13 +00:00
|
|
|
uint icon_left = 4 + (rtl ? r.right - this->text_offset : r.left);
|
|
|
|
uint text_left = r.left + (rtl ? WD_FRAMERECT_LEFT : this->text_offset);
|
|
|
|
uint text_right = r.right - (rtl ? this->text_offset : WD_FRAMERECT_RIGHT);
|
|
|
|
|
2009-09-04 22:03:21 +00:00
|
|
|
/* At least one sign available. */
|
2010-08-12 08:37:01 +00:00
|
|
|
for (uint16 i = this->vscroll->GetPosition(); this->vscroll->IsVisible(i) && i < this->vscroll->GetCount(); i++) {
|
2009-09-04 22:03:21 +00:00
|
|
|
const Sign *si = this->signs[i];
|
|
|
|
|
2009-11-22 14:40:25 +00:00
|
|
|
if (si->owner != OWNER_NONE) DrawCompanyIcon(si->owner, icon_left, y + sprite_offset_y);
|
2009-09-04 22:03:21 +00:00
|
|
|
|
|
|
|
SetDParam(0, si->index);
|
2010-08-16 17:25:11 +00:00
|
|
|
DrawString(text_left, text_right, y, STR_SIGN_NAME, TC_YELLOW);
|
2009-09-04 22:03:21 +00:00
|
|
|
y += this->resize.step_height;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
}
|
2009-09-04 22:03:21 +00:00
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2009-09-04 22:03:21 +00:00
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
|
{
|
2010-08-12 08:37:01 +00:00
|
|
|
if (widget == SLW_CAPTION) SetDParam(0, this->vscroll->GetCount());
|
2008-05-19 09:45:24 +00:00
|
|
|
}
|
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-19 09:45:24 +00:00
|
|
|
{
|
2010-08-16 16:15:22 +00:00
|
|
|
switch (widget) {
|
|
|
|
case SLW_LIST: {
|
|
|
|
uint id_v = this->vscroll->GetScrolledRowFromWidget(pt.y, this, SLW_LIST, WD_FRAMERECT_TOP);
|
|
|
|
if (id_v == INT_MAX) return;
|
|
|
|
|
|
|
|
const Sign *si = this->signs[id_v];
|
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SLW_FILTER_CLEAR_BTN:
|
|
|
|
this->ClearFilterTextWidget(); // Empty the text in the EditBox widget
|
|
|
|
this->SetFilterString(""); // Use empty text as filter text (= view all signs)
|
|
|
|
break;
|
2008-05-19 09:45:24 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
case SLW_FILTER_MATCH_CASE_BTN:
|
|
|
|
SignList::match_case = !SignList::match_case; // Toggle match case
|
|
|
|
this->SetWidgetLoweredState(SLW_FILTER_MATCH_CASE_BTN, SignList::match_case); // Toggle button pushed state
|
|
|
|
this->InvalidateData(); // Rebuild the list of signs
|
|
|
|
break;
|
2008-05-19 09:45:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-24 14:53:55 +00:00
|
|
|
virtual void OnResize()
|
2008-05-19 09:45:24 +00:00
|
|
|
{
|
2010-08-12 08:37:01 +00:00
|
|
|
this->vscroll->SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
|
2009-09-04 22:03:21 +00:00
|
|
|
}
|
|
|
|
|
2009-11-22 18:28:14 +00:00
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
2009-09-04 22:03:21 +00:00
|
|
|
{
|
2009-11-22 14:40:25 +00:00
|
|
|
switch (widget) {
|
|
|
|
case SLW_LIST: {
|
|
|
|
Dimension spr_dim = GetSpriteSize(SPR_COMPANY_ICON);
|
|
|
|
this->text_offset = WD_FRAMETEXT_LEFT + spr_dim.width + 2; // 2 pixels space between icon and the sign text.
|
|
|
|
resize->height = max<uint>(FONT_HEIGHT_NORMAL, GetSpriteSize(SPR_COMPANY_ICON).height);
|
|
|
|
Dimension d = {this->text_offset + MAX_LENGTH_SIGN_NAME_PIXELS + WD_FRAMETEXT_RIGHT, WD_FRAMERECT_TOP + 5 * resize->height + WD_FRAMERECT_BOTTOM};
|
|
|
|
*size = maxdim(*size, d);
|
2010-08-01 18:53:30 +00:00
|
|
|
break;
|
|
|
|
}
|
2009-11-22 14:40:25 +00:00
|
|
|
|
|
|
|
case SLW_CAPTION:
|
2009-11-29 01:00:03 +00:00
|
|
|
SetDParam(0, max<size_t>(1000, Sign::GetPoolSize()));
|
2009-11-22 14:40:25 +00:00
|
|
|
*size = GetStringBoundingBox(STR_SIGN_LIST_CAPTION);
|
|
|
|
size->height += padding.height;
|
|
|
|
size->width += padding.width;
|
|
|
|
break;
|
2009-09-05 10:53:26 +00:00
|
|
|
}
|
2008-05-19 09:45:24 +00:00
|
|
|
}
|
2008-07-29 10:26:48 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
virtual EventState OnKeyPress(uint16 key, uint16 keycode)
|
|
|
|
{
|
|
|
|
EventState state = ES_NOT_HANDLED;
|
|
|
|
switch (this->HandleEditBoxKey(SLW_FILTER_TEXT, key, keycode, state)) {
|
|
|
|
case HEBR_EDITING:
|
|
|
|
this->SetFilterString(this->text.buf);
|
|
|
|
break;
|
|
|
|
|
2010-08-16 17:25:11 +00:00
|
|
|
case HEBR_CONFIRM: // Enter pressed -> goto first sign in list
|
|
|
|
if (this->signs.Length() >= 1) {
|
|
|
|
const Sign *si = this->signs[0];
|
2010-08-16 16:15:22 +00:00
|
|
|
ScrollMainWindowToTile(TileVirtXY(si->x, si->y));
|
|
|
|
}
|
|
|
|
return state;
|
|
|
|
|
|
|
|
case HEBR_CANCEL: // ESC pressed, clear filter.
|
|
|
|
this->OnClick(Point(), SLW_FILTER_CLEAR_BTN, 1); // Simulate click on clear button.
|
|
|
|
this->UnfocusFocusedWidget(); // Unfocus the text box.
|
|
|
|
return state;
|
|
|
|
|
|
|
|
case HEBR_NOT_FOCUSED: // The filter text box is not globaly focused.
|
|
|
|
if (CheckHotkeyMatch(signlist_hotkeys, keycode, this) == SLHK_FOCUS_FILTER_BOX) {
|
|
|
|
this->SetFocusedWidget(SLW_FILTER_TEXT);
|
|
|
|
SetFocusedWindow(this); // The user has asked to give focus to the text box, so make sure this window is focused.
|
|
|
|
state = ES_HANDLED;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
NOT_REACHED();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state == ES_HANDLED) OnOSKInput(SLW_FILTER_TEXT);
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnOSKInput(int widget)
|
|
|
|
{
|
|
|
|
if (widget == SLW_FILTER_TEXT) this->SetFilterString(this->text.buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void OnMouseLoop()
|
|
|
|
{
|
|
|
|
this->HandleEditBox(SLW_FILTER_TEXT);
|
2010-09-25 19:13:25 +00:00
|
|
|
}
|
2010-08-16 16:15:22 +00:00
|
|
|
|
|
|
|
|
2008-07-29 10:26:48 +00:00
|
|
|
virtual void OnInvalidateData(int data)
|
|
|
|
{
|
2010-08-16 16:15:22 +00:00
|
|
|
/* When there is a filter string, we always need to rebuild the list even if
|
|
|
|
* the amount of signs in total is unchanged, as the subset of signs that is
|
|
|
|
* accepted by the filter might has changed.
|
|
|
|
*/
|
|
|
|
if (data == 0 || !StrEmpty(this->filter_string)) { // New or deleted sign, or there is a filter string
|
2008-07-29 10:26:48 +00:00
|
|
|
this->signs.ForceRebuild();
|
2009-09-04 22:03:21 +00:00
|
|
|
this->BuildSignsList();
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(SLW_CAPTION);
|
2010-08-12 08:37:01 +00:00
|
|
|
this->vscroll->SetCount(this->signs.Length());
|
2010-08-16 16:15:22 +00:00
|
|
|
} else { // Change of sign contents while there is no filter string
|
2008-07-29 10:26:48 +00:00
|
|
|
this->signs.ForceResort();
|
|
|
|
}
|
2009-09-04 22:03:21 +00:00
|
|
|
|
|
|
|
this->SortSignsList();
|
2008-07-29 10:26:48 +00:00
|
|
|
}
|
2010-08-16 16:15:22 +00:00
|
|
|
|
|
|
|
static Hotkey<SignListWindow> signlist_hotkeys[];
|
2008-05-19 09:45:24 +00:00
|
|
|
};
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
Hotkey<SignListWindow> SignListWindow::signlist_hotkeys[] = {
|
|
|
|
Hotkey<SignListWindow>('F', "focus_filter_box", SLHK_FOCUS_FILTER_BOX),
|
|
|
|
HOTKEY_LIST_END(SignListWindow)
|
|
|
|
};
|
|
|
|
Hotkey<SignListWindow> *_signlist_hotkeys = SignListWindow::signlist_hotkeys;
|
|
|
|
|
2009-04-26 08:36:48 +00:00
|
|
|
static const NWidgetPart _nested_sign_list_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2009-04-26 08:36:48 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, SLW_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-12-21 16:24:29 +00:00
|
|
|
NWidget(WWT_SHADEBOX, COLOUR_GREY),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_STICKYBOX, COLOUR_GREY),
|
2009-04-26 08:36:48 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(NWID_VERTICAL),
|
2010-08-16 16:15:22 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY, SLW_LIST), SetMinimalSize(WD_FRAMETEXT_LEFT + 16 + MAX_LENGTH_SIGN_NAME_PIXELS + WD_FRAMETEXT_RIGHT, 50),
|
|
|
|
SetResize(1, 10), SetFill(1, 0), SetScrollbar(SLW_SCROLLBAR), EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1),
|
|
|
|
NWidget(WWT_EDITBOX, COLOUR_GREY, SLW_FILTER_TEXT), SetMinimalSize(80, 12), SetResize(1, 0), SetFill(1, 0), SetPadding(2, 2, 2, 2),
|
|
|
|
SetDataTip(STR_LIST_FILTER_OSKTITLE, STR_LIST_FILTER_TOOLTIP),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(WWT_TEXTBTN, COLOUR_GREY, SLW_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SLW_FILTER_CLEAR_BTN), SetDataTip(STR_SIGN_LIST_CLEAR, STR_SIGN_LIST_CLEAR_TOOLTIP),
|
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_VERTICAL),
|
|
|
|
NWidget(NWID_VERTICAL), SetFill(0, 1),
|
|
|
|
NWidget(NWID_VSCROLLBAR, COLOUR_GREY, SLW_SCROLLBAR),
|
|
|
|
EndContainer(),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_RESIZEBOX, COLOUR_GREY),
|
2009-04-26 08:36:48 +00:00
|
|
|
EndContainer(),
|
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _sign_list_desc(
|
2009-11-28 14:42:35 +00:00
|
|
|
WDP_AUTO, 358, 138,
|
2007-02-01 15:49:12 +00:00
|
|
|
WC_SIGN_LIST, WC_NONE,
|
2010-08-16 16:15:22 +00:00
|
|
|
WDF_UNCLICK_BUTTONS,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_sign_list_widgets, lengthof(_nested_sign_list_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
/**
|
|
|
|
* Open the sign list window
|
|
|
|
*
|
|
|
|
* @return newly opened sign list window, or NULL if the window could not be opened.
|
|
|
|
*/
|
|
|
|
Window *ShowSignList()
|
|
|
|
{
|
|
|
|
return AllocateWindowDescFront<SignListWindow>(&_sign_list_desc, 0);
|
|
|
|
}
|
2007-01-21 12:35:35 +00:00
|
|
|
|
2010-08-16 16:15:22 +00:00
|
|
|
EventState SignListGlobalHotkeys(uint16 key, uint16 keycode)
|
2007-01-21 12:35:35 +00:00
|
|
|
{
|
2010-08-16 16:15:22 +00:00
|
|
|
int num = CheckHotkeyMatch<SignListWindow>(_signlist_hotkeys, keycode, NULL, true);
|
|
|
|
if (num == -1) return ES_NOT_HANDLED;
|
|
|
|
Window *w = ShowSignList();
|
|
|
|
if (w == NULL) return ES_NOT_HANDLED;
|
|
|
|
return w->OnKeyPress(key, keycode);
|
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_CAPTION,
|
|
|
|
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_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
|
|
|
|
2010-12-05 22:25:08 +00:00
|
|
|
SignWindow(const WindowDesc *desc, const Sign *si) : QueryStringBaseWindow(MAX_LENGTH_SIGN_NAME_CHARS * MAX_CHAR_LENGTH, MAX_LENGTH_SIGN_NAME_CHARS)
|
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;
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2009-09-28 19:12:15 +00:00
|
|
|
this->InitNested(desc);
|
|
|
|
|
|
|
|
this->LowerWidget(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
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-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;
|
2010-12-05 22:25:08 +00:00
|
|
|
InitializeTextBuffer(&this->text, this->edit_str_buf, this->edit_str_size, this->max_chars, MAX_LENGTH_SIGN_NAME_PIXELS);
|
2008-05-11 12:26:20 +00:00
|
|
|
|
2009-09-13 19:15:59 +00:00
|
|
|
this->SetWidgetDirty(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];
|
|
|
|
}
|
|
|
|
|
2009-09-28 19:12:15 +00:00
|
|
|
virtual void SetStringParameters(int widget) const
|
|
|
|
{
|
|
|
|
switch (widget) {
|
|
|
|
case QUERY_EDIT_SIGN_WIDGET_CAPTION:
|
|
|
|
SetDParam(0, this->caption);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-11 12:26:20 +00:00
|
|
|
virtual void OnPaint()
|
|
|
|
{
|
2008-05-17 12:48:06 +00:00
|
|
|
this->DrawWidgets();
|
2009-12-21 16:24:29 +00:00
|
|
|
if (!this->IsShaded()) this->DrawEditBox(QUERY_EDIT_SIGN_WIDGET_TEXT);
|
2008-05-11 12:26:20 +00:00
|
|
|
}
|
2007-06-30 17:51:50 +00:00
|
|
|
|
2010-01-30 18:34:48 +00:00
|
|
|
virtual void OnClick(Point pt, int widget, int click_count)
|
2008-05-11 12:26:20 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
2009-04-26 08:36:48 +00:00
|
|
|
static const NWidgetPart _nested_query_sign_edit_widgets[] = {
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-11-24 18:05:55 +00:00
|
|
|
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
|
2009-09-28 19:12:15 +00:00
|
|
|
NWidget(WWT_CAPTION, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_CAPTION), SetDataTip(STR_WHITE_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
|
2009-04-26 08:36:48 +00:00
|
|
|
EndContainer(),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY),
|
2009-08-05 17:59:21 +00:00
|
|
|
NWidget(WWT_EDITBOX, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_TEXT), SetMinimalSize(256, 12), SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL), SetPadding(2, 2, 2, 2),
|
2009-04-26 08:36:48 +00:00
|
|
|
EndContainer(),
|
|
|
|
NWidget(NWID_HORIZONTAL),
|
2009-09-28 19:12:15 +00:00
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_OK), SetMinimalSize(61, 12), SetDataTip(STR_BUTTON_OK, STR_NULL),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_CANCEL), SetMinimalSize(60, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
|
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_DELETE), SetMinimalSize(60, 12), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_NULL),
|
2009-11-24 21:13:36 +00:00
|
|
|
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
|
2010-08-12 16:44:51 +00:00
|
|
|
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_PREVIOUS), SetMinimalSize(11, 12), SetDataTip(AWV_DECREASE, STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP),
|
|
|
|
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, QUERY_EDIT_SIGN_WIDGET_NEXT), SetMinimalSize(11, 12), SetDataTip(AWV_INCREASE, STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP),
|
2009-04-26 08:36:48 +00:00
|
|
|
EndContainer(),
|
|
|
|
};
|
|
|
|
|
2009-03-15 15:12:06 +00:00
|
|
|
static const WindowDesc _query_sign_edit_desc(
|
2009-11-28 15:01:49 +00:00
|
|
|
WDP_AUTO, 0, 0,
|
2007-06-30 17:51:50 +00:00
|
|
|
WC_QUERY_STRING, WC_NONE,
|
2009-11-24 17:28:29 +00:00
|
|
|
WDF_CONSTRUCTION | WDF_UNCLICK_BUTTONS,
|
2009-11-15 10:26:01 +00:00
|
|
|
_nested_query_sign_edit_widgets, lengthof(_nested_query_sign_edit_widgets)
|
2009-03-15 15:12:06 +00:00
|
|
|
);
|
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;
|
|
|
|
}
|