mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks.
This commit is contained in:
parent
20e2a53324
commit
8515877c48
@ -80,7 +80,8 @@ void CConfigParser::Initialize(LPCTSTR filename, CRainmeter* pRainmeter, CMeterW
|
||||
ReadIniFile(iniFileMappings, m_Filename, config);
|
||||
ReadVariables();
|
||||
|
||||
std::unordered_set<std::wstring>().swap(m_FoundSections); // clear and minimize
|
||||
// Clear and minimize
|
||||
std::vector<std::wstring>().swap(m_ListVariables);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1107,6 +1108,8 @@ void CConfigParser::ReadIniFile(const std::vector<std::wstring>& iniFileMappings
|
||||
{
|
||||
m_Sections.push_back(L"Rainmeter");
|
||||
m_Sections.push_back(config);
|
||||
m_FoundSections.insert(L"rainmeter");
|
||||
m_FoundSections.insert(StrToLower(config));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,6 +72,7 @@ public:
|
||||
|
||||
const std::wstring& GetFilename() { return m_Filename; }
|
||||
const std::vector<std::wstring>& GetSections() { return m_Sections; }
|
||||
bool IsSectionDefined(LPCTSTR section) { return m_FoundSections.find(StrToLower(section)) != m_FoundSections.end(); }
|
||||
|
||||
bool ReplaceVariables(std::wstring& result);
|
||||
bool ReplaceMeasures(std::wstring& result);
|
||||
|
@ -2516,31 +2516,8 @@ void CRainmeter::GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& w
|
||||
}
|
||||
}
|
||||
|
||||
void CRainmeter::SetConfigOrder(int configIndex)
|
||||
void CRainmeter::SetLoadOrder(int configIndex, int order)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
int order;
|
||||
|
||||
if (GetPrivateProfileString(m_ConfigStrings[configIndex].config.c_str(), L"LoadOrder", L"", buffer, 256, m_IniFile.c_str()) > 0)
|
||||
{
|
||||
if (_wcsicmp(buffer, L"LAST") == 0)
|
||||
{
|
||||
order = INT_MAX;
|
||||
}
|
||||
else if (_wcsicmp(buffer, L"FIRST") == 0)
|
||||
{
|
||||
order = INT_MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
order = _wtoi(buffer);
|
||||
}
|
||||
}
|
||||
else // LoadOrder not exists
|
||||
{
|
||||
order = 0;
|
||||
}
|
||||
|
||||
std::multimap<int, int>::iterator iter = m_ConfigOrders.begin();
|
||||
for ( ; iter != m_ConfigOrders.end(); ++iter)
|
||||
{
|
||||
@ -3394,7 +3371,6 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||
|
||||
for (UINT i = 1; i <= CSystem::GetMonitorCount(); ++i)
|
||||
{
|
||||
WCHAR buffer[64];
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"DesktopWorkArea@%i", i);
|
||||
area = parser.ReadString(L"Rainmeter", buffer, L"");
|
||||
if (!area.empty())
|
||||
@ -3450,7 +3426,33 @@ void CRainmeter::ReadGeneralSettings(const std::wstring& iniFile)
|
||||
m_ConfigStrings[i].active = active;
|
||||
}
|
||||
|
||||
SetConfigOrder(i);
|
||||
int order;
|
||||
if (parser.IsSectionDefined(m_ConfigStrings[i].config.c_str()))
|
||||
{
|
||||
std::wstring orderStr = parser.ReadString(m_ConfigStrings[i].config.c_str(), L"LoadOrder", L"", false);
|
||||
if (orderStr.empty())
|
||||
{
|
||||
order = 0;
|
||||
}
|
||||
else if (_wcsicmp(orderStr.c_str(), L"LAST") == 0)
|
||||
{
|
||||
order = INT_MAX;
|
||||
}
|
||||
else if (_wcsicmp(orderStr.c_str(), L"FIRST") == 0)
|
||||
{
|
||||
order = INT_MIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
order = _wtoi(orderStr.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
order = 0;
|
||||
}
|
||||
|
||||
SetLoadOrder(i, order);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,7 +263,7 @@ private:
|
||||
void ScanForConfigs(const std::wstring& path);
|
||||
void ScanForThemes(const std::wstring& path);
|
||||
void ReadGeneralSettings(const std::wstring& iniFile);
|
||||
void SetConfigOrder(int configIndex);
|
||||
void SetLoadOrder(int configIndex, int order);
|
||||
int GetLoadOrder(const std::wstring& config);
|
||||
bool SetActiveConfig(const std::wstring& skinName, const std::wstring& skinIni);
|
||||
void UpdateDesktopWorkArea(bool reset);
|
||||
|
@ -272,105 +272,114 @@ HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
|
||||
void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
{
|
||||
// Clear old Settings
|
||||
KillTimer(m_Window, TRAYTIMER);
|
||||
|
||||
delete m_Measure;
|
||||
m_Measure = NULL;
|
||||
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = NULL;
|
||||
|
||||
for (size_t i = 0, isize = m_TrayIcons.size(); i < isize; ++i)
|
||||
{
|
||||
DestroyIcon(m_TrayIcons[i]);
|
||||
}
|
||||
m_TrayIcons.clear();
|
||||
|
||||
std::wstring measureName = parser.ReadString(L"TrayMeasure", L"Measure", L"");
|
||||
|
||||
if (!measureName.empty())
|
||||
{
|
||||
CConfigParser* oldParser = Rainmeter->GetCurrentParser();
|
||||
Rainmeter->SetCurrentParser(&parser);
|
||||
|
||||
try
|
||||
{
|
||||
m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure");
|
||||
if (m_Measure)
|
||||
{
|
||||
m_Measure->ReadConfig(parser);
|
||||
}
|
||||
}
|
||||
catch (CError& error)
|
||||
{
|
||||
delete m_Measure;
|
||||
m_Measure = NULL;
|
||||
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
Rainmeter->SetCurrentParser(oldParser);
|
||||
}
|
||||
|
||||
m_MeterType = TRAY_METER_TYPE_NONE;
|
||||
|
||||
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", L"HISTOGRAM");
|
||||
if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
|
||||
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
|
||||
}
|
||||
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_BITMAP;
|
||||
|
||||
std::wstring imageName = parser.ReadString(L"TrayMeasure", L"TrayBitmap", L"");
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if (!imageName.empty())
|
||||
{
|
||||
imageName.insert(0, Rainmeter->GetSkinPath());
|
||||
if (imageName.size() > 3)
|
||||
{
|
||||
std::wstring extension = imageName.substr(imageName.size() - 3);
|
||||
if (extension == L"ico" || extension == L"ICO")
|
||||
{
|
||||
int count = 1;
|
||||
HICON hIcon = NULL;
|
||||
|
||||
// Load the icons
|
||||
do
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
_snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++);
|
||||
|
||||
hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
|
||||
if (hIcon) m_TrayIcons.push_back(hIcon);
|
||||
if (imageName == buffer) break;
|
||||
} while(hIcon != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TrayIcons.empty())
|
||||
{
|
||||
// No icons found so load as bitmap
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = new Bitmap(imageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if (Ok != status)
|
||||
{
|
||||
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWithArgs(LOG_ERROR, L"No such TrayMeter: %s", type.c_str());
|
||||
}
|
||||
|
||||
// Read tray settings
|
||||
m_TrayIconEnabled = 0!=parser.ReadInt(L"Rainmeter", L"TrayIcon", 1);
|
||||
if (m_TrayIconEnabled)
|
||||
{
|
||||
std::wstring measureName = parser.ReadString(L"TrayMeasure", L"Measure", L"");
|
||||
|
||||
if (!measureName.empty())
|
||||
{
|
||||
CConfigParser* oldParser = Rainmeter->GetCurrentParser();
|
||||
Rainmeter->SetCurrentParser(&parser);
|
||||
|
||||
try
|
||||
{
|
||||
m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure");
|
||||
if (m_Measure)
|
||||
{
|
||||
m_Measure->ReadConfig(parser);
|
||||
}
|
||||
}
|
||||
catch (CError& error)
|
||||
{
|
||||
delete m_Measure;
|
||||
m_Measure = NULL;
|
||||
MessageBox(m_Window, error.GetString().c_str(), APPNAME, MB_OK | MB_TOPMOST | MB_ICONEXCLAMATION);
|
||||
}
|
||||
|
||||
Rainmeter->SetCurrentParser(oldParser);
|
||||
}
|
||||
|
||||
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", m_Measure ? L"HISTOGRAM" : L"NONE");
|
||||
if (_wcsicmp(type.c_str(), L"NONE") == 0)
|
||||
{
|
||||
// Use main icon
|
||||
}
|
||||
else if (_wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
|
||||
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
|
||||
}
|
||||
else if (_wcsicmp(type.c_str(), L"BITMAP") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_BITMAP;
|
||||
|
||||
std::wstring imageName = parser.ReadString(L"TrayMeasure", L"TrayBitmap", L"");
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if (!imageName.empty())
|
||||
{
|
||||
imageName.insert(0, Rainmeter->GetSkinPath());
|
||||
if (imageName.size() > 3)
|
||||
{
|
||||
std::wstring extension = imageName.substr(imageName.size() - 3);
|
||||
if (extension == L"ico" || extension == L"ICO")
|
||||
{
|
||||
int count = 1;
|
||||
HICON hIcon = NULL;
|
||||
|
||||
// Load the icons
|
||||
do
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
_snwprintf_s(buffer, _TRUNCATE, imageName.c_str(), count++);
|
||||
|
||||
hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
|
||||
if (hIcon) m_TrayIcons.push_back(hIcon);
|
||||
if (imageName == buffer) break;
|
||||
} while(hIcon != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TrayIcons.empty())
|
||||
{
|
||||
// No icons found so load as bitmap
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = new Bitmap(imageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if (Ok != status)
|
||||
{
|
||||
LogWithArgs(LOG_WARNING, L"Bitmap image not found: %s", imageName.c_str());
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LogWithArgs(LOG_ERROR, L"No such TrayMeter: %s", type.c_str());
|
||||
}
|
||||
|
||||
AddTrayIcon();
|
||||
|
||||
if (m_Measure)
|
||||
|
Loading…
x
Reference in New Issue
Block a user