Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebosp committed May 17, 2023
2 parents 0c9e27d + ff5d10c commit 91b8f8b
Show file tree
Hide file tree
Showing 15 changed files with 3,237 additions and 326 deletions.
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ description = "Visualizer experiments for Starcraft II - Replay data"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rerun = "0.4.0"
s2protocol = "1.0.0"
rerun = "0.5.1"
s2protocol = "1.1.1"
nom-mpq = "0.1.1"
colored = "2.0.0"
tracing = "0.1"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
clap = { version = "4.1", features = ["derive"] }
mimalloc = "0.1.36"
convert_case = "0.6.0"
thiserror = "1.0.40"

[workspace]
resolver = "2" # Important! wgpu/Bevy needs this!
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# swarmy
# swarmy 1.1.0

Starcraft 2 Replay in Rerun

## Recorded/Processed Replays

Rerun 0.5.1:

![2023-GSL-S1-RO16-GroupA-Winners-Match](https://sebosp.github.io/swarmy/public/0.5.1/2023-GSL-S1-RO16-GroupA-Winners-Match.html?url=https://sebosp.github.io/swarmy/public/0.5.1/assets/2023-GSL-S1-RO16-GroupA-Winners-Match.rrd)

## Running on native.

For now this has been tested on Linux.
Expand All @@ -11,6 +18,8 @@ Clone this repo.
```shell
# Clone this repository.
$ cargo run -r -- --source <FILE>
# To run the example file provided in this repo:
# cargo run -- --source assets/2023-04-08-2v2AI.SC2Replay
# The first time the code is compiled it will take a few minutes.
# Subsequent runs should not need compilation.
```
Expand All @@ -32,11 +41,9 @@ The minerals are recognized and drawn.

The drones are visible in their initial position.

![Initial preview](https://user-images.githubusercontent.com/873436/231281746-40fde3f1-fec6-49fe-8cf1-5fbd197589b7.png)

## Motivation:

Appreciate a fantastic game at a different level, learn how people use and learn the game.
Appreciate a fantastic game at a lower level, learn how people use and learn the game.

## Uses:

Expand Down
Binary file added assets/2023-04-08-2v2AI.SC2Replay
Binary file not shown.
10 changes: 10 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<ul>
<li><a href="https://sebosp.github.io/swarmy/public/0.5.1/2023-GSL-S1-RO16-GroupA-Winners-Match.html?url=https://sebosp.github.io/swarmy/public/0.5.1/assets/2023-GSL-S1-RO16-GroupA-Winners-Match.rrd">2023-GSL-S1-RO16-GroupA-Winners-Match.rrd - Rerun 0.5.1</a></li>
</ul>
</body>
</html>
208 changes: 208 additions & 0 deletions public/0.5.1/2023-GSL-S1-RO16-GroupA-Winners-Match.html

Large diffs are not rendered by default.

Binary file not shown.
11 changes: 11 additions & 0 deletions public/0.5.1/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
203 changes: 203 additions & 0 deletions public/0.5.1/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
<!DOCTYPE html>
<!-- The version of index.html bundled with the Rerun SDK. -->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- Disable zooming: -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

<head>
<link rel="icon" href="favicon.svg" />
<title>rerun viewer</title>
<style>
html {
/* Remove touch delay: */
touch-action: manipulation;
}

body {
/* Light mode background color for what is not covered by the egui canvas,
or where the egui canvas is translucent. */
background: #909090;
}

@media (prefers-color-scheme: dark) {
body {
/* Dark mode background color for what is not covered by the egui canvas,
or where the egui canvas is translucent. */
background: #404040;
}
}

/* Allow canvas to fill entire web page: */
html,
body {
overflow: hidden;
margin: 0 !important;
padding: 0 !important;
height: 100%;
width: 100%;
}

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

.centered {
margin-right: auto;
margin-left: auto;
display: block;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #f0f0f0;
font-size: 24px;
font-family: Ubuntu-Light, Helvetica, sans-serif;
text-align: center;
}

a {
display: inline-block;
background: white;
color: black;
padding: .75rem 1rem;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
}

/* ---------------------------------------------- */
/* Loading animation from https://loading.io/css/ */
.lds-dual-ring {
display: inline-block;
width: 24px;
height: 24px;
}

.lds-dual-ring:after {
content: " ";
display: block;
width: 24px;
height: 24px;
margin: 0px;
border-radius: 50%;
border: 3px solid #fff;
border-color: #fff transparent #fff transparent;
animation: lds-dual-ring 1.2s linear infinite;
}

@keyframes lds-dual-ring {
0% {
transform: rotate(0deg);
}

100% {
transform: rotate(360deg);
}
}

</style>
</head>

<body>
<!-- The Wasm code will resize the canvas dynamically -->
<canvas id="the_canvas_id"></canvas>
<div class="centered" id="mobile_text" style="visibility:hidden">
<p style="font-size:16px">
Rerun is not yet supported on mobile browsers.
</p>
<p style="font-size:16px">
<a href="#" id="try_anyways">Try anyways</a>
</p>
</div>
<div class="centered" id="center_text">
<p style="font-size:16px">
Loading…
</p>
<div class="lds-dual-ring"></div>
</div>

<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
// but this doesn't work with `file://` urls. This example is frequently
// viewed by simply opening `index.html` in a browser (with a `file://`
// url), so it would fail if we were to call this function!
//
// Work around this for now by deleting the function to ensure that the
// `no_modules.js` script doesn't have access to it. You won't need this
// hack when deploying over HTTP.
delete WebAssembly.instantiateStreaming;
</script>

<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
<script src="re_viewer.js"></script>

<script>
// On mobile platforms show a warning, but provide a link to try anyways
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
document.querySelector('#center_text').style.visibility = 'hidden';
document.querySelector('#mobile_text').style.visibility = 'visible';
document.querySelector('#try_anyways').addEventListener('click', function (event) {
event.preventDefault();
document.querySelector('#center_text').style.visibility = 'visible';
document.querySelector('#mobile_text').style.visibility = 'hidden';
load_wasm();
});
} else {
load_wasm();
}

function load_wasm() {
// We'll defer our execution until the wasm is ready to go.
// Here we tell bindgen the path to the wasm file so it can start
// initialization and return to us a promise when it's done.

console.debug("loading wasm…");
wasm_bindgen("./re_viewer_bg.wasm")
.then(on_wasm_loaded)
.catch(on_wasm_error);
}

function on_wasm_loaded() {
console.debug("wasm loaded. starting app…");

// This call installs a bunch of callbacks and then returns:
let url = null; // you can use this to point to an .rrd file over http, or a WebSocket Rerun server.
wasm_bindgen.start("the_canvas_id", url);

console.debug("app started.");
document.getElementById("center_text").remove();

if (window.location !== window.parent.location) {
window.parent.postMessage("READY", "*");
}
}

function on_wasm_error(error) {
console.error("Failed to start: " + error);
document.getElementById("center_text").innerHTML = `
<p>
An error occurred during loading:
</p>
<p style="font-family:Courier New">
${error}
</p>
<p style="font-size:14px">
Make sure you use a modern browser with WebGL and Wasm enabled.
</p>`;
}
</script>
</body>

</html>

<!-- Powered by egui: https://github.com/emilk/egui/ -->
Loading

0 comments on commit 91b8f8b

Please sign in to comment.