]> git.sesse.net Git - nageru/blobdiff - nageru/theme.cpp
Support disabling optional effects if a given other effect is _enabled_.
[nageru] / nageru / theme.cpp
index c6cf4515805ad83be506f783d26df92b30ebc103..78b0fde35cd2b075e2482f921776da71ade955f9 100644 (file)
@@ -873,6 +873,7 @@ const luaL_Reg Block_funcs[] = {
        { "enable_if", Block_enable_if },
        { "disable", Block_disable },
        { "always_disable_if_disabled", Block_always_disable_if_disabled },
+       { "promise_to_disable_if_enabled", Block_promise_to_disable_if_enabled },
        { "set_int", Block_set_int },
        { "set_float", Block_set_float },
        { "set_vec3", Block_set_vec3 },
@@ -1878,3 +1879,24 @@ void Theme::theme_menu_entry_clicked(int lua_ref)
                abort();
        }
 }
+
+string Theme::format_status_line(const string &disk_space_left_text, double file_length_seconds)
+{
+       lock_guard<mutex> lock(m);
+       lua_getglobal(L, "format_status_line");
+       if (lua_isnil(L, -1)) {
+               lua_pop(L, 1);
+               return disk_space_left_text;
+       }
+
+       lua_pushstring(L, disk_space_left_text.c_str());
+       lua_pushnumber(L, file_length_seconds);
+       if (lua_pcall(L, 2, 1, 0) != 0) {
+               fprintf(stderr, "error running function format_status_line(): %s\n", lua_tostring(L, -1));
+               abort();
+       }
+       string text = checkstdstring(L, 1);
+       lua_pop(L, 1);
+       assert(lua_gettop(L) == 0);
+       return text;
+}