mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-27 17:00:59 +01:00
Weather: Display last time of update in Properties
This commit is contained in:
parent
c195120d9d
commit
ff72f31b9b
@ -6,6 +6,7 @@ DEFINE_GUID(LiveSetting_Property_GUID, 0xc12bcd8e, 0x2a8e, 0x4950, 0x8a, 0xe7, 0
|
||||
TCHAR GUI_title[260];
|
||||
FILE* AuditFile = NULL;
|
||||
LANGID locale;
|
||||
WCHAR wszLanguage[MAX_PATH];
|
||||
void* GUI_FileMapping = NULL;
|
||||
DWORD GUI_FileSize = 0;
|
||||
BOOL g_darkModeEnabled = FALSE;
|
||||
@ -1030,6 +1031,7 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
wchar_t* lastHeading = calloc(MAX_LINE_LENGTH, sizeof(wchar_t));
|
||||
while ((numChRd = getline(&line, &bufsiz, f)) != -1)
|
||||
{
|
||||
hOldFont = NULL;
|
||||
if (currentSection == _this->section)
|
||||
{
|
||||
bWasSpecifiedSectionValid = TRUE;
|
||||
@ -1236,6 +1238,42 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
text,
|
||||
MAX_LINE_LENGTH
|
||||
);
|
||||
if (!wcsncmp(text, L"%WEATHERLASTUPDATETEXT%", 23))
|
||||
{
|
||||
BOOL bOk = FALSE;
|
||||
DWORD bIsWeatherEnabled = 0, dwSize = sizeof(DWORD);
|
||||
GUI_Internal_RegQueryValueExW(NULL, L"Virtualized_" _T(EP_CLSID) L"_PeopleBand", NULL, NULL, &bIsWeatherEnabled, &dwSize);
|
||||
if (bIsWeatherEnabled)
|
||||
{
|
||||
IEPWeather* epw = NULL;
|
||||
if (SUCCEEDED(CoCreateInstance(&CLSID_EPWeather, NULL, CLSCTX_LOCAL_SERVER, &IID_IEPWeather, &epw)) && epw)
|
||||
{
|
||||
SYSTEMTIME stLastUpdate;
|
||||
ZeroMemory(&stLastUpdate, sizeof(SYSTEMTIME));
|
||||
if (SUCCEEDED(epw->lpVtbl->GetLastUpdateTime(epw, &stLastUpdate)))
|
||||
{
|
||||
WCHAR wszWeatherLanguage[10];
|
||||
ZeroMemory(wszWeatherLanguage, 10);
|
||||
dwSize = sizeof(WCHAR) * 10;
|
||||
RegGetValueW(HKEY_CURRENT_USER, _T(REGPATH), L"WeatherLanguage", RRF_RT_REG_SZ, NULL, wszWeatherLanguage, &dwSize);
|
||||
WCHAR wszDate[MAX_PATH];
|
||||
ZeroMemory(wszDate, sizeof(WCHAR) * MAX_PATH);
|
||||
if (GetDateFormatEx(wszWeatherLanguage[0] ? wszWeatherLanguage : wszLanguage, DATE_AUTOLAYOUT | DATE_LONGDATE, &stLastUpdate, NULL, wszDate, MAX_PATH, NULL))
|
||||
{
|
||||
WCHAR wszTime[MAX_PATH];
|
||||
ZeroMemory(wszTime, sizeof(WCHAR) * MAX_PATH);
|
||||
if (GetTimeFormatEx(wszWeatherLanguage[0] ? wszWeatherLanguage : wszLanguage, TIME_NOSECONDS, &stLastUpdate, NULL, wszTime, MAX_PATH))
|
||||
{
|
||||
bOk = TRUE;
|
||||
swprintf_s(text, MAX_LINE_LENGTH, L"Last updated on: %s, %s.", wszDate, wszTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
epw->lpVtbl->Release(epw);
|
||||
}
|
||||
}
|
||||
if (!bOk) continue;
|
||||
}
|
||||
if (bResetLastHeading)
|
||||
{
|
||||
wcscpy_s(lastHeading, MAX_LINE_LENGTH, text);
|
||||
@ -3087,6 +3125,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
tabOrder++;
|
||||
}
|
||||
}
|
||||
if (hOldFont)
|
||||
{
|
||||
SelectObject(hdcPaint, hOldFont);
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
free(section);
|
||||
@ -3102,7 +3144,6 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
}
|
||||
|
||||
SelectObject(hdcPaint, hOldFont);
|
||||
if (!hDC)
|
||||
{
|
||||
ReleaseDC(hwnd, hdcPaint);
|
||||
@ -3822,6 +3863,26 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
|
||||
&dwSize
|
||||
);
|
||||
}
|
||||
BOOL bOk = FALSE;
|
||||
ULONG ulNumLanguages = 0;
|
||||
LPCWSTR wszLanguagesBuffer = NULL;
|
||||
ULONG cchLanguagesBuffer = 0;
|
||||
if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, NULL, &cchLanguagesBuffer))
|
||||
{
|
||||
if (wszLanguagesBuffer = malloc(cchLanguagesBuffer * sizeof(WCHAR)))
|
||||
{
|
||||
if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &ulNumLanguages, wszLanguagesBuffer, &cchLanguagesBuffer))
|
||||
{
|
||||
wcscpy_s(wszLanguage, MAX_PATH, wszLanguagesBuffer);
|
||||
bOk = TRUE;
|
||||
}
|
||||
free(wszLanguagesBuffer);
|
||||
}
|
||||
}
|
||||
if (!bOk)
|
||||
{
|
||||
wcscpy_s(wszLanguage, MAX_PATH, L"en-US");
|
||||
}
|
||||
|
||||
wchar_t wszPath[MAX_PATH];
|
||||
ZeroMemory(
|
||||
|
@ -25,6 +25,7 @@ processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
|
||||
#include "fmemopen.h"
|
||||
#include "utility.h"
|
||||
#include "../ep_weather_host/ep_weather.h"
|
||||
#include "../ep_weather_host/ep_weather_host_h.h"
|
||||
#include <ExDisp.h>
|
||||
#include <ShlGuid.h>
|
||||
|
||||
|
@ -497,9 +497,9 @@
|
||||
;x 500 500 %
|
||||
"WeatherZoomFactor"=dword:00000000
|
||||
;q
|
||||
;t Weather data courtesy of Google, and weather.com.
|
||||
;y Learn more about the Weather taskbar widget 🡕
|
||||
;https://github.com/valinet/ExplorerPatcher/wiki/Weather
|
||||
;t %WEATHERLASTUPDATETEXT%
|
||||
;u Update weather now
|
||||
;update_weather
|
||||
;u Clear weather widget local data
|
||||
|
@ -436,9 +436,9 @@
|
||||
;x 500 500 %
|
||||
"WeatherZoomFactor"=dword:00000000
|
||||
;q
|
||||
;t Weather data courtesy of Google, and weather.com.
|
||||
;y Learn more about the Weather taskbar widget 🡕
|
||||
;https://github.com/valinet/ExplorerPatcher/wiki/Weather
|
||||
;t %WEATHERLASTUPDATETEXT%
|
||||
;u Update weather now
|
||||
;update_weather
|
||||
;u Clear weather widget local data
|
||||
|
@ -8,6 +8,7 @@ DWORD32 global_ubr;
|
||||
EPWeather* EPWeather_Instance = NULL;
|
||||
SRWLOCK Lock_EPWeather_Instance = { .Ptr = SRWLOCK_INIT };
|
||||
FARPROC SHRegGetValueFromHKCUHKLMFunc;
|
||||
SYSTEMTIME stLastUpdate;
|
||||
|
||||
static DWORD epw_Weather_ReleaseBecauseClientDiedThread(EPWeather* _this)
|
||||
{
|
||||
@ -589,6 +590,9 @@ HRESULT STDMETHODCALLTYPE ICoreWebView2_ExecuteScriptCompleted(ICoreWebView2Exec
|
||||
}
|
||||
else
|
||||
{
|
||||
GetLocalTime(&stLastUpdate);
|
||||
HWND hGUI = FindWindowW(L"ExplorerPatcher_GUI_" _T(EP_CLSID), NULL);
|
||||
if (hGUI) InvalidateRect(hGUI, NULL, TRUE);
|
||||
InterlockedExchange64(&_this->bBrowserBusy, FALSE);
|
||||
printf("[General] Fetched data, requesting redraw.\n");
|
||||
SetTimer(_this->hWnd, EP_WEATHER_TIMER_REQUEST_REPAINT, EP_WEATHER_TIMER_REQUEST_REPAINT_DELAY, NULL);
|
||||
@ -1157,6 +1161,12 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetZoomFactor(EPWeather* _this, LONG64 dwZ
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_GetLastUpdateTime(EPWeather* _this, LPSYSTEMTIME lpLastUpdateTime)
|
||||
{
|
||||
*lpLastUpdateTime = stLastUpdate;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
DWORD WINAPI epw_Weather_MainThread(EPWeather* _this)
|
||||
{
|
||||
HRESULT hr = S_OK;
|
||||
|
@ -122,6 +122,7 @@ HRESULT STDMETHODCALLTYPE epw_Weather_SetWindowCornerPreference(EPWeather* _this
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetDevMode(EPWeather* _this, LONG64 dwDevMode, LONG64 bRefresh);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetIconPack(EPWeather* _this, LONG64 dwIconPack, LONG64 bRefresh);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_SetZoomFactor(EPWeather* _this, LONG64 dwZoomFactor);
|
||||
HRESULT STDMETHODCALLTYPE epw_Weather_GetLastUpdateTime(EPWeather* _this, LPSYSTEMTIME lpLastUpdateTime);
|
||||
|
||||
static const IEPWeatherVtbl IEPWeather_Vtbl = {
|
||||
.QueryInterface = epw_Weather_QueryInterface,
|
||||
@ -151,6 +152,7 @@ static const IEPWeatherVtbl IEPWeather_Vtbl = {
|
||||
.SetDevMode = epw_Weather_SetDevMode,
|
||||
.SetIconPack = epw_Weather_SetIconPack,
|
||||
.SetZoomFactor = epw_Weather_SetZoomFactor,
|
||||
.GetLastUpdateTime = epw_Weather_GetLastUpdateTime,
|
||||
};
|
||||
|
||||
static inline DWORD epw_Weather_GetTextScaleFactor(EPWeather* _this) { return InterlockedAdd64(&_this->dwTextScaleFactor, 0); }
|
||||
|
@ -85,4 +85,6 @@ import "unknwn.idl";
|
||||
HRESULT SetIconPack([in] LONG64 dwIconPack, [in] LONG64 bRefresh);
|
||||
|
||||
HRESULT SetZoomFactor([in] LONG64 dwZoomFactor);
|
||||
|
||||
HRESULT GetLastUpdateTime([out] LPSYSTEMTIME lpLastUpdateTime);
|
||||
};
|
Loading…
Reference in New Issue
Block a user