adding some functionnality on main windows [settings, juke blox, select language, information, help/author]

This commit is contained in:
AleaJactaEst 2021-06-07 23:07:44 +02:00
parent 7d44d8132b
commit b3b1029785
35 changed files with 1171 additions and 309 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 879 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 966 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 935 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 937 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 952 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 925 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 936 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 944 B

View file

@ -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)"

View file

@ -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)"

Binary file not shown.

View file

@ -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 ""

View file

@ -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]

View file

@ -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)

View file

@ -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()

View file

@ -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.

View file

@ -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

View file

@ -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 )

View file

@ -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"]

View file

@ -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("<MusicManager> Received signal mute")
update_playermusic()
if Config.mute:
set_mute_on()
else:
set_mute_off()
func _on_signal_musicplayer_pressed():
Config.msg_debug("<MusicManager> Received signal musicplayer")
update_playermusic()

View file

@ -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"]

View file

@ -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():

View file

@ -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():

View file

@ -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):

View file

@ -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("<Option/setting> signal received mute")
func _on_signal_mute_pressed():
Config.msg_debug("<Option/setting> signal received mute")
self.disable_execution_mute = true
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute
self.disable_execution_mute = false
Config.msg_debug("<Option/setting> signal received mute : End")
func _on_signal_musicplayer_pressed():
Config.msg_debug("<Option/setting> signal received musicplayer")
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5/musicplayer.pressed = Config.get_playermusic()

View file

@ -11,10 +11,12 @@ __meta__ = {
}
[node name="window_dialog" type="WindowDialog" parent="."]
visible = true
margin_left = 55.2183
margin_top = 62.4725
margin_right = 1231.22
margin_bottom = 674.473
window_title = "OPTION_TITLE"
__meta__ = {
"_edit_use_anchors_": false
}
@ -84,6 +86,7 @@ margin_bottom = 24.0
size_flags_horizontal = 2
[node name="h_box_container_9" type="HBoxContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO"]
visible = false
margin_top = 28.0
margin_right = 1158.0
margin_bottom = 52.0
@ -106,9 +109,9 @@ min_value = 8.0
value = 8.0
[node name="settings_video" type="GridContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO"]
margin_top = 56.0
margin_top = 28.0
margin_right = 1158.0
margin_bottom = 158.0
margin_bottom = 130.0
custom_constants/vseparation = 2
custom_constants/hseparation = 0
columns = 2
@ -358,43 +361,45 @@ margin_bottom = 19.0
size_flags_horizontal = 10
text = "OPTION_SETTINGS_SOUND_YOUR_MUSIC"
[node name="mute" type="CheckBox" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5"]
[node name="musicplayer" type="CheckBox" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5"]
margin_left = 581.0
margin_right = 605.0
margin_bottom = 24.0
size_flags_horizontal = 2
[node name="h_box_container" type="HBoxContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND"]
[node name="h_box_container_7" type="HBoxContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND"]
margin_top = 110.0
margin_right = 1158.0
margin_bottom = 130.0
size_flags_horizontal = 3
[node name="label" type="Label" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container"]
[node name="label" type="Label" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7"]
margin_left = 305.0
margin_top = 3.0
margin_right = 289.0
margin_right = 577.0
margin_bottom = 17.0
text = "OPTION_SETTINGS_SOUND_YOUR_SELECTION"
size_flags_horizontal = 10
text = "OPTION_SETTINGS_SOUND_SELECT_DEVICE"
[node name="add_music" type="Button" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container"]
margin_left = 293.0
margin_right = 587.0
[node name="audiodevice" type="OptionButton" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7"]
margin_left = 581.0
margin_right = 610.0
margin_bottom = 20.0
text = "OPTION_SETTINGS_SOUND_SELECTION_ADD"
size_flags_horizontal = 2
[node name="scroll_container" type="ScrollContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND"]
[node name="h_box_container" type="HBoxContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND"]
margin_top = 134.0
margin_right = 1158.0
margin_bottom = 541.0
margin_bottom = 154.0
size_flags_horizontal = 3
size_flags_vertical = 3
[node name="list_music" type="VBoxContainer" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/scroll_container"]
margin_right = 1158.0
margin_bottom = 407.0
size_flags_horizontal = 3
size_flags_vertical = 3
custom_constants/separation = 4
[node name="button" type="Button" parent="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container"]
margin_left = 546.0
margin_right = 612.0
margin_bottom = 20.0
size_flags_horizontal = 6
text = "Juke Box"
align = 2
[node name="ok" type="Button" parent="window_dialog/margin_container/v_box_container"]
margin_top = 582.0
@ -423,6 +428,7 @@ __meta__ = {
"_edit_use_anchors_": false
}
[connection signal="musicplayer_pressed" from="." to="." method="_on_control_musicplayer_pressed"]
[connection signal="mute_pressed" from="." to="." method="_on_control_mute_pressed"]
[connection signal="draw" from="window_dialog" to="." method="_on_window_dialog_draw"]
[connection signal="hide" from="window_dialog" to="." method="_on_window_dialog_hide"]
@ -440,6 +446,8 @@ __meta__ = {
[connection signal="value_changed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_3/sound_lvl_global" to="." method="_on_sound_lvl_global_value_changed"]
[connection signal="value_changed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_6/sound_lvl_music" to="." method="_on_sound_lvl_music_value_changed"]
[connection signal="value_changed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_4/sound_lvl_effect" to="." method="_on_sound_lvl_effect_value_changed"]
[connection signal="pressed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container/add_music" to="." method="_on_add_music_pressed"]
[connection signal="pressed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5/musicplayer" to="." method="_on_musicplayer_pressed"]
[connection signal="item_selected" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice" to="." method="_on_audiodevice_item_selected"]
[connection signal="pressed" from="window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container/button" to="." method="_on_button_pressed"]
[connection signal="pressed" from="window_dialog/margin_container/v_box_container/ok" to="." method="_on_ok_pressed"]
[connection signal="files_selected" from="file_dialog" to="." method="_on_file_dialog_files_selected"]

View file

@ -2,12 +2,40 @@ extends HBoxContainer
signal select_pressed( slot )
signal delete_pressed( slot )
signal down_pressed( slot )
signal up_pressed( slot )
var slot = null
var music_filename = null
func enable_up():
$up.disabled = false
func disable_up():
$up.disabled = true
func enable_down():
$down.disabled = false
func disable_down():
$down.disabled = true
func _on_select_pressed():
emit_signal( "select_pressed", self.slot )
func _on_delete_pressed():
emit_signal( "delete_pressed", self.slot )
func _on_down_pressed():
emit_signal( "down_pressed", self.slot )
func _on_up_pressed():
emit_signal( "up_pressed", self.slot )

View file

@ -1,6 +1,8 @@
[gd_scene load_steps=2 format=2]
[gd_scene load_steps=4 format=2]
[ext_resource path="res://scenes/interfaces/options/option_settings_music_box.gd" type="Script" id=1]
[ext_resource path="res://assets/interfaces/buttons/down.png" type="Texture" id=2]
[ext_resource path="res://assets/interfaces/buttons/up.png" type="Texture" id=3]
[node name="h_box_container" type="HBoxContainer"]
margin_right = 40.0
@ -25,4 +27,21 @@ margin_bottom = 27.0
size_flags_horizontal = 3
text = "file"
[node name="down" type="Button" parent="."]
margin_left = 330.0
margin_right = 358.0
margin_bottom = 40.0
icon = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="up" type="Button" parent="."]
margin_left = 358.0
margin_right = 386.0
margin_bottom = 40.0
icon = ExtResource( 3 )
[connection signal="pressed" from="delete" to="." method="_on_delete_pressed"]
[connection signal="pressed" from="down" to="." method="_on_down_pressed"]
[connection signal="pressed" from="up" to="." method="_on_up_pressed"]

View file

@ -3,17 +3,28 @@ extends Control
signal quit_pressed
signal mute_pressed
#signal musicplayer_pressed
func _ready():
get_node("option_settings").connect("mute_pressed", self, "_on_control_mute_pressed")
#get_node("option_settings").connect("mute_pressed", self, "_on_control_mute_pressed")
MusicManager.connect("mute_pressed", self, "_on_control_mute_pressed")
MusicManager.connect("musicplayer_pressed", self, "_on_control_musicplayer_pressed")
MusicManager.connect_ext( "mute_pressed", self )
$option_settings.connect( "mute_pressed", self, "_on_control_mute_pressed" )
$option_settings.connect_ext( "mute_pressed", self )
update_sound_button()
func _on_quit_button_pressed():
Config.msg_debug("_on_quit_button_pressed")
emit_signal( "quit_pressed" )
func _on_control_musicplayer_pressed():
Config.msg_debug("Option -> Receibed signal")
#emit_signal ( "musicplayer_pressed" )
func _on_language_button_pressed():
$option_language/window_dialog.show()
@ -22,6 +33,7 @@ func _on_news_button_pressed():
#$option_news/accept_dialog.show()
$option_news/window_dialog.show()
func _on_help_button_pressed():
$option_info/window_dialog.show()
@ -29,23 +41,36 @@ func _on_help_button_pressed():
func _on_settings_button_pressed():
$option_settings/window_dialog.show()
func update_sound_button():
Config.msg_debug("")
Config.msg_debug("<Option> update_sound_button")
if Config.mute:
$options_reduce/h_box_container/sound_button.texture_normal = load ( "res://assets/interfaces/Login-Khanat-sound-muted-button.png")
$options_reduce/h_box_container/sound_button.texture_hover = load ( "res://assets/interfaces/Login-Khanat-sound-muted-button-hover.png")
#MusicManager.set_mute_on()
else:
$options_reduce/h_box_container/sound_button.texture_normal = load ( "res://assets/interfaces/Login-Khanat-sound-button.png")
$options_reduce/h_box_container/sound_button.texture_hover = load ( "res://assets/interfaces/Login-Khanat-sound-button-hover.png")
#MusicManager.set_mute_off()
#$option_settings/window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute
func update_musicplayer():
Config.msg_debug("update_musicplayer")
$option_settings/window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5/musicplayer.pressed = Config.get_playermusic()
if Config.get_playermusic():
MusicManager.set_playermusic_on()
else:
MusicManager.set_playermusic_off()
func _on_sound_button_pressed():
Config.msg_debug("")
Config.msg_debug("Option mute")
MusicManager.set_sound_mute(not Config.mute)
emit_signal( "mute_pressed" )
func _on_control_mute_pressed():
Config.msg_debug("received signal mute")
Config.msg_debug("<Option> Received Signal mute")
update_sound_button()
$option_settings/window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute

View file

@ -11,14 +11,14 @@ var is_scene_loading = false
var creature_selected_slot = null
var creature_selected_filename = null
func _ready():
Connection.connect( "connection_ok", self, "_on_connexion_ok" )
Connection.connect( "connection_error", self, "_on_connection_error" )
Globals.ressource_queue.start()
func _process(_time):
if self.is_scene_loading:
if Globals.ressource_queue.is_ready( self.current_scene_path ):
print( "LOADING FINISHED")
@ -27,8 +27,6 @@ func _process(_time):
else:
self.update_progress()
$loading_screen.show()
# if loader == null:
# # no need to process anymore
# set_process(false)
@ -56,13 +54,14 @@ func _process(_time):
# printerr( "Loading errors." )
# loader = null
# break
func _input( event ):
if event.is_action_released( "music_manager" ):
MusicManager.toggle()
#func load_scene( path ):
# self.loader = ResourceLoader.load_interactive( path )
# if self.loader == null:
@ -99,17 +98,17 @@ func set_new_scene( scene_resource ):
self.get_node( "scene/creatures_editor_ui" ).slot = self.creature_selected_slot
# elif self.has_node( "scene/game" ):
# self.get_node( "scene/game" ).load_player( self.creature_selected_filename )
func update_progress():
var progress = float(Globals.ressource_queue.get_progress( self.current_scene_path ))
self.get_node("loading_screen/background_player").play("loading")
self.get_node("loading_screen/background_player").stop()
self.get_node("loading_screen/background_player").seek( (progress*13.0)/100.0 )
func goto_scene( p_path ):
# Clean old scene.
if self.current_scene:
Globals.ressource_queue.cancel_resource( self.current_scene_path )
@ -129,8 +128,7 @@ func goto_scene( p_path ):
#func update_progress():
# self.get_node("loading_screen/progress_bar").value = Globals.ressource_queue.get_progress( self.current_scene_path )
#
func _on_main_menu_play_pressed():
@ -140,40 +138,48 @@ func _on_main_menu_play_pressed():
Connection.do_request(username, password)
else:
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_creatures_menu_ui_new_pressed( slot ):
self.creature_selected_slot = slot
# Globals.goto_scene( "res://scenes/interfaces/creatures_editor/creatures_editor_ui.tscn" )
Globals.goto_scene( "res://scenes/creatures/creatures_creation.tscn" )
func _on_creatures_menu_ui_cancel_pressed():
$main_menu.show()
func _on_creatures_menu_ui_select_pressed( filename ):
self.creature_selected_filename = filename
Globals.goto_scene( "res://scenes/game/game.tscn" )
func _on_creature_editor_ui_valid_pressed():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_creature_editor_ui_cencel_pressed():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_main_menu_quit_pressed():
get_tree().quit()
func _on_connexion_ok():
Globals.goto_scene( "res://scenes/interfaces/creatures_menu/creatures_menu_ui.tscn" )
func _on_connection_error( message ):
$main_menu/screen_box/login_box/error.text = message
func _on_mute_pressed():
pass
# $main_menu/control/option_settings.update_sound_button()
func _on_main_menu_mute_pressed():
Config.msg_debug("_on_main_menu_mute_pressed")
$main_menu/control/option_settings.update_sound_button()