diff --git a/assets/fonts/Neothic/Neothic.ttf b/assets/fonts/Neothic/Neothic.ttf new file mode 100644 index 0000000..1323e1a Binary files /dev/null and b/assets/fonts/Neothic/Neothic.ttf differ diff --git a/assets/fonts/Neothic/OFL.txt b/assets/fonts/Neothic/OFL.txt new file mode 100644 index 0000000..f435ed8 --- /dev/null +++ b/assets/fonts/Neothic/OFL.txt @@ -0,0 +1,93 @@ +Copyright 2011 The Montserrat Project Authors (https://github.com/JulietaUla/Montserrat) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/images/Blank Button (Depressed).png b/assets/images/Blank Button (Depressed).png new file mode 100644 index 0000000..27c3819 --- /dev/null +++ b/assets/images/Blank Button (Depressed).png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d8a138c799b96fbd64707f17784a243f39986897cc9c1d5db528141d5e814f58 +size 65219 diff --git a/assets/images/Blank Button (Resting).png b/assets/images/Blank Button (Resting).png new file mode 100644 index 0000000..69f598e --- /dev/null +++ b/assets/images/Blank Button (Resting).png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:91a8e710ce6731bcf2530bddaa55529e81a8b126250b01bfb22f6e28f523e59c +size 63413 diff --git a/assets/martian.tweak.toml b/assets/martian.tweak.toml index 8e2ae6a..f6fd2c6 100644 --- a/assets/martian.tweak.toml +++ b/assets/martian.tweak.toml @@ -7,9 +7,9 @@ text = """ An Icehouse game by Andrew Looney -Art by Sam Hall +Art: Sam Hall -Programming by Elijah Voigt +Programming: Elijah Voigt --- @@ -25,13 +25,15 @@ FMOD/FMOD Studio: fmod.com Image Textures retrieved from textures.com: -Concrete Energy Pole - https://www.textures.com/download/PBR0340/136381 +Concrete Energy Pole: https://www.textures.com/download/PBR0340/136381 -Space Blanket Folds - https://www.textures.com/download/PBR0152/133187 +Space Blanket Folds: https://www.textures.com/download/PBR0152/133187 Background 2D art by NASA: LINK HERE -Silkscreen Font by Jason Kottke - https://www.kottke.org/plus/type/silkscreen/ +Silkscreen Font by Jason Kottke: https://www.kottke.org/plus/type/silkscreen/ + +Neothic Font by Daymarius: https://www.dafont.com/neothic.font """ ### @@ -115,6 +117,11 @@ end = ["Ok, now move some pieces somewheres!"] x = 640 y = 480 +[buttons] +image_resting = "images/Blank Button (Resting).png" +image_depressed = "images/Blank Button (Depressed).png" +font = "fonts/Neothic/Neothic.ttf" + ######################################################################### # Audio settings ######################################################################### diff --git a/src/credits.rs b/src/credits.rs index bd17177..8e6dd59 100644 --- a/src/credits.rs +++ b/src/credits.rs @@ -4,7 +4,7 @@ pub(crate) struct CreditsPlugin; impl Plugin for CreditsPlugin { fn build(&self, app: &mut App) { - app.add_systems(Startup, init_credits_ui) + app.add_systems(OnExit(GameState::Loading), init_credits_ui) .add_systems(OnEnter(GameState::Credits), update_credits); } } @@ -12,7 +12,15 @@ impl Plugin for CreditsPlugin { #[derive(Debug, Component)] struct Credits; -fn init_credits_ui(mut commands: Commands) { +fn init_credits_ui( + mut commands: Commands, + tweaks_file: Res, + tweaks: Res>, +) { + let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks"); + let button_handle = tweak.get_handle::("buttons_image_resting").unwrap(); + let font_handle = tweak.get_handle::("buttons_font").unwrap(); + commands .spawn(( GameState::Credits, @@ -39,7 +47,7 @@ fn init_credits_ui(mut commands: Commands) { padding: UiRect::all(Val::Px(25.0)), ..default() }, - background_color: Color::BLACK.with_a(0.5).into(), + background_color: Color::BLACK.into(), ..default() }, )) @@ -67,25 +75,36 @@ fn init_credits_ui(mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn(TextBundle { - text: Text { - sections: vec![TextSection { - value: "Back".into(), - style: TextStyle { - color: Color::BLACK, - font_size: 32.0, - ..default() - }, - }], + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "B a c k".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 12.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ..default() - }); + } + ); }); }); } diff --git a/src/game.rs b/src/game.rs index c1c9e2d..a6d794d 100644 --- a/src/game.rs +++ b/src/game.rs @@ -596,7 +596,16 @@ fn check_endgame(board: Res, mut next_state: ResMut> } } -fn set_endgame(score: Res, mut commands: Commands) { +fn set_endgame( + score: Res, + mut commands: Commands, + tweaks_file: Res, + tweaks: Res>, +) { + let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks"); + let button_handle = tweak.get_handle::("buttons_image_resting").unwrap(); + let font_handle = tweak.get_handle::("buttons_font").unwrap(); + commands .spawn(( Endgame, @@ -663,19 +672,36 @@ fn set_endgame(score: Res, mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "New Game", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "N e w G a m e".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); // Quit button @@ -689,19 +715,36 @@ fn set_endgame(score: Res, mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Quit", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "Q u i t".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); }); }); diff --git a/src/menu.rs b/src/menu.rs index 9f2f5f9..3870d7b 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -41,9 +41,17 @@ pub(crate) enum MenuState { #[derive(Debug, Component)] pub(crate) struct ButtonAction(pub S); -fn init_play_menu(mut commands: Commands) { +fn init_play_menu( + mut commands: Commands, + tweaks_file: Res, + tweaks: Res>, +) { info!("Initializing Play menu"); + let tweak = tweaks.get(tweaks_file.handle.clone()).expect("Load tweaks"); + let button_handle = tweak.get_handle::("buttons_image_resting").unwrap(); + let font_handle = tweak.get_handle::("buttons_font").unwrap(); + commands .spawn(( MenuState::On, @@ -84,19 +92,36 @@ fn init_play_menu(mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Continue", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "C o n t i n u e".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); // Tutorial button @@ -110,19 +135,36 @@ fn init_play_menu(mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Tutorial", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "T u t o r i a l".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); // Credits button @@ -136,19 +178,36 @@ fn init_play_menu(mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Credits", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "C r e d i t s".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); // Quit button @@ -162,19 +221,36 @@ fn init_play_menu(mut commands: Commands) { margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Quit", - TextStyle { - color: Color::BLACK, - font_size: 32.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "Q u i t".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 16.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); }); } diff --git a/src/tutorial.rs b/src/tutorial.rs index 06220ac..bbb0d68 100644 --- a/src/tutorial.rs +++ b/src/tutorial.rs @@ -85,6 +85,8 @@ fn initialize_tutorial( let background_hex = tweak.get::("tutorial_rgba_background").unwrap(); let text_visible_hex = tweak.get::("tutorial_rgba_visible").unwrap(); + let button_handle = tweak.get_handle::("buttons_image_resting").unwrap(); + let font_handle = tweak.get_handle::("buttons_font").unwrap(); // List of (state, lines) for tutorial steps [ @@ -235,19 +237,36 @@ fn initialize_tutorial( margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Start Over", - TextStyle { - color: Color::BLACK, - font_size: 16.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "R e s t a r t".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 12.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); parent @@ -261,19 +280,36 @@ fn initialize_tutorial( margin: UiRect::all(Val::Px(5.0)), ..default() }, - background_color: Color::ORANGE.with_a(0.5).into(), + image: UiImage { + texture: button_handle.clone(), + ..default() + }, ..default() }, )) .with_children(|parent| { - parent.spawn((TextBundle::from_section( - "Continue Game", - TextStyle { - color: Color::BLACK, - font_size: 16.0, + parent.spawn( + TextBundle { + text: Text { + sections: vec![ + TextSection { + value: "C o n t i n u e".into(), + style: TextStyle { + color: Color::WHITE, + font_size: 12.0, + font: font_handle.clone(), + }, + } + ], + ..default() + }, + style: Style { + margin: UiRect::all(Val::Px(20.0)), + ..default() + }, ..default() - }, - ),)); + } + ); }); }); } diff --git a/src/tweak.rs b/src/tweak.rs index e940798..e3fcc00 100644 --- a/src/tweak.rs +++ b/src/tweak.rs @@ -51,6 +51,8 @@ impl Tweaks { Some(load_context.load::(s).untyped()) } else if s.ends_with(".png") { Some(load_context.load::(s).untyped()) + } else if s.ends_with(".ttf") || s.ends_with(".otf") { + Some(load_context.load::(s).untyped()) } else { None } diff --git a/src/ui.rs b/src/ui.rs index 74dab46..1a061a8 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -69,22 +69,36 @@ fn manage_cursor( } fn interactive_button( - mut events: Query<(&mut BackgroundColor, &Interaction), (With