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
f15b6723b5
commit
9453780c26
@ -104,7 +104,7 @@ void CConfigParser::SetBuiltInVariables(CRainmeter* pRainmeter, CMeterWindow* me
|
|||||||
|
|
||||||
SetBuiltInVariable(L"CRLF", L"\n");
|
SetBuiltInVariable(L"CRLF", L"\n");
|
||||||
|
|
||||||
const std::wstring CURRENTSECTION = StrToLower(L"CURRENTSECTION");
|
const std::wstring CURRENTSECTION = L"CURRENTSECTION";
|
||||||
SetBuiltInVariable(CURRENTSECTION, L"");
|
SetBuiltInVariable(CURRENTSECTION, L"");
|
||||||
m_CurrentSection = &((*m_BuiltInVariables.find(CURRENTSECTION)).second); // shortcut
|
m_CurrentSection = &((*m_BuiltInVariables.find(CURRENTSECTION)).second); // shortcut
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
|
|||||||
{
|
{
|
||||||
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
|
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
|
||||||
|
|
||||||
const std::wstring strTmp = StrToLower(strVariable);
|
const std::wstring strTmp = StrToUpper(strVariable);
|
||||||
|
|
||||||
variables[strTmp] = strValue;
|
variables[strTmp] = strValue;
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
|
|||||||
{
|
{
|
||||||
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
|
// LogWithArgs(LOG_DEBUG, L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), (int)variables.size());
|
||||||
|
|
||||||
const std::wstring strTmp = StrToLower(strVariable);
|
const std::wstring strTmp = StrToUpper(strVariable);
|
||||||
|
|
||||||
variables[strTmp] = strValue;
|
variables[strTmp] = strValue;
|
||||||
}
|
}
|
||||||
@ -150,7 +150,7 @@ void CConfigParser::SetVariable(std::unordered_map<std::wstring, std::wstring>&
|
|||||||
*/
|
*/
|
||||||
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
|
bool CConfigParser::GetVariable(const std::wstring& strVariable, std::wstring& strValue)
|
||||||
{
|
{
|
||||||
const std::wstring strTmp = StrToLower(strVariable);
|
const std::wstring strTmp = StrToUpper(strVariable);
|
||||||
|
|
||||||
// #1: Built-in variables
|
// #1: Built-in variables
|
||||||
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
||||||
@ -656,13 +656,13 @@ void CConfigParser::AddMeasure(CMeasure* pMeasure)
|
|||||||
{
|
{
|
||||||
if (pMeasure)
|
if (pMeasure)
|
||||||
{
|
{
|
||||||
m_Measures[StrToLower(pMeasure->GetOriginalName())] = pMeasure;
|
m_Measures[StrToUpper(pMeasure->GetOriginalName())] = pMeasure;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
CMeasure* CConfigParser::GetMeasure(const std::wstring& name)
|
||||||
{
|
{
|
||||||
std::unordered_map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToLower(name));
|
std::unordered_map<std::wstring, CMeasure*>::const_iterator iter = m_Measures.find(StrToUpper(name));
|
||||||
if (iter != m_Measures.end())
|
if (iter != m_Measures.end())
|
||||||
{
|
{
|
||||||
return (*iter).second;
|
return (*iter).second;
|
||||||
@ -1223,7 +1223,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int
|
|||||||
if (*pos)
|
if (*pos)
|
||||||
{
|
{
|
||||||
value = pos; // section name
|
value = pos; // section name
|
||||||
StrToLowerC(key.assign(value));
|
StrToUpperC(key.assign(value));
|
||||||
if (unique.insert(key).second)
|
if (unique.insert(key).second)
|
||||||
{
|
{
|
||||||
if (m_FoundSections.insert(key).second)
|
if (m_FoundSections.insert(key).second)
|
||||||
@ -1294,7 +1294,7 @@ void CConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR config, int
|
|||||||
{
|
{
|
||||||
size_t clen = sep - pos; // key's length
|
size_t clen = sep - pos; // key's length
|
||||||
|
|
||||||
StrToLowerC(key.assign(pos, clen));
|
StrToUpperC(key.assign(pos, clen));
|
||||||
if (unique.insert(key).second)
|
if (unique.insert(key).second)
|
||||||
{
|
{
|
||||||
++sep;
|
++sep;
|
||||||
@ -1364,7 +1364,7 @@ void CConfigParser::SetValue(const std::wstring& strSection, const std::wstring&
|
|||||||
strTmp += L'~';
|
strTmp += L'~';
|
||||||
strTmp += strKey;
|
strTmp += strKey;
|
||||||
|
|
||||||
m_Values[StrToLowerC(strTmp)] = strValue;
|
m_Values[StrToUpperC(strTmp)] = strValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1379,7 +1379,7 @@ void CConfigParser::DeleteValue(const std::wstring& strSection, const std::wstri
|
|||||||
strTmp += L'~';
|
strTmp += L'~';
|
||||||
strTmp += strKey;
|
strTmp += strKey;
|
||||||
|
|
||||||
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLowerC(strTmp));
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
|
||||||
if (iter != m_Values.end())
|
if (iter != m_Values.end())
|
||||||
{
|
{
|
||||||
m_Values.erase(iter);
|
m_Values.erase(iter);
|
||||||
@ -1398,6 +1398,6 @@ const std::wstring& CConfigParser::GetValue(const std::wstring& strSection, cons
|
|||||||
strTmp += L'~';
|
strTmp += L'~';
|
||||||
strTmp += strKey;
|
strTmp += strKey;
|
||||||
|
|
||||||
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToLowerC(strTmp));
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
|
||||||
return (iter != m_Values.end()) ? (*iter).second : strDefault;
|
return (iter != m_Values.end()) ? (*iter).second : strDefault;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,6 @@ public:
|
|||||||
bool GetVariable(const std::wstring& strVariable, std::wstring& strValue);
|
bool GetVariable(const std::wstring& strVariable, std::wstring& strValue);
|
||||||
void SetVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_Variables, strVariable, strValue); }
|
void SetVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_Variables, strVariable, strValue); }
|
||||||
void SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
|
void SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
|
||||||
void SetBuiltInVariable(const WCHAR* strVariable, const WCHAR* strValue) { SetVariable(m_BuiltInVariables, strVariable, strValue); }
|
|
||||||
|
|
||||||
const std::unordered_map<std::wstring, std::wstring>& GetVariables() { return m_Variables; }
|
const std::unordered_map<std::wstring, std::wstring>& GetVariables() { return m_Variables; }
|
||||||
|
|
||||||
@ -119,9 +118,9 @@ private:
|
|||||||
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
static void SetMonitorVariable(const std::wstring& strVariable, const std::wstring& strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
||||||
static void SetMonitorVariable(const WCHAR* strVariable, const WCHAR* strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
static void SetMonitorVariable(const WCHAR* strVariable, const WCHAR* strValue) { SetVariable(c_MonitorVariables, strVariable, strValue); }
|
||||||
|
|
||||||
static std::wstring StrToLower(const std::wstring& str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
|
static std::wstring StrToUpper(const std::wstring& str) { std::wstring strTmp(str); StrToUpperC(strTmp); return strTmp; }
|
||||||
static std::wstring StrToLower(const WCHAR* str) { std::wstring strTmp(str); StrToLowerC(strTmp); return strTmp; }
|
static std::wstring StrToUpper(const WCHAR* str) { std::wstring strTmp(str); StrToUpperC(strTmp); return strTmp; }
|
||||||
static std::wstring& StrToLowerC(std::wstring& str) { _wcslwr(&str[0]); return str; }
|
static std::wstring& StrToUpperC(std::wstring& str) { _wcsupr(&str[0]); return str; }
|
||||||
|
|
||||||
std::wstring m_Filename;
|
std::wstring m_Filename;
|
||||||
|
|
||||||
|
@ -59,8 +59,7 @@ std::wstring CGroup::CreateGroup(const std::wstring& str)
|
|||||||
// Trim white-space
|
// Trim white-space
|
||||||
strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1);
|
strTmp.assign(str, pos, str.find_last_not_of(L" \t\r\n") - pos + 1);
|
||||||
|
|
||||||
// Convert to lower
|
_wcsupr(&strTmp[0]);
|
||||||
_wcslwr(&strTmp[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return strTmp;
|
return strTmp;
|
||||||
|
@ -765,7 +765,7 @@ void CMeterString::FreeFontCache(PrivateFontCollection* collection)
|
|||||||
size_t len = _snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
size_t len = _snwprintf_s(buffer, _TRUNCATE, L"<%p>", collection);
|
||||||
|
|
||||||
prefix.assign(buffer, len);
|
prefix.assign(buffer, len);
|
||||||
StringToLower(prefix);
|
_wcsupr(&prefix[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
|
std::unordered_map<std::wstring, Gdiplus::Font*>::iterator iter2 = c_Fonts.begin();
|
||||||
@ -818,7 +818,7 @@ std::wstring CMeterString::FontFaceToString(const std::wstring& fontFace, Privat
|
|||||||
strTmp.reserve(len + fontFace.size());
|
strTmp.reserve(len + fontFace.size());
|
||||||
strTmp.assign(buffer, len);
|
strTmp.assign(buffer, len);
|
||||||
strTmp += fontFace;
|
strTmp += fontFace;
|
||||||
StringToLower(strTmp);
|
_wcsupr(&strTmp[0]);
|
||||||
return strTmp;
|
return strTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2070,9 +2070,8 @@ bool CMeterWindow::ReadSkin()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checking for localfonts
|
// Load local fonts
|
||||||
const WCHAR* localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L"").c_str();
|
const WCHAR* localFont = m_Parser.ReadString(L"Rainmeter", L"LocalFont", L"").c_str();
|
||||||
// If there is a local font we want to load it
|
|
||||||
if (*localFont)
|
if (*localFont)
|
||||||
{
|
{
|
||||||
m_FontCollection = new PrivateFontCollection();
|
m_FontCollection = new PrivateFontCollection();
|
||||||
@ -2080,34 +2079,22 @@ bool CMeterWindow::ReadSkin()
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
// We want to check the fonts folder first
|
// Try program folder first
|
||||||
// !!!!!!! - We may want to fix the method in which I get the path to
|
|
||||||
// Rainmeter/fonts
|
|
||||||
std::wstring szFontFile = Rainmeter->GetPath() + L"Fonts\\";
|
std::wstring szFontFile = Rainmeter->GetPath() + L"Fonts\\";
|
||||||
szFontFile += localFont;
|
szFontFile += localFont;
|
||||||
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
Status nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||||
|
|
||||||
// It wasn't found in the fonts folder, check the local folder
|
|
||||||
if (nResults != Ok)
|
if (nResults != Ok)
|
||||||
{
|
{
|
||||||
szFontFile = Rainmeter->GetSkinPath(); // Get the local path
|
szFontFile = localFont;
|
||||||
szFontFile += m_SkinName;
|
MakePathAbsolute(szFontFile);
|
||||||
szFontFile += L'\\';
|
|
||||||
szFontFile += localFont;
|
|
||||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
||||||
|
|
||||||
// The font wasn't found, check full path.
|
|
||||||
if (nResults != Ok)
|
if (nResults != Ok)
|
||||||
{
|
{
|
||||||
szFontFile = localFont;
|
std::wstring error = L"Unable to load font file: ";
|
||||||
nResults = m_FontCollection->AddFontFile(szFontFile.c_str());
|
error += localFont;
|
||||||
|
Log(LOG_ERROR, error.c_str());
|
||||||
if (nResults != Ok)
|
|
||||||
{
|
|
||||||
std::wstring error = L"Unable to load font file: ";
|
|
||||||
error += localFont;
|
|
||||||
Log(LOG_ERROR, error.c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public:
|
|||||||
{
|
{
|
||||||
key = name;
|
key = name;
|
||||||
}
|
}
|
||||||
_wcslwr(&key[0]);
|
_wcsupr(&key[0]);
|
||||||
|
|
||||||
size_t len = _snwprintf_s(buffer, _TRUNCATE, L":%llx:%x", time, size);
|
size_t len = _snwprintf_s(buffer, _TRUNCATE, L":%llx:%x", time, size);
|
||||||
key.append(buffer, len);
|
key.append(buffer, len);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user