mirror of
https://github.com/PrimeDecomp/retrotool.git
synced 2026-07-12 18:18:58 -07:00
Embed assets in release builds
This commit is contained in:
@@ -186,7 +186,11 @@ jobs:
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
- name: Cargo build
|
||||
run: cargo ${{ matrix.build }} --release --target ${{ matrix.target }} --bin ${{ env.CARGO_BIN_NAME }}
|
||||
env:
|
||||
BEVY_ASSET_PATH: ${{ github.workspace }}/retrotool-gui/assets
|
||||
run: |
|
||||
cargo ${{ matrix.build }} --release --target ${{ matrix.target }} \
|
||||
--bin ${{ env.CARGO_BIN_NAME }} --features embed
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
|
||||
Generated
+17
@@ -534,6 +534,16 @@ dependencies = [
|
||||
"webbrowser",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_embedded_assets"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a1d4ecf67c553196cfdef560cf0748f1f699db5a86ed2aa211c958e2a379451"
|
||||
dependencies = [
|
||||
"bevy",
|
||||
"cargo-emit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bevy_encase_derive"
|
||||
version = "0.10.0"
|
||||
@@ -1014,6 +1024,12 @@ version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be"
|
||||
|
||||
[[package]]
|
||||
name = "cargo-emit"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1582e1c9e755dd6ad6b224dcffb135d199399a4568d454bd89fe515ca8425695"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.79"
|
||||
@@ -2788,6 +2804,7 @@ dependencies = [
|
||||
"astc-decode",
|
||||
"bevy",
|
||||
"bevy_egui",
|
||||
"bevy_embedded_assets",
|
||||
"binrw",
|
||||
"bit-set",
|
||||
"bytemuck",
|
||||
|
||||
@@ -12,11 +12,13 @@ readme = "README.md"
|
||||
[features]
|
||||
default = []
|
||||
dynamic = ["bevy/dynamic_linking"]
|
||||
embed = ["bevy_embedded_assets"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.69"
|
||||
astc-decode = "0.3.1"
|
||||
bevy_egui = "0.20.1"
|
||||
bevy_embedded_assets = { version = "0.7.0", optional = true }
|
||||
binrw = "0.11.1"
|
||||
bit-set = "0.5.3"
|
||||
bytemuck = "1.13.0"
|
||||
|
||||
@@ -105,6 +105,9 @@ pub struct RetroAssetIoPlugin;
|
||||
|
||||
impl Plugin for RetroAssetIoPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
#[cfg(feature = "embed")]
|
||||
let default = Box::new(bevy_embedded_assets::EmbeddedAssetIo::preloaded());
|
||||
#[cfg(not(feature = "embed"))]
|
||||
let default = AssetPlugin::default().create_platform_default_asset_io();
|
||||
let shared_package_info = SharedPackageInfo { packages: Arc::new(Default::default()) };
|
||||
let asset_io = RetroAssetIo { default, packages: shared_package_info.clone() };
|
||||
|
||||
@@ -21,11 +21,11 @@ use crate::{
|
||||
loaders::{
|
||||
material::MaterialAssetLoader,
|
||||
modcon::ModConAssetLoader,
|
||||
model::ModelAssetLoader,
|
||||
model::{ModelAsset, ModelAssetLoader},
|
||||
package::{
|
||||
package_loader_system, PackageAssetLoader, PackageDirectory, RetroAssetIoPlugin,
|
||||
},
|
||||
texture::TextureAssetLoader,
|
||||
texture::{TextureAsset, TextureAssetLoader},
|
||||
},
|
||||
material::CustomMaterial,
|
||||
render::TemporaryLabel,
|
||||
@@ -81,10 +81,11 @@ fn main() {
|
||||
.add_plugin(MaterialAssetLoader)
|
||||
.add_plugin(ModConAssetLoader)
|
||||
.add_plugin(EguiPlugin)
|
||||
.add_startup_system(setup_icon_font)
|
||||
.add_system(file_drop)
|
||||
.add_startup_system(setup_egui)
|
||||
.add_system(file_drop.before(load_files))
|
||||
.add_system(load_files)
|
||||
.add_system(package_loader_system)
|
||||
.add_system(package_loader_system.before(ui_system))
|
||||
.add_system(bottom_bar_system.before(ui_system))
|
||||
.add_system(ui_system)
|
||||
.run();
|
||||
}
|
||||
@@ -153,6 +154,25 @@ fn load_files(
|
||||
}
|
||||
}
|
||||
|
||||
fn bottom_bar_system(
|
||||
mut egui_ctx: EguiContexts,
|
||||
textures: Res<Assets<TextureAsset>>,
|
||||
models: Res<Assets<ModelAsset>>,
|
||||
entities: Query<Entity>,
|
||||
) {
|
||||
let entity_count = entities.iter().count();
|
||||
egui::TopBottomPanel::bottom("bottom_panel").show(egui_ctx.ctx_mut(), |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(format!(
|
||||
"[Loaded] Textures: {} | Models: {} | Entities: {}",
|
||||
textures.len(),
|
||||
models.len(),
|
||||
entity_count
|
||||
));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn ui_system(world: &mut World) {
|
||||
let mut ctx = world
|
||||
.query::<(&mut EguiContext, With<PrimaryWindow>)>()
|
||||
@@ -232,7 +252,7 @@ fn ui_system(world: &mut World) {
|
||||
});
|
||||
}
|
||||
|
||||
fn setup_icon_font(mut context: EguiContexts, state: ResMut<UiState>) {
|
||||
fn setup_egui(mut context: EguiContexts, state: ResMut<UiState>) {
|
||||
let ctx = context.ctx_mut();
|
||||
|
||||
let font = egui::FontData::from_static(include_bytes!("../icon.ttf"));
|
||||
|
||||
@@ -42,7 +42,6 @@ pub struct ModConTab {
|
||||
pub camera: ModelCamera,
|
||||
pub diffuse_map: Handle<Image>,
|
||||
pub specular_map: Handle<Image>,
|
||||
pub combined_aabb: Aabb,
|
||||
}
|
||||
|
||||
impl ModConTab {
|
||||
@@ -181,17 +180,14 @@ impl SystemTab for ModConTab {
|
||||
loaded = true;
|
||||
}
|
||||
|
||||
if loaded {
|
||||
let all_loaded = self.models.iter().all(|m| !m.loaded.is_empty());
|
||||
if all_loaded {
|
||||
let mut min = Vec3A::splat(f32::MAX);
|
||||
let mut max = Vec3A::splat(f32::MIN);
|
||||
for info in &self.models {
|
||||
min = info.aabb.min().min(min);
|
||||
max = info.aabb.max().max(max);
|
||||
}
|
||||
self.camera.init(&Aabb::from_min_max(min.into(), max.into()), true);
|
||||
if loaded && self.models.iter().all(|m| !m.loaded.is_empty()) {
|
||||
let mut min = Vec3A::splat(f32::MAX);
|
||||
let mut max = Vec3A::splat(f32::MIN);
|
||||
for info in &self.models {
|
||||
min = info.aabb.min().min(min);
|
||||
max = info.aabb.max().max(max);
|
||||
}
|
||||
self.camera.init(&Aabb::from_min_max(min.into(), max.into()), true);
|
||||
}
|
||||
|
||||
// FIXME
|
||||
@@ -230,8 +226,7 @@ impl SystemTab for ModConTab {
|
||||
self.camera.update(&rect, &response, ui.input(|i| i.scroll_delta));
|
||||
|
||||
let (mut commands, server, models, mod_con_assets) = query;
|
||||
let all_loaded = self.models.iter().all(|m| !m.loaded.is_empty());
|
||||
if !all_loaded {
|
||||
if !self.models.iter().all(|m| !m.loaded.is_empty()) {
|
||||
ui.centered_and_justified(|ui| {
|
||||
match self.get_load_state(&server, &mod_con_assets, &models) {
|
||||
LoadState::Failed => egui::Label::new(
|
||||
|
||||
Reference in New Issue
Block a user