GUI related to programming signals. More...
#include "stdafx.h"
#include "programmable_signals.h"
#include "command_func.h"
#include "window_func.h"
#include "strings_func.h"
#include "string_func.h"
#include "viewport_func.h"
#include "textbuf_gui.h"
#include "company_func.h"
#include "widgets/dropdown_func.h"
#include "gui.h"
#include "gfx_func.h"
#include "tilehighlight_func.h"
#include "rail_map.h"
#include "tile_cmd.h"
#include "table/sprites.h"
#include "table/strings.h"
Go to the source code of this file.
Data Structures | |
struct | GuiInstruction |
class | ProgramWindow |
class | SpeedWindow |
Typedefs | |
typedef SmallVector < GuiInstruction, 4 > | GuiInstructionList |
Enumerations | |
enum | ProgramWindowWidgets { PROGRAM_WIDGET_CAPTION, PROGRAM_WIDGET_INSTRUCTION_LIST, PROGRAM_WIDGET_SCROLLBAR, PROGRAM_WIDGET_SEL_TOP_LEFT, PROGRAM_WIDGET_SEL_TOP_MIDDLE, PROGRAM_WIDGET_SEL_TOP_RIGHT, PROGRAM_WIDGET_SET_STATE, PROGRAM_WIDGET_COND_VARIABLE, PROGRAM_WIDGET_COND_COMPARATOR, PROGRAM_WIDGET_COND_VALUE, PROGRAM_WIDGET_COND_GOTO_SIGNAL, PROGRAM_WIDGET_COND_SET_SIGNAL, PROGRAM_WIDGET_GOTO_SIGNAL, PROGRAM_WIDGET_INSERT, PROGRAM_WIDGET_REMOVE } |
enum | PanelWidgets { DPL_COND_VARIABLE = 0, DPL_SET_STATE, DPM_COND_COMPARATOR = 0, DPM_COND_GOTO_SIGNAL, DPR_COND_VALUE = 0, DPR_COND_SET_SIGNAL } |
enum | SpeedWindowWidgets { SPEED_WIDGET_CAPTION, SPEED_WIDGET_VALUE, SPEED_WIDGET_CLEAR, SPEED_WIDGET_CHANGE } |
Functions | |
static SignalOpcode | OpcodeForIndex (int index) |
static bool | IsConditionComparator (SignalCondition *cond) |
static char * | GetConditionString (SignalCondition *cond, char *buf, char *buflast, bool selected) |
Get the string for a condition. | |
static void | DrawInstructionString (SignalInstruction *instruction, int y, bool selected, int indent, int left, int right) |
Draws an instruction in the programming GUI. | |
void | ShowSignalProgramWindow (SignalReference ref) |
uint | ConvertSpeedToDisplaySpeed (uint speed) |
Convert the given (internal) speed to the display speed. | |
uint | ConvertDisplaySpeedToSpeed (uint speed) |
Convert the given display speed to the (internal) speed. | |
void | ShowSpeedSignalWindow (SignalReference ref) |
Variables | |
static const StringID | _program_insert [] |
static const StringID | _program_condvar [] |
static const StringID | _program_comparator [] |
static const StringID | _program_sigstate [] |
static const NWidgetPart | _nested_program_widgets [] |
static const WindowDesc | _program_desc (WDP_AUTO, 384, 100, WC_SIGNAL_PROGRAM, WC_BUILD_SIGNAL, WDF_CONSTRUCTION, _nested_program_widgets, lengthof(_nested_program_widgets)) |
static const NWidgetPart | _nested_speed_widgets [] |
static const WindowDesc | _speed_desc (WDP_AUTO, 384, 100, WC_SPEED_SIGNAL, WC_BUILD_SIGNAL, WDF_CONSTRUCTION, _nested_speed_widgets, lengthof(_nested_speed_widgets)) |
GUI related to programming signals.
Definition in file programmable_signals_gui.cpp.
uint ConvertDisplaySpeedToSpeed | ( | uint | speed | ) |
Convert the given display speed to the (internal) speed.
speed | the speed to convert |
Definition at line 675 of file strings.cpp.
References _settings_game, Units::c_velocity, UnitConversion::FromDisplay(), GameSettings::locale, and LocaleSettings::units.
uint ConvertSpeedToDisplaySpeed | ( | uint | speed | ) |
Convert the given (internal) speed to the display speed.
speed | the speed to convert |
Definition at line 662 of file strings.cpp.
References _settings_game, Units::c_velocity, GameSettings::locale, UnitConversion::ToDisplay(), and LocaleSettings::units.
static void DrawInstructionString | ( | SignalInstruction * | instruction, | |
int | y, | |||
bool | selected, | |||
int | indent, | |||
int | left, | |||
int | right | |||
) | [static] |
Draws an instruction in the programming GUI.
instruction | The instruction to draw. | |
y | Y position for drawing. | |
selected | True, if the order is selected. | |
indent | How many levels the instruction is indented. | |
left | Left border for text drawing. | |
right | Right border for text drawing. |
Definition at line 154 of file programmable_signals_gui.cpp.
References SignalIf::condition, DrawString(), GetConditionString(), INVALID_STRING_ID, lastof, PSO_FIRST, PSO_IF, PSO_IF_ELSE, PSO_IF_ENDIF, PSO_LAST, PSO_SET_SIGNAL, SetDParam(), and SetDParamStr().
Referenced by ProgramWindow::DrawWidget().
static char* GetConditionString | ( | SignalCondition * | cond, | |
char * | buf, | |||
char * | buflast, | |||
bool | selected | |||
) | [static] |
Get the string for a condition.
Definition at line 122 of file programmable_signals_gui.cpp.
References INVALID_STRING_ID, and SetDParam().
Referenced by DrawInstructionString().
const NWidgetPart _nested_speed_widgets[] [static] |
{ NWidget(NWID_HORIZONTAL), NWidget(WWT_CLOSEBOX, COLOUR_GREY), NWidget(WWT_CAPTION, COLOUR_GREY, SPEED_WIDGET_CAPTION), SetDataTip(STR_SPEEDSIG_CAPTION, STR_NULL), NWidget(WWT_STICKYBOX, COLOUR_GREY), EndContainer(), NWidget(WWT_PANEL, COLOUR_GREY), NWidget(WWT_LABEL, COLOUR_GREY, SPEED_WIDGET_VALUE), SetMinimalSize(128, 12), SetFill(1, 1), SetPadding(2, 2, 2, 2), EndContainer(), NWidget(NWID_HORIZONTAL, NC_EQUALSIZE), NWidget(WWT_TEXTBTN, COLOUR_GREY, SPEED_WIDGET_CLEAR), SetDataTip(STR_SPEEDSIG_CLEAR, STR_NULL), SetMinimalSize(87, 12), SetFill(1, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, SPEED_WIDGET_CHANGE), SetDataTip(STR_SPEEDSIG_CHANGE, STR_NULL), SetMinimalSize(87, 12), SetFill(1, 0), EndContainer(), }
Definition at line 886 of file programmable_signals_gui.cpp.
const StringID _program_comparator[] [static] |
{ STR_ORDER_CONDITIONAL_COMPARATOR_EQUALS, STR_ORDER_CONDITIONAL_COMPARATOR_NOT_EQUALS, STR_ORDER_CONDITIONAL_COMPARATOR_LESS_THAN, STR_ORDER_CONDITIONAL_COMPARATOR_LESS_EQUALS, STR_ORDER_CONDITIONAL_COMPARATOR_MORE_THAN, STR_ORDER_CONDITIONAL_COMPARATOR_MORE_EQUALS, STR_ORDER_CONDITIONAL_COMPARATOR_IS_TRUE, STR_ORDER_CONDITIONAL_COMPARATOR_IS_FALSE, INVALID_STRING_ID }
Definition at line 103 of file programmable_signals_gui.cpp.
const StringID _program_condvar[] [static] |
{ STR_PROGSIG_COND_ALWAYS, STR_PROGSIG_COND_NEVER, STR_PROGSIG_CONDVAR_NUM_GREEN, STR_PROGSIG_CONDVAR_NUM_RED, STR_PROGSIG_COND_SIGNAL_STATE, INVALID_STRING_ID }
Definition at line 93 of file programmable_signals_gui.cpp.
const StringID _program_insert[] [static] |
{ STR_PROGSIG_INSERT_IF, STR_PROGSIG_INSERT_SET_SIGNAL, INVALID_STRING_ID }
Definition at line 66 of file programmable_signals_gui.cpp.
const StringID _program_sigstate[] [static] |
{ STR_COLOUR_RED, STR_COLOUR_GREEN, INVALID_STRING_ID }
Definition at line 115 of file programmable_signals_gui.cpp.