figuring out the request

main
aprzn 1 year ago
parent cd3078da9c
commit 1587afc887

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

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

@ -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"),
]);
});
},
}
}

Loading…
Cancel
Save