diff options
Diffstat (limited to 'pixel-client/src/menu/settings.rs')
-rw-r--r-- | pixel-client/src/menu/settings.rs | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/pixel-client/src/menu/settings.rs b/pixel-client/src/menu/settings.rs index 90668039..aef56f2f 100644 --- a/pixel-client/src/menu/settings.rs +++ b/pixel-client/src/menu/settings.rs @@ -15,7 +15,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. */ -use crate::ui::Ui; +use crate::{config::Config, render::sprite::SpriteDraw, ui::Ui}; +use hurrycurry_protocol::glam::Vec2; +use log::warn; pub struct Settings { pub username: String, @@ -25,9 +27,39 @@ pub struct Settings { pub struct SettingsMenu {} impl SettingsMenu { - pub fn draw(&mut self, ui: &mut Ui) -> bool { - ui.text("Settings placeholder"); + pub fn draw(&mut self, ui: &mut Ui, config: &mut Config) -> bool { + ui.renderer.draw_ui(SpriteDraw::overlay( + ui.renderer.misc_textures.solid, + Vec2::ZERO, + ui.renderer.ui_size, + Some([0, 0, 0, 150]), + )); - return ui.button(80., "Back"); + let mut back = false; + + ui.horizontal(|ui| { + ui.advance(Vec2::splat(20.)); + ui.vertical(|ui| { + ui.advance(Vec2::splat(10.)); + ui.text("Settings"); + + ui.horizontal(|ui| { + ui.text("Username: "); + ui.textedit(100., &mut config.username); + }); + + ui.advance(ui.get_remaining() - Vec2::Y * 30.); + + if ui.button(80., "Back") { + if let Err(e) = config.save() { + warn!("cannot save config: {e}"); + } else { + back = true + } + } + }); + }); + + return back; } } |