figuring out the request

main
aprzn 1 year ago
parent cd3078da9c
commit 1587afc887

@ -2380,6 +2380,8 @@ dependencies = [
"once_cell", "once_cell",
"rustls", "rustls",
"rustls-webpki 0.100.2", "rustls-webpki 0.100.2",
"serde",
"serde_json",
"url", "url",
"webpki-roots", "webpki-roots",
] ]

@ -10,4 +10,4 @@ eframe = "0.22.0"
notify = "6.1.1" notify = "6.1.1"
serde = { version = "1.0.186", features = ["derive"] } serde = { version = "1.0.186", features = ["derive"] }
serde_json = "1.0.105" serde_json = "1.0.105"
ureq = "2.7.1" ureq = { version = "2.7.1", features = ["json"] }

@ -1,4 +1,6 @@
#![allow(dead_code)] #![allow(dead_code)]
use std::{sync::mpsc, thread};
use eframe::{ use eframe::{
egui::{CentralPanel, Context, Layout, TextFormat, Visuals}, egui::{CentralPanel, Context, Layout, TextFormat, Visuals},
emath::Align, emath::Align,
@ -42,15 +44,26 @@ enum Event {
IdSubmit { id: String }, IdSubmit { id: String },
} }
enum App { enum State {
IdSelect { search_string: String, enabled: bool }, IdSelect { search_string: String, enabled: bool },
} }
struct App {
state: State,
event_tx: mpsc::Sender<Event>,
event_rx: mpsc::Receiver<Event>,
}
impl App { impl App {
fn new() -> Self { fn new() -> Self {
Self::IdSelect { let (event_tx, event_rx) = mpsc::channel();
search_string: String::new(), Self {
enabled: true 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.with_layout(Layout::top_down(Align::Center), |ui| {
ui.label(title_text); ui.label(title_text);
match self { match &mut self.state {
Self::IdSelect { search_string, enabled } => { State::IdSelect { search_string, enabled } => {
ui.label("Enter level ID:"); ui.label("Enter level ID:");
ui.add_enabled_ui(*enabled, |ui| { ui.add_enabled_ui(*enabled, |ui| {
ui.text_edit_singleline(search_string).request_focus(); ui.text_edit_singleline(search_string).request_focus();
@ -104,7 +117,16 @@ impl App {
for event in events { for event in events {
match event { match event {
Event::IdSubmit { id } => { 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"),
]);
});
}, },
} }
} }

Loading…
Cancel
Save