refonte de l'inspecteur #61
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
[gd_scene load_steps=30 format=3 uid="uid://12nak7amd1uq"]
|
||||
[gd_scene load_steps=25 format=3 uid="uid://12nak7amd1uq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cqao7n800qy40" path="res://gui/game/scripts/game_gui.gd" id="1_udau0"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_nq5i2"]
|
||||
[ext_resource type="Texture2D" uid="uid://cm3ehinvvj52i" path="res://gui/game/assets/texture/Interface sans boutons.png" id="3_n4kem"]
|
||||
[ext_resource type="Texture2D" uid="uid://dcgnamu7sb3ov" path="res://gui/game/assets/icons/bolt.svg" id="4_k4juk"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="4_ujg5r"]
|
||||
[ext_resource type="Texture2D" uid="uid://c2pgaklnj5w3d" path="res://gui/game/assets/texture/Tablette info.png" id="6_fovlv"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_n4kem"]
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="8_n4kem"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3lff5fui1k0c" path="res://gui/game/inspector/inspector.tscn" id="6_dr1y2"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5cuxgisrsfgt" path="res://gui/game/pause/assets/icons/player-pause.svg" id="9_2wykm"]
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_id0t5"]
|
||||
@@ -20,6 +18,21 @@ gradient = SubResource("Gradient_id0t5")
|
||||
fill_to = Vector2(1, 1)
|
||||
repeat = 1
|
||||
|
||||
[sub_resource type="Animation" id="Animation_l73to"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0.950568, 0, 0.346412, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_p6blc"]
|
||||
resource_name = "default"
|
||||
loop_mode = 1
|
||||
@@ -36,38 +49,12 @@ tracks/0/keys = {
|
||||
"values": [Color(0.950568, 0, 0.346412, 1), Color(0.999996, 0.39403, 0.49625, 1), Color(0.950568, 0, 0.346412, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_l73to"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(0.950568, 0, 0.346412, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_l3q4a"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_l73to"),
|
||||
&"default": SubResource("Animation_p6blc")
|
||||
}
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ek73b"]
|
||||
atlas = ExtResource("7_n4kem")
|
||||
region = Rect2(76, 75, 124, 135)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ek73b"]
|
||||
font = ExtResource("8_n4kem")
|
||||
font_size = 20
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_n4kem"]
|
||||
font_size = 12
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_2wykm"]
|
||||
offsets = PackedFloat32Array(0, 0.279476, 1)
|
||||
colors = PackedColorArray(1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1)
|
||||
@@ -142,21 +129,6 @@ _data = {
|
||||
&"pass_day": SubResource("Animation_ykapk")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2wykm"]
|
||||
resource_name = "upgrade"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.9),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.6, 0.580392, 0, 0), Color(0.600196, 0.581106, 0, 0.392157), Color(0.6, 0.580392, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_l3q4a"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
@@ -172,12 +144,42 @@ tracks/0/keys = {
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_2wykm"]
|
||||
resource_name = "upgrade"
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:modulate")
|
||||
tracks/0/interp = 2
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.2, 0.9),
|
||||
"transitions": PackedFloat32Array(1, 1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(0.6, 0.580392, 0, 0), Color(0.600196, 0.581106, 0, 0.392157), Color(0.6, 0.580392, 0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_nhqnj"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_l3q4a"),
|
||||
&"upgrade": SubResource("Animation_2wykm")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_mbdxg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("NoEnergyLeft:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, -100)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_w16yr"]
|
||||
resource_name = "no_energy_left_appear"
|
||||
length = 0.5
|
||||
@@ -194,21 +196,6 @@ tracks/0/keys = {
|
||||
"values": [Vector2(0, -100), Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_mbdxg"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("NoEnergyLeft:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, -100)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_p0xoq"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_mbdxg"),
|
||||
@@ -332,56 +319,10 @@ label_settings = ExtResource("4_ujg5r")
|
||||
horizontal_alignment = 1
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ItemInfo" type="TextureRect" parent="MarginContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 300)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
theme = ExtResource("2_nq5i2")
|
||||
texture = ExtResource("6_fovlv")
|
||||
expand_mode = 3
|
||||
stretch_mode = 4
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="MarginContainer/ItemInfo"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 35
|
||||
theme_override_constants/margin_top = 35
|
||||
theme_override_constants/margin_right = 20
|
||||
theme_override_constants/margin_bottom = 75
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/ItemInfo/MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_nq5i2")
|
||||
|
||||
[node name="ItemIcon" type="TextureRect" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
texture = SubResource("AtlasTexture_ek73b")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="ItemName" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"]
|
||||
[node name="Inspector" parent="MarginContainer" instance=ExtResource("6_dr1y2")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "fdqsd"
|
||||
label_settings = SubResource("LabelSettings_ek73b")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ItemDesc" type="Label" parent="MarginContainer/ItemInfo/MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
text = "Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. "
|
||||
label_settings = SubResource("LabelSettings_n4kem")
|
||||
autowrap_mode = 3
|
||||
clip_text = true
|
||||
size_flags_horizontal = 8
|
||||
|
||||
[node name="TopRightContent" type="HBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
69
gui/game/inspector/inspector.tscn
Normal file
69
gui/game/inspector/inspector.tscn
Normal file
@@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://d3lff5fui1k0c"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_f5bv4"]
|
||||
[ext_resource type="Texture2D" uid="uid://c2pgaklnj5w3d" path="res://gui/game/assets/texture/Tablette info.png" id="2_a8c2j"]
|
||||
[ext_resource type="Script" uid="uid://b36bjfq4sng36" path="res://gui/game/inspector/scripts/inspector.gd" id="3_a8c2j"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="3_qfinp"]
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="4_yijvw"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ek73b"]
|
||||
atlas = ExtResource("3_qfinp")
|
||||
region = Rect2(76, 75, 124, 135)
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_ek73b"]
|
||||
font = ExtResource("4_yijvw")
|
||||
font_size = 20
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_n4kem"]
|
||||
font_size = 12
|
||||
|
||||
[node name="Inspector" type="TextureRect"]
|
||||
custom_minimum_size = Vector2(0, 300)
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 8
|
||||
theme = ExtResource("1_f5bv4")
|
||||
texture = ExtResource("2_a8c2j")
|
||||
expand_mode = 3
|
||||
stretch_mode = 4
|
||||
script = ExtResource("3_a8c2j")
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_constants/margin_left = 40
|
||||
theme_override_constants/margin_top = 40
|
||||
theme_override_constants/margin_right = 25
|
||||
theme_override_constants/margin_bottom = 75
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("1_f5bv4")
|
||||
|
||||
[node name="Texture" type="TextureRect" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
custom_minimum_size = Vector2(0, 50)
|
||||
layout_mode = 2
|
||||
texture = SubResource("AtlasTexture_ek73b")
|
||||
expand_mode = 1
|
||||
stretch_mode = 5
|
||||
|
||||
[node name="Title" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "fdqsd dqsdq dsqdqsd"
|
||||
label_settings = SubResource("LabelSettings_ek73b")
|
||||
horizontal_alignment = 1
|
||||
autowrap_mode = 2
|
||||
|
||||
[node name="Desc" type="Label" parent="MarginContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
text = "Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. Ceci est une pelle qui sert exclusivement à faire des choses intéressantes. "
|
||||
label_settings = SubResource("LabelSettings_n4kem")
|
||||
autowrap_mode = 3
|
||||
clip_text = true
|
||||
35
gui/game/inspector/scripts/inspector.gd
Normal file
35
gui/game/inspector/scripts/inspector.gd
Normal file
@@ -0,0 +1,35 @@
|
||||
extends Control
|
||||
class_name Inspector
|
||||
|
||||
var info : Info = null :
|
||||
set(i):
|
||||
info = i
|
||||
update_info(i)
|
||||
|
||||
func _ready():
|
||||
update_info(info)
|
||||
|
||||
func update_info(i : Info):
|
||||
if i == null:
|
||||
visible = false
|
||||
else :
|
||||
visible = true
|
||||
if i.texture:
|
||||
%Texture.texture = i.texture
|
||||
%Texture.visible = i.texture != null
|
||||
%Title.text = i.title
|
||||
%Desc.text = i.description
|
||||
|
||||
class Info:
|
||||
var title : String
|
||||
var texture: Texture
|
||||
var description : String
|
||||
|
||||
func _init(
|
||||
_title : String = "",
|
||||
_description : String = "",
|
||||
_texture : Texture = null,
|
||||
):
|
||||
title = _title
|
||||
description = _description
|
||||
texture = _texture
|
||||
1
gui/game/inspector/scripts/inspector.gd.uid
Normal file
1
gui/game/inspector/scripts/inspector.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b36bjfq4sng36
|
||||
@@ -3,19 +3,15 @@ class_name GameGui
|
||||
|
||||
signal pause_asked
|
||||
|
||||
func _ready():
|
||||
Pointer.connect("inspected_entity_changed", _on_inspected_entity_changed)
|
||||
|
||||
func _on_player_updated(player:Player):
|
||||
%EnergyCount.text = str(player.energy) + "/" + str(player.max_energy)
|
||||
%EnergyInfo.modulate = Color.WHITE if player.energy > 0 else Color.RED
|
||||
|
||||
update_no_energy_left_info(player.energy)
|
||||
|
||||
%ItemInfo.visible = player.inventory.get_item() != null
|
||||
if player.inventory.get_item():
|
||||
var item : Item = player.inventory.get_item()
|
||||
%ItemIcon.texture = item.icon
|
||||
%ItemName.text = item.name
|
||||
%ItemDesc.text = item.description
|
||||
|
||||
func _on_day_pass_pressed():
|
||||
|
||||
await $AnimationPlayer.animation_finished
|
||||
@@ -44,6 +40,12 @@ func _on_planet_pass_day_started(planet):
|
||||
await $PassDayAnimation.animation_finished
|
||||
$PassDayAnimation.speed_scale = 1
|
||||
|
||||
func _on_inspected_entity_changed(e : InspectableEntity):
|
||||
var info : Inspector.Info = null
|
||||
if e:
|
||||
info = e.inspector_info()
|
||||
%Inspector.info = info
|
||||
|
||||
func update_no_energy_left_info(energy):
|
||||
if energy == 0 and not %NoEnergyLeft.visible:
|
||||
%NoEnergyLeft.visible = true
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
extends Node
|
||||
|
||||
signal inspected_entity_changed(e : InspectableEntity)
|
||||
|
||||
const DEFAULT_ACTION_COLOR = Color.WHITE
|
||||
const ENERGY_ACTION_COLOR = Color("ffff2b")
|
||||
|
||||
@export var default_cursor : Texture2D
|
||||
|
||||
var inspected_entity : InspectableEntity = null
|
||||
var inspected_entity : InspectableEntity = null :
|
||||
set(e):
|
||||
inspected_entity = e
|
||||
inspected_entity_changed.emit(e)
|
||||
var player : Player # renseigné par Player
|
||||
var can_interact : bool = false
|
||||
var current_selected_item : Item = null
|
||||
@@ -72,7 +77,7 @@ func inspect_entity(entity : InspectableEntity):
|
||||
func update_inspector():
|
||||
%InspectorText.visible = inspected_entity != null
|
||||
if inspected_entity:
|
||||
%InspectorText.text = inspected_entity.inspected_text()
|
||||
%InspectorText.text = inspected_entity.pointer_text()
|
||||
|
||||
if player:
|
||||
if can_interact and inspected_entity and inspected_entity is Interactable:
|
||||
|
||||
Reference in New Issue
Block a user