Windows and images

Functions


art_frame_data

sfall.h

array 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

create_win

sfall.h

void create_win(string winName, int x, int y, int width, int height, int flags)

flags argument is optional. Works just like vanilla CreateWin function, but creates a window with MoveOnTop flag if the 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.


draw_image

sfall.h

void draw_image(string/int artFile/artId, int frame, int x, int y, bool noTransparent)
  • displays the specified PCX or FRM image in the active window created by vanilla CreateWin or sfall’s create_win script function
  • 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
  • x/y: offset relative to the top-left corner of the window
  • 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))

draw_image_scaled

sfall.h

void draw_image_scaled(string/int artFile/artId, int frame, int x, int y, int width, int height)
  • displays the specified PCX or FRM image in the active window created by vanilla CreateWin or sfall’s create_win script function
  • 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
  • x/y: offset relative to the top-left corner of the window
  • width/height: the new width/height to scale the image to. Pass -1 to either width or height to keep the aspect ratio when scaling
  • 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 called without x/y/width/height arguments, the image will be scaled to fit the window without transparent background

get_window_attribute

int sfall_func1("get_window_attribute", int winType)

Alternative form: int sfall_func2("get_window_attribute", int winType, int attrType) Returns the attribute of the specified interface window by the attrType argument.

  • winType: the type number of the interface window (see WINTYPE_* constants in sfall.h)
  • attrType: 0 - checks and returns a value of 1 if the specified interface window is created by the game (same as without the argument) 1 - X position, 2 - Y position (relative to the top-left corner of the game screen) 3 - interface width size, 4 - interface height size 5 - window ID (to compare with the get_window_under_mouse function) -1 - returns an associative array of keys (left, top, right, bottom) and values that define the position of the window rectangle (use standard syntax to access array values, e.g. winRect.top, winRect.bottom)
  • returns -1 if the specified attribute cannot be obtained

get_window_under_mouse

int get_window_under_mouse()

Returns the internal ID of the top-most window under mouse cursor.


interface_art_draw

int sfall_func4("interface_art_draw", int winType, string artFile/int artID, int x, int y)
int sfall_func4("interface_art_draw", int winType, string artFile/int artID, int x, int y)
int sfall_func5("interface_art_draw", int winType, string artFile/int artID, int x, int y, int frame)
int sfall_func6("interface_art_draw", int winType, string artFile/int artID, int x, int y, int frame, array param)
  • draws the specified PCX or FRM image in the game interface window, returns -1 on any error
  • winType: the type number of the interface window (see WINTYPE_* constants in sfall.h) this also takes the value of the flag (0x1000000) to prevent immediate redrawing of the interface window
  • 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)
  • x/y: offset relative to the top-left corner of the window

optional arguments:

  • frame: frame number, the first frame starts from zero
  • param: an array which specifies additional parameters, where: index 0 - sprite direction for multi-directional FRM index 1/index 2 - the new width/height to scale the image to. Pass -1 to use the original width/height

interface_overlay

sfall_func2("interface_overlay", int winType, int mode)

Alternative form: int sfall_func6("interface_overlay", int winType, 2, int x, int y, int width, int height).

Creates an additional drawing surface above the graphic layer of the specified interface window. All subsequent calls of interface_art_draw and interface_print functions will draw on it.

  • winType: the type number of the interface window (see WINTYPE_* constants in sfall.h)
  • mode: 1 - creates a new overlay surface 2 - clears the overlay area or the specified rectangle defined by the x, y, width, height arguments 0 - destroys the created overlay surface (frees up the memory allocated to the surface)

interface_print

int sfall_func5("interface_print", string text, int winType, int x, int y, int color)
int sfall_func5("interface_print", string text, int winType, int x, int y, int color)
int sfall_func6("interface_print", string text, int winType, int x, int y, int color, int width)
  • displays the text in the specified interface window with the current font. Use vanilla SetFont function to set the font
  • returns the count of lines printed, or -1 on any error
  • text: the text to be printed. Use the \n control character to move text to a new line (example: “Hello\nWorld!”)
  • winType: the type number of the interface window (see WINTYPE_* constants in sfall.h)
  • x/y: offset relative to the top-left corner of the window
  • color: the color index in the game palette. Pass 0 if the text color was previously set by vanilla SetTextColor function It can also take additional flags (via bwor) for displaying text:
    • 0x0010000 - adds a shadow to the text, the ‘textshadow’ compiler constant
    • 0x1000000 - prevents immediate redrawing of the interface window, the textdirect compiler constant (works the other way around)
    • 0x2000000 - fills the background of the text with black color, the textnofill compiler constant (works the other way around)
  • width (optional): the maximum width of the text. The text will be wrapped to fit within the specified width

message_box

int sfall_func4("message_box", string message, int flags, int color1, int color2)

Creates a dialog box with text and returns the result of pressing the button: 0 - No (Escape), 1 - Yes/Done (Enter). Returns -1 if for some reason the dialog box cannot be created.

- message: the text in the dialog box. Use the `\n` control character to move text to a new line (example: "Hello\nWorld!")
optional arguments:
- flags: mode flags (see `MSGBOX_*` constants in define_extra.h). Pass -1 to skip setting the flags (default flags are NORMAL and YESNO)
- color1/color2: the color index in the game palette. `color1` sets the text color for the first line, and `color2` for all subsequent lines of text (default color is 145)

set_window_flag

sfall.h

void set_window_flag(string winName/int winID, int flag, bool value)

Changes the specified flag for the created script or game interface window.

  • winName: the window name, assigned to the window by the CreateWin/create_win function
  • winID: the ID number of the interface or script window obtained with the get_window_under_mouse function, or 0 for the current game interface
  • flag: the flag to change (see WIN_FLAG_* constants in define_extra.h)
  • value: True - set the flag, False - unset the flag

win_fill_color

int win_fill_color(int x, int y, int width, int height, int color)

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)