mirror of
https://github.com/Zaarrg/stremio-community-v5.git
synced 2026-04-21 17:11:55 +00:00
Stylus addon support, Fixed tray menu dpi, Fix drag and drop subs no delay option
- Fixed tray menu not scaling with DPI - Added Stylus addon support + Handle for HandleStylusUsoInstall (Installing from uso archives) - Fixed drag and dropped subtitles not being handled as "ExternalEmbedded" preventing delay setting - Added zips of unpacked extensions for use in app.
This commit is contained in:
parent
aa03891ed4
commit
76d4355cd4
11 changed files with 76 additions and 8 deletions
|
|
@ -72,6 +72,7 @@ bool g_allowZoom = false;
|
||||||
int g_tray_itemH = 31;
|
int g_tray_itemH = 31;
|
||||||
int g_tray_sepH = 8;
|
int g_tray_sepH = 8;
|
||||||
int g_tray_w = 200;
|
int g_tray_w = 200;
|
||||||
|
int g_font_height = 12;
|
||||||
|
|
||||||
// Splash
|
// Splash
|
||||||
HWND g_hSplash = nullptr;
|
HWND g_hSplash = nullptr;
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,7 @@ extern bool g_allowZoom;
|
||||||
extern int g_tray_itemH;
|
extern int g_tray_itemH;
|
||||||
extern int g_tray_sepH;
|
extern int g_tray_sepH;
|
||||||
extern int g_tray_w;
|
extern int g_tray_w;
|
||||||
|
extern int g_font_height;
|
||||||
|
|
||||||
// Splash
|
// Splash
|
||||||
extern HWND g_hSplash;
|
extern HWND g_hSplash;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,6 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
// Load config
|
// Load config
|
||||||
LoadSettings();
|
LoadSettings();
|
||||||
LoadCustomMenuFont();
|
|
||||||
|
|
||||||
// Updater
|
// Updater
|
||||||
g_updaterThread=std::thread(RunAutoUpdaterOnce);
|
g_updaterThread=std::thread(RunAutoUpdaterOnce);
|
||||||
|
|
@ -117,6 +116,11 @@ int main(int argc, char* argv[])
|
||||||
AppendToCrashLog(L"[BOOT]: CreateWindow failed!");
|
AppendToCrashLog(L"[BOOT]: CreateWindow failed!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Scale Values with DPI
|
||||||
|
ScaleWithDPI();
|
||||||
|
LoadCustomMenuFont();
|
||||||
|
|
||||||
// Load Saved position
|
// Load Saved position
|
||||||
WINDOWPLACEMENT wp;
|
WINDOWPLACEMENT wp;
|
||||||
if (LoadWindowPlacement(wp)) {
|
if (LoadWindowPlacement(wp)) {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ void LoadCustomMenuFont()
|
||||||
g_hMenuFont = nullptr;
|
g_hMenuFont = nullptr;
|
||||||
}
|
}
|
||||||
LOGFONTW lf = { 0 };
|
LOGFONTW lf = { 0 };
|
||||||
lf.lfHeight = -12;
|
lf.lfHeight = -g_font_height;
|
||||||
lf.lfWeight = FW_MEDIUM;
|
lf.lfWeight = FW_MEDIUM;
|
||||||
wcscpy_s(lf.lfFaceName, L"Arial Rounded MT");
|
wcscpy_s(lf.lfFaceName, L"Arial Rounded MT");
|
||||||
lf.lfQuality = CLEARTYPE_QUALITY;
|
lf.lfQuality = CLEARTYPE_QUALITY;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,13 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../core/globals.h"
|
#include "../core/globals.h"
|
||||||
|
|
||||||
void HandlePremidLogin(const std::wstring& finalUri) {
|
bool HandleExtensions(const std::wstring& finalUri) {
|
||||||
|
bool handledPremid = HandlePremidLogin(finalUri);
|
||||||
|
bool handledStylus = HandleStylusUsoInstall(finalUri);
|
||||||
|
return handledPremid || handledStylus;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HandlePremidLogin(const std::wstring& finalUri) {
|
||||||
if (finalUri.rfind(L"https://login.premid.app", 0) == 0 && finalUri.rfind(L"https://discord.com", 0) != 0) {
|
if (finalUri.rfind(L"https://login.premid.app", 0) == 0 && finalUri.rfind(L"https://discord.com", 0) != 0) {
|
||||||
std::wstring extensionId;
|
std::wstring extensionId;
|
||||||
auto it = std::find_if(g_extensionMap.begin(), g_extensionMap.end(),
|
auto it = std::find_if(g_extensionMap.begin(), g_extensionMap.end(),
|
||||||
|
|
@ -16,7 +22,7 @@ void HandlePremidLogin(const std::wstring& finalUri) {
|
||||||
} else {
|
} else {
|
||||||
std::wcout << L"[EXTENSIONS]: Extension id not found\n";
|
std::wcout << L"[EXTENSIONS]: Extension id not found\n";
|
||||||
g_webview->Navigate(g_webuiUrl.c_str());
|
g_webview->Navigate(g_webuiUrl.c_str());
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wstring codeParam;
|
std::wstring codeParam;
|
||||||
|
|
@ -35,5 +41,28 @@ void HandlePremidLogin(const std::wstring& finalUri) {
|
||||||
|
|
||||||
std::wstring uri = L"chrome-extension://" + extensionId + L"/popup.html";
|
std::wstring uri = L"chrome-extension://" + extensionId + L"/popup.html";
|
||||||
g_webview->Navigate(uri.c_str());
|
g_webview->Navigate(uri.c_str());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool HandleStylusUsoInstall(const std::wstring& finalUri) {
|
||||||
|
if (finalUri.rfind(L"https://raw.githubusercontent.com/uso-archive", 0) == 0) {
|
||||||
|
std::wstring extensionId;
|
||||||
|
auto it = std::find_if(g_extensionMap.begin(), g_extensionMap.end(),
|
||||||
|
[](const std::pair<std::wstring, std::wstring>& p) -> bool {
|
||||||
|
return p.first.find(L"stylus") != std::wstring::npos;
|
||||||
|
});
|
||||||
|
if (it != g_extensionMap.end()) {
|
||||||
|
extensionId = it->second;
|
||||||
|
} else {
|
||||||
|
std::wcout << L"[EXTENSIONS]: Extension id not found\n";
|
||||||
|
g_webview->Navigate(g_webuiUrl.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
std::wstring uri = L"chrome-extension://" + extensionId + L"/install-usercss.html?updateUrl=" + finalUri;
|
||||||
|
g_webview->Navigate(uri.c_str());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
void HandlePremidLogin(const std::wstring& finalUri);
|
bool HandleExtensions(const std::wstring& finalUri);
|
||||||
|
bool HandlePremidLogin(const std::wstring& finalUri);
|
||||||
|
bool HandleStylusUsoInstall(const std::wstring& finalUri);
|
||||||
|
|
||||||
#endif //EXTENSIONS_H
|
#endif //EXTENSIONS_H
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <shellscalingapi.h>
|
||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
|
#include <VersionHelpers.h>
|
||||||
#include <winhttp.h>
|
#include <winhttp.h>
|
||||||
#include "../core/globals.h"
|
#include "../core/globals.h"
|
||||||
|
|
||||||
|
|
@ -285,3 +287,31 @@ bool FetchAndParseWhitelist() {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScaleWithDPI() {
|
||||||
|
if (!g_hWnd) return;
|
||||||
|
UINT dpi = 96;
|
||||||
|
HMONITOR hMonitor = MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY);
|
||||||
|
HRESULT hr = GetDpiForMonitor(hMonitor, MDT_EFFECTIVE_DPI, &dpi, nullptr);
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
// Fall back to using g_hWnd's DPI if GetDpiForMonitor is unavailable
|
||||||
|
if (IsWindowsVersionOrGreater(10, 0, 1607))
|
||||||
|
{
|
||||||
|
dpi = GetDpiForWindow(g_hWnd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
HDC hdc = GetDC(g_hWnd);
|
||||||
|
dpi = GetDeviceCaps(hdc, LOGPIXELSX);
|
||||||
|
ReleaseDC(g_hWnd, hdc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Lambda to scale a value based on current DPI
|
||||||
|
auto ScaleValue = [dpi](int value) -> int {
|
||||||
|
return MulDiv(value, dpi, 96);
|
||||||
|
};
|
||||||
|
g_tray_itemH = ScaleValue(g_tray_itemH);
|
||||||
|
g_tray_sepH = ScaleValue(g_tray_sepH);
|
||||||
|
g_tray_w = ScaleValue(g_tray_w);
|
||||||
|
g_font_height = ScaleValue(g_font_height);
|
||||||
|
}
|
||||||
|
|
@ -17,5 +17,6 @@ bool IsDuplicateProcessRunning(const std::vector<std::wstring>& targetProcesses)
|
||||||
bool isSubtitle(const std::wstring& filePath);
|
bool isSubtitle(const std::wstring& filePath);
|
||||||
bool URLContainsAny(const std::wstring& url);
|
bool URLContainsAny(const std::wstring& url);
|
||||||
bool FetchAndParseWhitelist();
|
bool FetchAndParseWhitelist();
|
||||||
|
void ScaleWithDPI();
|
||||||
|
|
||||||
#endif // HELPERS_H
|
#endif // HELPERS_H
|
||||||
|
|
|
||||||
|
|
@ -353,7 +353,7 @@ static void SetupWebMessageHandler()
|
||||||
if(g_hSplash && !g_waitStarted.exchange(true)) {
|
if(g_hSplash && !g_waitStarted.exchange(true)) {
|
||||||
WaitAndRefreshIfNeeded();
|
WaitAndRefreshIfNeeded();
|
||||||
}
|
}
|
||||||
HandlePremidLogin(finalUri);
|
HandleExtensions(finalUri);
|
||||||
}
|
}
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}).Get(),
|
}).Get(),
|
||||||
|
|
@ -506,9 +506,9 @@ static void SetupWebMessageHandler()
|
||||||
{
|
{
|
||||||
std::wstring filePath = wuri.substr(8);
|
std::wstring filePath = wuri.substr(8);
|
||||||
std::string utf8FilePath = WStringToUtf8(filePath);
|
std::string utf8FilePath = WStringToUtf8(filePath);
|
||||||
|
std::string baseName = std::filesystem::path(utf8FilePath).filename().string();
|
||||||
if (isSubtitle(filePath)) {
|
if (isSubtitle(filePath)) {
|
||||||
std::vector<std::string> subaddArgs = {"sub-add",utf8FilePath};
|
std::vector<std::string> subaddArgs = {"sub-add",utf8FilePath, "select", baseName + " External", "Other Tracks"};
|
||||||
HandleEvent("mpv-command", subaddArgs);
|
HandleEvent("mpv-command", subaddArgs);
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
utils/stremio/extensions/stylus_2.3.10_0.7z
Normal file
BIN
utils/stremio/extensions/stylus_2.3.10_0.7z
Normal file
Binary file not shown.
BIN
utils/stremio/extensions/ublock_1.62.0_0.7z
Normal file
BIN
utils/stremio/extensions/ublock_1.62.0_0.7z
Normal file
Binary file not shown.
Loading…
Reference in a new issue