Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Bevy Splash
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Splash
Commits
19e0083c
Verified
Commit
19e0083c
authored
10 months ago
by
Louis
Browse files
Options
Downloads
Patches
Plain Diff
Lint + fmt
parent
09a697aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
rustfmt.toml
+3
-0
3 additions, 0 deletions
rustfmt.toml
src/components.rs
+2
-4
2 additions, 4 deletions
src/components.rs
src/lib.rs
+61
-62
61 additions, 62 deletions
src/lib.rs
src/system.rs
+4
-11
4 additions, 11 deletions
src/system.rs
with
70 additions
and
77 deletions
rustfmt.toml
0 → 100644
+
3
−
0
View file @
19e0083c
hard_tabs
=
true
use_field_init_shorthand
=
true
use_try_shorthand
=
true
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/components.rs
+
2
−
4
View file @
19e0083c
use
bevy_asset
::
Handle
;
use
micro_musicbox
::
prelude
::
AudioSource
;
use
std
::
fmt
::
Debug
;
use
std
::
ops
::{
Deref
,
DerefMut
};
use
std
::
time
::
Duration
;
use
bevy_asset
::
Handle
;
use
bevy_ecs
::
prelude
::
*
;
use
bevy_render
::
prelude
::
*
;
...
...
@@ -19,8 +19,6 @@ pub struct SplashStep {
step_type
:
SplashStepType
,
}
pub
type
SplashAnimation
=
Vec
<
SplashStep
>
;
#[derive(Resource)]
pub
struct
LogoHandle
(
pub
Handle
<
Image
>
);
impl
Deref
for
LogoHandle
{
...
...
@@ -74,4 +72,4 @@ impl DerefMut for SplashTime {
fn
deref_mut
(
&
mut
self
)
->
&
mut
Self
::
Target
{
&
mut
self
.0
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
src/lib.rs
+
61
−
62
View file @
19e0083c
#![allow(clippy::type_complexity)]
// use bevy::prelude::*;
use
std
::
time
::
Duration
;
use
bevy_app
::{
App
,
Plugin
,
Update
};
use
bevy_ecs
::
prelude
::
*
;
use
std
::
time
::
Duration
;
pub
use
crate
::
components
::
SplashSettings
;
use
crate
::
components
::{
SplashTime
,
TweenClearColor
};
...
...
@@ -13,85 +12,85 @@ mod system;
#[derive(Default,
Debug,
Resource)]
struct
SplashManager
{
elapsed
:
Duration
,
elapsed
:
Duration
,
}
#[derive(PartialOrd,
PartialEq,
Copy,
Clone,
Resource,
Default)]
pub
enum
SplashState
{
#[default]
Loading
,
Running
,
#[default]
Loading
,
Running
,
}
impl
SplashState
{
pub
fn
is_loading
(
&
self
)
->
bool
{
matches!
(
&
self
,
SplashState
::
Loading
)
}
pub
fn
is_running
(
&
self
)
->
bool
{
matches!
(
&
self
,
SplashState
::
Running
)
}
pub
fn
is_loading
(
&
self
)
->
bool
{
matches!
(
&
self
,
SplashState
::
Loading
)
}
pub
fn
is_running
(
&
self
)
->
bool
{
matches!
(
&
self
,
SplashState
::
Running
)
}
}
pub
fn
is_loading
(
state
:
Res
<
SplashState
>
)
->
bool
{
state
.is_loading
()
state
.is_loading
()
}
pub
fn
is_running
(
state
:
Res
<
SplashState
>
)
->
bool
{
state
.is_running
()
state
.is_running
()
}
pub
fn
started_running
(
state
:
Res
<
SplashState
>
)
->
bool
{
state
.is_changed
()
&&
state
.is_running
()
state
.is_changed
()
&&
state
.is_running
()
}
pub
struct
AdventSplashPlugin
<
StateType
:
States
>
{
settings
:
SplashSettings
<
StateType
>
,
settings
:
SplashSettings
<
StateType
>
,
}
impl
<
StateType
:
States
>
AdventSplashPlugin
<
StateType
>
{
pub
fn
with_settings
(
settings
:
SplashSettings
<
StateType
>
)
->
AdventSplashPlugin
<
StateType
>
{
Self
{
settings
}
}
pub
fn
with_settings
(
settings
:
SplashSettings
<
StateType
>
)
->
AdventSplashPlugin
<
StateType
>
{
Self
{
settings
}
}
}
impl
<
StateType
:
States
+
Copy
>
Plugin
for
AdventSplashPlugin
<
StateType
>
{
fn
build
(
&
self
,
app
:
&
mut
App
)
{
app
.init_resource
::
<
SplashState
>
()
.insert_resource
(
SplashTime
(
Duration
::
from_secs
(
5
)))
.insert_resource
(
self
.settings
.clone
())
.add_systems
(
OnEnter
(
self
.settings.run_in
),
system
::
load_assets
::
<
StateType
>
,
)
.add_systems
(
Update
,
system
::
monitor_asset_loading
.run_if
(
is_loading
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
system
::
spawn_splash_assets
::
<
StateType
>
.run_if
(
started_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
(
system
::
apply_window_scale
,
system
::
tick_time
::
<
StateType
>
)
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
system
::
tween_clear_color
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
))
.run_if
(
resource_exists
::
<
TweenClearColor
>
),
)
.add_systems
(
OnExit
(
self
.settings.run_in
),
system
::
cleanup_assets
);
fn
build
(
&
self
,
app
:
&
mut
App
)
{
app
.init_resource
::
<
SplashState
>
()
.insert_resource
(
SplashTime
(
Duration
::
from_secs
(
5
)))
.insert_resource
(
self
.settings
.clone
())
.add_systems
(
OnEnter
(
self
.settings.run_in
),
system
::
load_assets
::
<
StateType
>
,
)
.add_systems
(
Update
,
system
::
monitor_asset_loading
.run_if
(
is_loading
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
system
::
spawn_splash_assets
::
<
StateType
>
.run_if
(
started_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
(
system
::
apply_window_scale
,
system
::
tick_time
::
<
StateType
>
)
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
)
.add_systems
(
Update
,
system
::
tween_clear_color
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
))
.run_if
(
resource_exists
::
<
TweenClearColor
>
),
)
.add_systems
(
OnExit
(
self
.settings.run_in
),
system
::
cleanup_assets
);
if
self
.settings.skip_on_input
{
app
.add_systems
(
Update
,
system
::
window_skip
::
<
StateType
>
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
);
}
}
if
self
.settings.skip_on_input
{
app
.add_systems
(
Update
,
system
::
window_skip
::
<
StateType
>
.run_if
(
is_running
)
.run_if
(
in_state
(
self
.settings.run_in
)),
);
}
}
}
This diff is collapsed.
Click to expand it.
src/system.rs
+
4
−
11
View file @
19e0083c
...
...
@@ -3,11 +3,11 @@ use crate::components::{
};
use
crate
::
SplashState
;
use
micro_musicbox
::
prelude
::
MusicBox
;
use
std
::
ops
::
Deref
;
use
std
::
time
::
Duration
;
use
bevy_asset
::{
Asset
s
,
Asset
Server
,
Handle
,
LoadState
,
RecursiveDependencyLoadState
};
use
bevy_asset
::{
Asset
Server
,
Asset
s
,
Handle
,
LoadState
,
RecursiveDependencyLoadState
};
use
bevy_ecs
::
prelude
::
*
;
use
bevy_hierarchy
::
DespawnRecursiveExt
;
use
bevy_input
::
prelude
::
*
;
use
bevy_math
::
Vec2
;
use
bevy_render
::
prelude
::
*
;
...
...
@@ -15,7 +15,6 @@ use bevy_render::texture::ImageSampler;
use
bevy_sprite
::
prelude
::
*
;
use
bevy_time
::
Time
;
use
bevy_transform
::
prelude
::
Transform
;
use
bevy_hierarchy
::
DespawnRecursiveExt
;
use
log
::
error
;
...
...
@@ -127,14 +126,8 @@ pub fn tween_clear_color(
pub
fn
apply_window_scale
(
window_query
:
Query
<&
OrthographicProjection
>
,
mut
scaled_query
:
Query
<
(
&
mut
Transform
,
Option
<&
Handle
<
Image
>>
,
),
(
With
<
Handle
<
Image
>>
,
With
<
ScaleToWindow
>
,
),
(
&
mut
Transform
,
Option
<&
Handle
<
Image
>>
),
(
With
<
Handle
<
Image
>>
,
With
<
ScaleToWindow
>
),
>
,
images
:
Res
<
Assets
<
Image
>>
,
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment