Skip to content

Commit 414cc0d

Browse files
committed
Add navigation to dashboard of web UI
1 parent 2dcae38 commit 414cc0d

File tree

4 files changed

+47
-13
lines changed

4 files changed

+47
-13
lines changed

Loader/gdmodext/html/menu.html

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,41 @@
66
</head>
77

88
<body>
9-
<h1 class="uk-heading-medium" id="connecting">Connecting...</h1>
10-
<h4>Choose the scene you want to load:</h2>
11-
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" id="scenes" uk-grid>
12-
<p>Loading...</p>
13-
</div>
9+
<h1 class="uk-heading-medium" id="connecting">Connecting to game...</h1>
10+
<ul class="uk-subnav uk-subnav-pill" uk-switcher>
11+
<li><a href="#">Overview</a></li>
12+
<li><a href="#">Mod Loader</a></li>
13+
<li><a href="#">Scene switcher</a></li>
14+
<li><a href="#">Settings</a></li>
15+
</ul>
16+
<ul class="uk-switcher uk-margin" uk-switcher="animation: uk-animation-fade">
17+
<li id="overview">
18+
<h2 class="uk-heading-small">Overview</h2>
19+
<p class="uk-text-lead">
20+
Welcome to the dashboard! Here you can control the game like you want.
21+
Keep in mind that this tool is for modding, and the other tools are made for
22+
<b>debugging mods</b>. You can use them for other purpose but
23+
while using them keep in mind that their main purpose is modding.
24+
</p>
25+
</li>
26+
<li id="mods">
27+
<h2 class="uk-heading-small">Mod Loader</h2>
28+
<p class="uk-text-lead">Nothing here yet ;)</p>
29+
<a href="#" uk-switcher-item="next">Go to Scene Switcher</a>
30+
</li>
31+
<li id="scenes">
32+
<h2 class="uk-heading-small">Scene switcher</h2>
33+
<h4>Chose the scene you want to load:</h2>
34+
<div class="uk-child-width-1-3@m uk-grid-small uk-grid-match" id="scenelist" uk-grid>
35+
<h5 class="uk-text-meta">Loading...</h5>
36+
</div>
37+
</li>
38+
<li id="settings">
39+
<h2 class="uk-heading-small">Settings</h2>
40+
<p class="uk-text-lead">Nothing to configure yet ;)</p>
41+
<a href="#" uk-switcher-item="previous">Go to Scene Switcher</a>
42+
</li>
43+
</ul>
1444

1545
<!-- Additional Scripts -->
1646
<script src="../vendor/uikit.min.js"></script>

Loader/gdmodext/js/injected.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const debug = false;
1111
/**
1212
* The CDN to fetch the GDAPI files from
1313
*/
14-
const CDN = "https://cdn.jsdelivr.net/gh/arthuro555/gdmod/API/";
14+
const CDN = "https://cdn.jsdelivr.net/gh/arthuro555/gdmod@latest/API/";
1515

1616
/**
1717
* Flag telling if that page got patched already.
@@ -106,6 +106,8 @@ if(window.gdjs !== undefined) {
106106
postToPopup("pong", true);
107107
} else if(event.data["message"] === "installAPI") {
108108
installGDModAPI();
109+
} else if(event.data["message"] === "connect") {
110+
postToPopup("connected", gdjs.projectData.properties);
109111
} else if(event.data["message"] === "listScenes") {
110112
let allScenes = [];
111113
for (let scene of gdjs.projectData.layouts) allScenes.push(scene.name);

Loader/gdmodext/js/menu.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,26 @@ chrome.tabs.query({active: true, currentWindow: false}, function(tabs) {
3636
if(event["id"] === "pong") {
3737
console.log("pong")
3838
} else if(event["id"] === "listScenes") {
39-
const scenes = document.getElementById("scenes");
39+
const scenes = document.getElementById("scenelist");
4040
scenes.innerHTML = "";
4141
for(let sceneName of event.payload) {
4242
scenes.appendChild(createCard(sceneName));
4343
}
4444
} else if(event["id"] === "installedAPI") {
45+
// TODO
46+
} else if(event["id"] === "connected") {
4547
// This means the game is connected and ready
4648
document.title = "GDmod Scene Selector";
47-
document.getElementById("connecting").innerHTML = "Connected!";
49+
document.getElementById("connecting").innerHTML = "Dashboard for GD game " + event.payload.name;
4850
chrome.tabs.sendMessage(tabs[0].id, {message: "listScenes"}); // Get list of scenes (will be moved)
4951
}
5052
}
5153
});
5254

55+
document.getElementById('mods').addEventListener('show', function () {
56+
chrome.tabs.sendMessage(tabs[0].id, {message: "installAPI"});
57+
});
58+
5359
// Now that we opened the mod loader install the API into the game (the API is not crucial and is therefore only loaded when needed)
54-
chrome.tabs.sendMessage(tabs[0].id, {message: "installAPI"});
60+
chrome.tabs.sendMessage(tabs[0].id, {message: "connect"});
5561
});

Loader/gdmodext/js/popup.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ let patcherButton = document.getElementById("patcher-button");
22

33
patcherButton.addEventListener("click", function() {
44
if (!patcherButton.hasAttribute("disabled")) {
5-
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
6-
chrome.tabs.sendMessage(tabs[0].id, {message: "patch"});
7-
});
8-
patcherButton.setAttribute("disabled", true);
95
chrome.windows.create({
106
url: chrome.runtime.getURL("html/menu.html"),
117
type: "popup"

0 commit comments

Comments
 (0)