// Project Lab - NHTV IGAD
//////////////////////////////////////////
// Author: Yoshi van Belkom - 130118
//////////////////////////////////////////
// The Skill Tree Editor main class.
//////////////////////////////////////////

#pragma once

#include "Toolkits/AssetEditorToolkit.h"
#include "Toolkits/AssetEditorManager.h"

class SSkillTreeEditorViewport;
class USkillTreeObject;
class USkillObject;

class FSkillTreeEditorViewport : public FAssetEditorToolkit//, public FGCObject
{
public:
	//The ID of the selected Skill.
	int32 selectedY = -1;

	// IToolkit interface
	virtual void RegisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager ) override;
	virtual void UnregisterTabSpawners( const TSharedRef<class FTabManager>& a_tabManager ) override;
	// End of IToolkit interface

	// FAssetEditorToolkit
	virtual FName GetToolkitFName() const override;
	virtual FText GetBaseToolkitName() const override;
	virtual FText GetToolkitName() const override;
	virtual FText GetToolkitToolTipText() const override;
	virtual FLinearColor GetWorldCentricTabColorScale() const override;
	virtual FString GetWorldCentricTabPrefix() const override;
	virtual FString GetDocumentationLink() const override;
	virtual void SaveAsset_Execute() override;
	// End of FAssetEditorToolkit

	//Set the Skill to Edit.
	void SetSkillBeingEdited( USkillObject* a_skill );
	//Get the Current Skill Tree that is being edited.
	USkillTreeObject* GetSkillTreeBeingEdited() const { return m_skillTreeBeingEdited; };
	//Get the Current Skill that is being edited.
	USkillObject* GetSkillBeingEdited() const { return m_skillBeingEdited; };

	void InitSkillTreeEditor( const EToolkitMode::Type a_mode, const TSharedPtr< class IToolkitHost >& a_toolkitHost, class USkillTreeObject* a_skillTree, class USkillObject* a_skill = NULL );

	void UpdateSkills();
protected:
	// A temporary list of Skills to check agains to see if new Skills have been added.
	TArray<TSubclassOf<USkillObject>> m_tmpSkills;

	// The pointer to the current Skill Tree.
	USkillTreeObject* m_skillTreeBeingEdited;
	// The pointer to the current Skill.
	USkillObject* m_skillBeingEdited = NULL;

	// The pointer to the Skill Tree Viewport.
	TSharedPtr<SSkillTreeEditorViewport> m_skillTreeViewport;
	// The pointer to the Skill Viewport.
	TSharedPtr<SSkillTreeEditorViewport> m_skillViewport;

	// Functions to spawn the Viewports and Details
	TSharedRef<SDockTab> SpawnTab_SKViewport( const FSpawnTabArgs& a_args );
	TSharedRef<SDockTab> SpawnTab_SViewport( const FSpawnTabArgs& a_args );
	TSharedRef<SDockTab> SpawnTab_SKDViewport( const FSpawnTabArgs& a_args );
	TSharedRef<SDockTab> SpawnTab_SDViewport( const FSpawnTabArgs& a_args );

	// Creates the toolbar buttons.
	void CreateModeToolbarWidgets( FToolBarBuilder& ToolbarBuilder );
};
