mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Additional code changes by spx268 to address issues with other image meter types (MeterBar, MeterBitmap, MeterButton, MeterRotator) and dynamic variables.
http://code.google.com/p/rainmeter/issues/detail?id=108
This commit is contained in:
parent
48bee2c6fe
commit
8ea3c6780a
@ -69,10 +69,14 @@ void CMeterBar::Initialize()
|
|||||||
// Load the bitmaps if defined
|
// Load the bitmaps if defined
|
||||||
if(!m_ImageName.empty())
|
if(!m_ImageName.empty())
|
||||||
{
|
{
|
||||||
|
if (m_Bitmap != NULL) delete m_Bitmap;
|
||||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||||
Status status = m_Bitmap->GetLastStatus();
|
Status status = m_Bitmap->GetLastStatus();
|
||||||
if(Ok != status)
|
if(Ok != status)
|
||||||
{
|
{
|
||||||
|
delete m_Bitmap;
|
||||||
|
m_Bitmap = NULL;
|
||||||
|
|
||||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +93,9 @@ void CMeterBar::Initialize()
|
|||||||
*/
|
*/
|
||||||
void CMeterBar::ReadConfig(const WCHAR* section)
|
void CMeterBar::ReadConfig(const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
// Store the current values so we know if the image needs to be updated
|
||||||
|
std::wstring oldImageName = m_ImageName;
|
||||||
|
|
||||||
// Read common configs
|
// Read common configs
|
||||||
CMeter::ReadConfig(section);
|
CMeter::ReadConfig(section);
|
||||||
|
|
||||||
@ -118,6 +125,12 @@ void CMeterBar::ReadConfig(const WCHAR* section)
|
|||||||
{
|
{
|
||||||
throw CError(std::wstring(L"No such BarOrientation: ") + orientation, __LINE__, __FILE__);
|
throw CError(std::wstring(L"No such BarOrientation: ") + orientation, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_Initialized &&
|
||||||
|
oldImageName != m_ImageName)
|
||||||
|
{
|
||||||
|
Initialize(); // Reload the image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -72,10 +72,14 @@ void CMeterBitmap::Initialize()
|
|||||||
// Load the bitmaps if defined
|
// Load the bitmaps if defined
|
||||||
if(!m_ImageName.empty())
|
if(!m_ImageName.empty())
|
||||||
{
|
{
|
||||||
|
if (m_Bitmap != NULL) delete m_Bitmap;
|
||||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||||
Status status = m_Bitmap->GetLastStatus();
|
Status status = m_Bitmap->GetLastStatus();
|
||||||
if(Ok != status)
|
if(Ok != status)
|
||||||
{
|
{
|
||||||
|
delete m_Bitmap;
|
||||||
|
m_Bitmap = NULL;
|
||||||
|
|
||||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +167,9 @@ bool CMeterBitmap::HitTest(int x, int y)
|
|||||||
*/
|
*/
|
||||||
void CMeterBitmap::ReadConfig(const WCHAR* section)
|
void CMeterBitmap::ReadConfig(const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
// Store the current values so we know if the image needs to be updated
|
||||||
|
std::wstring oldImageName = m_ImageName;
|
||||||
|
|
||||||
// Read common configs
|
// Read common configs
|
||||||
CMeter::ReadConfig(section);
|
CMeter::ReadConfig(section);
|
||||||
|
|
||||||
@ -199,6 +206,12 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
|
|||||||
{
|
{
|
||||||
throw CError(std::wstring(L"No such BitmapAlign: ") + align, __LINE__, __FILE__);
|
throw CError(std::wstring(L"No such BitmapAlign: ") + align, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_Initialized &&
|
||||||
|
oldImageName != m_ImageName)
|
||||||
|
{
|
||||||
|
Initialize(); // Reload the image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -81,10 +81,23 @@ void CMeterButton::Initialize()
|
|||||||
// Load the bitmaps if defined
|
// Load the bitmaps if defined
|
||||||
if(!m_ImageName.empty())
|
if(!m_ImageName.empty())
|
||||||
{
|
{
|
||||||
|
for (int i = 0; i < BUTTON_FRAMES; ++i)
|
||||||
|
{
|
||||||
|
if (m_Bitmaps[i] != NULL)
|
||||||
|
{
|
||||||
|
delete m_Bitmaps[i];
|
||||||
|
m_Bitmaps[i] = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (m_Bitmap != NULL) delete m_Bitmap;
|
||||||
|
|
||||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||||
Status status = m_Bitmap->GetLastStatus();
|
Status status = m_Bitmap->GetLastStatus();
|
||||||
if(Ok != status)
|
if(Ok != status)
|
||||||
{
|
{
|
||||||
|
delete m_Bitmap;
|
||||||
|
m_Bitmap = NULL;
|
||||||
|
|
||||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +143,11 @@ void CMeterButton::Initialize()
|
|||||||
*/
|
*/
|
||||||
void CMeterButton::ReadConfig(const WCHAR* section)
|
void CMeterButton::ReadConfig(const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
// Store the current values so we know if the image needs to be updated
|
||||||
|
std::wstring oldImageName = m_ImageName;
|
||||||
|
int oldW = m_W;
|
||||||
|
int oldH = m_H;
|
||||||
|
|
||||||
// Read common configs
|
// Read common configs
|
||||||
CMeter::ReadConfig(section);
|
CMeter::ReadConfig(section);
|
||||||
|
|
||||||
@ -139,6 +157,20 @@ void CMeterButton::ReadConfig(const WCHAR* section)
|
|||||||
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
|
m_ImageName = m_MeterWindow->MakePathAbsolute(m_ImageName);
|
||||||
|
|
||||||
m_Command = parser.ReadString(section, L"ButtonCommand", L"");
|
m_Command = parser.ReadString(section, L"ButtonCommand", L"");
|
||||||
|
|
||||||
|
if (m_Initialized)
|
||||||
|
{
|
||||||
|
if (oldImageName != m_ImageName)
|
||||||
|
{
|
||||||
|
Initialize(); // Reload the image
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Reset to old dimensions
|
||||||
|
m_W = oldW;
|
||||||
|
m_H = oldH;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -65,10 +65,14 @@ void CMeterRotator::Initialize()
|
|||||||
// Load the bitmaps if defined
|
// Load the bitmaps if defined
|
||||||
if(!m_ImageName.empty())
|
if(!m_ImageName.empty())
|
||||||
{
|
{
|
||||||
|
if (m_Bitmap != NULL) delete m_Bitmap;
|
||||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||||
Status status = m_Bitmap->GetLastStatus();
|
Status status = m_Bitmap->GetLastStatus();
|
||||||
if(Ok != status)
|
if(Ok != status)
|
||||||
{
|
{
|
||||||
|
delete m_Bitmap;
|
||||||
|
m_Bitmap = NULL;
|
||||||
|
|
||||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,6 +86,9 @@ void CMeterRotator::Initialize()
|
|||||||
*/
|
*/
|
||||||
void CMeterRotator::ReadConfig(const WCHAR* section)
|
void CMeterRotator::ReadConfig(const WCHAR* section)
|
||||||
{
|
{
|
||||||
|
// Store the current values so we know if the image needs to be updated
|
||||||
|
std::wstring oldImageName = m_ImageName;
|
||||||
|
|
||||||
// Read common configs
|
// Read common configs
|
||||||
CMeter::ReadConfig(section);
|
CMeter::ReadConfig(section);
|
||||||
|
|
||||||
@ -97,6 +104,12 @@ void CMeterRotator::ReadConfig(const WCHAR* section)
|
|||||||
|
|
||||||
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
||||||
m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder);
|
m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder);
|
||||||
|
|
||||||
|
if (m_Initialized &&
|
||||||
|
oldImageName != m_ImageName)
|
||||||
|
{
|
||||||
|
Initialize(); // Reload the image
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user