Skip to content
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.

Commit

Permalink
Dialog UI refactor (#172)
Browse files Browse the repository at this point in the history
* Using new dialog assets

* Fixed glitching camera in elevator cutscene

* Made loading screen GIFs bigger (closes #168) 

* Fixed patrolling behavior by removing timeout (closes #165)

* Dialog options can be picked with mouse (closes #81)

* We no longer want the space button atlas in dialog (closes #18)
  • Loading branch information
porkbrain authored May 26, 2024
1 parent dad3318 commit 84972d5
Show file tree
Hide file tree
Showing 28 changed files with 500 additions and 260 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
key: ${{ runner.os }}-cargo-check-${{ hashFiles('**/Cargo.toml') }}
- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly-2024-03-22
toolchain: nightly-2024-05-25
components: rustfmt, clippy
- name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev
Expand Down
11 changes: 0 additions & 11 deletions bevy_magic_light_2d/src/gi/resource.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
use bevy::prelude::*;
#[cfg(feature = "egui")]
use bevy_inspector_egui::prelude::ReflectInspectorOptions;
#[cfg(feature = "egui")]
use bevy_inspector_egui::InspectorOptions;

use crate::gi::{constants::GI_SCREEN_PROBE_SIZE, util};

Expand All @@ -26,32 +22,25 @@ pub struct BevyMagicLight2DSettings {

#[rustfmt::skip]
#[derive(Reflect, Copy, Clone, Debug)]
#[cfg_attr(feature = "egui", derive(InspectorOptions))]
#[cfg_attr(feature = "egui", reflect(InspectorOptions))]
pub struct LightPassParams {

/// Number of previous frames to keep in the reservoir.
#[cfg_attr(feature = "egui", inspector(min = 1, max = 64))]
pub reservoir_size: u32,

/// Size of the bilateral filter kernel used to smooth/denoise
/// irradiance values.
pub smooth_kernel_size: (u32, u32),

/// How much of the final light contribution should be direct light.
#[cfg_attr(feature = "egui", inspector(min = 0.0, max = 1.0))]
pub direct_light_contrib: f32,

/// How much of the final light contribution should be indirect light.
#[cfg_attr(feature = "egui", inspector(min = 0.0, max = 1.0))]
pub indirect_light_contrib: f32,

/// Number of rays to cast when sampling the indirect light
/// from direct light irradiance map.
#[cfg_attr(feature = "egui", inspector(min = 0, max = 512))]
pub indirect_rays_per_sample: i32,

#[cfg_attr(feature = "egui", inspector(min = 1.0, max = 100.0))]
pub indirect_rays_radius_factor: f32,
}

Expand Down
3 changes: 3 additions & 0 deletions common/action/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ edition.workspace = true
bevy.workspace = true
leafwing-input-manager.workspace = true
strum.workspace = true

[features]
devtools = []
57 changes: 57 additions & 0 deletions common/action/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,27 @@ pub enum GlobalAction {
/// This is mainly relevant for actions of gathering information about the
/// world.
Inspect,

/// Numeric input for zero.
NumZero,
/// Numeric input for one.
NumOne,
/// Numeric input for two.
NumTwo,
/// Numeric input for three.
NumThree,
/// Numeric input for four.
NumFour,
/// Numeric input for five.
NumFive,
/// Numeric input for six.
NumSix,
/// Numeric input for seven.
NumSeven,
/// Numeric input for eight.
NumEight,
/// Numeric input for nine.
NumNine,
}

/// Runs a system if cancel action is being held.
Expand Down Expand Up @@ -133,6 +154,16 @@ pub fn move_action_pressed(
}
}

/// Any numeric key is being held.
pub fn numeric_key_pressed(
) -> impl FnMut(Res<ActionState<GlobalAction>>) -> bool {
move |action_state: Res<ActionState<GlobalAction>>| {
GlobalAction::numerical()
.into_iter()
.any(|action| action_state.pressed(&action))
}
}

/// Any movement action was just pressed.
pub fn move_action_just_pressed(
) -> impl FnMut(Res<ActionState<GlobalAction>>) -> bool {
Expand Down Expand Up @@ -173,6 +204,22 @@ impl GlobalAction {
)
}

/// Returns all numeric actions from zero to nine.
pub fn numerical() -> Vec<Self> {
vec![
Self::NumZero,
Self::NumOne,
Self::NumTwo,
Self::NumThree,
Self::NumFour,
Self::NumFive,
Self::NumSix,
Self::NumSeven,
Self::NumEight,
Self::NumNine,
]
}

fn input_map() -> InputMap<Self> {
let mut input_map = InputMap::default();

Expand Down Expand Up @@ -226,6 +273,16 @@ impl GlobalAction {
Chord(vec![Kbd(ArrowUp), Kbd(ArrowRight)]),
],
Self::Inspect => vec![Single(Kbd(AltLeft))],
Self::NumZero => vec![Single(Kbd(Digit0))],
Self::NumOne => vec![Single(Kbd(Digit1))],
Self::NumTwo => vec![Single(Kbd(Digit2))],
Self::NumThree => vec![Single(Kbd(Digit3))],
Self::NumFour => vec![Single(Kbd(Digit4))],
Self::NumFive => vec![Single(Kbd(Digit5))],
Self::NumSix => vec![Single(Kbd(Digit6))],
Self::NumSeven => vec![Single(Kbd(Digit7))],
Self::NumEight => vec![Single(Kbd(Digit8))],
Self::NumNine => vec![Single(Kbd(Digit9))],
}
}
}
13 changes: 3 additions & 10 deletions common/assets/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@ pub mod meditation {
"meditation/textures/polpo/videos/vampire.webp";
}

pub mod dialog {
pub const FOLDER: &str = "dialog";

pub const DIALOG_BUBBLE: &str = "dialog/bubble.png";
pub const DIALOG_CHOICE: &str = "dialog/choice.png";
pub const DIALOG_CHOICE_HIGHLIGHTED: &str = "dialog/choice_highlighted.png";
}

pub mod portraits {
use bevy::math::Vec2;

Expand Down Expand Up @@ -117,8 +109,9 @@ pub mod misc {
pub mod ui {
use bevy::math::Vec2;

pub const HEARTBEAT_ATLAS: &str = "hud/heartbeat_atlas.png";
pub const TIME_ATLAS: &str = "hud/time_atlas.png";
pub const DIALOG_BOX: &str = "ui/dialog_box.png";
pub const HEARTBEAT_ATLAS: &str = "ui/hud/heartbeat_atlas.png";
pub const TIME_ATLAS: &str = "ui/hud/time_atlas.png";

pub const HEARTBEAT_ATLAS_SIZE: Vec2 = Vec2::splat(70.0);
}
20 changes: 11 additions & 9 deletions common/loading_screen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use bevy::{
math::vec3, prelude::*, render::view::RenderLayers, utils::Instant,
};
use common_visuals::{
camera::{order, render_layer, PIXEL_ZOOM},
camera::{order, render_layer},
PRIMARY_COLOR,
};

Expand All @@ -32,6 +32,8 @@ pub const DEFAULT_FADE_LOADING_SCREEN_IN: Duration = Duration::from_millis(400);
/// Fast fade out is the default, can be changed in [`LoadingScreenSettings`].
pub const DEFAULT_FADE_LOADING_SCREEN_OUT: Duration =
Duration::from_millis(100);
/// How many times to scale the original loading image.
pub const LOADING_IMAGE_TRANSFORM_SCALE: f32 = 5.0;

/// A state machine where the states are the steps of the loading screen.
/// They are executed in order and loop back to the beginning.
Expand All @@ -55,20 +57,20 @@ pub enum LoadingScreenState {
/// 4.
FadeInQuadWhileBgLoading,
/// 5. Wait
/// 6. Set visibility of the image to visible
/// (if no bg image go to [`LoadingScreenState::StareAtLoadingScreen`])
/// 6. Set visibility of the image to visible (if no bg image go to
/// [`LoadingScreenState::StareAtLoadingScreen`])
WaitForAtlasToLoad,
/// 7. Fades out and sets the state to
/// [`LoadingScreenState::StareAtLoadingScreen`].
/// (skipped if no bg image)
/// [`LoadingScreenState::StareAtLoadingScreen`]. (skipped if no bg
/// image)
FadeOutQuadToShowAtlas,
/// 8. If requested, stay on this screen for given amount of time before
/// transitioning to [`LoadingScreenState::WaitForSignalToFinish`].
StareAtLoadingScreen,
/// 9. Now we wait for the loading to be done, user must [`finish_state`].
WaitForSignalToFinish,
/// 10. Fade in
/// (if no bg image go to [`LoadingScreenState::FadeOutQuadToShowGame`])
/// 10. Fade in (if no bg image go to
/// [`LoadingScreenState::FadeOutQuadToShowGame`])
FadeInQuadToRemoveAtlas,
/// 11.
/// (skipped if no bg image)
Expand Down Expand Up @@ -292,8 +294,8 @@ fn spawn_loading_screen(
asset_server.load(atlas.asset_path()),
),
transform: Transform::from_scale(vec3(
PIXEL_ZOOM as f32,
PIXEL_ZOOM as f32,
LOADING_IMAGE_TRANSFORM_SCALE,
LOADING_IMAGE_TRANSFORM_SCALE,
1.0,
)),
..default()
Expand Down
20 changes: 19 additions & 1 deletion common/story/src/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ pub struct StartDialogWhenLoaded {
/// Node name uniquely identifies a node across all dialogs.
/// This is achieved by having namespaces (represent files) and node names or
/// auto-generated node names.
#[derive(Debug, Reflect, Clone, Hash, PartialEq, Eq, Default)]
#[derive(Reflect, Clone, Hash, PartialEq, Eq, Default)]
pub enum NodeName {
/// This node has been explicitly named in the dialog file.
/// If a node is explicitly named, other nodes can refer to it.
Expand Down Expand Up @@ -852,3 +852,21 @@ impl Default for Dialog {
}
}
}

impl std::fmt::Debug for NodeName {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Explicit(namespace, name) => {
write!(f, "{:?}::{:?}", namespace, name)
}
Self::Auto(namespace, index) => {
write!(f, "{:?}::auto_{:?}", namespace, index)
}
Self::NamespaceRoot(namespace) => {
write!(f, "{:?}::_root", namespace)
}
Self::Root => write!(f, "_root"),
Self::EndDialog => write!(f, "_end_dialog"),
}
}
}
Loading

0 comments on commit 84972d5

Please sign in to comment.