shape creation works!
This commit is contained in:
parent
c50609cd64
commit
898cb5e83c
4 changed files with 369 additions and 15 deletions
52
src/lib.rs
52
src/lib.rs
|
@ -1,18 +1,64 @@
|
|||
use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
|
||||
#[derive(Debug)]
|
||||
mod create;
|
||||
mod helpers;
|
||||
pub use create::create_sys;
|
||||
pub use helpers::*;
|
||||
|
||||
#[derive(Component, Debug, Clone, Copy)]
|
||||
pub struct SPoint(pub Vec2);
|
||||
|
||||
#[derive(Component, Debug)]
|
||||
pub struct ShapeData {
|
||||
pub shape: CreateShape,
|
||||
pub main_shape: Entity,
|
||||
pub edges: Vec<Entity>,
|
||||
pub center: Option<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Component)]
|
||||
pub struct MainCamera;
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum CreateShape {
|
||||
Triangle, Square, SquareCenter, Circle, Capsule
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
|
||||
pub enum Action {
|
||||
Create, Modify, Delete
|
||||
}
|
||||
pub struct UiState {
|
||||
pub current_action: Action,
|
||||
|
||||
pub create_shape: CreateShape,
|
||||
}
|
||||
impl Default for UiState {
|
||||
fn default() -> Self {
|
||||
Self { current_action: Action::Modify }
|
||||
Self {
|
||||
current_action: Action::Modify,
|
||||
create_shape: CreateShape::Square,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl UiState {
|
||||
pub fn create_shape_color(&self, colors: &ButtonsColors, shape: CreateShape) -> egui::Rgba {
|
||||
if self.create_shape == shape {
|
||||
colors.clicked
|
||||
}
|
||||
else {
|
||||
colors.regular
|
||||
}
|
||||
}
|
||||
pub fn current_action_color(&self, colors: &ButtonsColors, action: Action) -> egui::Rgba {
|
||||
if self.current_action == action {
|
||||
colors.clicked
|
||||
}
|
||||
else {
|
||||
colors.regular
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct ButtonsColors {
|
||||
pub regular: egui::Rgba,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue