gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police * Ajout d'un semblant d'exploration * Ajout de la sauvegarde des entités * Restructuration mineure de l'arborescence * Fix divers et réécriture des textes
This commit is contained in:
57
gui/game/card/scripts/card.gd
Normal file
57
gui/game/card/scripts/card.gd
Normal file
@@ -0,0 +1,57 @@
|
||||
@tool
|
||||
extends PanelContainer
|
||||
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
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
|
||||
func update():
|
||||
%CardTitle.text = info.title
|
||||
%CardUpperPart.self_modulate = info.bg_color
|
||||
%CardTypeIcon.texture = info.type_icon
|
||||
%EntityTexture.texture = info.texture
|
||||
|
||||
%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()
|
||||
|
||||
func update_card_stats():
|
||||
for stat in %CardStatsContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
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
|
||||
|
||||
func update_card_sections():
|
||||
for stat in %CardSectionsContainer.get_children():
|
||||
stat.queue_free()
|
||||
|
||||
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
|
||||
1
gui/game/card/scripts/card.gd.uid
Normal file
1
gui/game/card/scripts/card.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b7f10wuounfan
|
||||
18
gui/game/card/scripts/card_info.gd
Normal file
18
gui/game/card/scripts/card_info.gd
Normal file
@@ -0,0 +1,18 @@
|
||||
extends Resource
|
||||
class_name CardInfo
|
||||
|
||||
@export var title : String
|
||||
@export var bg_color : Color = Color("2364aaff")
|
||||
@export var type_icon : Texture = preload("res://common/icons/cube-3d-sphere.svg")
|
||||
@export var texture : Texture
|
||||
|
||||
@export var important_stat_text : String
|
||||
@export var important_stat_icon : Texture
|
||||
|
||||
@export var stats : Array[CardStatInfo] = []
|
||||
@export var sections : Array[CardSectionInfo] = []
|
||||
|
||||
func _init(
|
||||
_title : String = "",
|
||||
):
|
||||
title = _title
|
||||
1
gui/game/card/scripts/card_info.gd.uid
Normal file
1
gui/game/card/scripts/card_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dj2pv1hiwjfv0
|
||||
20
gui/game/card/scripts/card_section.gd
Normal file
20
gui/game/card/scripts/card_section.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
class_name CardSection
|
||||
|
||||
const DEFAULT_ICON_COLOR = Color("96b3dbff")
|
||||
const DEFAULT_TITLE_COLOR = Color("100f2bff")
|
||||
|
||||
@export var info : CardSectionInfo = CardSectionInfo.new()
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
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
|
||||
1
gui/game/card/scripts/card_section.gd.uid
Normal file
1
gui/game/card/scripts/card_section.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dcmee2jvohudl
|
||||
15
gui/game/card/scripts/card_section_info.gd
Normal file
15
gui/game/card/scripts/card_section_info.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
extends Resource
|
||||
class_name CardSectionInfo
|
||||
|
||||
@export var title_colored : bool = false
|
||||
@export var title_color : Color = Color("25c147ff")
|
||||
@export var title_text : String = ""
|
||||
@export var title_icon : Texture = null
|
||||
@export_multiline var text : String = ""
|
||||
|
||||
func _init(
|
||||
_title_text : String = "",
|
||||
_text : String = ""
|
||||
):
|
||||
title_text = _title_text
|
||||
text = _text
|
||||
1
gui/game/card/scripts/card_section_info.gd.uid
Normal file
1
gui/game/card/scripts/card_section_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dgbh38j13g5kn
|
||||
20
gui/game/card/scripts/card_stat.gd
Normal file
20
gui/game/card/scripts/card_stat.gd
Normal file
@@ -0,0 +1,20 @@
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
class_name CardStat
|
||||
|
||||
var is_ready = false
|
||||
|
||||
@export var info : CardStatInfo = CardStatInfo.new() :
|
||||
set(v):
|
||||
info = v
|
||||
if is_ready : update()
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
func _ready():
|
||||
is_ready = true
|
||||
update()
|
||||
|
||||
func update():
|
||||
%RichTextLabel.text = info.text
|
||||
%TextureRect.texture = info.icon
|
||||
1
gui/game/card/scripts/card_stat.gd.uid
Normal file
1
gui/game/card/scripts/card_stat.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c8xxhu28xm4hy
|
||||
12
gui/game/card/scripts/card_stat_info.gd
Normal file
12
gui/game/card/scripts/card_stat_info.gd
Normal file
@@ -0,0 +1,12 @@
|
||||
extends Resource
|
||||
class_name CardStatInfo
|
||||
|
||||
@export var text : String = ""
|
||||
@export var icon : Texture = null
|
||||
|
||||
func _init(
|
||||
_text : String = "",
|
||||
_icon : Texture = null,
|
||||
):
|
||||
icon = _icon
|
||||
text = _text
|
||||
1
gui/game/card/scripts/card_stat_info.gd.uid
Normal file
1
gui/game/card/scripts/card_stat_info.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b4tkium34c831
|
||||
62
gui/game/card/scripts/card_visualiser.gd
Normal file
62
gui/game/card/scripts/card_visualiser.gd
Normal file
@@ -0,0 +1,62 @@
|
||||
@tool
|
||||
extends TextureRect
|
||||
|
||||
const MAX_ROT = 15
|
||||
const ZOOM_SCALE = 1.0
|
||||
|
||||
var wanted_rot : Vector2 = Vector2.ZERO
|
||||
var real_rot : Vector2 = Vector2.ZERO
|
||||
var wanted_scale : Vector2 = Vector2.ONE
|
||||
|
||||
var is_ready = false
|
||||
|
||||
@export var small_mode : bool = false :
|
||||
set(v):
|
||||
small_mode = v
|
||||
if is_ready : update()
|
||||
|
||||
@export var card_info : CardInfo = null :
|
||||
set(v):
|
||||
card_info = v
|
||||
if is_ready : update()
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
func _ready():
|
||||
material = material.duplicate()
|
||||
update()
|
||||
is_ready = true
|
||||
|
||||
func _process(_d):
|
||||
var center_relative_mouse_position = (get_local_mouse_position() - size/2) / size
|
||||
|
||||
if is_mouse_over():
|
||||
wanted_rot = center_relative_mouse_position * MAX_ROT
|
||||
small_mode = false
|
||||
else:
|
||||
wanted_rot = Vector2.ZERO
|
||||
small_mode = true
|
||||
|
||||
real_rot = real_rot.lerp(wanted_rot, 0.1)
|
||||
|
||||
material.set_shader_parameter("y_rot", - real_rot.x)
|
||||
material.set_shader_parameter("x_rot", real_rot.y)
|
||||
|
||||
%SubViewport.size.y = %CardContainer.size.y
|
||||
size = %SubViewport.size
|
||||
|
||||
|
||||
func is_mouse_over() -> bool:
|
||||
var center_relative_mouse_position = (get_local_mouse_position() - size/2) / size
|
||||
|
||||
return (
|
||||
abs(center_relative_mouse_position.x) < 0.5
|
||||
and abs(center_relative_mouse_position.y) < 0.5
|
||||
)
|
||||
|
||||
func update():
|
||||
|
||||
if card_info:
|
||||
%Card.info = card_info
|
||||
%Card.small_mode = small_mode
|
||||
%Card.update()
|
||||
1
gui/game/card/scripts/card_visualiser.gd.uid
Normal file
1
gui/game/card/scripts/card_visualiser.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dj5pld5ragrjp
|
||||
Reference in New Issue
Block a user