Conditions | 2 |
Total Lines | 105 |
Code Lines | 92 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | from threading import Thread |
||
78 | def script_properties(): |
||
79 | props = obs.obs_properties_create() |
||
80 | |||
81 | setup_group = obs.obs_properties_create() |
||
82 | obs.obs_properties_add_group( |
||
83 | props, "initial_setup", "Initial setup - Check to make changes", obs.OBS_GROUP_CHECKABLE, setup_group) |
||
84 | p = obs.obs_properties_add_list( |
||
85 | setup_group, "source", "Text Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) |
||
86 | rtgg_obs.fill_source_list(p) |
||
87 | obs.obs_properties_add_text( |
||
88 | setup_group, "username", "Username", obs.OBS_TEXT_DEFAULT) |
||
89 | logging = obs.obs_properties_add_bool( |
||
90 | setup_group, "enable_log", "Enable logging") |
||
91 | log_levels = obs.obs_properties_add_list( |
||
92 | setup_group, "log_level", "Log lever", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
93 | obs.obs_property_list_add_string(log_levels, "Error", "Error") |
||
94 | obs.obs_property_list_add_string(log_levels, "Debug", "Debug") |
||
95 | obs.obs_property_list_add_string(log_levels, "Info", "Info") |
||
96 | obs.obs_property_set_long_description( |
||
97 | logging, "Generally, only log errors unless you are developing or are trying to find a specific problem.") |
||
98 | obs.obs_properties_add_bool(setup_group, "log_to_file", "Log to file?") |
||
99 | #obs.obs_property_set_modified_callback(p, log_to_file_toggled) |
||
100 | obs.obs_properties_add_path( |
||
101 | setup_group, "log_file", "Log File", obs.OBS_PATH_FILE_SAVE, "Text files(*.txt)", None) |
||
102 | |||
103 | category_list = obs.obs_properties_add_list( |
||
104 | props, "category_filter", "Filter by Category", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
105 | race_list = obs.obs_properties_add_list( |
||
106 | props, "race", "Race", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
107 | obs.obs_property_set_modified_callback(race_list, new_race_selected) |
||
108 | obs.obs_property_set_modified_callback( |
||
109 | category_list, new_category_selected) |
||
110 | |||
111 | p = obs.obs_properties_add_text( |
||
112 | props, "race_info", "Race Desc", obs.OBS_TEXT_MULTILINE) |
||
113 | obs.obs_property_set_enabled(p, False) |
||
114 | |||
115 | refresh = obs.obs_properties_add_button( |
||
116 | props, "button", "Refresh", lambda *props: None) |
||
117 | obs.obs_property_set_modified_callback(refresh, refresh_pressed) |
||
118 | |||
119 | p = obs.obs_properties_add_bool( |
||
120 | props, "use_podium", "Use custom color for podium finishes?") |
||
121 | obs.obs_property_set_modified_callback(p, podium_toggled) |
||
122 | |||
123 | podium_group = obs.obs_properties_create() |
||
124 | obs.obs_properties_add_group( |
||
125 | props, "podium_group", "Podium Colors", obs.OBS_GROUP_NORMAL, podium_group) |
||
126 | obs.obs_property_set_visible(obs.obs_properties_get( |
||
127 | props, "podium_group"), rtgg_obs.timer.use_podium_colors) |
||
128 | |||
129 | obs.obs_properties_add_color(podium_group, "pre_color", "Pre-race:") |
||
130 | obs.obs_properties_add_color(podium_group, "racing_color", "Still racing:") |
||
131 | obs.obs_properties_add_color(podium_group, "first_color", "1st place:") |
||
132 | obs.obs_properties_add_color(podium_group, "second_color", "2nd place:") |
||
133 | obs.obs_properties_add_color(podium_group, "third_color", "3rd place:") |
||
134 | obs.obs_properties_add_color( |
||
135 | podium_group, "finished_color", "After podium:") |
||
136 | |||
137 | p = obs.obs_properties_add_bool( |
||
138 | props, "use_coop", "Display coop information?") |
||
139 | obs.obs_property_set_modified_callback(p, coop_toggled) |
||
140 | |||
141 | coop_group = obs.obs_properties_create() |
||
142 | obs.obs_properties_add_group( |
||
143 | props, "coop_group", "Co-op Mode", obs.OBS_GROUP_NORMAL, coop_group) |
||
144 | obs.obs_property_set_visible( |
||
145 | obs.obs_properties_get(props, "coop_group"), rtgg_obs.coop.enabled) |
||
146 | p = obs.obs_properties_add_list( |
||
147 | coop_group, "coop_partner", "Co-op Partner", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
148 | p = obs.obs_properties_add_list( |
||
149 | coop_group, "coop_opponent1", "Co-op Opponent 1", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
150 | p = obs.obs_properties_add_list( |
||
151 | coop_group, "coop_opponent2", "Co-op Opponent 2", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) |
||
152 | rtgg_obs.fill_coop_entrant_lists(props) |
||
153 | p = obs.obs_properties_add_list(coop_group, "coop_source", "Coop Text Source", |
||
154 | obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) |
||
155 | obs.obs_property_set_long_description( |
||
156 | p, "This text source will display the time that the last racer needs to finish for their team to win") |
||
157 | rtgg_obs.fill_source_list(p) |
||
158 | p = obs.obs_properties_add_list(coop_group, "coop_label", "Coop Label Text Source", |
||
159 | obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) |
||
160 | obs.obs_property_set_long_description( |
||
161 | p, "This text source will be use to display a label such as \'<PartnerName> needs to finish before\' based on who the last racer is") |
||
162 | rtgg_obs.fill_source_list(p) |
||
163 | |||
164 | p = obs.obs_properties_add_bool( |
||
165 | props, "use_qualifier", "Display race results as tournament qualifier?") |
||
166 | obs.obs_property_set_modified_callback(p, qualifier_toggled) |
||
167 | |||
168 | qualifier_group = obs.obs_properties_create() |
||
169 | obs.obs_properties_add_group( |
||
170 | props, "qualifier_group", "Qualifier Mode", obs.OBS_GROUP_NORMAL, qualifier_group) |
||
171 | obs.obs_property_set_visible( |
||
172 | obs.obs_properties_get(props, "qualifier_group"), rtgg_obs.qualifier.enabled) |
||
173 | p = obs.obs_properties_add_int_slider( |
||
174 | qualifier_group, "qualifier_cutoff", "Use Top X as par time, where X=", 3, 10, 1) |
||
175 | p = obs.obs_properties_add_list(qualifier_group, "qualifier_par_source", |
||
176 | "Qualifier Par Time Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) |
||
177 | rtgg_obs.fill_source_list(p) |
||
178 | p = obs.obs_properties_add_list(qualifier_group, "qualifier_score_source", |
||
179 | "Qualifier Score Source", obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) |
||
180 | rtgg_obs.fill_source_list(p) |
||
181 | |||
182 | return props |
||
183 | |||
242 |