/// Draw a UI for selecting levels
/// (very quick and dirty)
Draw a UI for selecting levels
(very quick and dirty)
Draw a UI for selecting levels ( very quick and dirty )
pub fn quick_level_ui(
  mut commands: Commands,
  mut gui: ResMut<EguiContext>,
  mut game_state: ResMut<State<GameState>>,
  levels: Query<(Entity, &AvailableLevel, Option<&CompletedLevel>)>,
) {
  let window = gui.ctx_mut().available_rect();
  egui::Window::new("Choose a level")
    .resizable(false)
    .collapsible(false)
    .fixed_pos((0., window.height() - window.height() / 3.))
    .show(gui.ctx_mut(), |ui| {
      ui.expand_to_include_x(window.width());
      ui.expand_to_include_y(window.height());
      ui.horizontal(|ui| {
        ui.label("Made with");
        ui.hyperlink_to("Bevy", "https://bevyengine.org/");
        ui.label("for the first official");
        ui.hyperlink_to("Bevy game jam.", "https://itch.io/jam/bevy-jam-1/entries");
        ui.label("Warning: game is very WIP.")
      });
      ui.add_space(10.);
      for (level_entity, level, is_complete) in levels.iter() {
        ui.horizontal(|ui| {
          if ui.button(level.name.as_str()).clicked() {
            game_state.set(GameState::Running).unwrap();
            commands.entity(level_entity).insert(CurrentLevel);
          }
          if is_complete.is_some() {
            // I love using emojis in my code!
            ui.label("✔️");
          }
        });
      }
    });
}
pub fn quick_level_ui ( mut commands : Commands , mut gui : ResMut < EguiContext > , mut game_state : ResMut < State < GameState > > , levels : Query < ( Entity , & AvailableLevel , Option < & CompletedLevel > ) > , ) { let window = gui . ctx_mut ( ) . available_rect ( ) ; egui :: Window :: new ( " " ) . resizable ( false ) . collapsible ( false ) . fixed_pos ( ( 0. , window . height ( ) - window . height ( ) / 3. ) ) . show ( gui . ctx_mut ( ) , | ui | { ui . expand_to_include_x ( window . width ( ) ) ; ui . expand_to_include_y ( window . height ( ) ) ; ui . horizontal ( | ui | { ui . label ( " " ) ; ui . hyperlink_to ( " " , " " ) ; ui . label ( " " ) ; ui . hyperlink_to ( " " , " " ) ; ui . label ( " " ) } ) ; ui . add_space ( 10. ) ; for ( level_entity , level , is_complete ) in levels . iter ( ) { ui . horizontal ( | ui | { if ui . button ( level . name . as_str ( ) ) . clicked ( ) { game_state . set ( GameState :: Running ) . unwrap ( ) ; commands . entity ( level_entity ) . insert ( CurrentLevel ) ; } if is_complete . is_some ( ) { // I love using emojis in my code! ui . label ( " } } ) ; } } ) ; }
Draw a UI for selecting levels
(very quick and dirty)
Draw a UI for selecting levels ( very quick and dirty )
commands
Commands
gui
ResMut<EguiContext>
game_state
ResMut<State<GameState>>
levels
Query<(Entity, &AvailableLevel, Option<&CompletedLevel>)>