| 1 |  |  | import gettext | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | import os | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | import obspython as obs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | from rtgg_obs import RacetimeObs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | def script_update_timer_settings( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |     settings, rtgg_obs: RacetimeObs, update_sources | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | ): | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |     rtgg_obs.timer.use_podium_colors = obs.obs_data_get_bool( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |         settings, "use_podium") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |     rtgg_obs.timer.pre_color = obs.obs_data_get_int(settings, "pre_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |     rtgg_obs.timer.first_color = obs.obs_data_get_int(settings, "first_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     rtgg_obs.timer.second_color = obs.obs_data_get_int( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |         settings, "second_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     rtgg_obs.timer.third_color = obs.obs_data_get_int(settings, "third_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     rtgg_obs.timer.racing_color = obs.obs_data_get_int( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         settings, "racing_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     rtgg_obs.timer.finished_color = obs.obs_data_get_int( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         settings, "finished_color") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     rtgg_obs.logger.debug(f"timer.enabled is {rtgg_obs.timer.enabled}") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     rtgg_obs.logger.debug(f"timer.source_name is {rtgg_obs.timer.source_name}") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     rtgg_obs.logger.debug(f"selected_race is {rtgg_obs.selected_race}") | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | def script_timer_settings(props, rtgg_obs: RacetimeObs): | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     lang = gettext.translation( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         "racetime-obs", localedir=os.environ['LOCALEDIR']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     _ = lang.gettext | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     p = obs.obs_properties_add_bool( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         props, "use_podium", _("Use custom color for podium finishes?")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     obs.obs_property_set_modified_callback(p, podium_toggled) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     podium_group = obs.obs_properties_create() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     obs.obs_properties_add_group( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         props, "podium_group", _("Podium Colors"), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         obs.OBS_GROUP_NORMAL, podium_group | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     obs.obs_property_set_visible(obs.obs_properties_get( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         props, "podium_group"), rtgg_obs.timer.use_podium_colors) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     obs.obs_properties_add_color(podium_group, "pre_color", _("Pre-race:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     obs.obs_properties_add_color( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         podium_group, "racing_color", _("Still racing:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     obs.obs_properties_add_color(podium_group, "first_color", _("1st place:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     obs.obs_properties_add_color(podium_group, "second_color", _("2nd place:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     obs.obs_properties_add_color(podium_group, "third_color", _("3rd place:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     obs.obs_properties_add_color( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         podium_group, "finished_color", _("After podium:")) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 52 |  |  | def podium_toggled(props, prop, settings): | 
            
                                                        
            
                                    
            
            
                | 53 |  |  |     vis = obs.obs_data_get_bool(settings, "use_podium") | 
            
                                                        
            
                                    
            
            
                | 54 |  |  |     obs.obs_property_set_visible( | 
            
                                                        
            
                                    
            
            
                | 55 |  |  |         obs.obs_properties_get(props, "podium_group"), vis) | 
            
                                                        
            
                                    
            
            
                | 56 |  |  |     return True | 
            
                                                        
            
                                    
            
            
                | 57 |  |  |  |