#pragma once

#include "Parameter.h"


class k_EditBoxParameter
	: public k_BaseParameter
	, public IEditBoxParameter
{
public:
	k_EditBoxParameter(IDirect3D9BasePlugin& ar_Plugin, const GUID& ar_Guid, const std::wstring& as_Name, const std::wstring& as_Description, const std::wstring& as_Default)
		: k_BaseParameter(ar_Plugin, ar_Guid, as_Name, as_Name, as_Description, r_ParameterType::EditBox)
		, ms_Default(as_Default)
		, ms_Current(as_Default)
	{
		this->UpdateDisplayText();
	}

	// IObject
	void* QueryInterface(const GUID& ar_InterfaceGuid)
	{
		if (ar_InterfaceGuid == __uuidof(IEditBoxParameter)) 
			return static_cast<IEditBoxParameter*>(this);

		return k_BaseParameter::QueryInterface(ar_InterfaceGuid); 
	}

	// IEditBoxParameter
	virtual void set_DefaultValue(const std::wstring& as_Value)
	{
		ms_Default = as_Value;
	}

	virtual std::wstring get_DefaultValue() const
	{
		return ms_Default;
	}

	virtual void set_CurrentValue(const std::wstring& as_Value)
	{
		ms_Current = as_Value;
		this->UpdateDisplayText();
		mr_Plugin.OnParameterHasChanged(*this);
	}

	virtual std::wstring get_CurrentValue() const
	{
		return ms_Current;
	}
	
	virtual void ResetToDefault()
	{
		ms_Current = ms_Default;
		this->UpdateDisplayText();
		mr_Plugin.OnParameterHasChanged(*this);
	}

protected:
	void UpdateDisplayText()
	{
		ms_DisplayText = ms_Current;
	}

	std::wstring ms_Default;
	std::wstring ms_Current;
};
