using Godot;

namespace Cirno.Scripts.Resources.DebugMenu;

[GlobalClass]
public partial class DebugMapSelectResource : Resource
{
    [Export] public bool Enabled { get; private set; } = true;
    [Export] public MapResource Map { get; private set; }
    [Export] public string Path { get; private set; }

    [Export] private string _name { get; set; }
    
    [Export] public MapStartDataResource StartData { get; private set; }
    
    [Export] public Texture2D Icon { get; private set; }
    
    public string ScenePath => Map is not null ? Map.ScenePath : Path;
    
    public string DisplayName
    {
        get
        {
            if (!string.IsNullOrWhiteSpace(_name))
            {
                return _name;
            }

            if (!string.IsNullOrWhiteSpace(Path))
            {
                return Path.Split("/")[^1].Split(".")[0];
            }

            return string.Empty;
        }
        set => _name = value;
    }
}