def script_properties(): # ui props = obs.obs_properties_create() p = obs.obs_properties_add_list( props, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING, ) sources = obs.obs_enum_sources() if sources is not None: for source in sources: source_id = obs.obs_source_get_unversioned_id(source) if source_id == "text_gdiplus" or source_id == "text_ft2_source": name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(p, name, name) obs.source_list_release(sources) number = obs.obs_properties_add_int(props, "_int", "Number", 1, 100, 1) text_value = obs.obs_properties_add_text(props, "_text", "Additional input:", obs.OBS_TEXT_DEFAULT) obs.obs_property_set_visible(text_value, False) obs.obs_property_set_modified_callback(number, callback) return props
def script_qualifier_settings(props, rtgg_obs: RacetimeObs): lang = gettext.translation("racetime-obs", localedir=os.environ['LOCALEDIR']) _ = lang.gettext p = obs.obs_properties_add_bool( props, "use_qualifier", _("Display race results as tournament qualifier?")) obs.obs_property_set_modified_callback(p, qualifier_toggled) qualifier_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "qualifier_group", _("Qualifier Mode"), obs.OBS_GROUP_NORMAL, qualifier_group) obs.obs_property_set_visible( obs.obs_properties_get(props, "qualifier_group"), rtgg_obs.qualifier.enabled) p = obs.obs_properties_add_int_slider(qualifier_group, "qualifier_cutoff", _("Use Top X as par time, where X="), 3, 10, 1) p = obs.obs_properties_add_list(qualifier_group, "qualifier_par_source", _("Qualifier Par Time Source"), obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) fill_source_list(p) p = obs.obs_properties_add_list(qualifier_group, "qualifier_score_source", _("Qualifier Score Source"), obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) fill_source_list(p)
def _add(self, p, on_changed, clear=True): if clear: self.__property = [p] else: self.__property.append(p) if self.doc: _obs.obs_property_set_long_description(p, self.doc) _obs.obs_property_set_visible(p, self.visible) _obs.obs_property_set_enabled(p, self.enabled) if on_changed: _obs.obs_property_set_modified_callback(p, on_changed)
def callback(props, prop, settings): _number = obs.obs_data_get_int(settings, "_int") _text_value = obs.obs_data_get_string(settings, "_text") text_property = obs.obs_properties_get(props, "_text") if _number > 50: eg.data = _text_value + str(_number) obs.obs_property_set_visible(text_property, True) return True else: eg.data = "" obs.obs_property_set_visible(text_property, False) return True
def script_coop_settings(props, rtgg_obs: RacetimeObs): lang = gettext.translation("racetime-obs", localedir=os.environ['LOCALEDIR']) _ = lang.gettext p = obs.obs_properties_add_bool(props, "use_coop", _("Display coop information?")) obs.obs_property_set_modified_callback(p, coop_toggled) coop_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "coop_group", _("Co-op Mode"), obs.OBS_GROUP_NORMAL, coop_group) obs.obs_property_set_visible(obs.obs_properties_get(props, "coop_group"), rtgg_obs.coop.enabled) p = obs.obs_properties_add_list(coop_group, "coop_partner", _("Co-op Partner"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) p = obs.obs_properties_add_list(coop_group, "coop_opponent1", _("Co-op Rival 1"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) p = obs.obs_properties_add_list(coop_group, "coop_opponent2", _("Co-op Rival 2"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) fill_coop_entrant_lists(props, rtgg_obs) p = obs.obs_properties_add_list(coop_group, "coop_our_source", _("Our Team's Timer"), obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_set_long_description(p, ( _("This text source will display your team's timer when you finish."))) fill_source_list(p) p = obs.obs_properties_add_list(coop_group, "coop_opponent_source", "Rival Team's Timer", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_set_long_description( p, (_("This text source will be use to display your rival's timer when " "they finish"))) obs.obs_properties_add_color(coop_group, "coop_winner_color", _("Winner Color:")) obs.obs_properties_add_color(coop_group, "coop_loser_color", _("Loser Color:")) obs.obs_properties_add_color(coop_group, "coop_undetermined_color", _("Winner Undetermined Color")) fill_source_list(p)
def script_media_player_settings(props, rtgg_obs: RacetimeObs, media_player_toggled): lang = gettext.translation("racetime-obs", localedir=os.environ['LOCALEDIR']) _ = lang.gettext p = obs.obs_properties_add_bool(props, "use_media_player", _("Enable sounds?")) obs.obs_property_set_modified_callback(p, media_player_toggled) media_player_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "media_player_group", _("Media Player Mode"), obs.OBS_GROUP_NORMAL, media_player_group) obs.obs_property_set_visible( obs.obs_properties_get(props, "media_player_group"), rtgg_obs.media_player.enabled) monitoring_list = obs.obs_properties_add_list(media_player_group, "monitoring_type", _("Monitoring Type"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) obs.obs_property_list_add_int(monitoring_list, _("Listen Only"), obs.OBS_MONITORING_TYPE_MONITOR_ONLY) obs.obs_property_list_add_int(monitoring_list, _("Stream Only"), obs.OBS_MONITORING_TYPE_NONE) obs.obs_property_list_add_int(monitoring_list, _("Listen and Stream"), obs.OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT) p = obs.obs_properties_add_bool(media_player_group, "use_chat_pings", _("Chat Pings")) obs.obs_property_set_long_description( p, _("Enable this and set choose a sound file to play when a bot posts" " or when someone @s you in racetime.gg chat")) p = obs.obs_properties_add_path(media_player_group, "chat_ping_sound", _("Chat media file"), obs.OBS_PATH_FILE, "Audio Files (*.mp3 *.aac *.wav *.wma)", None) obs.obs_properties_add_path(media_player_group, "first_place_sound", _("First Place Sound"), obs.OBS_PATH_FILE, "Audio Files (*.mp3 *.aac *.wav *.wma)", None) obs.obs_property_set_long_description( p, _("Sound file to play when you finish first."))
def script_timer_settings(props, rtgg_obs: RacetimeObs): lang = gettext.translation("racetime-obs", localedir=os.environ['LOCALEDIR']) _ = lang.gettext p = obs.obs_properties_add_bool(props, "use_podium", _("Use custom color for podium finishes?")) obs.obs_property_set_modified_callback(p, podium_toggled) podium_group = obs.obs_properties_create() obs.obs_properties_add_group(props, "podium_group", _("Podium Colors"), obs.OBS_GROUP_NORMAL, podium_group) obs.obs_property_set_visible(obs.obs_properties_get(props, "podium_group"), rtgg_obs.timer.use_podium_colors) obs.obs_properties_add_color(podium_group, "pre_color", _("Pre-race:")) obs.obs_properties_add_color(podium_group, "racing_color", _("Still racing:")) obs.obs_properties_add_color(podium_group, "first_color", _("1st place:")) obs.obs_properties_add_color(podium_group, "second_color", _("2nd place:")) obs.obs_properties_add_color(podium_group, "third_color", _("3rd place:")) obs.obs_properties_add_color(podium_group, "finished_color", _("After podium:"))
def check_file_use(props, prop, settings): p = obs.obs_properties_get(props, "file_path") st = obs.obs_properties_get(props, "scripted_text") p2 = obs.obs_properties_get(props, "reload_file") obs.obs_property_set_visible(p, std.use_file) obs.obs_property_set_visible(p2, std.use_file) obs.obs_property_set_visible(st, not std.use_file) return True
def is_user_config(props, prop, data): if data: config = obs.obs_data_get_json(data) configjson = json.loads(config) del (config) isUserConfig = 'use_user_config' in configjson.keys( ) and configjson['use_user_config'] for a_prop in ('score_names', 'score_count', 'font', 'fgcolor', 'bgcolor'): thisprop = obs.obs_properties_get(props, a_prop) obs.obs_property_set_visible(thisprop, not isUserConfig) del (thisprop) config_path_property = obs.obs_properties_get(props, 'user_config') obs.obs_property_set_visible(config_path_property, isUserConfig) del (config_path_property) if isUserConfig: global settings settings = data return True
def media_trigger_settings(props, rtgg_obs: RacetimeObs, index: int): lang = gettext.translation("racetime-obs", localedir=os.environ['LOCALEDIR']) _ = lang.gettext media_player_group = obs.obs_properties_create() name = f"media_trigger_#{index}" obs.obs_properties_add_group(props, name, _("Media Trigger #") + f"{index}", obs.OBS_GROUP_NORMAL, media_player_group) obs.obs_property_set_visible( obs.obs_properties_get(props, "media_player_group"), rtgg_obs.media_player.enabled) obs.obs_properties_add_path(media_player_group, f"media_path_#{index}", _("Sound File"), obs.OBS_PATH_FILE, "Audio Files (*.mp3 *.aac *.wav *.wma)", None) p = obs.obs_properties_add_list(media_player_group, f"trigger_type_#{index}", _("Type of Trigger"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) obs.obs_property_list_add_string(p, "", "") obs.obs_property_list_add_string(p, _("Chat"), "chat") obs.obs_property_list_add_string(p, _("Finish Place"), "finish") obs.obs_property_list_add_string(p, _("Timer"), "time") obs.obs_property_set_modified_callback(p, media_type_changed) p = obs.obs_properties_add_list(media_player_group, f"monitoring_type_#{index}", _("Monitoring Type"), obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_INT) obs.obs_property_list_add_int(p, _("Only Listen"), obs.OBS_MONITORING_TYPE_MONITOR_ONLY) obs.obs_property_list_add_int(p, _("Only Stream"), obs.OBS_MONITORING_TYPE_NONE) obs.obs_property_list_add_int(p, _("Listen and Stream"), obs.OBS_MONITORING_TYPE_MONITOR_AND_OUTPUT)
def script_properties(): props = obs.obs_properties_create() obs.obs_properties_add_text( props, "scripted_text", "Scripted text", obs.OBS_TEXT_MULTILINE ) bool = obs.obs_properties_add_bool(props, "use_file", "Use file(UTF-8)") bool2 = obs.obs_properties_add_bool(props, "reload_file", "Auto reload file") fp = obs.obs_properties_add_path( props, "file_path", "Select file", obs.OBS_PATH_FILE, "*.*", std.path ) obs.obs_property_set_visible(fp, std.use_file) obs.obs_property_set_visible(bool2, std.use_file) obs.obs_property_set_modified_callback(bool, check_file_use) obs.obs_property_set_modified_callback(bool2, check_file_use) obs.obs_properties_add_int( props, "refresh_rate", "Refresh rate(ms)", 15, 5 * 1000, 1 ) obs.obs_properties_add_int(props, "duration", "Duration shown(s)", 1, 3600, 1) p = obs.obs_properties_add_list( props, "source", "<h2>Text Source</h2>", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING, ) sp = obs.obs_properties_add_list( props, "playsound", "Media Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING, ) tp = obs.obs_properties_add_list( props, "text_effect", "Text effect", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING, ) lp = obs.obs_properties_add_list( props, "layer", "Layer(img,video,gif,etc..)", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING, ) obs.obs_property_set_long_description( tp, "<h1>Description of current text effect</h1>" ) for i in std.txt_efcts.keys(): obs.obs_property_list_add_string(tp, i, i) obs.obs_property_set_modified_callback(tp, show_tooltip) sources = obs.obs_enum_sources() if sources is not None: for source in sources: # exclude Desktop Audio and Mic/Aux by their capabilities capability_flags = obs.obs_source_get_output_flags(source) if ( capability_flags & obs.OBS_SOURCE_DO_NOT_SELF_MONITOR ) == 0 and capability_flags != ( obs.OBS_SOURCE_AUDIO | obs.OBS_SOURCE_DO_NOT_DUPLICATE ): source_id = obs.obs_source_get_unversioned_id(source) if source_id == "text_gdiplus" or source_id == "text_ft2_source": name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(p, name, name) if source_id == "ffmpeg_source": name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(sp, name, name) else: name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(lp, name, name) obs.source_list_release(sources) scenes = obs.obs_frontend_get_scenes() # for layered scene source for scene in scenes: name = obs.obs_source_get_name(scene) obs.obs_property_list_add_string(lp, name, name) obs.source_list_release(scenes) obs.obs_properties_add_button( props, "button1", "PREVIEW", lambda *props: std.hotkey_hook() ) obs.obs_properties_add_button( props, "button2", "RESET", lambda *props: std.reset_duration() ) return props
def hide(self): if self.visible: self.visible = False for p in self.__property: _obs.obs_property_set_visible(p, False)
def coop_toggled(props, prop, settings): vis = obs.obs_data_get_bool(settings, "use_coop") obs.obs_property_set_visible(obs.obs_properties_get(props, "coop_group"), vis) return True
def animationProperties_set_vis(props, animation, variationType, movementType, showStartingProperties): global settings # variationType = animation.variationType # movementType = animation.movementType setDestinationProperty = obs.obs_properties_get( props, animation.setDestinationStorage) customStartingSettingsProperty = obs.obs_properties_get( props, animation.customStartingSettingStorage) posDirectionProperty = obs.obs_properties_get( props, animation.posDirectionStorage) commandProperty = obs.obs_properties_get(props, animation.commandStorage) stopCommandProperty = obs.obs_properties_get(props, animation.stopCommandStorage) startingXProperty = obs.obs_properties_get(props, animation.startingXStorage) startingYProperty = obs.obs_properties_get(props, animation.startingYStorage) destinationXProperty = obs.obs_properties_get( props, animation.destinationXStorage) destinationYProperty = obs.obs_properties_get( props, animation.destinationYStorage) posSpeedProperty = obs.obs_properties_get(props, animation.posSpeedStorage) movementTypeProperty = obs.obs_properties_get( props, animation.movementTypeStorage) changeSizeInPlaceProperty = obs.obs_properties_get( props, animation.changeSizeInPlaceStorage) durationProperty = obs.obs_properties_get(props, animation.durationStorage) if variationType == VARIATION_POSITION or variationType == VARIATION_BOTH: obs.obs_property_set_visible(startingXProperty, showStartingProperties) obs.obs_property_set_visible(startingYProperty, showStartingProperties) obs.obs_property_set_visible(destinationXProperty, True) obs.obs_property_set_visible(destinationYProperty, True) obs.obs_property_set_visible(posSpeedProperty, True) else: obs.obs_property_set_visible(startingXProperty, False) obs.obs_property_set_visible(startingYProperty, False) obs.obs_property_set_visible(destinationXProperty, False) obs.obs_property_set_visible(destinationYProperty, False) obs.obs_property_set_visible(posSpeedProperty, False) if variationType == VARIATION_POSITION: if movementType == MOVEMENT_DURATION: obs.obs_property_set_visible(posSpeedProperty, False) obs.obs_property_set_visible(durationProperty, True) elif movementType == MOVEMENT_SPEED: obs.obs_property_set_visible(posSpeedProperty, True) obs.obs_property_set_visible(durationProperty, False) else: obs.obs_property_set_visible(posSpeedProperty, True) obs.obs_property_set_visible(durationProperty, True) startingWidthProperty = obs.obs_properties_get( props, animation.startingWidthStorage) startingHeightProperty = obs.obs_properties_get( props, animation.startingHeightStorage) destinationWidthProperty = obs.obs_properties_get( props, animation.destinationWidthStorage) destinationHeightProperty = obs.obs_properties_get( props, animation.destinationHeightStorage) if variationType == VARIATION_SIZE or variationType == VARIATION_BOTH: obs.obs_property_set_visible(startingWidthProperty, showStartingProperties) obs.obs_property_set_visible(startingHeightProperty, showStartingProperties) obs.obs_property_set_visible(destinationWidthProperty, True) obs.obs_property_set_visible(destinationHeightProperty, True) obs.obs_property_set_visible(posSpeedProperty, False) obs.obs_property_set_visible(movementTypeProperty, False) else: obs.obs_property_set_visible(startingWidthProperty, False) obs.obs_property_set_visible(startingHeightProperty, False) obs.obs_property_set_visible(destinationWidthProperty, False) obs.obs_property_set_visible(destinationHeightProperty, False) obs.obs_property_set_visible(movementTypeProperty, True) if variationType == VARIATION_POSITION_FREE or variationType == VARIATION_SIZE_FREE or variationType == VARIATION_POSITION_FREE_ALL: obs.obs_property_set_visible(setDestinationProperty, False) obs.obs_property_set_visible(customStartingSettingsProperty, False) obs.obs_property_set_visible(stopCommandProperty, True) else: obs.obs_property_set_visible(setDestinationProperty, True) obs.obs_property_set_visible(customStartingSettingsProperty, True) obs.obs_property_set_visible(stopCommandProperty, False) if variationType == VARIATION_POSITION_FREE: obs.obs_property_set_visible(posSpeedProperty, True) obs.obs_property_set_visible(posDirectionProperty, True) obs.obs_property_set_visible(durationProperty, False) else: obs.obs_property_set_visible(posDirectionProperty, False) if variationType == VARIATION_POSITION_FREE_ALL: obs.obs_property_set_visible(posSpeedProperty, True) obs.obs_property_set_visible(durationProperty, False) if variationType == VARIATION_SIZE: obs.obs_property_set_visible(changeSizeInPlaceProperty, True) else: obs.obs_property_set_visible(changeSizeInPlaceProperty, False)
def qualifier_toggled(props, prop, settings): vis = obs.obs_data_get_bool(settings, "use_qualifier") obs.obs_property_set_visible( obs.obs_properties_get(props, "qualifier_group"), vis) return True
def podium_toggled(props, prop, settings): vis = obs.obs_data_get_bool(settings, "use_podium") obs.obs_property_set_visible(obs.obs_properties_get(props, "podium_group"), vis) return True
def show(self): if not self.visible: self.visible = True for p in self.__property: _obs.obs_property_set_visible(p, True)
def media_player_toggled(props, prop, settings): vis = obs.obs_data_get_bool(settings, "use_media_player") obs.obs_property_set_visible( obs.obs_properties_get(props, "media_player_group"), vis) return True