author | rubidium |
Sun, 03 Feb 2008 20:17:54 +0000 | |
branch | noai |
changeset 9724 | b39bc69bb2f2 |
parent 9723 | eee46cb39750 |
child 9732 | f8eb3e208514 |
permissions | -rw-r--r-- |
9574 | 1 |
/* $Id$ */ |
2 |
||
3 |
#include "stdafx.h" |
|
4 |
#include "openttd.h" |
|
5 |
#include "gui.h" |
|
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
6 |
#include "window_gui.h" |
9574 | 7 |
#include "variables.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
8 |
#include "transparency.h" |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "sound_func.h" |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
10 |
|
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
11 |
#include "table/sprites.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
12 |
#include "table/strings.h" |
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
13 |
|
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
14 |
TransparencyOptionBits _transparency_opt; |
9574 | 15 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
16 |
enum TransparencyToolbarWidgets{ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
17 |
/* Widgets not toggled when pressing the X key */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
18 |
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
19 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
20 |
/* Widgets toggled when pressing the X key */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
21 |
TTW_WIDGET_TREES, ///< Make trees transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
22 |
TTW_WIDGET_HOUSES, ///< Make houses transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
23 |
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
24 |
TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
25 |
TTW_WIDGET_BRIDGES, ///< Make bridges transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
26 |
TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent |
9629 | 27 |
TTW_WIDGET_LOADING, ///< Make loading indicators transperent |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
28 |
TTW_WIDGET_END, ///< End of toggle buttons |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
29 |
}; |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
30 |
|
9574 | 31 |
static void TransparencyToolbWndProc(Window *w, WindowEvent *e) |
32 |
{ |
|
33 |
switch (e->event) { |
|
34 |
case WE_PAINT: |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
35 |
/* must be sure that the widgets show the transparency variable changes |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
36 |
* also when we use shortcuts */ |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
37 |
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) { |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
38 |
w->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_SIGNS))); |
9574 | 39 |
} |
9724
b39bc69bb2f2
(svn r12051) [NoAI] -Sync: with trunk (r11795:12050).
rubidium
parents:
9723
diff
changeset
|
40 |
|
9574 | 41 |
DrawWindowWidgets(w); |
42 |
break; |
|
43 |
||
44 |
case WE_CLICK: |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
45 |
if (e->we.click.widget >= TTW_WIDGET_SIGNS) { |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
46 |
/* toggle the bit of the transparencies variable when clicking on a widget, and play a sound */ |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
47 |
ToggleTransparency((TransparencyOption)(e->we.click.widget - TTW_WIDGET_SIGNS)); |
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9694
diff
changeset
|
48 |
SndPlayFx(SND_15_BEEP); |
9574 | 49 |
MarkWholeScreenDirty(); |
50 |
} |
|
51 |
break; |
|
52 |
} |
|
53 |
} |
|
54 |
||
55 |
static const Widget _transparency_widgets[] = { |
|
56 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
9629 | 57 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 184, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
58 |
{WWT_STICKYBOX, RESIZE_NONE, 7, 185, 196, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
|
9574 | 59 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
60 |
/* transparency widgets: |
9629 | 61 |
* transparent signs, trees, houses, industries, player's buildings, bridges, unmovable structures and loading indicators */ |
9620
31e38d28a0af
(svn r9816) [NoAI] -Sync with trunk r9712:9815 except r9759 (MorphOS threading) because that needs special attention.
rubidium
parents:
9601
diff
changeset
|
62 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_DESC}, |
9574 | 63 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC}, |
64 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC}, |
|
65 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC}, |
|
66 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC}, |
|
67 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC}, |
|
68 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC}, |
|
9629 | 69 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_DESC}, |
9574 | 70 |
|
71 |
{ WIDGETS_END}, |
|
72 |
}; |
|
73 |
||
74 |
static const WindowDesc _transparency_desc = { |
|
9694
e72987579514
(svn r10775) [NoAI] -Sync: with trunk r10535:r10774.
rubidium
parents:
9629
diff
changeset
|
75 |
WDP_ALIGN_TBR, 58+36, 197, 36, 197, 36, |
9574 | 76 |
WC_TRANSPARENCY_TOOLBAR, WC_NONE, |
77 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
|
78 |
_transparency_widgets, |
|
79 |
TransparencyToolbWndProc |
|
80 |
}; |
|
81 |
||
82 |
void ShowTransparencyToolbar(void) |
|
83 |
{ |
|
84 |
AllocateWindowDescFront(&_transparency_desc, 0); |
|
85 |
} |