Subversion Repositories spk

Rev

Rev 121 | Go to most recent revision | Details | 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>
24
 
25
typedef struct SLanguageTexts {
26
	int		iLang;
27
	LANGMAP	texts;
28
} SLanguageTexts;
29
 
30
class SPKEXPORT CLanguages
31
{
32
public:
33
	static CLanguages *Instance();
34
	static void Release();
35
 
36
	void SetLanguage(int lang) { m_iLanguage = lang; }
37
 
38
	Utils::String findText(int section, int id);
39
 
40
protected:
41
	CLanguages();
42
	~CLanguages();
43
 
44
private:
45
	Utils::String GetText(int section, int id)
46
	{
47
		switch(section)
48
		{
49
			case LS_STARTUP:
50
				return GetText_Startup(id);
51
		}
52
 
53
		return _error(section, id);
54
	}
55
 
56
	Utils::String GetText_Startup(int id)
57
	{
58
		switch(id)
59
		{
60
			case LANGSTARTUP_ANOTHERINSTANCE_TITLE:
61
				return "Another Instance Detected";
62
 
63
			case LANGSTARTUP_ANOTHERINSTANCE:
64
				return "Another instance of the plugin manager is already running";
65
 
66
			case LANGSTARTUP_PROTECTEDDIR:
67
				return "";
68
 
69
			case LANGSTARTUP_LOCKEDDIR_TITLE:
70
				return "Directory Locked";
71
 
72
			case LANGSTARTUP_LOCKEDDIR:
73
				return "ERROR: The game directory:\n%s\n\nIs locked and unable to add/remove any plugins";
74
		}
75
		return _error(LS_STARTUP, id);
76
	}
77
 
78
	SLanguageTexts *_findLanguageText(int id = -1);
79
	Utils::String _error(int section, int id)
80
	{
81
		return "ReadText" + Utils::String::Number(section) + "-" + Utils::String::Number(id);
82
	}
83
 
84
private:
85
	static CLanguages *_pInstance;
86
 
87
	int		m_iLanguage;
88
 
89
	std::vector<SLanguageTexts> *_lLanguages;
90
};
91
 
92
#endif //__LANGUAGES_H__