diff --git a/include/core/moviefile.hpp b/include/core/moviefile.hpp index e6beb0b3..d9ac02f8 100644 --- a/include/core/moviefile.hpp +++ b/include/core/moviefile.hpp @@ -315,6 +315,10 @@ struct moviefile * Clear the dynamic state to power-on defaults. */ void clear_dynstate(); +/** + * Get the filename of the movie. + */ + std::string get_filename() { return filename; } private: moviefile(const moviefile&); moviefile& operator=(const moviefile&); @@ -323,6 +327,7 @@ private: void save(zip::writer& w, rrdata_set& rrd, bool as_state) throw(std::bad_alloc, std::runtime_error); void load(zip::reader& r, core_type& romtype) throw(std::bad_alloc, std::runtime_error); memtracker::autorelease tracker; + std::string filename; }; void emerg_save_movie(const moviefile& mv, rrdata_set& rrd); diff --git a/lua.lyx b/lua.lyx index 909bac48..abbb91d8 100644 --- a/lua.lyx +++ b/lua.lyx @@ -1,5 +1,5 @@ -#LyX 2.2 created this file. For more info see http://www.lyx.org/ -\lyxformat 508 +#LyX 2.3 created this file. For more info see http://www.lyx.org/ +\lyxformat 544 \begin_document \begin_header \save_transient_properties true @@ -21,6 +21,8 @@ \font_osf false \font_sf_scale 100 100 \font_tt_scale 100 100 +\use_microtype false +\use_dash_ligatures true \graphics default \default_output_format default \output_sync 0 @@ -59,6 +61,7 @@ \suppress_date false \justification true \use_refstyle 1 +\use_minted 0 \index Hakusana \shortcut idx \color #008000 @@ -74,7 +77,10 @@ \tocdepth 3 \paragraph_separation indent \paragraph_indentation default -\quotes_language english +\is_math_indent 0 +\math_numbering_side default +\quotes_style english +\dynamic_quotes 0 \papercolumns 1 \papersides 1 \paperpagestyle default @@ -7328,6 +7334,21 @@ fps_n: Exact nominal fps numerator fps_d: Exact nominal fps denominator. \end_layout +\begin_layout Subsection +movie.get_last_movie: Get name of last movie loaded +\end_layout + +\begin_layout Itemize +Syntax: String/Nil movie.get_last_movie() +\end_layout + +\begin_layout Standard +Returns the name of last movie loaded as a string, or nil if the last movie + loaded was unnamed. + If you are using this for naming something, movie.get_rom_info() might be + useful in case this returns nil or something useless starting with '$'. +\end_layout + \begin_layout Subsection INPUTFRAME::get_button: Get button \end_layout diff --git a/lua.pdf b/lua.pdf index d86495be..d18e6565 100644 Binary files a/lua.pdf and b/lua.pdf differ diff --git a/src/core/moviefile.cpp b/src/core/moviefile.cpp index ce0173bc..f27f217e 100644 --- a/src/core/moviefile.cpp +++ b/src/core/moviefile.cpp @@ -115,6 +115,7 @@ moviefile::moviefile() throw(std::bad_alloc) movie_rtc_subsecond = dyn.rtc_subsecond = DEFAULT_RTC_SUBSECOND; start_paused = false; lazy_project_create = true; + this->filename = ""; } moviefile::moviefile(loaded_rom& rom, std::map& c_settings, uint64_t rtc_sec, @@ -130,6 +131,7 @@ moviefile::moviefile(loaded_rom& rom, std::map& c_sett movie_rtc_subsecond = dyn.rtc_subsecond = rtc_subsec; start_paused = false; lazy_project_create = true; + this->filename = ""; settings = c_settings; input = NULL; auto ctrldata = rom.controllerconfig(settings); @@ -159,6 +161,7 @@ moviefile::moviefile(const std::string& movie, core_type& romtype) throw(std::ba copy_fields(s); return; } + this->filename = movie; input = NULL; start_paused = false; force_corrupt = false; diff --git a/src/lua/movie.cpp b/src/lua/movie.cpp index 5a542e6f..c0963fdc 100644 --- a/src/lua/movie.cpp +++ b/src/lua/movie.cpp @@ -228,6 +228,16 @@ namespace return 1; } + int get_last_movie(lua::state& L, lua::parameters& P) + { + auto m = CORE().mlogic->get_mfile().get_filename(); + if(m != "") + L.pushlstring(m); + else + L.pushnil(); + return 1; + } + lua::functions LUA_movie_fns(lua_func_misc, "movie", { {"currentframe", currentframe}, {"lagcount", lagcounter}, @@ -243,5 +253,6 @@ namespace {"rom_loaded", rom_loaded}, {"get_rom_info", get_rom_info}, {"get_game_info", get_game_info}, + {"get_last_movie", get_last_movie}, }); }