added fallback icons for resource packs and worlds
resource packs and worlds without icons now show a placeholder "?" pattern like mods already do. worlds use a larger 12x6 variant.
This commit is contained in:
1 parent
a29c90e86b
commit
ea59e39159
3 files changed
+42
-4
No files matched your search
@@ -226,8 +226,8 @@ pub(crate) fn make_icon_pixels(
|
||||
Some(rows)
|
||||
}
|
||||
|
||||
/// 6x3 fallback icon showing a "?" pattern for mods without icons.
|
||||
fn fallback_icon() -> Vec<Vec<IconCell>> {
|
||||
// 6x3 fallback icon showing a "?" pattern for mods without icons.
|
||||
pub(super) fn fallback_icon() -> Vec<Vec<IconCell>> {
|
||||
let b = IconCell {
|
||||
bg_r: 50,
|
||||
bg_g: 50,
|
||||
@@ -259,6 +259,42 @@ fn fallback_icon() -> Vec<Vec<IconCell>> {
|
||||
]
|
||||
}
|
||||
|
||||
// 12x6 fallback icon showing a "?" pattern for worlds without icons.
|
||||
pub(super) fn fallback_icon_large() -> Vec<Vec<IconCell>> {
|
||||
let b = IconCell {
|
||||
bg_r: 50,
|
||||
bg_g: 50,
|
||||
bg_b: 50,
|
||||
fg_r: 50,
|
||||
fg_g: 50,
|
||||
fg_b: 50,
|
||||
};
|
||||
let tb = IconCell {
|
||||
bg_r: 50,
|
||||
bg_g: 50,
|
||||
bg_b: 50,
|
||||
fg_r: 130,
|
||||
fg_g: 130,
|
||||
fg_b: 130,
|
||||
};
|
||||
let bt = IconCell {
|
||||
bg_r: 130,
|
||||
bg_g: 130,
|
||||
bg_b: 130,
|
||||
fg_r: 50,
|
||||
fg_g: 50,
|
||||
fg_b: 50,
|
||||
};
|
||||
vec![
|
||||
vec![b, b, tb, tb, tb, tb, tb, tb, tb, tb, b, b],
|
||||
vec![b, b, tb, tb, tb, tb, tb, tb, tb, tb, b, b],
|
||||
vec![b, b, b, b, b, b, bt, bt, bt, bt, b, b],
|
||||
vec![b, b, b, b, b, b, bt, bt, bt, bt, b, b],
|
||||
vec![b, b, b, b, bt, bt, bt, bt, b, b, b, b],
|
||||
vec![b, b, b, b, bt, bt, bt, bt, b, b, b, b],
|
||||
]
|
||||
}
|
||||
|
||||
// enable/disable by renaming the file with/without ".disabled" suffix.
|
||||
// the minecraft way, apparently.
|
||||
pub fn toggle_entry(entry: &ContentEntry) -> Result<(), std::io::Error> {
|
||||
|
||||
@@ -80,7 +80,8 @@ pub fn scan_resource_packs(instances_dir: &Path, instance_name: &str) -> Vec<Con
|
||||
|
||||
let icon_lines = icon_bytes
|
||||
.as_ref()
|
||||
.and_then(|bytes| make_icon_pixels(bytes, 6, 3));
|
||||
.and_then(|bytes| make_icon_pixels(bytes, 6, 3))
|
||||
.or_else(|| Some(super::mods::fallback_icon()));
|
||||
|
||||
let display_name = if name.is_empty() { file_stem.clone() } else { name };
|
||||
entries.push(ContentEntry {
|
||||
|
||||
@@ -35,7 +35,8 @@ pub fn scan_worlds(instances_dir: &Path, instance_name: &str) -> Vec<ContentEntr
|
||||
let icon_bytes = std::fs::read(path.join("icon.png")).ok();
|
||||
let icon_lines = icon_bytes
|
||||
.as_ref()
|
||||
.and_then(|bytes| make_icon_pixels(bytes, 12, 6));
|
||||
.and_then(|bytes| make_icon_pixels(bytes, 12, 6))
|
||||
.or_else(|| Some(super::mods::fallback_icon_large()));
|
||||
|
||||
let description = world_description(&path);
|
||||
|
||||
|
||||
Reference in new issue
Block a user