]> git.seodisparate.com - LudumDare45_StartWithNothing/commitdiff
Add InstantText, change name of project
authorStephen Seo <seo.disparate@gmail.com>
Sat, 5 Oct 2019 08:38:17 +0000 (17:38 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Sat, 5 Oct 2019 08:40:51 +0000 (17:40 +0900)
Cargo.lock
Cargo.toml
src/main.rs

index 6c565ed5283e9df98dbebba269897f3e0e4a40d6..75e86f1d3ac8ee957cd02e0d19fe410649108428 100644 (file)
@@ -994,7 +994,7 @@ version = "1.4.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
-name = "ld45_start_with_nothing"
+name = "ld45_one_and_all"
 version = "0.1.0"
 dependencies = [
  "quicksilver 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)",
index 4f997291d7b5d80e8ed44d1ef059cbf71bab40a1..4bfe1cc469d58412b8d1875c4299bc620854b730 100644 (file)
@@ -1,5 +1,5 @@
 [package]
-name = "ld45_start_with_nothing"
+name = "ld45_one_and_all"
 version = "0.1.0"
 authors = ["Stephen Seo <seo.disparate@gmail.com>"]
 edition = "2018"
index 7284bfa5891abcb983c2c30dc2aed8dd2a384e7b..4695f763731b18de1217610e6857a48da46b66b3 100644 (file)
@@ -33,6 +33,12 @@ enum MenuItemType {
         text_c: Color,
         timer: f64,
     },
+    InstantText {
+        text: &'static str,
+        text_image: Option<Image>,
+        text_size: f32,
+        text_color: Color,
+    },
     Pause {
         timer: f64,
         length: f64,
@@ -108,7 +114,57 @@ impl Menu {
             is_loaded: false,
         };
 
-        Menu { items: vec![item] }
+        Menu {
+            items: vec![
+                item,
+                Menu::instant_text(
+                    150.0,
+                    50.0,
+                    45.0,
+                    true,
+                    "One And All",
+                ),
+                Menu::instant_text(
+                    25.0,
+                    HEIGHT_F - 100.0,
+                    30.0,
+                    true,
+                    "Made with quicksilver which is licensed with either",
+                ),
+                Menu::instant_text(
+                    70.0,
+                    HEIGHT_F - 80.0,
+                    30.0,
+                    true,
+                    "MIT License or Apache License Version 2.0",
+                ),
+                Menu::instant_text(
+                    25.0,
+                    HEIGHT_F - 50.0,
+                    30.0,
+                    true,
+                    "Uses Clear-Sans which is licensed with Apache License Version 2.0",
+                ),
+            ],
+        }
+    }
+
+    fn instant_text(x: f32, y: f32, text_size: f32, first: bool, s: &'static str) -> MenuItem {
+        MenuItem {
+            x,
+            y,
+            w: 0.0,
+            h: 0.0,
+            item_type: MenuItemType::InstantText {
+                text: s,
+                text_image: None,
+                text_size,
+                text_color: Color::WHITE,
+            },
+            is_hover: false,
+            is_focus: false,
+            is_loaded: !first,
+        }
     }
 
     fn text(x: f32, y: f32, text_size: f32, first: bool, s: &'static str) -> MenuItem {
@@ -579,6 +635,20 @@ impl State for GameState {
                                     }
                                 }
                                 MenuItemType::Pause { timer, length } => (),
+                                MenuItemType::InstantText {
+                                    text,
+                                    text_image,
+                                    text_size,
+                                    text_color,
+                                } => {
+                                    if text_image.is_none() {
+                                        self.font.execute(|f| {
+                                            let style = FontStyle::new(*text_size, *text_color);
+                                            *text_image = Some(f.render(text, &style)?);
+                                            Ok(())
+                                        })?;
+                                    }
+                                }
                             }
                             mi.is_loaded = true;
                         }
@@ -733,6 +803,28 @@ impl State for GameState {
                             }
                         }
                     }
+                    MenuItemType::InstantText {
+                        text,
+                        text_image,
+                        text_size,
+                        text_color,
+                    } => {
+                        if text_image.is_none() {
+                            self.font.execute(|f| {
+                                let style = FontStyle::new(*text_size, *text_color);
+                                *text_image = Some(f.render(text, &style)?);
+                                Ok(())
+                            })?;
+                        }
+                        if text_image.is_some() {
+                            mi.is_loaded = true;
+                            if i + 1 < self.menu.items.len() {
+                                self.menu.items[i + 1].is_loaded = false;
+                            } else {
+                                self.current_finished = true;
+                            }
+                        }
+                    }
                 }
             }
         }
@@ -786,6 +878,19 @@ impl State for GameState {
                         window.draw(&image_rect, Img(i));
                     }
                 }
+                MenuItemType::InstantText {
+                    text,
+                    text_image,
+                    text_size,
+                    text_color,
+                } => {
+                    if let Some(i) = text_image {
+                        let mut image_rect = i.area();
+                        image_rect.pos.x = mi.x;
+                        image_rect.pos.y = mi.y;
+                        window.draw(&image_rect, Img(i));
+                    }
+                }
                 MenuItemType::Pause { timer, length } => (),
             }
         }
@@ -816,7 +921,7 @@ impl State for GameState {
 
 fn main() {
     run::<GameState>(
-        "LudumDare45_StartWithNothing",
+        "One And All - a Ludum Dare 45 compo entry",
         Vector::new(800, 600),
         Settings::default(),
     );