Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion desmume/src/frontend/posix/gtk/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
#include "gdbstub.h"
#endif

#ifdef HAVE_LUA
#include "tools/luaScriptConsole.h"
#include "lua-engine.h"
#endif

#if defined(ENABLE_OPENGL_STANDARD) || defined(ENABLE_OPENGL_ES)
#if defined(ENABLE_OPENGL_ES)
#include "OGLRender_ES3.h"
Expand Down Expand Up @@ -235,6 +240,11 @@ static void JITMaxBlockSizeChanged(GtkAdjustment* adj,void *);
#endif
static void GraphicsSettingsDialog(GSimpleAction *action, GVariant *parameter, gpointer user_data);

#ifdef HAVE_LUA
static void AddLuaScript(GSimpleAction *action, GVariant *parameter, gpointer user_data);
static void CloseAllLuaScripts(GSimpleAction *action, GVariant *parameter, gpointer user_data);
#endif

static const GActionEntry app_entries[] = {
// File
{ "open", OpenNdsDialog },
Expand Down Expand Up @@ -307,7 +317,11 @@ static const GActionEntry app_entries[] = {
{ "editjoyctrls", Edit_Joystick_Controls },

// Tools
// Populated in desmume_gtk_menu_tools().
// dTool entries are populated dynamically in desmume_gtk_menu_tools().
#ifdef HAVE_LUA
{ "addluascript", AddLuaScript },
{ "closealluascripts", CloseAllLuaScripts },
#endif

// Help
{ "about", About },
Expand Down Expand Up @@ -579,6 +593,17 @@ struct nds_screen_t nds_screen;

static guint regMainLoop = 0;

#ifdef HAVE_LUA
static void AddLuaScript(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
lua_script_open_console(GTK_WINDOW(pWindow));
}
static void CloseAllLuaScripts(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
lua_script_close_all();
}
#endif

static inline void UpdateStatusBar (const char *message)
{
gint pStatusBar_Ctx;
Expand Down Expand Up @@ -2946,8 +2971,19 @@ gboolean EmuLoop(gpointer data)
touchpad.click = 0;
}

#ifdef HAVE_LUA
NDS_beginProcessingInput();
CallRegisteredLuaFunctions(LUACALL_BEFOREEMULATION);
NDS_endProcessingInput();
#endif

desmume_cycle(); /* Emule ! */

#ifdef HAVE_LUA
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATION);
CallRegisteredLuaFunctions(LUACALL_AFTEREMULATIONGUI);
#endif

_updateDTools();

if (!config.fpslimiter || keys_latch & KEYMASK_(KEY_BOOST - 1)) {
Expand Down
13 changes: 13 additions & 0 deletions desmume/src/frontend/posix/gtk/menu.ui
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,19 @@
<attribute name='label' translatable='yes'>_IO regs view</attribute>
<attribute name='action'>app.ioregs</attribute>
</item>
<submenu>
<attribute name='label' translatable='yes'>_Lua Scripting</attribute>
<section>
<item>
<attribute name='label' translatable='yes'>_New Lua Script Window...</attribute>
<attribute name='action'>app.addluascript</attribute>
</item>
<item>
<attribute name='label' translatable='yes'>_Close All Script Windows</attribute>
<attribute name='action'>app.closealluascripts</attribute>
</item>
</section>
</submenu>
<submenu>
<attribute name='label' translatable='yes'>View _Layers</attribute>
<section>
Expand Down
5 changes: 5 additions & 0 deletions desmume/src/frontend/posix/gtk/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ desmume_src = [
gresource,
]

if dep_lua.found()
desmume_src += ['tools/luaScriptConsole.cpp']
endif

if get_option('glx') and dep_gl.found()
desmume_src += [
'../shared/glx_3Demu.cpp',
Expand Down Expand Up @@ -52,6 +56,7 @@ executable('desmume',
include_directories: includes,
link_with: libdesmume,
cpp_args: ['-DGTK_DISABLE_DEPRECATED'],
link_args: ['-Wl,--dynamic-list,' + meson.current_source_dir() / '../lua-exports.txt'],
install: true,
)

Expand Down
Loading