10 |
10 |
11 #include "table/sprites.h" |
11 #include "table/sprites.h" |
12 #include "table/strings.h" |
12 #include "table/strings.h" |
13 |
13 |
14 TransparencyOptionBits _transparency_opt; |
14 TransparencyOptionBits _transparency_opt; |
|
15 TransparencyOptionBits _transparency_lock; |
15 |
16 |
16 enum TransparencyToolbarWidgets{ |
17 enum TransparencyToolbarWidgets{ |
17 /* Widgets not toggled when pressing the X key */ |
|
18 TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent |
18 TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent |
19 |
|
20 /* Widgets toggled when pressing the X key */ |
|
21 TTW_WIDGET_TREES, ///< Make trees transparent |
19 TTW_WIDGET_TREES, ///< Make trees transparent |
22 TTW_WIDGET_HOUSES, ///< Make houses transparent |
20 TTW_WIDGET_HOUSES, ///< Make houses transparent |
23 TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent |
21 TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent |
24 TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent |
22 TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent |
25 TTW_WIDGET_BRIDGES, ///< Make bridges transparent |
23 TTW_WIDGET_BRIDGES, ///< Make bridges transparent |
37 for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) { |
35 for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) { |
38 w->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS))); |
36 w->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS))); |
39 } |
37 } |
40 |
38 |
41 DrawWindowWidgets(w); |
39 DrawWindowWidgets(w); |
|
40 for (uint i = TO_SIGNS; i < TO_END; i++) { |
|
41 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); |
|
42 } |
42 break; |
43 break; |
43 |
44 |
44 case WE_CLICK: |
45 case WE_CLICK: |
45 if (e->we.click.widget >= TTW_WIDGET_SIGNS) { |
46 if (e->we.click.widget >= TTW_WIDGET_SIGNS) { |
46 /* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */ |
47 if (_ctrl_pressed) { |
47 ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS)); |
48 /* toggle the bit of the transparencies lock variable */ |
48 SndPlayFx(SND_15_BEEP); |
49 ToggleTransparencyLock((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS)); |
49 MarkWholeScreenDirty(); |
50 SetWindowDirty(w); |
|
51 } else { |
|
52 /* toggle the bit of the transparencies variable and play a sound */ |
|
53 ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS)); |
|
54 SndPlayFx(SND_15_BEEP); |
|
55 MarkWholeScreenDirty(); |
|
56 } |
50 } |
57 } |
51 break; |
58 break; |
52 } |
59 } |
53 } |
60 } |
54 |
61 |