Skip to content

Commit

Permalink
Minor fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
spectria-limina committed Dec 5, 2024
1 parent 4d41a4d commit cd6f526
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 22 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
shared-key: "cargo"
- name: Build
run: cargo build --verbose
#- name: Test
# run: cargo test --verbose
- name: Test
run: cargo test --verbose
build-test-wasm:
runs-on: ubuntu-latest
env:
Expand All @@ -34,8 +34,8 @@ jobs:
run: rustup target add wasm32-unknown-unknown
- name: Build
run: cargo build --verbose --target wasm32-unknown-unknown
#- name: Test
# run: cargo test --verbose --target wasm32-unknown-unknown
- name: Test
run: cargo test --verbose --target wasm32-unknown-unknown
build-release-wasm:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
Expand Down Expand Up @@ -67,6 +67,7 @@ jobs:
with:
name: release-package
path: public
include-hidden-files: true
deploy-gh-pages:
needs:
- build-release-wasm
Expand Down
18 changes: 9 additions & 9 deletions assets/arenas/.listing
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,21 @@
"ultimate": {
"name": "Ultimate",
"subdirs": {
"tea": {
"name": "The Epic of Alexander",
"contents": [
"p1.arena.ron"
]
},
"fru": {
"name": "Futures Rewritten",
"contents": [
"i1.arena.ron",
"p1.arena.ron",
"p2.arena.ron",
"p3.arena.ron",
"p5.arena.ron",
"i1.arena.ron",
"p4.arena.ron"
"p4.arena.ron",
"p5.arena.ron"
]
},
"tea": {
"name": "The Epic of Alexander",
"contents": [
"p1.arena.ron"
]
}
}
Expand Down
18 changes: 17 additions & 1 deletion src/debug/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{prelude::*, utils::HashMap};

pub fn log_asset_events<A: Asset>(
mut reader: EventReader<AssetEvent<A>>,
Expand All @@ -25,3 +25,19 @@ pub fn log_events<E: Event + std::fmt::Debug>(mut reader: EventReader<E>) {
info!("asset event {ev:?}");
}
}

pub fn format_components(world: &World, id: Entity) -> String {
let mut names = vec![];
for cid in world.entity(id).archetype().components() {
names.push(world.components().get_info(cid).unwrap().name());
}
format!("{names:?}")
}

pub fn format_world(world: &World) -> String {
let mut m: HashMap<Entity, String> = HashMap::new();
for entity in world.iter_entities() {
m.insert(entity.id(), format_components(world, entity.id()));
}
format!("{m:#?}")
}
17 changes: 12 additions & 5 deletions src/spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ fn log_debug<E: std::fmt::Debug + Event>(mut events: EventReader<E>) {
}
}

fn observe_debug<E: std::fmt::Debug + Event>(ev: Trigger<E>) {
debug!("{:?} on {}", ev.event(), ev.entity());
}

#[cfg(test)]
mod test {
use super::*;
Expand All @@ -213,6 +217,8 @@ mod test {
use crate::{testing::*, widget};

use bevy::app::ScheduleRunnerPlugin;
use bevy::picking::pointer::Location;
use bevy::render::camera::{ManualTextureViewHandle, NormalizedRenderTarget};
use bevy::render::settings::{RenderCreation, WgpuSettings};
use bevy::render::RenderPlugin;
use bevy::window::PrimaryWindow;
Expand Down Expand Up @@ -277,7 +283,6 @@ mod test {
run_mode: bevy::app::RunMode::Loop { wait: None },
})
.add_plugins(EguiPlugin)
.add_plugins(DefaultPickingPlugins)
.add_plugins(crate::cursor::plugin())
.add_plugins(SpawnerPlugin::<Waymark>::default())
.add_systems(Startup, add_test_camera)
Expand All @@ -298,7 +303,7 @@ mod test {
}

#[test]
//#[ignore = "broken due to Drag imprecision"]
#[ignore = "broken since 0.15 for some reason: the drag ain't draggin'"]
fn spawner_drag() {
let (mut app, _) = test_app();

Expand All @@ -312,9 +317,9 @@ mod test {
duration: 10.0,
});
app.add_systems(Update, MockDrag::update)
.add_systems(Update, log_debug::<Pointer<DragStart>>)
.add_systems(Update, log_debug::<Pointer<Drag>>)
.add_systems(Update, log_debug::<Pointer<DragEnd>>)
.add_observer(observe_debug::<Pointer<DragStart>>)
.add_observer(observe_debug::<Pointer<Drag>>)
.add_observer(observe_debug::<Pointer<DragEnd>>)
.add_systems(Update, log_debug::<CursorMoved>)
.add_systems(Update, log_debug::<bevy::input::mouse::MouseButtonInput>)
.add_systems(First, || {
Expand All @@ -324,6 +329,8 @@ mod test {
app.update();
}

let id = app.world().iter_entities().next().unwrap().id();

let mut spawner_q = app
.world_mut()
.query_filtered::<(), With<Spawner<Waymark>>>();
Expand Down
7 changes: 4 additions & 3 deletions tools/tataru/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::{
collections::HashMap,
collections::{BTreeMap, HashMap},
fs::{self, read_dir},
io,
path::{Path, PathBuf},
Expand All @@ -22,8 +22,8 @@ pub static KNOWN_DIRS: LazyLock<HashMap<PathBuf, String>> = LazyLock::new(|| {
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
pub struct Listing {
pub name: String,
#[serde(skip_serializing_if = "HashMap::is_empty", default)]
pub subdirs: HashMap<String, Listing>,
#[serde(skip_serializing_if = "BTreeMap::is_empty", default)]
pub subdirs: BTreeMap<String, Listing>,
#[serde(skip_serializing_if = "Vec::is_empty", default)]
pub contents: Vec<String>,
}
Expand Down Expand Up @@ -93,5 +93,6 @@ pub fn generate_listing(
out.subdirs.insert(entry_name, subdir);
}
}
out.contents.sort();
Ok(out)
}

0 comments on commit cd6f526

Please sign in to comment.