summaryrefslogtreecommitdiff
path: root/src/music_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-19 20:34:45 +0000
committerrubidium <rubidium@openttd.org>2009-11-19 20:34:45 +0000
commit16f270467fc45d28bbc61741caf84fbeb094ebfe (patch)
tree2e759aa420f1c0ef77d7fbc4941ae9a099d991e6 /src/music_gui.cpp
parent0658ce739abd3e126fdb9a7ef7b52ec9ec42c1cd (diff)
downloadopenttd-16f270467fc45d28bbc61741caf84fbeb094ebfe.tar.xz
(svn r18192) -Codechange: make the music window RTL aware
Diffstat (limited to 'src/music_gui.cpp')
-rw-r--r--src/music_gui.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index 9f3a86d9b..6d6dfc59e 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -493,6 +493,12 @@ struct MusicWindow : public Window {
d.height += WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
*size = maxdim(*size, d);
} break;
+
+ /* Hack-ish: set the proper widget data; only needs to be done once
+ * per (Re)Init as that's the only time the language changes. */
+ case MW_PREV: this->GetWidget<NWidgetCore>(MW_PREV)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_SKIP_TO_NEXT : SPR_IMG_SKIP_TO_PREV; break;
+ case MW_NEXT: this->GetWidget<NWidgetCore>(MW_NEXT)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_SKIP_TO_PREV : SPR_IMG_SKIP_TO_NEXT; break;
+ case MW_PLAY: this->GetWidget<NWidgetCore>(MW_PLAY)->widget_data = _dynlang.text_dir == TD_RTL ? SPR_IMG_PLAY_MUSIC_RTL : SPR_IMG_PLAY_MUSIC; break;
}
}
@@ -543,7 +549,12 @@ struct MusicWindow : public Window {
DrawString(r.left, r.right, r.bottom - FONT_HEIGHT_SMALL, STR_MUSIC_MIN_MAX_RULER, TC_FROMSTRING, SA_CENTER);
y = (r.top + r.bottom - slider_height) / 2;
byte volume = (widget == MW_MUSIC_VOL) ? msf.music_vol : msf.effect_vol;
- int x = r.left + (volume * (r.right - r.left) / 127);
+ int x = (volume * (r.right - r.left) / 127);
+ if (_dynlang.text_dir == TD_RTL) {
+ x = r.right - x;
+ } else {
+ x += r.left;
+ }
DrawFrameRect(x, y, x + slider_width, y + slider_height, COLOUR_GREY, FR_NONE);
} break;
}
@@ -591,6 +602,7 @@ struct MusicWindow : public Window {
byte *vol = (widget == MW_MUSIC_VOL) ? &msf.music_vol : &msf.effect_vol;
byte new_vol = x * 127 / this->GetWidget<NWidgetBase>(widget)->current_x;
+ if (_dynlang.text_dir == TD_RTL) new_vol = 127 - new_vol;
if (new_vol != *vol) {
*vol = new_vol;
if (widget == MW_MUSIC_VOL) MusicVolumeChanged(new_vol);