project64/Source/Project64/Multilanguage/Language Class.h

65 lines
2.2 KiB
C
Raw Normal View History

2012-12-19 09:30:18 +00:00
/****************************************************************************
* *
2015-11-10 05:21:49 +00:00
* Project64 - A Nintendo 64 emulator. *
2012-12-19 09:30:18 +00:00
* http://www.pj64-emu.com/ *
* Copyright (C) 2012 Project64. All rights reserved. *
* *
* License: *
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
* *
****************************************************************************/
#pragma once
#pragma warning(disable:4786)
#include <string> //stl string
#include <map> //stl map
#include <list> //stl list
#include <common/stdtypes.h>
typedef std::map<int32_t, std::wstring, std::less<int32_t> > LANG_STRINGS;
typedef LANG_STRINGS::value_type LANG_STR;
struct LanguageFile
{
2015-10-25 10:50:28 +00:00
std::string Filename;
std::wstring LanguageName;
};
typedef std::list<LanguageFile> LanguageList;
2012-11-19 11:05:30 +00:00
class CLanguage
{
public:
2015-11-14 00:16:03 +00:00
CLanguage();
2015-11-14 00:16:03 +00:00
const std::wstring & GetString(LanguageStringID StringID);
LanguageList & GetLangList(void);
void SetLanguage(const wchar_t * LanguageName);
bool LoadCurrentStrings(void);
bool IsCurrentLang(LanguageFile & File);
bool IsLanguageLoaded(void) const { return m_LanguageLoaded; }
private:
2015-10-25 10:50:28 +00:00
CLanguage(const CLanguage&); // Disable copy constructor
CLanguage& operator=(const CLanguage&); // Disable assignment
2015-10-25 10:50:28 +00:00
std::wstring m_SelectedLanguage;
const std::wstring m_emptyString;
2015-10-25 10:50:28 +00:00
LANG_STRINGS m_CurrentStrings, m_DefaultStrings;
LanguageList m_LanguageList;
2015-11-14 00:16:03 +00:00
std::wstring GetLangString(const char * FileName, LanguageStringID ID);
LANG_STR GetNextLangString(void * OpenFile);
void LoadDefaultStrings(void);
2015-11-14 00:16:03 +00:00
bool m_LanguageLoaded;
};
extern CLanguage * g_Lang;
2015-11-14 00:16:03 +00:00
inline const wchar_t * GS(LanguageStringID StringID)
{
2015-10-25 10:50:28 +00:00
return g_Lang->GetString(StringID).c_str();
}