src/transparency.h
author rubidium
Thu, 19 Jun 2008 11:45:52 +0000
changeset 11023 583f32658248
parent 10429 1b99254f9607
permissions -rw-r--r--
(svn r13579) -Fix [FS#2088]: process the order coming after a conditional order, otherwise the vehicle would already leaving the station before it knows where the next destination is, making it leave in the wrong way. However, after processing as many conditional orders as there are in the order list it will stop processing them in order to not create an infinite loop.
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     1
/* $Id$ */
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     2
10429
1b99254f9607 (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: 9302
diff changeset
     3
/** @file transparency.h Functions related to transparency. */
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     4
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     5
#ifndef TRANSPARENCY_H
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     6
#define TRANSPARENCY_H
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
     7
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8428
diff changeset
     8
#include "gfx_func.h"
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8428
diff changeset
     9
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    10
/**
6caa3fdb972c (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.
6caa3fdb972c (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.
6caa3fdb972c (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.
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    14
 */
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    15
enum TransparencyOption {
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    16
	TO_SIGNS = 0,  ///< signs
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    17
	TO_TREES,      ///< trees
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    18
	TO_HOUSES,     ///< town buildings
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    19
	TO_INDUSTRIES, ///< industries
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    20
	TO_BUILDINGS,  ///< player buildings - depots, stations, HQ, ...
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    21
	TO_BRIDGES,    ///< bridges
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    22
	TO_STRUCTURES, ///< unmovable structures
9024
85bc26dd4935 (svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents: 9023
diff changeset
    23
	TO_CATENARY,   ///< catenary
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    24
	TO_LOADING,    ///< loading indicators
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    25
	TO_END,
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    26
};
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    27
9024
85bc26dd4935 (svn r12103) -Feature(tte): separate catenary transparency settings from building transparency settings
smatz
parents: 9023
diff changeset
    28
typedef uint TransparencyOptionBits; ///< transparency option bits
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    29
extern TransparencyOptionBits _transparency_opt;
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    30
extern TransparencyOptionBits _transparency_lock;
9302
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    31
extern TransparencyOptionBits _invisibility_opt;
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    32
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    33
/**
6caa3fdb972c (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
6caa3fdb972c (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)
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    36
 *
6caa3fdb972c (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
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    38
 */
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    39
static inline bool IsTransparencySet(TransparencyOption to)
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    40
{
8424
4a488a90ccab (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 8345
diff changeset
    41
	return (HasBit(_transparency_opt, to) && _game_mode != GM_MENU);
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    42
}
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    43
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    44
/**
9302
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    45
 * Check if the invisibility option bit is set
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    46
 * and if we aren't in the game menu (there's never transparency)
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    47
 *
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    48
 * @param to the structure which invisibility option is ask for
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    49
 */
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    50
static inline bool IsInvisibilitySet(TransparencyOption to)
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    51
{
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    52
	return (HasBit(_transparency_opt & _invisibility_opt, to) && _game_mode != GM_MENU);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    53
}
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    54
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    55
/**
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    56
 * Toggle the transparency option bit
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    57
 *
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    58
 * @param to the transparency option to be toggled
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    59
 */
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    60
static inline void ToggleTransparency(TransparencyOption to)
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    61
{
8428
f8300c908bd9 (svn r11485) -Codechange: Remove the doubled function ToggleBitT and rename the remaining to fit with the naming style
skidd13
parents: 8424
diff changeset
    62
	ToggleBit(_transparency_opt, to);
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    63
}
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
    64
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    65
/**
9302
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    66
 * Toggle the invisibility option bit
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    67
 *
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    68
 * @param to the structure which invisibility option is toggle
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    69
 */
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    70
static inline void ToggleInvisibility(TransparencyOption to)
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    71
{
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    72
	ToggleBit(_invisibility_opt, to);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    73
}
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    74
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    75
/**
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    76
 * Toggles between invisible and solid state.
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    77
 * If object is transparent, then it is made invisible.
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    78
 * Used by the keyboard shortcuts.
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    79
 *
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    80
 * @param to the object type which invisibility option to toggle
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    81
 */
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    82
static inline void ToggleInvisibilityWithTransparency(TransparencyOption to)
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    83
{
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    84
	if (IsInvisibilitySet(to)) {
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    85
		ClrBit(_invisibility_opt, to);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    86
		ClrBit(_transparency_opt, to);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    87
	} else {
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    88
		SetBit(_invisibility_opt, to);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    89
		SetBit(_transparency_opt, to);
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    90
	}
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    91
}
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    92
4aa3c4a44b16 (svn r12547) -Feature: invisibility options to make objects invisible instead of transparent
smatz
parents: 9154
diff changeset
    93
/**
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    94
 * Toggle the transparency lock bit
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    95
 *
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    96
 * @param to the transparency option to be locked or unlocked
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    97
 */
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    98
static inline void ToggleTransparencyLock(TransparencyOption to)
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
    99
{
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   100
	ToggleBit(_transparency_lock, to);
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   101
}
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   102
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   103
/** Set or clear all non-locked transparency options */
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   104
static inline void ResetRestoreAllTransparency()
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   105
{
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   106
	/* if none of the non-locked options are set */
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   107
	if ((_transparency_opt & ~_transparency_lock) == 0) {
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   108
		/* set all non-locked options */
9154
b20714ff4084 (svn r12320) -Fix [FS#1817]: Wrong transparency options could be saved after toggling all.
peter1138
parents: 9025
diff changeset
   109
		_transparency_opt |= GB(~_transparency_lock, 0, TO_END);
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   110
	} else {
9023
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   111
		/* clear all non-locked options */
3435736a1a6b (svn r12102) -Feature: Allow locking individual transparency settings so they will not be changed by pressing 'x'. (Roujin)
maedhros
parents: 8619
diff changeset
   112
		_transparency_opt &= _transparency_lock;
8345
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   113
	}
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   114
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   115
	MarkWholeScreenDirty();
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   116
}
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   117
6caa3fdb972c (svn r11399) -Feature(ette): transparency settings can now be saved and thus remembered.
belugas
parents:
diff changeset
   118
#endif /* TRANSPARENCY_H */