summaryrefslogtreecommitdiff
path: root/src/transparency_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-03 19:55:40 +0000
committersmatz <smatz@openttd.org>2008-04-03 19:55:40 +0000
commitfebc5150c9ee3f2df2a1cad8ef527d9541697b22 (patch)
tree6e5ae7f6b1b5f40dbc7a0e75f50db327a96a8b37 /src/transparency_gui.cpp
parent83f9e141e038d1564ca2ed9d2ff034afbc948dbc (diff)
downloadopenttd-febc5150c9ee3f2df2a1cad8ef527d9541697b22.tar.xz
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
Diffstat (limited to 'src/transparency_gui.cpp')
-rw-r--r--src/transparency_gui.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index 6315d4391..a88e9fa1b 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -13,6 +13,7 @@
TransparencyOptionBits _transparency_opt;
TransparencyOptionBits _transparency_lock;
+TransparencyOptionBits _invisibility_opt;
enum TransparencyToolbarWidgets{
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
@@ -25,6 +26,9 @@ enum TransparencyToolbarWidgets{
TTW_WIDGET_CATENARY, ///< Make catenary transparent
TTW_WIDGET_LOADING, ///< Make loading indicators transparent
TTW_WIDGET_END, ///< End of toggle buttons
+
+ /* Panel with buttons for invisibility */
+ TTW_BUTTONS = 12, ///< Panel with 'invisibility' buttons
};
static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
@@ -41,6 +45,18 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
for (uint i = TO_SIGNS; i < TO_END; i++) {
if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, w->widget[TTW_WIDGET_SIGNS + i].left + 1, w->widget[TTW_WIDGET_SIGNS + i].top + 1);
}
+
+ /* Do not draw button for invisible loading indicators */
+ for (uint i = 0; i < 8; i++) {
+ if (i < TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) {
+ DrawFrameRect(i * 22, 38, i * 22 + 19, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ } else if (i == TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) {
+ DrawFrameRect(i * 22, 38, i * 22 + 41, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ } else { // i > TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS
+ DrawFrameRect((i + 1) * 22, 38, (i + 1) * 22 + 19, 46, true, HasBit(_invisibility_opt, i) ? FR_LOWERED : FR_NONE);
+ }
+ }
+
break;
case WE_CLICK:
@@ -55,7 +71,23 @@ static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
SndPlayFx(SND_15_BEEP);
MarkWholeScreenDirty();
}
+ } else if (e->we.click.widget == TTW_BUTTONS) {
+ uint x = e->we.click.pt.x / 22;
+
+ if (x > TTW_WIDGET_BRIDGES - TTW_WIDGET_SIGNS) x--;
+ if (x > TTW_WIDGET_CATENARY - TTW_WIDGET_SIGNS) break;
+
+ ToggleInvisibility((TransparencyOption)x);
+ SndPlayFx(SND_15_BEEP);
+
+ /* Redraw whole screen only if transparency is set */
+ if (IsTransparencySet((TransparencyOption)x)) {
+ MarkWholeScreenDirty();
+ } else {
+ w->InvalidateWidget(TTW_BUTTONS);
+ }
}
+
break;
}
}
@@ -77,11 +109,13 @@ static const Widget _transparency_widgets[] = {
{ WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_BUILD_X_ELRAIL, STR_TRANSPARENT_CATENARY_DESC},
{ WWT_IMGBTN, RESIZE_NONE, 7, 197, 218, 14, 35, SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_DESC},
+{ WWT_PANEL, RESIZE_NONE, 7, 0, 218, 36, 48, 0x0, STR_TRANSPARENT_INVISIBLE_DESC},
+
{ WIDGETS_END},
};
static const WindowDesc _transparency_desc = {
- WDP_ALIGN_TBR, 58+36, 219, 36, 219, 36,
+ WDP_ALIGN_TBR, 58+36, 219, 49, 219, 49,
WC_TRANSPARENCY_TOOLBAR, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_transparency_widgets,