added license information screeen and resources
This commit is contained in:
parent
21d7cf417a
commit
d437b4809f
23 changed files with 525 additions and 159 deletions
99
ui/license_list/license_entry.gd
Normal file
99
ui/license_list/license_entry.gd
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
extends VBoxContainer
|
||||
|
||||
@onready var asset_type: Label = %AssetType
|
||||
@onready var license_type: Label = %LicenseType
|
||||
@onready var asset_name: Label = %AssetName
|
||||
@onready var author_name: Label = %AuthorName
|
||||
@onready var link_button: LinkButton = %LinkButton
|
||||
|
||||
@export var asset_type_colors: Dictionary = {
|
||||
"MUSIC": Color("c9ca00"),
|
||||
"SFX": Color("3aae65"),
|
||||
"THREEDIMENSIONAL": Color("c8954c"),
|
||||
"TEXTURES": Color("aa77cc"),
|
||||
"FONTS": Color("5185b2"),
|
||||
"NOT_SPECIFIED": Color("aaaaaa")
|
||||
}
|
||||
|
||||
@export var license_type_colors: Dictionary = {
|
||||
"CC0": Color("bc852e"),
|
||||
"CCBY": Color("3478f6"),
|
||||
"CCBYSA": Color("f69625"),
|
||||
"MIT": Color("2d8b57"),
|
||||
"GPL2": Color("d32f2f"),
|
||||
"GPL3": Color("c0392b"),
|
||||
"OFL": Color("8e44ad"),
|
||||
"NONE": Color("aaaaaa")
|
||||
}
|
||||
|
||||
|
||||
func populate(p_asset_info: AssetInfo) -> void:
|
||||
change_asset_type(p_asset_info.asset_type)
|
||||
change_asset_license(p_asset_info.license_type)
|
||||
asset_name.text = p_asset_info.asset_name
|
||||
author_name.text = "by " + p_asset_info.author_name
|
||||
link_button.text = p_asset_info.link
|
||||
link_button.uri = p_asset_info.link
|
||||
|
||||
func change_asset_type(p_asset_type: AssetInfo.AssetType) -> void:
|
||||
|
||||
var style_box: StyleBoxFlat = asset_type.get_parent().get("theme_override_styles/panel").duplicate()
|
||||
|
||||
match p_asset_type:
|
||||
AssetInfo.AssetType.MUSIC:
|
||||
asset_type.text = "MUSIC"
|
||||
style_box.set("bg_color", asset_type_colors["MUSIC"])
|
||||
AssetInfo.AssetType.SFX:
|
||||
asset_type.text = "SFX"
|
||||
style_box.set("bg_color", asset_type_colors["SFX"])
|
||||
AssetInfo.AssetType.THREEDIMENSIONAL:
|
||||
asset_type.text = "3D"
|
||||
style_box.set("bg_color", asset_type_colors["THREEDIMENSIONAL"])
|
||||
AssetInfo.AssetType.TEXTURES:
|
||||
asset_type.text = "TEXTURES"
|
||||
style_box.set("bg_color", asset_type_colors["TEXTURES"])
|
||||
AssetInfo.AssetType.FONTS:
|
||||
asset_type.text = "FONTS"
|
||||
style_box.set("bg_color", asset_type_colors["FONTS"])
|
||||
_:
|
||||
asset_type.text = "Not specified"
|
||||
style_box.set("bg_color", asset_type_colors["NOT_SPECIFIED"])
|
||||
|
||||
# Finally set the background color
|
||||
asset_type.get_parent().add_theme_stylebox_override("panel", style_box)
|
||||
|
||||
func change_asset_license(p_license_type: AssetInfo.LicenseType) -> void:
|
||||
|
||||
var style_box: StyleBoxFlat = license_type.get_parent().get("theme_override_styles/panel").duplicate()
|
||||
|
||||
match p_license_type:
|
||||
AssetInfo.LicenseType.CC0:
|
||||
license_type.text = "CC0"
|
||||
style_box.set("bg_color", license_type_colors["CC0"])
|
||||
AssetInfo.LicenseType.CCBY:
|
||||
license_type.text = "CC BY"
|
||||
style_box.set("bg_color", license_type_colors["CCBY"])
|
||||
AssetInfo.LicenseType.CCBYSA:
|
||||
license_type.text = "CC BY-SA"
|
||||
style_box.set("bg_color", license_type_colors["CCBYSA"])
|
||||
AssetInfo.LicenseType.MIT:
|
||||
license_type.text = "MIT"
|
||||
style_box.set("bg_color", license_type_colors["MIT"])
|
||||
AssetInfo.LicenseType.GPL2:
|
||||
license_type.text = "GPL 2.0"
|
||||
style_box.set("bg_color", license_type_colors["GPL2"])
|
||||
AssetInfo.LicenseType.GPL3:
|
||||
license_type.text = "GPL 3.0"
|
||||
style_box.set("bg_color", license_type_colors["GPL3"])
|
||||
AssetInfo.LicenseType.OFL:
|
||||
license_type.text = "OFL"
|
||||
style_box.set("bg_color", license_type_colors["OFL"])
|
||||
AssetInfo.LicenseType.NONE:
|
||||
license_type.text = "Not specified"
|
||||
style_box.set("bg_color", license_type_colors["NONE"])
|
||||
_:
|
||||
license_type.text = "Unknown"
|
||||
style_box.set("bg_color", license_type_colors["NONE"])
|
||||
|
||||
# Finally set the background color
|
||||
license_type.get_parent().add_theme_stylebox_override("panel", style_box)
|
||||
83
ui/license_list/license_entry.tscn
Normal file
83
ui/license_list/license_entry.tscn
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://b7raoxonsf116"]
|
||||
|
||||
[ext_resource type="Script" path="res://ui/license_list/license_entry.gd" id="1_fuqxo"]
|
||||
[ext_resource type="FontFile" uid="uid://c80eqcvqyrda0" path="res://assets/fonts/days_one/DaysOne-Regular.ttf" id="2_48yrm"]
|
||||
|
||||
[sub_resource type="FontVariation" id="FontVariation_yq0xd"]
|
||||
base_font = ExtResource("2_48yrm")
|
||||
variation_embolden = 0.5
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_dvghx"]
|
||||
content_margin_left = 6.0
|
||||
content_margin_top = 0.0
|
||||
content_margin_right = 6.0
|
||||
content_margin_bottom = 0.0
|
||||
bg_color = Color(0.1681, 0.228575, 0.41, 1)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ug4om"]
|
||||
content_margin_left = 8.0
|
||||
content_margin_right = 8.0
|
||||
draw_center = false
|
||||
border_width_left = 4
|
||||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color(0.752941, 0.619608, 0.337255, 1)
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[node name="LicenseEntry" type="VBoxContainer"]
|
||||
script = ExtResource("1_fuqxo")
|
||||
|
||||
[node name="TypeAndName" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="AssetName" type="Label" parent="TypeAndName"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
theme_override_fonts/font = SubResource("FontVariation_yq0xd")
|
||||
text = "Name of the asset"
|
||||
max_lines_visible = 1
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="TypeAndName"]
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_dvghx")
|
||||
|
||||
[node name="AssetType" type="Label" parent="TypeAndName/PanelContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(1, 1, 1, 1)
|
||||
text = "MUSIC"
|
||||
|
||||
[node name="LicenseContainer" type="PanelContainer" parent="TypeAndName"]
|
||||
layout_mode = 2
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_ug4om")
|
||||
|
||||
[node name="LicenseType" type="Label" parent="TypeAndName/LicenseContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_override_colors/font_color = Color(0.753848, 0.617939, 0.336047, 1)
|
||||
theme_override_font_sizes/font_size = 16
|
||||
text = "CC0"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="AuthorName" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "by Author Of XYZ"
|
||||
|
||||
[node name="LinkButton" type="LinkButton" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
text = "https://example.com"
|
||||
uri = "https://example.com"
|
||||
|
|
@ -5,10 +5,16 @@ signal on_game_continued
|
|||
|
||||
@onready var continue_game_button: Button = %ContinueGameButton
|
||||
@onready var new_game_button: Button = %NewGameButton
|
||||
@onready var license_container: VBoxContainer = %LicenseContainer
|
||||
|
||||
const LICENSE_FOLDER: String = "res://resources/asset_info/"
|
||||
@onready var license_entry: PackedScene = preload("res://ui/license_list/license_entry.tscn")
|
||||
|
||||
|
||||
# On ready, check which buttons to show
|
||||
func _ready() -> void:
|
||||
SoundManager.play_background_music("Unexplored Fields")
|
||||
list_licenses()
|
||||
|
||||
if SaveManager.save_exists():
|
||||
continue_game_button.visible = true
|
||||
|
|
@ -35,7 +41,23 @@ func _on_options_button_pressed() -> void:
|
|||
print("TODO")
|
||||
|
||||
func _on_licenses_button_pressed() -> void:
|
||||
print("TODO")
|
||||
%LicensesScreen.visible = true
|
||||
|
||||
func _on_exit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
|
||||
func list_licenses() -> void:
|
||||
var dir: DirAccess = DirAccess.open(LICENSE_FOLDER)
|
||||
for file: String in dir.get_files():
|
||||
add_license(file)
|
||||
|
||||
func add_license(license_path: String) -> void:
|
||||
var asset_info: AssetInfo = load(LICENSE_FOLDER + license_path)
|
||||
var new_license_entry: Node = license_entry.instantiate()
|
||||
license_container.add_child(new_license_entry)
|
||||
new_license_entry.populate(asset_info)
|
||||
|
||||
|
||||
func _on_licenses_close_button_pressed() -> void:
|
||||
%LicensesScreen.visible = false
|
||||
pass # Replace with function body.
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://dt00rjsodtady"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dt00rjsodtady"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b6ylra30qxf30" path="res://assets/logo/logo.png" id="1_1fmce"]
|
||||
[ext_resource type="Script" path="res://ui/main_menu/main_menu.gd" id="1_5gs73"]
|
||||
[ext_resource type="Texture2D" uid="uid://da7o6lfuoliid" path="res://assets/textures/Backgrounds/meadow2.jpg" id="2_bb61v"]
|
||||
[ext_resource type="Theme" uid="uid://xfq6d5yqsdh5" path="res://theme/basic_theme.tres" id="4_y6s8u"]
|
||||
|
||||
[node name="MainMenu" type="Control"]
|
||||
layout_mode = 3
|
||||
|
|
@ -76,7 +75,6 @@ size_flags_vertical = 3
|
|||
[node name="NewGameButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_y6s8u")
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "New Game"
|
||||
|
||||
|
|
@ -84,21 +82,18 @@ text = "New Game"
|
|||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_y6s8u")
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Continue"
|
||||
|
||||
[node name="OptionsButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_y6s8u")
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Options"
|
||||
|
||||
[node name="LicensesButton" type="Button" parent="VBoxContainer/MarginContainer/MenuButtons"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("4_y6s8u")
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Licenses"
|
||||
|
||||
|
|
@ -106,12 +101,59 @@ text = "Licenses"
|
|||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 10
|
||||
theme = ExtResource("4_y6s8u")
|
||||
theme_type_variation = &"RedButton"
|
||||
theme_override_font_sizes/font_size = 32
|
||||
text = "Exit"
|
||||
|
||||
[node name="LicensesScreen" type="PanelContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="LicensesScreen"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_top = 40
|
||||
theme_override_constants/margin_right = 40
|
||||
theme_override_constants/margin_bottom = 40
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="LicensesScreen/MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="LicensesScreen/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/margin_bottom = 20
|
||||
|
||||
[node name="LicensesHeadingLabel" type="Label" parent="LicensesScreen/MarginContainer/VBoxContainer/MarginContainer"]
|
||||
layout_mode = 2
|
||||
text = "Licenses used in this game"
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="LicensesScreen/MarginContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
follow_focus = true
|
||||
|
||||
[node name="LicenseContainer" type="VBoxContainer" parent="LicensesScreen/MarginContainer/VBoxContainer/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/separation = 20
|
||||
|
||||
[node name="LicensesCloseButton" type="Button" parent="LicensesScreen/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme_type_variation = &"RedButton"
|
||||
text = "Close"
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/NewGameButton" to="." method="_on_new_game_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/ContinueGameButton" to="." method="_on_continue_game_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/OptionsButton" to="." method="_on_options_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/LicensesButton" to="." method="_on_licenses_button_pressed"]
|
||||
[connection signal="pressed" from="VBoxContainer/MarginContainer/MenuButtons/ExitButton" to="." method="_on_exit_button_pressed"]
|
||||
[connection signal="pressed" from="LicensesScreen/MarginContainer/VBoxContainer/LicensesCloseButton" to="." method="_on_licenses_close_button_pressed"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue