display images and sounds directly in loader tool
This commit is contained in:
@@ -31,7 +31,6 @@ window/size/viewport_width=2560
|
||||
window/size/viewport_height=1800
|
||||
window/size/window_width_override=1280
|
||||
window/size/window_height_override=900
|
||||
window/subwindows/embed_subwindows=false
|
||||
window/stretch/mode="canvas_items"
|
||||
|
||||
[editor_plugins]
|
||||
|
||||
@@ -5,15 +5,17 @@ extends Control
|
||||
const description_line_class: = preload("res://sources/language_tool/image_and_sound_gp_description.tscn")
|
||||
|
||||
|
||||
func _on_description_line_delete(description_line: Control) -> void:
|
||||
description_line.queue_free()
|
||||
|
||||
|
||||
func _on_plus_button_pressed() -> void:
|
||||
var description_line: = description_line_class.instantiate()
|
||||
description_line.delete.connect(_on_description_line_delete.bind(description_line))
|
||||
func _ready() -> void:
|
||||
var _description_line: = description_line_class.instantiate()
|
||||
DirAccess.make_dir_recursive_absolute(_description_line.resource_folder + _description_line.language_folder + _description_line.image_folder)
|
||||
DirAccess.make_dir_recursive_absolute(_description_line.resource_folder + _description_line.language_folder + _description_line.sound_folder)
|
||||
_description_line.queue_free()
|
||||
|
||||
description_container.add_child(description_line)
|
||||
Database.db.query("Select * FROM GPs")
|
||||
for res in Database.db.query_result:
|
||||
var description_line: = description_line_class.instantiate()
|
||||
description_container.add_child(description_line)
|
||||
description_line.set_gp(res["Grapheme"] + "-" + res["Phoneme"])
|
||||
|
||||
|
||||
func _on_back_button_pressed() -> void:
|
||||
|
||||
@@ -70,6 +70,7 @@ text = "Sound"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="PlusButton" parent="VBoxContainer/PanelContainer/HBoxContainer" instance=ExtResource("1_tjhx5")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="BackButton" parent="VBoxContainer/PanelContainer/HBoxContainer" instance=ExtResource("1_tjhx5")]
|
||||
@@ -80,8 +81,12 @@ texture = ExtResource("3_04mkx")
|
||||
|
||||
[node name="PanelContainer2" type="PanelContainer" parent="VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="DescriptionsContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer2"]
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer/PanelContainer2"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DescriptionsContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer2/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
|
||||
|
||||
@@ -3,13 +3,14 @@ extends HBoxContainer
|
||||
signal delete
|
||||
|
||||
@onready var gp_menu_button: = %GPMenuButton
|
||||
@onready var image_check_box: = %ImageCheckBox
|
||||
@onready var image_preview: = %ImagePreview
|
||||
@onready var sound_preview: = %SoundPreview
|
||||
@onready var image_upload_button: = %ImageUploadButton
|
||||
@onready var sound_check_box: = %SoundCheckBox
|
||||
@onready var sound_upload_button: = %SoundUploadButton
|
||||
@onready var file_dialog: = $FileDialog
|
||||
@onready var sound_player: = $AudioStreamPlayer
|
||||
|
||||
const resource_folder: = "res://language_resources/"
|
||||
const resource_folder: = "user://language_resources/"
|
||||
const language_folder: = "french/"
|
||||
const image_folder: = "look_and_learn/images/"
|
||||
const sound_folder: = "look_and_learn/sounds/"
|
||||
@@ -17,18 +18,8 @@ const image_extension: = ".png"
|
||||
const sound_extension: = ".mp3"
|
||||
|
||||
var gp: = ""
|
||||
var gp_list: = {}
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var popup: PopupMenu = gp_menu_button.get_popup()
|
||||
|
||||
Database.db.query("Select * FROM GPs")
|
||||
for res in Database.db.query_result:
|
||||
popup.add_check_item(res["Grapheme"] + "-" + res["Phoneme"], res["ID"])
|
||||
gp_list[res["ID"]] = res["Grapheme"] + "-" + res["Phoneme"]
|
||||
|
||||
gp_menu_button.get_popup().id_pressed.connect(_on_gp_menu_button_popup_id_pressed)
|
||||
|
||||
|
||||
func _image_file_selected(file_path: String) -> void:
|
||||
@@ -39,8 +30,19 @@ func _image_file_selected(file_path: String) -> void:
|
||||
DirAccess.remove_absolute(current_file)
|
||||
|
||||
DirAccess.copy_absolute(file_path, current_file)
|
||||
|
||||
image_check_box.button_pressed = true
|
||||
set_image_preview(current_file)
|
||||
|
||||
|
||||
func set_image_preview(img_path: String) -> void:
|
||||
var image: = Image.load_from_file(img_path)
|
||||
image_preview.texture = ImageTexture.create_from_image(image)
|
||||
|
||||
|
||||
func set_sound_preview(sound_path: String) -> void:
|
||||
var file = FileAccess.open(sound_path, FileAccess.READ)
|
||||
var sound = AudioStreamMP3.new()
|
||||
sound.data = file.get_buffer(file.get_length())
|
||||
sound_player.stream = sound
|
||||
|
||||
|
||||
func _image_file_path() -> String:
|
||||
@@ -55,19 +57,25 @@ func _sound_file_selected(file_path: String) -> void:
|
||||
|
||||
DirAccess.copy_absolute(file_path, current_file)
|
||||
|
||||
sound_check_box.button_pressed = true
|
||||
set_sound_preview(current_file)
|
||||
sound_preview.show()
|
||||
|
||||
|
||||
func _sound_file_path() -> String:
|
||||
return resource_folder + language_folder + sound_folder + gp + sound_extension
|
||||
|
||||
|
||||
func _on_gp_menu_button_popup_id_pressed(id: int) -> void:
|
||||
gp = gp_list[id]
|
||||
func set_gp(p_gp: String) -> void:
|
||||
gp = p_gp
|
||||
gp_menu_button.text = gp
|
||||
|
||||
image_check_box.button_pressed = FileAccess.file_exists(_image_file_path())
|
||||
sound_check_box.button_pressed = FileAccess.file_exists(_sound_file_path())
|
||||
if FileAccess.file_exists(_image_file_path()):
|
||||
set_image_preview(_image_file_path())
|
||||
if FileAccess.file_exists(_sound_file_path()):
|
||||
set_sound_preview(_sound_file_path())
|
||||
sound_preview.show()
|
||||
else:
|
||||
sound_preview.hide()
|
||||
|
||||
|
||||
func _on_image_upload_button_pressed() -> void:
|
||||
@@ -98,3 +106,8 @@ func _on_sound_upload_button_pressed() -> void:
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
delete.emit()
|
||||
|
||||
|
||||
func _on_sound_preview_pressed() -> void:
|
||||
if sound_player.stream:
|
||||
sound_player.play()
|
||||
|
||||
@@ -19,6 +19,7 @@ theme_override_constants/margin_bottom = 10
|
||||
[node name="GPMenuButton" type="MenuButton" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
mouse_filter = 2
|
||||
theme_override_font_sizes/font_size = 64
|
||||
text = "GP"
|
||||
alignment = 0
|
||||
@@ -34,8 +35,15 @@ theme_override_constants/margin_bottom = 10
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="ImageContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="ImagePreview" type="TextureRect" parent="ImageContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 100)
|
||||
layout_mode = 2
|
||||
expand_mode = 1
|
||||
|
||||
[node name="ImageCheckBox" type="CheckBox" parent="ImageContainer/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
button_mask = 0
|
||||
|
||||
@@ -57,8 +65,16 @@ theme_override_constants/margin_bottom = 10
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer3"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SoundPreview" type="Button" parent="MarginContainer3/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(200, 2.08165e-12)
|
||||
layout_mode = 2
|
||||
theme_override_font_sizes/font_size = 70
|
||||
text = "Play"
|
||||
|
||||
[node name="SoundCheckBox" type="CheckBox" parent="MarginContainer3/HBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
button_mask = 0
|
||||
|
||||
@@ -70,6 +86,7 @@ layout_mode = 2
|
||||
texture = ExtResource("2_0hqnp")
|
||||
|
||||
[node name="Button" parent="." instance=ExtResource("1_uutsu")]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="TextureRect" parent="Button" index="0"]
|
||||
@@ -85,7 +102,10 @@ ok_button_text = "Ouvrir"
|
||||
file_mode = 0
|
||||
access = 2
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
|
||||
[connection signal="pressed" from="ImageContainer/HBoxContainer/ImageUploadButton" to="." method="_on_image_upload_button_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer3/HBoxContainer/SoundPreview" to="." method="_on_sound_preview_pressed"]
|
||||
[connection signal="pressed" from="MarginContainer3/HBoxContainer/SoundUploadButton" to="." method="_on_sound_upload_button_pressed"]
|
||||
[connection signal="pressed" from="Button" to="." method="_on_button_pressed"]
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
extends Node
|
||||
class_name Logger
|
||||
|
||||
const log_resource_class: = preload("res://sources/utils/minigame_resources/log.gd")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user