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 "sdl.h"
#include "gui.h" #include "gui.h"
//#define WIDTH 600 #ifdef _S9XLUA_H
//#define HEIGHT 600 #include "../../fceulua.h"
#endif
extern Config *g_config; 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 () void loadGame ()
{ {
@ -114,6 +132,9 @@ static GtkItemFactoryEntry menu_items[] = {
{ "/File/_Close ROM", "<control>C", closeGame, 0, "<StockItem>", GTK_STOCK_CLOSE }, { "/File/_Close ROM", "<control>C", closeGame, 0, "<StockItem>", GTK_STOCK_CLOSE },
// { "/File/Save _As", NULL, NULL, 0, "<Item>" }, // { "/File/Save _As", NULL, NULL, 0, "<Item>" },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" }, { "/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 }, { "/File/_Quit", "<CTRL>Q", quit, 0, "<StockItem>", GTK_STOCK_QUIT },
{ "/_Options", NULL, NULL, 0, "<Branch>" }, { "/_Options", NULL, NULL, 0, "<Branch>" },
{ "/Options/tear", NULL, NULL, 0, "<Tearoff>" }, { "/Options/tear", NULL, NULL, 0, "<Tearoff>" },

View File

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

View File

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