mirror of
https://github.com/SteamDeckHomebrew/decky-loader.git
synced 2026-06-17 08:47:49 +00:00
Added store button
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from injector import get_tab
|
from injector import get_tab, inject_to_tab
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from os import path, rename
|
from os import path, rename
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
@@ -26,7 +26,8 @@ class PluginBrowser:
|
|||||||
|
|
||||||
server_instance.add_routes([
|
server_instance.add_routes([
|
||||||
web.post("/browser/install_plugin", self.install_plugin),
|
web.post("/browser/install_plugin", self.install_plugin),
|
||||||
web.get("/browser/iframe", self.redirect_to_store)
|
web.get("/browser/redirect", self.redirect_to_store),
|
||||||
|
web.post("/browser/close_store", self.close_store)
|
||||||
])
|
])
|
||||||
|
|
||||||
def _unzip_to_plugin_dir(self, zip, name, hash):
|
def _unzip_to_plugin_dir(self, zip, name, hash):
|
||||||
@@ -72,6 +73,10 @@ class PluginBrowser:
|
|||||||
async def redirect_to_store(self, request):
|
async def redirect_to_store(self, request):
|
||||||
return web.Response(status=302, headers={"Location": self.store_url})
|
return web.Response(status=302, headers={"Location": self.store_url})
|
||||||
|
|
||||||
|
async def close_store(self, request):
|
||||||
|
await inject_to_tab("SP", "window.PLUGIN_STORE_TAB_INSTANCE.SetVisible(false)")
|
||||||
|
await inject_to_tab("SP", "SteamClient.BrowserView.Destroy(window.PLUGIN_STORE_TAB_INSTANCE)")
|
||||||
|
|
||||||
async def install_plugin(self, request):
|
async def install_plugin(self, request):
|
||||||
data = await request.post()
|
data = await request.post()
|
||||||
get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"]))
|
get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"]))
|
||||||
|
|||||||
@@ -53,8 +53,22 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
|||||||
</svg>
|
</svg>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
const SHOP_ICON = `
|
||||||
|
<button
|
||||||
|
class="DialogButton _DialogLayout Secondary basicdialog_Button_1Ievp Focusable"
|
||||||
|
style="width: auto; padding-left: 10px; padding-right: 10px; margin-right: 1rem; margin-left: auto; padding-top: 3px;"
|
||||||
|
id="open_shop_button"
|
||||||
|
>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-bag-fill" viewBox="0 0 16 16">
|
||||||
|
<path d="M8 1a2.5 2.5 0 0 1 2.5 2.5V4h-5v-.5A2.5 2.5 0 0 1 8 1zm3.5 3v-.5a3.5 3.5 0 1 0-7 0V4H1v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V4h-3.5z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
`
|
||||||
|
|
||||||
function createTitle(text) {
|
function createTitle(text) {
|
||||||
return `<div id="plugin_title" class="quickaccessmenu_Title_34nl5">${text}</div>`;
|
return `
|
||||||
|
<div id="plugin_title" class="quickaccessmenu_Title_34nl5">${text}${SHOP_ICON}</div>
|
||||||
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function createPluginList() {
|
function createPluginList() {
|
||||||
@@ -79,7 +93,15 @@ function addPluginInstallPrompt(artifact, version, request_id) {
|
|||||||
inject();
|
inject();
|
||||||
document.getElementById("plugin_title").onclick = function() {
|
document.getElementById("plugin_title").onclick = function() {
|
||||||
reloadIframe();
|
reloadIframe();
|
||||||
document.getElementById("plugin_title").innerText = "Plugins";
|
document.getElementById("plugin_title").innerHTML = `Plugins ${SHOP_ICON}`;
|
||||||
|
}
|
||||||
|
document.getElementById("open_shop_button").onclick = function(ev) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
console.debug(JSON.stringify({
|
||||||
|
"id": 1,
|
||||||
|
"method": "open_plugin_store",
|
||||||
|
"args": {}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
window.onmessage = function(ev) {
|
window.onmessage = function(ev) {
|
||||||
let title = ev.data;
|
let title = ev.data;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from injector import inject_to_tab
|
from injector import get_tab, get_tabs, inject_to_tab
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
class Utilities:
|
class Utilities:
|
||||||
@@ -11,7 +11,8 @@ class Utilities:
|
|||||||
"confirm_plugin_install": self.confirm_plugin_install,
|
"confirm_plugin_install": self.confirm_plugin_install,
|
||||||
"execute_in_tab": self.execute_in_tab,
|
"execute_in_tab": self.execute_in_tab,
|
||||||
"inject_css_into_tab": self.inject_css_into_tab,
|
"inject_css_into_tab": self.inject_css_into_tab,
|
||||||
"remove_css_from_tab": self.remove_css_from_tab
|
"remove_css_from_tab": self.remove_css_from_tab,
|
||||||
|
"open_plugin_store": self.open_plugin_store
|
||||||
}
|
}
|
||||||
|
|
||||||
async def confirm_plugin_install(self, request_id):
|
async def confirm_plugin_install(self, request_id):
|
||||||
@@ -104,3 +105,17 @@ class Utilities:
|
|||||||
"success": False,
|
"success": False,
|
||||||
"result": e
|
"result": e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async def open_plugin_store(self):
|
||||||
|
if self.context.plugin_browser.store_url in await get_tabs():
|
||||||
|
return
|
||||||
|
res = await inject_to_tab("SP", """
|
||||||
|
window.PLUGIN_STORE_TAB_INSTANCE = (function() {
|
||||||
|
let i = SteamClient.BrowserView.Create()
|
||||||
|
i.SetBounds(0, 60, 1280, 800-59-60)
|
||||||
|
i.LoadURL('http://127.0.0.1:1337/browser/redirect')
|
||||||
|
i.SetVisible(true);
|
||||||
|
return i;
|
||||||
|
})();
|
||||||
|
""")
|
||||||
|
setattr(self, "store_is_open", True)
|
||||||
Reference in New Issue
Block a user