feat: display a white border around the median grade.

master
Dominique Merle 4 years ago
parent 7b1e3400df
commit 89a18cd0b0

@ -40,7 +40,7 @@ func count_grades_with_judgments() -> int:
func get_median() -> int: func get_median() -> int:
""" """
Returns the grade index, not a Grade instance. Returns the grade index, not a Grade instance.
0 = worst grade 0 = worst grade (most conservative?)
Returns -1 if there are no judgments. Returns -1 if there are no judgments.
""" """
@ -69,6 +69,9 @@ func get_median() -> int:
func remove_one_judgment(grade_index:int) -> void: 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]) assert(0 < self.grades[grade_index])
self.grades[grade_index] -= 1 self.grades[grade_index] -= 1

@ -1,5 +1,9 @@
extends ColorRect 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): func set_grade_icon(_grade_icon:Texture):
get_material().set_shader_param("grade_icon", _grade_icon) get_material().set_shader_param("grade_icon", _grade_icon)

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

@ -1,6 +1,7 @@
shader_type canvas_item; shader_type canvas_item;
uniform sampler2D grade_icon; uniform sampler2D grade_icon;
uniform bool is_median = false;
void fragment() { void fragment() {
vec4 final_color = COLOR; vec4 final_color = COLOR;
@ -39,6 +40,20 @@ void fragment() {
texture_color_base.a 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; COLOR = final_color;

Loading…
Cancel
Save