/// Called everytime there is a window event
Called everytime there is a window event
Called everytime there is a window event
pub(super) fn event(
        &mut self,
        e: piston::input::Event,
        config: &Config,
        _audio: &audio::Audio,
        window: &mut WindowContext,
    ) {
        if let Some(i) = e.press_args() {
            if i == Button::Mouse(mouse::MouseButton::Left) && window.mouse_position[1] < self.window_height / 3.0 {
                let song_select = song_select::SongSelect::new(window, config);
                window.change_scene(song_select);
            } else if i == Button::Mouse(mouse::MouseButton::Left) && window.mouse_position[1] < self.window_height / 3.0 * 2.0 {
                window.change_scene(options::Options::new(window, config));
            }
        }
        if let Some(r) = e.render_args() {
            window.gl.draw(r.viewport(), |c, gl| {
                let [width, height] = r.window_size;
                self.window_height = height;
                let play_texture = &self.play_texture;
                let options_texture = &self.options_texture;
                let exit_texture = &self.exit_texture;
                graphics::clear([0.0, 0.0, 0.0, 0.0], gl);
                let draw_state = DrawState::default();
                let play_w = play_texture.get_width() as f64;
                let play_h = play_texture.get_height() as f64;
                let play_x = width / 2.0 - play_w / 2.0;
                let play_y = height / 4.0 - play_h / 2.0;
                let play_image = Image::new().rect([play_x, play_y, play_w, play_h]);
                let options_w = options_texture.get_width() as f64;
                let options_h = options_texture.get_height() as f64;
                let options_x = width / 2.0 - options_w / 2.0;
                let options_y = height / 2.0 - options_h / 2.0;
                let options_image = Image::new().rect([options_x, options_y, options_w, options_h]);
                let exit_w = exit_texture.get_width() as f64;
                let exit_h = exit_texture.get_height() as f64;
                let exit_x = width / 2.0 - exit_w / 2.0;
                let exit_y = 3.0 * height / 4.0 - exit_h / 2.0;
                let exit_image = Image::new().rect([exit_x, exit_y, exit_w, exit_h]);
                options_image.draw(options_texture, &draw_state, c.transform, gl);
                exit_image.draw(exit_texture, &draw_state, c.transform, gl);
                play_image.draw(play_texture, &draw_state, c.transform, gl);
            });
            window.window.swap_buffers();
        }
    }
pub ( super ) fn event ( & mut self , e : piston :: input :: Event , config : & Config , _audio : & audio :: Audio , window : & mut WindowContext , ) { if let Some ( i ) = e . press_args ( ) { if i == Button :: Mouse ( mouse :: MouseButton :: Left ) && window . mouse_position [ 1 ] < self . window_height / 3.0 { let song_select = song_select :: SongSelect :: new ( window , config ) ; window . change_scene ( song_select ) ; } else if i == Button :: Mouse ( mouse :: MouseButton :: Left ) && window . mouse_position [ 1 ] < self . window_height / 3.0 * 2.0 { window . change_scene ( options :: Options :: new ( window , config ) ) ; } } if let Some ( r ) = e . render_args ( ) { window . gl . draw ( r . viewport ( ) , | c , gl | { let [ width , height ] = r . window_size ; self . window_height = height ; let play_texture = & self . play_texture ; let options_texture = & self . options_texture ; let exit_texture = & self . exit_texture ; graphics :: clear ( [ 0.0 , 0.0 , 0.0 , 0.0 ] , gl ) ; let draw_state = DrawState :: default ( ) ; let play_w = play_texture . get_width ( ) as f64 ; let play_h = play_texture . get_height ( ) as f64 ; let play_x = width / 2.0 - play_w / 2.0 ; let play_y = height / 4.0 - play_h / 2.0 ; let play_image = Image :: new ( ) . rect ( [ play_x , play_y , play_w , play_h ] ) ; let options_w = options_texture . get_width ( ) as f64 ; let options_h = options_texture . get_height ( ) as f64 ; let options_x = width / 2.0 - options_w / 2.0 ; let options_y = height / 2.0 - options_h / 2.0 ; let options_image = Image :: new ( ) . rect ( [ options_x , options_y , options_w , options_h ] ) ; let exit_w = exit_texture . get_width ( ) as f64 ; let exit_h = exit_texture . get_height ( ) as f64 ; let exit_x = width / 2.0 - exit_w / 2.0 ; let exit_y = 3.0 * height / 4.0 - exit_h / 2.0 ; let exit_image = Image :: new ( ) . rect ( [ exit_x , exit_y , exit_w , exit_h ] ) ; options_image . draw ( options_texture , & draw_state , c . transform , gl ) ; exit_image . draw ( exit_texture , & draw_state , c . transform , gl ) ; play_image . draw ( play_texture , & draw_state , c . transform , gl ) ; } ) ; window . window . swap_buffers ( ) ; } }
Called everytime there is a window event
Called everytime there is a window event
&mut self
e
piston::input::Event
config
&Config
_audio
&audio::Audio
window
&mut WindowContext