From 5c4579f8595e43f357ec2b9fa96d2c112b467582 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 15 Mar 2009 23:46:57 +0000 Subject: [PATCH] Lua - added movie.getname() --- changelog.txt | 2 +- src/lua-engine.cpp | 17 +++++++++++++++++ src/movie.cpp | 5 ++++- src/movie.h | 1 + 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 24c79792..f2cb4859 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,5 @@ ---version 2.0.4 yet to be released--- -15-mar-2009 - adelikat - Lua - added movie.rerecordcount(), movie.length(), FCEU.getreadonly(), FCEU.setreadonly() +15-mar-2009 - adelikat - Lua - added movie.rerecordcount(), movie.length(), movie.getname, FCEU.getreadonly(), FCEU.setreadonly() 14-mar-2009 - adelikat - Lua - added movie.active() - returns a bool value based on whether a movie is currently loaded 14-mar-2009 - adelikat - Fixed Joypad.set, it uses 3 values instead of 2 now. True will take control of a button and make it on, False will take control and make it off, and Nil will not take control (allowing the user to press the button) 14-mar-2009 - adelikat - Fix major crash issue where NROM game savestates were writing erroneous information if a non NROM game was loaded prior diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index a4906c7a..65ddd85e 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -981,6 +981,9 @@ static int fceu_getreadonly (lua_State *L) { return 1; } +//FCEU.setreadonly +// +//Sets readonly / read+write status static int fceu_setreadonly (lua_State *L) { bool which = (lua_toboolean( L, 1 ) == 1); FCEUI_SetMovieToggleReadOnly(which); @@ -988,6 +991,19 @@ static int fceu_setreadonly (lua_State *L) { return 0; } +//movie.getname +// +//returns the filename of the movie loaded +static int movie_getname (lua_State *L) { + + if (!FCEUMOV_IsRecording() && !FCEUMOV_IsPlaying()) + luaL_error(L, "No movie loaded."); + + std::string name = FCEUI_GetMovieName(); + lua_pushstring(L, name.c_str()); + return 1; +} + // Common code by the gui library: make sure the screen array is ready static void gui_prepare() { if (!gui_data) @@ -1896,6 +1912,7 @@ static const struct luaL_reg movielib[] = { {"active", movie_active}, {"length", movie_length}, {"rerecordcount", movie_rerecordcount}, + {"getname", movie_getname}, // {"record", movie_record}, // {"playback", movie_playback}, diff --git a/src/movie.cpp b/src/movie.cpp index 632d317f..946517e3 100644 --- a/src/movie.cpp +++ b/src/movie.cpp @@ -1187,7 +1187,6 @@ void FCEUI_SetMovieToggleReadOnly(bool which) FCEU_DispMessage("Movie is Read+Write."); } } - void FCEUI_MovieToggleReadOnly() { if(movie_readonly) @@ -1209,6 +1208,10 @@ void FCEUI_MoviePlayFromBeginning(void) } } +string FCEUI_GetMovieName(void) +{ + return curMovieFilename; +} bool FCEUI_MovieGetInfo(FCEUFILE* fp, MOVIE_INFO& info, bool skipFrameCount) { diff --git a/src/movie.h b/src/movie.h index bcd278e3..4a8a826d 100644 --- a/src/movie.h +++ b/src/movie.h @@ -253,6 +253,7 @@ bool FCEUI_GetMovieToggleReadOnly(); void FCEUI_SetMovieToggleReadOnly(bool which); int FCEUI_GetMovieLength(); int FCEUI_GetMovieRerecordCount(); +std::string FCEUI_GetMovieName(void); void FCEUI_MovieToggleFrameDisplay(); void FCEUI_ToggleInputDisplay(void);