mirror of
https://github.com/Dadido3/noita-mapcap.git
synced 2024-11-18 17:17:31 +00:00
David Vogel
98dfb5fbb0
- Remove unused util functions - Put util stuff into its own namespace - Move all initialization stuff into root init.lua - Move progressBarString function into ui.lua - Fix ffi.load error message - Fix DebugAPI.BiomeMapGetFilename - Move JSON lib into Noita API wrapper - Move Vec2 lib into Noita API wrapper - Move compatibility stuff into Noita API wrapper - Emulate package tables if in restricted API mode - Emulate require if in restricted API mode - Use require instead of dofile_once everywhere - Fix WrapID method to accept nil - Add EmmyLua annotations for the default Noita API - Add README.md to Noita API wrapper
45 lines
988 B
Lua
45 lines
988 B
Lua
-- Copyright (c) 2019-2022 David Vogel
|
|
--
|
|
-- This software is released under the MIT License.
|
|
-- https://opensource.org/licenses/MIT
|
|
|
|
local ffi = ffi or _G.ffi or require("ffi")
|
|
|
|
local status, caplib = pcall(ffi.load, "mods/noita-mapcap/bin/capture-b/capture")
|
|
if not status then
|
|
print("Error loading capture lib: " .. caplib)
|
|
end
|
|
ffi.cdef [[
|
|
typedef long LONG;
|
|
typedef struct {
|
|
LONG left;
|
|
LONG top;
|
|
LONG right;
|
|
LONG bottom;
|
|
} RECT;
|
|
|
|
bool GetRect(RECT* rect);
|
|
bool Capture(int x, int y);
|
|
|
|
int SetThreadExecutionState(int esFlags);
|
|
]]
|
|
|
|
function TriggerCapture(x, y)
|
|
return caplib.Capture(x, y)
|
|
end
|
|
|
|
-- Get the client rectangle of the "Main" window of this process in screen coordinates
|
|
function GetRect()
|
|
local rect = ffi.new("RECT", 0, 0, 0, 0)
|
|
if not caplib.GetRect(rect) then
|
|
return nil
|
|
end
|
|
|
|
return rect
|
|
end
|
|
|
|
-- Reset computer and monitor standby timer
|
|
function ResetStandbyTimer()
|
|
ffi.C.SetThreadExecutionState(3) -- ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED
|
|
end
|