mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
- SetOption: Fixed that new image isn't loaded if DynamicVariables=0.
- SetOption: Fixed that Rainmeter crashes if !SetOption is executed to Measure=Plugin. - Code cleanup and cosmetic changes.
This commit is contained in:
parent
a76e8d1765
commit
fb004083d2
@ -1208,10 +1208,10 @@ void CConfigParser::DeleteValue(const std::wstring& strSection, const std::wstri
|
||||
std::wstring strTmp = strSection + L"::";
|
||||
strTmp += strKey;
|
||||
|
||||
std::unordered_map<std::wstring, std::wstring>::iterator i = m_Values.find(StrToLower(strTmp));
|
||||
if (i != m_Values.end())
|
||||
std::unordered_map<std::wstring, std::wstring>::iterator iter = m_Values.find(StrToLower(strTmp));
|
||||
if (iter != m_Values.end())
|
||||
{
|
||||
m_Values.erase(i);
|
||||
m_Values.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,8 @@ void CMeasureScript::DeleteLuaScript()
|
||||
m_HasInitializeFunction = false;
|
||||
m_HasUpdateFunction = false;
|
||||
m_HasGetStringFunction = false;
|
||||
|
||||
m_ScriptFile.clear();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -125,9 +127,6 @@ const WCHAR* CMeasureScript::GetStringValue(AUTOSCALE autoScale, double scale, i
|
||||
*/
|
||||
void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
// Store the current values
|
||||
std::string oldScriptFile = m_ScriptFile;
|
||||
|
||||
// Read common configs
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
@ -135,15 +134,15 @@ void CMeasureScript::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
if (!file.empty())
|
||||
{
|
||||
file = m_MeterWindow->MakePathAbsolute(file);
|
||||
m_ScriptFile = ConvertToAscii(file.c_str());
|
||||
std::string scriptFile = ConvertToAscii(m_MeterWindow->MakePathAbsolute(file).c_str());
|
||||
|
||||
if (!m_Initialized ||
|
||||
oldScriptFile != m_ScriptFile)
|
||||
scriptFile != m_ScriptFile)
|
||||
{
|
||||
lua_State* L = LuaManager::GetState();
|
||||
|
||||
DeleteLuaScript();
|
||||
|
||||
lua_State* L = LuaManager::GetState();
|
||||
m_ScriptFile = scriptFile;
|
||||
m_LuaScript = new LuaScript(LuaManager::GetState(), m_ScriptFile.c_str());
|
||||
|
||||
if (m_LuaScript->IsInitialized())
|
||||
|
@ -45,7 +45,6 @@ protected:
|
||||
std::wstring m_StringValue;
|
||||
|
||||
std::string m_ScriptFile;
|
||||
std::string m_TableName;
|
||||
};
|
||||
|
||||
#endif
|
@ -33,7 +33,7 @@ using namespace Gdiplus;
|
||||
**
|
||||
*/
|
||||
CMeterImage::CMeterImage(CMeterWindow* meterWindow, const WCHAR* name) : CMeter(meterWindow, name),
|
||||
m_NeedsReload(false),
|
||||
m_NeedsRedraw(false),
|
||||
m_WidthDefined(false),
|
||||
m_HeightDefined(false),
|
||||
m_PreserveAspectRatio(false),
|
||||
@ -157,6 +157,13 @@ void CMeterImage::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
|
||||
// Read tinting configs
|
||||
m_Image.ReadConfig(parser, section);
|
||||
|
||||
if (m_Initialized &&
|
||||
!m_Measure && !m_DynamicVariables)
|
||||
{
|
||||
Initialize();
|
||||
m_NeedsRedraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -216,6 +223,11 @@ bool CMeterImage::Update()
|
||||
LoadImage(m_ImageNameResult, oldResult != m_ImageNameResult);
|
||||
return true;
|
||||
}
|
||||
else if (m_NeedsRedraw)
|
||||
{
|
||||
m_NeedsRedraw = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ protected:
|
||||
std::wstring m_ImageNameResult; // Name of the image (as absolute path)
|
||||
std::wstring m_Path;
|
||||
|
||||
bool m_NeedsReload;
|
||||
bool m_NeedsRedraw;
|
||||
bool m_WidthDefined;
|
||||
bool m_HeightDefined;
|
||||
bool m_PreserveAspectRatio; // If true, aspect ratio of the image is preserved when the image is scaled
|
||||
|
@ -1461,27 +1461,29 @@ void CMeterWindow::SetOption(const WCHAR* arg, bool group)
|
||||
|
||||
if (group)
|
||||
{
|
||||
for (std::list<CMeter*>::const_iterator i = m_Meters.begin(); i != m_Meters.end(); ++i)
|
||||
for (std::list<CMeter*>::const_iterator j = m_Meters.begin(); j != m_Meters.end(); ++j)
|
||||
{
|
||||
if ((*i)->BelongsToGroup(section))
|
||||
if ((*j)->BelongsToGroup(section))
|
||||
{
|
||||
(*i)->SetDynamicVariables(true);
|
||||
// Force DynamicVariables temporarily (it will reset back to original setting in ReadConfig())
|
||||
(*j)->SetDynamicVariables(true);
|
||||
|
||||
if (value.empty())
|
||||
{
|
||||
GetParser().DeleteValue((*i)->GetName(), option);
|
||||
GetParser().DeleteValue((*j)->GetName(), option);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetParser().SetValue((*i)->GetName(), option, value);
|
||||
GetParser().SetValue((*j)->GetName(), option, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (std::list<CMeasure*>::const_iterator i = m_Measures.begin(); i != m_Measures.end(); ++i)
|
||||
{
|
||||
if ((*i)->BelongsToGroup(section))
|
||||
if ((*i)->BelongsToGroup(section) && dynamic_cast<CMeasurePlugin*>(*i) == NULL)
|
||||
{
|
||||
// Force DynamicVariables temporarily (it will reset back to original setting in ReadConfig())
|
||||
(*i)->SetDynamicVariables(true);
|
||||
|
||||
if (value.empty())
|
||||
@ -1516,8 +1518,9 @@ void CMeterWindow::SetOption(const WCHAR* arg, bool group)
|
||||
}
|
||||
|
||||
CMeasure* measure = GetMeasure(section);
|
||||
if (measure)
|
||||
if (measure && dynamic_cast<CMeasurePlugin*>(measure) == NULL)
|
||||
{
|
||||
// Force DynamicVariables temporarily (it will reset back to original setting in ReadConfig())
|
||||
measure->SetDynamicVariables(true);
|
||||
|
||||
if (value.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user