Made improvements to the Search window, Made small changes to the inspiration list scrolling, Made small changes to the player list, Changed the term game to soundtrack, #28: Made changes to the sync window
This commit is contained in:
1 parent
235bdcbcb5
commit
8da6fc442f
17 files changed
+448
-363
No files matched your search
+116
-55
@@ -19,34 +19,34 @@ var sync_hbox: HBoxContainer = %SyncHBoxContainer
|
||||
var sync_progress_bar: ProgressBar = %SyncProgressBar
|
||||
|
||||
@onready
|
||||
var games_added_vbox: VBoxContainer = %GamesAddedVBox
|
||||
var soundtracks_added_vbox: VBoxContainer = %SoundtracksAddedVBox
|
||||
|
||||
@onready
|
||||
var games_added_separator: VSeparator = %GamesAddedSeparator
|
||||
var soundtracks_added_separator: VSeparator = %SoundtracksAddedSeparator
|
||||
|
||||
@onready
|
||||
var games_readded_vbox: VBoxContainer = %GamesReAddedVBox
|
||||
var soundtracks_readded_vbox: VBoxContainer = %SoundtracksReAddedVBox
|
||||
|
||||
@onready
|
||||
var games_readded_separator: VSeparator = %GamesReAddedSeparator
|
||||
var soundtracks_readded_separator: VSeparator = %SoundtracksReAddedSeparator
|
||||
|
||||
@onready
|
||||
var games_changed_title_vbox: VBoxContainer = %GamesChangedTitleVBox
|
||||
var soundtracks_changed_title_vbox: VBoxContainer = %SoundtracksChangedTitleVBox
|
||||
|
||||
@onready
|
||||
var games_changed_title_separator: VSeparator = %GamesChangedTitleSeparator
|
||||
var soundtracks_changed_title_separator: VSeparator = %SoundtracksChangedTitleSeparator
|
||||
|
||||
@onready
|
||||
var games_changed_content_vbox: VBoxContainer = %GamesChangedContentVBox
|
||||
var soundtracks_changed_content_vbox: VBoxContainer = %SoundtracksChangedContentVBox
|
||||
|
||||
@onready
|
||||
var games_changed_content_separator: VSeparator = %GamesChangedContentSeparator
|
||||
var soundtracks_changed_content_separator: VSeparator = %SoundtracksChangedContentSeparator
|
||||
|
||||
@onready
|
||||
var games_removed_vbox: VBoxContainer = %GamesRemovedVBox
|
||||
var soundtracks_removed_vbox: VBoxContainer = %SoundtracksRemovedVBox
|
||||
|
||||
@onready
|
||||
var games_removed_separator: VSeparator = %GamesRemovedSeparator
|
||||
var soundtracks_removed_separator: VSeparator = %SoundtracksRemovedSeparator
|
||||
|
||||
@onready
|
||||
var catched_errors_vbox: VBoxContainer = %CatchedErrorsVBox
|
||||
@@ -57,6 +57,12 @@ var sync_time: Label = %SyncTime
|
||||
@onready
|
||||
var sync_timer: Timer = %SyncTimer
|
||||
|
||||
@onready
|
||||
var restart_sync_button: Button = %RestartSyncButton
|
||||
|
||||
@onready
|
||||
var first_separator: VSeparator = %VSeparator6
|
||||
|
||||
var changes: bool = false
|
||||
|
||||
var has_synced: bool = false
|
||||
@@ -66,6 +72,8 @@ signal sync_finished
|
||||
|
||||
func _ready() -> void:
|
||||
sync_timer.timeout.connect(_on_sync_timeout)
|
||||
restart_sync_button.pressed.connect(start_sync)
|
||||
restart_sync_button.visible = false
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if self.visible == true:
|
||||
@@ -74,17 +82,30 @@ func _input(event: InputEvent) -> void:
|
||||
if !Rect2(Vector2(0, 0), sync_panel.size).has_point(evLocal.position):
|
||||
self.visible = false
|
||||
|
||||
func show_section_if_has_data(data: Variant, vbox: VBoxContainer, separator: VSeparator, header_text: String) -> bool:
|
||||
if data != null && data.size() > 0:
|
||||
vbox.visible = true
|
||||
make_list(data, vbox, header_text)
|
||||
return true
|
||||
else:
|
||||
vbox.visible = false
|
||||
separator.visible = false
|
||||
return false
|
||||
|
||||
func start_sync() -> void:
|
||||
print("start_sync")
|
||||
self.visible = true
|
||||
if !has_synced:
|
||||
var sync_request_sent: Callable = func sync_request_sent() -> void:
|
||||
sync_timer.start(0.75)
|
||||
Settings.currently_syncing = true
|
||||
sync_started.emit()
|
||||
show_sync_progress()
|
||||
if !Settings.currently_syncing:
|
||||
Settings.make_request2("/sync", sync_request_sent, false)
|
||||
if has_synced:
|
||||
# Already synced, just show the results
|
||||
show_sync_result()
|
||||
return
|
||||
var sync_request_sent: Callable = func sync_request_sent() -> void:
|
||||
sync_timer.start(0.75)
|
||||
Settings.currently_syncing = true
|
||||
sync_started.emit()
|
||||
show_sync_progress()
|
||||
if !Settings.currently_syncing:
|
||||
Settings.make_request2("/sync", sync_request_sent, false)
|
||||
|
||||
func _on_sync_timeout() -> void:
|
||||
print("_on_sync_timeout!")
|
||||
@@ -94,7 +115,7 @@ func _on_sync_timeout() -> void:
|
||||
if data_received != null:
|
||||
if data_received.has("progress"):
|
||||
sync_progress_bar.value = int(data_received.progress)
|
||||
sync_time.text = data_received.time_spent
|
||||
sync_time.text = data_received.time_spent if data_received.has("time_spent") else ""
|
||||
else:
|
||||
on_sync_finished(data_received)
|
||||
Settings.make_request2("/sync/progress", get_progress, true)
|
||||
@@ -102,43 +123,77 @@ func _on_sync_timeout() -> void:
|
||||
func on_sync_finished(data_received: Dictionary) -> void:
|
||||
has_synced = true
|
||||
reset_sync_result()
|
||||
if data_received.games_added != null:
|
||||
|
||||
if show_section_if_has_data(data_received.soundtracks_added, soundtracks_added_vbox, soundtracks_added_separator, "Added"):
|
||||
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:
|
||||
|
||||
if show_section_if_has_data(data_received.soundtracks_re_added, soundtracks_readded_vbox, soundtracks_readded_separator, "ReAdded"):
|
||||
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:
|
||||
|
||||
if data_received.soundtracks_changed_title != null && data_received.soundtracks_changed_title.size() > 0:
|
||||
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")
|
||||
Settings.delete_children(soundtracks_changed_title_vbox)
|
||||
make_header_label(soundtracks_changed_title_vbox, "Changed Title")
|
||||
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])
|
||||
for old_soundtrack_title: String in data_received.soundtracks_changed_title:
|
||||
var label: Label = make_soundtrack_label(old_soundtrack_title + "\nchanged title to\n" + data_received.soundtracks_changed_title[old_soundtrack_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:
|
||||
soundtracks_changed_title_vbox.add_child(label)
|
||||
row += 1
|
||||
soundtracks_changed_title_vbox.visible = true
|
||||
|
||||
if show_section_if_has_data(data_received.soundtracks_changed_content, soundtracks_changed_content_vbox, soundtracks_changed_content_separator, "Changed Content"):
|
||||
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:
|
||||
|
||||
if show_section_if_has_data(data_received.soundtracks_removed, soundtracks_removed_vbox, soundtracks_removed_separator, "Removed"):
|
||||
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:
|
||||
|
||||
if data_received.catched_errors != null && data_received.catched_errors.size() > 0:
|
||||
catched_errors_vbox.visible = true
|
||||
make_list(data_received.catched_errors, catched_errors_vbox, "CatchedErrors")
|
||||
|
||||
# Hide separators that don't have a visible section after them
|
||||
# The structure is: RestartSyncButton -> VSeparator6 -> VBox -> Separator -> VBox -> Separator -> ...
|
||||
# Hide VSeparator6 if there are no visible sections
|
||||
var visible_sections: Array = []
|
||||
if soundtracks_added_vbox.visible:
|
||||
visible_sections.append("added")
|
||||
if soundtracks_readded_vbox.visible:
|
||||
visible_sections.append("readded")
|
||||
if soundtracks_changed_title_vbox.visible:
|
||||
visible_sections.append("changed_title")
|
||||
if soundtracks_changed_content_vbox.visible:
|
||||
visible_sections.append("changed_content")
|
||||
if soundtracks_removed_vbox.visible:
|
||||
visible_sections.append("removed")
|
||||
|
||||
first_separator.visible = visible_sections.size() > 1
|
||||
|
||||
# Show section separators only if there's a visible section after them
|
||||
for i in range(visible_sections.size()):
|
||||
var section = visible_sections[i]
|
||||
var separator_map = {
|
||||
"added": soundtracks_added_separator,
|
||||
"readded": soundtracks_readded_separator,
|
||||
"changed_title": soundtracks_changed_title_separator,
|
||||
"changed_content": soundtracks_changed_content_separator,
|
||||
"removed": soundtracks_removed_separator
|
||||
}
|
||||
# Show this section's separator only if there's a next section
|
||||
if i < visible_sections.size() - 1:
|
||||
separator_map[section].visible = true
|
||||
else:
|
||||
separator_map[section].visible = false
|
||||
|
||||
if !changes:
|
||||
no_changes_label.visible = true
|
||||
sync_time.text = data_received.total_time
|
||||
sync_time.text = "Total time: " + data_received.total_time if data_received.has("total_time") else ""
|
||||
Settings.currently_syncing = false
|
||||
sync_timer.stop()
|
||||
print("sync finished")
|
||||
show_sync_result()
|
||||
restart_sync_button.visible = true
|
||||
sync_finished.emit()
|
||||
|
||||
func list_visible(vbox: VBoxContainer, seperator: VSeparator) -> void:
|
||||
@@ -150,15 +205,16 @@ func make_header_label(vbox: VBoxContainer, text: String) -> void:
|
||||
label.set_texture_filter(TextureFilter.TEXTURE_FILTER_NEAREST)
|
||||
label.add_theme_font_size_override("font_size", 20)
|
||||
label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
|
||||
label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||||
label.text = text
|
||||
vbox.add_child(label)
|
||||
|
||||
func make_game_label(text: String) -> Label:
|
||||
func make_soundtrack_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.add_theme_font_size_override("font_size", 18)
|
||||
label.text = text
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_WORD
|
||||
label.autowrap_mode = TextServer.AUTOWRAP_OFF
|
||||
return label
|
||||
|
||||
func reset_sync_result() -> void:
|
||||
@@ -166,32 +222,35 @@ func reset_sync_result() -> void:
|
||||
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
|
||||
soundtracks_added_vbox.visible = false
|
||||
soundtracks_added_separator.visible = false
|
||||
soundtracks_readded_vbox.visible = false
|
||||
soundtracks_readded_separator.visible = false
|
||||
soundtracks_changed_title_vbox.visible = false
|
||||
soundtracks_changed_title_separator.visible = false
|
||||
soundtracks_changed_content_vbox.visible = false
|
||||
soundtracks_changed_content_separator.visible = false
|
||||
soundtracks_removed_vbox.visible = false
|
||||
soundtracks_removed_separator.visible = false
|
||||
catched_errors_vbox.visible = false
|
||||
first_separator.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)
|
||||
for soundtrack: String in list:
|
||||
var label: Label = make_soundtrack_label(soundtrack)
|
||||
if row % 2 != 0:
|
||||
label.add_theme_color_override("font_color", Color(1, 0.5, 0))
|
||||
vbox.add_child(label)
|
||||
row += 1
|
||||
|
||||
func show_sync_result() -> void:
|
||||
sync_title_label.text = "Sync Result"
|
||||
progress_hbox.visible = false
|
||||
sync_hbox.visible = true
|
||||
restart_sync_button.visible = true
|
||||
|
||||
func show_sync_progress() -> void:
|
||||
sync_title_label.text = "Sync in Progress"
|
||||
@@ -199,3 +258,5 @@ func show_sync_progress() -> void:
|
||||
no_changes_label.visible = false
|
||||
sync_hbox.visible = false
|
||||
catched_errors_vbox.visible = false
|
||||
restart_sync_button.visible = false
|
||||
first_separator.visible = false
|
||||
Reference in new issue
Block a user