Commit Graph

70 Commits

Author SHA1 Message Date
CasualPokePlayer 339994c5a7 change these to using var 2022-12-06 09:46:12 -08:00
CasualPokePlayer eb00019c86 fix passing numbers for string args in .net lua functions (old engine had this behavior, granted "bad user" if they relied on this), add appropriate test
fix passing sbyte/char as args, add appropriate tests
cleanup the lua auto unlock hack, using a nice ref struct + dispose to handle it
2022-12-05 23:21:23 -08:00
CasualPokePlayer f798021bba CloseRom acts like rebooting the core, so make it just reset Lua libs (more properly fixes #3226 without any yield nonsense)
Slight revert of 2efae13af4 (still want to set running scripts as it's used later)
Fix detaching registered functions (old logic was broken, Stop would null out the LuaRef used for creating the new dummy thread for the detached function. best solution i've come up with is to simply pass a callback over for creating the thread, nicely encapsulating that functionality)
Various cleanups, don't need VS complaining about old pattern matching code here anymore...
2022-12-03 04:57:58 -08:00
CasualPokePlayer 51f01efdc4 Properly handle errors when running a lua script, using Resume/Yield methods added to the LuaThread class (see f904fa0d53) 2022-12-02 14:44:05 -08:00
CasualPokePlayer 45fbdb4844
Move to NLua/KeraLua/Lua5.4 (#3361) 2022-12-01 00:51:02 -08:00
YoshiRulz 79d43dab1d
Extract constants used for `NamedLuaFunction.Event` 2022-09-29 08:54:23 +10:00
YoshiRulz 9815b377d1
Also protect against mutation of `IEnumerable` for `onconsoleclose`
see 7a26546cf, fixes dc66b4357
2022-09-29 08:54:16 +10:00
YoshiRulz 7a26546cfc
Maybe fix mutation of IEnumerable (`InvalidOperationException`)
fixes 3024bc0d0
2022-09-29 05:21:08 +10:00
YoshiRulz 3f2a07e582
Fix remaining MA0098 code style warnings
"Use indexer instead of LINQ methods"
fixes 17df5673d, forgot I was in the middle of this when I pushed
2022-07-22 04:51:56 +10:00
YoshiRulz 94e85f1079
Set `Form.Owner` to MainForm for Lua-made forms 2022-07-15 22:26:08 +10:00
YoshiRulz 09061843f4 Fix Lua string encoding bug (resolves #190) 2022-05-24 04:45:38 +10:00
James Groom 7c6f78b461
Add `save_image_to_disk` to Lua canvases (#2973)
* Pass PathEntryCollection through to Lua libs

* Pass EmulationLuaLibrary to LuaCanvas, add save function to LuaCanvas

resolves #2744
2021-10-20 08:57:39 -05:00
Hyago Oliveira dc66b4357f
Add event.onconsoleclose (squashed PR #2884) 2021-07-30 08:44:24 +10:00
YoshiRulz 46a55d6db4
Use nameof in some Type.GetMethod calls 2021-07-02 16:27:31 +10:00
YoshiRulz b8f5050d6c Replace specialised DisplayManager interfaces with DisplayManagerBase 2021-06-15 08:01:47 +10:00
YoshiRulz 0a9d496ece
Accept all 4 colour formats in all Lua functions, update docs/wikitext
resolves #2602
2021-05-03 19:06:15 +10:00
YoshiRulz 3da01dbfce
Init LuaFileList/LuaFunctionList outside platform impl. and pass in
now init'ing the lists at construction instead of mutating them afterwards
2021-03-25 16:02:22 +10:00
YoshiRulz f7cacfab99
Inline methods from LuaFunctionListExtensions and cleanup 2021-03-25 15:20:47 +10:00
YoshiRulz ef0b380192
Autolock hack is nothing without autounlock hack 2021-02-24 11:12:27 +10:00
YoshiRulz a8b1e06e44
Make autolocking of ApiHawk surface less aggressive when used via Lua 2021-02-22 04:26:05 +10:00
YoshiRulz 643d7b12dd
Lock/unlock Lua drawing surface for event callbacks (fixes #2595) 2021-02-05 10:52:13 +10:00
YoshiRulz 5c89d0cb15
Cache ApiContainer instead of GuiApi in Win32LuaLibraries 2021-01-19 01:09:52 +10:00
James Groom 7749d02382
Refactor DisplaySurface locking as used by ApiHawk (and Lua) (#2575)
* Refactor how the "emu" drawing surface is automatically opened/closed

fixes #2571 again
`gui.DrawNew("native")` now throws (I will replace this with something better).
`gui.DrawNew("emu")` and `gui.DrawFinish()` do nothing but print warning
messages, for backwards compatibility. This removes the feature which allowed
scripts to draw as soon as they became enabled. It also removes the feature to
draw without clearing the surface, though that wasn't working.

* Reimplement drawing to "client" surface (see desc.)

Changed surface names in APIs to "emucore" and "client" (not in DisplayManager
yet because I can't be bothered).
Via ApiHawk, `IGuiApi.WithEmuSurface(Action)` has been replaced with
`IGuiApi.WithSurface(DrawingSurfaceID, Action)`, the first param being an enum.
Via Lua (or ApiHawk), pass an extra string param (`DrawingSurfaceID` enum for
ApiHawk) to each `gui.draw*` call.
To make it less verbose, omitting the param is treated as using the default
"emucore" surface, *unless* the helper `gui.use_surface("client")` had been
called, which persists the chosen surface until Lua restarts or it's
overwritten. (The same is done when using `WithSurface` in ApiHawk, though it's
cleared once `WithSurface` returns.)
Along with the new surface names, the old names are still valid in the `surface`
params and `gui.use_surface` for now.

* Propogate enum to DisplayManager, s/Lua/ApiHawk/ in DisplayManager
2021-01-17 11:16:48 -06:00
adelikat de0d0d19e2 Revert "Remove GuiLibrary from Win32LuaLibraries (fixes #2571)"
This reverts commit 9cca7c4a31.
2021-01-16 13:15:27 -06:00
YoshiRulz 9cca7c4a31
Remove GuiLibrary from Win32LuaLibraries (fixes #2571)
Wrapping draw calls in DrawNew/DrawFinish is the responsibility of the script
author. This removes the feature which allowed scripts to draw as soon as they
became enabled. see also #2501 (still broken)
2021-01-17 04:25:45 +10:00
YoshiRulz 7edf3b36ad
Extract a tiny interface from DisplayManager for ApiHawk 2020-12-29 15:52:57 +10:00
YoshiRulz cf901753ba
Update Lua libs' ApiContainer when updating services
I don't think this mattered unless the tool restart was triggered by reloading
the rom with client.reboot_core(), which in my defence has always been jank
2020-12-06 05:41:58 +10:00
YoshiRulz febd4f1340
Remove unused prop EventsLibrary 2020-12-06 05:34:46 +10:00
YoshiRulz ce7aa1ff64
Convert abstract class LuaLibraries to an interface 2020-12-05 07:51:14 +10:00
YoshiRulz e42a021215
Move props from LuaLibraries to Win32LuaLibraries 2020-12-05 07:51:11 +10:00
YoshiRulz e4a0175351
Extract interface from NamedLuaFunction 2020-12-05 07:50:59 +10:00
YoshiRulz 8f10ce66a6
Merge EventsLuaLibrary.RegisteredFunctions into Win32LuaLibraries 2020-12-05 07:50:56 +10:00
YoshiRulz 6aefa75cff
Add helpers for manipulating NamedLuaFunctions 2020-12-05 07:50:53 +10:00
YoshiRulz 3024bc0d0f
Inline some methods from EventsLuaLibrary into Win32LuaLibraries 2020-12-05 07:50:50 +10:00
YoshiRulz f57897515e
Add prop EngineName to abstract class LuaLibraries 2020-12-05 07:50:43 +10:00
YoshiRulz 89a66563f1
Cleanup FormsLuaLibrary.WindowClosed and usages 2020-12-05 07:50:40 +10:00
YoshiRulz b541fe5b40
Use NLuaTableHelper for more conversion to/from LuaTable
also fix indexing that I broke in c8e10120d
2020-12-05 07:50:28 +10:00
YoshiRulz c8e10120db
Encapsulate conversion to/from LuaTable, stop passing NLua to Lua libs 2020-12-03 22:54:47 +10:00
YoshiRulz e69cab3297
Cleanup Win32LuaLibraries init 2020-12-03 22:15:07 +10:00
YoshiRulz 76f03a9508
Merge DelegatingLuaLibrary into LuaLibraryBase 2020-12-03 21:37:17 +10:00
YoshiRulz 928ea057d8
Enable SA1137 and fix noncompliance (except in Cores)
"Elements should have the same indentation"
2020-11-30 21:36:48 +10:00
YoshiRulz c991babdce
Use MainForm instead of GlobalWin in Lua internals 2020-11-30 19:03:50 +10:00
YoshiRulz 3de87af5de
Pass MovieSession to APIs via ctor 2020-11-28 22:48:02 +10:00
YoshiRulz 707dae93a7
Use MainForm's prop to get the global ToolManager in Win32LuaLibraries 2020-11-26 22:55:08 +10:00
YoshiRulz 2c086702c9
Pass global ToolManager to IToolApi impl via ctor 2020-11-26 22:53:27 +10:00
YoshiRulz 794c4b5b84
Pass global ToolManager to Console and TAStudio Lua libs on init 2020-11-26 22:41:46 +10:00
YoshiRulz 256f4d5b06
Make ConsoleLuaLib funcs not static, save callback on init of lib 2020-11-26 22:37:30 +10:00
YoshiRulz 9e0a3c0e34
Pass Lua Console log callback to LuaCanvas and replace static calls 2020-11-26 22:35:52 +10:00
YoshiRulz 663e9cfbec
Add wrapper for Lua Console log callback and cleanup 2020-11-26 22:24:39 +10:00
YoshiRulz 9fc853d404
Pass more things through to ApiManager 2020-11-26 14:03:07 +10:00