Compare commits
4 Commits
fbc4c747a5
...
3.0.0
| Author | SHA1 | Date | |
|---|---|---|---|
| ff311475dc | |||
| 8e61c8a2f2 | |||
| 97cdf4829a | |||
| 7244c24fe4 |
@@ -1,7 +1,8 @@
|
||||
use crate::AmongUsVersion;
|
||||
use crate::AppData;
|
||||
use druid::{
|
||||
widget::*, BoxConstraints, Env, Event, EventCtx, FileDialogOptions, LayoutCtx, LifeCycle,
|
||||
LifeCycleCtx, PaintCtx, Selector, Size, UpdateCtx, WidgetExt, WidgetPod,
|
||||
widget::*, BoxConstraints, Color, Env, Event, EventCtx, FileDialogOptions, LayoutCtx,
|
||||
LifeCycle, LifeCycleCtx, PaintCtx, Selector, Size, UpdateCtx, WidgetExt, WidgetPod,
|
||||
};
|
||||
use std::{fs, io, path::PathBuf};
|
||||
|
||||
@@ -56,14 +57,22 @@ impl AmongUsLauncherWidget {
|
||||
// Iterate first to find labels:
|
||||
|
||||
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 {
|
||||
let existing_ver_smash = i.as_ref().unwrap().file_name();
|
||||
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
||||
let auv = ver_smash_split.next().unwrap();
|
||||
if !auv_array.contains(&auv.to_string()) {
|
||||
let label_text = format!("Among Us {}", auv);
|
||||
let among_us_version = AmongUsVersion::from(ver_smash_split.next().unwrap());
|
||||
if !auv_array.contains(&among_us_version) {
|
||||
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()
|
||||
.with_flex_child(
|
||||
druid::widget::Label::new(label_text.as_str()).with_text_size(24.0),
|
||||
@@ -71,8 +80,6 @@ impl AmongUsLauncherWidget {
|
||||
)
|
||||
.with_default_spacer();
|
||||
flexbox_array.push(flex);
|
||||
auv_array.push(auv.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
println!("Installs list:");
|
||||
@@ -80,18 +87,28 @@ impl AmongUsLauncherWidget {
|
||||
for i in collection {
|
||||
let existing_ver_smash = i.unwrap().file_name();
|
||||
let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-');
|
||||
let auv = ver_smash_split.next().unwrap();
|
||||
let button_string: String =
|
||||
format!("Town of Us {}", ver_smash_split.next().unwrap());
|
||||
let mut blessed_split = data.blessed_version.as_str().split('-');
|
||||
let blessed_version = AmongUsVersion::from(blessed_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() {
|
||||
if j == auv {
|
||||
if j == &among_us_version {
|
||||
let mut clone: PathBuf = PathBuf::from(data.installs_path.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 fybutton = druid::widget::Button::new(button_string.as_str())
|
||||
let fybutton = druid::widget::Button::from_label(button_label)
|
||||
.fix_height(45.0)
|
||||
.center()
|
||||
.on_click(move |_, _: &mut AppData, _| {
|
||||
@@ -118,6 +135,8 @@ impl AmongUsLauncherWidget {
|
||||
}
|
||||
}
|
||||
|
||||
flexbox_array.reverse();
|
||||
|
||||
for i in flexbox_array {
|
||||
flex.add_flex_child(i, 1.0);
|
||||
}
|
||||
|
||||
13
src/main.rs
13
src/main.rs
@@ -28,6 +28,8 @@ use druid::{
|
||||
WidgetPod, WindowDesc, WindowId,
|
||||
};
|
||||
|
||||
use reqwest::StatusCode;
|
||||
|
||||
#[derive(PartialEq, Eq, Data, Clone, Debug)]
|
||||
pub enum InitializingState {
|
||||
StartingGUI,
|
||||
@@ -58,6 +60,7 @@ pub struct AppData {
|
||||
pub among_us_version: AmongUsVersion,
|
||||
pub data_path: String,
|
||||
pub app_state: GlobalAppState,
|
||||
pub blessed_version: String,
|
||||
}
|
||||
|
||||
static AMONG_US_APPID: &str = "945360";
|
||||
@@ -268,6 +271,15 @@ impl AppDelegate<AppData> for Delegate {
|
||||
fn main() {
|
||||
let version = env!("CARGO_PKG_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);
|
||||
// get_latest_updater_version().await.unwrap();
|
||||
@@ -310,6 +322,7 @@ fn main() {
|
||||
among_us_version: AmongUsVersion::default(),
|
||||
data_path: String::from(data_path.clone().to_str().unwrap()),
|
||||
app_state: GlobalAppState::Initializing(InitializingState::StartingGUI),
|
||||
blessed_version,
|
||||
};
|
||||
|
||||
let mut root_column: druid::widget::Flex<AppData> = druid::widget::Flex::column();
|
||||
|
||||
Reference in New Issue
Block a user