File: CommandColors.h

package info (click to toggle)
spring 88.0%2Bdfsg1-1.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 41,524 kB
  • sloc: cpp: 343,114; ansic: 38,414; python: 12,257; java: 12,203; awk: 5,748; sh: 1,204; xml: 997; perl: 405; objc: 192; makefile: 181; php: 134; sed: 2
file content (191 lines) | stat: -rwxr-xr-x 5,208 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */

#ifndef _COMMAND_COLORS_H
#define _COMMAND_COLORS_H

#include <map>
#include <string>

class CCommandColors {
	public:
		CCommandColors();
		~CCommandColors();

		bool LoadConfig(const std::string& filename);

		// for command queue lines
		bool         AlwaysDrawQueue()   const { return alwaysDrawQueue;   }
		bool         UseQueueIcons()     const { return useQueueIcons;     }
		float        QueueIconAlpha()    const { return queueIconAlpha;    }
		float        QueueIconScale()    const { return queueIconScale;    }
		bool         UseColorRestarts()  const { return useColorRestarts;  }
		bool         UseRestartColor()   const { return useRestartColor;   }
		float        RestartAlpha()      const { return restartAlpha;      }

		float        QueuedLineWidth()   const { return queuedLineWidth;   }
		unsigned int QueuedBlendSrc()    const { return queuedBlendSrc;    }
		unsigned int QueuedBlendDst()    const { return queuedBlendDst;    }
		unsigned int StipplePattern()    const { return stipplePattern;    }
		unsigned int StippleFactor()     const { return stippleFactor;     }
		float        StippleSpeed()      const { return stippleSpeed;      }

		float        SelectedLineWidth() const { return selectedLineWidth; }
		unsigned int SelectedBlendSrc()  const { return selectedBlendSrc;  }
		unsigned int SelectedBlendDst()  const { return selectedBlendDst;  }
		bool         BuildBoxesOnShift() const { return buildBoxesOnShift; }

		float        MouseBoxLineWidth() const { return mouseBoxLineWidth; }
		unsigned int MouseBoxBlendSrc()  const { return mouseBoxBlendSrc;  }
		unsigned int MouseBoxBlendDst()  const { return mouseBoxBlendDst;  }

		float        UnitBoxLineWidth()  const { return unitBoxLineWidth;  }

		// custom command queue rendering
		struct DrawData;
		void SetCustomCmdData(int cmdID, int cmdIconID,
		                      const float color[4], bool showArea);
		void ClearCustomCmdData(int cmdID);
		/// get custom command line parameters
		/// @return NULL if no line defined, a pointer to a DrawData otherwise
		const DrawData *GetCustomCmdData(int cmdID) const;

		// the colors
		const float* unitBox;
		const float* buildBox;
		const float* allyBuildBox;
		const float* mouseBox;
		// for command queue rendering
		const float* start;
		const float* restart;
		const float* stop;
		const float* wait;
		const float* build;
		const float* move;
		const float* attack;
		const float* fight;
		const float* guard;
		const float* patrol;
		const float* capture;
		const float* repair;
		const float* reclaim;
		const float* restore;
		const float* resurrect;
		const float* load;
		const float* unload;
		const float* deathWait;
		// for selected unit range rendering
		const float* rangeAttack;
		const float* rangeBuild;
		const float* rangeRadar;
		const float* rangeSonar;
		const float* rangeSeismic;
		const float* rangeJammer;
		const float* rangeSonarJammer;
		const float* rangeShield;
		const float* rangeDecloak;
		const float* rangeExtract;
		const float* rangeKamikaze;
		const float* rangeSelfDestruct;
		const float* rangeInterceptorOn;
		const float* rangeInterceptorOff;

	public:
		struct DrawData {
			int cmdIconID;
			float color[4];
			bool showArea;

			DrawData()
			: cmdIconID(0), showArea(false)
			{
				for (int i = 0; i<4; ++i) { color[i] = 1.0f; }
			}

			DrawData(int cii, const float c[4], bool area)
			: cmdIconID(cii), showArea(area)
			{
				for (int i = 0; i<4; ++i) { color[i] = c[i]; }
			}
		};

	private:
		std::map<std::string, int> colorNames;

		enum ColorIndices {
			start_index = 0,
			restart_index,
			stop_index,
			wait_index,
			build_index,
			move_index,
			attack_index,
			fight_index,
			guard_index,
			patrol_index,
			capture_index,
			repair_index,
			reclaim_index,
			restore_index,
			resurrect_index,
			load_index,
			unload_index,
			deathWait_index,
			rangeAttack_index,
			rangeBuild_index,
			rangeRadar_index,
			rangeSonar_index,
			rangeSeismic_index,
			rangeJammer_index,
			rangeSonarJammer_index,
			rangeShield_index,
			rangeDecloak_index,
			rangeExtract_index,
			rangeKamikaze_index,
			rangeSelfDestruct_index,
			rangeInterceptorOn_index,
			rangeInterceptorOff_index,
			unitBox_index,
			buildBox_index,
			allyBuildBox_index,
			mouseBox_index,
			ColorCount
		};

		float colors[ColorCount][4];

		// for command queue lines
		bool  alwaysDrawQueue;
		float queueIconAlpha;
		float queueIconScale;
		bool  useQueueIcons;
		bool  useColorRestarts;
		bool  useRestartColor;
		float restartAlpha;

		float        queuedLineWidth;
		unsigned int queuedBlendSrc;
		unsigned int queuedBlendDst;
		unsigned int stipplePattern;
		unsigned int stippleFactor;
		float        stippleSpeed;

		float        selectedLineWidth;
		unsigned int selectedBlendSrc;
		unsigned int selectedBlendDst;
		bool         buildBoxesOnShift;

		float        mouseBoxLineWidth;
		unsigned int mouseBoxBlendSrc;
		unsigned int mouseBoxBlendDst;

		float unitBoxLineWidth;

		typedef std::map<int, DrawData> customCmds_type;
		customCmds_type customCmds;
};


extern CCommandColors cmdColors;


#endif // _COMMAND_COLORS_H