système de sauvegarde, scène 3D de test sur la base astra et passage en forward+
This commit is contained in:
@@ -4,54 +4,57 @@ class_name Card
|
||||
|
||||
const CARD_STAT_SCENE : PackedScene = preload("res://gui/game/card/card_stat.tscn")
|
||||
const CARD_SECTION_SCENE : PackedScene = preload("res://gui/game/card/card_section.tscn")
|
||||
|
||||
@export var small_mode : bool = false
|
||||
@export var down_arrow : bool = false
|
||||
|
||||
@export var info : CardInfo = CardInfo.new("Default Card Name")
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
@export_tool_button("Reset Size", "Callable") var reset_size_action = func(): reset_size()
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
# func _ready():
|
||||
# update()
|
||||
|
||||
func update():
|
||||
%CardTitle.text = info.title
|
||||
%CardUpperPart.self_modulate = info.bg_color
|
||||
%CardTypeIcon.texture = info.type_icon
|
||||
%EntityTexture.texture = info.texture
|
||||
pass
|
||||
%Title.text = info.title
|
||||
%Subtitle.visible = info.subtitle != ""
|
||||
%Subtitle.text = info.subtitle
|
||||
|
||||
%ImportantStat.visible = info.important_stat_text != "" or info.important_stat_icon != null
|
||||
%ImportantStatIcon.texture = info.important_stat_icon
|
||||
%ImportantStatText.text = info.important_stat_text
|
||||
|
||||
%ArrowDown.visible = down_arrow
|
||||
|
||||
self_modulate = Color.TRANSPARENT if small_mode else Color.WHITE
|
||||
%CardUpperPart.self_modulate.a = 0.7 if small_mode else 1.0
|
||||
|
||||
update_card_stats()
|
||||
update_card_sections()
|
||||
|
||||
await get_tree().create_timer(0.01).timeout
|
||||
|
||||
reset_size()
|
||||
|
||||
func update_card_stats():
|
||||
for stat in %CardStatsContainer.get_children():
|
||||
for stat in %StatsContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
%StatsContainer.visible = len(info.stats) > 0
|
||||
%StatsContainer.columns = max(1,len(info.stats))
|
||||
|
||||
for stat_info in info.stats:
|
||||
if stat_info:
|
||||
var new_stat : CardStat = CARD_STAT_SCENE.instantiate() as CardStat
|
||||
new_stat.info = stat_info
|
||||
%CardStatsContainer.add_child(new_stat)
|
||||
|
||||
%CardStats.visible = len(info.stats) != 0 && small_mode == false
|
||||
%StatsContainer.add_child(new_stat)
|
||||
|
||||
func update_card_sections():
|
||||
for stat in %CardSectionsContainer.get_children():
|
||||
for stat in %SectionContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
%SectionContainer.visible = len(info.sections) > 0
|
||||
|
||||
for sections_info in info.sections:
|
||||
if sections_info:
|
||||
var new_section : CardSection = CARD_SECTION_SCENE.instantiate() as CardSection
|
||||
new_section.info = sections_info
|
||||
%CardSectionsContainer.add_child(new_section)
|
||||
|
||||
%CardSections.visible = len(%CardSectionsContainer.get_children()) != 0 && small_mode == false
|
||||
%SectionContainer.add_child(new_section)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ extends Resource
|
||||
class_name CardInfo
|
||||
|
||||
@export var title : String
|
||||
@export var bg_color : Color = Color("2364aaff")
|
||||
@export var subtitle : String
|
||||
@export var type_icon : Texture = preload("res://common/icons/cube-3d-sphere.svg")
|
||||
@export var texture : Texture
|
||||
|
||||
@@ -14,5 +14,7 @@ class_name CardInfo
|
||||
|
||||
func _init(
|
||||
_title : String = "",
|
||||
_subtitle : String = ""
|
||||
):
|
||||
title = _title
|
||||
title = _title
|
||||
subtitle = _subtitle
|
||||
@@ -1,5 +1,5 @@
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
extends PanelContainer
|
||||
class_name CardSection
|
||||
|
||||
const DEFAULT_ICON_COLOR = Color("96b3dbff")
|
||||
@@ -16,5 +16,4 @@ func update():
|
||||
%Text.text = info.text
|
||||
%TitleIcon.texture = info.title_icon
|
||||
%TitleText.text = info.title_text
|
||||
%TitleIcon.modulate = info.title_color if info.title_colored else DEFAULT_ICON_COLOR
|
||||
%TitleText.modulate = info.title_color if info.title_colored else DEFAULT_TITLE_COLOR
|
||||
self_modulate = info.color
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
extends Resource
|
||||
class_name CardSectionInfo
|
||||
|
||||
@export var title_colored : bool = false
|
||||
@export var title_color : Color = Color("25c147ff")
|
||||
@export var color : Color = Color('2364aaff')
|
||||
@export var title_text : String = ""
|
||||
@export var title_icon : Texture = null
|
||||
@export_multiline var text : String = ""
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
extends PanelContainer
|
||||
class_name CardStat
|
||||
|
||||
var is_ready = false
|
||||
@@ -16,5 +16,7 @@ func _ready():
|
||||
update()
|
||||
|
||||
func update():
|
||||
%RichTextLabel.visible = info.text != ""
|
||||
%RichTextLabel.text = info.text
|
||||
%TextureRect.visible = info.icon != null
|
||||
%TextureRect.texture = info.icon
|
||||
|
||||
@@ -20,14 +20,6 @@ var is_ready = false
|
||||
if is_ready :
|
||||
update()
|
||||
|
||||
@export var small_mode : bool = true :
|
||||
set(v):
|
||||
var old = small_mode
|
||||
small_mode = v
|
||||
if is_ready and old != small_mode :
|
||||
update()
|
||||
|
||||
@export var interactive_small_mode : bool = true
|
||||
@export var interactive_zoom : bool = false
|
||||
|
||||
@export var down_arrow : bool = true :
|
||||
@@ -62,11 +54,9 @@ func _process(_d):
|
||||
|
||||
if is_mouse_over():
|
||||
wanted_rot = center_relative_mouse_position * MAX_ROT
|
||||
if interactive_small_mode: small_mode = false
|
||||
if interactive_zoom: scale = scale.lerp(Vector2.ONE * ZOOM_SCALE, 0.2)
|
||||
else:
|
||||
wanted_rot = Vector2.ZERO
|
||||
if interactive_small_mode: small_mode = true
|
||||
if interactive_zoom: scale = scale.lerp(Vector2.ONE, 0.2)
|
||||
|
||||
real_rot = real_rot.lerp(wanted_rot, 0.1)
|
||||
@@ -92,7 +82,6 @@ func is_mouse_over() -> bool:
|
||||
func update():
|
||||
if card_info:
|
||||
%Card.info = card_info
|
||||
%Card.small_mode = small_mode
|
||||
%Card.down_arrow = down_arrow
|
||||
%Card.update()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user