diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 37c9fb9a..30da3bfd 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -235,6 +235,7 @@ #define intface_is_hidden sfall_func0("intface_is_hidden") #define intface_redraw sfall_func0("intface_redraw") #define intface_show sfall_func0("intface_show") +#define inventory_redraw(invSide) sfall_func1("inventory_redraw", invSide) #define item_weight(obj) sfall_func1("item_weight", obj) #define lock_is_jammed(obj) sfall_func1("lock_is_jammed", obj) #define outlined_object sfall_func0("outlined_object") diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 739fe8ed..e9f554b8 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -486,6 +486,10 @@ Some utility/math functions are available: - The text is limited to 19 characters - available colors: 0 - green, 1 - red, 2 - white, 3 - yellow, 4 - dark yellow, 5 - blue, 6 - purple +> void sfall_func1("inventory_redraw", int invSide) +- redraws inventory list in the inventory/use inventory item on/loot/barter screens +- invSide specifies which side needs to be redrawn: 0 - the player, 1 - target (container/NPC in loot/barter screens) + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 89f5a0c8..ebcfc3ca 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -31,6 +31,8 @@ WRAP_WATCOM_FUNC3(long, db_freadIntCount, DbFile*, file, DWORD*, dest, long, cou WRAP_WATCOM_FUNC2(long, db_fwriteByte, DbFile*, file, long, value) WRAP_WATCOM_FUNC2(long, db_fwriteInt, DbFile*, file, long, value) WRAP_WATCOM_FUNC0(void, display_stats) +WRAP_WATCOM_FUNC3(void, display_inventory, long, inventoryOffset, long, visibleOffset, long, mode) +WRAP_WATCOM_FUNC4(void, display_target_inventory, long, inventoryOffset, long, visibleOffset, DWORD*, targetInventory, long, mode) // perform combat turn for a given critter WRAP_WATCOM_FUNC2(long, combat_turn, GameObject*, critter, long, isDudeTurn) WRAP_WATCOM_FUNC1(long, critter_is_dead, GameObject*, critter) diff --git a/sfall/Modules/Scripting/Handlers/Interface.cpp b/sfall/Modules/Scripting/Handlers/Interface.cpp index 3d503959..203b40b7 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.cpp +++ b/sfall/Modules/Scripting/Handlers/Interface.cpp @@ -460,5 +460,32 @@ void sf_set_iface_tag_text(OpcodeContext& ctx) { } } +void sf_inventory_redraw(OpcodeContext& ctx) { + int mode = -1; + DWORD loopFlag = GetLoopFlags(); + if (loopFlag & INVENTORY) { + mode = 0; + } else if (loopFlag & INTFACEUSE) { + mode = 1; + } else if (loopFlag & INTFACELOOT) { + mode = 2; + } else if (loopFlag & BARTER) { + mode = 3; + } else { + return; + } + + if (!ctx.arg(0).asBool()) { + int* stack_offset = (int*)FO_VAR_stack_offset; + stack_offset[fo::var::curr_stack * 4] = 0; + fo::func::display_inventory(0, -1, mode); + } else if (mode >= 2) { + int* target_stack_offset = (int*)FO_VAR_target_stack_offset; + target_stack_offset[fo::var::target_curr_stack * 4] = 0; + fo::func::display_target_inventory(0, -1, (DWORD*)fo::var::target_pud, mode); + fo::func::win_draw(fo::var::i_wid); + } +} + } } diff --git a/sfall/Modules/Scripting/Handlers/Interface.h b/sfall/Modules/Scripting/Handlers/Interface.h index 01afe81c..099b7880 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.h +++ b/sfall/Modules/Scripting/Handlers/Interface.h @@ -91,5 +91,7 @@ void sf_display_stats(OpcodeContext&); void sf_set_iface_tag_text(OpcodeContext&); +void sf_inventory_redraw(OpcodeContext&); + } } diff --git a/sfall/Modules/Scripting/Handlers/Metarule.cpp b/sfall/Modules/Scripting/Handlers/Metarule.cpp index 2414268d..d149ee9d 100644 --- a/sfall/Modules/Scripting/Handlers/Metarule.cpp +++ b/sfall/Modules/Scripting/Handlers/Metarule.cpp @@ -94,6 +94,7 @@ static const SfallMetarule metarules[] = { {"intface_is_hidden", sf_intface_is_hidden, 0, 0}, {"intface_redraw", sf_intface_redraw, 0, 0}, {"intface_show", sf_intface_show, 0, 0}, + {"inventory_redraw", sf_inventory_redraw, 1, 1, {ARG_INT}}, {"item_weight", sf_item_weight, 1, 1, {ARG_OBJECT}}, {"lock_is_jammed", sf_lock_is_jammed, 1, 1, {ARG_OBJECT}}, {"outlined_object", sf_outlined_object, 0, 0},