Skip to content

Commit

Permalink
partially support English UI
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaDusknoir committed May 2, 2022
1 parent 26d0c18 commit 7496429
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
17 changes: 16 additions & 1 deletion AoE2TCWin/AoE2TCWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,23 @@ WCHAR* StringMap::operator[](UINT uID)
void GameDataJsonLoad(void)
{
WCHAR szDir[512];
size_t target_lang = 0;
auto lang_id = GetUserDefaultUILanguage();
switch (lang_id)
{
case 1028://tw
case 3076://hk
case 5124://mo
case 4100://sg
case 2052://cn
target_lang = 0;
break;
default:
target_lang = 1;
break;
}
GetCurrentDirectory(512, szDir);
AoEJsonRead(GameStr).json_load((std::wstring(szDir) + L"/string.json").c_str());
AoEJsonRead(GameStr, target_lang).json_load((std::wstring(szDir) + L"/string.json").c_str());
}

LRESULT CALLBACK EditorWndProc(HWND window, UINT msg, WPARAM wParam, LPARAM lParam)
Expand Down
Binary file modified AoE2TCWin/AoE2TCWin.rc
Binary file not shown.
2 changes: 1 addition & 1 deletion AoE2TCWin/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 148
#define _APS_NEXT_COMMAND_VALUE 32785
#define _APS_NEXT_COMMAND_VALUE 32786
#define _APS_NEXT_CONTROL_VALUE 1074
#define _APS_NEXT_SYMED_VALUE 110
#endif
Expand Down
19 changes: 11 additions & 8 deletions model/aoejson.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,16 @@ double AoEJsonRead::json_read(JsonValue o)
sum += o.toNumber();
break;
case JSON_STRING:
if (strcmp(excepted_key[excepted_key_idx], "condition_name") == 0)
if (excepted_key_idx >= 0)
{
paser_data.condition_name.push_back(win32::Utf8ToUtf16(string(o.toString())));
}
else if (strcmp(excepted_key[excepted_key_idx], "effect_name") == 0)
{
paser_data.effect_name.push_back(win32::Utf8ToUtf16(string(o.toString())));
if (strcmp(excepted_key[excepted_key_idx], "condition_name") == 0)
{
paser_data.condition_name.push_back(win32::Utf8ToUtf16(string(o.toString())));
}
else if (strcmp(excepted_key[excepted_key_idx], "effect_name") == 0)
{
paser_data.effect_name.push_back(win32::Utf8ToUtf16(string(o.toString())));
}
}
break;
case JSON_ARRAY:
Expand All @@ -108,7 +111,7 @@ double AoEJsonRead::json_read(JsonValue o)
}
return sum;
}
void AoEJsonRead::set_language()
void AoEJsonRead::set_language(size_t lang_idx)
{
excepted_key[0] = language_key[0];
excepted_key[0] = language_key[lang_idx];
}
6 changes: 3 additions & 3 deletions model/aoejson.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ struct AoEJsonData
class AoEJsonRead
{
public:
AoEJsonRead(AoEJsonData& _paser_data)
AoEJsonRead(AoEJsonData& _paser_data, size_t lang_idx = 0)
:excepted_key_idx(-1), paser_data(_paser_data)
{
set_language();
set_language(lang_idx);
}
void json_load(const char* path);
void json_load(const wchar_t* path);
Expand All @@ -25,5 +25,5 @@ class AoEJsonRead
int excepted_key_idx;
AoEJsonData& paser_data;
double json_read(JsonValue o);
void set_language();
void set_language(size_t lang_idx);
};

0 comments on commit 7496429

Please sign in to comment.