summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-09-28 12:38:35 +0000
committerrubidium <rubidium@openttd.org>2009-09-28 12:38:35 +0000
commit4347758e489b37a9d28c0b4b75931ed30fb6eb38 (patch)
tree1f4334b49ad6f416bd7c4903cf63891404f2e9e4
parentd74216b7feb020cb09f677053e4a9bd0cbbf0eee (diff)
downloadopenttd-4347758e489b37a9d28c0b4b75931ed30fb6eb38.tar.xz
(svn r17658) -Codechange: remove custom drawing of the signal density in the signal GUI
-Codechange: move the state updates from OnPaint
-rw-r--r--src/lang/english.txt1
-rw-r--r--src/rail_gui.cpp37
-rw-r--r--src/settings.cpp2
3 files changed, 25 insertions, 15 deletions
diff --git a/src/lang/english.txt b/src/lang/english.txt
index 0027c6dbc..119eafde1 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -3999,6 +3999,7 @@ STR_WHITE_DATE_LONG :{WHITE}{DATE_LO
STR_SHORT_DATE :{WHITE}{DATE_TINY}
STR_DATE_LONG_SMALL :{TINYFONT}{BLACK}{DATE_LONG}
STR_TINY_GROUP :{TINYFONT}{GROUP}
+STR_ORANGE_INT :{ORANGE}{NUM}
STR_WHITE_SIGN :{WHITE}{SIGN}
STR_TINY_BLACK_STATIONL :{TINYFONT}{BLACK}{STATION}
STR_BLACK_STRING :{BLACK}{STRING}
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index dad85159b..fc2fc7818 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1512,6 +1512,7 @@ enum BuildSignalWidgets {
BSW_ELECTRIC_PBS_OWAY,
BSW_CONVERT,
BSW_DRAG_SIGNALS_DENSITY,
+ BSW_DRAG_SIGNALS_DENSITY_LABEL,
BSW_DRAG_SIGNALS_DENSITY_DECREASE,
BSW_DRAG_SIGNALS_DENSITY_INCREASE,
};
@@ -1556,17 +1557,20 @@ public:
BuildSignalWindow(const WindowDesc *desc, Window *parent) : PickerWindowBase(parent)
{
this->InitNested(desc, TRANSPORT_RAIL);
+ this->OnInvalidateData();
};
- virtual void OnPaint()
+ virtual void SetStringParameters(int widget) const
{
- this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
-
- this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
-
- this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
- this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
+ switch (widget) {
+ case BSW_DRAG_SIGNALS_DENSITY_LABEL:
+ SetDParam(0, _settings_client.gui.drag_signals_density);
+ break;
+ }
+ }
+ virtual void OnPaint()
+ {
this->DrawWidgets();
this->DrawSignalSprite(BSW_SEMAPHORE_NORM, SPR_IMG_SIGNAL_SEMAPHORE_NORM);
@@ -1581,12 +1585,6 @@ public:
this->DrawSignalSprite(BSW_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_COMBO);
this->DrawSignalSprite(BSW_ELECTRIC_PBS, SPR_IMG_SIGNAL_ELECTRIC_PBS);
this->DrawSignalSprite(BSW_ELECTRIC_PBS_OWAY, SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY);
-
- /* Draw dragging signal density value in the BSW_DRAG_SIGNALS_DENSITY widget */
- SetDParam(0, _settings_client.gui.drag_signals_density);
- int right = this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_x + this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->current_x - 1;
- DrawString(this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_x, right,
- this->GetWidget<NWidgetBase>(BSW_DRAG_SIGNALS_DENSITY)->pos_y + 2, STR_JUST_INT, TC_ORANGE, SA_CENTER);
}
virtual void OnClick(Point pt, int widget)
@@ -1632,6 +1630,17 @@ public:
}
this->SetDirty();
+ this->OnInvalidateData();
+ }
+
+ virtual void OnInvalidateData(int data = 0)
+ {
+ this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
+
+ this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
+
+ this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_DECREASE, _settings_client.gui.drag_signals_density == 1);
+ this->SetWidgetDisabledState(BSW_DRAG_SIGNALS_DENSITY_INCREASE, _settings_client.gui.drag_signals_density == 20);
}
};
@@ -1658,7 +1667,7 @@ static const NWidgetPart _nested_signal_builder_widgets[] = {
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_TOOLTIP), EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_ELECTRIC_PBS_OWAY), SetMinimalSize(22, 27), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_ELECTRIC_PBS_OWAY_TOOLTIP), EndContainer(),
NWidget(WWT_PANEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY), SetDataTip(STR_NULL, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP),
- NWidget(NWID_SPACER), SetMinimalSize(0, 13),
+ NWidget(WWT_LABEL, COLOUR_DARK_GREEN, BSW_DRAG_SIGNALS_DENSITY_LABEL), SetMinimalSize(0, 13), SetDataTip(STR_ORANGE_INT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_TOOLTIP), SetFill(true, true),
NWidget(NWID_HORIZONTAL), SetPIP(2, 0, 2),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_DECREASE), SetMinimalSize(9, 12), SetDataTip(SPR_ARROW_LEFT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_DECREASE_TOOLTIP),
NWidget(WWT_PUSHIMGBTN, COLOUR_GREY, BSW_DRAG_SIGNALS_DENSITY_INCREASE), SetMinimalSize(9, 12), SetDataTip(SPR_ARROW_RIGHT, STR_BUILD_SIGNAL_DRAG_SIGNALS_DENSITY_INCREASE_TOOLTIP),
diff --git a/src/settings.cpp b/src/settings.cpp
index d7ac17356..7ea4ff194 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -751,7 +751,7 @@ static bool TrainAccelerationModelChanged(int32 p1)
static bool DragSignalsDensityChanged(int32)
{
- SetWindowDirty(WC_BUILD_SIGNAL, 0);
+ InvalidateWindowData(WC_BUILD_SIGNAL, 0);
return true;
}