summaryrefslogtreecommitdiff
path: root/src/rail_gui.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2012-07-01 23:12:50 +0000
committermichi_cc <michi_cc@openttd.org>2012-07-01 23:12:50 +0000
commitb0d21d2fadc9e7df11a2758e3e5cc411af2b0452 (patch)
tree533cf8897f15d02ccc19156034692ee32fa27976 /src/rail_gui.cpp
parenta6244ed0dc39f520283abf2530154f0ae3996f2f (diff)
downloadopenttd-b0d21d2fadc9e7df11a2758e3e5cc411af2b0452.tar.xz
(svn r24367) -Feature: [NewGRF] Customisable signals for rail types.
Diffstat (limited to 'src/rail_gui.cpp')
-rw-r--r--src/rail_gui.cpp19
1 files changed, 6 insertions, 13 deletions
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 4ce0d1785..d038af4df 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1445,16 +1445,13 @@ struct BuildSignalWindow : public PickerWindowBase {
private:
/**
* Draw dynamic a signal-sprite in a button in the signal GUI
- * Draw the sprite +1px to the right and down if the button is lowered and change the sprite to sprite + 1 (red to green light)
+ * Draw the sprite +1px to the right and down if the button is lowered
*
* @param widget_index index of this widget in the window
* @param image the sprite to draw
*/
void DrawSignalSprite(byte widget_index, SpriteID image) const
{
- /* First get the right image, which is one later for 'green' signals. */
- image += this->IsWidgetLowered(widget_index);
-
/* Next get the actual sprite so we can calculate the right offsets. */
const Sprite *sprite = GetSprite(image, ST_NORMAL);
@@ -1501,16 +1498,12 @@ public:
virtual void DrawWidget(const Rect &r, int widget) const
{
if (IsInsideMM(widget, WID_BS_SEMAPHORE_NORM, WID_BS_ELECTRIC_PBS_OWAY + 1)) {
- /* We need to do some custom sprite widget drawing for the signals. */
- const SpriteID _signal_lookup[] = {
- SPR_IMG_SIGNAL_SEMAPHORE_NORM, SPR_IMG_SIGNAL_SEMAPHORE_ENTRY, SPR_IMG_SIGNAL_SEMAPHORE_EXIT,
- SPR_IMG_SIGNAL_SEMAPHORE_COMBO, SPR_IMG_SIGNAL_SEMAPHORE_PBS, SPR_IMG_SIGNAL_SEMAPHORE_PBS_OWAY,
-
- SPR_IMG_SIGNAL_ELECTRIC_NORM, SPR_IMG_SIGNAL_ELECTRIC_ENTRY, SPR_IMG_SIGNAL_ELECTRIC_EXIT,
- SPR_IMG_SIGNAL_ELECTRIC_COMBO, SPR_IMG_SIGNAL_ELECTRIC_PBS, SPR_IMG_SIGNAL_ELECTRIC_PBS_OWAY
- };
+ /* Extract signal from widget number. */
+ int type = (widget - WID_BS_SEMAPHORE_NORM) % SIGTYPE_END;
+ int var = SIG_SEMAPHORE - (widget - WID_BS_SEMAPHORE_NORM) / SIGTYPE_END; // SignalVariant order is reversed compared to the widgets.
+ SpriteID sprite = GetRailTypeInfo(_cur_railtype)->gui_sprites.signals[type][var][this->IsWidgetLowered(widget)];
- this->DrawSignalSprite(widget, _signal_lookup[widget - WID_BS_SEMAPHORE_NORM]);
+ this->DrawSignalSprite(widget, sprite);
}
}