Compare commits

...

3 Commits

@ -40,7 +40,7 @@ func count_grades_with_judgments() -> int:
func get_median() -> int:
"""
Returns the grade index, not a Grade instance.
0 = worst grade
0 = worst grade (most conservative?)
Returns -1 if there are no judgments.
"""
@ -69,6 +69,9 @@ func get_median() -> int:
func remove_one_judgment(grade_index:int) -> void:
"""
Used by the naive sorting algorithm, that works on a copy.
"""
assert(0 < self.grades[grade_index])
self.grades[grade_index] -= 1

@ -1,5 +1,9 @@
extends ColorRect
func refresh_median_status(_is_median:bool):
get_material().set_shader_param("is_median", _is_median)
func set_grade_icon(_grade_icon:Texture):
get_material().set_shader_param("grade_icon", _grade_icon)

@ -55,6 +55,7 @@ func refresh(merit_profile:MajorityJudgmentCandidateMeritProfile):
yield($Tween, "tree_entered")
$Tween.remove_all()
var median : int = merit_profile.get_median()
var total_amount_of_judgments : int = merit_profile.count_judgments()
var amount_of_grades_with_judgments : int = merit_profile.count_grades_with_judgments()
var amount_of_grades : int = merit_profile.grades.size()
@ -63,6 +64,7 @@ func refresh(merit_profile:MajorityJudgmentCandidateMeritProfile):
var cursor := 0
for grade_index in range(amount_of_grades):
var grade_node = _grades_nodes[grade_index]
grade_node.refresh_median_status(grade_index == median)
var amount_of_judgments_for_grade = merit_profile.grades[grade_index]
var width = (
(total_width - (amount_of_grades_with_judgments-1) * gap_size)

@ -8,7 +8,7 @@ class_name MajorityJudgmentChatCommandJudgmentsProvider
# Command Syntax
# --------------
#
# <candidate><grade>
# <candidate_letter><grade>
#
# such as
#
@ -31,11 +31,14 @@ class_name MajorityJudgmentChatCommandJudgmentsProvider
#
# A0 B2 c0 D1
#
# We would like to get word grades, because numbers, although handy,
# create a bias. They don't mean the same thing to everyone.
# See https://git.mieuxvoter.fr/MieuxVoter/majority-judgment-for-streamers/issues/12
#
func process_chat_command(author_identifier:String, chat_command:String):
var regex = RegEx.new()
regex.compile("(?<candidate>[a-zA-Z]{1})(?<grade>[0-9]{1})")
regex.compile("(?<candidate>[a-zA-Z]{2})[ ]*(?<grade>[0-9]{2})")
var results = regex.search_all(chat_command)
if results:

@ -1,6 +1,7 @@
shader_type canvas_item;
uniform sampler2D grade_icon;
uniform bool is_median = false;
void fragment() {
vec4 final_color = COLOR;
@ -39,6 +40,20 @@ void fragment() {
texture_color_base.a
);
if (is_median) {
float border_size = 0.07;
if (
(UV.x > 1.0 - border_size)
||
(UV.x < border_size)
||
(UV.y > 1.0 - border_size)
||
(UV.y < border_size)
) {
final_color.rgb = vec3(1.0, 1.0, 1.0);
}
}
COLOR = final_color;

Loading…
Cancel
Save