From 6a282360f02d3930cba9d756d5018d0afa9bca56 Mon Sep 17 00:00:00 2001 From: Clayton Groeneveld Date: Wed, 15 Jan 2020 02:18:33 -0800 Subject: [PATCH] obs-text: Change default size of text to 256 --- plugins/obs-text/gdiplus/obs-text.cpp | 67 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/plugins/obs-text/gdiplus/obs-text.cpp b/plugins/obs-text/gdiplus/obs-text.cpp index 0a34e988b..6c09d2ab1 100644 --- a/plugins/obs-text/gdiplus/obs-text.cpp +++ b/plugins/obs-text/gdiplus/obs-text.cpp @@ -1035,12 +1035,41 @@ static obs_properties_t *get_properties(void *data) return props; } +static void defaults(obs_data_t *settings, int ver) +{ + obs_data_t *font_obj = obs_data_create(); + obs_data_set_default_string(font_obj, "face", "Arial"); + obs_data_set_default_int(font_obj, "size", ver == 1 ? 36 : 256); + + obs_data_set_default_obj(settings, S_FONT, font_obj); + obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); + obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); + obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_OPACITY, 100); + obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); + obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); + obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); + obs_data_set_default_int(settings, S_BKOPACITY, 0); + obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); + obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); + obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); + obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); + obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true); + obs_data_set_default_int(settings, S_EXTENTS_CX, 100); + obs_data_set_default_int(settings, S_EXTENTS_CY, 100); + obs_data_set_default_int(settings, S_TRANSFORM, S_TRANSFORM_NONE); + + obs_data_release(font_obj); +}; + bool obs_module_load(void) { obs_source_info si = {}; si.id = "text_gdiplus"; si.type = OBS_SOURCE_TYPE_INPUT; - si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW; + si.output_flags = OBS_SOURCE_VIDEO | OBS_SOURCE_CUSTOM_DRAW | + OBS_SOURCE_CAP_OBSOLETE; si.get_properties = get_properties; si.icon_type = OBS_ICON_TYPE_TEXT; @@ -1057,33 +1086,7 @@ bool obs_module_load(void) si.get_height = [](void *data) { return reinterpret_cast(data)->cy; }; - si.get_defaults = [](obs_data_t *settings) { - obs_data_t *font_obj = obs_data_create(); - obs_data_set_default_string(font_obj, "face", "Arial"); - obs_data_set_default_int(font_obj, "size", 36); - - obs_data_set_default_obj(settings, S_FONT, font_obj); - obs_data_set_default_string(settings, S_ALIGN, S_ALIGN_LEFT); - obs_data_set_default_string(settings, S_VALIGN, S_VALIGN_TOP); - obs_data_set_default_int(settings, S_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_OPACITY, 100); - obs_data_set_default_int(settings, S_GRADIENT_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_GRADIENT_OPACITY, 100); - obs_data_set_default_double(settings, S_GRADIENT_DIR, 90.0); - obs_data_set_default_int(settings, S_BKCOLOR, 0x000000); - obs_data_set_default_int(settings, S_BKOPACITY, 0); - obs_data_set_default_int(settings, S_OUTLINE_SIZE, 2); - obs_data_set_default_int(settings, S_OUTLINE_COLOR, 0xFFFFFF); - obs_data_set_default_int(settings, S_OUTLINE_OPACITY, 100); - obs_data_set_default_int(settings, S_CHATLOG_LINES, 6); - obs_data_set_default_bool(settings, S_EXTENTS_WRAP, true); - obs_data_set_default_int(settings, S_EXTENTS_CX, 100); - obs_data_set_default_int(settings, S_EXTENTS_CY, 100); - obs_data_set_default_int(settings, S_TRANSFORM, - S_TRANSFORM_NONE); - - obs_data_release(font_obj); - }; + si.get_defaults = [](obs_data_t *settings) { defaults(settings, 1); }; si.update = [](void *data, obs_data_t *settings) { reinterpret_cast(data)->Update(settings); }; @@ -1094,7 +1097,15 @@ bool obs_module_load(void) reinterpret_cast(data)->Render(); }; + obs_source_info si_v2 = si; + si_v2.id = "text_gdiplus_v2"; + si_v2.output_flags &= ~OBS_SOURCE_CAP_OBSOLETE; + si_v2.get_defaults = [](obs_data_t *settings) { + defaults(settings, 2); + }; + obs_register_source(&si); + obs_register_source(&si_v2); const GdiplusStartupInput gdip_input; GdiplusStartup(&gdip_token, &gdip_input, nullptr);