Subversion Repositories spk

Rev

Rev 104 | Rev 122 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
104 cycrow 1
#ifndef __LANGUAGES_H__
2
#define __LANGUAGES_H__
3
 
4
#include "Utils\String.h"
5
#include <map>
6
#include <vector>
7
 
8
enum Lang_Section 
9
{ 
10
	LS_STARTUP, 
11
	LS_FILEDIALOG 
12
};
13
 
14
enum 
15
{ 
16
	LANGSTARTUP_ANOTHERINSTANCE_TITLE,
17
	LANGSTARTUP_ANOTHERINSTANCE,
18
	LANGSTARTUP_PROTECTEDDIR,
19
	LANGSTARTUP_LOCKEDDIR,
20
	LANGSTARTUP_LOCKEDDIR_TITLE,
21
};
22
 
23
#define LANGMAP std::map<Utils::String, Utils::String>
121 cycrow 24
typedef std::map<int, Utils::String> LangPage;
25
typedef std::map<int, LangPage> LangMap;
104 cycrow 26
 
27
typedef struct SLanguageTexts {
28
	int		iLang;
29
	LANGMAP	texts;
30
} SLanguageTexts;
31
 
32
class SPKEXPORT CLanguages
33
{
34
public:
35
	static CLanguages *Instance();
36
	static void Release();
37
 
38
	void SetLanguage(int lang) { m_iLanguage = lang; }
39
 
40
	Utils::String findText(int section, int id);
41
 
42
protected:
43
	CLanguages();
44
	~CLanguages();
45
 
46
private:
47
	Utils::String GetText(int section, int id)
48
	{
49
		switch(section)
50
		{
51
			case LS_STARTUP:
52
				return GetText_Startup(id);
53
		}
54
 
55
		return _error(section, id);
56
	}
57
 
58
	Utils::String GetText_Startup(int id)
59
	{
60
		switch(id)
61
		{
62
			case LANGSTARTUP_ANOTHERINSTANCE_TITLE:
63
				return "Another Instance Detected";
64
 
65
			case LANGSTARTUP_ANOTHERINSTANCE:
66
				return "Another instance of the plugin manager is already running";
67
 
68
			case LANGSTARTUP_PROTECTEDDIR:
69
				return "";
70
 
71
			case LANGSTARTUP_LOCKEDDIR_TITLE:
72
				return "Directory Locked";
73
 
74
			case LANGSTARTUP_LOCKEDDIR:
75
				return "ERROR: The game directory:\n%s\n\nIs locked and unable to add/remove any plugins";
76
		}
77
		return _error(LS_STARTUP, id);
78
	}
79
 
80
	SLanguageTexts *_findLanguageText(int id = -1);
81
	Utils::String _error(int section, int id)
82
	{
83
		return "ReadText" + Utils::String::Number(section) + "-" + Utils::String::Number(id);
84
	}
85
 
86
private:
87
	static CLanguages *_pInstance;
88
 
89
	int		m_iLanguage;
90
 
91
	std::vector<SLanguageTexts> *_lLanguages;
92
};
93
 
94
#endif //__LANGUAGES_H__