Browse Source

feat: allow alignment with window bottom

This will help on Android, where the results are hidden by SMS notifications.
master
Dominique Merle 2 years ago
parent
commit
9cc7636793
  1. 8
      addons/majority_judgment/MajorityJudgmentPoll.gd
  2. 19
      addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd
  3. 3
      addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.tscn
  4. 3
      core/App.gd
  5. 30
      gui/MainMenu.tscn
  6. 12
      gui/forms/SettingsForm.gd
  7. 19
      gui/forms/SettingsForm.tscn

8
addons/majority_judgment/MajorityJudgmentPoll.gd

@ -96,7 +96,15 @@ func get_candidates() -> Array:
return candidates
func count_candidates() -> int:
if not candidates:
return 0
return candidates.size()
func has_judgments() -> bool:
if not judgments:
return false
return 0 < judgments.size()

19
addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.gd

@ -12,9 +12,13 @@ export(Resource) var poll setget set_poll, get_poll
export(int) var vertical_gap := 4 # pixels
export(int) var candidates_labels_width := 200 # pixels
export(bool) var align_with_bottom := false # pixels
export(int) var padding_with_window := 20 # pixels
onready var ProfilesContainer = find_node("ProfilesContainer", true)
var providers:Array # of MajorityJudgmentAbstractJudgmentsProvider
#var provider:MajorityJudgmentAbstractJudgmentsProvider
@ -114,7 +118,6 @@ func craft_nodes():
# wrapper.margin_top = position * height
# wrapper.margin_bottom = wrapper.margin_top + height
# separator.owner = self
candidate_label.owner = self
profile.owner = self
wrapper.owner = self
@ -127,7 +130,8 @@ func update_scene():
$Tween.remove_all()
var tally : MajorityJudgmentPollTally = get_poll().tally()
var candidate_index = 0 # as they were initially written, before the sort
var candidates_amount = get_poll().count_candidates()
var container_height = $ProfilesContainer.rect_size.y
for candidate in get_poll().get_candidates():
var profile = profiles_nodes[candidate_index]
var candidate_line_node = self.candidates_lines_nodes[candidate_index]
@ -141,6 +145,17 @@ func update_scene():
var tween_duration = 0.818
var tween_delay = 0
var cln_margin_top = position * (height + vertical_gap)
if align_with_bottom:
cln_margin_top += (
container_height
-
candidates_amount * (height + vertical_gap)
-
padding_with_window
)
else:
cln_margin_top += padding_with_window
$Tween.interpolate_property(
candidate_line_node,

3
addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.tscn

@ -9,8 +9,11 @@ script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
align_with_bottom = true
[node name="ProfilesContainer" type="Control" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_top = 4.0
rect_min_size = Vector2( 600, 400 )
__meta__ = {

3
core/App.gd

@ -50,7 +50,8 @@ func start_poll(poll):
# Move to poll results scene
var _done = get_tree().change_scene("res://addons/majority_judgment/nodes/MajorityJudgmentLinearResultsControl.tscn")
yield(get_tree(), "idle_frame")
get_tree().current_scene.set_poll(poll)
get_tree().current_scene.align_with_bottom = Config.get_parameter("align_with_bottom", false)
get_tree().current_scene.set_poll(poll) # last
func get_providers() -> Array:

30
gui/MainMenu.tscn

@ -24,32 +24,32 @@ __meta__ = {
}
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 224.0
margin_top = 305.0
margin_right = 376.0
margin_bottom = 495.0
margin_left = 218.0
margin_top = 290.0
margin_right = 382.0
margin_bottom = 510.0
[node name="NewPollButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_right = 152.0
margin_bottom = 46.0
margin_right = 164.0
margin_bottom = 52.0
text = "New Poll"
[node name="SettingsButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_top = 50.0
margin_right = 152.0
margin_bottom = 96.0
margin_top = 60.0
margin_right = 164.0
margin_bottom = 112.0
text = "Settings"
[node name="ExitButton" type="Button" parent="CenterContainer/VBoxContainer"]
margin_top = 100.0
margin_right = 152.0
margin_bottom = 146.0
margin_top = 120.0
margin_right = 164.0
margin_bottom = 172.0
text = "Exit"
[node name="VersionLabel" type="Label" parent="CenterContainer/VBoxContainer"]
margin_top = 150.0
margin_right = 152.0
margin_bottom = 190.0
margin_top = 180.0
margin_right = 164.0
margin_bottom = 220.0
text = "v0.1"
align = 1
[connection signal="pressed" from="CenterContainer/VBoxContainer/NewPollButton" to="." method="_on_NewPollButton_pressed"]

12
gui/forms/SettingsForm.gd

@ -4,6 +4,7 @@ extends Control
onready var DemoProviderCheckButton = find_node("DemoProviderCheckButton", true)
onready var TwitchCheckButton = find_node("TwitchCheckButton", true)
onready var SmsCheckButton = find_node("SmsCheckButton", true)
onready var AlignWithBottomCheckButton = find_node("AlignWithBottomCheckButton", true)
onready var WindowSizeWidthLineEdit = find_node("WindowSizeWidthLineEdit", true)
onready var WindowSizeHeightLineEdit = find_node("WindowSizeHeightLineEdit", true)
@ -25,6 +26,10 @@ func _ready():
false
)
SmsCheckButton.disabled = not App.can_have_sms_provider()
AlignWithBottomCheckButton.pressed = Config.get_parameter(
"align_with_bottom",
false
)
update_window_size_inputs()
initializing = false
@ -111,3 +116,10 @@ func _on_WindowSizeDetectionButton_pressed():
)
update_window_size_inputs()
func _on_AlignWithBottomCheckButton_toggled(button_pressed):
Config.set_parameter(
"align_with_bottom",
button_pressed
)

19
gui/forms/SettingsForm.tscn

@ -26,9 +26,9 @@ __meta__ = {
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
margin_left = 5.0
margin_top = 149.0
margin_top = 150.0
margin_right = 595.0
margin_bottom = 649.0
margin_bottom = 650.0
rect_min_size = Vector2( 590, 500 )
[node name="TabContainer" type="TabContainer" parent="CenterContainer/VBoxContainer"]
@ -37,6 +37,7 @@ margin_bottom = 440.0
size_flags_vertical = 3
[node name="Providers" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
@ -136,7 +137,6 @@ disabled = true
text = "Some other Chat Commands"
[node name="General" type="Control" parent="CenterContainer/VBoxContainer/TabContainer"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 8.0
@ -153,7 +153,7 @@ __meta__ = {
[node name="HelpLabel" type="RichTextLabel" parent="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer"]
margin_right = 574.0
margin_bottom = 318.0
margin_bottom = 230.0
size_flags_horizontal = 3
size_flags_vertical = 3
text = "General settings.
@ -162,6 +162,16 @@ __meta__ = {
"_edit_use_anchors_": false
}
[node name="AlignWithBottomContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer"]
margin_top = 238.0
margin_right = 574.0
margin_bottom = 318.0
[node name="AlignWithBottomCheckButton" type="CheckButton" parent="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer/AlignWithBottomContainer"]
margin_right = 521.0
margin_bottom = 80.0
text = "Align results with window bottom"
[node name="WindowSizeContainer" type="HBoxContainer" parent="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer"]
margin_top = 326.0
margin_right = 574.0
@ -237,6 +247,7 @@ margin_bottom = 625.0
[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="toggled" from="CenterContainer/VBoxContainer/TabContainer/Providers/VBoxContainer/SmsContainer/SmsCheckButton" to="." method="_on_SmsCheckButton_toggled"]
[connection signal="toggled" from="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer/AlignWithBottomContainer/AlignWithBottomCheckButton" to="." method="_on_AlignWithBottomCheckButton_toggled"]
[connection signal="focus_exited" from="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer/WindowSizeContainer/WindowSizeWidthLineEdit" to="." method="_on_WindowSizeWidthLineEdit_focus_exited"]
[connection signal="focus_exited" from="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer/WindowSizeContainer/WindowSizeHeightLineEdit" to="." method="_on_WindowSizeHeightLineEdit_focus_exited"]
[connection signal="pressed" from="CenterContainer/VBoxContainer/TabContainer/General/VBoxContainer/WindowSizeContainer/WindowSizeDetectionButton" to="." method="_on_WindowSizeDetectionButton_pressed"]

Loading…
Cancel
Save