mirror of
https://codeberg.org/Ikatono/TierMaker.git
synced 2025-10-28 20:45:35 -05:00
forgot to push for a while, got drag-and-drop mostly working
This commit is contained in:
34
PictureDropHandler.cs
Normal file
34
PictureDropHandler.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public partial class PictureDropHandler : Control
|
||||
{
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
GetTree().Root.FilesDropped += HandleDroppedFiles;
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
}
|
||||
public void HandleDroppedFiles(IEnumerable<string> paths)
|
||||
{
|
||||
//var cont = GetNode<HFlowContainer>("%UnassignedCardContainer");
|
||||
var g = GetNode<game>("/root/Game");
|
||||
foreach (var path in paths)
|
||||
{
|
||||
var img = new Image();
|
||||
img.Load(path);
|
||||
var tex = ImageTexture.CreateFromImage(img);
|
||||
if (tex is null)
|
||||
continue;
|
||||
var c = card.MakeCard(GetTree());
|
||||
c.SetImage(tex);
|
||||
g.AddUnassignedCard(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user