diff --git a/Error.wav b/Error.wav new file mode 100644 index 0000000..c6aca67 Binary files /dev/null and b/Error.wav differ diff --git a/Error.wav.import b/Error.wav.import new file mode 100644 index 0000000..8879438 --- /dev/null +++ b/Error.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://n8g3v41u2u48" +path="res://.godot/imported/Error.wav-f6422fca2f257bd634183d1c1c7a43ba.sample" + +[deps] + +source_file="res://Error.wav" +dest_files=["res://.godot/imported/Error.wav-f6422fca2f257bd634183d1c1c7a43ba.sample"] + +[params] + +force/8_bit=false +force/mono=false +force/max_rate=false +force/max_rate_hz=44100 +edit/trim=false +edit/normalize=false +edit/loop_mode=0 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Main.tscn b/Main.tscn index 9305104..c015ec0 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=69 format=3 uid="uid://b2sygl55s6fng"] +[gd_scene load_steps=74 format=3 uid="uid://b2sygl55s6fng"] [ext_resource type="Script" path="res://main.gd" id="1_ubs1p"] [ext_resource type="Texture2D" uid="uid://b8on1case224h" path="res://LoopPressed.png" id="2_iolk5"] @@ -36,6 +36,8 @@ [ext_resource type="Script" path="res://update_checker.gd" id="30_byc5i"] [ext_resource type="Script" path="res://patch_notes_button.gd" id="31_hjsj1"] [ext_resource type="Script" path="res://CustomButtonColor.gd" id="32_pwgec"] +[ext_resource type="Script" path="res://loading_failed_screen.gd" id="37_mkkhu"] +[ext_resource type="AudioStream" uid="uid://n8g3v41u2u48" path="res://Error.wav" id="38_nkjlp"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_kvkfy"] shader = ExtResource("8_xtnau") @@ -161,6 +163,31 @@ font_size = 31 [sub_resource type="LabelSettings" id="LabelSettings_ivhc6"] font_size = 20 +[sub_resource type="LabelSettings" id="LabelSettings_spe36"] +font_size = 46 +outline_size = 5 +outline_color = Color(0.675524, 0.62112, 0, 1) +shadow_size = 2 +shadow_color = Color(0.282353, 0.282353, 0.282353, 0.384314) +shadow_offset = Vector2(3, 5) + +[sub_resource type="LabelSettings" id="LabelSettings_amome"] +font_size = 18 +font_color = Color(0.894922, 0.894922, 0.894922, 1) +outline_size = 2 +outline_color = Color(0.519817, 0.439396, 0, 1) +shadow_size = 4 +shadow_color = Color(0.290196, 0.290196, 0.290196, 0.270588) +shadow_offset = Vector2(2, 3) + +[sub_resource type="LabelSettings" id="LabelSettings_drf2g"] +font_size = 20 +outline_size = 2 +outline_color = Color(0.519817, 0.439396, 0, 1) +shadow_size = 4 +shadow_color = Color(0.290196, 0.290196, 0.290196, 0.270588) +shadow_offset = Vector2(2, 3) + [node name="Node2D" type="Control"] layout_mode = 3 anchors_preset = 15 @@ -300,6 +327,7 @@ grow_vertical = 2 metadata/_edit_use_anchors_ = true [node name="PlaylistsPanel" type="Control" parent="PlaylistPanelHolder"] +visible = false layout_mode = 2 anchors_preset = 0 anchor_bottom = 1.0 @@ -493,10 +521,13 @@ color = Color(0.14902, 0.14902, 0.14902, 1) [node name="FileDialog" type="FileDialog" parent="CreatePlaylistsMenu"] title = "Open a Directory" +initial_position = 2 size = Vector2i(352, 180) ok_button_text = "Select Current Folder" file_mode = 2 access = 2 +filters = PackedStringArray("*") +show_hidden_files = true use_native_dialog = true [node name="ScrollContainer" type="ScrollContainer" parent="CreatePlaylistsMenu"] @@ -826,6 +857,7 @@ grow_horizontal = 0 grow_vertical = 0 size_flags_horizontal = 1 size_flags_vertical = 8 +tooltip_text = "use Up/Down arrow keys to adjust" focus_mode = 0 value = 100.0 @@ -1124,6 +1156,88 @@ horizontal_alignment = 1 initial_position = 2 dialog_text = "Are you sure you want to delete" +[node name="LoadingFailedScreen" type="Control" parent="."] +layout_mode = 1 +anchors_preset = 8 +anchor_left = 0.5 +anchor_top = 0.5 +anchor_right = 0.5 +anchor_bottom = 0.5 +offset_left = -235.0 +offset_top = -159.0 +offset_right = 235.0 +offset_bottom = 159.0 +grow_horizontal = 2 +grow_vertical = 2 +script = ExtResource("37_mkkhu") + +[node name="ColorRect" type="ColorRect" parent="LoadingFailedScreen"] +layout_mode = 1 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +color = Color(0.681657, 0.492205, 3.85046e-07, 1) + +[node name="VBoxContainer" type="VBoxContainer" parent="LoadingFailedScreen"] +layout_mode = 1 +anchors_preset = 5 +anchor_left = 0.5 +anchor_right = 0.5 +offset_left = -187.0 +offset_right = 187.0 +offset_bottom = 91.0 +grow_horizontal = 2 +alignment = 1 + +[node name="LoadingFailedLabel" type="Label" parent="LoadingFailedScreen/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +text = "LOADING FAILED" +label_settings = SubResource("LabelSettings_spe36") + +[node name="Label2" type="Label" parent="LoadingFailedScreen/VBoxContainer"] +layout_mode = 2 +text = "Saving is currently disabled +Simplaudio failed to load your save, +Simplaudio may also have failed to save, +if you suspect this, please contact me." +label_settings = SubResource("LabelSettings_amome") +horizontal_alignment = 1 + +[node name="Label3" type="Label" parent="LoadingFailedScreen/VBoxContainer"] +layout_mode = 2 +text = "Please restart Simplaudio, +if the issue presists you can:" +label_settings = SubResource("LabelSettings_drf2g") +horizontal_alignment = 1 + +[node name="HBoxContainer" type="HBoxContainer" parent="LoadingFailedScreen/VBoxContainer"] +layout_mode = 2 +size_flags_horizontal = 4 +alignment = 1 + +[node name="ContinueAnyways" type="Button" parent="LoadingFailedScreen/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Continue anyways" + +[node name="Contact" type="Button" parent="LoadingFailedScreen/VBoxContainer/HBoxContainer"] +layout_mode = 2 +text = "Contact me" + +[node name="ConfirmationDialog" type="ConfirmationDialog" parent="LoadingFailedScreen"] +title = "Are you sure?" +initial_position = 2 +size = Vector2i(242, 106) +force_native = true +ok_button_text = "Yes, i will take the risk" +dialog_text = "This is *irreversable*" +cancel_button_text = "No" + +[node name="FailedAudioCue" type="AudioStreamPlayer" parent="LoadingFailedScreen"] +stream = ExtResource("38_nkjlp") + [connection signal="toggled" from="SelectPlaylist" to="SelectPlaylist" method="_on_toggled"] [connection signal="pressed" from="PlaylistPanelHolder/PlaylistsPanel/PlaylistsContainer/VBoxContainer/HBoxContainer/CreatePlaylist" to="PlaylistPanelHolder/PlaylistsPanel" method="_on_create_playlist_pressed"] [connection signal="toggled" from="PlaylistPanelHolder/PlaylistsPanel/PlaylistsContainer/VBoxContainer/HBoxContainer/PlayAll" to="PlaylistPanelHolder/PlaylistsPanel" method="_on_play_all_toggled"] diff --git a/Settings.tscn b/Settings.tscn index d9b4572..075a74b 100644 --- a/Settings.tscn +++ b/Settings.tscn @@ -41,7 +41,7 @@ anchor_right = 1.0 anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 -scroll_vertical = 250 +scroll_vertical = 100 [node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"] custom_minimum_size = Vector2(576, 493) diff --git a/loading_failed_screen.gd b/loading_failed_screen.gd new file mode 100644 index 0000000..d043ef9 --- /dev/null +++ b/loading_failed_screen.gd @@ -0,0 +1,29 @@ +extends Control + +@onready var continue_anyways: Button = $VBoxContainer/HBoxContainer/ContinueAnyways +@onready var contact: Button = $VBoxContainer/HBoxContainer/Contact +@onready var failed_audio_cue: AudioStreamPlayer = $FailedAudioCue +@onready var confirmation_dialog: ConfirmationDialog = $ConfirmationDialog + +func Show(): + failed_audio_cue.play() + show() + continue_anyways.pressed.connect(confirmation_dialog.show) + confirmation_dialog.confirmed.connect(Confiremed) + contact.pressed.connect(Contact) + +func Confiremed(): + owner.LoadingSaveFailed = false + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + hide() + Show() + +func Contact(): + print("Contact pressed") + OS.shell_open("https://notdraimdev.github.io/SimplSite/Contact.html") + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/main.gd b/main.gd index 2191cf0..cbe89ba 100644 --- a/main.gd +++ b/main.gd @@ -69,6 +69,9 @@ var PlayAllLists:bool signal ContinueDelete var deleteSong:bool +var LoadingSaveFailed:bool +@onready var loading_failed_screen: Control = $LoadingFailedScreen + # Called when the node enters the scene tree for the first time. func _ready() -> void: get_tree().root.min_size = Vector2(850,492) @@ -88,9 +91,10 @@ func _ready() -> void: if Arg.to_lower().ends_with(".mp3") or Arg.to_lower().ends_with(".wav"): OS.alert("opening files like this\nis no longer supported") var data:Dictionary + var save = loadUserdata() + if save != {}: + data = save loadPlaylists() - if loadUserdata() != null: - data = loadUserdata() if Strin.is_empty(): if !Playlists.is_empty(): PlaylistSelected(Playlists.keys()[0],PlaylistsLocation[Playlists.keys()[0]]) @@ -179,6 +183,8 @@ func _ready() -> void: for child in get_children(true): if child is Control: child.focus_mode = child is LineEdit + if LoadingSaveFailed: + loading_failed_screen.Show() func setUpDiscord(): DiscordRPC.app_id = 1276916292170809426 @@ -277,7 +283,8 @@ func SetSong(IDX:int): CurrentIDX = IDX -1 PlaySongs() music_player.stop() - SaveEverything() + if !LoadingSaveFailed: + SaveEverything() print("SetSong") func pausePlay(): @@ -308,13 +315,12 @@ func SetVolume(Volume:float): AudioServer.set_bus_volume_db(0,volume) else: AudioServer.set_bus_volume_db(0,-1000) - print("Chnaged Volume") - SaveEverything() volume_slider.value = Volume func SelectPlaylistDir(): file_dialog.show() - SaveEverything() + if !LoadingSaveFailed: + SaveEverything() print("Select Playtlist dir") func DirectorySelected(dir:String): @@ -388,7 +394,8 @@ func PlaySongs(): CurrentSongLenth = song.get_length() music_player.stream = song music_player.play() - SaveEverything() + if !LoadingSaveFailed: + SaveEverything() print("set stream") @@ -467,9 +474,8 @@ func _process(_delta: float) -> void: currentSaveTime = SaveInterval DiscordUsername = DiscordRPC.get_current_user().get("username") - print(DiscordRPC.get_current_user()) - SaveEverything() - print("yoo") + if !LoadingSaveFailed: + SaveEverything() @warning_ignore("integer_division") if DiscordRPC.large_image != "nullbody": UpdateSplashes() @@ -579,44 +585,66 @@ func SaveEverything(): "PlayAllLists" : PlayAllLists, "DiscordUsername" : DiscordRPC.get_current_user().get("username") } + print("saving") saveUserdata(Data) savePlaylists() +var saveRetrys:int =0 + func savePlaylists(): var json = JSON.new() var file = FileAccess.open("user://playlists.dat", FileAccess.WRITE) var file2 = FileAccess.open("user://playlistsLocation.dat", FileAccess.WRITE) @warning_ignore("static_called_on_instance") - if !Playlists == null or !Playlists == {}: + if !(Playlists == null) or !(Playlists == {}): file.store_string(str(json.stringify(Playlists))) - if !PlaylistsLocation == null or !PlaylistsLocation == {}: + if !(PlaylistsLocation == null) or !(PlaylistsLocation == {}): file2.store_string(str(json.stringify(PlaylistsLocation))) + if loadUserdata() == {}: + if saveRetrys < 3: + savePlaylists() + else: + printerr("saving failed") func saveUserdata(content): var json = JSON.new() var file = FileAccess.open("user://data.dat", FileAccess.WRITE) @warning_ignore("static_called_on_instance") - file.store_string(Marshalls.utf8_to_base64(json.stringify(content))) + file.store_string(json.stringify(content)) file.close() -func loadUserdata(): +var saveLoadTries:int + +func loadUserdata() -> Dictionary: var json = JSON.new() var file = FileAccess.open("user://data.dat", FileAccess.READ) var filetext = file.get_as_text() if file != null else null if file != null: - var content + var content:Dictionary = {} if json.parse_string(file.get_as_text()) != null: content = json.parse_string(filetext) else: @warning_ignore("static_called_on_instance") content = json.parse_string(Marshalls.base64_to_utf8(file.get_as_text())) file.close() - return content + if content != null: + return content + else: + LoadingSaveFailed = true + return {} else: file.close() - return null + printerr("loading save failed") + if saveLoadTries < 3: + print("retrying") + saveLoadTries +=1 + return loadUserdata() + LoadingSaveFailed = true + return {} + +var playlistLoadTries:int func loadPlaylists(): var json = JSON.new() var file = FileAccess.open("user://playlistsLocation.dat", FileAccess.READ) @@ -626,8 +654,17 @@ func loadPlaylists(): print(filetext) #print("shit " + json.parse_string(filetext)) if file.get_as_text() != "" and file2.get_as_text() != "": - PlaylistsLocation = json.parse_string(file.get_as_text()) - Playlists = {} if json.parse_string(file2.get_as_text()) == null else json.parse_string(file2.get_as_text()) + var PlaylistsLocationTemp + var PlaylistsTemp + LoadingSaveFailed + PlaylistsLocationTemp = json.parse_string(file.get_as_text()) + PlaylistsTemp = json.parse_string(file2.get_as_text()) + if (PlaylistsTemp == null) or (PlaylistsLocationTemp == null): + printerr("Loading playlists failed") + LoadingSaveFailed = true + else: + Playlists = PlaylistsTemp + PlaylistsLocation = PlaylistsLocationTemp print(PlaylistsLocation) print(Playlists.keys()) print("Playlists") diff --git a/search_item.gd b/search_item.gd index 05b3b60..ba8c793 100644 --- a/search_item.gd +++ b/search_item.gd @@ -4,6 +4,8 @@ var SongName:String var CurrentlyPlaying:bool var idx:int @onready var songname: Button = $HBoxContainer/Songname +@onready var dropdown: Button = $HBoxContainer/Dropdown + signal PlayPressed signal DeletePressed @@ -14,12 +16,12 @@ func _ready() -> void: # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta: float) -> void: - pass + dropdown.visible = songname.is_hovered() or dropdown.is_hovered() func _on_songname_pressed() -> void: PlayPressed.emit(idx) -func _on_delete_pressed() -> void: - DeletePressed.emit(idx) +func _on_dropdown_pressed() -> void: + pass diff --git a/search_item.tscn b/search_item.tscn index ad9c71f..147032d 100644 --- a/search_item.tscn +++ b/search_item.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=3 format=3 uid="uid://ctqcbjrmxaqsk"] -[ext_resource type="Texture2D" uid="uid://cm5ps3a716wr0" path="res://XSmall.png" id="1_6wgd5"] [ext_resource type="Script" path="res://search_item.gd" id="1_j4126"] +[ext_resource type="Texture2D" uid="uid://dwvy6crqhardn" path="res://Dropdown.png" id="2_hicj1"] [node name="SearchItem" type="Control"] custom_minimum_size = Vector2(0, 30) @@ -17,23 +17,26 @@ size_flags_vertical = 4 script = ExtResource("1_j4126") [node name="HBoxContainer" type="HBoxContainer" parent="."] -custom_minimum_size = Vector2(700, 0) +custom_minimum_size = Vector2(700, 32) layout_mode = 1 anchors_preset = 4 anchor_top = 0.5 anchor_bottom = 0.5 -offset_top = -19.0 -offset_right = 50.0 -offset_bottom = 19.0 +offset_top = -16.0 +offset_right = 700.0 +offset_bottom = 16.0 grow_vertical = 2 +alignment = 1 -[node name="delete" type="Button" parent="HBoxContainer"] -modulate = Color(0.553478, 0.101429, 4.81308e-08, 1) +[node name="Dropdown" type="Button" parent="HBoxContainer"] +custom_minimum_size = Vector2(20, 0) layout_mode = 2 tooltip_text = "delete song from hard-drive" focus_mode = 0 -icon = ExtResource("1_6wgd5") +icon = ExtResource("2_hicj1") flat = true +icon_alignment = 1 +expand_icon = true [node name="Songname" type="Button" parent="HBoxContainer"] layout_mode = 2 @@ -42,5 +45,5 @@ focus_mode = 0 flat = true alignment = 0 -[connection signal="pressed" from="HBoxContainer/delete" to="." method="_on_delete_pressed"] +[connection signal="pressed" from="HBoxContainer/Dropdown" to="." method="_on_dropdown_pressed"] [connection signal="pressed" from="HBoxContainer/Songname" to="." method="_on_songname_pressed"]