much improved asset handling (now using zstd)
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -2,4 +2,4 @@
|
|||||||
Cargo.lock
|
Cargo.lock
|
||||||
/pkg
|
/pkg
|
||||||
/tmp
|
/tmp
|
||||||
/data.tar
|
/data.tar.zst
|
||||||
@@ -23,13 +23,14 @@ lto = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = { git = "https://github.com/Titaniumtown/egui", default-features = false, features = ["egui_glow"] }
|
eframe = { git = "https://github.com/Titaniumtown/egui", default-features = false, features = ["egui_glow"] }
|
||||||
include-flate = { git = "https://github.com/Titaniumtown/include-flate.git" }
|
# include-flate = { git = "https://github.com/Titaniumtown/include-flate.git" }
|
||||||
shadow-rs = { version = "0.9", default-features = false }
|
shadow-rs = { version = "0.9", default-features = false }
|
||||||
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
exmex = { git = "https://github.com/Titaniumtown/exmex.git", branch = "main", features = ["partial"] }
|
exmex = { git = "https://github.com/Titaniumtown/exmex.git", branch = "main", features = ["partial"] }
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
tar = "0.4.38"
|
tar = "0.4.38"
|
||||||
|
ruzstd = { git = "https://github.com/KillingSpark/zstd-rs.git" }
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = "0.9"
|
shadow-rs = "0.9"
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cd assets
|
rm -fr data.tar.zst | true
|
||||||
rm -fr data.tar | true
|
tar -I 'zstd --ultra -22' -cf data.tar.zst assets/*.*
|
||||||
tar -cvf data.tar *.*
|
|
||||||
mv data.tar ../
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::function::{FunctionEntry, RiemannSum, EMPTY_FUNCTIONENTRY};
|
use crate::function::{FunctionEntry, RiemannSum, EMPTY_FUNCTIONENTRY};
|
||||||
use crate::misc::digits_precision;
|
use crate::misc::{digits_precision, log_helper};
|
||||||
use crate::parsing::{add_asterisks, test_func};
|
use crate::parsing::{add_asterisks, test_func};
|
||||||
|
|
||||||
use const_format::formatc;
|
use const_format::formatc;
|
||||||
@@ -10,7 +10,6 @@ use egui::{
|
|||||||
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
RichText, SidePanel, Slider, TopBottomPanel, Vec2, Visuals, Window,
|
||||||
};
|
};
|
||||||
use epi::{Frame, Storage};
|
use epi::{Frame, Storage};
|
||||||
use include_flate::flate;
|
|
||||||
use instant::Duration;
|
use instant::Duration;
|
||||||
use shadow_rs::shadow;
|
use shadow_rs::shadow;
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
@@ -43,9 +42,6 @@ const DEFAULT_MIN_X: f64 = -10.0;
|
|||||||
const DEFAULT_MAX_X: f64 = 10.0;
|
const DEFAULT_MAX_X: f64 = 10.0;
|
||||||
const DEFAULT_INTEGRAL_NUM: usize = 100;
|
const DEFAULT_INTEGRAL_NUM: usize = 100;
|
||||||
|
|
||||||
// Font Data
|
|
||||||
flate!(static DATA_FILE: [u8] from "data.tar");
|
|
||||||
|
|
||||||
// Stores data loaded from files
|
// Stores data loaded from files
|
||||||
struct FileData {
|
struct FileData {
|
||||||
// Stores fonts
|
// Stores fonts
|
||||||
@@ -64,7 +60,16 @@ struct FileData {
|
|||||||
lazy_static::lazy_static! {
|
lazy_static::lazy_static! {
|
||||||
// Load all of the data from the compressed tarballe
|
// Load all of the data from the compressed tarballe
|
||||||
static ref FILE_DATA: FileData = {
|
static ref FILE_DATA: FileData = {
|
||||||
let mut tar_archive = tar::Archive::new(&**DATA_FILE);
|
let start = instant::Instant::now();
|
||||||
|
log_helper("Loading tarball...");
|
||||||
|
let mut tar_file_raw = include_bytes!("../data.tar.zst").as_slice();
|
||||||
|
log_helper("Decompressing...");
|
||||||
|
let mut tar_file = ruzstd::StreamingDecoder::new(&mut tar_file_raw).unwrap();
|
||||||
|
let mut tar_file_data = Vec::new();
|
||||||
|
log_helper("Reading tarball....");
|
||||||
|
tar_file.read_to_end(&mut tar_file_data).unwrap();
|
||||||
|
|
||||||
|
let mut tar_archive = tar::Archive::new(&*tar_file_data);
|
||||||
|
|
||||||
// Stores fonts
|
// Stores fonts
|
||||||
let mut font_ubuntu_light: Option<FontData> = None;
|
let mut font_ubuntu_light: Option<FontData> = None;
|
||||||
@@ -119,6 +124,8 @@ lazy_static::lazy_static! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_helper(&format!("Done loading assets! Took: {:?}", start.elapsed()));
|
||||||
|
|
||||||
// Create and return FileData struct
|
// Create and return FileData struct
|
||||||
FileData {
|
FileData {
|
||||||
font_ubuntu_light: font_ubuntu_light.expect("Ubuntu Light font not found!"),
|
font_ubuntu_light: font_ubuntu_light.expect("Ubuntu Light font not found!"),
|
||||||
|
|||||||
Reference in New Issue
Block a user