diff --git a/plugins/obs-text/data/locale/en-US.ini b/plugins/obs-text/data/locale/en-US.ini index d048ce794..260243b0e 100644 --- a/plugins/obs-text/data/locale/en-US.ini +++ b/plugins/obs-text/data/locale/en-US.ini @@ -31,3 +31,7 @@ UseCustomExtents="Use Custom Text Extents" UseCustomExtents.Wrap="Wrap" Width="Width" Height="Height" +Transform="Text Transform" +Transform.None="None" +Transform.Uppercase="Uppercase" +Transform.Lowercase="Lowercase" diff --git a/plugins/obs-text/gdiplus/obs-text.cpp b/plugins/obs-text/gdiplus/obs-text.cpp index d8c62ac72..f07da7533 100644 --- a/plugins/obs-text/gdiplus/obs-text.cpp +++ b/plugins/obs-text/gdiplus/obs-text.cpp @@ -62,6 +62,7 @@ using namespace Gdiplus; #define S_EXTENTS_WRAP "extents_wrap" #define S_EXTENTS_CX "extents_cx" #define S_EXTENTS_CY "extents_cy" +#define S_TRANSFORM "transform" #define S_ALIGN_LEFT "left" #define S_ALIGN_CENTER "center" @@ -71,6 +72,10 @@ using namespace Gdiplus; #define S_VALIGN_CENTER S_ALIGN_CENTER #define S_VALIGN_BOTTOM "bottom" +#define S_TRANSFORM_NONE 0 +#define S_TRANSFORM_UPPERCASE 1 +#define S_TRANSFORM_LOWERCASE 2 + #define T_(v) obs_module_text(v) #define T_FONT T_("Font") #define T_USE_FILE T_("ReadFromFile") @@ -97,6 +102,7 @@ using namespace Gdiplus; #define T_EXTENTS_WRAP T_("UseCustomExtents.Wrap") #define T_EXTENTS_CX T_("Width") #define T_EXTENTS_CY T_("Height") +#define T_TRANSFORM T_("Transform") #define T_FILTER_TEXT_FILES T_("Filter.TextFiles") #define T_FILTER_ALL_FILES T_("Filter.AllFiles") @@ -109,6 +115,10 @@ using namespace Gdiplus; #define T_VALIGN_CENTER T_ALIGN_CENTER #define T_VALIGN_BOTTOM T_("VerticalAlignment.Bottom") +#define T_TRANSFORM_NONE T_("Transform.None") +#define T_TRANSFORM_UPPERCASE T_("Transform.Uppercase") +#define T_TRANSFORM_LOWERCASE T_("Transform.Lowercase") + /* ------------------------------------------------------------------------- */ static inline DWORD get_alpha_val(uint32_t opacity) @@ -229,6 +239,8 @@ struct TextSource { uint32_t extents_cx = 0; uint32_t extents_cy = 0; + int text_transform = S_TRANSFORM_NONE; + bool chatlog_mode = false; int chatlog_lines = 6; @@ -659,6 +671,7 @@ inline void TextSource::Update(obs_data_t *s) bool new_extents_wrap = obs_data_get_bool(s, S_EXTENTS_WRAP); uint32_t n_extents_cx = obs_data_get_uint32(s, S_EXTENTS_CX); uint32_t n_extents_cy = obs_data_get_uint32(s, S_EXTENTS_CY); + int new_text_transform = (int)obs_data_get_int(s, S_TRANSFORM); const char *font_face = obs_data_get_string(font_obj, "face"); int font_size = (int)obs_data_get_int(font_obj, "size"); @@ -712,6 +725,7 @@ inline void TextSource::Update(obs_data_t *s) wrap = new_extents_wrap; extents_cx = n_extents_cx; extents_cy = n_extents_cy; + text_transform = new_text_transform; if (!gradient) { color2 = color; @@ -737,6 +751,10 @@ inline void TextSource::Update(obs_data_t *s) if (!text.empty()) text.push_back('\n'); } + if(text_transform == S_TRANSFORM_UPPERCASE) + transform(text.begin(), text.end(), text.begin(), towupper); + else if(text_transform == S_TRANSFORM_LOWERCASE) + transform(text.begin(), text.end(), text.begin(), towlower); use_outline = new_outline; outline_color = new_o_color; @@ -911,6 +929,13 @@ static obs_properties_t *get_properties(void *data) obs_properties_add_path(props, S_FILE, T_FILE, OBS_PATH_FILE, filter.c_str(), path.c_str()); + p = obs_properties_add_list(props, S_TRANSFORM, T_TRANSFORM, + OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT); + obs_property_list_add_int(p, T_TRANSFORM_NONE, S_TRANSFORM_NONE); + obs_property_list_add_int(p, T_TRANSFORM_UPPERCASE, S_TRANSFORM_UPPERCASE); + obs_property_list_add_int(p, T_TRANSFORM_LOWERCASE, S_TRANSFORM_LOWERCASE); + + obs_properties_add_bool(props, S_VERTICAL, T_VERTICAL); obs_properties_add_color(props, S_COLOR, T_COLOR); obs_properties_add_int_slider(props, S_OPACITY, T_OPACITY, 0, 100, 1); @@ -1015,6 +1040,7 @@ bool obs_module_load(void) 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); };