annotate src/transparency_gui.cpp @ 14396:4de60292e2a6 draft

(svn r18953) -Feature: [NoAI] allow editing AI settings while an AI is running Only settings with the AICONFIG_INGAME flag can be editted in this way
author yexo <yexo@openttd.org>
date Fri, 29 Jan 2010 21:38:55 +0000
parents a899d4e5ee1a
children 1eaefde497fd
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"
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
13 #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
14 #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
15 #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
16
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
17 #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
18 #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
19
7849
e6ee8bfd9045 (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas <belugas@openttd.org>
parents: 7341
diff changeset
20 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
21 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
22 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
23
11636
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
24 /** 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
25 enum TransparencyToolbarWidgets {
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
26 /* Button row. */
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
27 TTW_WIDGET_BEGIN, ///< First toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
28 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
29 TTW_WIDGET_TREES, ///< Trees transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
30 TTW_WIDGET_HOUSES, ///< Houses transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
31 TTW_WIDGET_INDUSTRIES, ///< industries transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
32 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
33 TTW_WIDGET_BRIDGES, ///< Bridges transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
34 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
35 TTW_WIDGET_CATENARY, ///< Catenary transparency toggle button.
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
36 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
37 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
38
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
39 /* 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
40 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
41 };
af4c3f370d2e (svn r16016) -Codechange: Moving the TransparencyToolbarWidgets outside the window class.
alberth <alberth@openttd.org>
parents: 11635
diff changeset
42
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
43 class TransparenciesWindow : public Window
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
44 {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
45 public:
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
46 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
47 {
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
48 this->InitNested(desc, window_number);
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
49 }
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
50
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
51 virtual void OnPaint()
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 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
54 this->DrawWidgets();
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
55 }
8806
104bbcae351d (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz <smatz@openttd.org>
parents: 8657
diff changeset
56
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
57 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
58 {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
59 switch (widget) {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
60 case TTW_WIDGET_SIGNS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
61 case TTW_WIDGET_TREES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
62 case TTW_WIDGET_HOUSES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
63 case TTW_WIDGET_INDUSTRIES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
64 case TTW_WIDGET_BUILDINGS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
65 case TTW_WIDGET_BRIDGES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
66 case TTW_WIDGET_STRUCTURES:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
67 case TTW_WIDGET_CATENARY:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
68 case TTW_WIDGET_LOADING: {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
69 uint i = widget - TTW_WIDGET_BEGIN;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
70 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
71 break;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
72 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
73 case TTW_WIDGET_BUTTONS:
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
74 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
75 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
76
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
77 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
78 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
79 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
80 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
81 break;
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
82 }
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
83 }
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
84
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
85 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
86 {
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
87 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
88 if (_ctrl_pressed) {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
89 /* 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
90 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
91 this->SetDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
92 } else {
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
93 /* 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
94 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
95 SndPlayFx(SND_15_BEEP);
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
96 MarkWholeScreenDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
97 }
12532
4124b3a47039 (svn r16969) -Codechange: Normalizing transparency gui widget numbers.
alberth <alberth@openttd.org>
parents: 11967
diff changeset
98 } 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
99 uint i;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
100 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
101 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
102 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
103 break;
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
104 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
105 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
106
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
107 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
108 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
109
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
110 /* 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
111 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
112 MarkWholeScreenDirty();
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
113 } 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
114 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
115 }
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
116 }
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
117 }
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
118
13794
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
119 virtual Point OnInitialPosition(const WindowDesc *desc, int16 sm_width, int16 sm_height, int window_number)
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
120 {
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
121 Point pt = GetToolbarAlignedWindowPosition(sm_width);
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
122 pt.y += 2 * (sm_height - this->GetWidget<NWidgetBase>(TTW_WIDGET_BUTTONS)->current_y);
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
123 return pt;
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
124 }
d82cab078498 (svn r18320) -Codechange: make the terraform and transparency window not use absolute location but manually calculate based on toolbar size etc.
rubidium <rubidium@openttd.org>
parents: 13755
diff changeset
125
12533
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
126 virtual void OnInvalidateData(int data)
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
127 {
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
128 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
129 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
130 }
f4fd476eafce (svn r16970) -Codechange: Transparency window uses nested widgets only.
alberth <alberth@openttd.org>
parents: 12532
diff changeset
131 }
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
132 };
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
133
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
134 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
135 NWidget(NWID_HORIZONTAL),
13752
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
136 NWidget(WWT_CLOSEBOX, COLOUR_DARK_GREEN),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
137 NWidget(WWT_CAPTION, COLOUR_DARK_GREEN), SetDataTip(STR_TRANSPARENCY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
517d77f53919 (svn r18277) -Codechange: remove unneeded widget indices for close, resize and sticky boxes and for window captions
rubidium <rubidium@openttd.org>
parents: 13749
diff changeset
138 NWidget(WWT_STICKYBOX, COLOUR_DARK_GREEN),
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
139 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
140 NWidget(NWID_HORIZONTAL),
13704
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
141 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_SIGNS), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_SIGN, STR_TRANSPARENT_SIGNS_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
142 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_TREES), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
143 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_HOUSES), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
144 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_INDUSTRIES), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
145 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_BUILDINGS), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
146 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_BRIDGES), SetMinimalSize(43, 22), SetFill(0, 1), SetDataTip(SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
147 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_STRUCTURES), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
148 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_CATENARY), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_BUILD_X_ELRAIL, STR_TRANSPARENT_CATENARY_TOOLTIP),
af90d4bf0785 (svn r18229) -Codechange: Make fill_x, fill_y a number instead of a bool.
alberth <alberth@openttd.org>
parents: 13628
diff changeset
149 NWidget(WWT_IMGBTN, COLOUR_DARK_GREEN, TTW_WIDGET_LOADING), SetMinimalSize(22, 22), SetFill(0, 1), SetDataTip(SPR_IMG_TRAINLIST, STR_TRANSPARENT_LOADING_TOOLTIP),
13755
bf8a4ced15fe (svn r18280) -Codechange: remove widget indices that are not needed for custom drawing/handling input
rubidium <rubidium@openttd.org>
parents: 13752
diff changeset
150 NWidget(WWT_PANEL, COLOUR_DARK_GREEN), SetFill(1, 1), EndContainer(),
11637
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
151 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
152 /* 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
153 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
154 EndContainer(),
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
155 };
c8133174cf71 (svn r16017) -Codechange: Added nested widgets to transparency settings window.
alberth <alberth@openttd.org>
parents: 11636
diff changeset
156
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
157 static const WindowDesc _transparency_desc(
13798
6f820ae12bb3 (svn r18324) -Codechange: there's no need for a default size when the window isn't resizable
rubidium <rubidium@openttd.org>
parents: 13796
diff changeset
158 WDP_MANUAL, 0, 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
159 WC_TRANSPARENCY_TOOLBAR, WC_NONE,
13749
fc3ab8256c95 (svn r18274) -Codechange: remove the unused WDF flags
rubidium <rubidium@openttd.org>
parents: 13704
diff changeset
160 0,
13564
bae287664b02 (svn r18086) -Codechange: remove 'widget' from WindowDesc
rubidium <rubidium@openttd.org>
parents: 13186
diff changeset
161 _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
162 );
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
11967
8f2520911121 (svn r16373) -Codechange: use () instead of (void) for functions without parameters
smatz <smatz@openttd.org>
parents: 11730
diff changeset
164 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
165 {
9196
7f58b98c86c5 (svn r13062) -Codechange: make a class of the TransparencyToolbar.
belugas <belugas@openttd.org>
parents: 9143
diff changeset
166 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
167 }