Skip to content

Commit

Permalink
Add file/game icons on macOS and config setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kelpsyberry committed Feb 10, 2024
1 parent 4a1861e commit 01d287c
Show file tree
Hide file tree
Showing 9 changed files with 550 additions and 212 deletions.
13 changes: 10 additions & 3 deletions core/src/ds_slot/rom/icon.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use super::Contents;
use super::{header::Header, Contents};
use crate::utils::Bytes;

#[inline]
pub fn decode(
pub fn decode_to_rgba8(
icon_title_offset: usize,
rom_contents: &mut impl Contents,
) -> Option<[u32; 32 * 32]> {
Expand Down Expand Up @@ -34,3 +33,11 @@ pub fn decode(
}
Some(pixels)
}

pub fn read_header_and_decode_to_rgba8(rom_contents: &mut impl Contents) -> Option<[u32; 32 * 32]> {
let mut header_bytes = Bytes::new([0; 0x170]);
rom_contents.read_header(&mut header_bytes);
let header = Header::new(header_bytes.as_byte_slice())?;
let icon_title_offset = header.icon_title_offset() as usize;
decode_to_rgba8(icon_title_offset, rom_contents)
}
3 changes: 0 additions & 3 deletions core/src/gpu/engine_3d/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ pub trait RendererTx {
fn skip_rendering(&mut self);
}

// TODO: Use the SCREEN_WIDTH/SCREEN_HEIGHT constants, can't right now due to a compiler bug making
// the trait stop being object-safe in that case.

pub trait SoftRendererRx {
fn start_frame(&mut self);
fn read_scanline(&mut self) -> &Scanline<u32>;
Expand Down
1 change: 1 addition & 0 deletions frontend/desktop/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ gdb-protocol = { version = "0.1", optional = true }
[target.'cfg(target_os = "macos")'.dependencies]
cocoa = "0.25"
objc = "0.2"
tempdir = "0.3"
9 changes: 9 additions & 0 deletions frontend/desktop/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ impl TitleBarMode {
}
}

#[derive(Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]
pub enum GameIconMode {
None,
File,
Game,
}

fn resolve_opt_nonzero_u32(
global: &u32,
game: &Option<u32>,
Expand Down Expand Up @@ -457,6 +465,7 @@ def_config! {
tracked {
global {
title_bar_mode: TitleBarMode = TitleBarMode::System,
game_icon_mode: GameIconMode = GameIconMode::Game,
game_db_path: Option<HomePathBuf> = Some(
HomePathBuf(base_dirs().data.join("game_db.json"))
),
Expand Down
2 changes: 1 addition & 1 deletion frontend/desktop/src/emu/dldi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl FsProvider {
return Ok(());
}
let mut chunk_manager = ChunkManager {
temp_dir: TempDir::new("dust")?,
temp_dir: TempDir::new("dust-dldi")?,
cur_addr: 0,
fs_max_size: 1 << 30,
chunk_size_shift: 22,
Expand Down
Loading

0 comments on commit 01d287c

Please sign in to comment.