|
|
|
@ -1,4 +1,6 @@
|
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
use std::{sync::mpsc, thread};
|
|
|
|
|
|
|
|
|
|
use eframe::{
|
|
|
|
|
egui::{CentralPanel, Context, Layout, TextFormat, Visuals},
|
|
|
|
|
emath::Align,
|
|
|
|
@ -42,15 +44,26 @@ enum Event {
|
|
|
|
|
IdSubmit { id: String },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
enum App {
|
|
|
|
|
enum State {
|
|
|
|
|
IdSelect { search_string: String, enabled: bool },
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct App {
|
|
|
|
|
state: State,
|
|
|
|
|
event_tx: mpsc::Sender<Event>,
|
|
|
|
|
event_rx: mpsc::Receiver<Event>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl App {
|
|
|
|
|
fn new() -> Self {
|
|
|
|
|
Self::IdSelect {
|
|
|
|
|
search_string: String::new(),
|
|
|
|
|
enabled: true
|
|
|
|
|
let (event_tx, event_rx) = mpsc::channel();
|
|
|
|
|
Self {
|
|
|
|
|
state: State::IdSelect {
|
|
|
|
|
search_string: String::new(),
|
|
|
|
|
enabled: true,
|
|
|
|
|
},
|
|
|
|
|
event_tx,
|
|
|
|
|
event_rx,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -83,8 +96,8 @@ impl App {
|
|
|
|
|
ui.with_layout(Layout::top_down(Align::Center), |ui| {
|
|
|
|
|
ui.label(title_text);
|
|
|
|
|
|
|
|
|
|
match self {
|
|
|
|
|
Self::IdSelect { search_string, enabled } => {
|
|
|
|
|
match &mut self.state {
|
|
|
|
|
State::IdSelect { search_string, enabled } => {
|
|
|
|
|
ui.label("Enter level ID:");
|
|
|
|
|
ui.add_enabled_ui(*enabled, |ui| {
|
|
|
|
|
ui.text_edit_singleline(search_string).request_focus();
|
|
|
|
@ -104,7 +117,16 @@ impl App {
|
|
|
|
|
for event in events {
|
|
|
|
|
match event {
|
|
|
|
|
Event::IdSubmit { id } => {
|
|
|
|
|
*self = Self::IdSelect { search_string: id, enabled: false };
|
|
|
|
|
let tx = self.event_tx.clone();
|
|
|
|
|
self.state = State::IdSelect { search_string: id.clone(), enabled: false };
|
|
|
|
|
thread::spawn(move || {
|
|
|
|
|
let res = ureq::post("http://www.boomlings.com/database/downloadGJLevel22.php")
|
|
|
|
|
.set("User-Agent", "")
|
|
|
|
|
.send_form(&[
|
|
|
|
|
("levelID", &id),
|
|
|
|
|
("secret", "Wmfd2893gb7"),
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|