File: TextManager.h

package info (click to toggle)
blobby 1.1.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 5,944 kB
  • sloc: cpp: 22,442; xml: 779; python: 56; makefile: 3
file content (195 lines) | stat: -rw-r--r-- 4,036 bytes parent folder | download | duplicates (3)
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
192
193
194
195
/*=============================================================================
Blobby Volley 2
Copyright (C) 2006 Jonathan Sieber (jonathan_sieber@yahoo.de)
Copyright (C) 2006 Daniel Knobe (daniel-knobe@web.de)

This program 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; either version 2 of the License, or
(at your option) any later version.

This program 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.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
=============================================================================*/

/**
 * @file TextManager.h
 * @brief Contains a class which handles different languages for text translations
 */

#pragma once

#include <vector>
#include <string>
#include <map>

/// \brief class for managing the text
/// \details multilanguage support
/// the string can be loaded from a xml file
/// <string english="english" translation="translation />

class TextManager
{
	public:
		/// enumeration for strings
		enum STRING
		{
			// common labels
			LBL_OK,
			LBL_CANCEL,
			LBL_YES,
			LBL_NO,
			LBL_CONF_QUIT,
			LBL_CONTINUE,

			// labels for main menu
			MNU_LABEL_ONLINE,
			MNU_LABEL_LAN,
			MNU_LABEL_START,
			MNU_LABEL_OPTIONS,
			MNU_LABEL_REPLAY,
			MNU_LABEL_CREDITS,
			MNU_LABEL_EXIT,

			// credits
			CRD_PROGRAMMERS,
			CRD_GRAPHICS,
			CRD_THX,

			// replays
			RP_SHOW_AGAIN,
			RP_PLAY,
			RP_DELETE,
			RP_INFO,
			RP_DURATION,
			RP_RESULT,
			RP_CHECKSUM,
			RP_VERSION,
			RP_FILE_OUTDATED,
			RP_FILE_CORRUPT,
			RP_SAVE_NAME,
			RP_WAIT_REPLAY,
			RP_SAVE,

			// game texts
			GAME_WIN,
			GAME_TRY_AGAIN,
			GAME_WAITING,
			GAME_OPP_LEFT,
			GAME_PAUSED,
			GAME_QUIT,

			// network texts
			NET_SERVER_SCAN,
			NET_DIRECT_CONNECT,
			NET_SERVER_INFO,
			NET_ACTIVE_GAMES,
			NET_WAITING_PLAYER,
			NET_HOST_GAME,
			NET_CONNECTING,
			NET_DISCONNECT,
			NET_CON_FAILED,
			NET_SERVER_FULL,
			NET_STAY_ON_SERVER,
			NET_RANDOM_OPPONENT,
			NET_OPEN_GAME,
			NET_JOIN,
			NET_LEAVE,
			NET_SPEED,
			NET_POINTS,
			NET_RULES_TITLE,
			NET_RULES_BY,
			NET_CHALLENGER,

			// options
			OP_TOUCH_TYPE,
			OP_TOUCH_ARROWS,
			OP_TOUCH_DIRECT,
			OP_INPUT_OP,
			OP_GFX_OP,
			OP_MISC,
			OP_VIDEO,
			OP_FULLSCREEN,
			OP_WINDOW,
			OP_RENDER_DEVICE,
			OP_SHOW_SHADOW,
			OP_BLOB_COLORS,
			OP_LEFT_PLAYER,
			OP_RIGHT_PLAYER,
			OP_RED,
			OP_GREEN,
			OP_BLUE,
			OP_MORPHING,
			OP_KEYBOARD,
			OP_MOUSE,
			OP_JOYSTICK,
			OP_JUMP_BUTTON,
			OP_SET_ALL,
			OP_LEFT_KEY,
			OP_RIGHT_KEY,
			OP_JUMP_KEY,
			OP_LEFT_BUTTON,
			OP_RIGHT_BUTTON,
			OP_PRESS_MOUSE_BUTTON,
			OP_PRESS_KEY_FOR,
			OP_MOVING_LEFT,
			OP_MOVING_RIGHT,
			OP_JUMPING,
			OP_PRESS_BUTTON_FOR,
			OP_BACKGROUND,
			OP_VOLUME,
			OP_MUTE,
			OP_FPS,
			OP_BLOOD,
			OP_NETWORK_SIDE,
			OP_LEFT,
			OP_RIGHT,
			OP_SPEED,
			OP_VSLOW,
			OP_SLOW,
			OP_DEFAULT,
			OP_FAST,
			OP_VFAST,
			OP_LANGUAGE,
			OP_DIFFICULTY,
			OP_WEAK,
			OP_MEDIUM,
			OP_STRONG,
			OP_RULES,

			UPDATE_NOTIFICATION,

			COUNT
		};

		explicit TextManager(std::string language);

		/// returns the string identified by str
		const std::string& getString(STRING str) const;

		std::string getLang() const;

		/// returns count of utf-8 characters
		static const int getUTF8Length(const std::string& str);

		static const std::map<std::string, std::string>& languageNames();
	private:

		/// vector with all strings
		std::vector<std::string> mStrings;

		/// string with language name
		std::string lang;

		/// loads the language data from an xml file
		bool loadFromXML(const std::string& file);

		/// sets the strings to the default values
		void setDefault();
};