From cf71ef4cce083d20828c4c4aa4ff78528bd32e61 Mon Sep 17 00:00:00 2001 From: domi41 Date: Sun, 6 Sep 2020 04:39:07 +0200 Subject: [PATCH] feat: save the ongoing poll on each judgment received The resumed poll may be buggy ; something about how we handle users --- addons/majority_judgment/MajorityJudgmentPoll.gd | 2 +- .../nodes/MajorityJudgmentLinearResultsControl.gd | 13 ++++++++----- gui/MainMenu.tscn | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/addons/majority_judgment/MajorityJudgmentPoll.gd b/addons/majority_judgment/MajorityJudgmentPoll.gd index d9c99bb..2d65a47 100644 --- a/addons/majority_judgment/MajorityJudgmentPoll.gd +++ b/addons/majority_judgment/MajorityJudgmentPoll.gd @@ -128,7 +128,7 @@ func add_judgment(judgment:MajorityJudgmentJudgment) -> void: func get_judgments() -> Array: - assert(judgments, "Poll has no judgments.") +# assert(judgments, "Poll has no judgments.") return judgments diff --git a/addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd b/addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd index 6faae98..8329f2c 100644 --- a/addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd +++ b/addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd @@ -60,14 +60,11 @@ func set_poll(__poll:MajorityJudgmentPoll): poll = __poll craft_nodes() update_scene() + App.save_ongoing_poll() self.providers = App.get_providers() for provider in self.providers: start_provider(provider) - -# var provider = MajorityJudgmentDemoProvider.new() -# var provider = MajorityJudgmentTwitchChatProvider.new() -# start_provider(provider) func close_poll(): @@ -234,7 +231,9 @@ func get_or_create_participant(identifier:String) -> MajorityJudgmentParticipant if not known_participants.has(identifier): known_participants[identifier] = MajorityJudgmentParticipant.make(identifier) return known_participants[identifier] - + + +var __save_mutex := Mutex.new() # perhaps overzealous func __on_judgment_emitted(author_identifier, grade_index, candidate_index): # Data comes from userland, best be careful here @@ -253,12 +252,16 @@ func __on_judgment_emitted(author_identifier, grade_index, candidate_index): # printerr("Ignoring candidate %s since it's out of range." % [char(candidate_index)]) return + __save_mutex.lock() var j = MajorityJudgmentJudgment.new() j.set_participant(get_or_create_participant(author_identifier)) j.set_grade(poll.grading.grades[grade_index]) j.set_candidate(poll.candidates[candidate_index]) poll.add_judgment(j) + App.save_ongoing_poll() + __save_mutex.unlock() + update_scene() diff --git a/gui/MainMenu.tscn b/gui/MainMenu.tscn index e1d8477..8632df9 100644 --- a/gui/MainMenu.tscn +++ b/gui/MainMenu.tscn @@ -25,9 +25,9 @@ __meta__ = { [node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"] margin_left = 218.0 -margin_top = 290.0 +margin_top = 260.0 margin_right = 382.0 -margin_bottom = 510.0 +margin_bottom = 540.0 [node name="ResumePollButton" type="Button" parent="CenterContainer/VBoxContainer"] margin_right = 164.0