- Migrate from set_global/get_global to ctx_set/ctx_get - Replace if-else chains with match() expressions - Update inline pointer handling patterns - Improve GfxWorld and asset parsing structures - Clean up redundant code across 60+ definition files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
254 lines
6.5 KiB
Plaintext
254 lines
6.5 KiB
Plaintext
type itemdef [display="Item Def"]
|
|
{
|
|
const PTR_INLINE = -1;
|
|
|
|
// itemDef_s struct - ~368 bytes fixed
|
|
|
|
// WindowDef_t embedded
|
|
window = parse_here("windowdef");
|
|
ui("window", "Window");
|
|
|
|
// Text Rect
|
|
text_rect = parse_here("rectdef");
|
|
ui("text_rect", "Text Rect");
|
|
|
|
// Item Properties
|
|
i32 item_type;
|
|
ui("item_type", "Type");
|
|
|
|
i32 data_type;
|
|
ui("data_type", "Data Type");
|
|
|
|
i32 alignment;
|
|
ui("alignment", "Alignment");
|
|
|
|
i32 font_enum;
|
|
ui("font_enum", "Font Enum");
|
|
|
|
i32 text_align_mode;
|
|
ui("text_align_mode", "Text Align Mode");
|
|
|
|
f32 text_align_x;
|
|
ui("text_align_x", "Text Align X");
|
|
|
|
f32 text_align_y;
|
|
ui("text_align_y", "Text Align Y");
|
|
|
|
f32 text_scale;
|
|
ui("text_scale", "Text Scale");
|
|
|
|
i32 text_style;
|
|
ui("text_style", "Text Style");
|
|
|
|
i32 game_msg_window_index;
|
|
ui("game_msg_window_index", "Game Msg Window Index");
|
|
|
|
i32 game_msg_window_mode;
|
|
ui("game_msg_window_mode", "Game Msg Window Mode");
|
|
|
|
// Pointers
|
|
i32 text_ptr;
|
|
ui("text_ptr", "Text Ptr");
|
|
|
|
i32 item_flags;
|
|
ui("item_flags", "Item Flags");
|
|
|
|
i32 parent_ptr;
|
|
ui("parent_ptr", "Parent Ptr");
|
|
|
|
i32 mouse_enter_text_ptr;
|
|
ui("mouse_enter_text_ptr", "Mouse Enter Text Ptr");
|
|
|
|
i32 mouse_exit_text_ptr;
|
|
ui("mouse_exit_text_ptr", "Mouse Exit Text Ptr");
|
|
|
|
i32 mouse_enter_ptr;
|
|
ui("mouse_enter_ptr", "Mouse Enter Ptr");
|
|
|
|
i32 mouse_exit_ptr;
|
|
ui("mouse_exit_ptr", "Mouse Exit Ptr");
|
|
|
|
i32 action_ptr;
|
|
ui("action_ptr", "Action Ptr");
|
|
|
|
i32 on_accept_ptr;
|
|
ui("on_accept_ptr", "On Accept Ptr");
|
|
|
|
i32 on_focus_ptr;
|
|
ui("on_focus_ptr", "On Focus Ptr");
|
|
|
|
i32 leave_focus_ptr;
|
|
ui("leave_focus_ptr", "Leave Focus Ptr");
|
|
|
|
i32 dvar_ptr;
|
|
ui("dvar_ptr", "Dvar Ptr");
|
|
|
|
i32 dvar_test_ptr;
|
|
ui("dvar_test_ptr", "Dvar Test Ptr");
|
|
|
|
i32 on_key_ptr;
|
|
ui("on_key_ptr", "On Key Ptr");
|
|
|
|
i32 enable_dvar_ptr;
|
|
ui("enable_dvar_ptr", "Enable Dvar Ptr");
|
|
|
|
i32 dvar_flags;
|
|
ui("dvar_flags", "Dvar Flags");
|
|
|
|
i32 focus_sound_ptr;
|
|
ui("focus_sound_ptr", "Focus Sound Ptr");
|
|
|
|
f32 special;
|
|
ui("special", "Special");
|
|
|
|
i32 cursor_pos;
|
|
ui("cursor_pos", "Cursor Pos");
|
|
|
|
i32 type_data_ptr;
|
|
ui("type_data_ptr", "Type Data Ptr");
|
|
|
|
i32 image_track;
|
|
ui("image_track", "Image Track");
|
|
|
|
// Expressions
|
|
visible_exp = parse_here("statement");
|
|
ui("visible_exp", "Visible Exp");
|
|
|
|
text_exp = parse_here("statement");
|
|
ui("text_exp", "Text Exp");
|
|
|
|
material_exp = parse_here("statement");
|
|
ui("material_exp", "Material Exp");
|
|
|
|
rect_x_exp = parse_here("statement");
|
|
ui("rect_x_exp", "Rect X Exp");
|
|
|
|
rect_y_exp = parse_here("statement");
|
|
ui("rect_y_exp", "Rect Y Exp");
|
|
|
|
rect_w_exp = parse_here("statement");
|
|
ui("rect_w_exp", "Rect W Exp");
|
|
|
|
rect_h_exp = parse_here("statement");
|
|
ui("rect_h_exp", "Rect H Exp");
|
|
|
|
forecolor_a_exp = parse_here("statement");
|
|
ui("forecolor_a_exp", "Forecolor A Exp");
|
|
|
|
// ============ INLINE DATA ============
|
|
|
|
// Window inline data
|
|
_win_name_ptr = get(window, "name_ptr");
|
|
if (_win_name_ptr == PTR_INLINE) {
|
|
name = cstring();
|
|
ui("name", "Name");
|
|
}
|
|
|
|
_win_group_ptr = get(window, "group_ptr");
|
|
if (_win_group_ptr == PTR_INLINE) {
|
|
group = cstring();
|
|
ui("group", "Group");
|
|
}
|
|
|
|
_win_bg_ptr = get(window, "background_ptr");
|
|
if (_win_bg_ptr == PTR_INLINE) {
|
|
background = parse_here("material");
|
|
ui("background", "Background");
|
|
}
|
|
|
|
// Simple inline strings
|
|
inline cstring text when text_ptr [ui="Text"];
|
|
inline cstring mouse_enter_text when mouse_enter_text_ptr [ui="Mouse Enter Text"];
|
|
inline cstring mouse_exit_text when mouse_exit_text_ptr [ui="Mouse Exit Text"];
|
|
inline cstring mouse_enter when mouse_enter_ptr [ui="Mouse Enter"];
|
|
inline cstring mouse_exit when mouse_exit_ptr [ui="Mouse Exit"];
|
|
inline cstring action when action_ptr [ui="Action"];
|
|
inline cstring on_accept when on_accept_ptr [ui="On Accept"];
|
|
inline cstring on_focus when on_focus_ptr [ui="On Focus"];
|
|
inline cstring leave_focus when leave_focus_ptr [ui="Leave Focus"];
|
|
inline cstring dvar when dvar_ptr [ui="Dvar"];
|
|
inline cstring dvar_test when dvar_test_ptr [ui="Dvar Test"];
|
|
inline itemkeyhandler on_key when on_key_ptr [ui="On Key"];
|
|
inline cstring enable_dvar when enable_dvar_ptr [ui="Enable Dvar"];
|
|
inline sound focus_sound when focus_sound_ptr [ui="Focus Sound"];
|
|
|
|
// Type-specific data
|
|
if (type_data_ptr == PTR_INLINE) {
|
|
match(item_type) {
|
|
6 => {
|
|
type_data = parse_here("listboxdef");
|
|
ui("type_data", "List Box Data");
|
|
}
|
|
4 | 9 | 16 | 17 | 18 => {
|
|
type_data = parse_here("editfielddef");
|
|
ui("type_data", "Edit Field Data");
|
|
}
|
|
12 => {
|
|
type_data = parse_here("multidef");
|
|
ui("type_data", "Multi Data");
|
|
}
|
|
13 => {
|
|
type_data = cstring();
|
|
ui("type_data", "Enum Dvar Name");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Expression entries (complex patterns - need ptr array first)
|
|
_vis_num = get(visible_exp, "num_entries");
|
|
_vis_ptr = get(visible_exp, "entries_ptr");
|
|
if (_vis_ptr == PTR_INLINE && _vis_num > 0) {
|
|
skip _vis_num * 4;
|
|
array[_vis_num] vis_entries: expressionentry;
|
|
}
|
|
|
|
_txt_num = get(text_exp, "num_entries");
|
|
_txt_ptr = get(text_exp, "entries_ptr");
|
|
if (_txt_ptr == PTR_INLINE && _txt_num > 0) {
|
|
skip _txt_num * 4;
|
|
array[_txt_num] txt_entries: expressionentry;
|
|
}
|
|
|
|
_mat_num = get(material_exp, "num_entries");
|
|
_mat_ptr = get(material_exp, "entries_ptr");
|
|
if (_mat_ptr == PTR_INLINE && _mat_num > 0) {
|
|
skip _mat_num * 4;
|
|
array[_mat_num] mat_entries: expressionentry;
|
|
}
|
|
|
|
_rx_num = get(rect_x_exp, "num_entries");
|
|
_rx_ptr = get(rect_x_exp, "entries_ptr");
|
|
if (_rx_ptr == PTR_INLINE && _rx_num > 0) {
|
|
skip _rx_num * 4;
|
|
array[_rx_num] rx_entries: expressionentry;
|
|
}
|
|
|
|
_ry_num = get(rect_y_exp, "num_entries");
|
|
_ry_ptr = get(rect_y_exp, "entries_ptr");
|
|
if (_ry_ptr == PTR_INLINE && _ry_num > 0) {
|
|
skip _ry_num * 4;
|
|
array[_ry_num] ry_entries: expressionentry;
|
|
}
|
|
|
|
_rw_num = get(rect_w_exp, "num_entries");
|
|
_rw_ptr = get(rect_w_exp, "entries_ptr");
|
|
if (_rw_ptr == PTR_INLINE && _rw_num > 0) {
|
|
skip _rw_num * 4;
|
|
array[_rw_num] rw_entries: expressionentry;
|
|
}
|
|
|
|
_rh_num = get(rect_h_exp, "num_entries");
|
|
_rh_ptr = get(rect_h_exp, "entries_ptr");
|
|
if (_rh_ptr == PTR_INLINE && _rh_num > 0) {
|
|
skip _rh_num * 4;
|
|
array[_rh_num] rh_entries: expressionentry;
|
|
}
|
|
|
|
_fc_num = get(forecolor_a_exp, "num_entries");
|
|
_fc_ptr = get(forecolor_a_exp, "entries_ptr");
|
|
if (_fc_ptr == PTR_INLINE && _fc_num > 0) {
|
|
skip _fc_num * 4;
|
|
array[_fc_num] fc_entries: expressionentry;
|
|
}
|
|
}
|