mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
add gett_interface_id, fix crash in interface_draw, add doc for get_window_under_mouse
This commit is contained in:
@@ -1774,6 +1774,7 @@
|
||||
- name: get_window_under_mouse
|
||||
detail: int get_window_under_mouse()
|
||||
opcode: 0x821f
|
||||
doc: "Returns internal ID of a top-most window under mouse cursor."
|
||||
- name: create_win
|
||||
detail: void create_win(string winName, int x, int y, int width, int height, int flags)
|
||||
doc: "`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."
|
||||
@@ -1788,6 +1789,7 @@
|
||||
- `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 get_window_under_mouse)
|
||||
`-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
|
||||
|
||||
@@ -320,6 +320,7 @@
|
||||
#define get_interface_y(winType) sfall_func2("get_window_attribute", winType, 2)
|
||||
#define get_interface_width(winType) sfall_func2("get_window_attribute", winType, 3)
|
||||
#define get_interface_height(winType) sfall_func2("get_window_attribute", winType, 4)
|
||||
#define get_interface_id(winType) sfall_func2("get_window_attribute", winType, 5)
|
||||
#define get_inven_ap_cost sfall_func0("get_inven_ap_cost")
|
||||
#define get_map_enter_position sfall_func0("get_map_enter_position")
|
||||
#define get_metarule_table sfall_func0("get_metarule_table")
|
||||
|
||||
@@ -722,6 +722,11 @@ static long InterfaceDrawImage(OpcodeContext& ctx, fo::Window* ifaceWin) {
|
||||
int width = (w >= 0) ? w : frm.width;
|
||||
int height = (h >= 0) ? h : frm.height;
|
||||
|
||||
if (x + width > ifaceWin->width || y + height > ifaceWin->height) {
|
||||
ctx.printOpcodeError("%s() - attempt to draw beyond window bounds (%d, %d)", ctx.getMetaruleName(), ifaceWin->width, ifaceWin->height);
|
||||
return -1;
|
||||
}
|
||||
|
||||
BYTE* surface = (ifaceWin->randY) ? WindowRender::GetOverlaySurface(ifaceWin) : ifaceWin->surface;
|
||||
|
||||
fo::func::trans_cscale(frm.pixelData, frm.width, frm.height, frm.width,
|
||||
@@ -783,6 +788,9 @@ void mf_get_window_attribute(OpcodeContext& ctx) {
|
||||
case 4:
|
||||
result = win->height;
|
||||
break;
|
||||
case 5:
|
||||
result = win->wID;
|
||||
break;
|
||||
}
|
||||
ctx.setReturn(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user