X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.cpp;h=78b0fde35cd2b075e2482f921776da71ade955f9;hb=5e9f3fe04e04a7c53a8e64106797e14e44fe9024;hp=c6cf4515805ad83be506f783d26df92b30ebc103;hpb=a60a2c892c08f6fab3a1e6b7cf4343cad8689058;p=nageru diff --git a/nageru/theme.cpp b/nageru/theme.cpp index c6cf451..78b0fde 100644 --- a/nageru/theme.cpp +++ b/nageru/theme.cpp @@ -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 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; +}