summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortza <marios8543@gmail.com>2022-05-10 20:31:39 +0300
committertza <marios8543@gmail.com>2022-05-10 20:31:39 +0300
commit0d0e57e35aebdc847fbefe1d791f72cc0979fa5a (patch)
tree55c5f42d6254b920021cd04db7d945ac2c4bc798
parent945db5de4788feefebc845817752472419051640 (diff)
downloaddecky-loader-0d0e57e35aebdc847fbefe1d791f72cc0979fa5a.tar.gz
decky-loader-0d0e57e35aebdc847fbefe1d791f72cc0979fa5a.zip
Added store button
-rw-r--r--plugin_loader/browser.py9
-rw-r--r--plugin_loader/static/plugin_page.js26
-rw-r--r--plugin_loader/utilities.py19
3 files changed, 48 insertions, 6 deletions
diff --git a/plugin_loader/browser.py b/plugin_loader/browser.py
index ffec26b3..e9c9bb53 100644
--- a/plugin_loader/browser.py
+++ b/plugin_loader/browser.py
@@ -1,4 +1,4 @@
-from injector import get_tab
+from injector import get_tab, inject_to_tab
from logging import getLogger
from os import path, rename
from shutil import rmtree
@@ -26,7 +26,8 @@ class PluginBrowser:
server_instance.add_routes([
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):
@@ -72,6 +73,10 @@ class PluginBrowser:
async def redirect_to_store(self, request):
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):
data = await request.post()
get_event_loop().create_task(self.request_plugin_install(data["artifact"], data["version"], data["hash"]))
diff --git a/plugin_loader/static/plugin_page.js b/plugin_loader/static/plugin_page.js
index 0531f04e..d571cfe3 100644
--- a/plugin_loader/static/plugin_page.js
+++ b/plugin_loader/static/plugin_page.js
@@ -53,8 +53,22 @@ function addPluginInstallPrompt(artifact, version, request_id) {
</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) {
- 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() {
@@ -79,7 +93,15 @@ function addPluginInstallPrompt(artifact, version, request_id) {
inject();
document.getElementById("plugin_title").onclick = function() {
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) {
let title = ev.data;
diff --git a/plugin_loader/utilities.py b/plugin_loader/utilities.py
index 39f9ca55..1cbecbf7 100644
--- a/plugin_loader/utilities.py
+++ b/plugin_loader/utilities.py
@@ -1,5 +1,5 @@
from aiohttp import ClientSession
-from injector import inject_to_tab
+from injector import get_tab, get_tabs, inject_to_tab
import uuid
class Utilities:
@@ -11,7 +11,8 @@ class Utilities:
"confirm_plugin_install": self.confirm_plugin_install,
"execute_in_tab": self.execute_in_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):
@@ -104,3 +105,17 @@ class Utilities:
"success": False,
"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) \ No newline at end of file