summaryrefslogtreecommitdiff
path: root/src/transparency_gui.cpp
diff options
context:
space:
mode:
authorbelugas <belugas@openttd.org>2007-11-10 01:17:15 +0000
committerbelugas <belugas@openttd.org>2007-11-10 01:17:15 +0000
commitf55fdfb7c42b2e2e39b165fd17f7671e14516303 (patch)
tree07b6a8f97a15f768d33fc0b7a3405373f3745b3b /src/transparency_gui.cpp
parent3a84801f5563ca73c47c56f9682582abe990abb7 (diff)
downloadopenttd-f55fdfb7c42b2e2e39b165fd17f7671e14516303.tar.xz
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
-Codechange: Wrap all transparency settings in accessors, hiding the implementation -Change: Clicking "transparent building" menu will toggle Houses And Trees only. The other options can be used in the transparency gui. Initial patch by Smatz (FS#1349), with some rework by BigBB and your humble servant.
Diffstat (limited to 'src/transparency_gui.cpp')
-rw-r--r--src/transparency_gui.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index bebb18fa1..d66f494b9 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -11,6 +11,9 @@
#include "gfx.h"
#include "sound.h"
#include "variables.h"
+#include "transparency.h"
+
+TransparencyOptionBits _transparency_opt;
enum TransparencyToolbarWidgets{
/* Widgets not toggled when pressing the X key */
@@ -27,16 +30,6 @@ enum TransparencyToolbarWidgets{
TTW_WIDGET_END, ///< End of toggle buttons
};
-/** Toggle the bits of the transparencies variable
- * when clicking on a widget, and play a sound
- * @param widget been clicked.
- */
-static void Transparent_Click(byte widget)
-{
- TOGGLEBIT(_transparent_opt, widget);
- SndPlayFx(SND_15_BEEP);
-}
-
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
@@ -44,14 +37,16 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
/* must be sure that the widgets show the transparency variable changes
* also when we use shortcuts */
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) {
- SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
+ SetWindowWidgetLoweredState(w, i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS)));
}
DrawWindowWidgets(w);
break;
case WE_CLICK:
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
- Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
+ /* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */
+ ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS));
+ SndPlayFx(SND_15_BEEP);
MarkWholeScreenDirty();
}
break;