Skip to content

Commit

Permalink
Fix trunk breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
maddymakesgames committed Jan 21, 2025
1 parent 3b41591 commit a283064
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,4 @@ jobs:
- name: Download and install Trunk binary
run: wget -qO- https://github.com/thedodd/trunk/releases/latest/download/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
- name: Build
run: ./trunk build ./gui/index.html
run: ./trunk build --config ./gui/Trunk.toml
3 changes: 3 additions & 0 deletions gui/Trunk.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build]
target = "./index.html"
filehash = false
32 changes: 23 additions & 9 deletions gui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,26 @@

<head>
<!-- change this to your project name -->
<title>celeste.rs</title>
<title>celeste_rs</title>

<!-- config for our rust wasm binary. go to https://trunkrs.dev/assets/#rust for more customization -->
<link data-trunk rel="rust" data-wasm-opt="2" />
<!-- this is the base url relative to which other urls will be constructed. trunk will insert this from the public-url option -->
<base data-trunk-public-url />

<link data-trunk rel="icon" href="assets/favicon.ico">


<link data-trunk rel="copy-file" href="assets/sw.js" />
<link data-trunk rel="copy-file" href="assets/manifest.json" />
<link data-trunk rel="copy-file" href="assets/icon-1024.png" />
<link data-trunk rel="copy-file" href="assets/icon-256.png" />
<link data-trunk rel="copy-file" href="assets/maskable_icon_x512.png" />
<link data-trunk rel="copy-file" href="assets/icon-1024.png" data-target-path="assets" />
<link data-trunk rel="copy-file" href="assets/icon-256.png" data-target-path="assets" />
<!-- <link data-trunk rel="copy-file" href="assets/icon_ios_touch_192.png" data-target-path="assets" /> -->
<link data-trunk rel="copy-file" href="assets/maskable_icon_x512.png" data-target-path="assets" />


<link rel="manifest" href="manifest.json">
<link rel="apple-touch-icon" href="assets/icon_ios_touch_192.png">
<meta name="theme-color" media="(prefers-color-scheme: light)" content="white">
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#404040">

Expand Down Expand Up @@ -55,15 +60,16 @@
width: 100%;
}

/* Position canvas in center-top: */
/* Make canvas fill entire document: */
canvas {
margin-right: auto;
margin-left: auto;
display: block;
position: absolute;
top: 0%;
left: 50%;
transform: translate(-50%, 0%);
top: 0;
left: 0;
width: 100%;
height: 100%;
}

.centered {
Expand Down Expand Up @@ -117,6 +123,14 @@
<!-- the id is hardcoded in main.rs . so, make sure both match. -->
<canvas id="the_canvas_id"></canvas>

<!-- the loading spinner will be removed in main.rs -->
<div class="centered" id="loading_text">
<p style="font-size:16px">
Loading…
</p>
<div class="lds-dual-ring"></div>
</div>

<!--Register Service Worker. this will cache the wasm / js scripts for offline use (for PWA functionality). -->
<!-- Force refresh (Ctrl + F5) to load the latest files instead of cached files -->
<script>
Expand All @@ -131,4 +145,4 @@

</html>

<!-- Powered by egui: https://github.com/emilk/egui/ -->
<!-- Powered by egui: https://github.com/emilk/egui/ -->
25 changes: 22 additions & 3 deletions gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,33 @@ fn main() {

// Expect is fine since its on startup
wasm_bindgen_futures::spawn_local(async {
eframe::WebRunner::new()
let document = web_sys::window()
.expect("No window")
.document()
.expect("No document");

let start_result = eframe::WebRunner::new()
.start(
"the_canvas_id",
eframe::WebOptions::default(),
Box::new(|cc| Box::new(SaveEditor::new(cc))),
)
.await
.expect("Error starting eframe app")
.await;

// Remove the loading text and spinner:
if let Some(loading_text) = document.get_element_by_id("loading_text") {
match start_result {
Ok(_) => {
loading_text.remove();
}
Err(e) => {
loading_text.set_inner_html(
"<p> The app has crashed. See the developer console for details. </p>",
);
panic!("Failed to start eframe: {e:?}");
}
}
}
});
}

Expand Down

0 comments on commit a283064

Please sign in to comment.