author | glx |
Tue, 26 Jun 2007 23:40:58 +0000 | |
branch | noai |
changeset 9629 | 66dde6412125 |
parent 9620 | 31e38d28a0af |
child 9694 | e72987579514 |
permissions | -rw-r--r-- |
9574 | 1 |
/* $Id$ */ |
2 |
||
3 |
#include "stdafx.h" |
|
4 |
#include "openttd.h" |
|
5 |
#include "table/sprites.h" |
|
6 |
#include "table/strings.h" |
|
7 |
#include "functions.h" |
|
8 |
#include "window.h" |
|
9 |
#include "gui.h" |
|
10 |
#include "viewport.h" |
|
11 |
#include "gfx.h" |
|
12 |
#include "sound.h" |
|
13 |
#include "variables.h" |
|
14 |
||
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
15 |
enum TransparencyToolbarWidgets{ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
16 |
/* Widgets not toggled when pressing the X key */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
17 |
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
18 |
|
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
19 |
/* Widgets toggled when pressing the X key */ |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
20 |
TTW_WIDGET_TREES, ///< Make trees transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
21 |
TTW_WIDGET_HOUSES, ///< Make houses transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
22 |
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
23 |
TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
24 |
TTW_WIDGET_BRIDGES, ///< Make bridges transparent |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
25 |
TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent |
9629 | 26 |
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
|
27 |
TTW_WIDGET_END, ///< End of toggle buttons |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
28 |
}; |
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 |
/** Toggle the bits of the transparencies variable |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
31 |
* when clicking on a widget, and play a sound |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
32 |
* @param widget been clicked. |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
33 |
*/ |
9574 | 34 |
static void Transparent_Click(byte widget) |
35 |
{ |
|
36 |
TOGGLEBIT(_transparent_opt, widget); |
|
37 |
SndPlayFx(SND_15_BEEP); |
|
38 |
} |
|
39 |
||
40 |
static void TransparencyToolbWndProc(Window *w, WindowEvent *e) |
|
41 |
{ |
|
42 |
switch (e->event) { |
|
43 |
case WE_PAINT: |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
44 |
/* 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
|
45 |
* 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
|
46 |
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) { |
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
47 |
SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS)); |
9574 | 48 |
} |
49 |
DrawWindowWidgets(w); |
|
50 |
break; |
|
51 |
||
52 |
case WE_CLICK: |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
53 |
if (e->we.click.widget >= TTW_WIDGET_SIGNS) { |
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
54 |
Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS); |
9574 | 55 |
MarkWholeScreenDirty(); |
56 |
} |
|
57 |
break; |
|
58 |
} |
|
59 |
} |
|
60 |
||
61 |
static const Widget _transparency_widgets[] = { |
|
62 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, |
|
9629 | 63 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 184, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS}, |
64 |
{WWT_STICKYBOX, RESIZE_NONE, 7, 185, 196, 0, 13, STR_NULL, STR_STICKY_BUTTON}, |
|
9574 | 65 |
|
9601
b499fdd106d5
(svn r9713) [NoAI] -Sync with trunk (r9631:9712).
rubidium
parents:
9574
diff
changeset
|
66 |
/* transparency widgets: |
9629 | 67 |
* 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
|
68 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_DESC}, |
9574 | 69 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC}, |
70 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC}, |
|
71 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC}, |
|
72 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC}, |
|
73 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC}, |
|
74 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC}, |
|
9629 | 75 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 175, 196, 14, 35, SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_DESC}, |
9574 | 76 |
|
77 |
{ WIDGETS_END}, |
|
78 |
}; |
|
79 |
||
80 |
static const WindowDesc _transparency_desc = { |
|
9629 | 81 |
WDP_ALIGN_TBR, 58+36, 197, 36, |
9574 | 82 |
WC_TRANSPARENCY_TOOLBAR, WC_NONE, |
83 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
|
84 |
_transparency_widgets, |
|
85 |
TransparencyToolbWndProc |
|
86 |
}; |
|
87 |
||
88 |
void ShowTransparencyToolbar(void) |
|
89 |
{ |
|
90 |
AllocateWindowDescFront(&_transparency_desc, 0); |
|
91 |
} |