Compare commits
7 Commits
9468194718
...
3.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| ff311475dc | |||
| 8e61c8a2f2 | |||
| 97cdf4829a | |||
| 7244c24fe4 | |||
| fbc4c747a5 | |||
| 7f1a6c6bc1 | |||
| 856cffd740 |
@@ -1,7 +1,8 @@
|
|||||||
|
use crate::AmongUsVersion;
|
||||||
use crate::AppData;
|
use crate::AppData;
|
||||||
use druid::{
|
use druid::{
|
||||||
widget::*, BoxConstraints, Env, Event, EventCtx, FileDialogOptions, LayoutCtx, LifeCycle,
|
widget::*, BoxConstraints, Color, Env, Event, EventCtx, FileDialogOptions, LayoutCtx,
|
||||||
LifeCycleCtx, PaintCtx, Selector, Size, UpdateCtx, WidgetExt, WidgetPod,
|
LifeCycle, LifeCycleCtx, PaintCtx, Selector, Size, UpdateCtx, WidgetExt, WidgetPod,
|
||||||
};
|
};
|
||||||
use std::{fs, io, path::PathBuf};
|
use std::{fs, io, path::PathBuf};
|
||||||
|
|
||||||
@@ -56,14 +57,22 @@ impl AmongUsLauncherWidget {
|
|||||||
// Iterate first to find labels:
|
// Iterate first to find labels:
|
||||||
|
|
||||||
let mut flexbox_array: Vec<druid::widget::Flex<AppData>> = Vec::new();
|
let mut flexbox_array: Vec<druid::widget::Flex<AppData>> = Vec::new();
|
||||||
let mut auv_array: Vec<String> = Vec::new();
|
let mut auv_array: Vec<AmongUsVersion> = Vec::new();
|
||||||
|
|
||||||
for i in &collection {
|
for i in &collection {
|
||||||
let existing_ver_smash = i.as_ref().unwrap().file_name();
|
let existing_ver_smash = i.as_ref().unwrap().file_name();
|
||||||
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
||||||
let auv = ver_smash_split.next().unwrap();
|
let among_us_version = AmongUsVersion::from(ver_smash_split.next().unwrap());
|
||||||
if !auv_array.contains(&auv.to_string()) {
|
if !auv_array.contains(&among_us_version) {
|
||||||
let label_text = format!("Among Us {}", auv);
|
auv_array.push(among_us_version);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auv_array.sort();
|
||||||
|
|
||||||
|
for among_us_version in &auv_array {
|
||||||
|
println!("{}", among_us_version);
|
||||||
|
let label_text = format!("Among Us {}", among_us_version);
|
||||||
let flex: druid::widget::Flex<AppData> = druid::widget::Flex::column()
|
let flex: druid::widget::Flex<AppData> = druid::widget::Flex::column()
|
||||||
.with_flex_child(
|
.with_flex_child(
|
||||||
druid::widget::Label::new(label_text.as_str()).with_text_size(24.0),
|
druid::widget::Label::new(label_text.as_str()).with_text_size(24.0),
|
||||||
@@ -71,8 +80,6 @@ impl AmongUsLauncherWidget {
|
|||||||
)
|
)
|
||||||
.with_default_spacer();
|
.with_default_spacer();
|
||||||
flexbox_array.push(flex);
|
flexbox_array.push(flex);
|
||||||
auv_array.push(auv.to_string());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Installs list:");
|
println!("Installs list:");
|
||||||
@@ -80,18 +87,28 @@ impl AmongUsLauncherWidget {
|
|||||||
for i in collection {
|
for i in collection {
|
||||||
let existing_ver_smash = i.unwrap().file_name();
|
let existing_ver_smash = i.unwrap().file_name();
|
||||||
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
||||||
let auv = ver_smash_split.next().unwrap();
|
let mut blessed_split = data.blessed_version.as_str().split('-');
|
||||||
let button_string: String =
|
let blessed_version = AmongUsVersion::from(blessed_split.next().unwrap());
|
||||||
format!("Town of Us {}", ver_smash_split.next().unwrap());
|
let among_us_version = AmongUsVersion::from(ver_smash_split.next().unwrap());
|
||||||
|
let tou_version = ver_smash_split.next().unwrap();
|
||||||
|
let blessed_tou_version = blessed_split.next().unwrap();
|
||||||
|
let button_string: String = format!("Town of Us {}", tou_version);
|
||||||
|
|
||||||
for (index, j) in auv_array.iter().enumerate() {
|
for (index, j) in auv_array.iter().enumerate() {
|
||||||
if j == auv {
|
if j == &among_us_version {
|
||||||
let mut clone: PathBuf = PathBuf::from(data.installs_path.clone());
|
let mut clone: PathBuf = PathBuf::from(data.installs_path.clone());
|
||||||
clone.push(existing_ver_smash.clone());
|
clone.push(existing_ver_smash.clone());
|
||||||
|
|
||||||
|
let mut button_label: Label<AppData> =
|
||||||
|
Label::new(button_string.as_str()).with_text_size(24.0);
|
||||||
|
|
||||||
|
if j == &blessed_version && tou_version == blessed_tou_version {
|
||||||
|
button_label.set_text_color(Color::GREEN);
|
||||||
|
}
|
||||||
|
|
||||||
let mut button_row: Flex<AppData> = Flex::row();
|
let mut button_row: Flex<AppData> = Flex::row();
|
||||||
|
|
||||||
let fybutton = druid::widget::Button::new(button_string.as_str())
|
let fybutton = druid::widget::Button::from_label(button_label)
|
||||||
.fix_height(45.0)
|
.fix_height(45.0)
|
||||||
.center()
|
.center()
|
||||||
.on_click(move |_, _: &mut AppData, _| {
|
.on_click(move |_, _: &mut AppData, _| {
|
||||||
@@ -118,6 +135,8 @@ impl AmongUsLauncherWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flexbox_array.reverse();
|
||||||
|
|
||||||
for i in flexbox_array {
|
for i in flexbox_array {
|
||||||
flex.add_flex_child(i, 1.0);
|
flex.add_flex_child(i, 1.0);
|
||||||
}
|
}
|
||||||
|
|||||||
21
src/main.rs
21
src/main.rs
@@ -28,6 +28,8 @@ use druid::{
|
|||||||
WidgetPod, WindowDesc, WindowId,
|
WidgetPod, WindowDesc, WindowId,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use reqwest::StatusCode;
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Data, Clone, Debug)]
|
#[derive(PartialEq, Eq, Data, Clone, Debug)]
|
||||||
pub enum InitializingState {
|
pub enum InitializingState {
|
||||||
StartingGUI,
|
StartingGUI,
|
||||||
@@ -58,6 +60,7 @@ pub struct AppData {
|
|||||||
pub among_us_version: AmongUsVersion,
|
pub among_us_version: AmongUsVersion,
|
||||||
pub data_path: String,
|
pub data_path: String,
|
||||||
pub app_state: GlobalAppState,
|
pub app_state: GlobalAppState,
|
||||||
|
pub blessed_version: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
static AMONG_US_APPID: &str = "945360";
|
static AMONG_US_APPID: &str = "945360";
|
||||||
@@ -224,10 +227,12 @@ impl AppDelegate<AppData> for Delegate {
|
|||||||
"Downloading Town of Us... Please be patient! [{}]",
|
"Downloading Town of Us... Please be patient! [{}]",
|
||||||
ver_url.1.clone()
|
ver_url.1.clone()
|
||||||
);
|
);
|
||||||
let zip = reqwest::blocking::get(ver_url.1.clone())
|
let client = reqwest::blocking::Client::builder()
|
||||||
.unwrap()
|
.timeout(None)
|
||||||
.bytes()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
let zip_request = client.get(ver_url.1.clone()).build().unwrap();
|
||||||
|
let zip = client.execute(zip_request).unwrap().bytes().unwrap();
|
||||||
fs::write(download_path.clone(), zip).unwrap();
|
fs::write(download_path.clone(), zip).unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -266,6 +271,15 @@ impl AppDelegate<AppData> for Delegate {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
let version = env!("CARGO_PKG_VERSION");
|
||||||
let title_string: String = format!("Town of Us Updater - {}", version);
|
let title_string: String = format!("Town of Us Updater - {}", version);
|
||||||
|
let blessed_body = reqwest::blocking::get("https://tou.dormedas.com/blessed");
|
||||||
|
let response = blessed_body.unwrap();
|
||||||
|
|
||||||
|
let blessed_version: String = match response.status() {
|
||||||
|
StatusCode::OK => response.text().unwrap(),
|
||||||
|
_ => String::from("0.0.0-v0.0.0"),
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Blessed Version: {}", blessed_version);
|
||||||
|
|
||||||
// println!("Updater Version: {}", version);
|
// println!("Updater Version: {}", version);
|
||||||
// get_latest_updater_version().await.unwrap();
|
// get_latest_updater_version().await.unwrap();
|
||||||
@@ -308,6 +322,7 @@ fn main() {
|
|||||||
among_us_version: AmongUsVersion::default(),
|
among_us_version: AmongUsVersion::default(),
|
||||||
data_path: String::from(data_path.clone().to_str().unwrap()),
|
data_path: String::from(data_path.clone().to_str().unwrap()),
|
||||||
app_state: GlobalAppState::Initializing(InitializingState::StartingGUI),
|
app_state: GlobalAppState::Initializing(InitializingState::StartingGUI),
|
||||||
|
blessed_version,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut root_column: druid::widget::Flex<AppData> = druid::widget::Flex::column();
|
let mut root_column: druid::widget::Flex<AppData> = druid::widget::Flex::column();
|
||||||
|
|||||||
Reference in New Issue
Block a user