My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nomicon/games/rstnode/rst-client/src/editor/mod.rs

50 lines
1.3 KiB

use crate::{assets::Assets, input::InputArbiter, ui::Button, viewport::Viewport, GameSettings};
use ggez::{
event::{EventHandler, MouseButton},
graphics::{self, Color},
Context, GameResult,
};
pub struct EditorState {
assets: Assets,
settings: GameSettings,
input: InputArbiter,
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: InputArbiter::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)
}
}