author | truebrain |
Thu, 12 Jun 2008 18:03:50 +0000 | |
branch | noai |
changeset 10938 | df6235dd2b7a |
parent 10455 | 22c441f5adf9 |
permissions | -rw-r--r-- |
9722 | 1 |
/* $Id$ */ |
2 |
||
10455
22c441f5adf9
(svn r12997) [NoAI] -Sync: with trunk r12895:12996.
rubidium
parents:
9869
diff
changeset
|
3 |
/** @file transparency.h Functions related to transparency. */ |
9722 | 4 |
|
5 |
#ifndef TRANSPARENCY_H |
|
6 |
#define TRANSPARENCY_H |
|
7 |
||
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
8 |
#include "gfx_func.h" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
|
9722 | 10 |
/** |
11 |
* Transparency option bits: which position in _transparency_opt stands for which transparency. |
|
12 |
* If you change the order, change the order of the ShowTransparencyToolbar() stuff in transparency_gui.cpp too. |
|
13 |
* If you add or remove an option don't forget to change the transparency 'hot keys' in main_gui.cpp. |
|
14 |
*/ |
|
15 |
enum TransparencyOption { |
|
16 |
TO_SIGNS = 0, ///< signs |
|
17 |
TO_TREES, ///< trees |
|
18 |
TO_HOUSES, ///< town buildings |
|
19 |
TO_INDUSTRIES, ///< industries |
|
20 |
TO_BUILDINGS, ///< player buildings - depots, stations, HQ, ... |
|
21 |
TO_BRIDGES, ///< bridges |
|
22 |
TO_STRUCTURES, ///< unmovable structures |
|
9732 | 23 |
TO_CATENARY, ///< catenary |
9722 | 24 |
TO_LOADING, ///< loading indicators |
25 |
TO_END, |
|
26 |
}; |
|
27 |
||
9732 | 28 |
typedef uint TransparencyOptionBits; ///< transparency option bits |
9722 | 29 |
extern TransparencyOptionBits _transparency_opt; |
9732 | 30 |
extern TransparencyOptionBits _transparency_lock; |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
31 |
extern TransparencyOptionBits _invisibility_opt; |
9722 | 32 |
|
33 |
/** |
|
34 |
* Check if the transparency option bit is set |
|
35 |
* and if we aren't in the game menu (there's never transparency) |
|
36 |
* |
|
37 |
* @param to the structure which transparency option is ask for |
|
38 |
*/ |
|
39 |
static inline bool IsTransparencySet(TransparencyOption to) |
|
40 |
{ |
|
41 |
return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU); |
|
42 |
} |
|
43 |
||
44 |
/** |
|
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
45 |
* Check if the invisibility option bit is set |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
46 |
* and if we aren't in the game menu (there's never transparency) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
47 |
* |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
48 |
* @param to the structure which invisibility option is ask for |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
49 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
50 |
static inline bool IsInvisibilitySet(TransparencyOption to) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
51 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
52 |
return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
53 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
54 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
55 |
/** |
9722 | 56 |
* Toggle the transparency option bit |
57 |
* |
|
9732 | 58 |
* @param to the transparency option to be toggled |
9722 | 59 |
*/ |
60 |
static inline void ToggleTransparency(TransparencyOption to) |
|
61 |
{ |
|
62 |
ToggleBit(_transparency_opt, to); |
|
63 |
} |
|
64 |
||
9732 | 65 |
/** |
9869
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
66 |
* Toggle the invisibility option bit |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
67 |
* |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
68 |
* @param to the structure which invisibility option is toggle |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
69 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
70 |
static inline void ToggleInvisibility(TransparencyOption to) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
71 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
72 |
ToggleBit(_invisibility_opt, to); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
73 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
74 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
75 |
/** |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
76 |
* Toggles between invisible and solid state. |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
77 |
* If object is transparent, then it is made invisible. |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
78 |
* Used by the keyboard shortcuts. |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
79 |
* |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
80 |
* @param to the object type which invisibility option to toggle |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
81 |
*/ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
82 |
static inline void ToggleInvisibilityWithTransparency(TransparencyOption to) |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
83 |
{ |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
84 |
if (IsInvisibilitySet(to)) { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
85 |
ClrBit(_invisibility_opt, to); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
86 |
ClrBit(_transparency_opt, to); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
87 |
} else { |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
88 |
SetBit(_invisibility_opt, to); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
89 |
SetBit(_transparency_opt, to); |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
90 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
91 |
} |
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
92 |
|
6404afe43575
(svn r12597) [NoAI] -Sync: with trunk r12501:12596.
rubidium
parents:
9826
diff
changeset
|
93 |
/** |
9732 | 94 |
* Toggle the transparency lock bit |
95 |
* |
|
96 |
* @param to the transparency option to be locked or unlocked |
|
97 |
*/ |
|
98 |
static inline void ToggleTransparencyLock(TransparencyOption to) |
|
99 |
{ |
|
100 |
ToggleBit(_transparency_lock, to); |
|
101 |
} |
|
102 |
||
103 |
/** Set or clear all non-locked transparency options */ |
|
9722 | 104 |
static inline void ResetRestoreAllTransparency() |
105 |
{ |
|
9732 | 106 |
/* if none of the non-locked options are set */ |
107 |
if ((_transparency_opt & ~_transparency_lock) == 0) { |
|
108 |
/* set all non-locked options */ |
|
9826
9707ad4c9b60
(svn r12462) [NoAI] -Sync: with trunk r12304:12461.
rubidium
parents:
9732
diff
changeset
|
109 |
_transparency_opt |= GB(~_transparency_lock, 0, TO_END); |
9722 | 110 |
} else { |
9732 | 111 |
/* clear all non-locked options */ |
112 |
_transparency_opt &= _transparency_lock; |
|
9722 | 113 |
} |
114 |
||
115 |
MarkWholeScreenDirty(); |
|
116 |
} |
|
117 |
||
118 |
#endif /* TRANSPARENCY_H */ |