Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nightly #205

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions .github/workflows/rust_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,7 @@ jobs:
- name: Download count.js
run: wget "https://gc.zgo.at/count.js" -P dist/

# Create dummy file for successful removal of any file
- name: Create dummy file
run: ssh flareflo-github@${{ secrets.CAVE_IP }} 'cd /var/www/flo_wt_calc; touch placeholder.txt'

# Clean up dist folder before pushing new set
- name: Prepare server for rsync
run: ssh flareflo-github@${{ secrets.CAVE_IP }} 'rm -rf /var/www/flo_wt_calc/*'

- name: Deploy with rsync
run: rsync -avz ./dist/ flareflo-github@${{ secrets.CAVE_IP }}:/var/www/flo_wt_calc/dist
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: dist # The folder the action should deploy.
123 changes: 74 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion js/missile_ballistics.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import init, {export_zip, main_js, plot, run_compare} from "../pkg";
import init, {export_zip, main_js, plot, run_compare, export_all_to_zip} from "../pkg";
import {input_manager, set_value_enter, sleep} from "./util";

async function main() {
Expand Down Expand Up @@ -72,6 +72,39 @@ async function main() {

});

document.getElementById("export_all_zip").addEventListener("click", () => {
const downloadBlob = function(data, fileName, mimeType) {
var blob, url;
blob = new Blob([data], {
type: mimeType
});
url = window.URL.createObjectURL(blob);
downloadURL(url, fileName);
setTimeout(function() {
return window.URL.revokeObjectURL(url);
}, 1000);
};

const downloadURL = function(data, fileName) {
var a;
a = document.createElement('a');
a.href = data;
a.download = fileName;
document.body.appendChild(a);
a.style = 'display: none';
a.click();
a.remove();
};

const bytes = new Uint8Array();
const zip = export_all_to_zip(
parseInt(document.getElementById("altitude").value),
parseInt(document.getElementById("velocity").value)
);
downloadBlob(zip, "missile_sim.zip", "application/zip");

});

let canvas_scale = 1;
let canvas_translate = (0, 0);
let canvas = document.getElementById("ballistics");
Expand Down
26 changes: 26 additions & 0 deletions src/missile_ballistics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use wt_ballistics_calc_lib::runner::{generate, LaunchResults};

use std::str::FromStr;
use std::sync::Mutex;
use js_sys::Math::min;
use wt_datamine_extractor_lib::missile::missile::Missile;

const WIDTH: u32 = 3840;
Expand Down Expand Up @@ -245,3 +246,28 @@ pub fn export_zip(plot_png: &[u8]) -> Vec<u8> {
let file = res.as_csv(Some(plot_png), missile);
file.unwrap()
}

#[wasm_bindgen]
pub fn export_all_to_zip(altitude: u32, start_velocity: f64) -> Vec<u8> {
let mut zip = None;
for missile in MISSILES.iter() {
let results = generate(
missile,
LaunchParameter {
use_gravity: false,
start_velocity,
distance_to_target: 0.0,
target_speed: 0.0,
altitude,
},
TIMESTEP,
false,
);
if zip.is_none() {
zip = Some(results.start_csv(None, missile.clone()));
} else {
results.write_into_zip(None, missile.clone(), zip.as_mut().unwrap()).unwrap();
}
}
LaunchResults::finish_zip(zip.unwrap()).unwrap()
}
1 change: 1 addition & 0 deletions static/html/missile_ballistics.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<form id="config" onsubmit="return false;">

<button class="button" id="export_zip">Export to zip</button><br>
<button class="button" id="export_all_zip">Export every missile to zip</button><br>

<label for="color_select">Color sheme</label>
<select id="color_select">
Expand Down
Loading