Skip to content

Commit

Permalink
Changed window icon mechanics
Browse files Browse the repository at this point in the history
  • Loading branch information
markusmoenig committed Jan 15, 2024
1 parent bd54b5f commit 3fe933f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 155 deletions.
140 changes: 0 additions & 140 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions creator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ rust-embed = { version = "8", default-features = true, features = ["include-excl
png = "0.17"
open = "5.0.1"

[target.'cfg(not(target_os = "macos"))'.dependencies]
image_rs = { version = "0.24.8", package = "image" }

[package.metadata.bundle]
name = "Eldiron"
identifier = "com.moenig.eldiron"
Expand Down
Binary file added creator/embedded/window_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 13 additions & 12 deletions creator/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ impl TheTrait for Editor {
}
}

fn window_title(&self) -> String {
"Eldiron Creator".to_string()
}

#[cfg(not(target_os = "macos"))]
fn window_icon(&self) -> Option<(Vec<u8>, u32, u32)> {
if let Some(image) = image_rs::load_from_memory(include_bytes!("../../build/windows/Eldiron.ico")) {
let image = image.into_rgba8();

let (width, height) = image.dimensions();

let icon = (image.into_raw(), width, height);
Some(icon)
if let Some(file) = Embedded::get("window_logo.png") {
let data = std::io::Cursor::new(file.data);

let decoder = png::Decoder::new(data);
if let Ok(mut reader) = decoder.read_info() {
let mut buf = vec![0; reader.output_buffer_size()];
let info = reader.next_frame(&mut buf).unwrap();
let bytes = &buf[..info.buffer_size()];

Some((bytes.to_vec(), info.width, info.height))
} else {
None
}
} else {
None
}
Expand Down

0 comments on commit 3fe933f

Please sign in to comment.