mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added ability to change language in Manage Settings.
This commit is contained in:
parent
6dd79c451d
commit
4f73f17cec
@ -101,7 +101,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd
|
||||
HMODULE module = GetModuleHandle(L"Rainmeter.dll");
|
||||
if (module == NULL || Initialize(hWnd, module, lpCmdLine) == 1)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
DestroyWindow(hWnd);
|
||||
return RetError;
|
||||
}
|
||||
|
@ -1629,6 +1629,53 @@ void CDialogManage::CTabSettings::Initialize()
|
||||
{
|
||||
m_Initialized = true;
|
||||
|
||||
// Scan for languages
|
||||
HWND item = GetDlgItem(m_Window, IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX);
|
||||
WIN32_FIND_DATA fd; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
std::wstring files = Rainmeter->GetPath() + L"Languages\\*.dll";
|
||||
hSearch = FindFirstFile(files.c_str(), &fd);
|
||||
do
|
||||
{
|
||||
if (hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
WCHAR* pos = wcschr(fd.cFileName, L'.');
|
||||
if (pos)
|
||||
{
|
||||
LCID lcid = (LCID)wcstoul(fd.cFileName, &pos, 10);
|
||||
if (GetLocaleInfo(lcid, LOCALE_SENGLISHLANGUAGENAME, fd.cFileName, MAX_PATH) > 0)
|
||||
{
|
||||
// Strip brackets in language name
|
||||
std::wstring text = fd.cFileName;
|
||||
std::wstring::size_type pos = 0;
|
||||
while ((pos = text.find_first_of(L"()")) != std::wstring::npos)
|
||||
{
|
||||
text.erase(pos, 1);
|
||||
}
|
||||
|
||||
text += L" (";
|
||||
GetLocaleInfo(lcid, LOCALE_SNATIVELANGUAGENAME, fd.cFileName, MAX_PATH);
|
||||
|
||||
// Some native language names don't start with a uppercase char..
|
||||
fd.cFileName[0] = towupper(fd.cFileName[0]);
|
||||
text += fd.cFileName;
|
||||
text += L")";
|
||||
|
||||
int index = ComboBox_AddString(item, text.c_str());
|
||||
ComboBox_SetItemData(item, index, (LPARAM)lcid);
|
||||
|
||||
if (lcid == Rainmeter->GetResourceLCID())
|
||||
{
|
||||
ComboBox_SetCurSel(item, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while (FindNextFile(hSearch, &fd));
|
||||
|
||||
FindClose(hSearch);
|
||||
|
||||
Button_SetCheck(GetDlgItem(m_Window, IDC_MANAGESETTINGS_CHECKUPDATES_CHECKBOX), !Rainmeter->GetDisableVersionCheck());
|
||||
Button_SetCheck(GetDlgItem(m_Window, IDC_MANAGESETTINGS_LOCKSKINS_CHECKBOX), Rainmeter->GetDisableDragging());
|
||||
Button_SetCheck(GetDlgItem(m_Window, IDC_MANAGESETTINGS_LOGTOFILE_CHECKBOX), Rainmeter->GetLogging());
|
||||
@ -1660,6 +1707,27 @@ INT_PTR CDialogManage::CTabSettings::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX:
|
||||
if (HIWORD(wParam) == CBN_SELCHANGE)
|
||||
{
|
||||
WCHAR buffer[16];
|
||||
int sel = ComboBox_GetCurSel((HWND)lParam);
|
||||
LCID lcid = ComboBox_GetItemData((HWND)lParam, sel);
|
||||
_ultow(lcid, buffer, 10);
|
||||
WritePrivateProfileString(L"Rainmeter", L"Language", buffer, Rainmeter->GetIniFile().c_str());
|
||||
|
||||
std::wstring resource = Rainmeter->GetPath() + L"Languages\\";
|
||||
resource += buffer;
|
||||
resource += L".dll";
|
||||
FreeLibrary(Rainmeter->m_ResourceInstance);
|
||||
Rainmeter->m_ResourceInstance = LoadLibraryEx(resource.c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
Rainmeter->m_ResourceLCID = lcid;
|
||||
|
||||
SendMessage(c_Dialog->GetWindow(), WM_DELAYED_CLOSE, 0, 0);
|
||||
ExecuteBang(L"!Manage Settings"); // Delayed execute
|
||||
}
|
||||
break;
|
||||
|
||||
case IDC_MANAGESETTINGS_CHECKUPDATES_CHECKBOX:
|
||||
Rainmeter->SetDisableVersionCheck(!Rainmeter->GetDisableVersionCheck());
|
||||
break;
|
||||
|
@ -155,7 +155,7 @@ int Initialize(HWND hWnd, HINSTANCE hInstance, LPCWSTR lpCmdLine)
|
||||
}
|
||||
catch (CError& error)
|
||||
{
|
||||
MessageBox(hWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
MessageBox(hWnd, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONERROR);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -968,13 +968,6 @@ int CRainmeter::Initialize(HWND hParent, HINSTANCE hInstance, LPCWSTR szPath)
|
||||
|
||||
m_Path = tmpSzPath;
|
||||
|
||||
wcscat(tmpSzPath, L"Languages\\English.dll");
|
||||
m_ResourceInstance = LoadLibraryEx(tmpSzPath, NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (!m_ResourceInstance)
|
||||
{
|
||||
throw CError(L"Unable to load English.dll");
|
||||
}
|
||||
|
||||
InitalizeLitestep();
|
||||
|
||||
bool bDefaultIniLocation = false;
|
||||
@ -1055,6 +1048,42 @@ int CRainmeter::Initialize(HWND hParent, HINSTANCE hInstance, LPCWSTR szPath)
|
||||
m_StatsFile += L".stats";
|
||||
}
|
||||
|
||||
// Determine the language resource to load
|
||||
std::wstring resource = m_Path + L"Languages\\";
|
||||
if (GetPrivateProfileString(L"Rainmeter", L"Language", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
m_ResourceLCID = wcstoul(tmpSzPath, NULL, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use whatever the user selected for the installer
|
||||
DWORD lang;
|
||||
DWORD size = sizeof(DWORD);
|
||||
if (SHGetValue(HKEY_LOCAL_MACHINE, L"Software\\Rainmeter", L"Language", NULL, &lang, &size) == ERROR_SUCCESS)
|
||||
{
|
||||
_ultow(lang, tmpSzPath, 10);
|
||||
m_ResourceLCID = lang;
|
||||
}
|
||||
}
|
||||
resource += tmpSzPath;
|
||||
resource += L".dll";
|
||||
|
||||
m_ResourceInstance = LoadLibraryEx(resource.c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
if (!m_ResourceInstance)
|
||||
{
|
||||
resource.insert(0, L"Unable to load language: ");
|
||||
Log(LOG_ERROR, resource.c_str());
|
||||
|
||||
// Try English
|
||||
resource = m_Path + L"Languages\\1033.dll";
|
||||
m_ResourceInstance = LoadLibraryEx(resource.c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
||||
m_ResourceLCID = 1033;
|
||||
if (!m_ResourceInstance)
|
||||
{
|
||||
throw CError(L"Unable to load language library");
|
||||
}
|
||||
}
|
||||
|
||||
// Read Logging settings beforehand
|
||||
m_Logging = 0!=GetPrivateProfileInt(L"Rainmeter", L"Logging", 0, m_IniFile.c_str());
|
||||
m_Debug = 0!=GetPrivateProfileInt(L"Rainmeter", L"Debug", 0, m_IniFile.c_str());
|
||||
@ -1070,7 +1099,6 @@ int CRainmeter::Initialize(HWND hParent, HINSTANCE hInstance, LPCWSTR szPath)
|
||||
m_SkinPath += L"Skins\\";
|
||||
|
||||
// Read the skin folder from the ini file
|
||||
tmpSzPath[0] = L'\0';
|
||||
if (GetPrivateProfileString(L"Rainmeter", L"SkinPath", L"", tmpSzPath, MAX_LINE_LENGTH, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
m_SkinPath = tmpSzPath;
|
||||
|
@ -130,6 +130,7 @@ public:
|
||||
|
||||
HINSTANCE GetInstance() { return m_Instance; }
|
||||
HINSTANCE GetResourceInstance() { return m_ResourceInstance; }
|
||||
LCID GetResourceLCID() { return m_ResourceLCID; }
|
||||
|
||||
bool GetDebug() { return m_Debug; }
|
||||
|
||||
@ -264,6 +265,7 @@ private:
|
||||
|
||||
HINSTANCE m_Instance;
|
||||
HMODULE m_ResourceInstance;
|
||||
LCID m_ResourceLCID;
|
||||
|
||||
ULONG_PTR m_GDIplusToken;
|
||||
|
||||
|
@ -78,6 +78,7 @@
|
||||
#define IDC_MANAGESETTINGS_VERBOSELOGGING_CHECKBOX 1056
|
||||
#define IDC_MANAGESETTINGS_SHOWLOGFILE_BUTTON 1057
|
||||
#define IDC_MANAGESETTINGS_DELETELOGFILE_BUTTON 1058
|
||||
#define IDC_MANAGESETTINGS_LANGUAGE_COMBOBOX 1059
|
||||
|
||||
#define ID_STR_ISRTL 2000
|
||||
#define ID_STR_UPDATEAVAILABLE 2001
|
||||
|
@ -5,6 +5,9 @@ EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Language", "Language\Language.vcxproj", "{6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Library", "Library\Library.vcxproj", "{BE9D2400-7F1C-49D6-8498-5CE495491AD6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A} = {6BE6F228-B741-4DA9-9FBC-E9F2A7BD483A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PluginAdvancedCPU", "Plugins\PluginAdvancedCPU\PluginAdvancedCPU.vcxproj", "{EE8EC522-8430-4B46-86A3-D943D77F9E4B}"
|
||||
EndProject
|
||||
|
Loading…
x
Reference in New Issue
Block a user