6307
|
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 |
|
6308
|
15 |
enum TransparencyToolbarWidgets{
|
|
16 |
/* Widgets not toggled when pressing the X key */
|
|
17 |
TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
|
|
18 |
|
|
19 |
/* Widgets toggled when pressing the X key */
|
|
20 |
TTW_WIDGET_TREES, ///< Make trees transparent
|
|
21 |
TTW_WIDGET_HOUSES, ///< Make houses transparent
|
|
22 |
TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
|
|
23 |
TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent
|
|
24 |
TTW_WIDGET_BRIDGES, ///< Make bridges transparent
|
|
25 |
TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent
|
|
26 |
};
|
|
27 |
|
|
28 |
/** Toggle the bits of the transparencies variable
|
|
29 |
* when clicking on a widget, and play a sound
|
|
30 |
* @param widget been clicked.
|
|
31 |
*/
|
6307
|
32 |
static void Transparent_Click(byte widget)
|
|
33 |
{
|
|
34 |
TOGGLEBIT(_transparent_opt, widget);
|
|
35 |
SndPlayFx(SND_15_BEEP);
|
|
36 |
}
|
|
37 |
|
|
38 |
static void TransparencyToolbWndProc(BaseWindow *w, WindowEvent *e)
|
|
39 |
{
|
|
40 |
switch (e->event) {
|
|
41 |
case WE_PAINT:
|
6308
|
42 |
/* must be sure that the widgets show the transparency variable changes
|
|
43 |
* also when we use shortcuts */
|
|
44 |
for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_STRUCTURES; i++) {
|
|
45 |
w->SetWidgetLoweredState(i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
|
6307
|
46 |
}
|
|
47 |
w->DrawWidgets();
|
|
48 |
break;
|
|
49 |
|
|
50 |
case WE_CLICK:
|
6308
|
51 |
if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
|
|
52 |
Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
|
6307
|
53 |
MarkWholeScreenDirty();
|
|
54 |
}
|
|
55 |
break;
|
|
56 |
}
|
|
57 |
}
|
|
58 |
|
|
59 |
static const OldWidget _transparency_widgets[] = {
|
|
60 |
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
|
61 |
{ WWT_CAPTION, RESIZE_NONE, 7, 11, 162, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
|
62 |
{WWT_STICKYBOX, RESIZE_NONE, 7, 163, 174, 0, 13, STR_NULL, STR_STICKY_BUTTON},
|
|
63 |
|
6308
|
64 |
/* transparency widgets:
|
|
65 |
* transparent signs, trees, houses, industries, player's buildings, bridges and unmovable structures */
|
6307
|
66 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_PLACE_SIGN, STR_TRANSPARENT_SIGNS_DESC},
|
|
67 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC},
|
|
68 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC},
|
|
69 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC},
|
|
70 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},
|
|
71 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC},
|
|
72 |
{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC},
|
|
73 |
|
|
74 |
{ WIDGETS_END},
|
|
75 |
};
|
|
76 |
|
|
77 |
static const WindowDesc _transparency_desc = {
|
|
78 |
WDP_ALIGN_TBR, 58+36, 175, 36,
|
|
79 |
WC_TRANSPARENCY_TOOLBAR, WC_NONE,
|
|
80 |
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
|
|
81 |
_transparency_widgets,
|
|
82 |
TransparencyToolbWndProc
|
|
83 |
};
|
|
84 |
|
|
85 |
void ShowTransparencyToolbar(void)
|
|
86 |
{
|
|
87 |
BaseWindow::AllocateFront(&_transparency_desc, 0);
|
|
88 |
}
|