use crate::{assets::Assets, input::InputHandle, ui::Button, viewport::Viewport, GameSettings}; use ggez::{ event::{EventHandler, MouseButton}, graphics::{self, Color}, Context, GameResult, }; pub struct EditorState { assets: Assets, settings: GameSettings, input: InputHandle, vp: Viewport, btn: Button, } impl EditorState { pub fn new(settings: GameSettings, assets: Assets) -> Self { info!("Initialising map editor state"); Self { assets, settings, vp: Viewport::new(), input: InputHandle::new(), btn: Button::new( (25.0, 25.0).into(), (250.0, 125.0).into(), Some("Create Node".into()), Color::from_rgb(50, 50, 50), ), } } } impl EventHandler for EditorState { fn update(&mut self, ctx: &mut Context) -> GameResult<()> { Ok(()) } fn mouse_button_down_event(&mut self, ctx: &mut Context, btn: MouseButton, x: f32, y: f32) { self.btn.mouse_button_down_event(ctx, btn, x, y) } fn draw(&mut self, ctx: &mut Context) -> GameResult<()> { graphics::clear(ctx, graphics::Color::from_rgb(15, 15, 15)); self.btn.draw(ctx)?; graphics::present(ctx) } }