|
1
|
|
|
import obspython as obs |
|
2
|
|
|
from rtgg_obs import RacetimeObs |
|
3
|
|
|
from . import fill_source_list |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
def script_coop_settings(props, rtgg_obs: RacetimeObs): |
|
7
|
|
|
p = obs.obs_properties_add_bool( |
|
8
|
|
|
props, "use_coop", "Display coop information?") |
|
9
|
|
|
obs.obs_property_set_modified_callback(p, coop_toggled) |
|
10
|
|
|
coop_group = obs.obs_properties_create() |
|
11
|
|
|
obs.obs_properties_add_group( |
|
12
|
|
|
props, "coop_group", "Co-op Mode", obs.OBS_GROUP_NORMAL, coop_group |
|
13
|
|
|
) |
|
14
|
|
|
obs.obs_property_set_visible( |
|
15
|
|
|
obs.obs_properties_get(props, "coop_group"), rtgg_obs.coop.enabled) |
|
16
|
|
|
p = obs.obs_properties_add_list( |
|
17
|
|
|
coop_group, "coop_partner", "Co-op Partner", |
|
18
|
|
|
obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING |
|
19
|
|
|
) |
|
20
|
|
|
p = obs.obs_properties_add_list( |
|
21
|
|
|
coop_group, "coop_opponent1", "Co-op Opponent 1", |
|
22
|
|
|
obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING |
|
23
|
|
|
) |
|
24
|
|
|
p = obs.obs_properties_add_list( |
|
25
|
|
|
coop_group, "coop_opponent2", "Co-op Opponent 2", |
|
26
|
|
|
obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING |
|
27
|
|
|
) |
|
28
|
|
|
fill_coop_entrant_lists(props, rtgg_obs) |
|
29
|
|
|
p = obs.obs_properties_add_list( |
|
30
|
|
|
coop_group, "coop_source", "Coop Text Source", |
|
31
|
|
|
obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING |
|
32
|
|
|
) |
|
33
|
|
|
obs.obs_property_set_long_description(p, ( |
|
34
|
|
|
"This text source will display the time that the last racer needs to" |
|
35
|
|
|
" finish for their team to win" |
|
36
|
|
|
)) |
|
37
|
|
|
fill_source_list(p) |
|
38
|
|
|
p = obs.obs_properties_add_list( |
|
39
|
|
|
coop_group, "coop_label", "Coop Label Text Source", |
|
40
|
|
|
obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING |
|
41
|
|
|
) |
|
42
|
|
|
obs.obs_property_set_long_description(p, ( |
|
43
|
|
|
"This text source will be use to display a label such as " |
|
44
|
|
|
"\'<PartnerName> needs to finish before\' based on who the last racer" |
|
45
|
|
|
" is" |
|
46
|
|
|
)) |
|
47
|
|
|
fill_source_list(p) |
|
48
|
|
|
|
|
49
|
|
|
|
|
50
|
|
|
def coop_toggled(props, prop, settings): |
|
51
|
|
|
vis = obs.obs_data_get_bool(settings, "use_coop") |
|
52
|
|
|
obs.obs_property_set_visible( |
|
53
|
|
|
obs.obs_properties_get(props, "coop_group"), vis) |
|
54
|
|
|
return True |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
def fill_coop_entrant_lists(props, rtgg_obs: RacetimeObs): |
|
58
|
|
|
fill_entrant_list( |
|
59
|
|
|
rtgg_obs.race, obs.obs_properties_get(props, "coop_partner")) |
|
60
|
|
|
fill_entrant_list(rtgg_obs.race, obs.obs_properties_get( |
|
61
|
|
|
props, "coop_opponent1")) |
|
62
|
|
|
fill_entrant_list(rtgg_obs.race, obs.obs_properties_get( |
|
63
|
|
|
props, "coop_opponent2")) |
|
64
|
|
|
|
|
65
|
|
|
|
|
66
|
|
|
def fill_entrant_list(race, entrant_list): |
|
67
|
|
|
obs.obs_property_list_clear(entrant_list) |
|
68
|
|
|
obs.obs_property_list_add_string(entrant_list, "", "") |
|
69
|
|
|
if race is not None: |
|
70
|
|
|
for entrant in race.entrants: |
|
71
|
|
|
obs.obs_property_list_add_string( |
|
72
|
|
|
entrant_list, entrant.user.full_name, entrant.user.full_name) |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
def script_update_coop_settings(settings, rtgg_obs: RacetimeObs): |
|
76
|
|
|
rtgg_obs.coop.enabled = obs.obs_data_get_bool(settings, "use_coop") |
|
77
|
|
|
rtgg_obs.coop.partner = obs.obs_data_get_string(settings, "coop_partner") |
|
78
|
|
|
rtgg_obs.coop.opponent1 = obs.obs_data_get_string( |
|
79
|
|
|
settings, "coop_opponent1") |
|
80
|
|
|
rtgg_obs.coop.opponent2 = obs.obs_data_get_string( |
|
81
|
|
|
settings, "coop_opponent2") |
|
82
|
|
|
rtgg_obs.coop.source = obs.obs_data_get_string(settings, "coop_source") |
|
83
|
|
|
rtgg_obs.coop.label_source = obs.obs_data_get_string( |
|
84
|
|
|
settings, "coop_label") |
|
85
|
|
|
|