Added logger

master
Mark 2024-01-23 21:21:31 -08:00
parent 98b460aba9
commit d6a3e10a84
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
15 changed files with 316 additions and 26 deletions

244
Cargo.lock generated
View File

@ -75,6 +75,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]]
name = "android-tzdata"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0"
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@ -147,6 +153,12 @@ dependencies = [
"num-traits", "num-traits",
] ]
[[package]]
name = "arc-swap"
version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
[[package]] [[package]]
name = "arrayref" name = "arrayref"
version = "0.3.7" version = "0.3.7"
@ -315,6 +327,20 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41daef31d7a747c5c847246f36de49ced6f7403b4cdabc807a97b5cc184cda7a"
dependencies = [
"android-tzdata",
"iana-time-zone",
"js-sys",
"num-traits",
"wasm-bindgen",
"windows-targets 0.52.0",
]
[[package]] [[package]]
name = "clap" name = "clap"
version = "4.4.18" version = "4.4.18"
@ -535,6 +561,23 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "destructure_traitobject"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c877555693c14d2f84191cfd3ad8582790fc52b5e2274b40b59cf5f5cea25c7"
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@ -634,6 +677,12 @@ dependencies = [
"spin", "spin",
] ]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]] [[package]]
name = "fontconfig-parser" name = "fontconfig-parser"
version = "0.5.3" version = "0.5.3"
@ -724,6 +773,8 @@ dependencies = [
"galactica-system", "galactica-system",
"galactica-util", "galactica-util",
"image", "image",
"log",
"log4rs",
"nalgebra", "nalgebra",
"pollster", "pollster",
"rand", "rand",
@ -741,6 +792,7 @@ dependencies = [
"galactica-util", "galactica-util",
"image", "image",
"lazy_static", "lazy_static",
"log",
"nalgebra", "nalgebra",
"rapier2d", "rapier2d",
"serde", "serde",
@ -787,6 +839,7 @@ dependencies = [
"galactica-util", "galactica-util",
"glyphon", "glyphon",
"image", "image",
"log",
"nalgebra", "nalgebra",
"rand", "rand",
"wgpu", "wgpu",
@ -927,7 +980,7 @@ checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c"
dependencies = [ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"gpu-descriptor-types", "gpu-descriptor-types",
"hashbrown", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -948,6 +1001,12 @@ dependencies = [
"crunchy", "crunchy",
] ]
[[package]]
name = "hashbrown"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
[[package]] [[package]]
name = "hashbrown" name = "hashbrown"
version = "0.14.3" version = "0.14.3"
@ -985,6 +1044,35 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df"
[[package]]
name = "humantime"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "iana-time-zone"
version = "0.1.59"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6a67363e2aa4443928ce15e57ebae94fd8949958fd1223c4cfc0cd473ad7539"
dependencies = [
"android_system_properties",
"core-foundation-sys",
"iana-time-zone-haiku",
"js-sys",
"wasm-bindgen",
"windows-core",
]
[[package]]
name = "iana-time-zone-haiku"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "image" name = "image"
version = "0.24.7" version = "0.24.7"
@ -1004,6 +1092,16 @@ dependencies = [
"tiff", "tiff",
] ]
[[package]]
name = "indexmap"
version = "1.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99"
dependencies = [
"autocfg",
"hashbrown 0.12.3",
]
[[package]] [[package]]
name = "indexmap" name = "indexmap"
version = "2.1.0" version = "2.1.0"
@ -1011,7 +1109,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f" checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [ dependencies = [
"equivalent", "equivalent",
"hashbrown", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -1026,6 +1124,12 @@ dependencies = [
"web-sys", "web-sys",
] ]
[[package]]
name = "itoa"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]] [[package]]
name = "jni-sys" name = "jni-sys"
version = "0.3.0" version = "0.3.0"
@ -1131,6 +1235,12 @@ dependencies = [
"redox_syscall 0.4.1", "redox_syscall 0.4.1",
] ]
[[package]]
name = "linked-hash-map"
version = "0.5.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
[[package]] [[package]]
name = "lock_api" name = "lock_api"
version = "0.4.11" version = "0.4.11"
@ -1146,6 +1256,41 @@ name = "log"
version = "0.4.20" version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
dependencies = [
"serde",
]
[[package]]
name = "log-mdc"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a94d21414c1f4a51209ad204c1776a3d0765002c76c6abcb602a6f09f1e881c7"
[[package]]
name = "log4rs"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d36ca1786d9e79b8193a68d480a0907b612f109537115c6ff655a3a1967533fd"
dependencies = [
"anyhow",
"arc-swap",
"chrono",
"derivative",
"fnv",
"humantime",
"libc",
"log",
"log-mdc",
"parking_lot",
"serde",
"serde-value",
"serde_json",
"serde_yaml",
"thiserror",
"thread-id",
"typemap-ors",
"winapi",
]
[[package]] [[package]]
name = "lru" name = "lru"
@ -1153,7 +1298,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7" checksum = "2994eeba8ed550fd9b47a0b38f0242bc3344e496483c6180b69139cc2fa5d1d7"
dependencies = [ dependencies = [
"hashbrown", "hashbrown 0.14.3",
] ]
[[package]] [[package]]
@ -1255,7 +1400,7 @@ dependencies = [
"bitflags 2.4.1", "bitflags 2.4.1",
"codespan-reporting", "codespan-reporting",
"hexf-parse", "hexf-parse",
"indexmap", "indexmap 2.1.0",
"log", "log",
"num-traits", "num-traits",
"rustc-hash", "rustc-hash",
@ -1517,6 +1662,15 @@ dependencies = [
"libredox", "libredox",
] ]
[[package]]
name = "ordered-float"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c"
dependencies = [
"num-traits",
]
[[package]] [[package]]
name = "owned_ttf_parser" name = "owned_ttf_parser"
version = "0.20.0" version = "0.20.0"
@ -1824,6 +1978,12 @@ dependencies = [
"unicode-script", "unicode-script",
] ]
[[package]]
name = "ryu"
version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f98d2aa92eebf49b69786be48e4477826b256916e84a57ff2a4f21923b48eb4c"
[[package]] [[package]]
name = "safe_arch" name = "safe_arch"
version = "0.7.1" version = "0.7.1"
@ -1882,6 +2042,16 @@ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]]
name = "serde-value"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c"
dependencies = [
"ordered-float",
"serde",
]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.193" version = "1.0.193"
@ -1893,6 +2063,17 @@ dependencies = [
"syn 2.0.42", "syn 2.0.42",
] ]
[[package]]
name = "serde_json"
version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0652c533506ad7a2e353cce269330d6afd8bdfb6d75e0ace5b35aacbd7b9e9"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]] [[package]]
name = "serde_spanned" name = "serde_spanned"
version = "0.6.5" version = "0.6.5"
@ -1902,6 +2083,18 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_yaml"
version = "0.8.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b"
dependencies = [
"indexmap 1.9.3",
"ryu",
"serde",
"yaml-rust",
]
[[package]] [[package]]
name = "simba" name = "simba"
version = "0.8.1" version = "0.8.1"
@ -1970,7 +2163,7 @@ version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd774eb23cff002036706e6ea83c3f4ab4c80dad89da76fe16d49f77ab71682f" checksum = "bd774eb23cff002036706e6ea83c3f4ab4c80dad89da76fe16d49f77ab71682f"
dependencies = [ dependencies = [
"hashbrown", "hashbrown 0.14.3",
"num-traits", "num-traits",
"robust", "robust",
"smallvec", "smallvec",
@ -2089,6 +2282,16 @@ dependencies = [
"syn 2.0.42", "syn 2.0.42",
] ]
[[package]]
name = "thread-id"
version = "4.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0ec81c46e9eb50deaa257be2f148adf052d1fb7701cfd55ccfab2525280b70b"
dependencies = [
"libc",
"winapi",
]
[[package]] [[package]]
name = "tiff" name = "tiff"
version = "0.9.0" version = "0.9.0"
@ -2167,7 +2370,7 @@ version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [ dependencies = [
"indexmap", "indexmap 2.1.0",
"toml_datetime", "toml_datetime",
"winnow", "winnow",
] ]
@ -2178,7 +2381,7 @@ version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
dependencies = [ dependencies = [
"indexmap", "indexmap 2.1.0",
"serde", "serde",
"serde_spanned", "serde_spanned",
"toml_datetime", "toml_datetime",
@ -2197,6 +2400,15 @@ version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]]
name = "typemap-ors"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a68c24b707f02dd18f1e4ccceb9d49f2058c2fb86384ef9972592904d7a28867"
dependencies = [
"unsafe-any-ors",
]
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.17.0" version = "1.17.0"
@ -2263,6 +2475,15 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c"
[[package]]
name = "unsafe-any-ors"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0a303d30665362d9680d7d91d78b23f5f899504d4f08b3c4cf08d055d87c0ad"
dependencies = [
"destructure_traitobject",
]
[[package]] [[package]]
name = "utf8parse" name = "utf8parse"
version = "0.2.1" version = "0.2.1"
@ -2891,6 +3112,15 @@ version = "0.13.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4" checksum = "66fee0b777b0f5ac1c69bb06d361268faafa61cd4682ae064a171c16c433e9e4"
[[package]]
name = "yaml-rust"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85"
dependencies = [
"linked-hash-map",
]
[[package]] [[package]]
name = "yazi" name = "yazi"
version = "0.1.6" version = "0.1.6"

View File

@ -72,3 +72,5 @@ toml = "0.8.8"
glyphon = "0.4.1" glyphon = "0.4.1"
lazy_static = "1.4.0" lazy_static = "1.4.0"
clap = { version = "4.4.18", features = ["derive"] } clap = { version = "4.4.18", features = ["derive"] }
log = "0.4.20"
log4rs = { version = "1.2.0", features = ["console_appender"] }

View File

@ -28,3 +28,4 @@ nalgebra = { workspace = true }
image = { workspace = true } image = { workspace = true }
rapier2d = { workspace = true } rapier2d = { workspace = true }
lazy_static = { workspace = true } lazy_static = { workspace = true }
log = { workspace = true }

View File

@ -10,6 +10,7 @@ mod util;
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use galactica_packer::{SpriteAtlas, SpriteAtlasImage}; use galactica_packer::{SpriteAtlas, SpriteAtlasImage};
use log::warn;
use std::{ use std::{
collections::HashMap, collections::HashMap,
fs::File, fs::File,
@ -179,22 +180,22 @@ impl Content {
match e.path().extension() { match e.path().extension() {
Some(t) => { Some(t) => {
if t.to_str() != Some("toml") { if t.to_str() != Some("toml") {
println!("[WARNING] {e:#?} is not a toml file, skipping."); warn!("{e:#?} is not a toml file, skipping");
continue; continue;
} }
} }
None => { None => {
println!("[WARNING] {e:#?} is not a toml file, skipping."); warn!("{e:#?} is not a toml file, skipping");
continue; continue;
} }
} }
let path = e.path(); let path = e.path();
let this_root = Self::try_parse(path) let this_root = Self::try_parse(path)
.with_context(|| format!("Could not read {}", path.display()))?; .with_context(|| format!("could not read {}", path.display()))?;
root.merge(this_root) root.merge(this_root)
.with_context(|| format!("Could not parse {}", path.display()))?; .with_context(|| format!("could not parse {}", path.display()))?;
} }
} }

View File

@ -10,7 +10,7 @@ pub(crate) mod sprite;
pub(crate) mod system; pub(crate) mod system;
pub use config::Config; pub use config::Config;
pub use effect::Effect; pub use effect::*;
pub use faction::{Faction, Relationship}; pub use faction::{Faction, Relationship};
pub use outfit::{Gun, Outfit, Projectile, ProjectileCollider}; pub use outfit::{Gun, Outfit, Projectile, ProjectileCollider};
pub use outfitspace::OutfitSpace; pub use outfitspace::OutfitSpace;

View File

@ -160,7 +160,7 @@ fn resolve_coordinates(
None => bail!("Could not resolve coordinate label `{l}`"), None => bail!("Could not resolve coordinate label `{l}`"),
}; };
Ok(resolve_position(&objects, &p, cycle_detector) Ok(resolve_position(&objects, &p, cycle_detector)
.with_context(|| format!("In object {:#?}", l))?) .with_context(|| format!("in object {:#?}", l))?)
} }
} }
} }
@ -223,7 +223,7 @@ impl crate::Build for System {
objects.push(SystemObject { objects.push(SystemObject {
sprite: sprite_handle, sprite: sprite_handle,
pos: resolve_position(&system.object, &obj, cycle_detector) pos: resolve_position(&system.object, &obj, cycle_detector)
.with_context(|| format!("In object {:#?}", label))?, .with_context(|| format!("in object {:#?}", label))?,
size: obj.size, size: obj.size,
angle: to_radians(obj.angle.unwrap_or(0.0)), angle: to_radians(obj.angle.unwrap_or(0.0)),
handle: SystemObjectHandle { handle: SystemObjectHandle {

View File

@ -37,3 +37,5 @@ nalgebra = { workspace = true }
clap = { workspace = true } clap = { workspace = true }
walkdir = { workspace = true } walkdir = { workspace = true }
image = { workspace = true } image = { workspace = true }
log = { workspace = true }
log4rs = { workspace = true }

View File

@ -1,6 +1,7 @@
use anyhow::{bail, Context, Result}; use anyhow::{bail, Context, Result};
use galactica_packer::AtlasSet; use galactica_packer::AtlasSet;
use image::io::Reader; use image::io::Reader;
use log::warn;
use std::path::Path; use std::path::Path;
use walkdir::WalkDir; use walkdir::WalkDir;
@ -22,21 +23,21 @@ pub fn run(asset_root: &Path, cache_target: &Path) -> Result<()> {
match e.path().extension() { match e.path().extension() {
Some(t) => { Some(t) => {
if t.to_str() != Some("png") && t.to_str() != Some("jpg") { if t.to_str() != Some("png") && t.to_str() != Some("jpg") {
println!("[WARNING] {e:#?} is not a png file, skipping."); warn!("{e:#?} is not a png file, skipping");
continue; continue;
} }
} }
None => { None => {
println!("[WARNING] {e:#?} is not a png file, skipping."); warn!("{e:#?} is not a png file, skipping");
continue; continue;
} }
} }
let path = e.path().to_path_buf(); let path = e.path().to_path_buf();
let reader = Reader::open(&path) let reader = Reader::open(&path)
.with_context(|| format!("While reading file `{}`", path.display()))?; .with_context(|| format!("while reading file `{}`", path.display()))?;
let dim = reader.into_dimensions().with_context(|| { let dim = reader.into_dimensions().with_context(|| {
format!("While reading dimensions of file `{}`", path.display()) format!("while reading dimensions of file `{}`", path.display())
})?; })?;
files.push((path, [dim.0, dim.1])); files.push((path, [dim.0, dim.1]));
total_dim += dim.0 as f64 * dim.1 as f64; total_dim += dim.0 as f64 * dim.1 as f64;
@ -55,7 +56,7 @@ pub fn run(asset_root: &Path, cache_target: &Path) -> Result<()> {
// Our tiling algorithm usually has efficiency better than 80% (~90%, as of writing) // Our tiling algorithm usually has efficiency better than 80% (~90%, as of writing)
// We need room for error, though, since this check doesn't guarante success. // We need room for error, though, since this check doesn't guarante success.
if total_dim / 0.80 >= (8192.0 * 8192.0 * 16.0) { if total_dim / 0.80 >= (8192.0 * 8192.0 * 16.0) {
bail!("Texture atlas is too small") bail!("texture atlas is too small")
} }
// Create atlas set // Create atlas set

View File

@ -64,6 +64,24 @@ impl<'a> Game {
], ],
); );
let a = phys_sim.add_ship(
&ct,
ShipHandle { index: 0 },
FactionHandle { index: 1 },
ShipPersonality::Point,
Point2::new(1000.0, 4000.0),
);
let s = phys_sim.get_ship_mut(&a).unwrap();
s.add_outfits(
&ct,
[
OutfitHandle { index: 0 },
OutfitHandle { index: 1 },
OutfitHandle { index: 2 },
],
);
let a = phys_sim.add_ship( let a = phys_sim.add_ship(
&ct, &ct,
ShipHandle { index: 0 }, ShipHandle { index: 0 },

View File

@ -10,6 +10,13 @@ use galactica_system::{
phys::{PhysImage, PhysSimShipHandle}, phys::{PhysImage, PhysSimShipHandle},
}; };
use galactica_util::constants::ASSET_CACHE; use galactica_util::constants::ASSET_CACHE;
use log::LevelFilter;
use log4rs::{
append::console::ConsoleAppender,
config::{Appender, Logger, Root},
encode::pattern::PatternEncoder,
Config,
};
use nalgebra::Vector2; use nalgebra::Vector2;
use std::{ use std::{
fs, fs,
@ -35,9 +42,34 @@ struct Args {
mod cli; mod cli;
fn set_up_logger(_args: &Args) -> log4rs::Handle {
// h: highlight with level color
// :<0.40 right align, min 0, max 40
let stdout = ConsoleAppender::builder()
.encoder(Box::new(PatternEncoder::new(
"{d(%H:%M:%S)} | {({h({l})}):5.5} | \x1b[0;34m{M}\x1b[0m — {m:<0.50}{n}",
)))
.build();
let config = Config::builder()
.appender(Appender::builder().build("stdout", Box::new(stdout)))
.logger(Logger::builder().build("wgpu_core", LevelFilter::Warn))
.logger(Logger::builder().build("wgpu_hal", LevelFilter::Warn))
.logger(Logger::builder().build("naga", LevelFilter::Warn))
.logger(Logger::builder().build("cosmic_text", LevelFilter::Warn))
.logger(Logger::builder().build("winit", LevelFilter::Warn))
.logger(Logger::builder().build("mio", LevelFilter::Warn))
.build(Root::builder().appender("stdout").build(LevelFilter::Trace))
.unwrap();
log4rs::init_config(config).unwrap()
}
fn main() -> Result<()> { fn main() -> Result<()> {
let args = Args::parse(); let args = Args::parse();
let _ = set_up_logger(&args);
let cache_dir = Path::new(ASSET_CACHE); let cache_dir = Path::new(ASSET_CACHE);
fs::create_dir_all(cache_dir)?; fs::create_dir_all(cache_dir)?;

View File

@ -85,9 +85,9 @@ impl AtlasSet {
let mut f = File::open(&path)?; let mut f = File::open(&path)?;
let mut bytes = Vec::new(); let mut bytes = Vec::new();
f.read_to_end(&mut bytes) f.read_to_end(&mut bytes)
.with_context(|| format!("While reading file `{}`", path.display()))?; .with_context(|| format!("while reading file `{}`", path.display()))?;
let img = image::load_from_memory(&bytes) let img = image::load_from_memory(&bytes)
.with_context(|| format!("While loading file `{}`", path.display()))?; .with_context(|| format!("while loading file `{}`", path.display()))?;
let image_dim = img.dimensions(); let image_dim = img.dimensions();
@ -102,7 +102,7 @@ impl AtlasSet {
} }
} }
if transparent_border { if transparent_border {
println!("[WARNING] {} wastes space with a transmparent border",); warn!("{} wastes space with a transmparent border",);
} }
*/ */

View File

@ -31,3 +31,4 @@ winit = { workspace = true }
wgpu = { workspace = true } wgpu = { workspace = true }
bytemuck = { workspace = true } bytemuck = { workspace = true }
glyphon = { workspace = true } glyphon = { workspace = true }
log = { workspace = true }

View File

@ -1,6 +1,7 @@
use crate::globaluniform::GlobalUniform; use crate::globaluniform::GlobalUniform;
// TODO: build script? // TODO: better preprocessor, build script?
// Not yet, this is ok for now.
/// Basic wgsl preprocesser /// Basic wgsl preprocesser
pub(crate) fn preprocess_shader( pub(crate) fn preprocess_shader(
shader: &str, shader: &str,

View File

@ -5,6 +5,7 @@ use galactica_content::Content;
use galactica_packer::SpriteAtlasImage; use galactica_packer::SpriteAtlasImage;
use galactica_util::constants::ASSET_CACHE; use galactica_util::constants::ASSET_CACHE;
use image::GenericImageView; use image::GenericImageView;
use log::info;
use std::{fs::File, io::Read, num::NonZeroU32, path::Path}; use std::{fs::File, io::Read, num::NonZeroU32, path::Path};
use wgpu::BindGroupLayout; use wgpu::BindGroupLayout;
@ -93,7 +94,7 @@ impl TextureArray {
let mut texture_data = Vec::new(); let mut texture_data = Vec::new();
for file in ct.atlas_files() { for file in ct.atlas_files() {
println!("opening {file}"); info!("opening {file}");
let p = Path::new(ASSET_CACHE); let p = Path::new(ASSET_CACHE);
let mut f = File::open(p.join(file))?; let mut f = File::open(p.join(file))?;
let mut bytes = Vec::new(); let mut bytes = Vec::new();
@ -108,7 +109,7 @@ impl TextureArray {
let mut image_locations = AtlasArray::zeroed(); let mut image_locations = AtlasArray::zeroed();
println!("sending to gpu"); info!("sending to gpu");
for image in ct.get_atlas().iter_images() { for image in ct.get_atlas().iter_images() {
image_locations.data[image.idx.get() as usize] = AtlasImageLocation { image_locations.data[image.idx.get() as usize] = AtlasImageLocation {
xpos: image.x, xpos: image.x,

View File

@ -122,7 +122,7 @@ impl Timing {
let f = self.physics_sim.as_secs_f32(); let f = self.physics_sim.as_secs_f32();
s.push_str(&format!("Phys {:6.00} fps\n", 1.0 / f)); s.push_str(&format!("Phys {:6.00} fps\n", 1.0 / f));
s.push_str(&format!( s.push_str(&format!(
"Step {:6.02}%\n", "Step {:5.02}%\n",
100.0 * self.physics_step.as_secs_f32() / f 100.0 * self.physics_step.as_secs_f32() / f
)); ));
s.push_str(&format!( s.push_str(&format!(