1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
use crate::api::monsters::MonsterSpeciesId;
use crate::api::overlay::OverlayLoadLease;
use crate::ffi;
/// Helper struct for dealing with sprite data in dungeon mode.
///
/// To get an instance of this, use [`crate::api::dungeon_mode::GlobalDungeonData::sprites`].
pub struct DungeonSpriteHandler<'a>(pub(crate) &'a OverlayLoadLease<29>);
impl<'a> DungeonSpriteHandler<'a> {
/// Loads the sprites of monsters that appear on the current floor because of a mission,
/// if applicable.
///
/// This includes monsters to be rescued, outlaws and its minions.
pub fn load_mission_monster_sprites(&mut self) {
// SAFETY: We hold a valid mutable reference to the global dungeon struct.
unsafe { ffi::LoadMissionMonsterSprites() }
}
/// Gets the sprite index of the specified monster on this floor
pub fn get_monster_sprite_index(&self, monster_idx: MonsterSpeciesId) -> u16 {
// SAFETY: We hold a valid mutable reference to the global dungeon struct.
unsafe { ffi::GetSpriteIndex(monster_idx) }
}
/// Loads the sprite of the specified monster to use it in a dungeon.
///
/// # Safety
/// The caller must make sure the undefined params are valid for this function.
pub unsafe fn load_monster_sprite(
&mut self,
monster_id: MonsterSpeciesId,
param_2: ffi::undefined,
) {
ffi::LoadMonsterSprite(monster_id, param_2)
}
/// Checks Castform and Cherrim
///
/// Note: unverified, ported from Irdkwia's notes
pub fn get_total_sprite_file_size(&self, monster_id: MonsterSpeciesId) -> i32 {
unsafe { ffi::GetTotalSpriteFileSize(monster_id) }
}
/// Note: unverified, ported from Irdkwia's notes
pub fn store_sprite_file_index_both_genders(
&mut self,
monster_id: MonsterSpeciesId,
file_id: i32,
) {
unsafe { ffi::StoreSpriteFileIndexBothGenders(monster_id, file_id) }
}
/// Note: unverified, ported from Irdkwia's notes
pub fn swap_monster_wan_file_index(&mut self, src_id: i32, dst_id: i32) {
unsafe { ffi::SwapMonsterWanFileIndex(src_id, dst_id) }
}
/// Note: unverified, ported from Irdkwia's notes
pub fn delete_monster_sprite_file(&mut self, monster_id: MonsterSpeciesId) {
unsafe { ffi::DeleteMonsterSpriteFile(monster_id) }
}
/// Note: unverified, ported from Irdkwia's notes
pub fn delete_all_monster_sprite_files(&mut self) {
unsafe { ffi::DeleteAllMonsterSpriteFiles() }
}
}