using Godot;
using System;
using SessionZeroClient.API;

namespace SessionZeroClient;

public partial class Main : Node
{
    [Export] public CanvasLayer MainCanvasLayer { get; set; }
    [Export] public PackedScene AccountScreenScene { get; set; }
    
    private IApiHandler _apiHandler;
    private AccountScreenLogic _accountScreenLogic;
    private AccountManager _accountManager;
    
    public override void _Ready()
    {
        _apiHandler = new ApiHandler();
        _accountManager = new AccountManager(_apiHandler);
        SetupAccountScreen();
    }
    
    private void SetupAccountScreen()
    {
        try
        {
            _accountScreenLogic = AccountScreenScene.Instantiate() as AccountScreenLogic;
            _accountScreenLogic.Init(_accountManager);
            MainCanvasLayer.AddChild(_accountScreenLogic);
        }
        catch (Exception e)
        {
            throw new Exception($"Error instantiating AccountScreenLogic: {e.Message}");
        }
    }
    
}
