Skip to content

Commit 2a073c6

Browse files
committed
Panicking trying to set WINIT_WINDOWS
1 parent e72bda1 commit 2a073c6

File tree

13 files changed

+334
-3
lines changed

13 files changed

+334
-3
lines changed

Cargo.lock

Lines changed: 86 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,26 @@ crossbeam-channel = "0.5"
4343
mft = { version = "0.6.1", git = "https://github.com/TeamDman/mft", branch = "mine" }
4444
rustc-hash = "2.1.1"
4545
winstructs = "0.3.2"
46-
uom = { version = "0.37.0", features = ["autoconvert", "human", "usize"], git = "https://github.com/TeamDman/uom", branch = "mine" }
46+
uom = { version = "0.37.0", features = [
47+
"autoconvert",
48+
"human",
49+
"usize",
50+
], git = "https://github.com/TeamDman/uom", branch = "mine" }
4751
rayon = { version = "1.10" }
4852
humantime = "2.2.0"
4953
thousands = "0.2.0"
5054
nucleo = "0.5.0"
5155
chrono = "0.4.41"
52-
compact_str = {version="0.9.0", git="https://github.com/TeamDman/compact_str", branch="mine", features=["bevy-reflect"]}
56+
compact_str = { version = "0.9.0", git = "https://github.com/TeamDman/compact_str", branch = "mine", features = [
57+
"bevy-reflect",
58+
] }
5359
teamy-windows = "0.2.0"
5460
bevy = "0.17.0-rc.1"
61+
bevy_winit = "0.17.0-rc.1"
62+
winit = { version = "0.30.12", default-features = false }
63+
64+
[build-dependencies]
65+
embed-resource = "3.0.3"
5566

5667
[dev-dependencies]
5768
tempfile = "3.20"

assets/textures/icon.png

145 KB
Loading

build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
extern crate embed_resource;
2+
fn main() {
3+
println!("cargo:rerun-if-changed=icons.rc");
4+
println!("cargo:rerun-if-changed=favicon.ico");
5+
embed_resource::compile("icons.rc", embed_resource::NONE)
6+
.manifest_required()
7+
.unwrap();
8+
}

favicon.ico

237 KB
Binary file not shown.

icons.rc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aaa_my_icon ICON "favicon.ico"

make-icon.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# create .ico
2+
magick convert -background transparent "assets/textures/icon.png" -define icon:auto-resize=16,24,32,48,64,72,96,128,256 "favicon.ico"
3+
4+
# create resized image
5+
# magick convert -background transparent "original_icon.png" -resize 64x64 ".\assets\textures\icon.png"

src/engine/assets/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod textures;

src/engine/assets/textures.rs

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
use bevy::asset::AssetPath;
2+
use std::path::Path;
3+
use strum::VariantArray;
4+
5+
#[derive(VariantArray, Clone, Copy, Eq, Debug, PartialEq)]
6+
pub enum MyTexture {
7+
Icon,
8+
}
9+
impl From<MyTexture> for AssetPath<'static> {
10+
fn from(value: MyTexture) -> Self {
11+
AssetPath::from_path(match value {
12+
MyTexture::Icon => Path::new("textures/icon.png"),
13+
})
14+
}
15+
}
16+
17+
#[cfg(test)]
18+
mod test {
19+
use crate::engine::assets::textures::MyTexture;
20+
use bevy::asset::AssetPath;
21+
use std::path::Path;
22+
use strum::VariantArray;
23+
24+
#[test]
25+
fn texture_exists() {
26+
for font in MyTexture::VARIANTS.iter().cloned() {
27+
let assets_dir =
28+
Path::new(&std::env::var("CARGO_MANIFEST_DIR").unwrap()).join("../../assets");
29+
let asset_path: AssetPath = font.into();
30+
let path = assets_dir.join(asset_path.path());
31+
let exists = path.exists();
32+
assert!(
33+
exists,
34+
"Texture {:?} does not exist in the assets dir: {}",
35+
font,
36+
path.display()
37+
);
38+
}
39+
}
40+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use crate::engine::assets::textures::MyTexture;
2+
use crate::engine::window_icon_plugin::WindowIcon;
3+
use bevy::prelude::*;
4+
5+
/// Marker component for the overview window entity
6+
#[derive(Component, Reflect, Debug, Default)]
7+
#[reflect(Component)]
8+
pub struct MftFileOverviewWindow;
9+
10+
pub struct MftFileOverviewWindowPlugin;
11+
12+
impl Plugin for MftFileOverviewWindowPlugin {
13+
fn build(&self, app: &mut App) {
14+
app.register_type::<MftFileOverviewWindow>();
15+
app.add_systems(Startup, spawn_overview_window_if_missing);
16+
}
17+
}
18+
19+
const WINDOW_TITLE: &str = "MFT Files - Overview";
20+
21+
fn spawn_overview_window_if_missing(
22+
mut commands: Commands,
23+
existing: Query<Entity, With<MftFileOverviewWindow>>,
24+
asset_server: Res<AssetServer>,
25+
) {
26+
if existing.is_empty() {
27+
// Create a new standalone window with the required title
28+
commands.spawn((
29+
Window {
30+
title: WINDOW_TITLE.into(),
31+
..default()
32+
},
33+
MftFileOverviewWindow,
34+
WindowIcon::new(asset_server.load(MyTexture::Icon)),
35+
));
36+
info!(title = WINDOW_TITLE, "Spawned MFT overview window");
37+
}
38+
}

0 commit comments

Comments
 (0)