From e435e1d614210bf004e81feffbcd214c0f5c1e56 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Tue, 7 May 2024 21:05:42 +0800 Subject: [PATCH] Updated docs for art_frame_data script function Minor code edits: type name, indentation/alignment, unified messages --- artifacts/scripting/functions.yml | 10 ++++----- artifacts/scripting/sfall function notes.md | 10 +++++++++ sfall/FalloutEngine/Functions_def.h | 6 ++--- sfall/FalloutEngine/Variables_def.h | 5 ++--- .../Modules/Scripting/Handlers/Interface.cpp | 22 +++++++++---------- 5 files changed, 31 insertions(+), 22 deletions(-) diff --git a/artifacts/scripting/functions.yml b/artifacts/scripting/functions.yml index d1bde851..1ab1429f 100644 --- a/artifacts/scripting/functions.yml +++ b/artifacts/scripting/functions.yml @@ -1690,13 +1690,13 @@ - name: art_frame_data detail: array art_frame_data(string/int artFile/artId, int frame, int rotation) doc: | - - returns dimensions of a given PCX or FRM frame as temp array in form: [width, height] - - artFile/artId: path to the PCX/FRM file (e.g. `art\\inven\\5mmap.frm`), or its FRM ID number (e.g. `0x7000026`, see specification of the FID format) + - returns the dimensions of a given PCX or FRM frame as a temp array in the form **[width, height]** + - `artFile/artId`: path to the PCX/FRM file (e.g. `art\\inven\\5mmap.frm`), or its FRM ID number (e.g. `0x7000026`, see specification of the FID format) optional arguments: - `frame`: frame number, the first frame starts from zero - - `rotation`: rotation to get the frame for, useful when reading FRM file by path + - `rotation`: rotation to get the frame for, useful when reading FRM files by path macro: sfall.h - + - name: interface_art_draw detail: int sfall_func4("interface_art_draw", int winType, string artFile/int artID, int x, int y) doc: | @@ -1806,7 +1806,7 @@ doc: | Fills the rectangle area of the currently selected script window with the specified color, or clears the window with transparent (index 0) color (call the function without arguments). - `color`: the color index in the game palette (from 0 to 255) - - name: nterface_overlay + - name: interface_overlay detail: sfall_func2("interface_overlay", int winType, int mode) doc: | Alternative form: `int sfall_func6("interface_overlay", int winType, 2, int x, int y, int width, int height)`. diff --git a/artifacts/scripting/sfall function notes.md b/artifacts/scripting/sfall function notes.md index 21a1e2f1..56c67732 100644 --- a/artifacts/scripting/sfall function notes.md +++ b/artifacts/scripting/sfall function notes.md @@ -1139,6 +1139,16 @@ sfall_funcX metarule functions `void sfall_func0("signal_close_game")` - Works in a similar way to vanilla function: `metarule(METARULE_SIGNAL_END_GAME, 0)`, but it will then close the game instead of only returning the player to the main menu +---- +#### art_frame_data +`array sfall_func3("art_frame_data", string/int artFile/artId, int frame, int rotation)` +- Returns the dimensions of a given PCX or FRM frame as a temp array in the form **[width, height]** +- `artFile/artId`: path to the PCX/FRM file (e.g. `art\\inven\\5mmap.frm`), or its FRM ID number (e.g. `0x7000026`, see specification of the FID format) + +**Optional arguments:** +- `frame`: frame number, the first frame starts from zero +- `rotation`: rotation to get the frame for, useful when reading FRM files by path + **** _See other documentation files (arrays.md, hookscripts.md) for related functions reference._ diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 135a61ce..a2c45251 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -105,7 +105,7 @@ WRAP_WATCOM_FUNC1(long, critter_kill_count_type, fo::GameObject*, critter) WRAP_WATCOM_FUNC1(const char*, critter_name, fo::GameObject*, critter) // Returns the name of the critter WRAP_WATCOM_FUNC1(void, critter_pc_set_name, const char*, newName) // Change the name of playable character WRAP_WATCOM_FUNC1(long, critterIsOverloaded, fo::GameObject*, critter) -WRAP_WATCOM_FUNC4(void, datafileConvertData, unsigned char*, data, unsigned char*, palette, long, width, long, height) +WRAP_WATCOM_FUNC4(void, datafileConvertData, BYTE*, data, BYTE*, palette, long, width, long, height) WRAP_WATCOM_FUNC1(void, display_print, const char*, msg) // Displays message in main UI console window WRAP_WATCOM_FUNC0(void, display_stats) WRAP_WATCOM_FUNC2(void, endgame_load_palette, long, artType, long, fid) @@ -177,8 +177,8 @@ WRAP_WATCOM_FUNC1(long, item_w_secondary_mp_cost, fo::GameObject*, item) WRAP_WATCOM_FUNC2(long, item_w_subtype, fo::GameObject*, item, long, hitMode) WRAP_WATCOM_FUNC1(long, item_weight, fo::GameObject*, item) WRAP_WATCOM_FUNC2(long, light_get_tile, long, elevation, long, tileNum) // Returns light level at given tile -WRAP_WATCOM_FUNC2(long, load_frame, const char*, filename, fo::FrmFile**, frmPtr) -WRAP_WATCOM_FUNC4(unsigned char*, loadPCX, const char*, fileName, long*, width, long*, height, unsigned char*, palette) +WRAP_WATCOM_FUNC2(long, load_frame, const char*, fileName, fo::FrmFile**, frmPtr) +WRAP_WATCOM_FUNC4(BYTE*, loadPCX, const char*, fileName, long*, width, long*, height, BYTE*, palette) WRAP_WATCOM_FUNC1(fo::Program*, loadProgram, const char*, fileName) WRAP_WATCOM_FUNC1(const char*, map_get_short_name, long, mapID) WRAP_WATCOM_FUNC2(void, MapDirErase, const char*, folder, const char*, ext) diff --git a/sfall/FalloutEngine/Variables_def.h b/sfall/FalloutEngine/Variables_def.h index 55c20864..9d7f90ca 100644 --- a/sfall/FalloutEngine/Variables_def.h +++ b/sfall/FalloutEngine/Variables_def.h @@ -171,7 +171,7 @@ VAR_(optionsButtonUp1, DWORD) VAR_(optionsButtonUpKey, DWORD) VARC(optnwin, DWORD) VAR_(outlined_object, fo::GameObject*) -VARA(pal, unsigned char, 0x300) +VARA(pal, BYTE, 0x300) VAR_(partyMemberAIOptions, DWORD) VAR_(partyMemberCount, DWORD) VAR_(partyMemberLevelUpInfoList, DWORD*) @@ -273,9 +273,8 @@ VAR_(YellowColor, BYTE) #undef VAR_ #undef VARC -#undef VARP #undef VARA #undef VAR2 #undef VAR3 #undef VARD -#undef VARF +#undef VARP diff --git a/sfall/Modules/Scripting/Handlers/Interface.cpp b/sfall/Modules/Scripting/Handlers/Interface.cpp index c0f32703..e8a7edd8 100644 --- a/sfall/Modules/Scripting/Handlers/Interface.cpp +++ b/sfall/Modules/Scripting/Handlers/Interface.cpp @@ -482,7 +482,7 @@ void mf_set_window_flag(OpcodeContext& ctx) { // raw frame data loaded from FRM or PCX struct FrameData { - unsigned char* pixelData = nullptr; + BYTE* pixelData = nullptr; short width = 0; short height = 0; short xOffset = 0; @@ -502,7 +502,7 @@ struct FrameData { } // Data from PCX file. - FrameData(unsigned char* data, long w, long h) { + FrameData(BYTE* data, long w, long h) { pixelData = data; width = (short)w; height = (short)h; @@ -549,9 +549,9 @@ static FrameData LoadFrameDataCached(const char* file, long frame, long directio } frmFileCache.emplace(file, frmPtr); } - return frmPtr != nullptr - ? FrameData(frmPtr, direction, frame) - : FrameData(); + return (frmPtr != nullptr) + ? FrameData(frmPtr, direction, frame) + : FrameData(); } void ClearInterfaceArtCache() { @@ -593,8 +593,8 @@ static long GetArtFIDFile(long fid, char* outFilePath) { struct ArtCacheLock { DWORD entryPtr = 0; - ArtCacheLock() { } - ArtCacheLock(DWORD _lock) : entryPtr(_lock) { } + ArtCacheLock() {} + ArtCacheLock(DWORD _lock) : entryPtr(_lock) {} ~ArtCacheLock() { if (entryPtr != 0) { fo::func::art_ptr_unlock(entryPtr); @@ -607,9 +607,9 @@ static FrameData LockFrameData(unsigned long fid, ArtCacheLock& lock, long direc long objType = (fid >> 24) & 0xF; if (direction < 0) { // If direction is not specified, take it from FID. - direction = objType == fo::OBJ_TYPE_CRITTER - ? (fid >> 28) - : 0; + direction = (objType == fo::OBJ_TYPE_CRITTER) + ? (fid >> 28) + : 0; } else if (objType == fo::OBJ_TYPE_CRITTER) { // Apply direction to FID. fid = (direction << 28) | (fid & (0xFFFFFFF)); @@ -633,7 +633,7 @@ static long DrawImage(OpcodeContext& ctx, bool isScaled) { frm = LockFrameData(fid, cacheLock, -1, frame); if (frm.pixelData == nullptr) { - ctx.printOpcodeError("%s() - cannot find art by FID %d", ctx.getMetaruleName(), fid); + ctx.printOpcodeError("%s() - cannot load art by FID: %d", ctx.getMetaruleName(), fid); return -1; } } else {