OpenTTD Source  20241108-master-g80f628063a
signs_gui.cpp File Reference

The GUI for signs. More...

#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 (WDP_AUTO, "list_signs", 358, 138, WC_SIGN_LIST, WC_NONE, 0, _nested_sign_list_widgets, &SignListWindow::hotkeys)
 
static constexpr NWidgetPart _nested_query_sign_edit_widgets []
 
static WindowDesc _query_sign_edit_desc (WDP_CENTER, nullptr, 0, 0, WC_QUERY_STRING, WC_NONE, WDF_CONSTRUCTION, _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 585 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 556 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 403 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 573 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 392 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), SetAspect(WidgetDimensions::ASPECT_LOCATION), SetDataTip(SPR_GOTO_LOCATION, STR_EDIT_SIGN_LOCATION_TOOLTIP),
NWidget(WWT_PANEL, COLOUR_GREY),
NWidget(WWT_EDITBOX, COLOUR_GREY, WID_QES_TEXT), SetMinimalSize(256, 0), 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),
}
constexpr NWidgetPart SetFill(uint16_t fill_x, uint16_t fill_y)
Widget part function for setting filling.
Definition: widget_type.h:1181
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:1228
constexpr NWidgetPart SetDataTip(uint32_t data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1202
constexpr NWidgetPart SetTextStyle(TextColour colour, FontSize size=FS_NORMAL)
Widget part function for setting the text style.
Definition: widget_type.h:1160
constexpr NWidgetPart SetMinimalSize(int16_t x, int16_t y)
Widget part function for setting the minimal size.
Definition: widget_type.h:1137
constexpr NWidgetPart NWidget(WidgetType tp, Colours col, WidgetID idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1309
constexpr NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:1191
constexpr NWidgetPart SetAspect(float ratio, AspectFlags flags=AspectFlags::ResizeX)
Widget part function for setting the aspect ratio.
Definition: widget_type.h:1295
@ WID_QES_PREVIOUS
Previous button.
Definition: sign_widget.h:31
@ WID_QES_LOCATION
Scroll to sign location.
Definition: sign_widget.h:26
@ WID_QES_CANCEL
Cancel button.
Definition: sign_widget.h:29
@ WID_QES_OK
OK button.
Definition: sign_widget.h:28
@ WID_QES_NEXT
Next button.
Definition: sign_widget.h:32
@ WID_QES_DELETE
Delete button.
Definition: sign_widget.h:30
@ WID_QES_TEXT
Text of the query.
Definition: sign_widget.h:27
@ WID_QES_CAPTION
Caption of the window.
Definition: sign_widget.h:25
@ AWV_DECREASE
Arrow to the left or in case of RTL to the right.
Definition: widget_type.h:31
@ AWV_INCREASE
Arrow to the right or in case of RTL to the left.
Definition: widget_type.h:32
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:112
@ WWT_PUSHIMGBTN
Normal push-button (no toggle button) with image caption.
Definition: widget_type.h:113
@ WWT_PUSHARROWBTN
Normal push-button (no toggle button) with arrow caption.
Definition: widget_type.h:114
@ WWT_EDITBOX
a textbox for typing
Definition: widget_type.h:71
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:75
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:50
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:61
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:69

Definition at line 526 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, 0), 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),
}
static const WidgetDimensions unscaled
Unscaled widget dimensions.
Definition: window_gui.h:67
constexpr NWidgetPart SetScrollbar(WidgetID index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1284
constexpr NWidgetPart SetResize(int16_t dx, int16_t dy)
Widget part function for setting the resize step.
Definition: widget_type.h:1126
@ WID_SIL_SCROLLBAR
Scrollbar of list.
Definition: sign_widget.h:18
@ WID_SIL_FILTER_MATCH_CASE_BTN
Button to toggle if case sensitive filtering should be used.
Definition: sign_widget.h:20
@ WID_SIL_FILTER_TEXT
Text box for typing a filter string.
Definition: sign_widget.h:19
@ WID_SIL_CAPTION
Caption of the window.
Definition: sign_widget.h:16
@ WID_SIL_LIST
List of signs.
Definition: sign_widget.h:17
@ WWT_TEXTBTN
(Toggle) Button with text
Definition: widget_type.h:55
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:66
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:64
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:84
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:77
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:68
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:65

Definition at line 352 of file signs_gui.cpp.