ajout des mutation et refonte de l'inspecteur
* ajout des mutations #86 * changement de l'objectif #85 * refonte de l'inspecteur #71 * changement léger de la plantation * les plantes ne donnent que des graines de leurs espèces * refonte partielle du code, refacto
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
extends Control
|
||||
class_name Inspector
|
||||
|
||||
const FRAMED_INFO_SCENE : PackedScene = preload("res://gui/game/inspector/framed_info/framed_info.tscn")
|
||||
const STAT_INFO_SCENE : PackedScene = preload("res://gui/game/inspector/stat_info/stat_info.tscn")
|
||||
|
||||
var info : Info = null :
|
||||
set(i):
|
||||
info = i
|
||||
@@ -19,11 +22,33 @@ func update_info(i : Info):
|
||||
%Texture.visible = i.texture != null
|
||||
%Title.text = i.title
|
||||
%Desc.text = i.description
|
||||
%Desc.visible = i.description != ""
|
||||
update_framed_infos(info.framed_infos)
|
||||
update_stat_info(info.stat_infos)
|
||||
|
||||
func update_framed_infos(framed_infos : Array[FramedInfo]):
|
||||
for c in %FramedInfos.get_children() :
|
||||
c.queue_free()
|
||||
for i in range(len(framed_infos)):
|
||||
var frame_info_object = FRAMED_INFO_SCENE.instantiate()
|
||||
%FramedInfos.add_child(frame_info_object)
|
||||
frame_info_object.framed_info = framed_infos[i]
|
||||
|
||||
func update_stat_info(stat_infos):
|
||||
%StatInfos.visible = len(stat_infos) != 0
|
||||
for c in %StatInfos.get_children() :
|
||||
c.queue_free()
|
||||
for i in range(len(stat_infos)):
|
||||
var stat_inof_object = STAT_INFO_SCENE.instantiate()
|
||||
%StatInfos.add_child(stat_inof_object)
|
||||
stat_inof_object.stat_info = stat_infos[i]
|
||||
|
||||
class Info:
|
||||
var title : String
|
||||
var texture: Texture
|
||||
var description : String
|
||||
var title : String = ""
|
||||
var texture: Texture = null
|
||||
var description : String = ""
|
||||
var framed_infos : Array[Inspector.FramedInfo] = []
|
||||
var stat_infos = []
|
||||
|
||||
func _init(
|
||||
_title : String = "",
|
||||
@@ -32,4 +57,39 @@ class Info:
|
||||
):
|
||||
title = _title
|
||||
description = _description
|
||||
texture = _texture
|
||||
texture = _texture
|
||||
|
||||
func add_framed_info(framed_info : Inspector.FramedInfo):
|
||||
framed_infos.push_front(framed_info)
|
||||
|
||||
func add_stat_info(s_info : Inspector.StatInfo):
|
||||
stat_infos.push_front(s_info)
|
||||
|
||||
|
||||
class FramedInfo:
|
||||
var title : String
|
||||
var icon: Texture
|
||||
var description : String
|
||||
var bg_color : Color
|
||||
|
||||
func _init(
|
||||
_title : String = "",
|
||||
_desc : String = "",
|
||||
_icon : Texture = null,
|
||||
_bg_color : Color = Color("0B1326")
|
||||
):
|
||||
title = _title
|
||||
description = _desc
|
||||
icon = _icon
|
||||
bg_color = _bg_color
|
||||
|
||||
class StatInfo:
|
||||
var text : String
|
||||
var icon: Texture
|
||||
|
||||
func _init(
|
||||
_text : String = "",
|
||||
_icon : Texture = null,
|
||||
):
|
||||
text = _text
|
||||
icon = _icon
|
||||
|
||||
Reference in New Issue
Block a user