diff --git a/assets/interfaces/buttons/add.png b/assets/interfaces/buttons/add.png new file mode 100644 index 0000000..a0b636c Binary files /dev/null and b/assets/interfaces/buttons/add.png differ diff --git a/assets/interfaces/buttons/del.png b/assets/interfaces/buttons/del.png new file mode 100644 index 0000000..0ad266b Binary files /dev/null and b/assets/interfaces/buttons/del.png differ diff --git a/assets/interfaces/buttons/down.png b/assets/interfaces/buttons/down.png new file mode 100644 index 0000000..8a264ae Binary files /dev/null and b/assets/interfaces/buttons/down.png differ diff --git a/assets/interfaces/buttons/up.png b/assets/interfaces/buttons/up.png new file mode 100644 index 0000000..7b82492 Binary files /dev/null and b/assets/interfaces/buttons/up.png differ diff --git a/assets/interfaces/jukebox/auto_off.png b/assets/interfaces/jukebox/auto_off.png new file mode 100644 index 0000000..5714808 Binary files /dev/null and b/assets/interfaces/jukebox/auto_off.png differ diff --git a/assets/interfaces/jukebox/auto_on.png b/assets/interfaces/jukebox/auto_on.png new file mode 100644 index 0000000..cf115f0 Binary files /dev/null and b/assets/interfaces/jukebox/auto_on.png differ diff --git a/assets/interfaces/jukebox/music_off.png b/assets/interfaces/jukebox/music_off.png new file mode 100644 index 0000000..f475809 Binary files /dev/null and b/assets/interfaces/jukebox/music_off.png differ diff --git a/assets/interfaces/jukebox/music_on.png b/assets/interfaces/jukebox/music_on.png new file mode 100644 index 0000000..15cb16f Binary files /dev/null and b/assets/interfaces/jukebox/music_on.png differ diff --git a/assets/interfaces/jukebox/mute.png b/assets/interfaces/jukebox/mute.png new file mode 100644 index 0000000..b5e4024 Binary files /dev/null and b/assets/interfaces/jukebox/mute.png differ diff --git a/assets/interfaces/jukebox/sound_off.png b/assets/interfaces/jukebox/sound_off.png new file mode 100644 index 0000000..b5e4024 Binary files /dev/null and b/assets/interfaces/jukebox/sound_off.png differ diff --git a/assets/interfaces/jukebox/sound_on.png b/assets/interfaces/jukebox/sound_on.png new file mode 100644 index 0000000..8da562d Binary files /dev/null and b/assets/interfaces/jukebox/sound_on.png differ diff --git a/assets/interfaces/jukebox/soundeffect_off.png b/assets/interfaces/jukebox/soundeffect_off.png new file mode 100644 index 0000000..129ff64 Binary files /dev/null and b/assets/interfaces/jukebox/soundeffect_off.png differ diff --git a/assets/interfaces/jukebox/soundeffect_on.png b/assets/interfaces/jukebox/soundeffect_on.png new file mode 100644 index 0000000..a0d27de Binary files /dev/null and b/assets/interfaces/jukebox/soundeffect_on.png differ diff --git a/locale/en.po b/locale/en.po index a6df706..0d51f7c 100644 --- a/locale/en.po +++ b/locale/en.po @@ -118,3 +118,39 @@ msgstr "Add" msgid "OPTION_SETTINGS_SOUND_SELECTION_DELETE" msgstr "Del" + +msgid "JUKEBOX_TITLE" +msgstr "JUKE BOX" + +msgid "JUKEBOX_PREVIOUS" +msgstr "Previous" + +msgid "JUKEBOX_PAUSE" +msgstr "Pause" + +msgid "JUKEBOX_PLAY" +msgstr "Play" + +msgid "JUKEBOX_NEXT" +msgstr "Next" + +msgid "JUKEBOX_SOUND_EFFECT" +msgstr "Sound effect" + +msgid "JUKEBOX_MUSIC" +msgstr "Music" + +msgid "JUKEBOX_AUTO" +msgstr "Music khanat (Auto) or your music" + +msgid "JUKEBOX_MUTE" +msgstr "Mute" + +msgid "OPTION_SETTINGS_SOUND_SELECT_DEVICE" +msgstr "Del" + +msgid "OPTION_TITLE" +msgstr "Settings" + +msgid "JUKEBOX_ADD" +msgstr "Add music(s)" diff --git a/locale/fr.po b/locale/fr.po index c739c0c..24c2b09 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -118,3 +118,39 @@ msgstr "Ajouter" msgid "OPTION_SETTINGS_SOUND_SELECTION_DELETE" msgstr "Supprimer" + +msgid "JUKEBOX_TITLE" +msgstr "JUKE BOX" + +msgid "JUKEBOX_PREVIOUS" +msgstr "Précédent" + +msgid "JUKEBOX_PAUSE" +msgstr "Pause" + +msgid "JUKEBOX_PLAY" +msgstr "Jouer" + +msgid "JUKEBOX_NEXT" +msgstr "Suivant" + +msgid "JUKEBOX_SOUND_EFFECT" +msgstr "Effet sonore" + +msgid "JUKEBOX_MUSIC" +msgstr "Musique" + +msgid "JUKEBOX_AUTO" +msgstr "Jouez votre musique" + +msgid "JUKEBOX_MUTE" +msgstr "Silence" + +msgid "OPTION_SETTINGS_SOUND_SELECT_DEVICE" +msgstr "Supprimer" + +msgid "OPTION_TITLE" +msgstr "Configuration" + +msgid "JUKEBOX_ADD" +msgstr "Ajouter une(des) musique(s)" diff --git a/locale/messages.mo b/locale/messages.mo index 9fa5282..eb17e2f 100644 Binary files a/locale/messages.mo and b/locale/messages.mo differ diff --git a/locale/messages.pot b/locale/messages.pot index 87c331f..5e266bf 100644 --- a/locale/messages.pot +++ b/locale/messages.pot @@ -110,3 +110,40 @@ msgstr "" msgid "OPTION_SETTINGS_SOUND_SELECTION_DELETE" msgstr "" +msgid "JUKEBOX_TITLE" +msgstr "" + +msgid "JUKEBOX_PREVIOUS" +msgstr "" + +msgid "JUKEBOX_PAUSE" +msgstr "" + +msgid "JUKEBOX_PLAY" +msgstr "" + +msgid "JUKEBOX_NEXT" +msgstr "" + +msgid "JUKEBOX_SOUND_EFFECT" +msgstr "" + +msgid "JUKEBOX_MUSIC" +msgstr "" + +msgid "JUKEBOX_AUTO" +msgstr "" + +msgid "JUKEBOX_MUTE" +msgstr "" + +msgid "OPTION_SETTINGS_SOUND_SELECT_DEVICE" +msgstr "" + +msgid "OPTION_TITLE" +msgstr "" + +msgid "JUKEBOX_ADD" +msgstr "" + + diff --git a/project.godot b/project.godot index bba0b02..c1a22db 100644 --- a/project.godot +++ b/project.godot @@ -82,8 +82,8 @@ Datas="*res://ressources/scripts/datas/data.gd" [debug] -gdscript/warnings/unused_variable=false -gdscript/warnings/unused_argument=false +gdscript/completion/autocomplete_setters_and_getters=true +gdscript/warnings/unused_class_variable=true gdscript/warnings/return_value_discarded=false [display] diff --git a/ressources/scripts/config/config.gd b/ressources/scripts/config/config.gd index 553be57..a66bfbd 100644 --- a/ressources/scripts/config/config.gd +++ b/ressources/scripts/config/config.gd @@ -20,25 +20,44 @@ var sound_lvl_music = 50 var sound_lvl_effect = 50 var sound_lvl_global = 50 var mute:bool = false +var playermusic:bool = false +var queuemusic = [] + +onready var rand = RandomNumberGenerator.new() + func msg_debug(text): if debug: var frame = get_stack()[1] print("DEBUG [%s:%d] %s" % [frame.source, frame.line, text] ) + func msg_info(text): var frame = get_stack()[1] print("INFO [%s:%d] %s" % [frame.source, frame.line, text] ) + func msg_error(text): var frame = get_stack()[1] print("ERROR [%s:%d] %s" % [frame.source, frame.line, text] ) + # Called when the node enters the scene tree for the first time. func _ready(): load_config() + rand.randomize() msg_debug("load end") + +func set_playermusic(state): + Config.msg_debug("player music:" + str(state)) + self.playermusic = state + #MusicManager.load_playlist() + #load_playlist + +func get_playermusic(): + return self.playermusic + func set_window_fullscreen(value: bool): #if ProjectSettings.has_setting( "display/window/size/fullscreen" ): # ProjectSettings.set_setting("display/window/size/fullscreen", value) @@ -46,6 +65,7 @@ func set_window_fullscreen(value: bool): if video_default == false: OS.window_fullscreen = window_fullscreen + func set_window_borderless(value: bool): #if ProjectSettings.has_setting( "display/window/size/borderless" ): # ProjectSettings.set_setting("display/window/size/borderless", value) @@ -53,13 +73,15 @@ func set_window_borderless(value: bool): if video_default == false: OS.window_borderless = window_borderless + func set_window_resizable(value: bool): #if ProjectSettings.has_setting( "display/window/size/resizable" ): # ProjectSettings.set_setting("display/window/size/resizable", value) - window_resizable = true + window_resizable = value if video_default == false: OS.window_resizable = window_resizable + func set_window_width(value: int): #if ProjectSettings.has_setting( "display/window/size/width" ): # ProjectSettings.set_setting("display/window/size/width", value) @@ -68,6 +90,7 @@ func set_window_width(value: int): OS.window_size.x = window_size_x #OS.window_fullscreen = ProjectSettings.get_setting("display/window/size/width") + func set_window_height(value: int): #if ProjectSettings.has_setting( "display/window/size/height" ): # ProjectSettings.set_setting("display/window/size/height", value) @@ -76,29 +99,35 @@ func set_window_height(value: int): OS.window_size.y = window_size_y #OS.window_fullscreen = ProjectSettings.get_setting("display/window/size/height") + func set_font_size(value: int): font_size = value if video_default == false: pass + func set_video_default(value): video_default = value + func set_window_always_on_top(value: bool): window_always_on_top = value if video_default == false: OS.set_window_always_on_top(window_always_on_top) + func set_current_screen(value: int): screen_number = int(value) if video_default == false: OS.current_screen = screen_number - + + func set_screen_orientation(value: int): if video_default == false: screen_orientation = int(value) OS.set_screen_orientation(screen_orientation) + func set_window_maximized(value: bool): if value: window_maximized = true @@ -107,6 +136,7 @@ func set_window_maximized(value: bool): if not video_default: OS.set_window_maximized(window_maximized) + func enable_window_default(): # display/window/handheld/orientation if ProjectSettings.has_setting( "display/window/handheld/orientation" ): @@ -144,6 +174,7 @@ func enable_window_default(): if ProjectSettings.has_setting( "display/window/size/resizable" ): OS.window_resizable = ProjectSettings.get_setting( "display/window/size/resizable" ) + func disable_window_default(): OS.set_screen_orientation(screen_orientation) OS.set_window_maximized(window_maximized) @@ -155,10 +186,12 @@ func disable_window_default(): OS.window_borderless = window_borderless OS.window_resizable = window_resizable + func set_sound_mute(value: bool): Config.msg_debug("mute:" + str(value)) mute = value + func save_config(): var config_file = ConfigFile.new() config_file.set_value( "theme", "font_size", 14 ) @@ -176,9 +209,16 @@ func save_config(): config_file.set_value( "sound", "music_level", sound_lvl_music ) config_file.set_value( "sound", "effect_level", sound_lvl_effect ) config_file.set_value( "sound", "mute", mute ) + config_file.set_value( "sound", "playermusic", playermusic ) + var posmusic = 0 + for child in queuemusic: + #Config.msg_debug("" + child ) + config_file.set_value( "playermusic", str(posmusic), child ) + posmusic += 1 config_file.save( SettingsFile ) #print("[res://ressources/scripts/config/config.gd] save_config") + func load_config(): var config_file = ConfigFile.new() var err = config_file.load( SettingsFile ) @@ -203,3 +243,8 @@ func load_config(): sound_lvl_music = config_file.get_value("sound", "music_level", 100) sound_lvl_effect = config_file.get_value("sound", "effect_level", 100) mute = config_file.get_value("sound", "mute", false) + playermusic = config_file.get_value("sound", "playermusic", false) + for key in config_file.get_section_keys( "playermusic" ): + var file = config_file.get_value( "playermusic", key, "" ) + # Config.msg_debug( "playermusic:" + key + " " + str(file) ) + queuemusic.append(file) diff --git a/ressources/scripts/creatures_old.gd b/ressources/scripts/creatures_old.gd index 2b64d91..58b3063 100644 --- a/ressources/scripts/creatures_old.gd +++ b/ressources/scripts/creatures_old.gd @@ -1,85 +1,85 @@ extends Node class Creature_old2: - - enum Sex { F, M, H, A, U } - - var type - var pseudonym - + + enum Sex { F, M, H, A, U } + + var type + var pseudonym + - func _init( p_pseudonym = "Créature" ): - self.type = "creature" - self.pseudonym = p_pseudonym - + func _init( p_pseudonym = "Créature" ): + self.type = "creature" + self.pseudonym = p_pseudonym + class Ra_old2 extends Creature_old2: - - - var sex = Creature_old2.Sex.F - - var female_boobs = 0.0 - var female_hip = 0.0 - var male_pack = 0.0 - var male_throat = 0.0 - var female_pregnant = 0.0 - - var color = Color( 1.0, 1.0, 1.0 ) - - var douleur = 0.0 - var trauma = 0.0 - var oubli = 0.0 - - func _init( p_pseudonym = "Créature" ): - self.type = "ra" - self.pseudonym = p_pseudonym + + + var sex = Creature_old2.Sex.F + + var female_boobs = 0.0 + var female_hip = 0.0 + var male_pack = 0.0 + var male_throat = 0.0 + var female_pregnant = 0.0 + + var color = Color( 1.0, 1.0, 1.0 ) + + var douleur = 0.0 + var trauma = 0.0 + var oubli = 0.0 + + func _init( p_pseudonym = "Créature" ): + self.type = "ra" + self.pseudonym = p_pseudonym - func to_dictionary(): - - var dictionary = Dictionary() - dictionary[ "type" ] = self.type - dictionary[ "pseudonym" ] = self.pseudonym - - dictionary[ "sex" ] = var2str( self.sex ) - dictionary[ "female_boobs" ] = var2str( self.female_boobs ) - dictionary[ "female_hip" ] = var2str( self.female_hip ) - dictionary[ "male_pack" ] = var2str( self.male_pack ) - dictionary[ "male_throat" ] = var2str( self.male_throat ) - dictionary[ "female_pregnant" ] = var2str( self.female_pregnant ) - - dictionary[ "color" ] = var2str( self.color ) + func to_dictionary(): + + var dictionary = Dictionary() + dictionary[ "type" ] = self.type + dictionary[ "pseudonym" ] = self.pseudonym + + dictionary[ "sex" ] = var2str( self.sex ) + dictionary[ "female_boobs" ] = var2str( self.female_boobs ) + dictionary[ "female_hip" ] = var2str( self.female_hip ) + dictionary[ "male_pack" ] = var2str( self.male_pack ) + dictionary[ "male_throat" ] = var2str( self.male_throat ) + dictionary[ "female_pregnant" ] = var2str( self.female_pregnant ) + + dictionary[ "color" ] = var2str( self.color ) - - return dictionary - - func from_dictionary( dictionary ): - - self.pseudonym = dictionary.get( "pseudonym", self.pseudonym ) - - self.sex = dictionary.get( "sex", self.sex ) - self.female_boobs = dictionary.get( "female_boobs", self.female_boobs ) - self.female_hip = dictionary.get( "female_hip", self.female_hip ) - self.male_pack = dictionary.get( "male_pack", self.male_pack ) - self.male_throat = dictionary.get( "male_throat", self.male_throat ) - self.female_pregnant = dictionary.get( "female_pregnant", self.female_pregnant ) - - self.color = dictionary.get( "color", self.color ) + + return dictionary + + func from_dictionary( dictionary ): + + self.pseudonym = dictionary.get( "pseudonym", self.pseudonym ) + + self.sex = dictionary.get( "sex", self.sex ) + self.female_boobs = dictionary.get( "female_boobs", self.female_boobs ) + self.female_hip = dictionary.get( "female_hip", self.female_hip ) + self.male_pack = dictionary.get( "male_pack", self.male_pack ) + self.male_throat = dictionary.get( "male_throat", self.male_throat ) + self.female_pregnant = dictionary.get( "female_pregnant", self.female_pregnant ) + + self.color = dictionary.get( "color", self.color ) - func from_file( filename ): - var file = File.new() - if file.file_exists( "user://creatures/" + filename ): - file.open( "user://creatures/" + filename, File.READ ) - var lines = "" - while not file.eof_reached(): - var current_line = file.get_line() - lines += current_line - var json = JSON.parse( lines ).result - var dict = {} - for data in json: - dict[ data ] = str2var( json[data] ) - + func from_file( filename ): + var file = File.new() + if file.file_exists( "user://creatures/" + filename ): + file.open( "user://creatures/" + filename, File.READ ) + var lines = "" + while not file.eof_reached(): + var current_line = file.get_line() + lines += current_line + var json = JSON.parse( lines ).result + var dict = {} + for data in json: + dict[ data ] = str2var( json[data] ) + - self.from_dictionary( dict ) - - file.close() + self.from_dictionary( dict ) + + file.close() diff --git a/scenes/connection/connection.gd b/scenes/connection/connection.gd index 21a1d77..0aa0764 100644 --- a/scenes/connection/connection.gd +++ b/scenes/connection/connection.gd @@ -4,31 +4,31 @@ signal connection_ok signal connection_error( message ) func do_request(username, password): - var message = load("res://ressources/scripts/nel/nel_login_message.gd") - if message: - message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en"); - # $http_request.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string()); - $http_request.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string()); + var message = load("res://ressources/scripts/nel/nel_login_message.gd") + if message: + message = message.nel_login_message.new("https-login", username, password, "Lirria", "2", "en"); + # $http_request.request("http://lirria.khaganat.net/login/r2_login.php?" + message.get_request_string()); + $http_request.request("http://149.91.80.160/login/r2_login.php?" + message.get_request_string()); func _make_post_request(url, data_to_send, use_ssl): - # Convert data to json string: - var query = JSON.print(data_to_send) - # Add 'Content-Type' header: - var headers = ["Content-Type: application/json"] - $http_request.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query) + # Convert data to json string: + var query = JSON.print(data_to_send) + # Add 'Content-Type' header: + var headers = ["Content-Type: application/json"] + $http_request.request(url, headers, use_ssl, HTTPClient.METHOD_POST, query) func _on_http_request_request_completed(result, response_code, headers, body): - print( response_code ) - if ProjectSettings.get_setting("khanat/debug_mode"): - emit_signal( "connection_ok" ) - elif not response_code == 200: - emit_signal( "connection_error", "Erreur de connexion." ) - else: - var s = body.get_string_from_utf8().split(":") - if(s[0] != "0"): - var server_info_script = load("res://ressources/scripts/nel/nel_server_infos.gd"); - var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8()); - emit_signal( "connection_ok" ) - # No error so login was successful. + print( response_code ) + if ProjectSettings.get_setting("khanat/debug_mode"): + emit_signal( "connection_ok" ) + elif not response_code == 200: + emit_signal( "connection_error", "Erreur de connexion." ) + else: + var s = body.get_string_from_utf8().split(":") + if(s[0] != "0"): + var server_info_script = load("res://ressources/scripts/nel/nel_server_infos.gd"); + var server_info = server_info_script.nel_server_info.new(body.get_string_from_utf8()); + emit_signal( "connection_ok" ) + # No error so login was successful. diff --git a/scenes/interfaces/main_menu/main_menu.gd b/scenes/interfaces/main_menu/main_menu.gd index ade662c..38cb51a 100644 --- a/scenes/interfaces/main_menu/main_menu.gd +++ b/scenes/interfaces/main_menu/main_menu.gd @@ -17,7 +17,7 @@ func _on_control_quit_pressed(): emit_signal( "quit_pressed" ) func _on_control_mute_pressed(): - #Config.msg_debug("") + Config.msg_debug("_on_control_mute_pressed") #emit_signal( "mute_pressed" ) pass diff --git a/scenes/interfaces/music_manager/music_button.gd b/scenes/interfaces/music_manager/music_button.gd index e803443..cfd95a5 100644 --- a/scenes/interfaces/music_manager/music_button.gd +++ b/scenes/interfaces/music_manager/music_button.gd @@ -1,8 +1,54 @@ -extends Button +extends Node signal music_selected( filename ) +signal del_pressed(slot) +signal down_pressed(slot) +signal up_pressed(slot) + +var id = 0 + +func set_music(_filename, _id): + $musicplayer.text = _filename + self.id = _id + + +func set_disabled(): + $musicplayer.disabled = true + + +func set_play(): + $musicplayer.disabled = true + + +func set_unplay(): + $musicplayer.disabled = false + + +func get_music(): + return $musicplayer.text + + +func get_id(): + return self.id -var music_filename = "" func _on_music_button_pressed(): - emit_signal( "music_selected", self.music_filename ) + emit_signal( "music_selected", $musicplayer.text ) + + +func _on_music_button_music_selected(filename): + Config.msg_debug(filename) + MusicManager.play_music(filename) + pass # Replace with function body. + + +func _on_down_pressed(): + emit_signal( "down_pressed", self.id ) + + +func _on_up_pressed(): + emit_signal( "up_pressed", self.id ) + + +func _on_del_pressed(): + emit_signal( "del_pressed", self.id ) diff --git a/scenes/interfaces/music_manager/music_button.tscn b/scenes/interfaces/music_manager/music_button.tscn index 32d0b64..d7b5e88 100644 --- a/scenes/interfaces/music_manager/music_button.tscn +++ b/scenes/interfaces/music_manager/music_button.tscn @@ -1,13 +1,63 @@ -[gd_scene load_steps=2 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://scenes/interfaces/music_manager/music_button.gd" type="Script" id=1] +[ext_resource path="res://assets/interfaces/buttons/del.png" type="Texture" id=2] +[ext_resource path="res://assets/interfaces/buttons/down.png" type="Texture" id=3] +[ext_resource path="res://assets/interfaces/buttons/up.png" type="Texture" id=4] -[node name="music_button" type="Button"] -margin_right = 12.0 -margin_bottom = 20.0 +[node name="music_button" type="HBoxContainer"] +margin_right = 150.0 +size_flags_horizontal = 3 +size_flags_vertical = 3 script = ExtResource( 1 ) __meta__ = { "_edit_use_anchors_": false } -[connection signal="pressed" from="." to="." method="_on_music_button_pressed"] +[node name="up" type="TextureButton" parent="."] +margin_top = 2.0 +margin_right = 16.0 +margin_bottom = 18.0 +size_flags_vertical = 6 +texture_normal = ExtResource( 4 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="down" type="TextureButton" parent="."] +margin_left = 20.0 +margin_top = 2.0 +margin_right = 36.0 +margin_bottom = 18.0 +size_flags_vertical = 6 +texture_normal = ExtResource( 3 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="musicplayer" type="Button" parent="."] +margin_left = 40.0 +margin_right = 130.0 +margin_bottom = 20.0 +size_flags_horizontal = 3 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="del" type="TextureButton" parent="."] +margin_left = 134.0 +margin_top = 2.0 +margin_right = 150.0 +margin_bottom = 18.0 +size_flags_horizontal = 8 +size_flags_vertical = 6 +texture_normal = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[connection signal="music_selected" from="." to="." method="_on_music_button_music_selected"] +[connection signal="pressed" from="up" to="." method="_on_up_pressed"] +[connection signal="pressed" from="down" to="." method="_on_down_pressed"] +[connection signal="pressed" from="musicplayer" to="." method="_on_music_button_pressed"] +[connection signal="pressed" from="del" to="." method="_on_del_pressed"] diff --git a/scenes/interfaces/music_manager/music_manager.gd b/scenes/interfaces/music_manager/music_manager.gd index d59945e..0ec0b34 100644 --- a/scenes/interfaces/music_manager/music_manager.gd +++ b/scenes/interfaces/music_manager/music_manager.gd @@ -1,37 +1,31 @@ extends WindowDialog -onready var audio_player = $music +signal mute_pressed +signal musicplayer_pressed + + +onready var music_player = $music + +var playlist_music = { 'player': [], 'global': ["res://assets/musics/sangakanat_ames_voyageuses.ogg"] } +var lastdomain = "global" +var currentmusic = "" + +var numberchannelplayeraudio = 1 +var cacheplayeraudio = [] +var music_play = false +var bus = "master" +var next_id = 0 +var pause = false +var disable_execution_mute:bool = false +var playback_position_before_pause = 0 +var last_update_playermusic = false -func load_external_music(filepath): - var stream = null - Config.msg_debug("") - var file = File.new() - file.open(filepath, file.READ) - var ext = filepath.split(".")[-1].to_lower() - var buffer = file.get_buffer(file.get_len()) - Config.msg_debug(ext) - match ext: - "ogg": - stream = AudioStreamOGGVorbis.new() - "mp3": - stream = AudioStreamMP3.new() - #"wav": - # # We need decode message to get format - # stream = AudioStreamSample.new() - # stream.format = AudioStreamSample.FORMAT_16_BITS - # #stream.stereo = true - _: - Config.msg_error("Impossible to identify type of file (file:" + filepath + ", ext:" + ext + ")") - return - stream.data = buffer - audio_player.stream = stream - Config.msg_debug("") func _ready(): var directory = Directory.new() get_tree().paused = false - Config.msg_debug("") - + Config.msg_debug("Load MusicManager") + self.last_update_playermusic = Config.get_playermusic() if not directory.dir_exists( "user://musics/" ): directory.make_dir_recursive( "user://musics/" ) directory.open( "user://musics/" ) @@ -44,74 +38,475 @@ func _ready(): elif not file.begins_with(".") and not directory.current_is_dir() and not file.ends_with( ".import" ): files.append(file) directory.list_dir_end() - - for file in files: - var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance() - button.music_filename = "res://assets/musics/" + file - button.text = file - button.connect( "music_selected", self, "_on_music_pressed" ) - $window_box/scroll_box/musics_box.add_child( button ) - - audio_player.stream = load( "res://assets/musics/sangakanat_ames_voyageuses.ogg" ) - #add_music(audio_player) - #audio_player.set_volume_db(linear2db(0.5)) - #audio_player.set_volume_db(1.0) - audio_player.play() - #audio_player.set_volume_db(1.0) - #audioPlayer.play() +# for file in files: +# var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance() +# button.music_filename = "res://assets/musics/" + file +# button.text = file +# button.connect( "music_selected", self, "_on_music_pressed" ) +# $window_box/scroll_box/musics_box.add_child( button ) + for file in Config.queuemusic: +# # Config.msg_debug(str(file)) + add_music( file ) update_volume_db() - Config.msg_debug("Load End") + #musicplayer = AudioStreamPlayer.new() + #self.add_child(music_player) + # update_playermusic() + if Config.mute: + set_mute_on() + else: + set_mute_off() + music_player.connect("finished", self, "_on_stream_finished", []) + + +func connect_ext( signal_name, target ): + Config.msg_debug("Connect external [signal:" + signal_name + ", func:" + "_on_signal_" + signal_name + "]") + target.connect( signal_name, self, "_on_signal_" + signal_name ) + + +func _on_stream_finished(): + # When finished playing a stream, make the player available again. + Config.msg_debug("_on_stream_finished") + music_play = false + + +func play_music(filename: String): + Config.msg_debug("path:" + str(filename)) + music_player.stream = load_music( filename ) + music_player.play() + currentmusic = filename + music_play = true + for child in $window_box/scroll_box/musics_box.get_children(): + if Config.mute: + child.set_disabled() + elif child.get_music() == filename or not Config.playermusic : + child.set_play() + else: + child.set_unplay() + + +func load_playlist(): + Config.msg_debug("load_playlist") + var domain="global" + var pos = 0 + var posmusic = -1 +# if Config.mute: +# if music_play: +# Config.msg_debug("mute") +# music_player.set_pause_mode(true) +# return + if music_play: + music_player.set_pause_mode(false) + # music_player.queue_free() + if Config.playermusic: + domain="player" + if domain != lastdomain: + Config.msg_debug("Change domain:" + domain) + currentmusic = "" + posmusic = -1 + lastdomain = domain + if len(playlist_music[domain]) == 0: + Config.msg_debug("No musique on" + domain) + music_player.stop() + return + for path in playlist_music[domain]: + if Config.playermusic: + if currentmusic == path.get_music(): + posmusic = pos + Config.msg_debug("Change domain:" + domain + " posmusic:" + str(posmusic)) + break + else: + if currentmusic == path: + posmusic = pos + Config.msg_debug("Change domain:" + domain + " posmusic:" + str(posmusic)) + break + pos += 1 + Config.msg_debug("Change domain:" + domain + " posmusic" + str(posmusic)) + if posmusic == -1: + posmusic = 0 + Config.msg_debug("init:" + str(posmusic) + " / " + str(len(playlist_music[domain]))) + else: + posmusic = (posmusic + 1) % len(playlist_music[domain]) + Config.msg_debug("next:" + str(posmusic)) + var path = playlist_music[domain][posmusic] + if Config.playermusic: + currentmusic = path.get_music() + else: + currentmusic = path + play_music(currentmusic) +# Config.msg_debug("path:" + str(currentmusic)) +# music_player.stream = load_music( currentmusic ) +# music_player.play() +# play_music = true + #audio_player.add_child() + + +func _process(_delta): + if not pause and not music_play and not Config.mute: + Config.msg_debug("next") + load_playlist() +# music_player.stream = load_music(queuemusic.pop_front()) +# music_player.play() +# music_play = true + + +func load_external_music(filepath): + var stream = null + Config.msg_debug("load_external_music") + var file = File.new() + file.open(filepath, file.READ) + var ext = filepath.split(".")[-1].to_lower() + var buffer = file.get_buffer(file.get_len()) + Config.msg_debug(ext) + match ext: + "ogg": + stream = AudioStreamOGGVorbis.new() + "mp3": + stream = AudioStreamMP3.new() + #"wav": + # # We need decode message to get format (Stero/size bit/ ... + # stream = AudioStreamSample.new() + # stream.format = AudioStreamSample.FORMAT_16_BITS + # #stream.stereo = true + _: + Config.msg_error("Impossible to identify type of file (file:" + filepath + ", ext:" + ext + ")") + return + stream.data = buffer + Config.msg_debug("load_external_music : End") + return stream + + +func load_music(filepath: String): + if filepath.left(5) == "res:/": + return load( filepath ) + return load_external_music(filepath) + + +func reinitialize(): + pass + + +func play_next_music(stream): + Config.msg_debug("play_next_music") + func update_volume_db(): + Config.msg_debug("update_volume_db") if Config.mute: - audio_player.set_volume_db(linear2db(0.0)) - audio_player.set_pause_mode(true) + music_player.set_volume_db(linear2db(0.0)) + music_player.set_pause_mode(true) + #update_playermusic() return var lvl = Config.sound_lvl_global * Config.sound_lvl_music / 10000.0 - audio_player.set_volume_db(linear2db(lvl)) - audio_player.set_pause_mode(false) + music_player.set_volume_db(linear2db(lvl)) + music_player.set_pause_mode(false) + #update_playermusic() + func set_sound_mute(value: bool): + Config.msg_debug("set_sound_mute") Config.set_sound_mute(value) update_volume_db() + Config.save_config() + func set_level_global(value: int): + Config.msg_debug("set_level_global") Config.sound_lvl_global = value update_volume_db() + func set_level_music(value: int): + Config.msg_debug("set_level_music") Config.sound_lvl_music = value update_volume_db() - + + func set_level_effect(value: int): + Config.msg_debug("set_level_effect") Config.sound_lvl_effect = value update_volume_db() - -func add_music(file): - var button = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance() - button.music_filename = file - button.text = file - button.connect( "music_selected", self, "_on_music_pressed" ) - $window_box/scroll_box/musics_box.add_child( button ) + + +func clear_music(): + pass + + +func load_music_to_config(): + Config.msg_debug("load_music_to_config") + Config.queuemusic = [] + for child in $window_box/scroll_box/musics_box.get_children(): + Config.queuemusic.append( child.get_music() ) + Config.save_config() + + +func add_music(file: String): + var music_box = preload( "res://scenes/interfaces/music_manager/music_button.tscn" ).instance() + music_box.set_music( file, self.next_id ) + music_box.connect( "del_pressed", self, "_on_music_box_delete_pressed" ) + music_box.connect( "down_pressed", self, "_on_music_box_down_pressed" ) + music_box.connect( "up_pressed", self, "_on_music_box_up_pressed" ) + $window_box/scroll_box/musics_box.add_child( music_box ) + self.next_id += 1 + playlist_music['player'] = $window_box/scroll_box/musics_box.get_children() + load_music_to_config() + + +func _on_music_box_delete_pressed( id ): + Config.msg_debug("_on_music_box_delete_pressed") + for child in $window_box/scroll_box/musics_box.get_children(): + if child.id == id: + child.queue_free() + + +func _on_music_box_down_pressed( id ): + Config.msg_debug("_on_music_box_down_pressed") + var pos = 0 + for child in $window_box/scroll_box/musics_box.get_children(): + if child.id == id: + break + pos += 1 + if pos >= $window_box/scroll_box/musics_box.get_child_count(): + Config.msg_error("Out of range : " + "pos:" + str(pos) + " count:" + str($window_box/scroll_box/musics_box.get_child_count())) + return + self.move_child_id(id, pos + 1) + + +func _on_music_box_up_pressed( id ): + Config.msg_debug("_on_music_box_up_pressed") + var pos = 0 + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_id() == id: + break + pos += 1 + if pos <= 0: + Config.msg_error("Out of range : " + "pos:" + str(pos)) + return + self.move_child_id(id, pos - 1) + + +func move_child(music_filename, pos): + var ele = null + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_music() == music_filename: + ele = child + break + if ele: + $window_box/scroll_box/musics_box.move_child(ele, pos) + playlist_music['player'] = $window_box/scroll_box/musics_box.get_children() + + +func move_child_id(id, pos): + var ele = null + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_id() == id: + ele = child + break + if ele: + $window_box/scroll_box/musics_box.move_child(ele, pos) + playlist_music['player'] = $window_box/scroll_box/musics_box.get_children() + load_music_to_config() + func open(): + Config.msg_debug("Open") + update_playermusic() self.popup() - + + func close(): + Config.msg_debug("Close") self.hide() - + + func toggle(): + Config.msg_debug("toggle") if self.visible: self.close() else: self.open() -func _on_music_pressed( p_filename ): +func _on_music_pressed(): + Config.msg_debug("Music") + + +func _on_music_bis_pressed( p_filename ): Config.msg_debug(p_filename) - #audio_player.stream = load( p_filename ) - #audio_player.set_volume_db(1.0) - #audio_player.play() - - #$music.stream = load( p_filename ) - #$music.play() + + +func _on_previous_pressed(): + Config.msg_debug("Previous") + var previous = null + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_music() == currentmusic: + if previous != null: + pause = false + play_music(previous.get_music()) + return + previous = child + + +func _on_pause_pressed(): + Config.msg_debug("Pause") + if pause: + return + pause = true + playback_position_before_pause = music_player.get_playback_position( ) + #music_player.stop() + + +func _on_play_pressed(): + Config.msg_debug("Play") + if not pause: + return + music_player.play(playback_position_before_pause) + pause = false + + +func _on_next_pressed(): + Config.msg_debug("Next") + var detected = false + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_music() == currentmusic: + detected = true + break + if detected: + pause = false + play_music(child.get_music()) + return + + +func _on_sound_pressed(): + Config.msg_debug("Music") + + +func _on_soundeffect_pressed(): + Config.msg_debug("Sound Effect") + + +func _on_auto_pressed(): + Config.msg_debug("Auto") + Config.set_playermusic(not Config.get_playermusic()) + Config.save_config() + emit_signal( "musicplayer_pressed" ) + + +func _on_mute_toggled(button_pressed): + Config.msg_debug("Mute") + MusicManager.set_sound_mute(button_pressed) + emit_signal( "mute_pressed" ) + + +func _on_mute_pressed(): + Config.msg_debug("Button JukeBox Mute") + MusicManager.set_sound_mute(not Config.mute) + emit_signal( "mute_pressed" ) + + +func set_playermusic_on(): + Config.msg_debug("playermusic on") + $window_box/controls_box/h_box_container_3/auto.texture_normal = load ( "res://assets/interfaces/jukebox/auto_on.png") + + +func set_playermusic_off(): + Config.msg_debug("playermusic off") + $window_box/controls_box/h_box_container_3/auto.texture_normal = load ( "res://assets/interfaces/jukebox/auto_off.png") + Config.msg_debug("playermusic off : End") + + +func set_mute_on(): + Config.msg_debug("mute on") + self.disable_execution_mute = true + $window_box/controls_box/h_box_container/mute.texture_normal = load ( "res://assets/interfaces/jukebox/sound_off.png") + self.disable_execution_mute = false + + +func set_mute_off(): + Config.msg_debug("mute off") + self.disable_execution_mute = true + $window_box/controls_box/h_box_container/mute.texture_normal = load ( "res://assets/interfaces/jukebox/sound_on.png") + self.disable_execution_mute = false + + +func _on_add_pressed(): + Config.msg_debug("") + $file_dialog.show() + + +func _on_file_dialog_files_selected(paths): + Config.msg_debug("multi files") + #if self.slots_number > 0: + # self.slots[self.slots_number - 1].disable_down() + for path in paths: + var found = false + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_music() == path: + found = true + break + if found: + continue + Config.msg_debug("file: "+ path) + MusicManager.add_music(path) + self.next_id += 1 + self.open() + + +func update_playermusic(): + Config.msg_debug("update_playermusic") + if Config.get_playermusic(): + #Config.msg_debug("update_playermusic: player music") + set_playermusic_on() + for child in $window_box/scroll_box/musics_box.get_children(): + if child.get_music() == currentmusic: + #Config.msg_debug("update_playermusic: player music : on " + child.get_music()) + child.set_play() + elif Config.mute: + child.set_disabled() + else: + #Config.msg_debug("update_playermusic: player music : off " + child.get_music()) + child.set_unplay() + else: + #Config.msg_debug("update_playermusic: khanat music") + set_playermusic_off() + for child in $window_box/scroll_box/musics_box.get_children(): + child.set_disabled() + if last_update_playermusic != Config.get_playermusic(): + Config.msg_debug("*** last_update_playermusic different ***") + load_playlist() + last_update_playermusic = Config.get_playermusic() + Config.msg_debug("update_playermusic : End") + + +func _on_check_button_toggled(button_pressed): + Config.msg_debug("_on_check_button_toggled") + #Config.set_playermusic(not Config.get_playermusic()) + Config.set_playermusic(button_pressed) + emit_signal( "musicplayer_toggled" , not Config.playermusic ) + + +func _on_music_manager_musicplayer_pressed(): + Config.msg_debug("Signal musicplayer_pressed recieved on MusicManager") + update_playermusic() + + +func _on_music_manager_mute_pressed(): + Config.msg_debug("Signal mute_pressed") + update_playermusic() + if Config.mute: + set_mute_on() + else: + set_mute_off() + + +func _on_signal_mute_pressed(): + Config.msg_debug(" Received signal mute") + update_playermusic() + if Config.mute: + set_mute_on() + else: + set_mute_off() + + +func _on_signal_musicplayer_pressed(): + Config.msg_debug(" Received signal musicplayer") + update_playermusic() diff --git a/scenes/interfaces/music_manager/music_manager.tscn b/scenes/interfaces/music_manager/music_manager.tscn index 38e4f4a..22ff3be 100644 --- a/scenes/interfaces/music_manager/music_manager.tscn +++ b/scenes/interfaces/music_manager/music_manager.tscn @@ -1,29 +1,48 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=11 format=2] [ext_resource path="res://assets/interfaces/music_manager/play.png" type="Texture" id=1] [ext_resource path="res://assets/interfaces/music_manager/previous.png" type="Texture" id=2] [ext_resource path="res://assets/interfaces/music_manager/next.png" type="Texture" id=3] [ext_resource path="res://assets/interfaces/music_manager/pause.png" type="Texture" id=4] [ext_resource path="res://scenes/interfaces/music_manager/music_manager.gd" type="Script" id=5] +[ext_resource path="res://assets/interfaces/jukebox/soundeffect_on.png" type="Texture" id=6] +[ext_resource path="res://assets/interfaces/jukebox/music_on.png" type="Texture" id=7] +[ext_resource path="res://assets/interfaces/jukebox/sound_on.png" type="Texture" id=8] +[ext_resource path="res://assets/interfaces/jukebox/auto_on.png" type="Texture" id=9] +[ext_resource path="res://assets/interfaces/buttons/add.png" type="Texture" id=10] [node name="music_manager" type="WindowDialog"] -anchor_left = 0.5 -anchor_top = 0.5 -anchor_right = 0.5 -anchor_bottom = 0.5 -margin_left = -64.0 -margin_top = -64.0 -margin_right = 64.0 -margin_bottom = 64.0 +anchor_left = 0.45 +anchor_top = 0.411 +anchor_right = 0.817 +anchor_bottom = 0.651 +margin_top = 0.0799866 +margin_right = 0.23999 +margin_bottom = 0.279968 rect_min_size = Vector2( 256, 128 ) -popup_exclusive = true -window_title = "Juke box" +window_title = "JUKEBOX_TITLE" resizable = true script = ExtResource( 5 ) __meta__ = { "_edit_use_anchors_": false } +[node name="file_dialog" type="FileDialog" parent="."] +margin_right = 538.0 +margin_bottom = 326.0 +popup_exclusive = true +window_title = "Ouvrir un ou plusieurs fichiers" +resizable = true +mode = 1 +access = 2 +filters = PoolStringArray( "*.mp3,*.ogg" ) +show_hidden_files = true +current_dir = "/home/aleajactaest/Projets/khanat/khanat-client-new" +current_path = "/home/aleajactaest/Projets/khanat/khanat-client-new/" +__meta__ = { +"_edit_use_anchors_": false +} + [node name="window_box" type="VBoxContainer" parent="."] anchor_right = 1.0 anchor_bottom = 1.0 @@ -32,45 +51,126 @@ __meta__ = { } [node name="controls_box" type="HBoxContainer" parent="window_box"] -margin_left = 90.0 -margin_right = 166.0 +margin_right = 470.0 +margin_bottom = 16.0 +size_flags_horizontal = 3 + +[node name="h_box_container_4" type="HBoxContainer" parent="window_box/controls_box"] +margin_right = 152.0 +margin_bottom = 16.0 +size_flags_horizontal = 7 + +[node name="add" type="TextureButton" parent="window_box/controls_box/h_box_container_4"] +margin_left = 68.0 +margin_right = 84.0 +margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_ADD" +size_flags_horizontal = 6 +texture_normal = ExtResource( 10 ) + +[node name="h_box_container" type="HBoxContainer" parent="window_box/controls_box"] +margin_left = 224.0 +margin_right = 240.0 margin_bottom = 16.0 size_flags_horizontal = 6 -[node name="previous" type="TextureButton" parent="window_box/controls_box"] +[node name="mute" type="TextureButton" parent="window_box/controls_box/h_box_container"] margin_right = 16.0 margin_bottom = 16.0 -texture_normal = ExtResource( 2 ) +hint_tooltip = "JUKEBOX_MUTE" +size_flags_horizontal = 5 +texture_normal = ExtResource( 8 ) +__meta__ = { +"_edit_use_anchors_": false +} -[node name="pause" type="TextureButton" parent="window_box/controls_box"] +[node name="h_box_container_2" type="HBoxContainer" parent="window_box/controls_box"] +margin_left = 313.0 +margin_right = 313.0 +margin_bottom = 16.0 + +[node name="previous" type="TextureButton" parent="window_box/controls_box/h_box_container_2"] +visible = false +margin_right = 16.0 +margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_PREVIOUS" +texture_normal = ExtResource( 2 ) +__meta__ = { +"_editor_description_": "" +} + +[node name="pause" type="TextureButton" parent="window_box/controls_box/h_box_container_2"] +visible = false +margin_right = 16.0 +margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_PAUSE" +texture_normal = ExtResource( 4 ) + +[node name="play" type="TextureButton" parent="window_box/controls_box/h_box_container_2"] +visible = false +margin_right = 16.0 +margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_PLAY" +texture_normal = ExtResource( 1 ) + +[node name="next" type="TextureButton" parent="window_box/controls_box/h_box_container_2"] +visible = false margin_left = 20.0 margin_right = 36.0 margin_bottom = 16.0 -texture_normal = ExtResource( 4 ) - -[node name="play" type="TextureButton" parent="window_box/controls_box"] -margin_left = 40.0 -margin_right = 56.0 -margin_bottom = 16.0 -texture_normal = ExtResource( 1 ) - -[node name="next" type="TextureButton" parent="window_box/controls_box"] -margin_left = 60.0 -margin_right = 76.0 -margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_NEXT" texture_normal = ExtResource( 3 ) +[node name="h_box_container_3" type="HBoxContainer" parent="window_box/controls_box"] +margin_left = 385.0 +margin_right = 401.0 +margin_bottom = 16.0 +size_flags_horizontal = 6 + +[node name="soundeffect" type="TextureButton" parent="window_box/controls_box/h_box_container_3"] +visible = false +margin_right = 16.0 +margin_bottom = 40.0 +hint_tooltip = "JUKEBOX_SOUND_EFFECT" +texture_normal = ExtResource( 6 ) + +[node name="music" type="TextureButton" parent="window_box/controls_box/h_box_container_3"] +visible = false +margin_right = 16.0 +margin_bottom = 40.0 +hint_tooltip = "JUKEBOX_MUSIC" +texture_normal = ExtResource( 7 ) + +[node name="auto" type="TextureButton" parent="window_box/controls_box/h_box_container_3"] +margin_right = 16.0 +margin_bottom = 16.0 +hint_tooltip = "JUKEBOX_AUTO" +texture_normal = ExtResource( 9 ) + [node name="scroll_box" type="ScrollContainer" parent="window_box"] margin_top = 20.0 -margin_right = 256.0 -margin_bottom = 128.0 +margin_right = 470.0 +margin_bottom = 173.0 size_flags_horizontal = 3 size_flags_vertical = 3 [node name="musics_box" type="VBoxContainer" parent="window_box/scroll_box"] -margin_left = 128.0 -margin_right = 128.0 -size_flags_horizontal = 6 -size_flags_vertical = 2 +margin_right = 470.0 +margin_bottom = 153.0 +size_flags_horizontal = 7 +size_flags_vertical = 3 [node name="music" type="AudioStreamPlayer" parent="."] + +[connection signal="musicplayer_pressed" from="." to="." method="_on_music_manager_musicplayer_pressed"] +[connection signal="mute_pressed" from="." to="." method="_on_music_manager_mute_pressed"] +[connection signal="files_selected" from="file_dialog" to="." method="_on_file_dialog_files_selected"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_4/add" to="." method="_on_add_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container/mute" to="." method="_on_mute_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_2/previous" to="." method="_on_previous_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_2/pause" to="." method="_on_pause_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_2/play" to="." method="_on_play_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_2/next" to="." method="_on_next_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_3/soundeffect" to="." method="_on_soundeffect_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_3/music" to="." method="_on_music_pressed"] +[connection signal="pressed" from="window_box/controls_box/h_box_container_3/auto" to="." method="_on_auto_pressed"] diff --git a/scenes/interfaces/options/option_info.gd b/scenes/interfaces/options/option_info.gd index fac0803..95a685c 100644 --- a/scenes/interfaces/options/option_info.gd +++ b/scenes/interfaces/options/option_info.gd @@ -18,12 +18,10 @@ func read_license(key): return true return false + func load_license(): var current_locale = TranslationServer.get_locale() var root_language = current_locale.split('_')[0] - var file = File.new() - var filenews = "" - if read_license(current_locale): pass elif read_license(root_language): @@ -31,6 +29,7 @@ func load_license(): elif read_license(""): pass + func read_authors(key): var file = File.new() var filenews = "" @@ -51,16 +50,13 @@ func read_authors(key): func load_authors(): var current_locale = TranslationServer.get_locale() var root_language = current_locale.split('_')[0] - var file = File.new() - var filenews = "" - if read_authors(current_locale): pass elif read_authors(root_language): pass elif read_authors(""): pass - + # Called when the node enters the scene tree for the first time. func _ready(): diff --git a/scenes/interfaces/options/option_language.gd b/scenes/interfaces/options/option_language.gd index e776457..80214f0 100644 --- a/scenes/interfaces/options/option_language.gd +++ b/scenes/interfaces/options/option_language.gd @@ -34,12 +34,10 @@ func _ready(): func _on_option_button_item_selected(index): - var id = 0 for key in TranslationServer.get_loaded_locales(): - if id == $window_dialog/margin_container/v_box_container/option_button.get_selected(): + if index == $window_dialog/margin_container/v_box_container/option_button.get_selected(): TranslationServer.set_locale(key) return - id += 1 func _on_button_pressed(): diff --git a/scenes/interfaces/options/option_news.gd b/scenes/interfaces/options/option_news.gd index e95436d..68f2557 100644 --- a/scenes/interfaces/options/option_news.gd +++ b/scenes/interfaces/options/option_news.gd @@ -28,9 +28,6 @@ func read_news(key): func load_news(): var current_locale = TranslationServer.get_locale() var root_language = current_locale.split('_')[0] - var file = File.new() - var filenews = "" - if read_news(current_locale): pass elif read_news(root_language): diff --git a/scenes/interfaces/options/option_settings.gd b/scenes/interfaces/options/option_settings.gd index baaa5b2..4aac741 100644 --- a/scenes/interfaces/options/option_settings.gd +++ b/scenes/interfaces/options/option_settings.gd @@ -1,10 +1,15 @@ extends Control signal mute_pressed +signal musicplayer_pressed -var slots_number = 0 -var slots = {} +onready var audiodevice_list = get_node("window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice") + +#var slots_number = 0 +#var slots = {} var firstime = false +var disable_execution_mute:bool = false + # Called when the node enters the scene tree for the first time. func _ready(): @@ -62,23 +67,48 @@ func _ready(): # Mute #$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute update_mute() + # List audio device + for item in AudioServer.get_device_list(): + $window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice.add_item(item) + #audiodevice_list.add_item(item) + var device = AudioServer.get_device() + for i in range(audiodevice_list.get_item_count()): + if device == audiodevice_list.get_item_text(i): + audiodevice_list.select(i) + break + MusicManager.connect("musicplayer_pressed", self, "_on_signal_musicplayer_pressed") + #$option.connect("mute_pressed", self, "update_mute") + MusicManager.connect("mute_pressed", self, "_on_signal_mute_pressed") + MusicManager.connect_ext("musicplayer_pressed", self ) + MusicManager.connect_ext("mute_pressed", self ) + + +func connect_ext( signal_name, target): + Config.msg_debug("Connect external [signal:" + signal_name + ", func:" + "_on_signal_" + signal_name + "]") + target.connect( signal_name, self, "_on_signal_" + signal_name ) + func update_mute(): Config.msg_debug("") $window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute + func _on_fullscreen_toggled(button_pressed): Config.set_window_fullscreen(button_pressed) + func _on_borderless_toggled(button_pressed): Config.set_window_borderless(button_pressed) + func _on_resizable_toggled(button_pressed): Config.set_window_resizable(button_pressed) + func _on_window_maximized_toggled(button_pressed): Config.set_window_maximized(button_pressed) + func _on_screen_value_changed(value): Config.set_current_screen(value) @@ -90,6 +120,7 @@ func _on_screen_value_changed(value): # SCREEN_ORIENTATION_SENSOR_PORTRAIT = 5 Uses portrait or reverse portrait based on the hardware sensor. # SCREEN_ORIENTATION_SENSOR = 6 Uses most suitable orientation based on + func _on_orientation_value_changed(value): # display/window/handheld/orientation #print(OS.screen_orientation) @@ -101,43 +132,10 @@ func _on_orientation_value_changed(value): Config.set_screen_orientation(value) #OS.set_screen_orientation(value) + func _on_always_on_top_toggled(button_pressed): Config.set_window_always_on_top(button_pressed) -func _on_add_music_pressed(): - pass # Replace with function body. - $file_dialog.show() - - -func _on_file_dialog_files_selected(paths): - print("multi files") - for path in paths: - var found = false - for slot in self.slots: - if self.slots[slot].music_filename == path: - found = true - continue - if found: - continue - var music_box = preload( "res://scenes/interfaces/options/option_settings_music_box.tscn" ).instance() - music_box.get_node( "label" ).text = path - #music_box.enable.pressed = true - #music_box.zone = "All" - music_box.slot = self.slots_number - music_box.music_filename = path - #creature_box.connect( "select_pressed", self, "_on_creature_box_select_pressed" ) - music_box.connect( "delete_pressed", self, "_on_music_box_delete_pressed" ) - $window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/scroll_container/list_music.add_child(music_box) - MusicManager.add_music(path) - self.slots[ self.slots_number ] = music_box - self.slots_number += 1 - -func _on_music_box_delete_pressed( slot ): - if self.slots[ slot ].music_filename: - #var dir = Directory.new() - #dir.remove( "user://creatures/" + self.slots[ slot ].creature_filename ) - pass - self.slots[ slot ].queue_free() func _on_default_toggled(button_pressed): if button_pressed: @@ -150,36 +148,78 @@ func _on_default_toggled(button_pressed): Config.disable_window_default() Config.set_video_default(button_pressed) + func _on_font_value_changed(value): - var valueint = int(value) - Config.set_font_size(value) + Config.set_font_size(int(value)) + func _on_sound_lvl_global_value_changed(value): MusicManager.set_level_global(int(value)) + func _on_sound_lvl_music_value_changed(value): MusicManager.set_level_music(int(value)) + func _on_sound_lvl_effect_value_changed(value): MusicManager.set_level_effect(int(value)) + func _on_ok_pressed(): $file_dialog.hide() $window_dialog.hide() Config.save_config() + func _on_window_dialog_hide(): $file_dialog.hide() if firstime: Config.save_config() + func _on_window_dialog_draw(): firstime = true + func _on_mute_toggled(button_pressed): - Config.msg_debug("") + Config.msg_debug("Option/Setting push mute") + if self.disable_execution_mute: + return MusicManager.set_sound_mute(button_pressed) emit_signal( "mute_pressed" ) -#func _on_control_mute_pressed(): -# update_mute() + +func _on_button_pressed(): + MusicManager.open() + + +func _on_musicplayer_pressed(): + Config.msg_debug("") + Config.set_playermusic(not Config.get_playermusic()) + Config.save_config() + emit_signal( "musicplayer_pressed") + + +func _on_audiodevice_item_selected(index): + Config.msg_debug("TODO") + + +func _on_control_musicplayer_pressed(): + Config.msg_debug("Option/setting signal received musicplayer") + + +func _on_control_mute_pressed(): + Config.msg_debug("