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
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
#pragma warning(disable:4786)
|
|
|
|
#include <string> //stl string
|
|
|
|
#include <map> //stl map
|
|
|
|
#include <list> //stl list
|
2015-12-19 23:57:27 +00:00
|
|
|
#include <Common/stdtypes.h>
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
typedef std::map<int32_t, std::string, std::less<int32_t> > LANG_STRINGS;
|
|
|
|
typedef LANG_STRINGS::value_type LANG_STR;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-05-04 00:08:53 +00:00
|
|
|
struct LanguageFile
|
2015-03-25 20:34:26 +00:00
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
std::string Filename;
|
2015-12-23 20:04:36 +00:00
|
|
|
std::string LanguageName;
|
2015-05-04 00:08:53 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-03-04 09:36:08 +00:00
|
|
|
typedef std::list<LanguageFile> LanguageList;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2012-11-19 11:05:30 +00:00
|
|
|
class CLanguage
|
|
|
|
{
|
2012-10-04 20:42:51 +00:00
|
|
|
public:
|
2015-11-14 00:16:03 +00:00
|
|
|
CLanguage();
|
2015-03-04 09:36:08 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
const std::string & GetString(LanguageStringID StringID);
|
2015-11-14 00:16:03 +00:00
|
|
|
LanguageList & GetLangList(void);
|
2015-12-23 20:04:36 +00:00
|
|
|
void SetLanguage(const char * LanguageName);
|
2015-11-14 00:16:03 +00:00
|
|
|
bool LoadCurrentStrings(void);
|
|
|
|
bool IsCurrentLang(LanguageFile & File);
|
|
|
|
bool IsLanguageLoaded(void) const { return m_LanguageLoaded; }
|
2012-10-04 20:42:51 +00:00
|
|
|
|
|
|
|
private:
|
2015-10-25 10:50:28 +00:00
|
|
|
CLanguage(const CLanguage&); // Disable copy constructor
|
|
|
|
CLanguage& operator=(const CLanguage&); // Disable assignment
|
2012-10-04 20:42:51 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
std::string m_SelectedLanguage;
|
|
|
|
const std::string m_emptyString;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-10-25 10:50:28 +00:00
|
|
|
LANG_STRINGS m_CurrentStrings, m_DefaultStrings;
|
|
|
|
LanguageList m_LanguageList;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
std::string GetLangString(const char * FileName, LanguageStringID ID);
|
2015-11-14 00:16:03 +00:00
|
|
|
LANG_STR GetNextLangString(void * OpenFile);
|
|
|
|
void LoadDefaultStrings(void);
|
2015-10-25 19:20:23 +00:00
|
|
|
|
2015-11-14 00:16:03 +00:00
|
|
|
bool m_LanguageLoaded;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|
|
|
|
|
2015-03-04 09:36:08 +00:00
|
|
|
extern CLanguage * g_Lang;
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-23 20:04:36 +00:00
|
|
|
const std::wstring wGS(LanguageStringID StringID);
|
|
|
|
|
|
|
|
inline const char * GS(LanguageStringID StringID)
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
2015-10-25 10:50:28 +00:00
|
|
|
return g_Lang->GetString(StringID).c_str();
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|