Skip to content

Commit

Permalink
Touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Bash authored and Bash committed May 26, 2024
1 parent b00cfcf commit cc617ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,12 @@ pub fn details(app: &App) -> IcedContainer<'_> {
]
.spacing(15),
// convert
widget::button("Create Replay").on_press(Message::CreateReplay)
widget::row![
widget::button("Create Replay").on_press(Message::CreateReplay),
widget::text(&app.status)
]
.align_items(iced::Alignment::Center)
.spacing(15)
]
.spacing(15);

Expand Down
19 changes: 14 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ impl Application for App {
&header.map,
);

println!("Loaded demo: {header:?}");
self.demo = Ok(header);
self.status = String::new();
}
Message::ClearThumbnail => {
if let Err(e) = self.load_thumbnail(None) {
Expand All @@ -166,7 +166,9 @@ impl Application for App {
}
Message::CreateReplay => {
if let Err(e) = self.create_replay() {
println!("Error creating replay: {e:?}");
self.status = format!("Error creating replay: {e}");
} else {
self.status = String::from("Successfully created replay!");
}
}
Message::SetReplayName(name) => self.replay_name = name,
Expand Down Expand Up @@ -232,6 +234,9 @@ impl App {
};

let file_name = filenamify(&self.replay_name);
if file_name.trim().is_empty() {
return Err(anyhow!("Replay name is not valid"));
}

let handle = &mut std::fs::read_dir(tf2_dir.join(DIR_REPLAY))
.context("Reading replay folder")?
Expand Down Expand Up @@ -295,9 +300,13 @@ impl App {
}

fn main() {
App::run(iced::Settings::with_flags(
let mut settings = iced::Settings::with_flags(
steamlocate::SteamDir::locate()
.and_then(|mut s| s.app(&TF2_APP_ID).map(|a| a.path.clone())),
))
.expect("Failed to run app.");
);

settings.window.size.width = 1050.0;
settings.window.size.height = 500.0;

App::run(settings).expect("Failed to run app.");
}

0 comments on commit cc617ff

Please sign in to comment.