added lua script loading to gtk2 gui

This commit is contained in:
punkrockguy318 2009-12-21 20:03:24 +00:00
parent af14209f43
commit 491311db44
3 changed files with 31 additions and 5 deletions

View File

@ -10,9 +10,9 @@
#include "sdl.h"
#include "gui.h"
//#define WIDTH 600
//#define HEIGHT 600
#ifdef _S9XLUA_H
#include "../../fceulua.h"
#endif
extern Config *g_config;
@ -71,8 +71,26 @@ void showAbout ()
}
#ifdef _S9XLUA_H
void loadLua ()
{
GtkWidget* fileChooser;
fileChooser = gtk_file_chooser_dialog_new ("Open LUA Script", GTK_WINDOW(MainWindow),
GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
if (gtk_dialog_run (GTK_DIALOG (fileChooser)) ==GTK_RESPONSE_ACCEPT)
{
char* filename;
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (fileChooser));
FCEU_LoadLuaCode(filename);
g_free(filename);
}
gtk_widget_destroy (fileChooser);
}
#endif
void loadGame ()
{
@ -114,6 +132,9 @@ static GtkItemFactoryEntry menu_items[] = {
{ "/File/_Close ROM", "<control>C", closeGame, 0, "<StockItem>", GTK_STOCK_CLOSE },
// { "/File/Save _As", NULL, NULL, 0, "<Item>" },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
#ifdef _S9XLUA_H
{ "/File/Load _Lua Script", NULL, loadLua, 0, "<Item>"},
#endif
{ "/File/_Quit", "<CTRL>Q", quit, 0, "<StockItem>", GTK_STOCK_QUIT },
{ "/_Options", NULL, NULL, 0, "<Branch>" },
{ "/Options/tear", NULL, NULL, 0, "<Tearoff>" },

View File

@ -151,7 +151,9 @@ static int g_fkbEnabled = 0;
// key definitions
int cheatMenuKey;
#ifdef _S9XLUA_H
int loadLuaKey;
#endif
int renderBgKey;
int saveStateKey;
int loadStateKey;

View File

@ -1,4 +1,6 @@
#ifdef _S9XLUA_H
#ifndef _FCEULUA_H
#define _FCEULUA_H
enum LuaCallID
{
@ -84,3 +86,4 @@ char *FCEU_GetFreezeFilename(int slot);
#endif
#endif