commonlibsse_ng\re\i/
InventoryMenu.rs

1use core::ffi::c_void;
2
3use crate::re::BSTArray::BSTArray;
4use crate::re::BottomBar::BottomBar;
5use crate::re::GFxValue::GFxValue;
6use crate::re::IMenu::{IMenu, IMenuVtbl};
7use crate::re::ItemCard::ItemCard;
8use crate::re::ItemList::ItemList;
9use crate::re::UI::HasMenuName;
10use crate::re::offsets_rtti::RTTI_InventoryMenu;
11use crate::rel::id::VariantID;
12use crate::rel::relocation::{RelocationError, relocate_member, relocate_member_mut};
13
14/// - menuDepth: `0`
15/// - flags: `PausesGame | DisablePauseMenu | UpdateUsesCursor | InventoryItemMenu | CustomRendering`
16/// - context: `None`
17#[repr(C)]
18#[derive(Debug)]
19pub struct InventoryMenu {
20    pub __base: IMenu, // 0x000
21}
22const _: () = assert!(core::mem::size_of::<InventoryMenu>() == 0x30);
23
24impl InventoryMenu {
25    /// Address & offset of the runtime type information (RTTI) identifier.
26    pub const RTTI: VariantID = RTTI_InventoryMenu;
27
28    /// Gets fields whose offset is determined at runtime.
29    ///
30    /// # Errors
31    /// This function may return an error if the module's runtime is not available or if any error occurs while fetching the runtime state.
32    /// Specifically, it calls `ModuleState::map_active`, which could result in an error.
33    #[inline]
34    pub fn get_runtime_data(&self) -> Result<&RUNTIME_DATA, RelocationError> {
35        relocate_member(self, 0x30, 0x40)
36    }
37
38    /// Gets mutable fields whose offset is determined at runtime.
39    ///
40    /// # Errors
41    /// This function may return an error if the module's runtime is not available or if any error occurs while fetching the runtime state.
42    /// Specifically, it calls `ModuleState::map_active_mut`, which could result in an error.
43    #[inline]
44    pub fn get_runtime_data_mut(&mut self) -> Result<&mut RUNTIME_DATA, RelocationError> {
45        relocate_member_mut(self, 0x30, 0x40)
46    }
47}
48
49impl HasMenuName for InventoryMenu {
50    const MENU_NAME: &'static core::ffi::CStr = c"InventoryMenu";
51}
52
53#[repr(C)]
54pub struct InventoryMenuVtbl {
55    pub __base: IMenuVtbl,
56}
57
58#[derive(Debug)]
59#[repr(C)]
60pub struct RUNTIME_DATA {
61    pub root: GFxValue,               // 0x00 - kDisplayObject - "_level0.Menu_mc"
62    pub itemList: *mut ItemList,      // 0x18
63    pub itemCard: *mut ItemCard,      // 0x20
64    pub bottomBar: *mut BottomBar,    // 0x28
65    pub unk60: BSTArray<*mut c_void>, // 0x30
66    pub unk78: u8,                    // 0x48
67    pub pad79: u8,                    // 0x49
68    pub pad7A: u16,                   // 0x4A
69    pub unk7C: u32,                   // 0x4C
70    pub pcControlsReady: bool,        // 0x50
71    pub unk81: u8,                    // 0x51
72    pub pad82: u16,                   // 0x52
73    pub pad84: u32,                   // 0x54
74}
75const _: () = assert!(core::mem::size_of::<RUNTIME_DATA>() == 0x58);