changeset 750:31897f650d2d

examples: Add a third screen to the menu
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Wed, 29 Jan 2020 18:18:24 +0100
parents ee45bfde91bb
children eab7dde1164f
files examples/menu.rs
diffstat 1 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/examples/menu.rs
+++ b/examples/menu.rs
@@ -133,15 +133,23 @@ fn main() {
         .build()
         .unwrap();
 
+    let tl_dat = directory.join("TL.DAT");
+    let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("TL.DAT present");
+
     let mut back_buffer = surface.back_buffer().unwrap();
     let mut resize = false;
     let mut frame = 0;
+    let mut z_pressed = false;
+    let mut x_pressed = false;
 
     'app: loop {
         for event in surface.poll_events() {
             match event {
                 WindowEvent::Close | WindowEvent::Key(Key::Escape, _, Action::Release, _) => break 'app,
 
+                WindowEvent::Key(Key::Z, _, Action::Press, _) => z_pressed = true,
+                WindowEvent::Key(Key::X, _, Action::Press, _) => x_pressed = true,
+
                 WindowEvent::FramebufferSize(..) => {
                     resize = true;
                 }
@@ -157,13 +165,17 @@ fn main() {
 
         frame += 1;
         if frame == 60 {
-            let tl_dat = directory.join("TL.DAT");
-            let mut tl_pbg3 = pbg3::from_path_buffered(tl_dat).expect("IN.DAT present");
-            let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("th06logo.jpg in IN.DAT");
+            let jpeg = tl_pbg3.get_file("title00.jpg", true).expect("title00.jpg in TL.DAT");
             let image = common::load_from_data(&jpeg).expect("th06logo.jpg decodable");
             common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture");
         }
 
+        if frame >= 60 && z_pressed {
+            let jpeg = tl_pbg3.get_file("select00.jpg", true).expect("select00.jpg in TL.DAT");
+            let image = common::load_from_data(&jpeg).expect("select00.jpg decodable");
+            common::reupload_texture_from_rgb_image(&mut background, image).expect("upload data to texture");
+        }
+
         // here, we need to bind the pipeline variable; it will enable us to bind the texture to the GPU
         // and use it in the shader
         surface