build you shall
Browse files- src/app/main.rs +6 -8
- src/components/interactions.rs +1 -2
- src/components/mod.rs +20 -20
- src/entities/cat.rs +3 -3
- src/entities/cauldron.rs +3 -3
- src/entities/chest.rs +3 -3
- src/entities/dog.rs +3 -3
- src/entities/enemy.rs +2 -3
- src/entities/movingplatform.rs +3 -3
- src/entities/player.rs +2 -2
- src/entities/pumpkin.rs +3 -3
- src/entities/torch.rs +3 -3
- src/lib.rs +1 -0
- src/plugins/audio/delayed_audio_source.rs +10 -10
- src/plugins/debug.rs +20 -34
- src/plugins/dialogueview/mod.rs +6 -11
- src/plugins/dialogueview/option_selection.rs +10 -9
- src/plugins/dialogueview/setup.rs +5 -4
- src/plugins/gamestate.rs +3 -1
- src/plugins/input.rs +5 -4
- src/plugins/mod.rs +15 -15
- src/plugins/splashscreen/mod.rs +2 -1
- src/plugins/splashscreen/resources.rs +3 -1
- src/plugins/splashscreen/state.rs +1 -1
- src/plugins/splashscreen/systems.rs +2 -1
- src/plugins/ui/banner_widget.rs +16 -17
- src/plugins/ui/fps_widget.rs +17 -18
- src/plugins/ui/keycap.rs +3 -6
- src/plugins/ui/mod.rs +5 -6
- src/plugins/ui/release_label.rs +1 -1
src/app/main.rs
CHANGED
@@ -1,8 +1,8 @@
|
|
1 |
-
use separated;
|
2 |
-
|
3 |
// Turn clippy into a real bitch
|
4 |
#![warn(clippy::all, clippy::pedantic)]
|
5 |
|
|
|
|
|
6 |
// This changes the executable to a graphical application instead of a CLI one
|
7 |
// only for Release builds.
|
8 |
//#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
@@ -15,8 +15,6 @@ use seldom_state::prelude::*;
|
|
15 |
// bevy_rand
|
16 |
use bevy_rand::prelude::{ WyRand, EntropyPlugin, GlobalEntropy };
|
17 |
|
18 |
-
use plugins::gamestate::GameState;
|
19 |
-
|
20 |
use separated::plugins::gamestate::GameState;
|
21 |
use separated::components::settings::GameSettings;
|
22 |
use separated::plugins::ui::set_window_icon::set_window_icon;
|
@@ -58,10 +56,10 @@ use bevy_incandescent::{
|
|
58 |
//use bevy_hanabi::prelude::*;
|
59 |
|
60 |
// ⚠️ TODO: Move this with Game Settings
|
61 |
-
use separated::components::settings::GameSettings;
|
62 |
|
63 |
-
use separated::plugins::ui::set_window_icon::set_window_icon;
|
64 |
-
use separated::plugins::get_backend::get_backend;
|
65 |
// ⚠️ TODO: Move audio stuff to its own thing
|
66 |
|
67 |
// 🎲 - Random Number Generation
|
@@ -140,7 +138,7 @@ fn main() {
|
|
140 |
separated::plugins::audio::plugin,
|
141 |
separated::plugins::pathfinding::plugin,
|
142 |
StateMachinePlugin,
|
143 |
-
bevy_mod_aseprite::AsepritePlugin,
|
144 |
//IncandescentPlugin,
|
145 |
//HanabiPlugin,
|
146 |
))
|
|
|
|
|
|
|
1 |
// Turn clippy into a real bitch
|
2 |
#![warn(clippy::all, clippy::pedantic)]
|
3 |
|
4 |
+
use separated;
|
5 |
+
|
6 |
// This changes the executable to a graphical application instead of a CLI one
|
7 |
// only for Release builds.
|
8 |
//#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]
|
|
|
15 |
// bevy_rand
|
16 |
use bevy_rand::prelude::{ WyRand, EntropyPlugin, GlobalEntropy };
|
17 |
|
|
|
|
|
18 |
use separated::plugins::gamestate::GameState;
|
19 |
use separated::components::settings::GameSettings;
|
20 |
use separated::plugins::ui::set_window_icon::set_window_icon;
|
|
|
56 |
//use bevy_hanabi::prelude::*;
|
57 |
|
58 |
// ⚠️ TODO: Move this with Game Settings
|
59 |
+
// use separated::components::settings::GameSettings;
|
60 |
|
61 |
+
// use separated::plugins::ui::set_window_icon::set_window_icon;
|
62 |
+
// use separated::plugins::get_backend::get_backend;
|
63 |
// ⚠️ TODO: Move audio stuff to its own thing
|
64 |
|
65 |
// 🎲 - Random Number Generation
|
|
|
138 |
separated::plugins::audio::plugin,
|
139 |
separated::plugins::pathfinding::plugin,
|
140 |
StateMachinePlugin,
|
141 |
+
// bevy_mod_aseprite::AsepritePlugin,
|
142 |
//IncandescentPlugin,
|
143 |
//HanabiPlugin,
|
144 |
))
|
src/components/interactions.rs
CHANGED
@@ -2,7 +2,6 @@ use std::collections::HashSet;
|
|
2 |
|
3 |
use bevy::{
|
4 |
core::Name,
|
5 |
-
render::color::Color,
|
6 |
ecs::{
|
7 |
component::Component,
|
8 |
entity::Entity,
|
@@ -48,7 +47,7 @@ pub(crate) fn spawn_interaction_sensor(
|
|
48 |
#[cfg(feature = "dev_features")]
|
49 |
sensor_cmds.insert((
|
50 |
Name::new("interaction_sensor"),
|
51 |
-
bevy_rapier2d::render::ColliderDebugColor(
|
52 |
));
|
53 |
let child = sensor_cmds.id();
|
54 |
commands.add(PushChild { parent, child });
|
|
|
2 |
|
3 |
use bevy::{
|
4 |
core::Name,
|
|
|
5 |
ecs::{
|
6 |
component::Component,
|
7 |
entity::Entity,
|
|
|
47 |
#[cfg(feature = "dev_features")]
|
48 |
sensor_cmds.insert((
|
49 |
Name::new("interaction_sensor"),
|
50 |
+
bevy_rapier2d::render::ColliderDebugColor(bevy::color::palettes::css::GREEN.into()),
|
51 |
));
|
52 |
let child = sensor_cmds.id();
|
53 |
commands.add(PushChild { parent, child });
|
src/components/mod.rs
CHANGED
@@ -1,20 +1,20 @@
|
|
1 |
-
pub
|
2 |
-
pub
|
3 |
-
pub
|
4 |
-
pub
|
5 |
-
pub
|
6 |
-
pub
|
7 |
-
pub
|
8 |
-
pub
|
9 |
-
pub
|
10 |
-
pub
|
11 |
-
pub
|
12 |
-
pub
|
13 |
-
pub
|
14 |
-
pub
|
15 |
-
pub
|
16 |
-
pub
|
17 |
-
pub
|
18 |
-
pub
|
19 |
-
pub
|
20 |
-
pub
|
|
|
1 |
+
pub mod animals;
|
2 |
+
pub mod health;
|
3 |
+
pub mod collision;
|
4 |
+
pub mod ground;
|
5 |
+
pub mod items;
|
6 |
+
pub mod sensorbundle;
|
7 |
+
pub mod camera;
|
8 |
+
pub mod hunger;
|
9 |
+
pub mod armor;
|
10 |
+
pub mod predefinedpath;
|
11 |
+
pub mod animation;
|
12 |
+
pub mod settings;
|
13 |
+
pub mod interactions;
|
14 |
+
pub mod deathzone;
|
15 |
+
pub mod swimming;
|
16 |
+
pub mod climbing;
|
17 |
+
pub mod line_of_sight;
|
18 |
+
pub mod ai;
|
19 |
+
pub mod childof;
|
20 |
+
pub mod name;
|
src/entities/cat.rs
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::prelude::LdtkEntity;
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
use crate::components::animals::Animal;
|
@@ -35,7 +35,7 @@ impl Animal for Cat {
|
|
35 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
36 |
pub struct CatBundle {
|
37 |
#[sprite_sheet_bundle]
|
38 |
-
pub sprite_sheet_bundle:
|
39 |
#[from_entity_instance]
|
40 |
pub collider_bundle: ColliderBundle,
|
41 |
pub cat: Cat,
|
|
|
1 |
+
use bevy::ecs::{ bundle::Bundle, component::Component };
|
2 |
+
use bevy_ecs_ldtk::{ prelude::LdtkEntity, utils::LdtkSpriteSheetBundle };
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
use crate::components::animals::Animal;
|
|
|
35 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
36 |
pub struct CatBundle {
|
37 |
#[sprite_sheet_bundle]
|
38 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
39 |
#[from_entity_instance]
|
40 |
pub collider_bundle: ColliderBundle,
|
41 |
pub cat: Cat,
|
src/entities/cauldron.rs
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::LdtkEntity;
|
3 |
|
4 |
use super::ColliderBundle;
|
5 |
|
6 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
7 |
pub struct CauldronBundle {
|
8 |
#[sprite_sheet_bundle]
|
9 |
-
pub sprite_sheet_bundle:
|
10 |
#[from_entity_instance]
|
11 |
pub collider_bundle: ColliderBundle,
|
12 |
}
|
|
|
1 |
+
use bevy::ecs::bundle::Bundle;
|
2 |
+
use bevy_ecs_ldtk::{ utils::LdtkSpriteSheetBundle, LdtkEntity };
|
3 |
|
4 |
use super::ColliderBundle;
|
5 |
|
6 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
7 |
pub struct CauldronBundle {
|
8 |
#[sprite_sheet_bundle]
|
9 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
10 |
#[from_entity_instance]
|
11 |
pub collider_bundle: ColliderBundle,
|
12 |
}
|
src/entities/chest.rs
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::LdtkEntity;
|
3 |
|
4 |
use super::ColliderBundle;
|
5 |
|
6 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
7 |
pub struct ChestBundle {
|
8 |
#[sprite_sheet_bundle]
|
9 |
-
pub sprite_sheet_bundle:
|
10 |
#[from_entity_instance]
|
11 |
pub collider_bundle: ColliderBundle,
|
12 |
}
|
|
|
1 |
+
use bevy::ecs::bundle::Bundle;
|
2 |
+
use bevy_ecs_ldtk::{ utils::LdtkSpriteSheetBundle, LdtkEntity };
|
3 |
|
4 |
use super::ColliderBundle;
|
5 |
|
6 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
7 |
pub struct ChestBundle {
|
8 |
#[sprite_sheet_bundle]
|
9 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
10 |
#[from_entity_instance]
|
11 |
pub collider_bundle: ColliderBundle,
|
12 |
}
|
src/entities/dog.rs
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::prelude::LdtkEntity;
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
use crate::components::animals::Animal;
|
@@ -35,7 +35,7 @@ impl Animal for Dog {
|
|
35 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
36 |
pub struct DogBundle {
|
37 |
#[sprite_sheet_bundle]
|
38 |
-
pub sprite_sheet_bundle:
|
39 |
#[from_entity_instance]
|
40 |
pub collider_bundle: ColliderBundle,
|
41 |
pub dog: Dog,
|
|
|
1 |
+
use bevy::ecs::{ bundle::Bundle, component::Component };
|
2 |
+
use bevy_ecs_ldtk::{ prelude::LdtkEntity, utils::LdtkSpriteSheetBundle };
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
use crate::components::animals::Animal;
|
|
|
35 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
36 |
pub struct DogBundle {
|
37 |
#[sprite_sheet_bundle]
|
38 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
39 |
#[from_entity_instance]
|
40 |
pub collider_bundle: ColliderBundle,
|
41 |
pub dog: Dog,
|
src/entities/enemy.rs
CHANGED
@@ -6,11 +6,10 @@ use bevy::{
|
|
6 |
system::{ In, Query, Res },
|
7 |
query::With,
|
8 |
},
|
9 |
-
sprite::SpriteSheetBundle,
|
10 |
time::Time,
|
11 |
transform::components::Transform,
|
12 |
};
|
13 |
-
use bevy_ecs_ldtk::{ prelude::LdtkEntity, EntityInstance };
|
14 |
use seldom_state::{ prelude::StateMachine, trigger::IntoTrigger as _ };
|
15 |
|
16 |
use super::{ ColliderBundle, PredefinedPath };
|
@@ -22,7 +21,7 @@ pub struct Enemy;
|
|
22 |
#[derive(Default, Bundle, LdtkEntity)]
|
23 |
pub struct EnemyBundle {
|
24 |
#[sprite_sheet_bundle]
|
25 |
-
pub sprite_sheet_bundle:
|
26 |
#[from_entity_instance]
|
27 |
pub collider_bundle: ColliderBundle,
|
28 |
pub enemy: Enemy,
|
|
|
6 |
system::{ In, Query, Res },
|
7 |
query::With,
|
8 |
},
|
|
|
9 |
time::Time,
|
10 |
transform::components::Transform,
|
11 |
};
|
12 |
+
use bevy_ecs_ldtk::{ prelude::LdtkEntity, utils::LdtkSpriteSheetBundle, EntityInstance };
|
13 |
use seldom_state::{ prelude::StateMachine, trigger::IntoTrigger as _ };
|
14 |
|
15 |
use super::{ ColliderBundle, PredefinedPath };
|
|
|
21 |
#[derive(Default, Bundle, LdtkEntity)]
|
22 |
pub struct EnemyBundle {
|
23 |
#[sprite_sheet_bundle]
|
24 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
25 |
#[from_entity_instance]
|
26 |
pub collider_bundle: ColliderBundle,
|
27 |
pub enemy: Enemy,
|
src/entities/movingplatform.rs
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::prelude::LdtkEntity;
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
|
@@ -9,7 +9,7 @@ pub struct MovingPlatform;
|
|
9 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
10 |
pub struct MovingPlatformBundle {
|
11 |
#[sprite_sheet_bundle]
|
12 |
-
pub sprite_sheet_bundle:
|
13 |
#[from_entity_instance]
|
14 |
pub collider_bundle: ColliderBundle,
|
15 |
#[ldtk_entity]
|
|
|
1 |
+
use bevy::ecs::{ bundle::Bundle, component::Component };
|
2 |
+
use bevy_ecs_ldtk::{ prelude::LdtkEntity, utils::LdtkSpriteSheetBundle };
|
3 |
|
4 |
use super::{ ColliderBundle, PredefinedPath };
|
5 |
|
|
|
9 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
10 |
pub struct MovingPlatformBundle {
|
11 |
#[sprite_sheet_bundle]
|
12 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
13 |
#[from_entity_instance]
|
14 |
pub collider_bundle: ColliderBundle,
|
15 |
#[ldtk_entity]
|
src/entities/player.rs
CHANGED
@@ -85,13 +85,13 @@ pub fn draw_health_bar(mut gizmos: Gizmos, query: Query<(&GlobalTransform, &Play
|
|
85 |
let end = start + Vec3::new(bar_width, 0.0, 0.0);
|
86 |
|
87 |
// Draw the background (red) bar
|
88 |
-
gizmos.line_2d(start.truncate(), end.truncate(),
|
89 |
|
90 |
// Draw the foreground (green) bar based on health
|
91 |
gizmos.line_2d(
|
92 |
start.truncate(),
|
93 |
(start + Vec3::new(bar_width * health_ratio, 0.0, 0.0)).truncate(),
|
94 |
-
|
95 |
);
|
96 |
}
|
97 |
}
|
|
|
85 |
let end = start + Vec3::new(bar_width, 0.0, 0.0);
|
86 |
|
87 |
// Draw the background (red) bar
|
88 |
+
gizmos.line_2d(start.truncate(), end.truncate(), bevy::color::palettes::css::RED);
|
89 |
|
90 |
// Draw the foreground (green) bar based on health
|
91 |
gizmos.line_2d(
|
92 |
start.truncate(),
|
93 |
(start + Vec3::new(bar_width * health_ratio, 0.0, 0.0)).truncate(),
|
94 |
+
bevy::color::palettes::css::GREEN
|
95 |
);
|
96 |
}
|
97 |
}
|
src/entities/pumpkin.rs
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
use bevy::{ ecs::component::Component, prelude::Bundle
|
2 |
-
use bevy_ecs_ldtk::LdtkEntity;
|
3 |
|
4 |
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Component)]
|
5 |
pub struct Pumpkin;
|
@@ -8,5 +8,5 @@ pub struct Pumpkin;
|
|
8 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
9 |
pub struct PumpkinBundle {
|
10 |
#[sprite_sheet_bundle(no_grid)]
|
11 |
-
pub sprite_sheet_bundle:
|
12 |
}
|
|
|
1 |
+
use bevy::{ ecs::component::Component, prelude::Bundle };
|
2 |
+
use bevy_ecs_ldtk::{ utils::LdtkSpriteSheetBundle, LdtkEntity };
|
3 |
|
4 |
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Component)]
|
5 |
pub struct Pumpkin;
|
|
|
8 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
9 |
pub struct PumpkinBundle {
|
10 |
#[sprite_sheet_bundle(no_grid)]
|
11 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
12 |
}
|
src/entities/torch.rs
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
-
use bevy::
|
2 |
-
use bevy_ecs_ldtk::{ EntityInstance, LdtkEntity };
|
3 |
|
4 |
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Component)]
|
5 |
pub struct Torch;
|
@@ -7,7 +7,7 @@ pub struct Torch;
|
|
7 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
8 |
pub struct TorchBundle {
|
9 |
#[sprite_sheet_bundle]
|
10 |
-
pub sprite_sheet_bundle:
|
11 |
pub torch: Torch,
|
12 |
#[from_entity_instance]
|
13 |
pub instance: EntityInstance,
|
|
|
1 |
+
use bevy::ecs::{ bundle::Bundle, component::Component };
|
2 |
+
use bevy_ecs_ldtk::{ utils::LdtkSpriteSheetBundle, EntityInstance, LdtkEntity };
|
3 |
|
4 |
#[derive(Copy, Clone, Eq, PartialEq, Debug, Default, Component)]
|
5 |
pub struct Torch;
|
|
|
7 |
#[derive(Clone, Default, Bundle, LdtkEntity)]
|
8 |
pub struct TorchBundle {
|
9 |
#[sprite_sheet_bundle]
|
10 |
+
pub sprite_sheet_bundle: LdtkSpriteSheetBundle,
|
11 |
pub torch: Torch,
|
12 |
#[from_entity_instance]
|
13 |
pub instance: EntityInstance,
|
src/lib.rs
CHANGED
@@ -1,3 +1,4 @@
|
|
1 |
pub mod components;
|
2 |
pub mod entities;
|
3 |
pub mod plugins;
|
|
|
|
1 |
pub mod components;
|
2 |
pub mod entities;
|
3 |
pub mod plugins;
|
4 |
+
pub mod systems;
|
src/plugins/audio/delayed_audio_source.rs
CHANGED
@@ -1,7 +1,6 @@
|
|
1 |
use std::time::Duration;
|
2 |
|
3 |
-
use bevy::{ audio::
|
4 |
-
use rodio::source::{ Delay, Repeat, Source };
|
5 |
|
6 |
/// An asset type that warps an audio source for adding a delay and infinite
|
7 |
/// repeats (private to this module)
|
@@ -11,13 +10,13 @@ struct DelayedAudioSource {
|
|
11 |
delay: Duration,
|
12 |
}
|
13 |
|
14 |
-
impl Decodable for DelayedAudioSource {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
}
|
21 |
|
22 |
/// Component that gets converted to an AudioBundle
|
23 |
#[derive(Component)]
|
@@ -74,7 +73,8 @@ fn convert_delayed_settings_to_audio_bundle(
|
|
74 |
|
75 |
/// Setup an audio source type for DelayedAudioSource
|
76 |
pub(super) fn plugin(app: &mut App) {
|
77 |
-
app.add_audio_source::<DelayedAudioSource>()
|
|
|
78 |
PostUpdate,
|
79 |
// bevy_audios's AudioPlaySet (sadly private) runs after
|
80 |
// TransformSystem::TransformPropagate, so we run before that to ensure
|
|
|
1 |
use std::time::Duration;
|
2 |
|
3 |
+
use bevy::{ audio::PlaybackMode, prelude::*, transform::TransformSystem };
|
|
|
4 |
|
5 |
/// An asset type that warps an audio source for adding a delay and infinite
|
6 |
/// repeats (private to this module)
|
|
|
10 |
delay: Duration,
|
11 |
}
|
12 |
|
13 |
+
// impl Decodable for DelayedAudioSource {
|
14 |
+
// type DecoderItem = <AudioSource as Decodable>::DecoderItem;
|
15 |
+
// type Decoder = Delay<Repeat<<AudioSource as Decodable>::Decoder>>;
|
16 |
+
// fn decoder(&self) -> Self::Decoder {
|
17 |
+
// self.source.decoder().repeat_infinite().delay(self.delay)
|
18 |
+
// }
|
19 |
+
// }
|
20 |
|
21 |
/// Component that gets converted to an AudioBundle
|
22 |
#[derive(Component)]
|
|
|
73 |
|
74 |
/// Setup an audio source type for DelayedAudioSource
|
75 |
pub(super) fn plugin(app: &mut App) {
|
76 |
+
// app.add_audio_source::<DelayedAudioSource>()
|
77 |
+
app.add_systems(
|
78 |
PostUpdate,
|
79 |
// bevy_audios's AudioPlaySet (sadly private) runs after
|
80 |
// TransformSystem::TransformPropagate, so we run before that to ensure
|
src/plugins/debug.rs
CHANGED
@@ -1,22 +1,15 @@
|
|
1 |
/// this code is compiled only if debug assertions are enabled (debug mode)
|
2 |
//use graphviz_rust::{ cmd::{ CommandArg, Format }, exec_dot };
|
3 |
-
use bevy::
|
4 |
-
|
5 |
-
|
6 |
-
};
|
7 |
-
use bevy_inspector_egui::quick::WorldInspectorPlugin;
|
8 |
-
use bevy_rapier2d::{prelude::RapierDebugRenderPlugin, render::DebugRenderContext};
|
9 |
-
|
10 |
-
use super::{
|
11 |
-
gamestate::GameState,
|
12 |
-
ui::fps_widget::{spawn_fps_widget, FpsWidget},
|
13 |
-
};
|
14 |
use crate::components::childof::debug_children;
|
15 |
|
16 |
// Adds L key as debug KeyCode for toggling physics wireframes.
|
17 |
pub fn toggle_physics_wireframes(
|
18 |
mut ctx: ResMut<DebugRenderContext>,
|
19 |
-
input: Res<ButtonInput<KeyCode
|
20 |
) {
|
21 |
if input.just_pressed(KeyCode::F9) {
|
22 |
ctx.enabled = !ctx.enabled;
|
@@ -27,38 +20,32 @@ pub fn disable_physics_wireframes(mut ctx: ResMut<DebugRenderContext>) {
|
|
27 |
ctx.enabled = false;
|
28 |
}
|
29 |
|
30 |
-
pub
|
31 |
// Plugins
|
32 |
app.add_plugins((
|
33 |
// FpsWidget
|
34 |
super::ui::fps_widget::plugin,
|
35 |
// WorldInspectorPlugin
|
36 |
-
WorldInspectorPlugin::default().run_if(input_toggle_active(false, KeyCode::F11)),
|
37 |
// RapierDebugRenderPlugin
|
38 |
RapierDebugRenderPlugin::default(),
|
39 |
// StateInspectorPlugin
|
40 |
-
|
41 |
-
|
42 |
-
),
|
43 |
));
|
44 |
|
45 |
// Startup
|
46 |
-
app.add_systems(
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
disable_physics_wireframes,
|
53 |
-
),
|
54 |
-
);
|
55 |
|
56 |
// Update
|
57 |
// FpsWidget
|
58 |
-
app.add_systems(
|
59 |
-
Update,
|
60 |
-
spawn_fps_widget.run_if(not(any_with_component::<FpsWidget>)),
|
61 |
-
);
|
62 |
// DebugRenderContext - Rapier
|
63 |
app.add_systems(Update, toggle_physics_wireframes);
|
64 |
|
@@ -69,12 +56,11 @@ pub(crate) fn plugin(app: &mut App) {
|
|
69 |
*/
|
70 |
}
|
71 |
|
72 |
-
pub
|
73 |
bevy::log::LogPlugin {
|
74 |
level: bevy::log::Level::DEBUG,
|
75 |
-
filter: "info,big_brain=debug,one_off=debug,separated=debug,wgpu_core=warn,wgpu_hal=warn"
|
76 |
-
|
77 |
-
update_subscriber: None,
|
78 |
}
|
79 |
}
|
80 |
|
|
|
1 |
/// this code is compiled only if debug assertions are enabled (debug mode)
|
2 |
//use graphviz_rust::{ cmd::{ CommandArg, Format }, exec_dot };
|
3 |
+
use bevy::prelude::*;
|
4 |
+
use bevy_rapier2d::{ prelude::RapierDebugRenderPlugin, render::DebugRenderContext };
|
5 |
+
|
6 |
+
use super::ui::fps_widget::{ spawn_fps_widget, FpsWidget };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
use crate::components::childof::debug_children;
|
8 |
|
9 |
// Adds L key as debug KeyCode for toggling physics wireframes.
|
10 |
pub fn toggle_physics_wireframes(
|
11 |
mut ctx: ResMut<DebugRenderContext>,
|
12 |
+
input: Res<ButtonInput<KeyCode>>
|
13 |
) {
|
14 |
if input.just_pressed(KeyCode::F9) {
|
15 |
ctx.enabled = !ctx.enabled;
|
|
|
20 |
ctx.enabled = false;
|
21 |
}
|
22 |
|
23 |
+
pub fn plugin(app: &mut App) {
|
24 |
// Plugins
|
25 |
app.add_plugins((
|
26 |
// FpsWidget
|
27 |
super::ui::fps_widget::plugin,
|
28 |
// WorldInspectorPlugin
|
29 |
+
//WorldInspectorPlugin::default().run_if(input_toggle_active(false, KeyCode::F11)),
|
30 |
// RapierDebugRenderPlugin
|
31 |
RapierDebugRenderPlugin::default(),
|
32 |
// StateInspectorPlugin
|
33 |
+
// StateInspectorPlugin::<GameState>::default().run_if(
|
34 |
+
// bevy::input::common_conditions::input_toggle_active(false, KeyCode::F10),
|
35 |
+
// ),
|
36 |
));
|
37 |
|
38 |
// Startup
|
39 |
+
app.add_systems(Startup, (
|
40 |
+
// Debug all parent and child elements with the Name component.
|
41 |
+
debug_children,
|
42 |
+
// Disable wireframes by default. I've seen enough collision boxes for now.
|
43 |
+
disable_physics_wireframes,
|
44 |
+
));
|
|
|
|
|
|
|
45 |
|
46 |
// Update
|
47 |
// FpsWidget
|
48 |
+
app.add_systems(Update, spawn_fps_widget.run_if(not(any_with_component::<FpsWidget>)));
|
|
|
|
|
|
|
49 |
// DebugRenderContext - Rapier
|
50 |
app.add_systems(Update, toggle_physics_wireframes);
|
51 |
|
|
|
56 |
*/
|
57 |
}
|
58 |
|
59 |
+
pub fn make_log_plugin() -> impl Plugin {
|
60 |
bevy::log::LogPlugin {
|
61 |
level: bevy::log::Level::DEBUG,
|
62 |
+
filter: "info,big_brain=debug,one_off=debug,separated=debug,wgpu_core=warn,wgpu_hal=warn".into(),
|
63 |
+
custom_layer: |_| None,
|
|
|
64 |
}
|
65 |
}
|
66 |
|
src/plugins/dialogueview/mod.rs
CHANGED
@@ -24,18 +24,13 @@ mod updating;
|
|
24 |
use bevy::{
|
25 |
app::{ App, Plugin, Update },
|
26 |
asset::Handle,
|
27 |
-
log::info,
|
28 |
ecs::{
|
29 |
-
schedule::{
|
30 |
-
SystemSet,
|
31 |
-
IntoSystemConfigs,
|
32 |
-
Condition,
|
33 |
-
States,
|
34 |
-
common_conditions::{ in_state, resource_added },
|
35 |
-
},
|
36 |
system::{ Commands, Res, Resource },
|
37 |
},
|
|
|
38 |
render::texture::Image,
|
|
|
39 |
text::Font,
|
40 |
};
|
41 |
use bevy_asset_loader::{
|
@@ -45,7 +40,7 @@ use bevy_asset_loader::{
|
|
45 |
use bevy_yarnspinner::prelude::{ YarnFileSource, YarnSpinnerPlugin, YarnProject };
|
46 |
|
47 |
pub use updating::SpeakerChangeEvent;
|
48 |
-
pub(crate) use typewriter::
|
49 |
|
50 |
/// The plugin registering all systems of the dialogue view.
|
51 |
#[derive(Debug, Default)]
|
@@ -71,7 +66,7 @@ struct Assets {
|
|
71 |
edge: Handle<Image>,
|
72 |
}
|
73 |
|
74 |
-
impl<T: States> Plugin for YarnSpinnerDialogueViewPlugin<T> {
|
75 |
fn build(&self, app: &mut App) {
|
76 |
app.add_plugins(
|
77 |
YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file("dialogues/test_dialog.yarn"))
|
@@ -96,7 +91,7 @@ impl<T: States> Plugin for YarnSpinnerDialogueViewPlugin<T> {
|
|
96 |
fn spawn_dialogue_runner(mut commands: Commands, project: Res<YarnProject>) {
|
97 |
info!("Starting dialogue runner.");
|
98 |
// Create a dialogue runner from the project.
|
99 |
-
let
|
100 |
// ⚠️ TODO: Only run dialogues on interaction!
|
101 |
//dialogue_runner.start_node("Start");
|
102 |
commands.spawn(dialogue_runner);
|
|
|
24 |
use bevy::{
|
25 |
app::{ App, Plugin, Update },
|
26 |
asset::Handle,
|
|
|
27 |
ecs::{
|
28 |
+
schedule::{ common_conditions::resource_added, Condition, IntoSystemConfigs, SystemSet },
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
system::{ Commands, Res, Resource },
|
30 |
},
|
31 |
+
log::info,
|
32 |
render::texture::Image,
|
33 |
+
state::{ condition::in_state, state::{ FreelyMutableState, States } },
|
34 |
text::Font,
|
35 |
};
|
36 |
use bevy_asset_loader::{
|
|
|
40 |
use bevy_yarnspinner::prelude::{ YarnFileSource, YarnSpinnerPlugin, YarnProject };
|
41 |
|
42 |
pub use updating::SpeakerChangeEvent;
|
43 |
+
pub(crate) use typewriter::not_in_dialogue;
|
44 |
|
45 |
/// The plugin registering all systems of the dialogue view.
|
46 |
#[derive(Debug, Default)]
|
|
|
66 |
edge: Handle<Image>,
|
67 |
}
|
68 |
|
69 |
+
impl<T: States + FreelyMutableState> Plugin for YarnSpinnerDialogueViewPlugin<T> {
|
70 |
fn build(&self, app: &mut App) {
|
71 |
app.add_plugins(
|
72 |
YarnSpinnerPlugin::with_yarn_source(YarnFileSource::file("dialogues/test_dialog.yarn"))
|
|
|
91 |
fn spawn_dialogue_runner(mut commands: Commands, project: Res<YarnProject>) {
|
92 |
info!("Starting dialogue runner.");
|
93 |
// Create a dialogue runner from the project.
|
94 |
+
let dialogue_runner = project.create_dialogue_runner();
|
95 |
// ⚠️ TODO: Only run dialogues on interaction!
|
96 |
//dialogue_runner.start_node("Start");
|
97 |
commands.spawn(dialogue_runner);
|
src/plugins/dialogueview/option_selection.rs
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
use bevy::{
|
2 |
app::{ App, Update },
|
|
|
3 |
ecs::{
|
4 |
entity::Entity,
|
5 |
-
|
|
|
6 |
schedule::{
|
7 |
-
|
8 |
Condition,
|
9 |
-
|
10 |
},
|
11 |
-
|
12 |
-
event::{ Event, EventReader, EventWriter },
|
13 |
},
|
14 |
hierarchy::{ Children, DespawnRecursiveExt, HierarchyQueryExt },
|
|
|
15 |
reflect::Reflect,
|
16 |
-
render::
|
17 |
text::Text,
|
18 |
ui::{ widget::Button, Display, Interaction, Style },
|
19 |
utils::HashMap,
|
20 |
-
input::{ ButtonInput, keyboard::KeyCode },
|
21 |
window::{ CursorIcon, PrimaryWindow, Window },
|
22 |
};
|
23 |
use bevy_yarnspinner::{
|
@@ -131,10 +132,10 @@ fn select_option(
|
|
131 |
let (color, icon) = match *interaction {
|
132 |
Interaction::Pressed if selection.is_none() => {
|
133 |
selection = Some(button.0);
|
134 |
-
(
|
135 |
}
|
136 |
Interaction::Hovered => (Color::WHITE, CursorIcon::Pointer),
|
137 |
-
_ => (
|
138 |
};
|
139 |
window.cursor.icon = icon;
|
140 |
let text_entity = children
|
|
|
1 |
use bevy::{
|
2 |
app::{ App, Update },
|
3 |
+
color::Color,
|
4 |
ecs::{
|
5 |
entity::Entity,
|
6 |
+
event::{ Event, EventReader, EventWriter },
|
7 |
+
query::{ Changed, With, Without },
|
8 |
schedule::{
|
9 |
+
common_conditions::{ any_with_component, resource_added, resource_exists },
|
10 |
Condition,
|
11 |
+
IntoSystemConfigs,
|
12 |
},
|
13 |
+
system::{ Commands, Query, Res, Resource },
|
|
|
14 |
},
|
15 |
hierarchy::{ Children, DespawnRecursiveExt, HierarchyQueryExt },
|
16 |
+
input::{ keyboard::KeyCode, ButtonInput },
|
17 |
reflect::Reflect,
|
18 |
+
render::view::Visibility,
|
19 |
text::Text,
|
20 |
ui::{ widget::Button, Display, Interaction, Style },
|
21 |
utils::HashMap,
|
|
|
22 |
window::{ CursorIcon, PrimaryWindow, Window },
|
23 |
};
|
24 |
use bevy_yarnspinner::{
|
|
|
132 |
let (color, icon) = match *interaction {
|
133 |
Interaction::Pressed if selection.is_none() => {
|
134 |
selection = Some(button.0);
|
135 |
+
(bevy::color::palettes::css::TOMATO.into(), CursorIcon::Default)
|
136 |
}
|
137 |
Interaction::Hovered => (Color::WHITE, CursorIcon::Pointer),
|
138 |
+
_ => (bevy::color::palettes::css::TOMATO.into(), CursorIcon::Default),
|
139 |
};
|
140 |
window.cursor.icon = icon;
|
141 |
let text_entity = children
|
src/plugins/dialogueview/setup.rs
CHANGED
@@ -1,9 +1,10 @@
|
|
1 |
use bevy::{
|
|
|
2 |
core::Name,
|
3 |
ecs::system::EntityCommands,
|
4 |
hierarchy::BuildChildren,
|
5 |
prelude::{ default, Commands, Component, Res },
|
6 |
-
render::
|
7 |
text::{ Text, TextSection, TextStyle },
|
8 |
ui::{
|
9 |
node_bundles::{ ButtonBundle, ImageBundle, NodeBundle, TextBundle },
|
@@ -125,7 +126,7 @@ pub(crate) fn setup(mut commands: Commands, assets: Res<Assets>) {
|
|
125 |
padding: UiRect::horizontal(Val::Px(TEXT_BORDER)),
|
126 |
..default()
|
127 |
},
|
128 |
-
background_color: Color::BLACK.
|
129 |
..default()
|
130 |
},
|
131 |
))
|
@@ -325,7 +326,7 @@ mod text_style {
|
|
325 |
|
326 |
pub(crate) fn option_id(assets: &Assets) -> TextStyle {
|
327 |
TextStyle {
|
328 |
-
color:
|
329 |
..option_text(assets)
|
330 |
}
|
331 |
}
|
@@ -333,7 +334,7 @@ mod text_style {
|
|
333 |
pub(crate) fn option_text(assets: &Assets) -> TextStyle {
|
334 |
TextStyle {
|
335 |
font_size: 18.0,
|
336 |
-
color:
|
337 |
..standard(assets)
|
338 |
}
|
339 |
}
|
|
|
1 |
use bevy::{
|
2 |
+
color::{ Alpha, Color },
|
3 |
core::Name,
|
4 |
ecs::system::EntityCommands,
|
5 |
hierarchy::BuildChildren,
|
6 |
prelude::{ default, Commands, Component, Res },
|
7 |
+
render::view::Visibility,
|
8 |
text::{ Text, TextSection, TextStyle },
|
9 |
ui::{
|
10 |
node_bundles::{ ButtonBundle, ImageBundle, NodeBundle, TextBundle },
|
|
|
126 |
padding: UiRect::horizontal(Val::Px(TEXT_BORDER)),
|
127 |
..default()
|
128 |
},
|
129 |
+
background_color: Color::BLACK.with_alpha(0.8).into(),
|
130 |
..default()
|
131 |
},
|
132 |
))
|
|
|
326 |
|
327 |
pub(crate) fn option_id(assets: &Assets) -> TextStyle {
|
328 |
TextStyle {
|
329 |
+
color: bevy::color::palettes::css::ALICE_BLUE.into(),
|
330 |
..option_text(assets)
|
331 |
}
|
332 |
}
|
|
|
334 |
pub(crate) fn option_text(assets: &Assets) -> TextStyle {
|
335 |
TextStyle {
|
336 |
font_size: 18.0,
|
337 |
+
color: bevy::color::palettes::css::TOMATO.into(),
|
338 |
..standard(assets)
|
339 |
}
|
340 |
}
|
src/plugins/gamestate.rs
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
use bevy::{
|
2 |
app::App,
|
|
|
3 |
log::info,
|
4 |
math::Vec2,
|
5 |
prelude::{ OnEnter, States },
|
6 |
reflect::Reflect,
|
7 |
-
render::
|
|
|
8 |
};
|
9 |
use bevy_asset_loader::{
|
10 |
loading_state::{ LoadingState, LoadingStateAppExt },
|
|
|
1 |
use bevy::{
|
2 |
app::App,
|
3 |
+
color::Color,
|
4 |
log::info,
|
5 |
math::Vec2,
|
6 |
prelude::{ OnEnter, States },
|
7 |
reflect::Reflect,
|
8 |
+
render::camera::ScalingMode,
|
9 |
+
state::app::AppExtStates as _,
|
10 |
};
|
11 |
use bevy_asset_loader::{
|
12 |
loading_state::{ LoadingState, LoadingStateAppExt },
|
src/plugins/input.rs
CHANGED
@@ -4,22 +4,23 @@ use bevy::{
|
|
4 |
ecs::{
|
5 |
bundle::Bundle,
|
6 |
component::Component,
|
7 |
-
schedule::{
|
8 |
system::{ Query, Res },
|
9 |
},
|
10 |
input::{ gamepad::GamepadButtonType, keyboard::KeyCode, mouse::MouseButton },
|
11 |
log::info,
|
12 |
reflect::Reflect,
|
|
|
13 |
time::{ Real, Time },
|
14 |
utils::default,
|
15 |
};
|
16 |
use bevy_rapier2d::dynamics::Velocity;
|
17 |
use leafwing_input_manager::{
|
18 |
-
input_map::InputMap,
|
19 |
action_state::{ ActionData, ActionState },
|
20 |
-
|
21 |
input_processing::WithDualAxisProcessingPipelineExt,
|
22 |
plugin::{ InputManagerPlugin, InputManagerSystem },
|
|
|
23 |
};
|
24 |
pub use leafwing_input_manager::Actionlike;
|
25 |
|
@@ -79,7 +80,7 @@ impl<A: Actionlike> Default for InputBundle<A> {
|
|
79 |
pub(crate) fn make_action_map<Ability: Actionlike>(
|
80 |
abilities: HashMap<u8, Ability>
|
81 |
) -> InputBundle<Ability> {
|
82 |
-
let dual_axis_pad =
|
83 |
// You can configure a processing pipeline to handle axis-like user inputs.
|
84 |
//
|
85 |
// This step adds a circular deadzone that normalizes input values
|
|
|
4 |
ecs::{
|
5 |
bundle::Bundle,
|
6 |
component::Component,
|
7 |
+
schedule::{ Condition, IntoSystemConfigs as _ },
|
8 |
system::{ Query, Res },
|
9 |
},
|
10 |
input::{ gamepad::GamepadButtonType, keyboard::KeyCode, mouse::MouseButton },
|
11 |
log::info,
|
12 |
reflect::Reflect,
|
13 |
+
state::condition::in_state,
|
14 |
time::{ Real, Time },
|
15 |
utils::default,
|
16 |
};
|
17 |
use bevy_rapier2d::dynamics::Velocity;
|
18 |
use leafwing_input_manager::{
|
|
|
19 |
action_state::{ ActionData, ActionState },
|
20 |
+
input_map::InputMap,
|
21 |
input_processing::WithDualAxisProcessingPipelineExt,
|
22 |
plugin::{ InputManagerPlugin, InputManagerSystem },
|
23 |
+
user_input::KeyboardVirtualDPad,
|
24 |
};
|
25 |
pub use leafwing_input_manager::Actionlike;
|
26 |
|
|
|
80 |
pub(crate) fn make_action_map<Ability: Actionlike>(
|
81 |
abilities: HashMap<u8, Ability>
|
82 |
) -> InputBundle<Ability> {
|
83 |
+
let dual_axis_pad = KeyboardVirtualDPad::WASD
|
84 |
// You can configure a processing pipeline to handle axis-like user inputs.
|
85 |
//
|
86 |
// This step adds a circular deadzone that normalizes input values
|
src/plugins/mod.rs
CHANGED
@@ -1,21 +1,21 @@
|
|
1 |
-
pub
|
2 |
-
pub
|
3 |
-
pub
|
4 |
-
pub
|
5 |
-
pub
|
6 |
-
pub
|
7 |
-
pub
|
8 |
-
pub
|
9 |
-
pub
|
10 |
-
pub
|
11 |
-
pub
|
12 |
|
13 |
-
#[cfg(feature="dev_features")]
|
14 |
-
pub
|
15 |
|
16 |
/// this code is compiled only if debug assertions are disabled (release mode)
|
17 |
-
#[cfg(not(feature="dev_features"))]
|
18 |
-
pub
|
19 |
pub fn plugin(_app: &mut bevy::app::App) {}
|
20 |
|
21 |
pub(crate) fn make_log_plugin() -> impl bevy::app::Plugin {
|
|
|
1 |
+
pub mod ldtk;
|
2 |
+
pub mod splashscreen;
|
3 |
+
pub mod dialogueview;
|
4 |
+
pub mod gamestate;
|
5 |
+
pub mod input;
|
6 |
+
pub mod ui;
|
7 |
+
pub mod easing;
|
8 |
+
pub mod get_backend;
|
9 |
+
pub mod rapier_utils;
|
10 |
+
pub mod audio;
|
11 |
+
pub mod pathfinding;
|
12 |
|
13 |
+
#[cfg(feature = "dev_features")]
|
14 |
+
pub mod debug;
|
15 |
|
16 |
/// this code is compiled only if debug assertions are disabled (release mode)
|
17 |
+
#[cfg(not(feature = "dev_features"))]
|
18 |
+
pub mod debug {
|
19 |
pub fn plugin(_app: &mut bevy::app::App) {}
|
20 |
|
21 |
pub(crate) fn make_log_plugin() -> impl bevy::app::Plugin {
|
src/plugins/splashscreen/mod.rs
CHANGED
@@ -6,6 +6,7 @@ pub(crate) mod systems;
|
|
6 |
use bevy::{
|
7 |
app::{ App, Plugin, Update },
|
8 |
prelude::{ in_state, Condition, IntoSystemConfigs, OnEnter, OnExit, States },
|
|
|
9 |
};
|
10 |
use bevy_asset_loader::loading_state::{
|
11 |
config::ConfigureLoadingState,
|
@@ -23,7 +24,7 @@ use self::{
|
|
23 |
|
24 |
pub struct SplashScreenPlugin<T: States + Clone>(pub SplashScreenConfiguration<T>);
|
25 |
|
26 |
-
impl<T: States + Clone> Plugin for SplashScreenPlugin<T> {
|
27 |
fn build(&self, app: &mut App) {
|
28 |
app.init_state::<SplashScreenState>();
|
29 |
|
|
|
6 |
use bevy::{
|
7 |
app::{ App, Plugin, Update },
|
8 |
prelude::{ in_state, Condition, IntoSystemConfigs, OnEnter, OnExit, States },
|
9 |
+
state::{ app::AppExtStates as _, state::FreelyMutableState },
|
10 |
};
|
11 |
use bevy_asset_loader::loading_state::{
|
12 |
config::ConfigureLoadingState,
|
|
|
24 |
|
25 |
pub struct SplashScreenPlugin<T: States + Clone>(pub SplashScreenConfiguration<T>);
|
26 |
|
27 |
+
impl<T: States + FreelyMutableState + Clone> Plugin for SplashScreenPlugin<T> {
|
28 |
fn build(&self, app: &mut App) {
|
29 |
app.init_state::<SplashScreenState>();
|
30 |
|
src/plugins/splashscreen/resources.rs
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
use bevy::{
|
2 |
asset::Handle,
|
|
|
3 |
math::Vec2,
|
4 |
prelude::{ Resource, States },
|
5 |
-
render::{ camera::ScalingMode,
|
|
|
6 |
};
|
7 |
use bevy_asset_loader::{
|
8 |
asset_collection::AssetCollection,
|
|
|
1 |
use bevy::{
|
2 |
asset::Handle,
|
3 |
+
color::Color,
|
4 |
math::Vec2,
|
5 |
prelude::{ Resource, States },
|
6 |
+
render::{ camera::ScalingMode, texture::Image },
|
7 |
+
ecs::change_detection::Res,
|
8 |
};
|
9 |
use bevy_asset_loader::{
|
10 |
asset_collection::AssetCollection,
|
src/plugins/splashscreen/state.rs
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
use bevy::
|
2 |
|
3 |
/// Controls the flow of our plugin
|
4 |
#[derive(States, Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
|
|
1 |
+
use bevy::state::state::States;
|
2 |
|
3 |
/// Controls the flow of our plugin
|
4 |
#[derive(States, Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
|
src/plugins/splashscreen/systems.rs
CHANGED
@@ -4,6 +4,7 @@ use bevy::{
|
|
4 |
prelude::{ Camera2dBundle, Commands, Entity, NextState, Query, Res, ResMut, States, With },
|
5 |
render::{ camera::{ Camera, ClearColorConfig, OrthographicProjection }, texture::Image },
|
6 |
sprite::{ Sprite, SpriteBundle },
|
|
|
7 |
time::{ Time, Timer, TimerMode },
|
8 |
};
|
9 |
use bevy_asset_loader::dynamic_asset::DynamicAssets;
|
@@ -58,7 +59,7 @@ pub fn on_exit(
|
|
58 |
splash_screen_state.set(SplashScreenState::Idle);
|
59 |
}
|
60 |
|
61 |
-
pub fn update_splash_screen<T: States + Clone>(
|
62 |
mut commands: Commands,
|
63 |
time: Res<Time>,
|
64 |
splash_screen_configuration: Res<SplashScreenConfiguration<T>>,
|
|
|
4 |
prelude::{ Camera2dBundle, Commands, Entity, NextState, Query, Res, ResMut, States, With },
|
5 |
render::{ camera::{ Camera, ClearColorConfig, OrthographicProjection }, texture::Image },
|
6 |
sprite::{ Sprite, SpriteBundle },
|
7 |
+
state::state::FreelyMutableState,
|
8 |
time::{ Time, Timer, TimerMode },
|
9 |
};
|
10 |
use bevy_asset_loader::dynamic_asset::DynamicAssets;
|
|
|
59 |
splash_screen_state.set(SplashScreenState::Idle);
|
60 |
}
|
61 |
|
62 |
+
pub fn update_splash_screen<T: States + Clone + FreelyMutableState>(
|
63 |
mut commands: Commands,
|
64 |
time: Res<Time>,
|
65 |
splash_screen_configuration: Res<SplashScreenConfiguration<T>>,
|
src/plugins/ui/banner_widget.rs
CHANGED
@@ -1,22 +1,24 @@
|
|
1 |
use bevy::{
|
|
|
2 |
ecs::system::EntityCommands,
|
3 |
prelude::{ Component, Entity },
|
4 |
-
render::color::Color,
|
5 |
ui::{ node_bundles::ImageBundle, AlignSelf, JustifyContent, PositionType, Val },
|
6 |
};
|
7 |
use sickle_ui::{
|
|
|
8 |
ui_builder::{ UiBuilder, UiRoot },
|
9 |
ui_commands::SetTextExt,
|
10 |
ui_style::{
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
18 |
},
|
19 |
-
widgets::{ container::UiContainerExt, label::{ LabelConfig, UiLabelExt } },
|
20 |
};
|
21 |
|
22 |
use crate::plugins::ui::set::{ SetFont, SetPosition };
|
@@ -51,15 +53,12 @@ impl BannerWidgetConfig {
|
|
51 |
}
|
52 |
}
|
53 |
|
54 |
-
pub trait UiBannerWidgetExt
|
55 |
-
fn banner_widget
|
56 |
}
|
57 |
|
58 |
-
impl
|
59 |
-
fn banner_widget<'
|
60 |
-
&'a mut self,
|
61 |
-
config: BannerWidgetConfig
|
62 |
-
) -> UiBuilder<'w, 's, 'a, Entity> {
|
63 |
self.container((ImageBundle::default(), BannerWidget), |banner| {
|
64 |
banner
|
65 |
.style()
|
@@ -69,7 +68,7 @@ impl<'w, 's> UiBannerWidgetExt<'w, 's> for UiBuilder<'w, 's, '_, UiRoot> {
|
|
69 |
.width(Val::Px(100.0))
|
70 |
.height(Val::Px(12.0))
|
71 |
// Add a nice looking background image to our widget.
|
72 |
-
.image("ui/label_gradient_transparent.png");
|
73 |
|
74 |
// And we'll want a customizable label on the banner.
|
75 |
let mut label = banner.label(LabelConfig::default());
|
|
|
1 |
use bevy::{
|
2 |
+
color::Color,
|
3 |
ecs::system::EntityCommands,
|
4 |
prelude::{ Component, Entity },
|
|
|
5 |
ui::{ node_bundles::ImageBundle, AlignSelf, JustifyContent, PositionType, Val },
|
6 |
};
|
7 |
use sickle_ui::{
|
8 |
+
prelude::{ LabelConfig, UiContainerExt as _, UiLabelExt as _ },
|
9 |
ui_builder::{ UiBuilder, UiRoot },
|
10 |
ui_commands::SetTextExt,
|
11 |
ui_style::{
|
12 |
+
generated::{
|
13 |
+
SetAlignSelfExt as _,
|
14 |
+
SetHeightExt as _,
|
15 |
+
SetJustifyContentExt as _,
|
16 |
+
SetPositionTypeExt as _,
|
17 |
+
SetTopExt as _,
|
18 |
+
SetWidthExt as _,
|
19 |
+
},
|
20 |
+
manual::SetImageExt as _,
|
21 |
},
|
|
|
22 |
};
|
23 |
|
24 |
use crate::plugins::ui::set::{ SetFont, SetPosition };
|
|
|
53 |
}
|
54 |
}
|
55 |
|
56 |
+
pub trait UiBannerWidgetExt {
|
57 |
+
fn banner_widget(&mut self, config: BannerWidgetConfig) -> UiBuilder<'_, Entity>;
|
58 |
}
|
59 |
|
60 |
+
impl UiBannerWidgetExt for UiBuilder<'_, UiRoot> {
|
61 |
+
fn banner_widget(&mut self, config: BannerWidgetConfig) -> UiBuilder<'_, Entity> {
|
|
|
|
|
|
|
62 |
self.container((ImageBundle::default(), BannerWidget), |banner| {
|
63 |
banner
|
64 |
.style()
|
|
|
68 |
.width(Val::Px(100.0))
|
69 |
.height(Val::Px(12.0))
|
70 |
// Add a nice looking background image to our widget.
|
71 |
+
.image("ui/label_gradient_transparent.png".into());
|
72 |
|
73 |
// And we'll want a customizable label on the banner.
|
74 |
let mut label = banner.label(LabelConfig::default());
|
src/plugins/ui/fps_widget.rs
CHANGED
@@ -1,24 +1,23 @@
|
|
1 |
use bevy::{
|
2 |
app::{ App, Update },
|
|
|
3 |
ecs::{ component::Component, entity::Entity, query::With, system::{ Commands, Query, Res } },
|
4 |
-
render::color::Color,
|
5 |
text::TextStyle,
|
6 |
ui::{ node_bundles::NodeBundle, JustifyContent, PositionType, Val },
|
7 |
};
|
8 |
|
9 |
use bevy::{ asset::AssetServer, diagnostic::{ DiagnosticsStore, FrameTimeDiagnosticsPlugin } };
|
10 |
use sickle_ui::{
|
11 |
-
|
|
|
12 |
ui_commands::SetTextExt,
|
13 |
-
ui_style::{
|
14 |
-
SetBackgroundColorExt,
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
SetNodeTopExt,
|
20 |
},
|
21 |
-
widgets::{ container::UiContainerExt, label::{ LabelConfig, UiLabelExt } },
|
22 |
};
|
23 |
|
24 |
pub fn plugin(app: &mut App) {
|
@@ -31,12 +30,12 @@ pub struct FpsWidget;
|
|
31 |
#[derive(Component, Default)]
|
32 |
struct FpsText;
|
33 |
|
34 |
-
pub trait UiFPSWidgetExt
|
35 |
-
fn fps
|
36 |
}
|
37 |
|
38 |
-
impl
|
39 |
-
fn fps
|
40 |
self.container((NodeBundle::default(), FpsWidget), |fps| {
|
41 |
fps.style()
|
42 |
.position_type(PositionType::Absolute)
|
@@ -74,17 +73,17 @@ fn update_fps(
|
|
74 |
// Target frame rate for 60 Hz monitors is actually slightly less than 60,
|
75 |
// so we round down slightly to avoid flickering under happy circumstances.
|
76 |
let text_color = if smoothed_fps > 59.5 {
|
77 |
-
|
78 |
} else if smoothed_fps > 30.0 {
|
79 |
-
|
80 |
} else {
|
81 |
-
|
82 |
};
|
83 |
|
84 |
let text_style = TextStyle {
|
85 |
font: asset_server.load("fonts/bahnschrift.ttf"),
|
86 |
font_size: 12.0,
|
87 |
-
color: text_color,
|
88 |
};
|
89 |
|
90 |
commands.entity(label).set_text(format!("{:3.0}", smoothed_fps), text_style.into());
|
|
|
1 |
use bevy::{
|
2 |
app::{ App, Update },
|
3 |
+
color::{ palettes, Color },
|
4 |
ecs::{ component::Component, entity::Entity, query::With, system::{ Commands, Query, Res } },
|
|
|
5 |
text::TextStyle,
|
6 |
ui::{ node_bundles::NodeBundle, JustifyContent, PositionType, Val },
|
7 |
};
|
8 |
|
9 |
use bevy::{ asset::AssetServer, diagnostic::{ DiagnosticsStore, FrameTimeDiagnosticsPlugin } };
|
10 |
use sickle_ui::{
|
11 |
+
prelude::{ LabelConfig, UiContainerExt as _, UiLabelExt as _ },
|
12 |
+
ui_builder::{ UiBuilder, UiBuilderExt as _, UiRoot },
|
13 |
ui_commands::SetTextExt,
|
14 |
+
ui_style::generated::{
|
15 |
+
SetBackgroundColorExt as _,
|
16 |
+
SetJustifyContentExt as _,
|
17 |
+
SetPositionTypeExt as _,
|
18 |
+
SetRightExt as _,
|
19 |
+
SetTopExt as _,
|
|
|
20 |
},
|
|
|
21 |
};
|
22 |
|
23 |
pub fn plugin(app: &mut App) {
|
|
|
30 |
#[derive(Component, Default)]
|
31 |
struct FpsText;
|
32 |
|
33 |
+
pub trait UiFPSWidgetExt {
|
34 |
+
fn fps(&mut self) -> UiBuilder<'_, Entity>;
|
35 |
}
|
36 |
|
37 |
+
impl UiFPSWidgetExt for UiBuilder<'_, UiRoot> {
|
38 |
+
fn fps(&mut self) -> UiBuilder<'_, Entity> {
|
39 |
self.container((NodeBundle::default(), FpsWidget), |fps| {
|
40 |
fps.style()
|
41 |
.position_type(PositionType::Absolute)
|
|
|
73 |
// Target frame rate for 60 Hz monitors is actually slightly less than 60,
|
74 |
// so we round down slightly to avoid flickering under happy circumstances.
|
75 |
let text_color = if smoothed_fps > 59.5 {
|
76 |
+
palettes::css::GREEN
|
77 |
} else if smoothed_fps > 30.0 {
|
78 |
+
palettes::css::YELLOW
|
79 |
} else {
|
80 |
+
palettes::css::RED
|
81 |
};
|
82 |
|
83 |
let text_style = TextStyle {
|
84 |
font: asset_server.load("fonts/bahnschrift.ttf"),
|
85 |
font_size: 12.0,
|
86 |
+
color: text_color.into(),
|
87 |
};
|
88 |
|
89 |
commands.entity(label).set_text(format!("{:3.0}", smoothed_fps), text_style.into());
|
src/plugins/ui/keycap.rs
CHANGED
@@ -47,14 +47,11 @@ impl KeycapWidgetConfig {
|
|
47 |
}
|
48 |
|
49 |
pub trait UiKeycapWidgetExt<'w, 's> {
|
50 |
-
fn keycap_widget<'a>(&'a mut self, config: KeycapWidgetConfig) -> UiBuilder<'
|
51 |
}
|
52 |
|
53 |
-
impl<'w, 's> UiKeycapWidgetExt<'w, 's> for UiBuilder<'
|
54 |
-
fn keycap_widget<'a>(
|
55 |
-
&'a mut self,
|
56 |
-
config: KeycapWidgetConfig
|
57 |
-
) -> UiBuilder<'w, 's, 'a, Entity> {
|
58 |
self.container((ImageBundle::default(), KeycapWidget), |keycap| {
|
59 |
keycap
|
60 |
.style()
|
|
|
47 |
}
|
48 |
|
49 |
pub trait UiKeycapWidgetExt<'w, 's> {
|
50 |
+
fn keycap_widget<'a>(&'a mut self, config: KeycapWidgetConfig) -> UiBuilder<'_, Entity>;
|
51 |
}
|
52 |
|
53 |
+
impl<'w, 's> UiKeycapWidgetExt<'w, 's> for UiBuilder<'_, UiRoot> {
|
54 |
+
fn keycap_widget<'a>(&'a mut self, config: KeycapWidgetConfig) -> UiBuilder<'_, Entity> {
|
|
|
|
|
|
|
55 |
self.container((ImageBundle::default(), KeycapWidget), |keycap| {
|
56 |
keycap
|
57 |
.style()
|
src/plugins/ui/mod.rs
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
use bevy::prelude::*;
|
2 |
|
3 |
-
use aery::prelude::*;
|
4 |
use release_label::release_label;
|
5 |
use tooltip::spawn_tooltip;
|
6 |
|
@@ -14,9 +13,9 @@ pub(crate) mod fps_widget;
|
|
14 |
// Rewrite with shapes?
|
15 |
//pub(crate) mod keycap;
|
16 |
//pub(crate) mod keycap_demo;
|
17 |
-
pub
|
18 |
-
pub
|
19 |
-
pub
|
20 |
mod tooltip;
|
21 |
|
22 |
/*
|
@@ -31,9 +30,9 @@ use crate::plugins::ui::flying::flying_labels;
|
|
31 |
use crate::plugins::ui::keycap_demo::keycap_demo;
|
32 |
*/
|
33 |
|
34 |
-
pub
|
35 |
// Resources
|
36 |
-
app.insert_resource(ClearColor(
|
37 |
// Startup
|
38 |
//.add_systems(Startup, keycap_demo)
|
39 |
.add_systems(Startup, release_label)
|
|
|
1 |
use bevy::prelude::*;
|
2 |
|
|
|
3 |
use release_label::release_label;
|
4 |
use tooltip::spawn_tooltip;
|
5 |
|
|
|
13 |
// Rewrite with shapes?
|
14 |
//pub(crate) mod keycap;
|
15 |
//pub(crate) mod keycap_demo;
|
16 |
+
pub mod release_label;
|
17 |
+
pub mod set;
|
18 |
+
pub mod set_window_icon;
|
19 |
mod tooltip;
|
20 |
|
21 |
/*
|
|
|
30 |
use crate::plugins::ui::keycap_demo::keycap_demo;
|
31 |
*/
|
32 |
|
33 |
+
pub fn plugin(app: &mut bevy::app::App) {
|
34 |
// Resources
|
35 |
+
app.insert_resource(ClearColor(bevy::color::palettes::css::DARK_GRAY.into()))
|
36 |
// Startup
|
37 |
//.add_systems(Startup, keycap_demo)
|
38 |
.add_systems(Startup, release_label)
|
src/plugins/ui/release_label.rs
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
use bevy::prelude::*;
|
2 |
use sickle_ui::{
|
3 |
ui_builder::{ UiBuilderExt, UiRoot },
|
4 |
-
ui_style::{
|
5 |
};
|
6 |
|
7 |
use super::banner_widget::{ BannerWidgetConfig, UiBannerWidgetExt };
|
|
|
1 |
use bevy::prelude::*;
|
2 |
use sickle_ui::{
|
3 |
ui_builder::{ UiBuilderExt, UiRoot },
|
4 |
+
ui_style::generated::{ SetBottomExt as _, SetLeftExt as _ },
|
5 |
};
|
6 |
|
7 |
use super::banner_widget::{ BannerWidgetConfig, UiBannerWidgetExt };
|