generated from ElnuDev/rust-project
cargo fmt
This commit is contained in:
parent
4666368b0a
commit
cd01bb6567
9 changed files with 116 additions and 75 deletions
|
@ -1,16 +1,19 @@
|
|||
use std::{path::PathBuf, sync::{Arc, Mutex}};
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
|
||||
use eframe::egui;
|
||||
use renrs::State;
|
||||
|
||||
use sfml::{
|
||||
graphics::{Color, RenderTarget, RenderWindow, RectangleShape, Transformable},
|
||||
system::Vector2f,
|
||||
window::{Event, mouse, Key, Style},
|
||||
};
|
||||
use egui_sfml::SfEgui;
|
||||
use sfml::{
|
||||
graphics::{Color, RectangleShape, RenderTarget, RenderWindow, Transformable},
|
||||
system::Vector2f,
|
||||
window::{mouse, Event, Key, Style},
|
||||
};
|
||||
|
||||
const WIDTH: f32 = 800.0;
|
||||
const HEIGHT: f32 = 600.0;
|
||||
|
@ -121,8 +124,17 @@ impl App {
|
|||
while window.is_open() {
|
||||
while let Some(event) = window.poll_event() {
|
||||
match event {
|
||||
Event::Closed | Event::KeyPressed { code: Key::Escape, .. } => return,
|
||||
Event::MouseButtonPressed { button: mouse::Button::Left, .. } | Event::KeyPressed { code: Key::Space, .. } => self.handle_interaction(),
|
||||
Event::Closed
|
||||
| Event::KeyPressed {
|
||||
code: Key::Escape, ..
|
||||
} => return,
|
||||
Event::MouseButtonPressed {
|
||||
button: mouse::Button::Left,
|
||||
..
|
||||
}
|
||||
| Event::KeyPressed {
|
||||
code: Key::Space, ..
|
||||
} => self.handle_interaction(),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -137,15 +149,18 @@ impl App {
|
|||
..Default::default()
|
||||
})
|
||||
.show(ctx, |ui| {
|
||||
if ctx.input(|i|
|
||||
if ctx.input(|i| {
|
||||
i.key_pressed(Key::Space)
|
||||
|| i.pointer.button_clicked(PointerButton::Primary)
|
||||
) {
|
||||
|| i.pointer.button_clicked(PointerButton::Primary)
|
||||
}) {
|
||||
self.handle_interaction();
|
||||
}
|
||||
ui.with_layout(egui::Layout::left_to_right(Align::Max), |ui| ui.heading(&self.text[0..*self.chars.lock().unwrap()]));
|
||||
ui.with_layout(egui::Layout::left_to_right(Align::Max), |ui| {
|
||||
ui.heading(&self.text[0..*self.chars.lock().unwrap()])
|
||||
});
|
||||
});
|
||||
}).unwrap();
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
let Vector2f { x, y } = shape.position();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue