mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-06 22:46:06 +02:00
Use image cache from chromium
This commit is contained in:
@@ -210,22 +210,10 @@ namespace VRCX
|
|||||||
return CpuMonitor.Instance.CpuUsage;
|
return CpuMonitor.Instance.CpuUsage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CacheImage(string ImageURL, string AppVersion)
|
public void CacheImage(string Base64File)
|
||||||
{
|
{
|
||||||
String Icon = Path.Combine(Program.BaseDirectory, "cache\\toast");
|
String Icon = Path.Combine(Program.BaseDirectory, "cache\\toast");
|
||||||
try
|
File.WriteAllBytes(Icon, Convert.FromBase64String(Base64File));
|
||||||
{
|
|
||||||
using (var client = new WebClient())
|
|
||||||
{
|
|
||||||
client.Headers.Add("user-agent", AppVersion);
|
|
||||||
client.DownloadFile(ImageURL, Icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (WebException)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DesktopNotification(string BoldText, string Text, bool Image)
|
public void DesktopNotification(string BoldText, string Text, bool Image)
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -41,7 +41,7 @@ namespace VRCX
|
|||||||
cefSettings.CefCommandLineArgs.Add("disable-extensions");
|
cefSettings.CefCommandLineArgs.Add("disable-extensions");
|
||||||
cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
|
cefSettings.CefCommandLineArgs["autoplay-policy"] = "no-user-gesture-required";
|
||||||
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
|
// cefSettings.CefCommandLineArgs.Add("allow-universal-access-from-files");
|
||||||
// cefSettings.CefCommandLineArgs.Add("disable-web-security");
|
cefSettings.CefCommandLineArgs.Add("disable-web-security");
|
||||||
cefSettings.SetOffScreenRenderingBestPerformanceArgs();
|
cefSettings.SetOffScreenRenderingBestPerformanceArgs();
|
||||||
|
|
||||||
CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO
|
CefSharpSettings.WcfEnabled = true; // TOOD: REMOVE THIS LINE YO
|
||||||
|
|||||||
+24
-1
@@ -4318,7 +4318,30 @@ speechSynthesis.getVoices();
|
|||||||
((this.desktopToast === 'Game Closed') && (!this.isGameRunning)) ||
|
((this.desktopToast === 'Game Closed') && (!this.isGameRunning)) ||
|
||||||
((this.desktopToast === 'Desktop Mode') && (this.isGameNoVR) && (this.isGameRunning))) ||
|
((this.desktopToast === 'Desktop Mode') && (this.isGameNoVR) && (this.isGameRunning))) ||
|
||||||
((this.xsNotifications) && (this.isGameRunning) && (!this.isGameNoVR)))) {
|
((this.xsNotifications) && (this.isGameRunning) && (!this.isGameNoVR)))) {
|
||||||
var image = await AppApi.CacheImage(imageURL, appVersion);
|
try {
|
||||||
|
await fetch(imageURL, {
|
||||||
|
method: 'GET',
|
||||||
|
redirect: 'follow',
|
||||||
|
headers: {
|
||||||
|
'User-Agent': appVersion
|
||||||
|
}
|
||||||
|
}).then(response => {
|
||||||
|
return response.arrayBuffer();
|
||||||
|
}).then(buffer => {
|
||||||
|
var binary = '';
|
||||||
|
var bytes = new Uint8Array(buffer);
|
||||||
|
var length = bytes.byteLength;
|
||||||
|
for (var i = 0; i < length; i++) {
|
||||||
|
binary += String.fromCharCode(bytes[i]);
|
||||||
|
}
|
||||||
|
var imageData = btoa(binary);
|
||||||
|
AppApi.CacheImage(imageData);
|
||||||
|
});
|
||||||
|
image = true;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
image = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((this.xsNotifications) && (this.isGameRunning) && (!this.isGameNoVR)) {
|
if ((this.xsNotifications) && (this.isGameRunning) && (!this.isGameNoVR)) {
|
||||||
this.displayXSNotification(noty, message, image);
|
this.displayXSNotification(noty, message, image);
|
||||||
|
|||||||
Reference in New Issue
Block a user