OpenTTD Source  14.0-beta3
signs_gui.cpp File Reference
#include "stdafx.h"
#include "company_gui.h"
#include "company_func.h"
#include "signs_base.h"
#include "signs_func.h"
#include "debug.h"
#include "command_func.h"
#include "strings_func.h"
#include "window_func.h"
#include "map_func.h"
#include "viewport_func.h"
#include "querystring_gui.h"
#include "sortlist_type.h"
#include "stringfilter_type.h"
#include "string_func.h"
#include "core/geometry_func.hpp"
#include "hotkeys.h"
#include "transparency.h"
#include "gui.h"
#include "signs_cmd.h"
#include "timer/timer.h"
#include "timer/timer_window.h"
#include "widgets/sign_widget.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "safeguards.h"

Go to the source code of this file.

Data Structures

struct  SignList
 
struct  SignListWindow
 
struct  SignWindow
 

Enumerations

enum  SignListHotkeys { SLHK_FOCUS_FILTER_BOX }
 Enum referring to the Hotkeys in the sign list window. More...
 

Functions

WindowShowSignList ()
 Open the sign list window. More...
 
static bool RenameSign (SignID index, const char *text)
 Actually rename the sign. More...
 
void HandleClickOnSign (const Sign *si)
 Handle clicking on a sign. More...
 
void ShowRenameSignWindow (const Sign *si)
 Show the window to change the text of a sign. More...
 
void DeleteRenameSignWindow (SignID sign)
 Close the sign window associated with the given sign. More...
 

Variables

static constexpr NWidgetPart _nested_sign_list_widgets []
 
static WindowDesc _sign_list_desc (__FILE__, __LINE__, WDP_AUTO, "list_signs", 358, 138, WC_SIGN_LIST, WC_NONE, 0, std::begin(_nested_sign_list_widgets), std::end(_nested_sign_list_widgets), &SignListWindow::hotkeys)
 
static constexpr NWidgetPart _nested_query_sign_edit_widgets []
 
static WindowDesc _query_sign_edit_desc (__FILE__, __LINE__, WDP_CENTER, nullptr, 0, 0, WC_QUERY_STRING, WC_NONE, WDF_CONSTRUCTION, std::begin(_nested_query_sign_edit_widgets), std::end(_nested_query_sign_edit_widgets))
 

Detailed Description

The GUI for signs.

Definition in file signs_gui.cpp.

Enumeration Type Documentation

◆ SignListHotkeys

Enum referring to the Hotkeys in the sign list window.

Enumerator
SLHK_FOCUS_FILTER_BOX 

Focus the edit box for editing the filter string.

Definition at line 136 of file signs_gui.cpp.

Function Documentation

◆ DeleteRenameSignWindow()

void DeleteRenameSignWindow ( SignID  sign)

Close the sign window associated with the given sign.

Parameters
signThe sign to close the window for.

Definition at line 592 of file signs_gui.cpp.

References Window::Close(), FindWindowById(), WC_QUERY_STRING, and WN_QUERY_STRING_SIGN.

Referenced by Sign::~Sign().

◆ HandleClickOnSign()

void HandleClickOnSign ( const Sign si)

Handle clicking on a sign.

Parameters
siThe sign that was clicked on.

Definition at line 563 of file signs_gui.cpp.

References _ctrl_pressed, _local_company, CompanyCanRenameSign(), and OWNER_DEITY.

◆ RenameSign()

static bool RenameSign ( SignID  index,
const char *  text 
)
static

Actually rename the sign.

Parameters
indexthe sign to rename.
textthe new name.
Returns
true if the window will already be removed after returning.

Definition at line 410 of file signs_gui.cpp.

References StrEmpty().

◆ ShowRenameSignWindow()

void ShowRenameSignWindow ( const Sign si)

Show the window to change the text of a sign.

Parameters
siThe sign to show the window for.

Definition at line 580 of file signs_gui.cpp.

References CloseWindowByClass(), and WC_QUERY_STRING.

◆ ShowSignList()

Window* ShowSignList ( )

Open the sign list window.

Returns
newly opened sign list window, or nullptr if the window could not be opened.

Definition at line 399 of file signs_gui.cpp.

Variable Documentation

◆ _nested_query_sign_edit_widgets

constexpr NWidgetPart _nested_query_sign_edit_widgets[]
staticconstexpr
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_GREY),
NWidget(WWT_CAPTION, COLOUR_GREY, WID_QES_CAPTION), SetDataTip(STR_JUST_STRING, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS), SetTextStyle(TC_WHITE),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, WID_QES_LOCATION), SetMinimalSize(12, 14), SetDataTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 12), SetDataTip(STR_EDIT_SIGN_SIGN_OSKTITLE, STR_NULL), SetPadding(2, 2, 2, 2),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_OK), SetMinimalSize(61, 12), SetDataTip(STR_BUTTON_OK, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_CANCEL), SetMinimalSize(60, 12), SetDataTip(STR_BUTTON_CANCEL, STR_NULL),
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_QES_DELETE), SetMinimalSize(60, 12), SetDataTip(STR_TOWN_VIEW_DELETE_BUTTON, STR_NULL),
NWidget(WWT_PANEL, COLOUR_GREY), SetFill(1, 1), EndContainer(),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_PREVIOUS), SetMinimalSize(11, 12), SetDataTip(AWV_DECREASE, STR_EDIT_SIGN_PREVIOUS_SIGN_TOOLTIP),
NWidget(WWT_PUSHARROWBTN, COLOUR_GREY, WID_QES_NEXT), SetMinimalSize(11, 12), SetDataTip(AWV_INCREASE, STR_EDIT_SIGN_NEXT_SIGN_TOOLTIP),
}

Definition at line 533 of file signs_gui.cpp.

◆ _nested_sign_list_widgets

constexpr NWidgetPart _nested_sign_list_widgets[]
staticconstexpr
Initial value:
= {
NWidget(WWT_CLOSEBOX, COLOUR_BROWN),
NWidget(WWT_CAPTION, COLOUR_BROWN, WID_SIL_CAPTION), SetDataTip(STR_SIGN_LIST_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
NWidget(WWT_SHADEBOX, COLOUR_BROWN),
NWidget(WWT_DEFSIZEBOX, COLOUR_BROWN),
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
NWidget(WWT_PANEL, COLOUR_BROWN, WID_SIL_LIST), SetMinimalSize(WidgetDimensions::unscaled.frametext.Horizontal() + 16 + 255, 0),
NWidget(WWT_PANEL, COLOUR_BROWN), SetFill(1, 1),
NWidget(WWT_EDITBOX, COLOUR_BROWN, WID_SIL_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),
NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_SIL_FILTER_MATCH_CASE_BTN), SetDataTip(STR_SIGN_LIST_MATCH_CASE, STR_SIGN_LIST_MATCH_CASE_TOOLTIP),
NWidget(WWT_RESIZEBOX, COLOUR_BROWN),
}

Definition at line 359 of file signs_gui.cpp.

SetFill
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1141
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:68
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:63
WID_QES_TEXT
@ WID_QES_TEXT
Text of the query.
Definition: sign_widget.h:28
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:67
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:77
EndContainer
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1151
WID_SIL_LIST
@ WID_SIL_LIST
List of signs.
Definition: sign_widget.h:17
WWT_PUSHARROWBTN
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:112
WID_SIL_FILTER_TEXT
@ WID_SIL_FILTER_TEXT
Text box for typing a filter string.
Definition: sign_widget.h:19
SetPadding
constexpr NWidgetPart SetPadding(uint8_t top, uint8_t right, uint8_t bottom, uint8_t left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1188
SetResize
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1086
SetScrollbar
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1244
WWT_EDITBOX
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:73
WID_QES_DELETE
@ WID_QES_DELETE
Delete button.
Definition: sign_widget.h:31
WID_QES_LOCATION
@ WID_QES_LOCATION
Scroll to sign location.
Definition: sign_widget.h:27
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:110
WID_SIL_FILTER_MATCH_CASE_BTN
@ WID_SIL_FILTER_MATCH_CASE_BTN
Button to toggle if case sensitive filtering should be used.
Definition: sign_widget.h:20
NWidget
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1258
WID_SIL_CAPTION
@ WID_SIL_CAPTION
Caption of the window.
Definition: sign_widget.h:16
WID_QES_OK
@ WID_QES_OK
OK button.
Definition: sign_widget.h:29
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:79
WidgetDimensions::unscaled
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:71
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:70
WWT_PUSHIMGBTN
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:111
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:86
WID_QES_CANCEL
@ WID_QES_CANCEL
Cancel button.
Definition: sign_widget.h:30
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:52
WID_QES_NEXT
@ WID_QES_NEXT
Next button.
Definition: sign_widget.h:33
WID_QES_CAPTION
@ WID_QES_CAPTION
Caption of the window.
Definition: sign_widget.h:26
SetMinimalSize
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1097
WID_QES_PREVIOUS
@ WID_QES_PREVIOUS
Previous button.
Definition: sign_widget.h:32
SetDataTip
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1162
AWV_INCREASE
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:34
SetTextStyle
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1120
WID_SIL_SCROLLBAR
@ WID_SIL_SCROLLBAR
Scrollbar of list.
Definition: sign_widget.h:18
WWT_TEXTBTN
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:57
AWV_DECREASE
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:33
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:66