file refactor
This commit is contained in:
parent
da5a3e874b
commit
bffb012a26
175 changed files with 1086 additions and 1107 deletions
24
scripts/gui/choose_your_seeds/GridLoader.cs
Normal file
24
scripts/gui/choose_your_seeds/GridLoader.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Godot;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class GridLoader : GridContainer
|
||||
{
|
||||
private const string PLANT_RESOURCE_PATH = "res://resources/plants/";
|
||||
private PackedScene _plantCard;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
||||
|
||||
foreach(var resource in GameRegistry.GetPlants())
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetResource(resource);
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/GridLoader.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/GridLoader.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://eq3ecja30mlj
|
||||
16
scripts/gui/choose_your_seeds/LevelRunButton.cs
Normal file
16
scripts/gui/choose_your_seeds/LevelRunButton.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class LevelRunButton : Button
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
public override void _Pressed()
|
||||
{
|
||||
RuntimeLevelData.Instance.SetLevelState(RuntimeLevelData.LevelStates.Game);
|
||||
GetTree().Paused = false;
|
||||
|
||||
_player.Play("Hide");
|
||||
}
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/LevelRunButton.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/LevelRunButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d26waisd3v488
|
||||
51
scripts/gui/choose_your_seeds/Previewport.cs
Normal file
51
scripts/gui/choose_your_seeds/Previewport.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using Newlon.Components;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
using Newlon.Components.Plants;
|
||||
|
||||
public partial class Previewport : SubViewport
|
||||
{
|
||||
private Node current_display;
|
||||
private Texture2D start_Field;
|
||||
|
||||
[Export] private Label title;
|
||||
[Export] private RichTextLabel description;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
GetParent().GetViewport().GuiFocusChanged += OnFocusChanged;
|
||||
start_Field = GetNode<Sprite2D>("FrameField").Texture;
|
||||
}
|
||||
|
||||
public void OnFocusChanged(Control node)
|
||||
{
|
||||
if (GetParent<Control>().IsVisibleInTree() == false) return;
|
||||
if (node is Seedpacket packet)
|
||||
{
|
||||
ChangeDisplay(packet.GetResource());
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDisplay(DisplayResource resource)
|
||||
{
|
||||
// Expand with updates
|
||||
if (current_display != null)
|
||||
{
|
||||
current_display.QueueFree();
|
||||
}
|
||||
if (resource.customFrame != null && resource.customFrame.almanachField != null)
|
||||
{
|
||||
GetNode<Sprite2D>("FrameField").Texture = resource.customFrame.almanachField;
|
||||
}
|
||||
else
|
||||
GetNode<Sprite2D>("FrameField").Texture = start_Field;
|
||||
current_display = resource.Scene.Instantiate();
|
||||
title.Text = Tr(resource.name_key);
|
||||
description.Text = Tr(resource.description_key);
|
||||
AddChild(current_display);
|
||||
if (current_display is Entity entity)
|
||||
entity.DisableBrain();
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/Previewport.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/Previewport.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://covbig00p22di
|
||||
Loading…
Add table
Add a link
Reference in a new issue