From d1172969908b44be21b1ec5cc9d6fdfc2c989ac8 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 2 Oct 2018 12:15:48 +0800 Subject: [PATCH] Backported "create_win" script function and InterfaceDontMoveOnTop option from the developt branch. Updated version number. --- artifacts/ddraw.ini | 5 ++++- artifacts/scripting/headers/sfall.h | 2 ++ artifacts/scripting/sfall function notes.txt | 5 +++++ sfall/FalloutEngine.cpp | 14 ++++++++++++++ sfall/FalloutEngine.h | 4 ++++ sfall/ScriptExtender.cpp | 1 + sfall/ScriptOps/InterfaceOp.hpp | 19 ++++++++++++++++++- sfall/ScriptOps/MetaruleOp.hpp | 1 + sfall/main.cpp | 7 +++++++ sfall/version.h | 6 +++--- 10 files changed, 59 insertions(+), 5 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 3c8c9697..b5d562f9 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v3.8.11 +;v3.8.12 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. @@ -615,6 +615,9 @@ NumbersInDialogue=0 ;Set to 1 to use Fallout's normal text font instead of DOS-like font on the world map WorldMapFontPatch=0 +;Set to 1 to prevent the inventory/loot/automap interfaces from being placed on top of other script-created windows +InterfaceDontMoveOnTop=0 + ;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top CreditsAtBottom=0 diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 806ec29a..4276884d 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -189,6 +189,8 @@ #define party_member_list_all party_member_list(1) +#define create_win(winName, x, y, w, h) sfall_func5("create_win", winName, x, y, w, h) +#define create_win_flag(winName, x, y, w, h, flag) sfall_func6("create_win", winName, x, y, w, h, flag) #define critter_inven_obj2(obj, type) sfall_func2("critter_inven_obj2", obj, type) #define exec_map_update_scripts sfall_func0("exec_map_update_scripts") #define floor2(value) sfall_func1("floor2", value) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 34e2272a..1845917d 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -388,6 +388,11 @@ Some utility/math functions are available: > int sfall_func1("get_current_inven_size", object) - returns the current inventory size of the container or the critter +> void sfall_func5("create_win", string winName, int x, int y, int width, int height) +> void sfall_func6("create_win", string winName, int x, int y, int width, int height, int flags) +- works just like vanilla CreateWin function, but creates a window with MoveOnTop flag if flags argument is not specified, and allows to set additional flags for the created window +- MoveOnTop flag allows the created window to be placed on top of the game interface + ------------------------ ------ MORE INFO ------- ------------------------ diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index f6218104..a3a7371c 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -265,6 +265,7 @@ const DWORD compute_damage_ = 0x4247B8; const DWORD config_set_value_ = 0x42C160; const DWORD container_exit_ = 0x476394; const DWORD correctFidForRemovedItem_ = 0x45409C; +const DWORD createWindow_ = 0x4B7F3C; const DWORD credits_ = 0x42C860; const DWORD credits_get_next_line_ = 0x42CE6C; const DWORD critter_body_type_ = 0x42DDC4; @@ -848,3 +849,16 @@ TGameObj* __stdcall InvenRightHand(TGameObj* critter) { call inven_right_hand_ } } + +int __stdcall CreateWindowFunc(const char* winName, DWORD x, DWORD y, DWORD width, DWORD height, DWORD bgColorIndex, DWORD flags) { + __asm { + push flags + push bgColorIndex + push height + mov ecx, width + mov ebx, y + mov edx, x + mov eax, winName + call createWindow_ + } +} diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 0a547751..946cd880 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -450,6 +450,7 @@ extern const DWORD compute_damage_; extern const DWORD config_set_value_; extern const DWORD container_exit_; extern const DWORD correctFidForRemovedItem_; // (int critter@, int oldArmor@, int removeSlotsFlags@) +extern const DWORD createWindow_; extern const DWORD credits_; extern const DWORD credits_get_next_line_; extern const DWORD critter_body_type_; @@ -941,3 +942,6 @@ void __declspec() DebugPrintf(const char* fmt, ...); // returns the name of current procedure by program pointer const char* __stdcall FindCurrentProc(TProgram* program); + +// creates a window with the name and flags +int __stdcall CreateWindowFunc(const char* winName, DWORD x, DWORD y, DWORD width, DWORD height, DWORD bgColorIndex, DWORD flags); diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index 8ee6cbea..28c69648 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -375,6 +375,7 @@ static const SfallOpcodeMetadata opcodeMetaArray[] = { {sf_spatial_radius, "spatial_radius", {DATATYPE_MASK_VALID_OBJ}}, {sf_critter_inven_obj2, "critter_inven_obj2", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}}, {sf_set_ini_setting, "set_ini_setting", {DATATYPE_MASK_STR, DATATYPE_MASK_INT | DATATYPE_MASK_STR}}, + {sf_create_win, "create_win", {DATATYPE_MASK_STR, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}}, //{op_message_str_game, {}} }; diff --git a/sfall/ScriptOps/InterfaceOp.hpp b/sfall/ScriptOps/InterfaceOp.hpp index da7c08cb..00a91869 100644 --- a/sfall/ScriptOps/InterfaceOp.hpp +++ b/sfall/ScriptOps/InterfaceOp.hpp @@ -466,4 +466,21 @@ static void sf_intface_is_hidden() { mov isHidden, eax; } opHandler.setReturn(isHidden); -} \ No newline at end of file +} + +static void sf_create_win() { + int flags; + if (opHandler.numArgs() == 6) { + flags = opHandler.arg(5).asInt(); + } else { + flags = 0x4; // MoveOnTop + } + + if (CreateWindowFunc(opHandler.arg(0).asString(), + opHandler.arg(1).asInt(), opHandler.arg(2).asInt(), // y, x + opHandler.arg(3).asInt(), opHandler.arg(4).asInt(), // w, h + 256, flags) == -1) + { + opHandler.printOpcodeError("create_win() - couldn't create window."); + } +} diff --git a/sfall/ScriptOps/MetaruleOp.hpp b/sfall/ScriptOps/MetaruleOp.hpp index 957cc08f..de43fa85 100644 --- a/sfall/ScriptOps/MetaruleOp.hpp +++ b/sfall/ScriptOps/MetaruleOp.hpp @@ -104,6 +104,7 @@ static void sf_get_metarule_table() { */ static const SfallMetarule metaruleArray[] = { {"critter_inven_obj2", sf_critter_inven_obj2, 2, 2}, + {"create_win", sf_create_win, 5, 6}, {"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0}, {"floor2", sf_floor2, 1, 1}, {"get_current_inven_size", sf_get_current_inven_size, 1, 1}, diff --git a/sfall/main.cpp b/sfall/main.cpp index 41d5b311..60a162af 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -1545,6 +1545,13 @@ static void DllMain2() { dlogr(" Done", DL_INIT); } + if (GetPrivateProfileIntA("Misc", "InterfaceDontMoveOnTop", 0, ini)) { + dlog("Applying InterfaceDontMoveOnTop patch.", DL_INIT); + SafeWrite8(0x46ECE9, 0x10); // set only Exclusive flag for Player Inventory/Loot/UseOn + SafeWrite8(0x41B966, 0x10); // set only Exclusive flag for Automap + dlogr(" Done", DL_INIT); + } + dlogr("Leave DllMain2", DL_MAIN); } diff --git a/sfall/version.h b/sfall/version.h index 9552d264..6f1cffff 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -24,13 +24,13 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 11 +#define VERSION_BUILD 12 #define VERSION_REV 0 #ifdef WIN2K -#define VERSION_STRING "3.8.11 win2k" +#define VERSION_STRING "3.8.12 win2k" #else -#define VERSION_STRING "3.8.11" +#define VERSION_STRING "3.8.12" #endif #define CHECK_VAL (4)