Skip to content

Commit

Permalink
UI for image download refactor and fixes (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipK authored Apr 24, 2022
1 parent 5721c8d commit d2ccef8
Show file tree
Hide file tree
Showing 7 changed files with 407 additions and 323 deletions.
2 changes: 1 addition & 1 deletion src/steam/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub struct ShortcutInfo {
pub shortcuts: Vec<ShortcutOwned>,
}

#[derive(Default, PartialEq, Clone)]
#[derive(Default, PartialEq, Clone, Debug)]
pub struct SteamUsersInfo {
pub steam_user_data_folder: String,
pub shortcut_path: Option<String>,
Expand Down
7 changes: 4 additions & 3 deletions src/steamgriddb/cached_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ impl<'a> CachedSearch<'a> {
save_search_map(&self.search_map);
}

pub fn set_cache<S>(&mut self, app_id: u32, name:S, new_grid_id:usize)
pub fn set_cache<S>(&mut self, app_id: u32, name: S, new_grid_id: usize)
where
S: Into<String>{
self.search_map.insert(app_id,(name.into(),new_grid_id));
S: Into<String>,
{
self.search_map.insert(app_id, (name.into(), new_grid_id));
self.save();
}

Expand Down
10 changes: 5 additions & 5 deletions src/steamgriddb/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,12 @@ async fn get_images_for_ids(
image_search_result.map_err(|e| format!("Image search failed {:?}", e))
}

const BIG_PICTURE_DIMS : [GridDimentions;2] = [GridDimentions::D920x430, GridDimentions::D460x215];
const BIG_PICTURE_DIMS: [GridDimentions; 2] = [GridDimentions::D920x430, GridDimentions::D460x215];

pub fn get_query_type(download_animated: bool, image_type: &ImageType) -> steamgriddb_api::QueryType {
pub fn get_query_type(
download_animated: bool,
image_type: &ImageType,
) -> steamgriddb_api::QueryType {
let anymation_type = if download_animated {
Some(&[steamgriddb_api::query_parameters::AnimtionType::Animated][..])
} else {
Expand Down Expand Up @@ -366,6 +369,3 @@ pub struct ToDownload {
pub app_name: String,
pub image_type: ImageType,
}

unsafe impl Send for ToDownload {
}
17 changes: 11 additions & 6 deletions src/steamgriddb/image_type.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#[derive(Debug, Clone, Copy,PartialEq)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum ImageType {
Hero,
Grid,
Expand All @@ -8,16 +8,21 @@ pub enum ImageType {
Icon,
}

pub const ALL_TYPES : [ImageType;6] =
[ImageType::Hero,ImageType::Grid,ImageType::WideGrid,ImageType::Logo,ImageType::BigPicture,ImageType::Icon];
pub const ALL_TYPES: [ImageType; 6] = [
ImageType::Hero,
ImageType::Grid,
ImageType::WideGrid,
ImageType::Logo,
ImageType::BigPicture,
ImageType::Icon,
];

impl ImageType {

pub fn all() -> &'static [ImageType;6]{
pub fn all() -> &'static [ImageType; 6] {
&ALL_TYPES
}

pub fn name(&self) -> &str{
pub fn name(&self) -> &str {
match self {
ImageType::Hero => "Hero",
ImageType::Grid => "Grid",
Expand Down
690 changes: 382 additions & 308 deletions src/ui/ui_image_download.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/ui/ui_import_games.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl MyEguiApp {
ui.label("Check the settings if BoilR didn't find the game you where looking for");
},
_=> {
ui.ctx().request_repaint();
ui.label("Finding installed games");
},
};
Expand Down
3 changes: 3 additions & 0 deletions src/ui/uiapp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ impl epi::App for MyEguiApp {
}
SyncProgress::Done => ("Done importing games".to_string(), false),
};
if syncing {
ui.ctx().request_repaint();
}
if !status_string.is_empty() {
ui.label(status_string);
}
Expand Down

0 comments on commit d2ccef8

Please sign in to comment.