﻿using System;
using System.Reflection.Emit;
using System.Runtime.Versioning;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;

[InitializeOnLoad]
public class Credits : EditorWindow
{
    public Texture2D logo;
    public Texture2D kitto;


    static Credits()
    {
        AssetDatabase.importPackageCompleted += OnPackageImported;
    }

    private static void OnPackageImported(string packageName)
    {
        ShowCredits();
    }

    private void OnEnable()
    {
        logo = Resources.Load<Texture2D>("discord");
        kitto = Resources.Load<Texture2D>("kitto");
    }


    [MenuItem("Credits/Open Novabeast Credits")]
    public static void ShowCredits() 
    {
        Credits wnd = GetWindow<Credits>();
        wnd.titleContent = new GUIContent("Novabeast Credits");
        Vector2 screenSize = new Vector2(Screen.currentResolution.width, Screen.currentResolution.height);
        Vector2 windowSize = new Vector2(400, 600);
        wnd.position = new Rect((screenSize - windowSize) / 2, windowSize);
        wnd.Show();
    }


    private void OnGUI()
    {
        GUILayout.Label("Thank you for purchasing the Novabeast!", EditorStyles.boldLabel, GUILayout.Width(1000), GUILayout.Height(20));

        if (GUI.Button(new Rect(5, 30, 52, 52), logo))
        {
            Application.OpenURL("https://discord.com/invite/a3hVcxrMXC");
        }

        if (GUI.Button(new Rect(62, 30, 52, 52), kitto))
        {
            Application.OpenURL("https://twitter.com/kittomatic");
        }


        GUILayout.Label("If you have any questions about the avatar don't hesiate to join\r\nthe official Novabeast discord server by clicking above!\n                           Hope you enjoy! <3", EditorStyles.boldLabel, GUILayout.Width(1000), GUILayout.Height(180));

        
        GUILayout.Label("                                  *Credits*", EditorStyles.boldLabel, GUILayout.Width(300), GUILayout.Height(10));
        GUILayout.Label("Concept, Design, Modeling, and Implementation:\r\n      Kittomatic\r\n\nTexturing help, Substance Painter setup, and Promotional pictures:\r\n      VoltageWicker\r\n\nPhotoshop setup and Community help:\r\n      PxINKY\r\n\nNovabeast logo:\r\n      Synthematic\r\n\nTesting and Emotional support:\r\n      Flashy. and Gallius Strados", EditorStyles.boldLabel, GUILayout.Width(1000), GUILayout.Height(300));
    }

}