init
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class_name CreditButton
|
||||
extends VBoxContainer
|
||||
|
||||
signal display_license
|
||||
|
||||
var credit: CreditEntry
|
||||
|
||||
func set_credit(credit_entry: CreditEntry) -> void:
|
||||
credit = credit_entry
|
||||
if credit.descriptor:
|
||||
$DescribtorLabel.text = credit.descriptor
|
||||
$HBoxContainer/CreditButton.text = credit.name
|
||||
if credit.url:
|
||||
$HBoxContainer/CreditButton.pressed.connect(open_url)
|
||||
|
||||
func open_url():
|
||||
OS.shell_open(credit.url)
|
||||
|
||||
func _on_license_button_pressed() -> void:
|
||||
display_license.emit(credit)
|
||||
@@ -0,0 +1 @@
|
||||
uid://6q5m84onxilu
|
||||
@@ -0,0 +1,39 @@
|
||||
[gd_scene format=3 uid="uid://bhqw5lfvaq0bg"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://6q5m84onxilu" path="res://ui/screens/credit-screen/credit_element.gd" id="1_ukcj5"]
|
||||
|
||||
[sub_resource type="StyleBoxEmpty" id="StyleBoxEmpty_2mwwd"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_p0wxk"]
|
||||
font_size = 12
|
||||
|
||||
[node name="Credit" type="VBoxContainer" unique_id=69516036]
|
||||
offset_right = 40.0
|
||||
offset_bottom = 40.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 0
|
||||
alignment = 1
|
||||
script = ExtResource("1_ukcj5")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="." unique_id=599791176]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="CreditButton" type="Button" parent="HBoxContainer" unique_id=955063757]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_font_sizes/font_size = 20
|
||||
theme_override_styles/focus = SubResource("StyleBoxEmpty_2mwwd")
|
||||
flat = true
|
||||
|
||||
[node name="LicenseButton" type="Button" parent="HBoxContainer" unique_id=351433666]
|
||||
layout_mode = 2
|
||||
text = "License"
|
||||
|
||||
[node name="DescribtorLabel" type="Label" parent="." unique_id=322246210]
|
||||
modulate = Color(1, 1, 1, 0.670588)
|
||||
layout_mode = 2
|
||||
label_settings = SubResource("LabelSettings_p0wxk")
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[connection signal="pressed" from="HBoxContainer/LicenseButton" to="." method="_on_license_button_pressed"]
|
||||
@@ -0,0 +1,8 @@
|
||||
class_name CreditEntry
|
||||
extends Resource
|
||||
|
||||
@export var name: String
|
||||
@export var descriptor: String
|
||||
@export var license: String
|
||||
@export var license_file: String
|
||||
@export var url: String
|
||||
@@ -0,0 +1 @@
|
||||
uid://cjhxtjhj5o81f
|
||||
@@ -0,0 +1,84 @@
|
||||
extends Control
|
||||
|
||||
@export var credits: String
|
||||
|
||||
func _ready() -> void:
|
||||
$VBoxContainer/Return.grab_focus()
|
||||
|
||||
var credit_button_scene = load("res://ui/screens/credit-screen/credit_element.tscn")
|
||||
|
||||
var creds: Array[CreditEntry] = _dicts_to_entry(_read_credits())
|
||||
for c in creds:
|
||||
var b: CreditButton = credit_button_scene.instantiate()
|
||||
b.display_license.connect(display_license)
|
||||
b.set_credit(c)
|
||||
$VBoxContainer/ScrollContainer/VBoxContainer/VBoxContainer.add_child(b)
|
||||
$VBoxContainer/ScrollContainer.scroll_vertical = 0
|
||||
|
||||
func _on_return_pressed() -> void:
|
||||
queue_free()
|
||||
|
||||
func _read_credits() -> Array:
|
||||
var text = FileAccess.open(credits, FileAccess.READ).get_as_text()
|
||||
var content_as_dictionary: Array = JSON.parse_string(text)
|
||||
return content_as_dictionary
|
||||
|
||||
|
||||
func _dicts_to_entry(array: Array) -> Array[CreditEntry]:
|
||||
var item_array: Array[CreditEntry] = []
|
||||
for dict in array:
|
||||
var item = CreditEntry.new()
|
||||
item.name = dict["name"]
|
||||
item.descriptor = dict["descriptor"] if dict.has("descriptor") else ""
|
||||
if dict.has("license"):
|
||||
item.license = dict["license"] if dict["license"] else ""
|
||||
elif dict.has("license_file"):
|
||||
item.license = FileAccess.open(dict["license_file"], FileAccess.READ).get_as_text()\
|
||||
if FileAccess.file_exists(dict["license_file"]) else ""
|
||||
else:
|
||||
item.license = ""
|
||||
item.url = dict["url"] if dict.has("url") else ""
|
||||
item_array.append(item)
|
||||
return item_array
|
||||
|
||||
func _on_detailed_g_credits_pressed() -> void:
|
||||
if not $VBoxContainer/ScrollContainer/Godot3PCredits.text:
|
||||
var copyright_info = Engine.get_copyright_info()
|
||||
var copyright_text = "Godot Engine Copyright Information:"
|
||||
for entry in copyright_info:
|
||||
copyright_text += "\n\n" + entry["name"] + ":\n"
|
||||
var parts = entry["parts"]
|
||||
for part in parts:
|
||||
copyright_text += "Files:\n"
|
||||
for file in part["files"]:
|
||||
copyright_text += " " + file + "\n"
|
||||
for copyright_owner in part["copyright"]:
|
||||
copyright_text += "© " + copyright_owner + "\n"
|
||||
copyright_text += "License:" + part["license"] + "\n"
|
||||
# Append full license texts
|
||||
var license_texts = Engine.get_license_info()
|
||||
copyright_text += "\n\n\n\nFull license texts:"
|
||||
for license in license_texts:
|
||||
copyright_text += "\n\n" + license + ":\n"
|
||||
copyright_text += license_texts[license]
|
||||
|
||||
$VBoxContainer/ScrollContainer/Godot3PCredits.text = copyright_text
|
||||
|
||||
$VBoxContainer/ScrollContainer/Godot3PCredits.visible = \
|
||||
not $VBoxContainer/ScrollContainer/Godot3PCredits.visible
|
||||
|
||||
$VBoxContainer/ScrollContainer/VBoxContainer.visible = \
|
||||
not $VBoxContainer/ScrollContainer/VBoxContainer.visible
|
||||
|
||||
if $VBoxContainer/ScrollContainer/Godot3PCredits.visible:
|
||||
$DetailedGCredits.text = "Return to Credits"
|
||||
else:
|
||||
$DetailedGCredits.text = "Show detailed Godot Credits"
|
||||
|
||||
func display_license(credit: CreditEntry) -> void:
|
||||
$LicenseText.visible = true
|
||||
$LicenseText/VBoxContainer/Label.text = credit.name
|
||||
$LicenseText/VBoxContainer/ScrollContainer/Label.text = credit.license
|
||||
|
||||
func _on_close_licence_text_pressed() -> void:
|
||||
$LicenseText.visible = false
|
||||
@@ -0,0 +1 @@
|
||||
uid://dx5iawpcgwhlm
|
||||
116
rougelikeaboutmechs/ui/screens/credit-screen/credit_screen.tscn
Normal file
116
rougelikeaboutmechs/ui/screens/credit-screen/credit_screen.tscn
Normal file
@@ -0,0 +1,116 @@
|
||||
[gd_scene format=3 uid="uid://fd3xmnc047tm"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dx5iawpcgwhlm" path="res://ui/screens/credit-screen/credit_screen.gd" id="1_h6a2t"]
|
||||
[ext_resource type="Theme" uid="uid://hheneshfv1b2" path="res://ui/themes/your_theme.tres" id="2_dvsi5"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_cutkl"]
|
||||
font_size = 22
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_r8dx7"]
|
||||
font_size = 12
|
||||
|
||||
[node name="CreditScreen" type="MarginContainer" unique_id=554750649]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_dvsi5")
|
||||
script = ExtResource("1_h6a2t")
|
||||
credits = "res://ui/screens/credit-screen/credits.json"
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="." unique_id=1426215384]
|
||||
layout_mode = 2
|
||||
alignment = 1
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer" unique_id=193875904]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
horizontal_scroll_mode = 0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer" unique_id=1766199227]
|
||||
custom_minimum_size = Vector2(700, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LabelCredits" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=500318037]
|
||||
custom_minimum_size = Vector2(731.345, 0)
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"HeaderLarge"
|
||||
text = "Credits"
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Spacer2" type="Control" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=341639053]
|
||||
custom_minimum_size = Vector2(0, 27.17)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelCreatedBy" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=1161453390]
|
||||
layout_mode = 2
|
||||
text = "Created by You"
|
||||
label_settings = SubResource("LabelSettings_cutkl")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="LabelSpecialThanks" type="Label" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=1866642574]
|
||||
layout_mode = 2
|
||||
text = "Special thanks to Also You"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=123317386]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/ScrollContainer/VBoxContainer" unique_id=1405225546]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Godot3PCredits" type="Label" parent="VBoxContainer/ScrollContainer" unique_id=1092186786]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
label_settings = SubResource("LabelSettings_r8dx7")
|
||||
|
||||
[node name="Return" type="Button" parent="VBoxContainer" unique_id=464459005]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
text = "Return to Main Menu
|
||||
"
|
||||
|
||||
[node name="DetailedGCredits" type="Button" parent="." unique_id=729625426]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 8
|
||||
theme_override_font_sizes/font_size = 12
|
||||
text = "Show detailed Godot Credits"
|
||||
flat = true
|
||||
|
||||
[node name="LicenseText" type="PanelContainer" parent="." unique_id=1702054193]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_dvsi5")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="LicenseText" unique_id=1286974170]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="LicenseText/VBoxContainer" unique_id=426678051]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
theme = ExtResource("2_dvsi5")
|
||||
theme_type_variation = &"HeaderMedium"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="LicenseText/VBoxContainer" unique_id=1054289490]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Label" type="Label" parent="LicenseText/VBoxContainer/ScrollContainer" unique_id=589755459]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 6
|
||||
|
||||
[node name="CloseLicense" type="Button" parent="LicenseText/VBoxContainer" unique_id=102920052]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 4
|
||||
text = "Close"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/Return" to="." method="_on_return_pressed"]
|
||||
[connection signal="pressed" from="DetailedGCredits" to="." method="_on_detailed_g_credits_pressed"]
|
||||
[connection signal="pressed" from="LicenseText/VBoxContainer/CloseLicense" to="." method="_on_close_licence_text_pressed"]
|
||||
18
rougelikeaboutmechs/ui/screens/credit-screen/credits.json
Normal file
18
rougelikeaboutmechs/ui/screens/credit-screen/credits.json
Normal file
@@ -0,0 +1,18 @@
|
||||
[
|
||||
{
|
||||
"name": "Godot",
|
||||
"descriptor": "Open Source 2D/3D Game Engine",
|
||||
"license": "This game uses Godot Engine, available under the following license:\n\nCopyright (c) 2014-present Godot Engine contributors.\nCopyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.",
|
||||
"url": "https://godotengine.org/license"
|
||||
},
|
||||
{
|
||||
"name": "Godot Game Template",
|
||||
"descriptor": "Universal game template targeted at game jams.",
|
||||
"license": "MIT License\n\nCopyright (c) 2025 Ekaterina Ehringhaus and Hendrik Brucker\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.",
|
||||
"url": "https://github.com/Godot-Stammtisch-Karlsruhe/godot-game-template"
|
||||
},
|
||||
{
|
||||
"name": "Sample Asset",
|
||||
"descriptor": "Sample description (optional)"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user