Skip to content

Commit

Permalink
Merge pull request #76 from Jupeyy/pr_consistent_asset_names
Browse files Browse the repository at this point in the history
Use consistent naming scheme for asset parts.
  • Loading branch information
Jupeyy authored Jan 17, 2025
2 parents 4537b1e + ef5e25f commit 82e4d70
Show file tree
Hide file tree
Showing 23 changed files with 1,018 additions and 1,229 deletions.
10 changes: 10 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ members = [
"lib/steam",
"game/game-state-wasm", "lib/native-display", "src/assets-server", "game/assets-base", "src/community-server",
"src/community-register-server",
"game/community", "lib/input-binds", "game/ghost", "game/client-ghost", "game/client-replay", "game/editor-wasm", "game/client-notifications", "src/editor-server",
"game/community", "lib/input-binds", "game/ghost", "game/client-ghost", "game/client-replay", "game/editor-wasm", "game/client-notifications", "src/editor-server", "src/extra-convert",
]

[package]
Expand Down
2 changes: 1 addition & 1 deletion data
Submodule data updated 268 files
77 changes: 77 additions & 0 deletions game/client-containers/src/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,45 @@ pub fn load_file_part_and_upload_ex(
})
}

pub fn load_file_part_list_and_upload(
graphics_mt: &GraphicsMultiThreaded,
files: &ContainerLoadedItemDir,
default_files: &ContainerLoadedItemDir,
item_name: &str,
extra_paths: &[&str],
part_name_base: &str,
) -> anyhow::Result<Vec<ContainerItemLoadData>> {
let mut textures = Vec::new();
let mut i = 0;
let mut allow_default = true;
loop {
match load_file_part_and_upload_ex(
graphics_mt,
files,
default_files,
item_name,
extra_paths,
&format!("{part_name_base}_{:03}", i + 1),
allow_default,
) {
Ok(img) => {
allow_default &= img.from_default;
textures.push(img.img);
}
Err(err) => {
if i == 0 {
return Err(err);
} else {
break;
}
}
}

i += 1;
}
Ok(textures)
}

pub struct SoundFilePartResult {
pub mem: SoundBackendMemory,
/// Was loaded by the default fallback mechanism
Expand Down Expand Up @@ -1570,6 +1609,44 @@ pub fn load_sound_file_part_and_upload_ex(
Ok(SoundFilePartResult { mem, from_default })
}

pub fn load_sound_file_part_list_and_upload(
sound_mt: &SoundMultiThreaded,
files: &ContainerLoadedItemDir,
default_files: &ContainerLoadedItemDir,
item_name: &str,
extra_paths: &[&str],
part_name_base: &str,
) -> anyhow::Result<Vec<SoundBackendMemory>> {
let mut sounds = Vec::new();
let mut i = 0;
let mut allow_default = true;
loop {
match load_sound_file_part_and_upload_ex(
sound_mt,
files,
default_files,
item_name,
extra_paths,
&format!("{part_name_base}_{:03}", i + 1),
allow_default,
) {
Ok(sound) => {
allow_default &= sound.from_default;
sounds.push(sound.mem);
}
Err(err) => {
if i == 0 {
return Err(err);
} else {
break;
}
}
}
i += 1;
}
Ok(sounds)
}

/// returns the png data, the width and height are the 3d texture w & h, additionally the depth is returned
pub fn load_file_part_as_png_and_convert_3d(
runtime_thread_pool: &Arc<rayon::ThreadPool>,
Expand Down
42 changes: 11 additions & 31 deletions game/client-containers/src/freezes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use sound::{
};

use crate::{
container::{load_sound_file_part_and_upload_ex, ContainerLoadedItem, ContainerLoadedItemDir},
container::{
load_sound_file_part_list_and_upload, ContainerLoadedItem, ContainerLoadedItemDir,
},
skins::{LoadSkin, Skin},
};

Expand Down Expand Up @@ -49,36 +51,14 @@ impl LoadFreeze {
Some("skin"),
)?,

attacks: {
let mut sounds = Vec::new();
let mut i = 0;
let mut allow_default = true;
loop {
match load_sound_file_part_and_upload_ex(
sound_mt,
&files,
default_files,
freeze_name,
&["audio"],
&format!("attack{}", i + 1),
allow_default,
) {
Ok(sound) => {
allow_default &= sound.from_default;
sounds.push(sound.mem);
}
Err(err) => {
if i == 0 {
return Err(err);
} else {
break;
}
}
}
i += 1;
}
sounds
},
attacks: load_sound_file_part_list_and_upload(
sound_mt,
&files,
default_files,
freeze_name,
&["audio"],
"attack",
)?,

_freeze_name: freeze_name.to_string(),
})
Expand Down
Loading

0 comments on commit 82e4d70

Please sign in to comment.