mirror of
				https://github.com/chibicitiberiu/rainmeter-studio.git
				synced 2024-02-24 04:33:31 +00:00 
			
		
		
		
	Formula now can be used with the relative position (r/R) in Meter's X/Y option.
Added built-in variable #PROGRAMDRIVE# Changed Net measures to gather statistics of the logical interfaces for wireless devices.
This commit is contained in:
		@@ -99,6 +99,30 @@ void CConfigParser::SetDefaultVariables(CRainmeter* pRainmeter, CMeterWindow* me
 | 
			
		||||
	if (pRainmeter)
 | 
			
		||||
	{
 | 
			
		||||
		SetVariable(L"PROGRAMPATH", pRainmeter->GetPath());
 | 
			
		||||
 | 
			
		||||
		// Extract volume path from program path
 | 
			
		||||
		// E.g.:
 | 
			
		||||
		//  "C:\path\" to "C:"
 | 
			
		||||
		//  "\\server\share\" to "\\server\share"
 | 
			
		||||
		//  "\\server\C:\path\" to "\\server\C:"
 | 
			
		||||
		const std::wstring& path = pRainmeter->GetPath();
 | 
			
		||||
		std::wstring::size_type loc, loc2;
 | 
			
		||||
		if ((loc = path.find_first_of(L':')) != std::wstring::npos)
 | 
			
		||||
		{
 | 
			
		||||
			SetVariable(L"PROGRAMDRIVE", path.substr(0, loc + 1));
 | 
			
		||||
		}
 | 
			
		||||
		else if (path.length() >= 2 && (path[0] == L'\\' || path[0] == L'/') && (path[1] == L'\\' || path[1] == L'/'))
 | 
			
		||||
		{
 | 
			
		||||
			if ((loc = path.find_first_of(L"\\/", 2)) != std::wstring::npos)
 | 
			
		||||
			{
 | 
			
		||||
				if ((loc2 = path.find_first_of(L"\\/", loc + 1)) != std::wstring::npos || loc != (path.length() - 1))
 | 
			
		||||
				{
 | 
			
		||||
					loc = loc2;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			SetVariable(L"PROGRAMDRIVE", path.substr(0, loc));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		SetVariable(L"SETTINGSPATH", pRainmeter->GetSettingsPath());
 | 
			
		||||
		SetVariable(L"SKINSPATH", pRainmeter->GetSkinPath());
 | 
			
		||||
		SetVariable(L"PLUGINSPATH", pRainmeter->GetPluginPath());
 | 
			
		||||
@@ -614,7 +638,7 @@ double CConfigParser::ReadFormula(LPCTSTR section, LPCTSTR key, double defValue)
 | 
			
		||||
 | 
			
		||||
// Returns an int if the formula was read successfully, -1 for failure.
 | 
			
		||||
// Pass a pointer to a double.
 | 
			
		||||
int CConfigParser::ReadFormula(std::wstring& result, double* resultValue)
 | 
			
		||||
int CConfigParser::ReadFormula(const std::wstring& result, double* resultValue)
 | 
			
		||||
{
 | 
			
		||||
	// Formulas must be surrounded by parenthesis
 | 
			
		||||
	if (!result.empty() && result[0] == L'(' && result[result.size() - 1] == L')')
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ public:
 | 
			
		||||
	const std::vector<std::wstring>& GetSections();
 | 
			
		||||
 | 
			
		||||
	// Returns an int if the formula was read successfully, -1 for failure.
 | 
			
		||||
	int ReadFormula(std::wstring& result, double* number);
 | 
			
		||||
	int ReadFormula(const std::wstring& result, double* number);
 | 
			
		||||
 | 
			
		||||
	static std::vector<std::wstring> Tokenize(const std::wstring& str, const std::wstring delimiters);
 | 
			
		||||
	static double ParseDouble(const std::wstring& string, double defValue, bool rejectExp = false);
 | 
			
		||||
 
 | 
			
		||||
@@ -101,7 +101,7 @@ void CMeasureNet::UpdateIFTable()
 | 
			
		||||
			c_Table = NULL;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (c_GetIfTable2Ex(MibIfTableRaw, (MIB_IF_TABLE2**)&c_Table) == NO_ERROR)
 | 
			
		||||
		if (c_GetIfTable2Ex(MibIfTableNormal, (MIB_IF_TABLE2**)&c_Table) == NO_ERROR)
 | 
			
		||||
		{
 | 
			
		||||
			MIB_IF_TABLE2* ifTable = (MIB_IF_TABLE2*)c_Table;
 | 
			
		||||
 | 
			
		||||
@@ -279,9 +279,9 @@ ULONG64 CMeasureNet::GetNetOctets(NET net)
 | 
			
		||||
			// Get all interfaces
 | 
			
		||||
			for (UINT i = 0; i < c_NumOfTables; ++i)
 | 
			
		||||
			{
 | 
			
		||||
				// Ignore the loopback and non-hardware interfaces
 | 
			
		||||
				// Ignore the loopback and filter interfaces
 | 
			
		||||
				if (table[i].Type == IF_TYPE_SOFTWARE_LOOPBACK ||
 | 
			
		||||
					table[i].InterfaceAndOperStatusFlags.HardwareInterface == 0) continue;
 | 
			
		||||
					table[i].InterfaceAndOperStatusFlags.FilterInterface == 1) continue;
 | 
			
		||||
 | 
			
		||||
				switch (net)
 | 
			
		||||
				{
 | 
			
		||||
@@ -394,13 +394,13 @@ ULONG64 CMeasureNet::GetNetStatsValue(NET net)
 | 
			
		||||
		// Get all interfaces
 | 
			
		||||
		for(size_t i = 0; i < c_StatValues.size() / 2; ++i)
 | 
			
		||||
		{
 | 
			
		||||
			// Ignore the loopback and non-hardware interfaces
 | 
			
		||||
			// Ignore the loopback and filter interfaces
 | 
			
		||||
			if (c_NumOfTables == c_StatValues.size() / 2)
 | 
			
		||||
			{
 | 
			
		||||
				if (c_UseNewApi)
 | 
			
		||||
				{
 | 
			
		||||
					if (((MIB_IF_TABLE2*)c_Table)->Table[i].Type == IF_TYPE_SOFTWARE_LOOPBACK ||
 | 
			
		||||
						((MIB_IF_TABLE2*)c_Table)->Table[i].InterfaceAndOperStatusFlags.HardwareInterface == 0) continue;
 | 
			
		||||
						((MIB_IF_TABLE2*)c_Table)->Table[i].InterfaceAndOperStatusFlags.FilterInterface == 1) continue;
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
 
 | 
			
		||||
@@ -217,39 +217,55 @@ void CMeter::ReadConfig(const WCHAR* section)
 | 
			
		||||
	const std::wstring& style = parser.ReadString(section, L"MeterStyle", L"");
 | 
			
		||||
	parser.SetStyleTemplate(style);
 | 
			
		||||
 | 
			
		||||
	const std::wstring& x = parser.ReadString(section, L"X", L"0");
 | 
			
		||||
	if (x.size() > 0)
 | 
			
		||||
	std::wstring coord = parser.ReadString(section, L"X", L"0");
 | 
			
		||||
	if (coord.size() > 0)
 | 
			
		||||
	{
 | 
			
		||||
		m_X = _wtoi(x.c_str());
 | 
			
		||||
		if (x[x.size() - 1] == L'r')
 | 
			
		||||
		size_t len = coord.size();
 | 
			
		||||
		if (coord[len - 1] == L'r')
 | 
			
		||||
		{
 | 
			
		||||
			m_RelativeX = POSITION_RELATIVE_TL;
 | 
			
		||||
			coord.erase(--len);
 | 
			
		||||
		}
 | 
			
		||||
		else if (x[x.size() - 1] == L'R')
 | 
			
		||||
		else if (coord[len - 1] == L'R')
 | 
			
		||||
		{
 | 
			
		||||
			m_RelativeX = POSITION_RELATIVE_BR;
 | 
			
		||||
			coord.erase(--len);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		double val;
 | 
			
		||||
		if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && -1 != parser.ReadFormula(coord, &val))
 | 
			
		||||
		{
 | 
			
		||||
			m_X = (int)val;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			m_X = (int)parser.ReadFormula(section, L"X", 0.0);
 | 
			
		||||
			m_X = (int)parser.ParseDouble(coord, 0.0);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	const std::wstring& y = parser.ReadString(section, L"Y", L"0");
 | 
			
		||||
	if (y.size() > 0)
 | 
			
		||||
	coord = parser.ReadString(section, L"Y", L"0");
 | 
			
		||||
	if (coord.size() > 0)
 | 
			
		||||
	{
 | 
			
		||||
		m_Y = _wtoi(y.c_str());
 | 
			
		||||
		if (y[y.size() - 1] == L'r')
 | 
			
		||||
		size_t len = coord.size();
 | 
			
		||||
		if (coord[len - 1] == L'r')
 | 
			
		||||
		{
 | 
			
		||||
			m_RelativeY = POSITION_RELATIVE_TL;
 | 
			
		||||
			coord.erase(--len);
 | 
			
		||||
		}
 | 
			
		||||
		else if (y[y.size() - 1] == L'R')
 | 
			
		||||
		else if (coord[len - 1] == L'R')
 | 
			
		||||
		{
 | 
			
		||||
			m_RelativeY = POSITION_RELATIVE_BR;
 | 
			
		||||
			coord.erase(--len);
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		double val;
 | 
			
		||||
		if (len >= 2 && coord[0] == L'(' && coord[len - 1] == L')' && -1 != parser.ReadFormula(coord, &val))
 | 
			
		||||
		{
 | 
			
		||||
			m_Y = (int)val;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			m_Y = (int)parser.ReadFormula(section, L"Y", 0.0);
 | 
			
		||||
			m_Y = (int)parser.ParseDouble(coord, 0.0);;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user