feat: add a Demo provider, useful for demos

master
Dominique Merle 4 years ago
parent 3e4605d07c
commit 9db0ec27ee

@ -15,7 +15,8 @@ export(int) var candidates_labels_width := 200 # pixels
onready var ProfilesContainer = find_node("ProfilesContainer", true) onready var ProfilesContainer = find_node("ProfilesContainer", true)
var provider:MajorityJudgmentAbstractJudgmentsProvider var providers:Array # of MajorityJudgmentAbstractJudgmentsProvider
#var provider:MajorityJudgmentAbstractJudgmentsProvider
func _input(_event): func _input(_event):
@ -40,9 +41,13 @@ func set_poll(__poll:MajorityJudgmentPoll):
craft_nodes() craft_nodes()
update_nodes() update_nodes()
self.providers = App.get_providers()
for provider in self.providers:
start_provider(provider)
# var provider = MajorityJudgmentDemoProvider.new() # var provider = MajorityJudgmentDemoProvider.new()
var provider = MajorityJudgmentTwitchChatProvider.new() # var provider = MajorityJudgmentTwitchChatProvider.new()
start_provider(provider) # start_provider(provider)
var candidates_lines_nodes := Array() var candidates_lines_nodes := Array()
@ -163,12 +168,12 @@ func create_merit_profile_scene(gradation_size:int):
func start_provider(__provider): func start_provider(__provider):
self.provider = __provider # self.provider = __provider
var connected = self.provider.connect( var connected = __provider.connect(
"judgment_emitted", "judgment_emitted",
self, "__on_judgment_emitted" self, "__on_judgment_emitted"
) )
self.provider.start_providing() __provider.start_providing()
var known_participants := Dictionary() # id => Participant var known_participants := Dictionary() # id => Participant

@ -2,19 +2,29 @@ extends MajorityJudgmentChatCommandJudgmentsProvider
class_name MajorityJudgmentDemoProvider class_name MajorityJudgmentDemoProvider
# Dummy provider, to test the app out.
func start_providing(): func start_providing():
yield(App.timer(1), "timeout") var commands = [
process_chat_command("Stup", "A0B1C3") ["Stup", "A0B1C3"],
yield(App.timer(1), "timeout") ["Flip", "A0B2C1"],
process_chat_command("Flip", "A0B2C1") ["Flip", "A1"],
yield(App.timer(1), "timeout") ["Sylvain", "A3B4"],
process_chat_command("Flip", "A1") ["Sylvain", "C5B3"],
yield(App.timer(1), "timeout") ["Julia", "A0"],
process_chat_command("Clap", "A3B4") ["Julia", "B1"],
yield(App.timer(1), "timeout") ["Julia", "C2"],
process_chat_command("Clap", "C5B3") ["Elliot", "A0B0C5"],
yield(App.timer(2), "timeout") ["Sophie", "C0"],
process_chat_command("Neo", "B5") ["Sophie", "C0A2B5"],
yield(App.timer(1), "timeout") ["Yohan", "B1A2C3"],
process_chat_command("April", "A4") ["Teddy", "A5"],
["Miu", "A4B2C1"],
# … add more
]
for command in commands:
yield(App.timer(1+(randi()%3)), "timeout")
process_chat_command(command[0], command[1])

@ -14,10 +14,10 @@ var __config : Dictionary
func get_parameter(parameter_key:String, default=null): func get_parameter(parameter_key:String, default=null):
hydrate_lazily() hydrate_lazily()
if self.__config.has(parameter_key): if self.__config.has(parameter_key):
# print("[Config] Reading parameter `%s' from Config." % parameter_key) print("[Config] Reading parameter `%s' from Config." % parameter_key)
return self.__config[parameter_key] return self.__config[parameter_key]
else: else:
# print("[Config] Using default value for parameter `%s'." % parameter_key) print("[Config] Using default value for parameter `%s'." % parameter_key)
return default return default

@ -2,6 +2,7 @@ extends Control
onready var TwitchCheckButton = find_node("TwitchCheckButton", true) onready var TwitchCheckButton = find_node("TwitchCheckButton", true)
onready var DemoProviderCheckButton = find_node("DemoProviderCheckButton", true)
var initializing = true var initializing = true
func _ready(): func _ready():
@ -9,6 +10,10 @@ func _ready():
"provider_MajorityJudgmentTwitchChatProvider_enabled", "provider_MajorityJudgmentTwitchChatProvider_enabled",
false false
) )
DemoProviderCheckButton.pressed = Config.get_parameter(
"provider_MajorityJudgmentDemoProvider_enabled",
false
)
initializing = false initializing = false
@ -27,3 +32,10 @@ func _on_TwitchCheckButton_toggled(button_pressed):
) )
if button_pressed and not initializing: if button_pressed and not initializing:
find_node('NoTwitchSettingsPopup', true).show_if_should() find_node('NoTwitchSettingsPopup', true).show_if_should()
func _on_DemoProviderCheckButton_toggled(button_pressed):
Config.set_parameter(
"provider_MajorityJudgmentDemoProvider_enabled",
button_pressed
)

@ -17,20 +17,22 @@ __meta__ = {
[node name="CenterContainer" type="CenterContainer" parent="."] [node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
margin_left = 0.943848
margin_right = 0.943848
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 337.0 margin_left = 337.0
margin_top = 188.0 margin_top = 173.0
margin_right = 687.0 margin_right = 687.0
margin_bottom = 412.0 margin_bottom = 427.0
[node name="TabContainer" type="TabContainer" parent="CenterContainer/VBoxContainer"] [node name="TabContainer" type="TabContainer" parent="CenterContainer/VBoxContainer"]
margin_right = 350.0 margin_right = 350.0
margin_bottom = 200.0 margin_bottom = 230.0
rect_min_size = Vector2( 350, 200 ) rect_min_size = Vector2( 350, 230 )
[node name="Providers" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"] [node name="Providers" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"]
anchor_right = 1.0 anchor_right = 1.0
@ -55,7 +57,7 @@ bbcode_enabled = true
bbcode_text = "Your community votes by sending commands such as \"B2\" in the chat. You must enable at least one provider or your polls will have no participants." bbcode_text = "Your community votes by sending commands such as \"B2\" in the chat. You must enable at least one provider or your polls will have no participants."
text = "Your community votes by sending commands such as \"B2\" in the chat. You must enable at least one provider or your polls will have no participants." text = "Your community votes by sending commands such as \"B2\" in the chat. You must enable at least one provider or your polls will have no participants."
[node name="TwitchContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"] [node name="DemoContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"]
margin_top = 54.0 margin_top = 54.0
margin_right = 342.0 margin_right = 342.0
margin_bottom = 94.0 margin_bottom = 94.0
@ -63,6 +65,27 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="DemoProviderCheckButton" type="CheckButton" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/DemoContainer"]
margin_right = 176.0
margin_bottom = 40.0
text = "Demo Provider"
[node name="Label" type="Label" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/DemoContainer"]
margin_left = 180.0
margin_top = 4.0
margin_right = 330.0
margin_bottom = 35.0
text = "Enable this to simulate
votes for a quick demo."
[node name="TwitchContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"]
margin_top = 98.0
margin_right = 342.0
margin_bottom = 138.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="TwitchCheckButton" type="CheckButton" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer"] [node name="TwitchCheckButton" type="CheckButton" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer"]
margin_right = 229.0 margin_right = 229.0
margin_bottom = 40.0 margin_bottom = 40.0
@ -75,9 +98,9 @@ margin_bottom = 40.0
text = "Configure" text = "Configure"
[node name="OtherContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"] [node name="OtherContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer"]
margin_top = 98.0 margin_top = 142.0
margin_right = 342.0 margin_right = 342.0
margin_bottom = 138.0 margin_bottom = 182.0
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -115,9 +138,9 @@ margin_bottom = 240.0
rect_min_size = Vector2( 350, 200 ) rect_min_size = Vector2( 350, 200 )
[node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"] [node name="HBoxContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer"]
margin_top = 204.0 margin_top = 234.0
margin_right = 350.0 margin_right = 350.0
margin_bottom = 224.0 margin_bottom = 254.0
[node name="VSeparator" type="VSeparator" parent="CenterContainer/VBoxContainer/HBoxContainer"] [node name="VSeparator" type="VSeparator" parent="CenterContainer/VBoxContainer/HBoxContainer"]
self_modulate = Color( 1, 1, 1, 0 ) self_modulate = Color( 1, 1, 1, 0 )
@ -132,6 +155,8 @@ margin_bottom = 20.0
text = "DONE" text = "DONE"
[node name="NoTwitchSettingsPopup" parent="." instance=ExtResource( 3 )] [node name="NoTwitchSettingsPopup" parent="." instance=ExtResource( 3 )]
visible = false
[connection signal="toggled" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/DemoContainer/DemoProviderCheckButton" to="." method="_on_DemoProviderCheckButton_toggled"]
[connection signal="toggled" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer/TwitchCheckButton" to="." method="_on_TwitchCheckButton_toggled"] [connection signal="toggled" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer/TwitchCheckButton" to="." method="_on_TwitchCheckButton_toggled"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer/TwitchConfigureButton" to="." method="_on_TwitchConfigureButton_pressed"] [connection signal="pressed" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/TwitchContainer/TwitchConfigureButton" to="." method="_on_TwitchConfigureButton_pressed"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/DoneButton" to="." method="_on_DoneButton_pressed"] [connection signal="pressed" from="CenterContainer/VBoxContainer/HBoxContainer/DoneButton" to="." method="_on_DoneButton_pressed"]

Loading…
Cancel
Save