using Serilog.Events;
using System;
using System.Collections.Generic;
using System.IO;

namespace VeloeMinecraftLauncher.Utils;

public class SettingsSerializable : ICloneable
{
    public string JavaPath { get; set; } = string.Empty;
    public string MinecraftForlderPath { get; set; } = Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar;
    public UInt32 MaxRam { get; set; } = 2048;
    public bool UseCustomJava { get; set; } = false;
    public bool SetMaxRam { get; set; } = false;
    public bool SetPath { get; set; } = true;
    public bool CheckGameAssets { get; set; } = false;

    public bool GameLogToLauncher { get; set; } = false;

    public string Username { get; set; } = string.Empty;

    public string LastChosenVersion { get; set; } = string.Empty;

    public bool SetMaxLog { get; set; } = false;
    public UInt32 MaxLog { get; set; } = 1024;

    public bool FullScreen { get; set; } = false;
    public bool CustomSize { set; get; } = false;
    public UInt32 ClientWidth { get; set; } = 1280;
    public UInt32 ClientHeight { get; set; } = 720;

    public bool HideLauncher { get; set; } = false;

    public LogEventLevel ConsoleLogEventLevel { get; set; } = LogEventLevel.Debug;
    public LogEventLevel FileLogEventLevel { get; set; } = LogEventLevel.Debug;

    public Dictionary<string, string> ServerAutoConnectLinks { get; set; } = new();

    public object Clone()
    {
        return MemberwiseClone();
    }

    public override bool Equals(object? obj)
    {
        return obj is SettingsSerializable serializable &&
               MaxRam == serializable.MaxRam &&
               UseCustomJava == serializable.UseCustomJava &&
               SetMaxRam == serializable.SetMaxRam &&
               SetPath == serializable.SetPath &&
               CheckGameAssets == serializable.CheckGameAssets &&
               GameLogToLauncher == serializable.GameLogToLauncher &&
               SetMaxLog == serializable.SetMaxLog &&
               MaxLog == serializable.MaxLog &&
               FullScreen == serializable.FullScreen &&
               LastChosenVersion == serializable.LastChosenVersion &&
               Username == serializable.Username &&
               CustomSize == serializable.CustomSize &&
               ClientWidth == serializable.ClientWidth &&
               ClientHeight == serializable.ClientHeight &&
               HideLauncher == serializable.HideLauncher &&
               ConsoleLogEventLevel == serializable.ConsoleLogEventLevel &&
               FileLogEventLevel == serializable.FileLogEventLevel &&
               MinecraftForlderPath == serializable.MinecraftForlderPath &&
               JavaPath == serializable.JavaPath;
    }

    public override int GetHashCode()
    {
        HashCode hash = new HashCode();
        hash.Add(JavaPath);
        hash.Add(MinecraftForlderPath);
        hash.Add(MaxRam);
        hash.Add(UseCustomJava);
        hash.Add(SetMaxRam);
        hash.Add(SetPath);
        hash.Add(CheckGameAssets);
        hash.Add(GameLogToLauncher);
        hash.Add(Username);
        hash.Add(LastChosenVersion);
        hash.Add(SetMaxLog);
        hash.Add(MaxLog);
        hash.Add(FullScreen);
        hash.Add(CustomSize);
        hash.Add(ClientWidth);
        hash.Add(ClientHeight);
        hash.Add(HideLauncher);
        hash.Add(ConsoleLogEventLevel);
        hash.Add(FileLogEventLevel);
        return hash.ToHashCode();
    }
}
