basically function but needs a lot of refinement

This commit is contained in:
2024-04-23 03:24:23 -05:00
parent 3ac7bf33c4
commit d3beca8014
26 changed files with 985 additions and 345 deletions

View File

@@ -1,7 +1,7 @@
using Godot;
using System;
public partial class card_preview : Control
public partial class card_preview : PanelContainer
{
[Export]
private string _CardName;
@@ -39,7 +39,7 @@ public partial class card_preview : Control
public void SetTexture(Texture2D texture)
{
_Texture = texture;
if (IsNodeReady())
// if (IsNodeReady())
PropogateTexture();
}
private void PropogateTexture()
@@ -55,6 +55,7 @@ public partial class card_preview : Control
{
PropogateCardId();
PropogateCardName();
GD.Print(Size);
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -75,13 +76,19 @@ public partial class card_preview : Control
}
public static card_preview MakePreview(card c)
{
const float TRANSPARENCY = 0.25f;
const float TRANSPARENCY = 0.75f;
var scene = GD.Load<PackedScene>("res://card_preview.tscn");
var prev = scene.Instantiate() as card_preview;
prev.CardName = c.CardName;
prev.CardId = c.CardId;
prev.SetTexture(c.GetTexture());
prev.Size = c.Size;
// prev.Size = c.Size;
var tr = prev.GetNode<TextureRect>("%CardPreviewImage");
tr.CustomMinimumSize = c.Size;
var ci = c.GetNode<TextureRect>("%CardImage");
tr.ExpandMode = ci.ExpandMode;
tr.StretchMode = ci.StretchMode;
prev.GetNode<Control>("%CardPreviewImage").CustomMinimumSize = c.Size;
prev.Scale = c.Scale;
prev.Modulate = new(1, 1, 1, TRANSPARENCY);
return prev;