mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Added 64-bit compilation configuration.
The bitmap meter supports transition frames now. Few Vista/Win7 fixes (the rainmeter.ini is now in %APPDATA%).
This commit is contained in:
@ -157,7 +157,7 @@ BEGIN
|
||||
CONTROL "List1",IDC_STATISTICS,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER |
|
||||
WS_TABSTOP,14,98,206,98
|
||||
CTEXT "Get the latest version at: http://www.iki.fi/rainy",
|
||||
CTEXT "Get the latest version at: http://www.rainmeter.net",
|
||||
IDC_URL_STRING,19,43,201,8
|
||||
CTEXT "Rainmeter version 0.0",IDC_VERSION_STRING,19,17,201,8
|
||||
CONTROL "Tab1",IDC_CONFIG_TAB,"SysTabControl32",0x0,7,81,220,120
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -20,11 +20,14 @@
|
||||
|
||||
#include "Litestep.h"
|
||||
#include "Error.h"
|
||||
#include "Rainmeter.h"
|
||||
#include <shellapi.h>
|
||||
#include <crtdbg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
typedef BOOL (*FPADDBANGCOMMAND)(LPCSTR command, BangCommand f);
|
||||
FPADDBANGCOMMAND fpAddBangCommand = NULL;
|
||||
|
||||
@ -277,6 +280,47 @@ HRGN BitmapToRegion(HBITMAP hbm, COLORREF clrTransp, COLORREF clrTolerance, int
|
||||
return hRgn;
|
||||
}
|
||||
|
||||
HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
{
|
||||
BOOL IsInAdminGroup = FALSE;
|
||||
|
||||
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
|
||||
PSID AdministratorsGroup;
|
||||
// Initialize SID.
|
||||
if( !AllocateAndInitializeSid( &NtAuthority,
|
||||
2,
|
||||
SECURITY_BUILTIN_DOMAIN_RID,
|
||||
DOMAIN_ALIAS_RID_ADMINS,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
&AdministratorsGroup))
|
||||
{
|
||||
// Initializing SID Failed.
|
||||
IsInAdminGroup = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check whether the token is present in admin group.
|
||||
if( !CheckTokenMembership( NULL,
|
||||
AdministratorsGroup,
|
||||
&IsInAdminGroup ))
|
||||
{
|
||||
// Error occurred.
|
||||
IsInAdminGroup = FALSE;
|
||||
}
|
||||
// Free SID and return.
|
||||
FreeSid(AdministratorsGroup);
|
||||
}
|
||||
|
||||
if (IsInAdminGroup)
|
||||
{
|
||||
return ExecuteCommand(Owner, szCommand, nShowCmd, L"open");
|
||||
}
|
||||
else
|
||||
{
|
||||
return ExecuteCommand(Owner, szCommand, nShowCmd, L"runas");
|
||||
}
|
||||
}
|
||||
|
||||
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
@ -286,6 +330,11 @@ HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
return fpLSExecute(Owner, asc.c_str(), nShowCmd);
|
||||
}
|
||||
|
||||
return ExecuteCommand(Owner, szCommand, nShowCmd, L"open");
|
||||
}
|
||||
|
||||
HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR szVerb)
|
||||
{
|
||||
// The stub implementation (some of this code is taken from lsapi.cpp)
|
||||
if (szCommand == NULL || wcslen(szCommand) == 0) return NULL;
|
||||
|
||||
@ -322,7 +371,7 @@ HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
DWORD type = GetFileAttributes(command.c_str());
|
||||
if (type & FILE_ATTRIBUTE_DIRECTORY && type != 0xFFFFFFFF)
|
||||
{
|
||||
HINSTANCE instance = ShellExecute(Owner, L"open", command.c_str(), NULL, NULL, nShowCmd ? nShowCmd : SW_SHOWNORMAL);
|
||||
HINSTANCE instance = ShellExecute(Owner, szVerb, command.c_str(), NULL, NULL, nShowCmd ? nShowCmd : SW_SHOWNORMAL);
|
||||
return instance;
|
||||
}
|
||||
|
||||
@ -337,7 +386,7 @@ HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
si.hwnd = Owner;
|
||||
si.lpVerb = L"open";
|
||||
si.lpVerb = szVerb;
|
||||
si.lpFile = command.c_str();
|
||||
si.lpParameters = args.c_str();
|
||||
si.lpDirectory = dir.c_str();
|
||||
@ -483,55 +532,54 @@ BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
||||
}
|
||||
|
||||
// The stub implementation
|
||||
FILE* logFile;
|
||||
GetModuleFileName(NULL, buffer, MAX_PATH);
|
||||
|
||||
std::wstring logfile(buffer);
|
||||
logfile.replace(logfile.length() - 4, 4, L".log");
|
||||
|
||||
if (logFound == 0)
|
||||
if (Rainmeter)
|
||||
{
|
||||
// Check if the file exists
|
||||
logFile = _wfopen(logfile.c_str(), L"r");
|
||||
if (logFile)
|
||||
FILE* logFile;
|
||||
std::wstring logfile = Rainmeter->GetLogFile();
|
||||
if (logFound == 0)
|
||||
{
|
||||
logFound = 1;
|
||||
fclose(logFile);
|
||||
|
||||
// Clear the file
|
||||
logFile = _wfopen(logfile.c_str(), L"w");
|
||||
fputwc(0xFEFF, logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
logFound = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (logFound == 1)
|
||||
{
|
||||
logFile = _wfopen(logfile.c_str(), L"a+");
|
||||
if (logFile)
|
||||
{
|
||||
switch(nLevel)
|
||||
// Check if the file exists
|
||||
logFile = _wfopen(logfile.c_str(), L"r");
|
||||
if (logFile)
|
||||
{
|
||||
case 1:
|
||||
fputws(L"ERROR: ", logFile);
|
||||
break;
|
||||
case 2:
|
||||
fputws(L"WARNING: ", logFile);
|
||||
break;
|
||||
case 3:
|
||||
fputws(L"NOTICE: ", logFile);
|
||||
break;
|
||||
case 4:
|
||||
fputws(L"DEBUG: ", logFile);
|
||||
break;
|
||||
logFound = 1;
|
||||
fclose(logFile);
|
||||
|
||||
// Clear the file
|
||||
logFile = _wfopen(logfile.c_str(), L"w");
|
||||
fputwc(0xFEFF, logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
logFound = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (logFound == 1)
|
||||
{
|
||||
logFile = _wfopen(logfile.c_str(), L"a+");
|
||||
if (logFile)
|
||||
{
|
||||
switch(nLevel)
|
||||
{
|
||||
case 1:
|
||||
fputws(L"ERROR: ", logFile);
|
||||
break;
|
||||
case 2:
|
||||
fputws(L"WARNING: ", logFile);
|
||||
break;
|
||||
case 3:
|
||||
fputws(L"NOTICE: ", logFile);
|
||||
break;
|
||||
case 4:
|
||||
fputws(L"DEBUG: ", logFile);
|
||||
break;
|
||||
}
|
||||
fputws(message.c_str(), logFile);
|
||||
fputws(L"\n", logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
fputws(message.c_str(), logFile);
|
||||
fputws(L"\n", logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,4 +59,7 @@ void ResetLoggingFlag();
|
||||
std::string ConvertToAscii(LPCTSTR str);
|
||||
std::wstring ConvertToWide(LPCSTR str);
|
||||
|
||||
HINSTANCE LSExecuteAsAdmin(HWND Owner, LPCTSTR szCommand, int nShowCmd);
|
||||
HINSTANCE ExecuteCommand(HWND Owner, LPCTSTR szCommand, int nShowCmd, LPCTSTR szVerb);
|
||||
|
||||
#endif
|
@ -38,6 +38,7 @@ public:
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
virtual bool HasActiveTransition() { return false; }
|
||||
|
||||
virtual int GetH() { return m_Hidden ? 0 : m_H; };
|
||||
virtual int GetW() { return m_Hidden ? 0 : m_W; };
|
||||
|
@ -44,6 +44,8 @@ CMeterBitmap::CMeterBitmap(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
m_Separation = 0;
|
||||
m_Digits = 0;
|
||||
m_Value = 0;
|
||||
m_TransitionFrameCount = 0;
|
||||
m_TransitionStartTicks = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -115,16 +117,17 @@ bool CMeterBitmap::HitTest(int x, int y)
|
||||
}
|
||||
else
|
||||
{
|
||||
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
||||
do
|
||||
{
|
||||
numOfNums ++;
|
||||
if (m_FrameCount == 1)
|
||||
if (realFrames == 1)
|
||||
{
|
||||
tmpValue /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpValue /= m_FrameCount;
|
||||
tmpValue /= realFrames;
|
||||
}
|
||||
} while (tmpValue > 0);
|
||||
}
|
||||
@ -175,6 +178,8 @@ void CMeterBitmap::ReadConfig(const WCHAR* section)
|
||||
m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0);
|
||||
m_Digits = parser.ReadInt(section, L"BitmapDigits", 0);
|
||||
|
||||
m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0);
|
||||
|
||||
std::wstring align;
|
||||
align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
|
||||
@ -206,14 +211,47 @@ bool CMeterBitmap::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
double value = 0.0;
|
||||
if (m_Extend)
|
||||
{
|
||||
m_Value = m_Measure->GetValue();
|
||||
value = m_Measure->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = m_Measure->GetRelativeValue();
|
||||
value = m_Measure->GetRelativeValue();
|
||||
}
|
||||
|
||||
if (m_TransitionFrameCount > 0)
|
||||
{
|
||||
int realFrames = m_FrameCount / (m_TransitionFrameCount + 1);
|
||||
if ((int)(value * realFrames) != (int)(m_Value * realFrames))
|
||||
{
|
||||
m_TransitionStartValue = m_Value;
|
||||
m_TransitionStartTicks = GetTickCount();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TransitionStartTicks = 0;
|
||||
}
|
||||
}
|
||||
|
||||
m_Value = value;
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** HasActiveTransition
|
||||
**
|
||||
** Returns true if the meter has active transition animation.
|
||||
**
|
||||
*/
|
||||
bool CMeterBitmap::HasActiveTransition()
|
||||
{
|
||||
if (m_TransitionStartTicks > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -236,11 +274,15 @@ bool CMeterBitmap::Draw()
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
DWORD diffTicks = GetTickCount() - m_TransitionStartTicks;
|
||||
if (m_Extend)
|
||||
{
|
||||
int value = (int)m_Value;
|
||||
value = max(0, value); // Only positive integers are supported
|
||||
|
||||
int transitionValue = (int)m_TransitionStartValue;
|
||||
transitionValue = max(0, transitionValue); // Only positive integers are supported
|
||||
|
||||
int tmpValue = value;
|
||||
// Calc the number of numbers
|
||||
int numOfNums = 0;
|
||||
@ -288,14 +330,41 @@ bool CMeterBitmap::Draw()
|
||||
|
||||
Rect r(x + offset, y, m_W, m_H);
|
||||
|
||||
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
||||
int frame = (value % realFrames) * (m_TransitionFrameCount + 1);
|
||||
|
||||
// If transition is ongoing the pick the correct frame
|
||||
if (m_TransitionStartTicks > 0)
|
||||
{
|
||||
int range = ((value % realFrames) - ((int)transitionValue % realFrames)) * (m_TransitionFrameCount + 1);
|
||||
if (range < 0)
|
||||
{
|
||||
range += m_FrameCount;
|
||||
}
|
||||
int frameAdjustment = 0;
|
||||
frameAdjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
|
||||
if (frameAdjustment > range)
|
||||
{
|
||||
m_TransitionStartTicks = 0; // The transition is over. Draw with the real value.
|
||||
}
|
||||
else
|
||||
{
|
||||
frame = ((int)transitionValue % realFrames) * (m_TransitionFrameCount + 1);
|
||||
frame += frameAdjustment;
|
||||
frame %= m_FrameCount;
|
||||
}
|
||||
}
|
||||
|
||||
// DebugLog(L"[%i] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(m_Bitmap->GetHeight() > m_Bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = m_H * (value % m_FrameCount);
|
||||
newY = m_H * frame;
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = m_W * (value % m_FrameCount);
|
||||
newX = m_W * frame;
|
||||
newY = 0;
|
||||
}
|
||||
|
||||
@ -303,10 +372,12 @@ bool CMeterBitmap::Draw()
|
||||
if (m_FrameCount == 1)
|
||||
{
|
||||
value /= 2;
|
||||
transitionValue /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
value /= m_FrameCount;
|
||||
value /= realFrames;
|
||||
transitionValue /= realFrames;
|
||||
}
|
||||
numOfNums--;
|
||||
} while (numOfNums > 0);
|
||||
@ -314,21 +385,44 @@ bool CMeterBitmap::Draw()
|
||||
else
|
||||
{
|
||||
int frame = 0;
|
||||
int realFrames = (m_FrameCount / (m_TransitionFrameCount + 1));
|
||||
|
||||
if (m_ZeroFrame)
|
||||
{
|
||||
// Use the first frame only if the value is zero
|
||||
if (m_Value > 0)
|
||||
{
|
||||
frame = (int)(m_Value * (m_FrameCount - 1));
|
||||
frame = (int)(m_Value * (realFrames - 1)) * (m_TransitionFrameCount + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the correct frame linearly
|
||||
frame = (int)(m_Value * m_FrameCount);
|
||||
frame = (int)(m_Value * realFrames) * (m_TransitionFrameCount + 1);
|
||||
}
|
||||
|
||||
// If transition is ongoing the pick the correct frame
|
||||
if (m_TransitionStartTicks > 0)
|
||||
{
|
||||
if ((int)diffTicks > ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate()))
|
||||
{
|
||||
m_TransitionStartTicks = 0; // The transition is over. Draw with the real value.
|
||||
}
|
||||
else
|
||||
{
|
||||
double range = (m_Value - m_TransitionStartValue);
|
||||
double adjustment = range * diffTicks / ((m_TransitionFrameCount + 1) * m_MeterWindow->GetTransitionUpdate());
|
||||
double frameAdjustment = adjustment * m_FrameCount;
|
||||
|
||||
frame = (int)(m_TransitionStartValue * realFrames) * (m_TransitionFrameCount + 1);
|
||||
frame += (int)frameAdjustment;
|
||||
frame %= m_FrameCount;
|
||||
frame = max(0, frame);
|
||||
}
|
||||
}
|
||||
|
||||
// DebugLog(L"[%i] Value: %f Frame: %i (Transition = %s)", GetTickCount(), m_Value, frame, m_TransitionStartTicks > 0 ? L"true" : L"false");
|
||||
|
||||
if(m_Bitmap->GetHeight() > m_Bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
|
@ -34,17 +34,22 @@ public:
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual bool HasActiveTransition();
|
||||
|
||||
private:
|
||||
bool m_ZeroFrame; // If true, the first frame is only shown when the measured value is zero
|
||||
int m_FrameCount; // Number of frames in the bitmap
|
||||
Gdiplus::Bitmap* m_Bitmap; // Handle to the bitmap
|
||||
int m_TransitionFrameCount; // Number of transition frames (per one frame) in the bitmap
|
||||
Gdiplus::Bitmap* m_Bitmap; // Handle to the bitmap
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
METER_ALIGNMENT m_Align; // Alignment of the bitmaps
|
||||
bool m_Extend; // If true, bitmaps extend horizontally and are used like numbers
|
||||
int m_Separation;
|
||||
int m_Digits;
|
||||
double m_Value;
|
||||
|
||||
DWORD m_TransitionStartTicks;
|
||||
double m_TransitionStartValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -200,7 +200,7 @@ void CMeterString::ReadConfig(const WCHAR* section)
|
||||
m_FontSize = parser.ReadInt(section, L"FontSize", 10);
|
||||
m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1);
|
||||
|
||||
m_Angle = parser.ReadFloat(section, L"Angle", 0.0f);
|
||||
m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0);
|
||||
|
||||
std::wstring scale;
|
||||
scale = parser.ReadString(section, L"Scale", L"1");
|
||||
@ -413,9 +413,9 @@ bool CMeterString::DrawString(RectF* rect)
|
||||
}
|
||||
|
||||
REAL angle = m_Angle * 180.0f / 3.14159265f; // Convert to degrees
|
||||
graphics.TranslateTransform(CMeter::GetX(), y);
|
||||
graphics.TranslateTransform((Gdiplus::REAL)CMeter::GetX(), y);
|
||||
graphics.RotateTransform(angle);
|
||||
graphics.TranslateTransform(-CMeter::GetX(), -y);
|
||||
graphics.TranslateTransform(-(Gdiplus::REAL)CMeter::GetX(), -y);
|
||||
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rc, &stringFormat, &solidBrush);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ using namespace Gdiplus;
|
||||
#define METERTIMER 1
|
||||
#define MOUSETIMER 2
|
||||
#define FADETIMER 3
|
||||
#define TRANSITIONTIMER 4
|
||||
|
||||
#define SNAPDISTANCE 10
|
||||
|
||||
@ -91,6 +92,8 @@ CMeterWindow::CMeterWindow(std::wstring& config, std::wstring& iniFile)
|
||||
m_WindowZPosition = ZPOSITION_NORMAL;
|
||||
m_WindowDraggable = true;
|
||||
m_WindowUpdate = 1000;
|
||||
m_TransitionUpdate = 100;
|
||||
m_ActiveTransition = false;
|
||||
m_WindowHide = HIDEMODE_NONE;
|
||||
m_WindowStartHidden = false;
|
||||
m_SnapEdges = true;
|
||||
@ -1341,6 +1344,7 @@ void CMeterWindow::ReadSkin()
|
||||
m_OnRefreshAction = m_Parser.ReadString(L"Rainmeter", L"OnRefreshAction", L"");
|
||||
|
||||
m_WindowUpdate = m_Parser.ReadInt(L"Rainmeter", L"Update", m_WindowUpdate);
|
||||
m_TransitionUpdate = m_Parser.ReadInt(L"Rainmeter", L"TransitionUpdate", m_TransitionUpdate);
|
||||
|
||||
// Create the meters and measures
|
||||
|
||||
@ -1830,6 +1834,28 @@ void CMeterWindow::Update(bool nodraw)
|
||||
Redraw();
|
||||
}
|
||||
|
||||
// Check for transitions and start the timer if necessary
|
||||
bool bActiveTransition = false;
|
||||
j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); j++)
|
||||
{
|
||||
if ((*j)->HasActiveTransition())
|
||||
{
|
||||
bActiveTransition = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Start/stop the transition timer if necessary
|
||||
if (!m_ActiveTransition && bActiveTransition)
|
||||
{
|
||||
SetTimer(m_Window, TRANSITIONTIMER, m_TransitionUpdate, NULL);
|
||||
}
|
||||
else if (m_ActiveTransition && !bActiveTransition)
|
||||
{
|
||||
KillTimer(m_Window, TRANSITIONTIMER);
|
||||
}
|
||||
|
||||
// if (m_MeasuresToVariables) // BUG: LSSetVariable doens't seem to work for some reason.
|
||||
// {
|
||||
// std::list<CMeasure*>::iterator i = m_Measures.begin();
|
||||
@ -1940,6 +1966,25 @@ LRESULT CMeterWindow::OnTimer(WPARAM wParam, LPARAM lParam)
|
||||
// }
|
||||
//}
|
||||
}
|
||||
else if(wParam == TRANSITIONTIMER)
|
||||
{
|
||||
// Redraw only if there is active transition still going
|
||||
bool bActiveTransition = false;
|
||||
std::list<CMeter*>::iterator j = m_Meters.begin();
|
||||
for( ; j != m_Meters.end(); j++)
|
||||
{
|
||||
if ((*j)->HasActiveTransition())
|
||||
{
|
||||
bActiveTransition = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (bActiveTransition)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
}
|
||||
else if(wParam == MOUSETIMER)
|
||||
{
|
||||
ShowWindowIfAppropriate();
|
||||
@ -2248,10 +2293,10 @@ LRESULT CMeterWindow::OnCommand(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if(wParam == ID_CONTEXT_SKINMENU_EDITSKIN)
|
||||
{
|
||||
std::wstring command = m_Rainmeter->GetConfigEditor();
|
||||
std::wstring command = Rainmeter->GetConfigEditor();
|
||||
command += L" \"";
|
||||
command += m_Rainmeter->GetSkinPath() + L"\\" + m_SkinName + L"\\" + m_SkinIniFile + L"\"";
|
||||
m_Rainmeter->ExecuteCommand(command.c_str(), this);
|
||||
LSExecuteAsAdmin(NULL, command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SKINMENU_REFRESH)
|
||||
{
|
||||
@ -2612,7 +2657,7 @@ LRESULT CMeterWindow::OnLeftButtonUp(WPARAM wParam, LPARAM lParam)
|
||||
pos.x = (SHORT)LOWORD(lParam);
|
||||
pos.y = (SHORT)HIWORD(lParam);
|
||||
m_Dragging = false;
|
||||
OutputDebugString(_T("Left up\n"));
|
||||
// OutputDebugString(_T("Left up\n"));
|
||||
if (m_Message == WM_NCLBUTTONUP)
|
||||
{
|
||||
// Transform the point to client rect
|
||||
@ -2907,6 +2952,7 @@ LRESULT CMeterWindow::OnMove(WPARAM wParam, LPARAM lParam)
|
||||
// Store the new window position
|
||||
m_ScreenX = (SHORT)LOWORD(lParam);
|
||||
m_ScreenY = (SHORT)HIWORD(lParam);
|
||||
/*
|
||||
if(m_Dragging)
|
||||
{
|
||||
OutputDebugString (_T("OnMove Dragging\n"));
|
||||
@ -2915,7 +2961,7 @@ LRESULT CMeterWindow::OnMove(WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
OutputDebugString(_T("OnMove No Dragging\n"));
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if (m_SavePosition && m_Dragging)
|
||||
{
|
||||
|
@ -171,6 +171,7 @@ public:
|
||||
HIDEMODE GetWindowHide() { return m_WindowHide; }
|
||||
int GetAlphaValue() { return m_AlphaValue; }
|
||||
int GetUpdateCounter() { return m_UpdateCounter; }
|
||||
int GetTransitionUpdate() { return m_TransitionUpdate; }
|
||||
|
||||
void AddMeasureBang(const WCHAR* bang, int index, CMeasure* measure);
|
||||
|
||||
@ -268,6 +269,8 @@ private:
|
||||
static MULTIMONITOR_INFO m_Monitors; // Multi-Monitor info
|
||||
bool m_WindowDraggable; // True, if window can be moved
|
||||
int m_WindowUpdate; // Measure update frequency
|
||||
int m_TransitionUpdate; // Transition redraw frequency
|
||||
bool m_ActiveTransition;
|
||||
HIDEMODE m_WindowHide; // If true, the window is hidden when mouse is over it
|
||||
bool m_WindowStartHidden; // If true, the window is hidden at startup
|
||||
bool m_SavePosition; // If true, the window's position is saved
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <time.h>
|
||||
#include <commctrl.h>
|
||||
#include <gdiplus.h>
|
||||
#include <fstream>
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
@ -673,6 +674,37 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
m_IniFile = m_Path + L"Rainmeter.ini";
|
||||
m_SkinPath = m_Path + L"Skins\\";
|
||||
|
||||
// If the ini file doesn't exist in the program folder store it to the %APPDATA% instead so that things work better in Vista/Win7
|
||||
if (_waccess(m_IniFile.c_str(), 0) == -1)
|
||||
{
|
||||
WCHAR buffer[4096]; // lets hope the buffer is large enough...
|
||||
|
||||
// Expand the environment variables
|
||||
DWORD ret = ExpandEnvironmentStrings(L"%APPDATA%\\Rainmeter\\rainmeter.ini", buffer, 4096);
|
||||
if (ret != 0 && ret < 4096)
|
||||
{
|
||||
m_IniFile = buffer;
|
||||
|
||||
// If the ini file doesn't exist in the %APPDATA% either, create a default rainmeter.ini file.
|
||||
if (_waccess(m_IniFile.c_str(), 0) == -1)
|
||||
{
|
||||
CreateDefaultConfigFile(m_IniFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the log file location
|
||||
m_LogFile = m_IniFile;
|
||||
size_t posExt = m_LogFile.find(L".ini");
|
||||
if (posExt != std::wstring::npos)
|
||||
{
|
||||
m_LogFile.replace(posExt, 4, L".log");
|
||||
}
|
||||
else
|
||||
{
|
||||
m_LogFile += L".log"; // Append the extension so that we don't accidentally overwrite the ini file
|
||||
}
|
||||
|
||||
if (!c_DummyLitestep)
|
||||
{
|
||||
char tmpSz[MAX_LINE_LENGTH];
|
||||
@ -774,6 +806,30 @@ int CRainmeter::Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath)
|
||||
return Result; // Alles OK
|
||||
}
|
||||
|
||||
/*
|
||||
** CreateDefaultConfigFile
|
||||
**
|
||||
** Creates the default Rainmeter.ini file. The CPU tray meter and Tranquil/System-C config
|
||||
** are enabled.
|
||||
**
|
||||
*/
|
||||
void CRainmeter::CreateDefaultConfigFile(std::wstring strFile)
|
||||
{
|
||||
size_t pos = strFile.find_last_of(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::wstring strPath(strFile.begin(), strFile.begin() + pos);
|
||||
CreateDirectory(strPath.c_str(), NULL);
|
||||
}
|
||||
|
||||
std::ofstream out(strFile.c_str(), std::ios::out);
|
||||
if (out)
|
||||
{
|
||||
out << std::string("[Rainmeter]\n\n[TrayMeasure]\nMeasure=CPU\n\n[Tranquil\\System]\nActive=1\n");
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
void CRainmeter::ReloadSettings()
|
||||
{
|
||||
ScanForConfigs(m_SkinPath);
|
||||
|
@ -116,6 +116,7 @@ public:
|
||||
|
||||
const std::wstring& GetPath() { return m_Path; };
|
||||
const std::wstring& GetIniFile() { return m_IniFile; };
|
||||
const std::wstring& GetLogFile() { return m_LogFile; };
|
||||
const std::wstring& GetSkinPath() { return m_SkinPath; };
|
||||
const std::wstring& GetPluginPath() { return m_PluginPath; };
|
||||
|
||||
@ -168,6 +169,7 @@ private:
|
||||
void ChangeSkinIndex(HMENU subMenu, int index);
|
||||
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu);
|
||||
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
|
||||
void CreateDefaultConfigFile(std::wstring strFile);
|
||||
|
||||
CTrayWindow* m_TrayWindow;
|
||||
|
||||
@ -177,6 +179,7 @@ private:
|
||||
|
||||
std::wstring m_Path; // Path to the main folder
|
||||
std::wstring m_IniFile; // The main ini file
|
||||
std::wstring m_LogFile; // The log file
|
||||
std::wstring m_SkinPath; // Path to the folder where the skins are
|
||||
std::wstring m_PluginPath; // Path to the folder where the plugins are
|
||||
|
||||
|
@ -424,8 +424,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
else if(wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
{
|
||||
// Check if the file exists
|
||||
std::wstring log = Rainmeter->GetPath();
|
||||
log += L"Rainmeter.log";
|
||||
std::wstring log = Rainmeter->GetLogFile();
|
||||
if (_waccess(log.c_str(), 0) != -1)
|
||||
{
|
||||
std::wstring command = L"Notepad.exe ";
|
||||
|
Reference in New Issue
Block a user