fix pbxgen stress scene glyph asset id mismatch
This commit is contained in:
parent
4227d26101
commit
41801a8e7a
@ -25,6 +25,9 @@ use std::fs;
|
|||||||
use std::mem::size_of;
|
use std::mem::size_of;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
const STRESS_GLYPH_ASSET_ID: AssetId = 100;
|
||||||
|
const STRESS_SCENE_ASSET_ID: AssetId = 1;
|
||||||
|
|
||||||
fn asm(s: &str) -> Vec<u8> {
|
fn asm(s: &str) -> Vec<u8> {
|
||||||
assemble(s).expect("assemble")
|
assemble(s).expect("assemble")
|
||||||
}
|
}
|
||||||
@ -224,7 +227,7 @@ fn build_assets_pack() -> Result<Vec<u8>> {
|
|||||||
let scene = build_scene_bank();
|
let scene = build_scene_bank();
|
||||||
let scene_payload = encode_scene_payload(&scene);
|
let scene_payload = encode_scene_payload(&scene);
|
||||||
let scene_entry = AssetEntry {
|
let scene_entry = AssetEntry {
|
||||||
asset_id: 1,
|
asset_id: STRESS_SCENE_ASSET_ID,
|
||||||
asset_name: "stress_scene".into(),
|
asset_name: "stress_scene".into(),
|
||||||
bank_type: BankType::SCENE,
|
bank_type: BankType::SCENE,
|
||||||
offset: glyph_payload.len() as u64,
|
offset: glyph_payload.len() as u64,
|
||||||
@ -235,8 +238,10 @@ fn build_assets_pack() -> Result<Vec<u8>> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let asset_table = vec![glyph_entry, scene_entry];
|
let asset_table = vec![glyph_entry, scene_entry];
|
||||||
let preload =
|
let preload = vec![
|
||||||
vec![PreloadEntry { asset_id: 0, slot: 0 }, PreloadEntry { asset_id: 1, slot: 0 }];
|
PreloadEntry { asset_id: STRESS_GLYPH_ASSET_ID, slot: 0 },
|
||||||
|
PreloadEntry { asset_id: STRESS_SCENE_ASSET_ID, slot: 0 },
|
||||||
|
];
|
||||||
let payload_len = glyph_payload.len() + scene_payload.len();
|
let payload_len = glyph_payload.len() + scene_payload.len();
|
||||||
let header = serde_json::to_vec(&AssetsPackHeader { asset_table, preload })?;
|
let header = serde_json::to_vec(&AssetsPackHeader { asset_table, preload })?;
|
||||||
let payload_offset = (ASSETS_PA_PRELUDE_SIZE + header.len()) as u64;
|
let payload_offset = (ASSETS_PA_PRELUDE_SIZE + header.len()) as u64;
|
||||||
@ -264,7 +269,7 @@ fn build_glyph_asset() -> (AssetEntry, Vec<u8>) {
|
|||||||
payload.extend_from_slice(&build_palette_bytes());
|
payload.extend_from_slice(&build_palette_bytes());
|
||||||
|
|
||||||
let entry = AssetEntry {
|
let entry = AssetEntry {
|
||||||
asset_id: 0,
|
asset_id: STRESS_GLYPH_ASSET_ID,
|
||||||
asset_name: "stress_square".into(),
|
asset_name: "stress_square".into(),
|
||||||
bank_type: BankType::GLYPH,
|
bank_type: BankType::GLYPH,
|
||||||
offset: 0,
|
offset: 0,
|
||||||
@ -339,7 +344,7 @@ fn build_scene_bank() -> SceneBank {
|
|||||||
|
|
||||||
SceneLayer {
|
SceneLayer {
|
||||||
active: true,
|
active: true,
|
||||||
glyph_asset_id: 100,
|
glyph_asset_id: STRESS_GLYPH_ASSET_ID,
|
||||||
tile_size: TileSize::Size8,
|
tile_size: TileSize::Size8,
|
||||||
parallax_factor: match layer_index {
|
parallax_factor: match layer_index {
|
||||||
0 => ParallaxFactor { x: 1.0, y: 1.0 },
|
0 => ParallaxFactor { x: 1.0, y: 1.0 },
|
||||||
@ -431,8 +436,12 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(header.asset_table.len(), 2);
|
assert_eq!(header.asset_table.len(), 2);
|
||||||
assert_eq!(header.preload.len(), 2);
|
assert_eq!(header.preload.len(), 2);
|
||||||
|
assert_eq!(header.asset_table[0].asset_id, STRESS_GLYPH_ASSET_ID);
|
||||||
|
assert_eq!(header.asset_table[1].asset_id, STRESS_SCENE_ASSET_ID);
|
||||||
assert_eq!(header.asset_table[0].bank_type, BankType::GLYPH);
|
assert_eq!(header.asset_table[0].bank_type, BankType::GLYPH);
|
||||||
assert_eq!(header.asset_table[1].bank_type, BankType::SCENE);
|
assert_eq!(header.asset_table[1].bank_type, BankType::SCENE);
|
||||||
|
assert_eq!(header.preload[0].asset_id, STRESS_GLYPH_ASSET_ID);
|
||||||
|
assert_eq!(header.preload[1].asset_id, STRESS_SCENE_ASSET_ID);
|
||||||
assert_eq!(header.preload[0].slot, 0);
|
assert_eq!(header.preload[0].slot, 0);
|
||||||
assert_eq!(header.preload[1].slot, 0);
|
assert_eq!(header.preload[1].slot, 0);
|
||||||
assert_eq!(header.asset_table[0].offset, 0);
|
assert_eq!(header.asset_table[0].offset, 0);
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user