Added "inventory_redraw" script function (from Mr.Stalin)

This commit is contained in:
NovaRain
2018-07-08 00:30:26 +08:00
parent 84c7ac0536
commit 2a20209bb8
6 changed files with 37 additions and 0 deletions
+1
View File
@@ -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")
@@ -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 -------
------------------------
+2
View File
@@ -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)
@@ -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);
}
}
}
}
@@ -91,5 +91,7 @@ void sf_display_stats(OpcodeContext&);
void sf_set_iface_tag_text(OpcodeContext&);
void sf_inventory_redraw(OpcodeContext&);
}
}
@@ -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},