M sdbclient/src/main.rs => sdbclient/src/main.rs +14 -0
@@ 18,6 18,8 @@ use bevy_mod_scripting::prelude::*;
use iyes_loopless::prelude::*;
+use belly::prelude::BellyPlugin;
+
mod api;
mod cfg;
mod constants;
@@ 77,6 79,8 @@ fn main() {
app.add_plugin(ScriptingPlugin).add_plugin(lua::LuaPlugin);
+ app.add_plugin(BellyPlugin);
+
app.insert_resource(cfg::CfgDirs(
directories::ProjectDirs::from("com", "liljamo", "deckbuilder")
.expect("failed to get project directories"),
@@ 109,3 113,13 @@ pub fn despawn_screen<T: Component>(to_despawn: Query<Entity, With<T>>, mut comm
commands.entity(entity).despawn_recursive();
}
}
+
+/// Utility function to remove UI nodes, which is usually just one node
+/// NOTE: So, UI shows up as just nodes that don't have parents, so this
+/// works mighty fine, at least for now.
+/// MAY break something in the future, but that's why this note is here.
+pub fn remove_ui(mut commands: Commands, nodes: Query<Entity, (With<Node>, Without<Parent>)>) {
+ for node in &nodes {
+ commands.entity(node).despawn_recursive();
+ }
+}
M => +2 -2
@@ 11,7 11,7 @@ use iyes_loopless::prelude::*;
use crate::cfg::CfgUser;
use crate::{despawn_screen, GameState};
use crate::{despawn_screen, remove_ui, GameState};
mod mainmenuscreen;
use mainmenuscreen::*;
@@ 73,7 73,7 @@ impl Plugin for MenuPlugin {
.add_exit_system(MenuState::AccountLoggedIn, despawn_screen::<OnAccountLoggedInScreen>)
// Systems for play screen
.add_enter_system(MenuState::Play, play_setup)
.add_exit_system(MenuState::Play, despawn_screen::<OnPlayScreen>)
.add_exit_system(MenuState::Play, remove_ui)
// Common systems
.add_system_set(
ConditionSet::new()
M => +20 -1
@@ 10,16 10,20 @@ use bevy::{
prelude::*,
ui::{JustifyContent, Size, Style, Val},
};
use iyes_loopless::prelude::*;
use belly::prelude::*;
use crate::constants::TEXT_COLOR;
use super::{MenuButtonAction, NORMAL_BUTTON};
use super::{MenuButtonAction, MenuState, NORMAL_BUTTON};
/// Tag component for tagging entities on the play screen
#[derive(Component)]
pub struct OnPlayScreen;
pub fn play_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
/*
let font = asset_server.load("fonts/FiraMono-Regular.ttf");
let button_style = Style {
@@ 35,7 39,21 @@ pub fn play_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
font_size: 40.0,
color: TEXT_COLOR,
};
*/
commands.add(eml! {
<body>
<div>
<button on:press=connect!(|ctx| {
ctx.commands().insert_resource(NextState(MenuState::Main))
})>
"Back"
</button>
</div>
</body>
});
/*
commands
.spawn((
NodeBundle {
@@ 99,4 117,5 @@ pub fn play_setup(mut commands: Commands, asset_server: Res<AssetServer>) {
}
});
});
*/
}