]> git.sesse.net Git - nageru/blobdiff - nageru/theme.cpp
Add a theme function Nageru.schedule_cut().
[nageru] / nageru / theme.cpp
index 937043f7ca72e96ad60bf7a4611857091bf13730..cf323b0bb041a2c86b0119567085dbce512fd9ba 100644 (file)
@@ -1448,6 +1448,15 @@ int Nageru_set_audio_bus_mute(lua_State *L)
        return 0;
 }
 
+int Nageru_schedule_cut(lua_State *L)
+{
+       if (global_mixer == nullptr) {
+               luaL_error(L, "Cuts can not be scheduled before the theme is done initializing.");
+       }
+       global_mixer->schedule_cut();
+       return 0;
+}
+
 int Nageru_get_audio_bus_eq_level_db(lua_State *L)
 {
        if (global_audio_mixer == nullptr) {
@@ -1660,6 +1669,9 @@ void Theme::register_globals()
                { "get_audio_bus_mute", Nageru_get_audio_bus_mute },
                { "set_audio_bus_mute", Nageru_set_audio_bus_mute },
 
+               // Misc.
+               { "schedule_cut", Nageru_schedule_cut },
+
                { nullptr, nullptr }
        };
        lua_pushlightuserdata(L, this);
@@ -2074,8 +2086,8 @@ unique_ptr<Theme::MenuEntry> create_theme_menu_entry(lua_State *L, int index)
        lua_pop(L, 1);
 
        unsigned flags = 0;
-       if (lua_objlen(L, -1) > 2) {
-               lua_rawgeti(L, -1, 3);
+       if (lua_objlen(L, index) > 2) {
+               lua_rawgeti(L, index, 3);
                flags = luaL_checknumber(L, -1);
                lua_pop(L, 1);
        }