author | rubidium |
Tue, 30 Sep 2008 20:39:50 +0000 | |
changeset 10207 | c291a21b304e |
parent 9111 | 48ce04029fe4 |
permissions | -rw-r--r-- |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
1 |
/* $Id$ */ |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
2 |
|
9111
48ce04029fe4
(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
parents:
8806
diff
changeset
|
3 |
/** @file transparency.h Functions related to transparency. */ |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
4 |
|
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
5 |
#ifndef TRANSPARENCY_H |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
6 |
#define TRANSPARENCY_H |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
7 |
|
8123
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
7932
diff
changeset
|
8 |
#include "gfx_func.h" |
ce31d2843a95
(svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents:
7932
diff
changeset
|
9 |
|
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
10 |
/** |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
11 |
* Transparency option bits: which position in _transparency_opt stands for which transparency. |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
12 |
* If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
13 |
* If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
14 |
*/ |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
15 |
enum TransparencyOption { |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
16 |
TO_SIGNS = 0, ///< signs |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
17 |
TO_TREES, ///< trees |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
18 |
TO_HOUSES, ///< town buildings |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
19 |
TO_INDUSTRIES, ///< industries |
10207
c291a21b304e
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents:
9111
diff
changeset
|
20 |
TO_BUILDINGS, ///< company buildings - depots, stations, HQ, ... |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
21 |
TO_BRIDGES, ///< bridges |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
22 |
TO_STRUCTURES, ///< unmovable structures |
8528
6e61e651790e
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8527
diff
changeset
|
23 |
TO_CATENARY, ///< catenary |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
24 |
TO_LOADING, ///< loading indicators |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
25 |
TO_END, |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
26 |
}; |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
27 |
|
8528
6e61e651790e
(svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents:
8527
diff
changeset
|
28 |
typedef uint TransparencyOptionBits; ///< transparency option bits |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
29 |
extern TransparencyOptionBits _transparency_opt; |
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
30 |
extern TransparencyOptionBits _transparency_lock; |
8806
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
31 |
extern TransparencyOptionBits _invisibility_opt; |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
32 |
|
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
33 |
/** |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
34 |
* Check if the transparency option bit is set |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
35 |
* and if we aren't in the game menu (there's never transparency) |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
36 |
* |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
37 |
* @param to the structure which transparency option is ask for |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
38 |
*/ |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
39 |
static inline bool IsTransparencySet(TransparencyOption to) |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
40 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
7849
diff
changeset
|
41 |
return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
42 |
} |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
43 |
|
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
44 |
/** |
8806
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
45 |
* Check if the invisibility option bit is set |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
46 |
* and if we aren't in the game menu (there's never transparency) |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
47 |
* |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
48 |
* @param to the structure which invisibility option is ask for |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
49 |
*/ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
50 |
static inline bool IsInvisibilitySet(TransparencyOption to) |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
51 |
{ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
52 |
return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
53 |
} |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
54 |
|
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
55 |
/** |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
56 |
* Toggle the transparency option bit |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
57 |
* |
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
58 |
* @param to the transparency option to be toggled |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
59 |
*/ |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
60 |
static inline void ToggleTransparency(TransparencyOption to) |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
61 |
{ |
7932
6c3d71e8a129
(svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
62 |
ToggleBit(_transparency_opt, to); |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
63 |
} |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
64 |
|
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
65 |
/** |
8806
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
66 |
* Toggle the invisibility option bit |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
67 |
* |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
68 |
* @param to the structure which invisibility option is toggle |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
69 |
*/ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
70 |
static inline void ToggleInvisibility(TransparencyOption to) |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
71 |
{ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
72 |
ToggleBit(_invisibility_opt, to); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
73 |
} |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
74 |
|
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
75 |
/** |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
76 |
* Toggles between invisible and solid state. |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
77 |
* If object is transparent, then it is made invisible. |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
78 |
* Used by the keyboard shortcuts. |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
79 |
* |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
80 |
* @param to the object type which invisibility option to toggle |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
81 |
*/ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
82 |
static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
83 |
{ |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
84 |
if (IsInvisibilitySet(to)) { |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
85 |
ClrBit(_invisibility_opt, to); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
86 |
ClrBit(_transparency_opt, to); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
87 |
} else { |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
88 |
SetBit(_invisibility_opt, to); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
89 |
SetBit(_transparency_opt, to); |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
90 |
} |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
91 |
} |
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
92 |
|
4fe163e0b52a
(svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents:
8658
diff
changeset
|
93 |
/** |
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
94 |
* Toggle the transparency lock bit |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
95 |
* |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
96 |
* @param to the transparency option to be locked or unlocked |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
97 |
*/ |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
98 |
static inline void ToggleTransparencyLock(TransparencyOption to) |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
99 |
{ |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
100 |
ToggleBit(_transparency_lock, to); |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
101 |
} |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
102 |
|
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
103 |
/** Set or clear all non-locked transparency options */ |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
104 |
static inline void ResetRestoreAllTransparency() |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
105 |
{ |
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
106 |
/* if none of the non-locked options are set */ |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
107 |
if ((_transparency_opt & ~_transparency_lock) == 0) { |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
108 |
/* set all non-locked options */ |
8658
e6fd51e0e9b0
(svn r12320) -Fix [FS#1817]: Wrong transparency options could be saved after toggling all.
peter1138
parents:
8529
diff
changeset
|
109 |
_transparency_opt |= GB(~_transparency_lock, 0, TO_END); |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
110 |
} else { |
8527
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
111 |
/* clear all non-locked options */ |
a32b9ac056af
(svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents:
8123
diff
changeset
|
112 |
_transparency_opt &= _transparency_lock; |
7849
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
113 |
} |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
114 |
|
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
115 |
MarkWholeScreenDirty(); |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
116 |
} |
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
117 |
|
0a1c0af2c96c
(svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff
changeset
|
118 |
#endif /* TRANSPARENCY_H */ |