Lua: add gui.register and emu.message

Note: using emu.message in the callback function of gui.register causes infinite recursive call and the script will die.
This commit is contained in:
gocha 2012-08-05 17:06:21 +09:00
parent 2afcfc4589
commit 79c50791ae
3 changed files with 14 additions and 4 deletions

View File

@ -186,6 +186,7 @@
#include "screenshot.h"
#include "font.h"
#include "display.h"
#include "lua-engine.h"
extern struct SCheatData Cheat;
extern struct SLineData LineData[240];
@ -433,6 +434,9 @@ void S9xEndScreenRefresh (void)
if (Settings.AutoDisplayMessages)
S9xDisplayMessages(GFX.Screen, GFX.RealPPL, IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, 1);
#ifdef HAVE_LUA
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI);
#endif
S9xDeinitUpdate(IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight);
}
}

View File

@ -3,6 +3,7 @@
#include "port.h"
#include "snes9x.h"
#include "display.h"
#include "lua-engine.h"
#include <assert.h>
#include <vector>
@ -1020,14 +1021,14 @@ DEFINE_LUA_FUNCTION(print, "...")
}
/*
DEFINE_LUA_FUNCTION(emu_message, "str")
{
const char* str = toCString(L);
osd->addLine(str);
S9xSetInfoString(str);
return 0;
}
*/
// provides an easy way to copy a table from Lua
// (simple assignment only makes an alias, but sometimes an independent table is desired)
@ -3694,7 +3695,7 @@ static const struct luaL_reg emulib [] =
{"registerstart", emu_registerstart},
{"registerexit", emu_registerexit},
{"persistglobalvariables", emu_persistglobalvariables},
// {"message", emu_message},
{"message", emu_message},
{"print", print}, // sure, why not
{"openscript", emu_openscript},
// {"loadrom", emu_loadrom},

View File

@ -183,6 +183,7 @@
#include "../snes9x.h"
#include "../ppu.h"
#include "../font.h"
#include "../lua-engine.h"
#include "wsnes9x.h"
#include "win32_display.h"
#include "CDirect3D.h"
@ -221,6 +222,10 @@ void WinRefreshDisplay(void)
if(!Src.Width)
return;
#ifdef HAVE_LUA
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI);
#endif
SelectRenderMethod ();
S9xDisplayOutput->Render(Src);