mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added "create_win" script function and InterfaceDontMoveOnTop option (from Mr.Stalin)
This commit is contained in:
@@ -607,6 +607,9 @@ FullItemDescInBarter=0
|
|||||||
;Set to 1 to display experience points with the bonus from Swift Learner perk when gained from non-scripted situations
|
;Set to 1 to display experience points with the bonus from Swift Learner perk when gained from non-scripted situations
|
||||||
DisplaySwiftLearnerExp=1
|
DisplaySwiftLearnerExp=1
|
||||||
|
|
||||||
|
;Set to 1 to allow windows created by vanilla script function to be placed on top of inventory/loot/automap interfaces
|
||||||
|
InterfaceDontMoveOnTop=0
|
||||||
|
|
||||||
;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top
|
;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top
|
||||||
CreditsAtBottom=0
|
CreditsAtBottom=0
|
||||||
|
|
||||||
|
|||||||
@@ -223,6 +223,8 @@
|
|||||||
|
|
||||||
#define attack_is_aimed sfall_func0("attack_is_aimed")
|
#define attack_is_aimed sfall_func0("attack_is_aimed")
|
||||||
#define car_gas_amount sfall_func0("car_gas_amount")
|
#define car_gas_amount sfall_func0("car_gas_amount")
|
||||||
|
#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 critter_inven_obj2(obj, type) sfall_func2("critter_inven_obj2", obj, type)
|
||||||
#define dialog_message(text) sfall_func1("dialog_message", text)
|
#define dialog_message(text) sfall_func1("dialog_message", text)
|
||||||
#define display_stats sfall_func0("display_stats")
|
#define display_stats sfall_func0("display_stats")
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
---------- GLOBAL SCRIPTS -----------
|
---------- GLOBAL SCRIPTS -----------
|
||||||
-------------------------------------
|
-------------------------------------
|
||||||
|
|
||||||
As well as the new functions, sfall also adds global scripts. These run independent of any loaded maps, but do not have an attached object. (i.e. using self_obj without using set_self first will crash the script.) To use a global script, the script must have a name which begins with 'gl' and contains a procedure called 'start', 'map_enter_p_proc', 'map_exit_p_proc', or 'map_update_p_proc'. The start procedure will be executed once when the player loads a saved game or starts a new game. The map_*_p_proc procedures will be executed once when the player enters/leaves a map via exit grids or the world map, or rests/waits on a map. If you wish the script to be executed repeatedly, call set_global_script_repeat on this first run using the number of frames between each run as the argument. (0 disables the script, 1 runs it every frame, 2 runs it every other frame etc.)
|
As well as the new functions, sfall also adds global scripts. These run independent of any loaded maps, but do not have an attached object. (i.e. using self_obj without using set_self first will crash the script.) To use a global script, the script must have a name which begins with 'gl' and contains a procedure called 'start', 'map_enter_p_proc', 'map_exit_p_proc', or 'map_update_p_proc'. The start procedure will be executed once when the player loads a saved game or starts a new game. The map_*_p_proc procedures will be executed once when the player enters/leaves a map via exit grids or the world map, or rests/waits on a map. If you wish the script to be executed repeatedly, call set_global_script_repeat on the first run of the start procedure using the number of frames between each run as the argument. (0 disables the script, 1 runs it every frame, 2 runs it every other frame etc.)
|
||||||
|
|
||||||
Global scripts have multiple modes, which can be set using the set_global_script_type function. In the default mode (i.e. mode 0) their execution is linked to the local map game loop, so the script will not run in dialogs or on the world map. In mode 1 their execution is linked to the player input, and so they will run whenever the mouse cursor is visible on screen, including the world map, character dialogs etc. In mode 2, execution is linked to the world map loop, so the script will only be executed on the world map and not on the local map or in any dialog windows. Mode 3 is a combination of modes 0 and 2, so scripts will be executed on both local maps and the world map, but not in dialog windows. Using mode 1 requires the input wrapper to be enabled. Use available_global_script_types to check what is available.
|
Global scripts have multiple modes, which can be set using the set_global_script_type function. In the default mode (i.e. mode 0) their execution is linked to the local map game loop, so the script will not run in dialogs or on the world map. In mode 1 their execution is linked to the player input, and so they will run whenever the mouse cursor is visible on screen, including the world map, character dialogs etc. In mode 2, execution is linked to the world map loop, so the script will only be executed on the world map and not on the local map or in any dialog windows. Mode 3 is a combination of modes 0 and 2, so scripts will be executed on both local maps and the world map, but not in dialog windows. Using mode 1 requires the input wrapper to be enabled. Use available_global_script_types to check what is available.
|
||||||
|
|
||||||
@@ -500,6 +500,11 @@ Some utility/math functions are available:
|
|||||||
> int sfall_func1("get_current_inven_size", object)
|
> int sfall_func1("get_current_inven_size", object)
|
||||||
- returns the current inventory size of the container or the critter
|
- 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 -------
|
------ MORE INFO -------
|
||||||
------------------------
|
------------------------
|
||||||
|
|||||||
@@ -689,4 +689,20 @@ namespace Fields {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace WinFlags {
|
||||||
|
enum WinButtonFlags : long
|
||||||
|
{
|
||||||
|
OwnerFlag = 0x1,
|
||||||
|
UnknownFlag2 = 0x2,
|
||||||
|
MoveOnTop = 0x4,
|
||||||
|
Hidden = 0x8,
|
||||||
|
Exclusive = 0x10,
|
||||||
|
Transparent = 0x20,
|
||||||
|
UnknownFlag40 = 0x40,
|
||||||
|
UnknownFlag80 = 0x80,
|
||||||
|
scriptWindow = 0x100,
|
||||||
|
itsButton = 0x10000,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -388,6 +388,11 @@ long __stdcall win_register_button(DWORD winRef, long xPos, long yPos, long widt
|
|||||||
WRAP_WATCOM_CALL6(name##_, arg1, arg2, arg3, arg4, arg5, arg6) \
|
WRAP_WATCOM_CALL6(name##_, arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define WRAP_WATCOM_FUNC7(retType, name, arg1t, arg1, arg2t, arg2, arg3t, arg3, arg4t, arg4, arg5t, arg5, arg6t, arg6, arg7t, arg7) \
|
||||||
|
retType __stdcall name(arg1t arg1, arg2t arg2, arg3t arg3, arg4t arg4, arg5t arg5, arg6t arg6, arg7t arg7) { \
|
||||||
|
WRAP_WATCOM_CALL7(name##_, arg1, arg2, arg3, arg4, arg5, arg6, arg7) \
|
||||||
|
}
|
||||||
|
|
||||||
#include "Functions_def.h"
|
#include "Functions_def.h"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -219,6 +219,9 @@ long __stdcall win_register_button(DWORD winRef, long xPos, long yPos, long widt
|
|||||||
#define WRAP_WATCOM_FUNC6(retType, name, arg1t, arg1, arg2t, arg2, arg3t, arg3, arg4t, arg4, arg5t, arg5, arg6t, arg6) \
|
#define WRAP_WATCOM_FUNC6(retType, name, arg1t, arg1, arg2t, arg2, arg3t, arg3, arg4t, arg4, arg5t, arg5, arg6t, arg6) \
|
||||||
retType __stdcall name(arg1t arg1, arg2t arg2, arg3t arg3, arg4t arg4, arg5t arg5, arg6t arg6);
|
retType __stdcall name(arg1t arg1, arg2t arg2, arg3t arg3, arg4t arg4, arg5t arg5, arg6t arg6);
|
||||||
|
|
||||||
|
#define WRAP_WATCOM_FUNC7(retType, name, arg1t, arg1, arg2t, arg2, arg3t, arg3, arg4t, arg4, arg5t, arg5, arg6t, arg6, arg7t, arg7) \
|
||||||
|
retType __stdcall name(arg1t arg1, arg2t arg2, arg3t arg3, arg4t arg4, arg5t arg5, arg6t arg6, arg7t arg7);
|
||||||
|
|
||||||
#include "Functions_def.h"
|
#include "Functions_def.h"
|
||||||
|
|
||||||
#undef WRAP_WATCOM_FUNC0
|
#undef WRAP_WATCOM_FUNC0
|
||||||
@@ -228,7 +231,7 @@ long __stdcall win_register_button(DWORD winRef, long xPos, long yPos, long widt
|
|||||||
#undef WRAP_WATCOM_FUNC4
|
#undef WRAP_WATCOM_FUNC4
|
||||||
#undef WRAP_WATCOM_FUNC5
|
#undef WRAP_WATCOM_FUNC5
|
||||||
#undef WRAP_WATCOM_FUNC6
|
#undef WRAP_WATCOM_FUNC6
|
||||||
//#undef WRAP_WATCOM_FUNC7
|
#undef WRAP_WATCOM_FUNC7
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ WRAP_WATCOM_FUNC4(BYTE*, art_ptr_lock_data, long, frmId, long, frameNum, long, r
|
|||||||
WRAP_WATCOM_FUNC4(BYTE*, art_lock, long, frmId, DWORD*, lockPtr, long*, widthOut, long*, heightOut)
|
WRAP_WATCOM_FUNC4(BYTE*, art_lock, long, frmId, DWORD*, lockPtr, long*, widthOut, long*, heightOut)
|
||||||
WRAP_WATCOM_FUNC1(long, art_ptr_unlock, DWORD, lockId)
|
WRAP_WATCOM_FUNC1(long, art_ptr_unlock, DWORD, lockId)
|
||||||
WRAP_WATCOM_FUNC2(long, barter_compute_value, GameObject*, source, GameObject*, target)
|
WRAP_WATCOM_FUNC2(long, barter_compute_value, GameObject*, source, GameObject*, target)
|
||||||
|
WRAP_WATCOM_FUNC7(long, createWindow, const char*, winName, long, x, long, y, long, width, long, height, long, bgColorIndex, long, flags)
|
||||||
WRAP_WATCOM_FUNC1(void*, dbase_open, const char*, fileName)
|
WRAP_WATCOM_FUNC1(void*, dbase_open, const char*, fileName)
|
||||||
WRAP_WATCOM_FUNC1(void, dbase_close, void*, dbPtr)
|
WRAP_WATCOM_FUNC1(void, dbase_close, void*, dbPtr)
|
||||||
WRAP_WATCOM_FUNC3(long, db_freadShortCount, DbFile*, file, WORD*, dest, long, count)
|
WRAP_WATCOM_FUNC3(long, db_freadShortCount, DbFile*, file, WORD*, dest, long, count)
|
||||||
|
|||||||
@@ -855,6 +855,15 @@ void KeepWeaponSelectModePatch() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterfaceDontMoveOnTopPatch() {
|
||||||
|
if (GetConfigInt("Misc", "InterfaceDontMoveOnTop", 0)) {
|
||||||
|
dlog("Applying InterfaceDontMoveOnTop patch.", DL_INIT);
|
||||||
|
SafeWrite8(0x46ECE9, fo::WinFlags::Exclusive); // Player Inventory/Loot/UseOn
|
||||||
|
SafeWrite8(0x41B966, fo::WinFlags::Exclusive); // Automap
|
||||||
|
dlogr(" Done", DL_INIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MiscPatches::init() {
|
void MiscPatches::init() {
|
||||||
mapName[64] = 0;
|
mapName[64] = 0;
|
||||||
if (GetConfigString("Misc", "StartingMap", "", mapName, 64)) {
|
if (GetConfigString("Misc", "StartingMap", "", mapName, 64)) {
|
||||||
@@ -929,6 +938,7 @@ void MiscPatches::init() {
|
|||||||
|
|
||||||
DisplaySecondWeaponRangePatch();
|
DisplaySecondWeaponRangePatch();
|
||||||
KeepWeaponSelectModePatch();
|
KeepWeaponSelectModePatch();
|
||||||
|
InterfaceDontMoveOnTopPatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MiscPatches::exit() {
|
void MiscPatches::exit() {
|
||||||
|
|||||||
@@ -442,5 +442,19 @@ void sf_dialog_message(OpcodeContext& ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sf_create_win(OpcodeContext& ctx) {
|
||||||
|
int flags = (ctx.arg(5).type() != DataType::NONE)
|
||||||
|
? ctx.arg(5).asInt()
|
||||||
|
: fo::WinFlags::MoveOnTop;
|
||||||
|
|
||||||
|
if (fo::func::createWindow(ctx.arg(0).asString(),
|
||||||
|
ctx.arg(1).asInt(), ctx.arg(2).asInt(), // y, x
|
||||||
|
ctx.arg(3).asInt(), ctx.arg(4).asInt(), // w, h
|
||||||
|
256, flags) == -1)
|
||||||
|
{
|
||||||
|
ctx.printOpcodeError("create_win() - couldn't create window.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,5 +95,7 @@ void sf_inventory_redraw(OpcodeContext&);
|
|||||||
|
|
||||||
void sf_dialog_message(OpcodeContext&);
|
void sf_dialog_message(OpcodeContext&);
|
||||||
|
|
||||||
|
void sf_create_win(OpcodeContext&);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,6 +79,7 @@ static const SfallMetarule* currentMetarule;
|
|||||||
static const SfallMetarule metarules[] = {
|
static const SfallMetarule metarules[] = {
|
||||||
{"attack_is_aimed", sf_attack_is_aimed, 0, 0},
|
{"attack_is_aimed", sf_attack_is_aimed, 0, 0},
|
||||||
{"car_gas_amount", sf_car_gas_amount, 0, 0},
|
{"car_gas_amount", sf_car_gas_amount, 0, 0},
|
||||||
|
{"create_win", sf_create_win, 5, 6, {ARG_STRING, ARG_INT, ARG_INT, ARG_INT, ARG_INT, ARG_INT}},
|
||||||
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2, {ARG_OBJECT, ARG_INT}},
|
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2, {ARG_OBJECT, ARG_INT}},
|
||||||
{"dialog_message", sf_dialog_message, 1, 1, {ARG_STRING}},
|
{"dialog_message", sf_dialog_message, 1, 1, {ARG_STRING}},
|
||||||
{"display_stats", sf_display_stats, 0, 0},
|
{"display_stats", sf_display_stats, 0, 0},
|
||||||
|
|||||||
@@ -99,6 +99,7 @@ bool OpcodeContext::validateArguments(const OpcodeArgumentType argTypes[], const
|
|||||||
auto actualType = arg(i).type();
|
auto actualType = arg(i).type();
|
||||||
// display invalid type error if type is set and differs from actual type
|
// display invalid type error if type is set and differs from actual type
|
||||||
// exception is when type set to
|
// exception is when type set to
|
||||||
|
if (actualType == DataType::NONE) break;
|
||||||
if ((argType == ARG_INT || argType == ARG_OBJECT) && !(actualType == DataType::INT)) {
|
if ((argType == ARG_INT || argType == ARG_OBJECT) && !(actualType == DataType::INT)) {
|
||||||
printOpcodeError("%s() - argument #%d is not an integer.", opcodeName, i);
|
printOpcodeError("%s() - argument #%d is not an integer.", opcodeName, i);
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user