X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Ftheme.cpp;h=78b0fde35cd2b075e2482f921776da71ade955f9;hb=1924bea4fde26067d8ee81cfd12f2dd66c5b2cad;hp=ce3d2d6d55c917f6fdc0afba77c1cec348428ca2;hpb=2e1b69c339862fb9b8147bf0ac07d87ca4810d4e;p=nageru diff --git a/nageru/theme.cpp b/nageru/theme.cpp index ce3d2d6..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 }, @@ -1295,6 +1296,10 @@ int Nageru_set_supports_wb(lua_State *L) Theme::Theme(const string &filename, const vector &search_dirs, ResourcePool *resource_pool, unsigned num_cards) : resource_pool(resource_pool), num_cards(num_cards), signal_to_card_mapping(global_flags.default_stream_mapping) { + // Defaults. + channel_names[0] = "Live"; + channel_names[1] = "Preview"; + L = luaL_newstate(); luaL_openlibs(L); @@ -1569,6 +1574,12 @@ string Theme::get_channel_name(unsigned channel) { lock_guard lock(m); + // We never ask the legacy channel_name() about live and preview. + // The defaults are set in our constructor. + if (channel == 0 || channel == 1) { + return channel_names[channel]; + } + lua_getglobal(L, "channel_name"); if (lua_isnil(L, -1)) { lua_pop(L, 1); @@ -1868,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; +}