annotate src/transparency_gui.cpp @ 13628:2123810ad874 draft

(svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
author rubidium <rubidium@openttd.org>
date Tue, 17 Nov 2009 19:16:48 +0000
parents 52ce9c06ee36
children af90d4bf0785
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
1 /* $Id$ */
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
2
12778
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
3 /*
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
4 * This file is part of OpenTTD.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
5 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
6 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
7 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
8 */
bc7926153e19 (svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents: 12632
diff changeset
9
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
10 /** @file transparency_gui.cpp The transparency GUI. */
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8806
diff changeset
11
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
12 #include "stdafx.h"
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
13 #include "openttd.h"
8107
f65cf2bc3255 (svn r11668) -Codechange: more refactoring aimed at reducing compile time and making it more logic where function definitions can be found.
rubidium <rubidium@openttd.org>
parents: 8106
diff changeset
14 #include "window_gui.h"
7849
e6ee8bfd9045 (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents: 7341
diff changeset
15 #include "transparency.h"
8157
019833e42fda (svn r11719) -Codechange: split sound.h in a header with types and one with functions.
rubidium <rubidium@openttd.org>
parents: 8131
diff changeset
16 #include "sound_func.h"
7849
e6ee8bfd9045 (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents: 7341
diff changeset
17
8264
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
18 #include "table/sprites.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
19 #include "table/strings.h"
2495310e220f (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium <rubidium@openttd.org>
parents: 8224
diff changeset
20
7849
e6ee8bfd9045 (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents: 7341
diff changeset
21 TransparencyOptionBits _transparency_opt;
8527
0ab483c54082 (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros <maedhros@openttd.org>
parents: 8452
diff changeset
22 TransparencyOptionBits _transparency_lock;
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8657
diff changeset
23 TransparencyOptionBits _invisibility_opt;
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
24
11636
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
25 /** Widget numbers of the transparency window. */
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
26 enum TransparencyToolbarWidgets {
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
27 TTW_WIDGET_CLOSEBOX, ///< Closebox.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
28 TTW_WIDGET_CAPTION, ///< Titlebar caption.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
29 TTW_WIDGET_STICKYBOX, ///< Stickybox.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
30
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
31 /* Button row. */
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
32 TTW_WIDGET_BEGIN, ///< First toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
33 TTW_WIDGET_SIGNS = TTW_WIDGET_BEGIN, ///< Signs background transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
34 TTW_WIDGET_TREES, ///< Trees transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
35 TTW_WIDGET_HOUSES, ///< Houses transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
36 TTW_WIDGET_INDUSTRIES, ///< industries transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
37 TTW_WIDGET_BUILDINGS, ///< Company buildings and structures transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
38 TTW_WIDGET_BRIDGES, ///< Bridges transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
39 TTW_WIDGET_STRUCTURES, ///< Unmovable structures transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
40 TTW_WIDGET_CATENARY, ///< Catenary transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
41 TTW_WIDGET_LOADING, ///< Loading indicators transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
42 TTW_WIDGET_END, ///< End of toggle buttons.
11636
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
43
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
44 /* Panel with buttons for invisibility */
13583
52ce9c06ee36 (svn r18107) -Codechange: Add spacer panel to end of transparency window, to fill space if title is too long.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
45 TTW_WIDGET_BUTTONS, ///< Panel with 'invisibility' buttons.
11636
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
46 };
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
47
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
48 class TransparenciesWindow : public Window
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
49 {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
50 public:
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
51 TransparenciesWindow(const WindowDesc *desc, int window_number) : Window()
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
52 {
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
53 this->InitNested(desc, window_number);
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
54 }
6496
af3092f47536 (svn r9679) -Codechange: use enums to identify transparency widgets and add a bit of documentation (patch by Wolf01)
belugas <belugas@openttd.org>
parents: 6427
diff changeset
55
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
56 virtual void OnPaint()
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
57 {
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
58 OnInvalidateData(0); // Must be sure that the widgets show the transparency variable changes, also when we use shortcuts.
9273
72a6d2e60834 (svn r13139) -Codechange: move DrawWindowWidgets and DrawWindowViewport to the Window class and remove Window from their naming.
rubidium <rubidium@openttd.org>
parents: 9203
diff changeset
59 this->DrawWidgets();
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
60 }
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8657
diff changeset
61
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
62 virtual void DrawWidget(const Rect &r, int widget) const
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
63 {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
64 switch (widget) {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
65 case TTW_WIDGET_SIGNS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
66 case TTW_WIDGET_TREES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
67 case TTW_WIDGET_HOUSES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
68 case TTW_WIDGET_INDUSTRIES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
69 case TTW_WIDGET_BUILDINGS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
70 case TTW_WIDGET_BRIDGES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
71 case TTW_WIDGET_STRUCTURES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
72 case TTW_WIDGET_CATENARY:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
73 case TTW_WIDGET_LOADING: {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
74 uint i = widget - TTW_WIDGET_BEGIN;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
75 if (HasBit(_transparency_lock, i)) DrawSprite(SPR_LOCK, PAL_NONE, r.left + 1, r.top + 1);
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
76 break;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
77 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
78 case TTW_WIDGET_BUTTONS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
79 for (uint i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
80 if (i == TTW_WIDGET_LOADING) continue; // Do not draw button for invisible loading indicators.
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
81
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13034
diff changeset
82 const NWidgetBase *wi = this->GetWidget<NWidgetBase>(i);
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
83 DrawFrameRect(wi->pos_x + 1, r.top + 2, wi->pos_x + wi->current_x - 2, r.bottom - 2, COLOUR_PALE_GREEN,
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
84 HasBit(_invisibility_opt, i - TTW_WIDGET_BEGIN) ? FR_LOWERED : FR_NONE);
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
85 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
86 break;
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
87 }
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
88 }
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
89
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
90 virtual void OnClick(Point pt, int widget)
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
91 {
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
92 if (widget >= TTW_WIDGET_BEGIN && widget < TTW_WIDGET_END) {
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
93 if (_ctrl_pressed) {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
94 /* toggle the bit of the transparencies lock variable */
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
95 ToggleTransparencyLock((TransparencyOption)(widget - TTW_WIDGET_BEGIN));
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
96 this->SetDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
97 } else {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
98 /* toggle the bit of the transparencies variable and play a sound */
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
99 ToggleTransparency((TransparencyOption)(widget - TTW_WIDGET_BEGIN));
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
100 SndPlayFx(SND_15_BEEP);
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
101 MarkWholeScreenDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
102 }
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
103 } else if (widget == TTW_WIDGET_BUTTONS) {
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
104 uint i;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
105 for (i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) {
13072
75bd67594af2 (svn r17572) -Codechange: Use the Window::GetWidget() function to access nested widgets through the nested_array.
alberth <alberth@openttd.org>
parents: 13034
diff changeset
106 const NWidgetBase *nwid = this->GetWidget<NWidgetBase>(i);
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
107 if (IsInsideBS(pt.x, nwid->pos_x, nwid->current_x))
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
108 break;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
109 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
110 if (i == TTW_WIDGET_LOADING || i == TTW_WIDGET_END) return;
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8657
diff changeset
111
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
112 ToggleInvisibility((TransparencyOption)(i - TTW_WIDGET_BEGIN));
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
113 SndPlayFx(SND_15_BEEP);
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8657
diff changeset
114
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
115 /* Redraw whole screen only if transparency is set */
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
116 if (IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_BEGIN))) {
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
117 MarkWholeScreenDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
118 } else {
13034
6eb3f749890a (svn r17532) -Codechange: Rename several Invalidate functions to SetDirty for more consistency and distinguishability.
frosch <frosch@openttd.org>
parents: 12789
diff changeset
119 this->SetWidgetDirty(TTW_WIDGET_BUTTONS);
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
120 }
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
121 }
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
122 }
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
123
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
124 virtual void OnInvalidateData(int data)
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
125 {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
126 for (uint i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
127 this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_BEGIN)));
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
128 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
129 }
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
130 };
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
131
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
132 static const NWidgetPart _nested_transparency_widgets[] = {
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
133 NWidget(NWID_HORIZONTAL),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
134 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN, TTW_WIDGET_CLOSEBOX),
12632
e41943276802 (svn r17075) -Codechange: rename ~750 strings to be more uniform with their relatives
rubidium <rubidium@openttd.org>
parents: 12533
diff changeset
135 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN, TTW_WIDGET_CAPTION), SetDataTip(STR_TRANSPARENCY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
136 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN, TTW_WIDGET_STICKYBOX),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
137 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
138 NWidget(NWID_HORIZONTAL),
12789
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
139 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_SIGNS), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
140 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_TREES), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
141 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_HOUSES), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
142 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_INDUSTRIES), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
143 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_BUILDINGS), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
144 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_BRIDGES), SetMinimalSize(43, 22), SetFill(false, true), SetDataTip(SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
145 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_STRUCTURES), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
146 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_CATENARY), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_BUILD_X_ELRAIL, STR_TRANSPARENT_CATENARY_TOOLTIP),
dd7db20331f6 (svn r17271) -Fix: SetFill sometimes used 1/0 when it should be using true/false
rubidium <rubidium@openttd.org>
parents: 12778
diff changeset
147 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_LOADING), SetMinimalSize(22, 22), SetFill(false, true), SetDataTip(SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_TOOLTIP),
13583
52ce9c06ee36 (svn r18107) -Codechange: Add spacer panel to end of transparency window, to fill space if title is too long.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
148 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, TTW_WIDGET_END), SetFill(true, true), EndContainer(),
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
149 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
150 /* Panel with 'inivisibility' buttons. */
13583
52ce9c06ee36 (svn r18107) -Codechange: Add spacer panel to end of transparency window, to fill space if title is too long.
peter1138 <peter1138@openttd.org>
parents: 13564
diff changeset
151 NWidget(WWT_PANEL, COLOUR_DARK_GREEN, TTW_WIDGET_BUTTONS), SetMinimalSize(219, 13), SetDataTip(0x0, STR_TRANSPARENT_INVISIBLE_TOOLTIP),
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
152 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
153 };
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
154
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
155 static const WindowDesc _transparency_desc(
13628
2123810ad874 (svn r18152) -Codechange: remove the 'minimum window size' from the WindowDesc; it's determined from the (nested) widgets
rubidium <rubidium@openttd.org>
parents: 13583
diff changeset
156 WDP_ALIGN_TBR, 94, 219, 49,
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
157 WC_TRANSPARENCY_TOOLBAR, WC_NONE,
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
158 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
159 _nested_transparency_widgets, lengthof(_nested_transparency_widgets)
11373
474ba6cc0946 (svn r15723) -Codechange: use a constructor for WindowDescs as that makes expanding them much easier (Alberth)
rubidium <rubidium@openttd.org>
parents: 10960
diff changeset
160 );
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
161
11967
8f2520911121 (svn r16373) -Codechange: use () instead of (void) for functions without parameters
smatz <smatz@openttd.org>
parents: 11730
diff changeset
162 void ShowTransparencyToolbar()
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
163 {
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
164 AllocateWindowDescFront<TransparenciesWindow>(&_transparency_desc, 0);
6427
2437ed7b277c (svn r9563) -Feature: Add more finer control to transparency options, including a new toolbar, accessible from the map menu or Ctrl X. Patch by Wolf01.
peter1138 <peter1138@openttd.org>
parents:
diff changeset
165 }