mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Backported "draw_image" and "draw_image_scaled" functions from 4.1
This commit is contained in:
@@ -234,6 +234,8 @@
|
|||||||
#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_obj sfall_func0("dialog_obj")
|
#define dialog_obj sfall_func0("dialog_obj")
|
||||||
#define display_stats sfall_func0("display_stats")
|
#define display_stats sfall_func0("display_stats")
|
||||||
|
#define draw_image(pathFile, frame, x, y, noTrans) sfall_func5("draw_image", pathFile, frame, x, y, noTrans)
|
||||||
|
#define draw_image_scaled(pathFile, frame, x, y, w, h) sfall_func6("draw_image_scaled", pathFile, frame, x, y, w, h)
|
||||||
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
#define exec_map_update_scripts sfall_func0("exec_map_update_scripts")
|
||||||
#define floor2(value) sfall_func1("floor2", value)
|
#define floor2(value) sfall_func1("floor2", value)
|
||||||
#define get_current_inven_size(obj) sfall_func1("get_current_inven_size", obj)
|
#define get_current_inven_size(obj) sfall_func1("get_current_inven_size", obj)
|
||||||
|
|||||||
@@ -522,6 +522,18 @@ Some utility/math functions are available:
|
|||||||
- there is also a unique ID number range for the player and party members from 18000 to 83535
|
- there is also a unique ID number range for the player and party members from 18000 to 83535
|
||||||
- to assign a new ID number generated by the engine to the object (i.e. unassign a unique ID), call the function with two arguments and pass -1 for the flag argument
|
- to assign a new ID number generated by the engine to the object (i.e. unassign a unique ID), call the function with two arguments and pass -1 for the flag argument
|
||||||
|
|
||||||
|
> void sfall_func5("draw_image", string/int pathFile/artId, int frame, int x, int y, bool noTransparent)
|
||||||
|
> void sfall_func6("draw_image_scaled", string/int pathFile/artId, int frame, int x, int y, int width, int height)
|
||||||
|
- displays the specified FRM image in the active window created by vanilla CreateWin or sfall's create_win script function
|
||||||
|
- pathFile/artId: path to the FRM file (e.g. "art\\inven\\5mmap.frm"), or its FRM ID number (e.g. 117440550, see specification of the FID format)
|
||||||
|
optional arguments:
|
||||||
|
- frame: frame number, the first frame starts from zero
|
||||||
|
- x/y: offset relative to the top-left corner of the window
|
||||||
|
- width/height: image size, used to scale the image when displaying it. Pass -1 to either width or height to keep the aspect ratio when scaling
|
||||||
|
- noTransparent: pass true to display an image without transparent background
|
||||||
|
- NOTE: to omit optional arguments starting from the right, call the functions with different sfall_funcX (e.g. sfall_func4("draw_image", pathFile, frame, x, y))
|
||||||
|
- if draw_image_scaled is called without x/y/width/height arguments, the image will be scaled to fit the window without transparent background
|
||||||
|
|
||||||
> void sfall_func2("unwield_slot", object critter, int slot)
|
> void sfall_func2("unwield_slot", object critter, int slot)
|
||||||
- unequips an item from the specified slot for a critter or the player
|
- unequips an item from the specified slot for a critter or the player
|
||||||
- can take off player's equipped item when the inventory is opened, or the player is in the barter screen
|
- can take off player's equipped item when the inventory is opened, or the player is in the barter screen
|
||||||
|
|||||||
@@ -265,6 +265,7 @@ const DWORD art_frame_data_ = 0x419870;
|
|||||||
const DWORD art_frame_length_ = 0x4197B8;
|
const DWORD art_frame_length_ = 0x4197B8;
|
||||||
const DWORD art_frame_width_ = 0x4197A0;
|
const DWORD art_frame_width_ = 0x4197A0;
|
||||||
const DWORD art_get_code_ = 0x419314;
|
const DWORD art_get_code_ = 0x419314;
|
||||||
|
const DWORD art_get_name_ = 0x419428;
|
||||||
const DWORD art_id_ = 0x419C88;
|
const DWORD art_id_ = 0x419C88;
|
||||||
const DWORD art_init_ = 0x418840;
|
const DWORD art_init_ = 0x418840;
|
||||||
const DWORD art_lock_ = 0x4191CC;
|
const DWORD art_lock_ = 0x4191CC;
|
||||||
@@ -336,6 +337,7 @@ const DWORD debug_printf_ = 0x4C6F48;
|
|||||||
const DWORD debug_register_env_ = 0x4C6D90;
|
const DWORD debug_register_env_ = 0x4C6D90;
|
||||||
const DWORD determine_to_hit_func_ = 0x4243A8;
|
const DWORD determine_to_hit_func_ = 0x4243A8;
|
||||||
const DWORD dialog_out_ = 0x41CF20;
|
const DWORD dialog_out_ = 0x41CF20;
|
||||||
|
const DWORD displayInWindow_ = 0x4B8B10;
|
||||||
const DWORD display_inventory_ = 0x46FDF4;
|
const DWORD display_inventory_ = 0x46FDF4;
|
||||||
const DWORD display_print_ = 0x43186C;
|
const DWORD display_print_ = 0x43186C;
|
||||||
const DWORD display_scroll_down_ = 0x431B9C;
|
const DWORD display_scroll_down_ = 0x431B9C;
|
||||||
@@ -484,6 +486,7 @@ const DWORD loadColorTable_ = 0x4C78E4;
|
|||||||
const DWORD LoadGame_ = 0x47C640;
|
const DWORD LoadGame_ = 0x47C640;
|
||||||
const DWORD loadProgram_ = 0x4A3B74;
|
const DWORD loadProgram_ = 0x4A3B74;
|
||||||
const DWORD LoadSlot_ = 0x47DC68;
|
const DWORD LoadSlot_ = 0x47DC68;
|
||||||
|
const DWORD load_frame_ = 0x419EC0;
|
||||||
const DWORD loot_container_ = 0x473904;
|
const DWORD loot_container_ = 0x473904;
|
||||||
const DWORD main_game_loop_ = 0x480E48;
|
const DWORD main_game_loop_ = 0x480E48;
|
||||||
const DWORD main_init_system_ = 0x480CC0;
|
const DWORD main_init_system_ = 0x480CC0;
|
||||||
@@ -675,6 +678,7 @@ const DWORD trait_get_ = 0x4B3B54;
|
|||||||
const DWORD trait_init_ = 0x4B39F0;
|
const DWORD trait_init_ = 0x4B39F0;
|
||||||
const DWORD trait_level_ = 0x4B3BC8;
|
const DWORD trait_level_ = 0x4B3BC8;
|
||||||
const DWORD trait_set_ = 0x4B3B48;
|
const DWORD trait_set_ = 0x4B3B48;
|
||||||
|
const DWORD trans_cscale_ = 0x4D3560;
|
||||||
const DWORD use_inventory_on_ = 0x4717E4;
|
const DWORD use_inventory_on_ = 0x4717E4;
|
||||||
const DWORD _word_wrap_ = 0x4BC6F0;
|
const DWORD _word_wrap_ = 0x4BC6F0;
|
||||||
const DWORD win_add_ = 0x4D6238;
|
const DWORD win_add_ = 0x4D6238;
|
||||||
@@ -692,8 +696,12 @@ const DWORD win_register_button_ = 0x4D8260;
|
|||||||
const DWORD win_register_button_disable_ = 0x4D8674;
|
const DWORD win_register_button_disable_ = 0x4D8674;
|
||||||
const DWORD win_register_button_sound_func_ = 0x4D87F8;
|
const DWORD win_register_button_sound_func_ = 0x4D87F8;
|
||||||
const DWORD win_show_ = 0x4D6DAC;
|
const DWORD win_show_ = 0x4D6DAC;
|
||||||
|
const DWORD windowDisplayBuf_ = 0x4B8EF0;
|
||||||
|
const DWORD windowDisplayTransBuf_ = 0x4B8F64;
|
||||||
|
const DWORD windowGetBuffer_ = 0x4B82DC;
|
||||||
const DWORD windowHide_ = 0x4B7610;
|
const DWORD windowHide_ = 0x4B7610;
|
||||||
const DWORD windowShow_ = 0x4B7648;
|
const DWORD windowShow_ = 0x4B7648;
|
||||||
|
const DWORD windowWidth_ = 0x4B7734;
|
||||||
const DWORD wmFindCurSubTileFromPos_ = 0x4C0C00;
|
const DWORD wmFindCurSubTileFromPos_ = 0x4C0C00;
|
||||||
const DWORD wmInterfaceScrollTabsStart_ = 0x4C219C;
|
const DWORD wmInterfaceScrollTabsStart_ = 0x4C219C;
|
||||||
const DWORD wmMapIsSaveable_ = 0x4BFA64;
|
const DWORD wmMapIsSaveable_ = 0x4BFA64;
|
||||||
@@ -1053,6 +1061,44 @@ void __stdcall DialogOut(const char* text) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// draws an image to the buffer without scaling and with transparency display toggle
|
||||||
|
void __fastcall WindowDisplayBuf(long x, long width, long y, long height, void* data, long noTrans) {
|
||||||
|
__asm {
|
||||||
|
push height;
|
||||||
|
push edx; // from_width
|
||||||
|
push y;
|
||||||
|
mov eax, data; // from
|
||||||
|
mov ebx, windowDisplayTransBuf_;
|
||||||
|
cmp noTrans, 0;
|
||||||
|
cmovnz ebx, windowDisplayBuf_;
|
||||||
|
call ebx; // *data<eax>, from_width<edx>, unused<ebx>, X<ecx>, Y, width, height
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// draws an image in the window and scales it to fit the window
|
||||||
|
void __fastcall DisplayInWindow(long w_here, long width, long height, void* data) {
|
||||||
|
__asm {
|
||||||
|
mov ebx, height;
|
||||||
|
mov eax, data;
|
||||||
|
call displayInWindow_; // *data<eax>, width<edx>, height<ebx>, where<ecx>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __fastcall TransCscale(long i_width, long i_height, long s_width, long s_height, long xy_shift, long w_width, void* data) {
|
||||||
|
__asm {
|
||||||
|
push w_width;
|
||||||
|
push s_height;
|
||||||
|
push s_width;
|
||||||
|
mov ebx, edx; // i_height
|
||||||
|
mov edx, ecx; // i_width
|
||||||
|
call windowGetBuffer_;
|
||||||
|
add eax, xy_shift;
|
||||||
|
push eax; // to_buff
|
||||||
|
mov eax, data;
|
||||||
|
call trans_cscale_; // *from_buff<eax>, i_width<edx>, i_height<ebx>, i_width2<ecx>, to_buff, width, height, to_width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
long __fastcall GetGameConfigString(const char* outValue, const char* section, const char* param) {
|
long __fastcall GetGameConfigString(const char* outValue, const char* section, const char* param) {
|
||||||
__asm {
|
__asm {
|
||||||
mov ebx, param;
|
mov ebx, param;
|
||||||
@@ -1110,6 +1156,10 @@ void __stdcall DestroyWin(DWORD winRef) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
long __stdcall WindowWidth() {
|
||||||
|
__asm call windowWidth_;
|
||||||
|
}
|
||||||
|
|
||||||
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode) {
|
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode) {
|
||||||
__asm {
|
__asm {
|
||||||
mov ebx, mode;
|
mov ebx, mode;
|
||||||
@@ -1348,3 +1398,18 @@ long __fastcall MouseClickIn(long x, long y, long x_end, long y_end) {
|
|||||||
call mouse_click_in_;
|
call mouse_click_in_;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* __stdcall ArtGetName(long artFID) {
|
||||||
|
__asm {
|
||||||
|
mov eax, artFID;
|
||||||
|
call art_get_name_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr) {
|
||||||
|
__asm {
|
||||||
|
mov edx, frmPtr;
|
||||||
|
mov eax, filename;
|
||||||
|
call load_frame_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -63,6 +63,7 @@
|
|||||||
#define _curr_font_num 0x51E3B0
|
#define _curr_font_num 0x51E3B0
|
||||||
#define _curr_pc_stat 0x6681AC
|
#define _curr_pc_stat 0x6681AC
|
||||||
#define _curr_stack 0x59E96C
|
#define _curr_stack 0x59E96C
|
||||||
|
#define _currentWindow 0x51DCB8
|
||||||
#define _cursor_line 0x664514
|
#define _cursor_line 0x664514
|
||||||
#define _dialog_target 0x518848
|
#define _dialog_target 0x518848
|
||||||
#define _dialog_target_is_party 0x51884C
|
#define _dialog_target_is_party 0x51884C
|
||||||
@@ -500,6 +501,7 @@ extern const DWORD art_frame_data_;
|
|||||||
extern const DWORD art_frame_length_;
|
extern const DWORD art_frame_length_;
|
||||||
extern const DWORD art_frame_width_;
|
extern const DWORD art_frame_width_;
|
||||||
extern const DWORD art_get_code_;
|
extern const DWORD art_get_code_;
|
||||||
|
extern const DWORD art_get_name_;
|
||||||
extern const DWORD art_id_;
|
extern const DWORD art_id_;
|
||||||
extern const DWORD art_init_;
|
extern const DWORD art_init_;
|
||||||
extern const DWORD art_lock_;
|
extern const DWORD art_lock_;
|
||||||
@@ -571,6 +573,7 @@ extern const DWORD debug_printf_;
|
|||||||
extern const DWORD debug_register_env_;
|
extern const DWORD debug_register_env_;
|
||||||
extern const DWORD determine_to_hit_func_;
|
extern const DWORD determine_to_hit_func_;
|
||||||
extern const DWORD dialog_out_;
|
extern const DWORD dialog_out_;
|
||||||
|
extern const DWORD displayInWindow_;
|
||||||
extern const DWORD display_inventory_;
|
extern const DWORD display_inventory_;
|
||||||
extern const DWORD display_print_; // eax - char* to display
|
extern const DWORD display_print_; // eax - char* to display
|
||||||
extern const DWORD display_scroll_down_;
|
extern const DWORD display_scroll_down_;
|
||||||
@@ -721,6 +724,7 @@ extern const DWORD loadColorTable_;
|
|||||||
extern const DWORD LoadGame_;
|
extern const DWORD LoadGame_;
|
||||||
extern const DWORD loadProgram_; // loads script from scripts/ folder by file name and returns pointer to it: char* <eax> - file name (w/o extension)
|
extern const DWORD loadProgram_; // loads script from scripts/ folder by file name and returns pointer to it: char* <eax> - file name (w/o extension)
|
||||||
extern const DWORD LoadSlot_;
|
extern const DWORD LoadSlot_;
|
||||||
|
extern const DWORD load_frame_;
|
||||||
extern const DWORD loot_container_;
|
extern const DWORD loot_container_;
|
||||||
extern const DWORD main_game_loop_;
|
extern const DWORD main_game_loop_;
|
||||||
extern const DWORD main_init_system_;
|
extern const DWORD main_init_system_;
|
||||||
@@ -918,6 +922,7 @@ extern const DWORD trait_get_;
|
|||||||
extern const DWORD trait_init_;
|
extern const DWORD trait_init_;
|
||||||
extern const DWORD trait_level_;
|
extern const DWORD trait_level_;
|
||||||
extern const DWORD trait_set_;
|
extern const DWORD trait_set_;
|
||||||
|
extern const DWORD trans_cscale_;
|
||||||
extern const DWORD use_inventory_on_;
|
extern const DWORD use_inventory_on_;
|
||||||
extern const DWORD _word_wrap_;
|
extern const DWORD _word_wrap_;
|
||||||
extern const DWORD win_add_;
|
extern const DWORD win_add_;
|
||||||
@@ -935,8 +940,12 @@ extern const DWORD win_register_button_;
|
|||||||
extern const DWORD win_register_button_disable_;
|
extern const DWORD win_register_button_disable_;
|
||||||
extern const DWORD win_register_button_sound_func_;
|
extern const DWORD win_register_button_sound_func_;
|
||||||
extern const DWORD win_show_;
|
extern const DWORD win_show_;
|
||||||
|
extern const DWORD windowDisplayBuf_;
|
||||||
|
extern const DWORD windowDisplayTransBuf_;
|
||||||
|
extern const DWORD windowGetBuffer_;
|
||||||
extern const DWORD windowHide_;
|
extern const DWORD windowHide_;
|
||||||
extern const DWORD windowShow_;
|
extern const DWORD windowShow_;
|
||||||
|
extern const DWORD windowWidth_;
|
||||||
extern const DWORD wmFindCurSubTileFromPos_;
|
extern const DWORD wmFindCurSubTileFromPos_;
|
||||||
extern const DWORD wmInterfaceScrollTabsStart_;
|
extern const DWORD wmInterfaceScrollTabsStart_;
|
||||||
extern const DWORD wmMapIsSaveable_;
|
extern const DWORD wmMapIsSaveable_;
|
||||||
@@ -1090,6 +1099,12 @@ long __stdcall WinRegisterButton(DWORD winRef, long xPos, long yPos, long width,
|
|||||||
|
|
||||||
void __stdcall DialogOut(const char* text);
|
void __stdcall DialogOut(const char* text);
|
||||||
|
|
||||||
|
void __fastcall WindowDisplayBuf(long x, long width, long y, long height, void* data, long noTrans);
|
||||||
|
|
||||||
|
void __fastcall DisplayInWindow(long w_here, long width, long height, void* data);
|
||||||
|
|
||||||
|
void __fastcall TransCscale(long i_width, long i_height, long s_width, long s_height, long xy_shift, long w_width, void* data);
|
||||||
|
|
||||||
long __fastcall GetGameConfigString(const char* outValue, const char* section, const char* param);
|
long __fastcall GetGameConfigString(const char* outValue, const char* section, const char* param);
|
||||||
|
|
||||||
long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count);
|
long __fastcall WordWrap(const char* text, int maxWidth, DWORD* buf, BYTE* count);
|
||||||
@@ -1100,6 +1115,8 @@ void __stdcall HideWin(DWORD winRef);
|
|||||||
void __stdcall RedrawWin(DWORD winRef);
|
void __stdcall RedrawWin(DWORD winRef);
|
||||||
void __stdcall DestroyWin(DWORD winRef);
|
void __stdcall DestroyWin(DWORD winRef);
|
||||||
|
|
||||||
|
long __stdcall WindowWidth();
|
||||||
|
|
||||||
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode);
|
void __fastcall DisplayInventory(long inventoryOffset, long visibleOffset, long mode);
|
||||||
|
|
||||||
void __fastcall DisplayTargetInventory(long inventoryOffset, long visibleOffset, DWORD* targetInventory, long mode);
|
void __fastcall DisplayTargetInventory(long inventoryOffset, long visibleOffset, DWORD* targetInventory, long mode);
|
||||||
@@ -1159,3 +1176,7 @@ long __stdcall InvenUnwield(TGameObj* critter, long slot);
|
|||||||
long __fastcall ItemAddForce(TGameObj* critter, TGameObj* item, long count);
|
long __fastcall ItemAddForce(TGameObj* critter, TGameObj* item, long count);
|
||||||
|
|
||||||
long __fastcall MouseClickIn(long x, long y, long x_end, long y_end);
|
long __fastcall MouseClickIn(long x, long y, long x_end, long y_end);
|
||||||
|
|
||||||
|
const char* __stdcall ArtGetName(long artFID);
|
||||||
|
|
||||||
|
long __stdcall LoadFrame(const char* filename, FrmFile** frmPtr);
|
||||||
|
|||||||
@@ -711,7 +711,7 @@ void _stdcall RefreshHeroBaseArt() {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
// Check fallout file and get file size (result 0 - file exists)
|
// Check fallout file and get file size (result 0 - file exists)
|
||||||
long __stdcall db_dir_entry(const char *fileName, DWORD *sizeOut) {
|
long __stdcall DbDirEntry(const char *fileName, DWORD *sizeOut) {
|
||||||
__asm {
|
__asm {
|
||||||
mov edx, sizeOut;
|
mov edx, sizeOut;
|
||||||
mov eax, fileName;
|
mov eax, fileName;
|
||||||
|
|||||||
@@ -398,6 +398,8 @@ static const SfallOpcodeMetadata opcodeMetaArray[] = {
|
|||||||
{sf_add_trait, "add_trait", {DATATYPE_MASK_INT}},
|
{sf_add_trait, "add_trait", {DATATYPE_MASK_INT}},
|
||||||
{sf_create_win, "create_win", {DATATYPE_MASK_STR, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}},
|
{sf_create_win, "create_win", {DATATYPE_MASK_STR, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}},
|
||||||
{sf_critter_inven_obj2, "critter_inven_obj2", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
|
{sf_critter_inven_obj2, "critter_inven_obj2", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
|
||||||
|
{sf_draw_image, "draw_image", {DATATYPE_MASK_INT | DATATYPE_MASK_STR, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}},
|
||||||
|
{sf_draw_image_scaled, "draw_image_scaled", {DATATYPE_MASK_INT | DATATYPE_MASK_STR, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT, DATATYPE_MASK_INT}},
|
||||||
{sf_get_current_inven_size, "get_current_inven_size", {DATATYPE_MASK_VALID_OBJ}},
|
{sf_get_current_inven_size, "get_current_inven_size", {DATATYPE_MASK_VALID_OBJ}},
|
||||||
{sf_get_flags, "get_flags", {DATATYPE_MASK_VALID_OBJ}},
|
{sf_get_flags, "get_flags", {DATATYPE_MASK_VALID_OBJ}},
|
||||||
{sf_get_object_data, "get_object_data", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
|
{sf_get_object_data, "get_object_data", {DATATYPE_MASK_VALID_OBJ, DATATYPE_MASK_INT}},
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ static void sf_inventory_redraw() {
|
|||||||
|
|
||||||
static void sf_create_win() {
|
static void sf_create_win() {
|
||||||
int flags;
|
int flags;
|
||||||
if (opHandler.numArgs() == 6) {
|
if (opHandler.numArgs() > 5) {
|
||||||
flags = opHandler.arg(5).asInt();
|
flags = opHandler.arg(5).asInt();
|
||||||
} else {
|
} else {
|
||||||
flags = WIN_MoveOnTop;
|
flags = WIN_MoveOnTop;
|
||||||
@@ -506,6 +506,152 @@ static void sf_set_window_flag() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sf_draw_image() {
|
||||||
|
if (*(DWORD*)_currentWindow == -1) {
|
||||||
|
opHandler.printOpcodeError("draw_image() - no created/selected window for the image.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long direction = 0;
|
||||||
|
const char* file = nullptr;
|
||||||
|
if (opHandler.arg(0).isInt()) { // art id
|
||||||
|
long fid = opHandler.arg(0).rawValue();
|
||||||
|
if (fid == -1) return;
|
||||||
|
long _fid = fid & 0xFFFFFFF;
|
||||||
|
file = ArtGetName(_fid); // .frm
|
||||||
|
if (_fid >> 24 == OBJ_TYPE_CRITTER) {
|
||||||
|
direction = (fid >> 28);
|
||||||
|
if (direction && !DbAccess(file)) {
|
||||||
|
file = ArtGetName(fid); // .fr#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file = opHandler.arg(0).strValue(); // path to frm file
|
||||||
|
}
|
||||||
|
FrmFile* frmPtr = nullptr;
|
||||||
|
if (LoadFrame(file, &frmPtr)) {
|
||||||
|
opHandler.printOpcodeError("draw_image() - cannot open the file: %s", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FrmFrameData* framePtr = (FrmFrameData*)&frmPtr->width;
|
||||||
|
if (direction > 0 && direction < 6) {
|
||||||
|
BYTE* offsOriFrame = (BYTE*)framePtr;
|
||||||
|
offsOriFrame += frmPtr->oriFrameOffset[direction];
|
||||||
|
framePtr = (FrmFrameData*)offsOriFrame;
|
||||||
|
}
|
||||||
|
// initialize other args
|
||||||
|
int frameno = 0, x = 0, y = 0, noTrans = 0;
|
||||||
|
switch (opHandler.numArgs()) {
|
||||||
|
case 5:
|
||||||
|
noTrans = opHandler.arg(4).rawValue();
|
||||||
|
case 4:
|
||||||
|
y = opHandler.arg(3).rawValue();
|
||||||
|
case 3:
|
||||||
|
x = opHandler.arg(2).rawValue();
|
||||||
|
case 2:
|
||||||
|
frameno = opHandler.arg(1).rawValue();
|
||||||
|
}
|
||||||
|
if (frameno > 0) {
|
||||||
|
int maxFrames = frmPtr->frames - 1;
|
||||||
|
if (frameno > maxFrames) frameno = maxFrames;
|
||||||
|
while (frameno-- > 0) {
|
||||||
|
BYTE* offsFrame = (BYTE*)framePtr;
|
||||||
|
offsFrame += framePtr->size + (sizeof(FrmFrameData) - 1);
|
||||||
|
framePtr = (FrmFrameData*)offsFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// with x/y frame offsets
|
||||||
|
WindowDisplayBuf(x + frmPtr->xshift[direction], framePtr->width, y + frmPtr->yshift[direction], framePtr->height, framePtr->data, noTrans);
|
||||||
|
__asm {
|
||||||
|
mov eax, frmPtr;
|
||||||
|
call mem_free_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sf_draw_image_scaled() {
|
||||||
|
if (*(DWORD*)_currentWindow == -1) {
|
||||||
|
opHandler.printOpcodeError("draw_image_scaled() - no created/selected window for the image.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long direction = 0;
|
||||||
|
const char* file = nullptr;
|
||||||
|
if (opHandler.arg(0).isInt()) { // art id
|
||||||
|
long fid = opHandler.arg(0).rawValue();
|
||||||
|
if (fid == -1) return;
|
||||||
|
long _fid = fid & 0xFFFFFFF;
|
||||||
|
file = ArtGetName(_fid); // .frm
|
||||||
|
if (_fid >> 24 == OBJ_TYPE_CRITTER) {
|
||||||
|
direction = (fid >> 28);
|
||||||
|
if (direction && !DbAccess(file)) {
|
||||||
|
file = ArtGetName(fid); // .fr#
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
file = opHandler.arg(0).strValue(); // path to frm file
|
||||||
|
}
|
||||||
|
FrmFile* frmPtr = nullptr;
|
||||||
|
if (LoadFrame(file, &frmPtr)) {
|
||||||
|
opHandler.printOpcodeError("draw_image_scaled() - cannot open the file: %s", file);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FrmFrameData* framePtr = (FrmFrameData*)&frmPtr->width;
|
||||||
|
if (direction > 0 && direction < 6) {
|
||||||
|
BYTE* offsOriFrame = (BYTE*)framePtr;
|
||||||
|
offsOriFrame += frmPtr->oriFrameOffset[direction];
|
||||||
|
framePtr = (FrmFrameData*)offsOriFrame;
|
||||||
|
}
|
||||||
|
// initialize other args
|
||||||
|
int frameno = 0, x = 0, y = 0, wsize = 0;
|
||||||
|
const int argNums = opHandler.numArgs();
|
||||||
|
switch (argNums) {
|
||||||
|
case 6:
|
||||||
|
case 5:
|
||||||
|
wsize = opHandler.arg(4).rawValue();
|
||||||
|
case 4:
|
||||||
|
y = opHandler.arg(3).rawValue();
|
||||||
|
case 3:
|
||||||
|
x = opHandler.arg(2).rawValue();
|
||||||
|
case 2:
|
||||||
|
frameno = opHandler.arg(1).rawValue();
|
||||||
|
}
|
||||||
|
if (frameno > 0) {
|
||||||
|
int maxFrames = frmPtr->frames - 1;
|
||||||
|
if (frameno > maxFrames) frameno = maxFrames;
|
||||||
|
while (frameno-- > 0) {
|
||||||
|
BYTE* offsFrame = (BYTE*)framePtr;
|
||||||
|
offsFrame += framePtr->size + (sizeof(FrmFrameData) - 1);
|
||||||
|
framePtr = (FrmFrameData*)offsFrame;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argNums < 3) {
|
||||||
|
DisplayInWindow(framePtr->width, framePtr->width, framePtr->height, framePtr->data); // scaled to window size (w/o transparent)
|
||||||
|
} else {
|
||||||
|
// draw to scale
|
||||||
|
long s_width, s_height;
|
||||||
|
if (argNums < 5) {
|
||||||
|
s_width = framePtr->width;
|
||||||
|
s_height = framePtr->height;
|
||||||
|
} else {
|
||||||
|
s_width = wsize;
|
||||||
|
s_height = (argNums > 5) ? opHandler.arg(5).rawValue() : -1;
|
||||||
|
}
|
||||||
|
// scale with aspect ratio if w or h is set to -1
|
||||||
|
if (s_width <= -1 && s_height > 0) {
|
||||||
|
s_width = s_height * framePtr->width / framePtr->height;
|
||||||
|
} else if (s_height <= -1 && s_width > 0) {
|
||||||
|
s_height = s_width * framePtr->height / framePtr->width;
|
||||||
|
}
|
||||||
|
if (s_width <= 0 || s_height <= 0) return;
|
||||||
|
|
||||||
|
long w_width = WindowWidth();
|
||||||
|
long xy_pos = (y * w_width) + x;
|
||||||
|
TransCscale(framePtr->width, framePtr->height, s_width, s_height, xy_pos, w_width, framePtr->data); // custom scaling
|
||||||
|
}
|
||||||
|
__asm {
|
||||||
|
mov eax, frmPtr;
|
||||||
|
call mem_free_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void sf_unwield_slot() {
|
static void sf_unwield_slot() {
|
||||||
long slot = static_cast<long>(opHandler.arg(1).rawValue());
|
long slot = static_cast<long>(opHandler.arg(1).rawValue());
|
||||||
if (slot < INVEN_TYPE_WORN || slot > INVEN_TYPE_LEFT_HAND) {
|
if (slot < INVEN_TYPE_WORN || slot > INVEN_TYPE_LEFT_HAND) {
|
||||||
|
|||||||
@@ -127,6 +127,8 @@ static const SfallMetarule metaruleArray[] = {
|
|||||||
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2},
|
{"critter_inven_obj2", sf_critter_inven_obj2, 2, 2},
|
||||||
{"dialog_obj", sf_get_dialog_object, 0, 0},
|
{"dialog_obj", sf_get_dialog_object, 0, 0},
|
||||||
{"display_stats", sf_display_stats, 0, 0}, // refresh
|
{"display_stats", sf_display_stats, 0, 0}, // refresh
|
||||||
|
{"draw_image", sf_draw_image, 1, 5},
|
||||||
|
{"draw_image_scaled", sf_draw_image_scaled, 1, 6},
|
||||||
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
{"exec_map_update_scripts", sf_exec_map_update_scripts, 0, 0},
|
||||||
{"floor2", sf_floor2, 1, 1},
|
{"floor2", sf_floor2, 1, 1},
|
||||||
{"get_current_inven_size", sf_get_current_inven_size, 1, 1},
|
{"get_current_inven_size", sf_get_current_inven_size, 1, 1},
|
||||||
|
|||||||
Reference in New Issue
Block a user