#2 #6 #7 Added a new sync screen that shows progress during sync
All checks were successful
Build / build (push) Successful in 1m22s
All checks were successful
Build / build (push) Successful in 1m22s
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://n2g8jddr85h2"
|
||||
path="res://.godot/imported/01. Opening.mp3-3b470cf2b258d9ffad574f672712bdc3.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://01. Opening.mp3"
|
||||
dest_files=["res://.godot/imported/01. Opening.mp3-3b470cf2b258d9ffad574f672712bdc3.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
@@ -8,8 +8,6 @@ extends Control
|
||||
# 386 LOC 12/6 - 2024
|
||||
|
||||
##TODO
|
||||
# 13. Fix graphics in lists
|
||||
# 14. Fix layout
|
||||
# 15. Fix for local play
|
||||
|
||||
@onready
|
||||
@@ -55,7 +53,7 @@ var sound_test_button: Button = $SoundTestButton
|
||||
var sync_button: Button = $SyncButton
|
||||
|
||||
@onready
|
||||
var sync_popup: PopupPanel = $SyncPopupPanel
|
||||
var sync_window: Control = %SyncWindow
|
||||
|
||||
@onready
|
||||
var settings_button: Button = $SettingsButton
|
||||
@@ -149,8 +147,6 @@ func _ready() -> void:
|
||||
if is_debug:
|
||||
print("is_debug")
|
||||
debug_label.visible = true
|
||||
##Settings.default_path = "http://localhost:8080"
|
||||
##Settings.selected_server = 3
|
||||
Settings.default_path = "http://localhost:8080"
|
||||
Settings.selected_server = 3
|
||||
Settings.winning_score = 5
|
||||
@@ -172,6 +168,9 @@ func _ready() -> void:
|
||||
music_player_container.connect("play_next_song", fetch_song.bind(false))
|
||||
music_player_container.connect("update_song_list", update_song_list)
|
||||
settings_window.connect("server_changed", server_updated)
|
||||
sync_window.connect("sync_started", _on_sync_started)
|
||||
sync_window.connect("sync_finished", _on_sync_finished)
|
||||
|
||||
|
||||
add_players_button.pressed.connect(add_players)
|
||||
add_player_button.pressed.connect(add_player)
|
||||
@@ -210,13 +209,13 @@ func _input(event: InputEvent) -> void:
|
||||
func server_updated() -> void:
|
||||
print("server_updated")
|
||||
update_from_server()
|
||||
reset_playlist()
|
||||
reset_points()
|
||||
|
||||
func update_from_server() -> void:
|
||||
print("update_from_server")
|
||||
search_view.get_list_of_games()
|
||||
get_suggestion_list()
|
||||
reset_playlist()
|
||||
|
||||
func repeat_song() -> void:
|
||||
Settings.auto_repeat_song = !Settings.auto_repeat_song
|
||||
@@ -362,26 +361,23 @@ func get_statistics() -> void:
|
||||
|
||||
func sync_games() -> void:
|
||||
print("sync_games")
|
||||
sync_button.disabled = true
|
||||
var games_synced: Callable = func games_synced() -> void:
|
||||
sync_button.disabled = false
|
||||
sync_popup.visible = true
|
||||
print("games_synced")
|
||||
reset_playlist()
|
||||
update_from_server()
|
||||
sync_window.start_sync()
|
||||
|
||||
var new_games_synced: Callable = func new_games_synced(synced) -> void:
|
||||
sync_button.disabled = false
|
||||
sync_popup.visible = true
|
||||
print("games_synced")
|
||||
print("synced: ", synced)
|
||||
reset_playlist()
|
||||
update_from_server()
|
||||
|
||||
if Settings.quick_sync == true:
|
||||
Settings.make_request2("/sync/new", new_games_synced, true)
|
||||
else:
|
||||
Settings.make_request2("/sync/quick", games_synced, false)
|
||||
func _on_sync_started() -> void:
|
||||
print("_on_sync_started")
|
||||
sync_button.disabled = false
|
||||
sound_test_button.disabled = true
|
||||
reset_playlist_button.disabled = true
|
||||
show_answer_button.disabled = true
|
||||
next_button.disabled = true
|
||||
|
||||
func _on_sync_finished() -> void:
|
||||
print("_on_sync_finished")
|
||||
update_from_server()
|
||||
sound_test_button.disabled = false
|
||||
reset_playlist_button.disabled = false
|
||||
show_answer_button.disabled = false
|
||||
next_button.disabled = false
|
||||
|
||||
func get_suggestion_list() -> void:
|
||||
print("get_suggestion_list")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=26 format=3 uid="uid://xwq863o6uvsu"]
|
||||
[gd_scene load_steps=27 format=3 uid="uid://xwq863o6uvsu"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b8f4g15cas2j2" path="res://MainWindow.gd" id="1_eu0t5"]
|
||||
[ext_resource type="PackedScene" uid="uid://b16on0oscg1bv" path="res://CharacterSelect.tscn" id="2_76kf4"]
|
||||
@@ -9,6 +9,7 @@
|
||||
[ext_resource type="Script" uid="uid://cgakje8gb37tf" path="res://PlayerNameField.gd" id="7_qsdfy"]
|
||||
[ext_resource type="Theme" uid="uid://rxexo3ur85as" path="res://LightGrayTheme.tres" id="7_wxbv6"]
|
||||
[ext_resource type="PackedScene" uid="uid://bxydgil1yifps" path="res://SearchWindow.tscn" id="9_5ijvr"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpdem7pdxweb5" path="res://SyncWindow.tscn" id="10_yxw0b"]
|
||||
[ext_resource type="Texture2D" uid="uid://r4as0nmtoa7p" path="res://noCharacter.png" id="11_1qef0"]
|
||||
[ext_resource type="PackedScene" uid="uid://dldpeo5y3l5hq" path="res://SettingsWindow.tscn" id="11_k62u5"]
|
||||
|
||||
@@ -371,19 +372,14 @@ offset_top = 96.0
|
||||
offset_right = 56.0
|
||||
offset_bottom = 96.0
|
||||
|
||||
[node name="SyncPopupPanel" type="PopupPanel" parent="."]
|
||||
initial_position = 2
|
||||
size = Vector2i(140, 70)
|
||||
|
||||
[node name="Label" type="Label" parent="SyncPopupPanel"]
|
||||
texture_filter = 1
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 136.0
|
||||
offset_bottom = 66.0
|
||||
text = "Games synced!"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
[node name="SyncWindow" parent="." instance=ExtResource("10_yxw0b")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
offset_left = 364.0
|
||||
offset_top = 153.0
|
||||
offset_right = 364.0
|
||||
offset_bottom = 153.0
|
||||
|
||||
[node name="StatisticsPopupPanel" type="PopupPanel" parent="."]
|
||||
initial_position = 2
|
||||
@@ -476,8 +472,8 @@ size = Vector2i(268, 233)
|
||||
[node name="SettingsWindow" parent="SettingsPopupPanel" instance=ExtResource("11_k62u5")]
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 264.0
|
||||
offset_bottom = 229.0
|
||||
offset_right = 271.0
|
||||
offset_bottom = 354.0
|
||||
|
||||
[node name="WinnerPopupPanel" type="PopupPanel" parent="."]
|
||||
initial_position = 2
|
||||
|
||||
@@ -205,4 +205,4 @@ func play_local_song() -> void:
|
||||
play_sound(load_mp3(local_path))
|
||||
|
||||
func sound_test_local() -> void:
|
||||
play_sound(preload("res://01. Opening.mp3"))
|
||||
play_sound(preload("res://sounds/01. Opening.mp3"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://ds15cgsf8vpvc"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d1v0rquma6nt8" path="res://MusicPlayer.gd" id="1_t24ra"]
|
||||
[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://01. Opening.mp3" id="2_xti80"]
|
||||
[ext_resource type="AudioStream" uid="uid://n2g8jddr85h2" path="res://sounds/01. Opening.mp3" id="2_xti80"]
|
||||
[ext_resource type="Texture2D" uid="uid://comxqfiykp54f" path="res://icons/play_icon_light.svg" id="3_6g308"]
|
||||
[ext_resource type="Texture2D" uid="uid://ccb6rvbldlgdg" path="res://icons/reload_light_icon.svg" id="4_jleuo"]
|
||||
[ext_resource type="PackedScene" uid="uid://w400rnew7453" path="res://volume_slider.tscn" id="5_iifuj"]
|
||||
|
||||
@@ -21,7 +21,7 @@ var is_first_point: bool = true
|
||||
|
||||
var character: Texture = load("res://noCharacter.png")
|
||||
|
||||
func _init(new_name: String, new_id: int):
|
||||
func _init(new_name: String, new_id: int) -> void:
|
||||
player_name = new_name
|
||||
id = new_id
|
||||
player_score = 0
|
||||
|
||||
@@ -15,6 +15,7 @@ var use_low_played_mode: bool = false
|
||||
var winning_score: int = 20
|
||||
var fullscreen: bool = false
|
||||
var quick_sync: bool = true
|
||||
var number_of_tracks_to_preload: int = 1
|
||||
var play_local: bool = false
|
||||
|
||||
var player_array: Array[PlayerObject]
|
||||
@@ -22,12 +23,16 @@ var song_object_array: Array[SongObject] = []
|
||||
var latest_played_song: int = 0
|
||||
var currently_playing_song: int = -1
|
||||
var edit_players: bool = false
|
||||
var currently_syncing: bool = false
|
||||
|
||||
var version: String = "1.6.0"
|
||||
|
||||
var whats_new: String = "Changelog:
|
||||
1.6.0:
|
||||
#1: Fixed bug with inspiration list not reloding after sync
|
||||
#2: New dialog for sync
|
||||
#6: Now show progress during sync
|
||||
#7: Blocking all requests to the server during sync
|
||||
1.5.0: Made big changes to players and the song list and how the local song list works
|
||||
0.9.0-Beta: Fixed settings and updated the player view
|
||||
0.8.0-Beta: Fixed reset buttons and some other small things
|
||||
|
||||
153
SyncWindow.tscn
Normal file
153
SyncWindow.tscn
Normal file
@@ -0,0 +1,153 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dpdem7pdxweb5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c3ejukwth512a" path="res://sync_window.gd" id="1_8ba47"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_anbfi"]
|
||||
font_size = 25
|
||||
|
||||
[node name="Control" type="Control"]
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_8ba47")
|
||||
|
||||
[node name="SyncPanel" type="Panel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 640.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="SyncPanel"]
|
||||
layout_mode = 0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 640.0
|
||||
|
||||
[node name="SyncVBoxContainer" type="VBoxContainer" parent="SyncPanel/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SyncTitleLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
text = "Sync"
|
||||
label_settings = SubResource("LabelSettings_anbfi")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="NoChangesLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 0
|
||||
text = "No changes since last sync"
|
||||
label_settings = SubResource("LabelSettings_anbfi")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ProgressHBoxContainer" type="HBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SyncProgressBar" type="ProgressBar" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/ProgressHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(1000, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
step = 1.0
|
||||
rounded = true
|
||||
|
||||
[node name="SyncHBoxContainer" type="HBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme_override_constants/separation = 30
|
||||
|
||||
[node name="VSeparator6" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesAddedVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesAddedLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer/GamesAddedVBox"]
|
||||
layout_mode = 2
|
||||
text = "GamesAdded"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GamesAddedSeparator" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesReAddedVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesReAddedLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer/GamesReAddedVBox"]
|
||||
layout_mode = 2
|
||||
text = "GamesReAdded"
|
||||
|
||||
[node name="GamesReAddedSeparator" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesChangedTitleVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesChangedTitleLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer/GamesChangedTitleVBox"]
|
||||
layout_mode = 2
|
||||
text = "GamesChangedTitle"
|
||||
|
||||
[node name="GamesChangedTitleSeparator" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesChangedContentVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesChangedContentLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer/GamesChangedContentVBox"]
|
||||
layout_mode = 2
|
||||
text = "GamesChangedContent"
|
||||
|
||||
[node name="GamesChangedContentSeparator" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesRemovedVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="GamesRemovedLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer/GamesRemovedVBox"]
|
||||
layout_mode = 2
|
||||
text = "GamesRemoved"
|
||||
|
||||
[node name="GamesRemovedSeparator" type="VSeparator" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/SyncHBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SyncTime" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "Sync time: "
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="CatchedErrorsVBox" type="VBoxContainer" parent="SyncPanel/ScrollContainer/SyncVBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CatchedErrorsLabel" type="Label" parent="SyncPanel/ScrollContainer/SyncVBoxContainer/CatchedErrorsVBox"]
|
||||
layout_mode = 2
|
||||
text = "CatchedErrors"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="CoolDownTimer" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="SyncTimer" type="Timer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
5
progress_response.gd
Normal file
5
progress_response.gd
Normal file
@@ -0,0 +1,5 @@
|
||||
class_name ProgressResponse
|
||||
extends Node
|
||||
|
||||
var progress: String
|
||||
var total_time: String
|
||||
1
progress_response.gd.uid
Normal file
1
progress_response.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://e74iuu78stc3
|
||||
@@ -21,7 +21,6 @@ Settings="*res://Settings.gd"
|
||||
|
||||
[debug]
|
||||
|
||||
settings/stdout/print_fps=true
|
||||
gdscript/warnings/untyped_declaration=1
|
||||
gdscript/warnings/inferred_declaration=1
|
||||
|
||||
|
||||
19
sounds/01. Opening.mp3.import
Normal file
19
sounds/01. Opening.mp3.import
Normal file
@@ -0,0 +1,19 @@
|
||||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
uid="uid://n2g8jddr85h2"
|
||||
path="res://.godot/imported/01. Opening.mp3-559a476b5f0faf13d7bec359898ef47c.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://sounds/01. Opening.mp3"
|
||||
dest_files=["res://.godot/imported/01. Opening.mp3-559a476b5f0faf13d7bec359898ef47c.mp3str"]
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
10
sync_response.gd
Normal file
10
sync_response.gd
Normal file
@@ -0,0 +1,10 @@
|
||||
class_name SyncResponse
|
||||
extends Node
|
||||
|
||||
var games_added: Array
|
||||
var games_re_added: Array
|
||||
var games_changed_title: Array
|
||||
var games_changed_content: Array
|
||||
var games_removed: Array
|
||||
var catched_errors: Array
|
||||
var total_time: String
|
||||
1
sync_response.gd.uid
Normal file
1
sync_response.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dtfsuob2aidl7
|
||||
212
sync_window.gd
Normal file
212
sync_window.gd
Normal file
@@ -0,0 +1,212 @@
|
||||
extends Control
|
||||
|
||||
@onready
|
||||
var sync_panel: Panel = %SyncPanel
|
||||
|
||||
@onready
|
||||
var sync_title_label: Label = %SyncTitleLabel
|
||||
|
||||
@onready
|
||||
var no_changes_label: Label = %NoChangesLabel
|
||||
|
||||
@onready
|
||||
var progress_hbox: HBoxContainer = %ProgressHBoxContainer
|
||||
|
||||
@onready
|
||||
var sync_hbox: HBoxContainer = %SyncHBoxContainer
|
||||
|
||||
@onready
|
||||
var sync_progress_bar: ProgressBar = %SyncProgressBar
|
||||
|
||||
@onready
|
||||
var games_added_vbox: VBoxContainer = %GamesAddedVBox
|
||||
|
||||
@onready
|
||||
var games_added_separator: VSeparator = %GamesAddedSeparator
|
||||
|
||||
@onready
|
||||
var games_readded_vbox: VBoxContainer = %GamesReAddedVBox
|
||||
|
||||
@onready
|
||||
var games_readded_separator: VSeparator = %GamesReAddedSeparator
|
||||
|
||||
@onready
|
||||
var games_changed_title_vbox: VBoxContainer = %GamesChangedTitleVBox
|
||||
|
||||
@onready
|
||||
var games_changed_title_separator: VSeparator = %GamesChangedTitleSeparator
|
||||
|
||||
@onready
|
||||
var games_changed_content_vbox: VBoxContainer = %GamesChangedContentVBox
|
||||
|
||||
@onready
|
||||
var games_changed_content_separator: VSeparator = %GamesChangedContentSeparator
|
||||
|
||||
@onready
|
||||
var games_removed_vbox: VBoxContainer = %GamesRemovedVBox
|
||||
|
||||
@onready
|
||||
var games_removed_separator: VSeparator = %GamesRemovedSeparator
|
||||
|
||||
@onready
|
||||
var catched_errors_vbox: VBoxContainer = %CatchedErrorsVBox
|
||||
|
||||
@onready
|
||||
var sync_time: Label = %SyncTime
|
||||
|
||||
@onready
|
||||
var cool_down_timer: Timer = %CoolDownTimer
|
||||
|
||||
@onready
|
||||
var sync_timer: Timer = %SyncTimer
|
||||
|
||||
var changes: bool = false
|
||||
|
||||
var cool_down_ongoing: bool = false
|
||||
|
||||
signal sync_started
|
||||
signal sync_finished
|
||||
|
||||
func _ready() -> void:
|
||||
sync_timer.timeout.connect(_on_sync_timeout)
|
||||
cool_down_timer.timeout.connect(_on_cool_down_timeout)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if self.visible == true:
|
||||
if event is InputEventMouseButton && event.is_pressed():
|
||||
print("Mouse Click/Unclick at: ", event.position)
|
||||
var evLocal = make_input_local(event)
|
||||
if !Rect2(Vector2(0, 0), sync_panel.size).has_point(evLocal.position):
|
||||
self.visible = false
|
||||
print("CLOSING")
|
||||
|
||||
func start_sync() -> void:
|
||||
print("start_sync")
|
||||
self.visible = true
|
||||
var sync_started: Callable = func sync_started() -> void:
|
||||
sync_timer.start(0.75)
|
||||
Settings.currently_syncing = true
|
||||
sync_started.emit()
|
||||
show_sync_progress()
|
||||
if !cool_down_ongoing && !Settings.currently_syncing:
|
||||
Settings.make_request2("/sync", sync_started, false)
|
||||
|
||||
func _on_cool_down_timeout() -> void:
|
||||
print("_on_cool_down_timeout")
|
||||
print("COOLDOWN IS NOW FINSISHED, SYNC CAN START AGAIN")
|
||||
cool_down_ongoing = false
|
||||
|
||||
func _on_sync_timeout() -> void:
|
||||
print("_on_sync_timeout!")
|
||||
var get_progress: Callable = func get_progress(data_received: Dictionary) -> void:
|
||||
print("get_progress")
|
||||
print("data_received: ", data_received)
|
||||
if data_received != null:
|
||||
if data_received.has("progress"):
|
||||
sync_progress_bar.value = int(data_received.progress)
|
||||
sync_time.text = data_received.time_spent
|
||||
else:
|
||||
on_sync_finished(data_received)
|
||||
Settings.make_request2("/sync/progress", get_progress, true)
|
||||
|
||||
func on_sync_finished(data_received: Dictionary) -> void:
|
||||
reset_sync_result()
|
||||
if data_received.games_added != null:
|
||||
changes = true
|
||||
list_visible(games_added_vbox, games_added_separator)
|
||||
make_list(data_received.games_added, games_added_vbox, "GamesAdded")
|
||||
if data_received.games_re_added != null:
|
||||
changes = true
|
||||
list_visible(games_readded_vbox, games_readded_separator)
|
||||
make_list(data_received.games_re_added, games_readded_vbox, "GamesReAdded")
|
||||
if data_received.games_changed_title != null:
|
||||
changes = true
|
||||
list_visible(games_changed_title_vbox, games_changed_title_separator)
|
||||
Settings.delete_children(games_changed_title_vbox)
|
||||
make_header_label(games_changed_title_vbox, "GamesChangedTitle")
|
||||
var row: int = 0
|
||||
for old_game_title: String in data_received.games_changed_title:
|
||||
var label: Label = make_game_label(old_game_title + " changed title to " + data_received.games_changed_title[old_game_title])
|
||||
if row % 2 != 0:
|
||||
label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||||
games_changed_title_vbox.add_child(label)
|
||||
if data_received.games_changed_content != null:
|
||||
changes = true
|
||||
list_visible(games_changed_content_vbox, games_changed_content_separator)
|
||||
make_list(data_received.games_changed_content, games_changed_content_vbox, "GamesChangedContent")
|
||||
if data_received.games_removed != null:
|
||||
changes = true
|
||||
list_visible(games_removed_vbox, games_removed_separator)
|
||||
make_list(data_received.games_removed, games_removed_vbox, "GamesRemoved")
|
||||
if data_received.catched_errors != null:
|
||||
catched_errors_vbox.visible = true
|
||||
make_list(data_received.catched_errors, catched_errors_vbox, "CatchedErrors")
|
||||
if !changes:
|
||||
no_changes_label.visible = true
|
||||
sync_time.text = data_received.total_time
|
||||
Settings.currently_syncing = false
|
||||
sync_timer.stop()
|
||||
print("sync finished")
|
||||
show_sync_result()
|
||||
cool_down_timer.start(30*60)
|
||||
cool_down_ongoing = true
|
||||
sync_finished.emit()
|
||||
|
||||
func list_visible(vbox: VBoxContainer, seperator: VSeparator) -> void:
|
||||
vbox.visible = true
|
||||
seperator.visible = true
|
||||
|
||||
func make_header_label(vbox: VBoxContainer, text: String) -> void:
|
||||
var label: Label = Label.new()
|
||||
label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
label.add_theme_font_size_override("font_size", 20)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.text = text
|
||||
vbox.add_child(label)
|
||||
|
||||
func make_game_label(text: String) -> Label:
|
||||
var label: Label = Label.new()
|
||||
label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
label.add_theme_font_size_override("font_size", 20)
|
||||
label.text = text
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
return label
|
||||
|
||||
func reset_sync_result() -> void:
|
||||
sync_progress_bar.value = 0
|
||||
sync_time.text = ""
|
||||
changes = false
|
||||
no_changes_label.visible = false
|
||||
games_added_vbox.visible = false
|
||||
games_added_separator.visible = false
|
||||
games_readded_vbox.visible = false
|
||||
games_readded_separator.visible = false
|
||||
games_changed_title_vbox.visible = false
|
||||
games_changed_title_separator.visible = false
|
||||
games_changed_content_vbox.visible = false
|
||||
games_changed_content_separator.visible = false
|
||||
games_removed_vbox.visible = false
|
||||
games_removed_separator.visible = false
|
||||
catched_errors_vbox.visible = false
|
||||
|
||||
func make_list(list: Array, vbox: VBoxContainer, text: String) -> void:
|
||||
Settings.delete_children(vbox)
|
||||
make_header_label(vbox, text)
|
||||
var row: int = 0
|
||||
for game: String in list:
|
||||
var label: Label = make_game_label(game)
|
||||
if row % 2 != 0:
|
||||
label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||||
vbox.add_child(label)
|
||||
|
||||
func show_sync_result() -> void:
|
||||
sync_title_label.text = "Sync Result"
|
||||
progress_hbox.visible = false
|
||||
sync_hbox.visible = true
|
||||
|
||||
func show_sync_progress() -> void:
|
||||
sync_title_label.text = "Sync in Progress"
|
||||
progress_hbox.visible = true
|
||||
no_changes_label.visible = false
|
||||
sync_hbox.visible = false
|
||||
catched_errors_vbox.visible = false
|
||||
1
sync_window.gd.uid
Normal file
1
sync_window.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c3ejukwth512a
|
||||
Reference in New Issue
Block a user