struct LANGUAGE should be a class CLanguage

This commit is contained in:
SushiTee 2010-07-10 06:55:42 +08:00 committed by oy
parent 3824d885a2
commit e79bfb243c

View file

@ -625,15 +625,16 @@ void CMenus::RenderSettingsSound(CUIRect MainView)
}
}
struct LANGUAGE
class CLanguage
{
LANGUAGE() {}
LANGUAGE(const char *n, const char *f) : m_Name(n), m_FileName(f) {}
public:
CLanguage() {}
CLanguage(const char *n, const char *f) : m_Name(n), m_FileName(f) {}
string m_Name;
string m_FileName;
bool operator<(const LANGUAGE &Other) { return m_Name < Other.m_Name; }
bool operator<(const CLanguage &Other) { return m_Name < Other.m_Name; }
};
@ -644,7 +645,7 @@ void GatherLanguages(const char *pName, int IsDir, void *pUser)
if(IsDir || pName[0] == '.')
return;
sorted_array<LANGUAGE> &Languages = *((sorted_array<LANGUAGE> *)pUser);
sorted_array<CLanguage> &Languages = *((sorted_array<CLanguage> *)pUser);
char aFileName[128];
str_format(aFileName, sizeof(aFileName), "data/languages/%s", pName);
@ -657,19 +658,19 @@ void GatherLanguages(const char *pName, int IsDir, void *pUser)
if(*p == '.')
*p = 0;
Languages.add(LANGUAGE(NiceName, aFileName));
Languages.add(CLanguage(NiceName, aFileName));
}
void CMenus::RenderSettingsGeneral(CUIRect MainView)
{
static int s_LanguageList = 0;
static int s_SelectedLanguage = 0;
static sorted_array<LANGUAGE> s_Languages;
static sorted_array<CLanguage> s_Languages;
static float s_ScrollValue = 0;
if(s_Languages.size() == 0)
{
s_Languages.add(LANGUAGE("English", ""));
s_Languages.add(CLanguage("English", ""));
fs_listdir("data/languages", GatherLanguages, &s_Languages);
for(int i = 0; i < s_Languages.size(); i++)
if(str_comp(s_Languages[i].m_FileName, g_Config.m_ClLanguagefile) == 0)
@ -684,7 +685,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView)
CUIRect List = MainView;
UiDoListboxStart(&s_LanguageList , &List, 24.0f, Localize("Language"), "", s_Languages.size(), 1, s_SelectedLanguage, s_ScrollValue);
for(sorted_array<LANGUAGE>::range r = s_Languages.all(); !r.empty(); r.pop_front())
for(sorted_array<CLanguage>::range r = s_Languages.all(); !r.empty(); r.pop_front())
{
CListboxItem Item = UiDoListboxNextItem(&r.front());