|
|
@ -5,87 +5,12 @@ use eframe::egui;
|
|
|
|
use std::boxed::Box;
|
|
|
|
use std::boxed::Box;
|
|
|
|
use std::collections::VecDeque;
|
|
|
|
use std::collections::VecDeque;
|
|
|
|
|
|
|
|
|
|
|
|
/*use iced::{
|
|
|
|
|
|
|
|
widget::{
|
|
|
|
|
|
|
|
button,
|
|
|
|
|
|
|
|
column,
|
|
|
|
|
|
|
|
row,
|
|
|
|
|
|
|
|
text,
|
|
|
|
|
|
|
|
scrollable,
|
|
|
|
|
|
|
|
Column,
|
|
|
|
|
|
|
|
Row,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
Application,
|
|
|
|
|
|
|
|
Settings,
|
|
|
|
|
|
|
|
Element,
|
|
|
|
|
|
|
|
Alignment,
|
|
|
|
|
|
|
|
Theme,
|
|
|
|
|
|
|
|
executor,
|
|
|
|
|
|
|
|
Command,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
use rodio::{
|
|
|
|
|
|
|
|
source::Source,
|
|
|
|
|
|
|
|
Decoder,
|
|
|
|
|
|
|
|
OutputStream,
|
|
|
|
|
|
|
|
Sink,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct Guider {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy)]
|
|
|
|
|
|
|
|
enum Message {
|
|
|
|
|
|
|
|
Msg,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Application for Guider {
|
|
|
|
|
|
|
|
type Executor = executor::Default;
|
|
|
|
|
|
|
|
type Flags = ();
|
|
|
|
|
|
|
|
type Message = Message;
|
|
|
|
|
|
|
|
type Theme = Theme;
|
|
|
|
|
|
|
|
fn new(_flags: Self::Flags) -> (Self, Command<Self::Message>) {
|
|
|
|
|
|
|
|
(Self {}, Command::none())
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn view(&self) -> Element<Self::Message> {
|
|
|
|
|
|
|
|
// column![button("pause").on_press(Message::Pause), button("play").on_press(Message::Play)].into()
|
|
|
|
|
|
|
|
row![
|
|
|
|
|
|
|
|
scrollable(["lvl 1", "lvl 2", "lvl 3"].iter().fold(
|
|
|
|
|
|
|
|
Column::new(), |col, item| col.push(button(*item).on_press(Message::Msg))
|
|
|
|
|
|
|
|
)),
|
|
|
|
|
|
|
|
column![
|
|
|
|
|
|
|
|
row![
|
|
|
|
|
|
|
|
column![text("Some Title Info?")],
|
|
|
|
|
|
|
|
column![
|
|
|
|
|
|
|
|
text("G"),
|
|
|
|
|
|
|
|
text("Y"),
|
|
|
|
|
|
|
|
text("O"),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
row![text("zoom in"), text("zoom out"), text("delete"), text("add"), text("edit")],
|
|
|
|
|
|
|
|
text("view canvas"),
|
|
|
|
|
|
|
|
]
|
|
|
|
|
|
|
|
].align_items(Alignment::Fill).into()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn update(&mut self, message: Message) -> Command<Self::Message> {
|
|
|
|
|
|
|
|
match message {
|
|
|
|
|
|
|
|
Message::Msg => {println!("Message received!")}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Command::none()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn title(&self) -> String {
|
|
|
|
|
|
|
|
String::from("Guider")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct PipeDash {
|
|
|
|
struct PipeDash {
|
|
|
|
selected_level: Option<i32>,
|
|
|
|
msg_queue: VecDeque<Message>,
|
|
|
|
|
|
|
|
selected_level: Option<usize>,
|
|
|
|
selected_color: Option<Color>,
|
|
|
|
selected_color: Option<Color>,
|
|
|
|
|
|
|
|
level_list: Vec<gd::OuterLevel>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
|
@ -98,29 +23,36 @@ enum Color {
|
|
|
|
#[derive(Debug)]
|
|
|
|
#[derive(Debug)]
|
|
|
|
enum Message {
|
|
|
|
enum Message {
|
|
|
|
ColorSelected(Color),
|
|
|
|
ColorSelected(Color),
|
|
|
|
|
|
|
|
LevelSelected(usize),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl PipeDash {
|
|
|
|
impl PipeDash {
|
|
|
|
fn new(_cc: &eframe::CreationContext) -> Self {
|
|
|
|
fn new(_cc: &eframe::CreationContext) -> Self {
|
|
|
|
Self {
|
|
|
|
Self {
|
|
|
|
selected_level: None,
|
|
|
|
selected_level: None,
|
|
|
|
selected_color: None,
|
|
|
|
selected_color: None,
|
|
|
|
|
|
|
|
msg_queue: VecDeque::new(),
|
|
|
|
|
|
|
|
level_list: gd::OuterLevel::load_all(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl eframe::App for PipeDash {
|
|
|
|
impl eframe::App for PipeDash {
|
|
|
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
|
|
|
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
|
|
|
|
let mut message_queue: VecDeque<Message> = VecDeque::new();
|
|
|
|
use Message::*;
|
|
|
|
|
|
|
|
use Color::*;
|
|
|
|
ctx.set_pixels_per_point(2f32);
|
|
|
|
ctx.set_pixels_per_point(2f32);
|
|
|
|
|
|
|
|
|
|
|
|
egui::SidePanel::left("level_picker").show(ctx, |ui| {
|
|
|
|
egui::SidePanel::left("level_picker").default_width(100f32).show(ctx, |ui| {
|
|
|
|
if ui.selectable_label(self.selected_level == Some(0), "lbl 1").clicked() {
|
|
|
|
ui.with_layout(egui::Layout::top_down_justified(egui::Align::Min), |ui| {
|
|
|
|
self.selected_level = Some(0);
|
|
|
|
for (idx, level) in self.level_list.iter().enumerate() {
|
|
|
|
}
|
|
|
|
if ui.selectable_label(self.selected_level == Some(idx), level.display_name()).clicked() {
|
|
|
|
if ui.selectable_label(self.selected_level == Some(1), "lbl 2").clicked() {
|
|
|
|
self.msg_queue.push_back(LevelSelected(idx));
|
|
|
|
self.selected_level = Some(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
|
|
egui::CentralPanel::default().show(ctx, |ui| {
|
|
|
|
ui.vertical_centered_justified(|ui| {
|
|
|
|
ui.vertical_centered_justified(|ui| {
|
|
|
@ -131,15 +63,15 @@ impl eframe::App for PipeDash {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
|
|
|
ui.with_layout(egui::Layout::right_to_left(egui::Align::TOP), |ui| {
|
|
|
|
ui.vertical(|ui| {
|
|
|
|
ui.vertical(|ui| {
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Color::Orange), "orange").clicked() {
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Orange), "orange").clicked() {
|
|
|
|
message_queue.push_back(Message::ColorSelected(Color::Orange));
|
|
|
|
self.msg_queue.push_back(ColorSelected(Orange));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Color::Yellow), "yellow").clicked() {
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Yellow), "yellow").clicked() {
|
|
|
|
message_queue.push_back(Message::ColorSelected(Color::Yellow));
|
|
|
|
self.msg_queue.push_back(ColorSelected(Yellow));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Color::Green), "green").clicked() {
|
|
|
|
if ui.selectable_label(self.selected_color == Some(Green), "green").clicked() {
|
|
|
|
message_queue.push_back(Message::ColorSelected(Color::Green));
|
|
|
|
self.msg_queue.push_back(ColorSelected(Green));
|
|
|
|
};
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -147,19 +79,21 @@ impl eframe::App for PipeDash {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
for message in message_queue.drain(..) {
|
|
|
|
for message in self.msg_queue.drain(..) {
|
|
|
|
println!("{:?}", message);
|
|
|
|
println!("{:?}", message);
|
|
|
|
match message {
|
|
|
|
match message {
|
|
|
|
Message::ColorSelected(color) => {
|
|
|
|
Message::ColorSelected(color) => {
|
|
|
|
self.selected_color = Some(color);
|
|
|
|
self.selected_color = Some(color);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
Message::LevelSelected(idx) => {
|
|
|
|
|
|
|
|
self.selected_level = Some(idx);
|
|
|
|
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
fn main() {
|
|
|
|
println!("{:?}", gd::get_outer_levels());
|
|
|
|
|
|
|
|
let app: PipeDash;
|
|
|
|
let app: PipeDash;
|
|
|
|
let opts = eframe::NativeOptions::default();
|
|
|
|
let opts = eframe::NativeOptions::default();
|
|
|
|
eframe::run_native("PipeDash", opts, Box::new(|cc| Box::new(PipeDash::new(cc))));
|
|
|
|
eframe::run_native("PipeDash", opts, Box::new(|cc| Box::new(PipeDash::new(cc))));
|
|
|
|