From f55fdfb7c42b2e2e39b165fd17f7671e14516303 Mon Sep 17 00:00:00 2001 From: belugas Date: Sat, 10 Nov 2007 01:17:15 +0000 Subject: (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. --- src/transparency_gui.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'src/transparency_gui.cpp') 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; -- cgit v1.2.3-54-g00ecf