-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e700295
commit 54d7ff4
Showing
2 changed files
with
37 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use eframe::egui::{self, ImageData, ImageSource}; | ||
use nohash_hasher::IntMap; | ||
|
||
use crate::GAME_DIR; | ||
|
||
pub struct ImageCache { | ||
pub games: IntMap<i64, ImageData>, | ||
} | ||
|
||
impl ImageCache { | ||
pub const fn default_game_image() -> &'static ImageSource<'static> { | ||
&egui::include_image!("./../../default-logo.png") | ||
} | ||
|
||
pub fn new() -> Self { | ||
std::fs::create_dir(GAME_DIR).unwrap(); | ||
let dir = std::fs::read_dir(GAME_DIR).unwrap(); | ||
|
||
let mut games = IntMap::default(); | ||
|
||
for file in dir.into_iter() { | ||
if let Ok(path) = file.map(|file| file.path()) { | ||
if let Some(extension) = path.extension() { | ||
if extension == "png" { | ||
// TODO: Load the image and push it into the map | ||
} | ||
} | ||
} | ||
} | ||
|
||
Self { games } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters