<commit_before>/*
 * Copyright (C) 2016 necropotame (<EMAIL>)
 * 
 * This file is part of TeeUniverses.
 * 
 * TeeUniverses is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * TeeUniverses is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with TeeUniverses.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <editor/components/gui.h>

#include <shared/components/assetsmanager.h>
#include <shared/components/storage.h>
#include <client/gui/panellayout.h>
#include <client/gui/popup.h>
#include <client/gui/filler.h>
#include <client/gui/text-edit.h>
#include <client/gui/toggle.h>
#include <client/keys.h>
#include <client/components/input.h>
#include <client/gui/panellayout.h>
#include <client/loading_tools.h>
#include <editor/gui/assetslist.h>
#include <editor/gui/view.h>
#include <editor/gui/timeline.h>
#include <editor/gui/assetsinspector.h>

/* CONTEXT MENU *******************************************************/

CContextMenu::CContextMenu(CGuiEditor* pAssetsEditor) :
	gui::CPopup(pAssetsEditor, gui::CRect(pAssetsEditor->GetMousePos().x, pAssetsEditor->GetMousePos().y, 0, 0), 250, -1, gui::CPopup::ALIGNMENT_SIDE),
	m_pAssetsEditor(pAssetsEditor)
{		
	m_pList = new gui::CVListLayout(Context());
	m_pList->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Menu);
	Add(m_pList);
}

class CPackageNameEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageName(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageName(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageNameEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageAuthorEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageAuthor(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageAuthor(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageAuthorEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageCreditsEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageCredits(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageCredits(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageCreditsEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageLicenseEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageLicense(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageLicense(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageLicenseEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageVersionEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageVersion(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageVersion(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageVersionEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

CDialog::CDialog(CGuiEditor* pAssetsEditor) :
	gui::CPopup(pAssetsEditor, pAssetsEditor->GetDrawRect(), 400, 300, gui::CPopup::ALIGNMENT_INNER),
	m_pAssetsEditor(pAssetsEditor)
{
	
}

PackagePropertiesDialog::PackagePropertiesDialog(CGuiEditor* pAssetsEditor, int PackageId) :
	CDialog(pAssetsEditor),
	m_PackageId(PackageId)
{
	gui::CVScrollLayout* pLayout = new gui::CVScrollLayout(Context());
	pLayout->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Dialog);
	Add(pLayout);
	
	pLayout->Add(new gui::CLabelHeader(Context(), _GUI("Package Properties")), false);
	pLayout->Add(new gui::CFiller(Context()), true);
	
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Name")), true);
		pHList->Add(new CPackageNameEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Version")), true);
		pHList->Add(new CPackageVersionEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Author")), true);
		pHList->Add(new CPackageAuthorEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Credits")), true);
		pHList->Add(new CPackageCreditsEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("License")), true);
		pHList->Add(new CPackageLicenseEntry(m_pAssetsEditor, m_PackageId), true);
	}
	
	pLayout->Add(new gui::CFiller(Context()), true);
	pLayout->AddSeparator();
	
	//Buttonlist
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CFiller(Context()), true);
		pHList->Add(new CClose(this), false);
	}
}

CErrorDialog::CErrorDialog(CGuiEditor* pAssetsEditor, const CLocalizableString& LString) :
	CDialog(pAssetsEditor)
{
	gui::CVScrollLayout* pLayout = new gui::CVScrollLayout(Context());
	pLayout->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Dialog);
	Add(pLayout);
	
	pLayout->Add(new gui::CLabelHeader(Context(), _GUI("Error")), false);
	
	gui::CLabel* pMessage = new gui::CLabel(Context(), LString);
	pMessage->SetLabelStyle(m_pAssetsEditor->m_Path_Label_DialogMessage);
	pMessage->NoTextClipping();
	pLayout->Add(pMessage, true);
	
	pLayout->AddSeparator();
	
	//Buttonlist
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CFiller(Context()), true);
		pHList->Add(new CClose(this), false);
	}
}

class COpenSavePackageDialog : public gui::CPopup
{
public:
	enum
	{
		FORMAT_PACKAGE=0,
		FORMAT_MAP_TW,
		FORMAT_MAP_INFCLASS,
		FORMAT_MAP_OPENFNG,
		FORMAT_IMAGE,
	};
	
protected:
	class CItem_Directory : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		CGuiEditor* m_pAssetsEditor;
		dynamic_string m_Directory;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->SelectDirectory(m_Directory.buffer());
		}
		
	public:
		CItem_Directory(COpenSavePackageDialog* pPopup, const char* pFilename, const char* pDir) :
			gui::CButton(pPopup->Context(), pFilename, pPopup->m_pAssetsEditor->m_Path_Sprite_IconFolder),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			m_Directory.copy(pDir);
			SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
		
		CItem_Directory(COpenSavePackageDialog* pPopup, const CLocalizableString& Title, const char* pDir) :
			gui::CButton(pPopup->Context(), Title, pPopup->m_pAssetsEditor->m_Path_Sprite_IconFolder),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			m_Directory.copy(pDir);
			SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
	};
	
	class CItem_Load : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		CGuiEditor* m_pAssetsEditor;
		dynamic_string m_Filename;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->SelectName(m_Filename.buffer());
		}
		
	public:
		CItem_Load(COpenSavePackageDialog* pPopup, const char* pFilename) :
			gui::CButton(pPopup->Context(), pFilename),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			switch(m_pPopup->GetFormat())
			{
				case FORMAT_IMAGE:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconImage);
					break;
				case FORMAT_MAP_TW:
				case FORMAT_MAP_INFCLASS:
				case FORMAT_MAP_OPENFNG:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconMap);
					break;
				default:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconAsset);
					break;
			}
			m_Filename.copy(pFilename);
		}
		
		virtual void Update(bool ParentEnabled)
		{
			if(m_Filename == m_pPopup->m_Filename)
				SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItemHL);
			else
				SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
	};
	
	class COpen : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->Open();
		}
		
	public:
		COpen(COpenSavePackageDialog* pPopup) :
			gui::CButton(pPopup->Context(), _GUI("Open")),
			m_pPopup(pPopup)
		{
			SetButtonStyle(pPopup->m_pAssetsEditor->m_Path_Button_Dialog);
		}
	};
	
	class CSave : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->Save();
		}
		
	public:
		CSave(COpenSavePackageDialog* pPopup) :
			gui::CButton(pPopup->Context(), _GUI("Save")),
			m_pPopup(pPopup)
		{
			SetButtonStyle(pPopup->m_pAssetsEditor->m_Path_Button_Dialog);
		}
	};
	
	class CCancel : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		<commit_msg>Close #38<commit_after>/*
 * Copyright (C) 2016 necropotame (<EMAIL>)
 * 
 * This file is part of TeeUniverses.
 * 
 * TeeUniverses is free software: you can redistribute it and/or  modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * TeeUniverses is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with TeeUniverses.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <editor/components/gui.h>

#include <shared/components/assetsmanager.h>
#include <shared/components/storage.h>
#include <client/gui/panellayout.h>
#include <client/gui/popup.h>
#include <client/gui/filler.h>
#include <client/gui/text-edit.h>
#include <client/gui/toggle.h>
#include <client/keys.h>
#include <client/components/input.h>
#include <client/gui/panellayout.h>
#include <client/loading_tools.h>
#include <editor/gui/assetslist.h>
#include <editor/gui/view.h>
#include <editor/gui/timeline.h>
#include <editor/gui/assetsinspector.h>

/* CONTEXT MENU *******************************************************/

CContextMenu::CContextMenu(CGuiEditor* pAssetsEditor) :
	gui::CPopup(pAssetsEditor, gui::CRect(pAssetsEditor->GetMousePos().x, pAssetsEditor->GetMousePos().y, 0, 0), 250, -1, gui::CPopup::ALIGNMENT_SIDE),
	m_pAssetsEditor(pAssetsEditor)
{		
	m_pList = new gui::CVListLayout(Context());
	m_pList->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Menu);
	Add(m_pList);
}

class CPackageNameEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageName(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageName(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageNameEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageAuthorEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageAuthor(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageAuthor(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageAuthorEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageCreditsEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageCredits(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageCredits(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageCreditsEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageLicenseEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageLicense(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageLicense(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageLicenseEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

class CPackageVersionEntry : public gui::CAbstractTextEdit
{
protected:
	CGuiEditor* m_pAssetsEditor;
	int m_PackageId;

protected:
	virtual void SaveFromTextBuffer()
			{ AssetsManager()->SetPackageVersion(m_PackageId, GetText()); }
	
	virtual void CopyToTextBuffer()
		{
			const char* pName = AssetsManager()->GetPackageVersion(m_PackageId);
			if(m_Text != pName)
				SetText(pName);
			else if(!pName)
				SetText("");
		}

public:
	CPackageVersionEntry(CGuiEditor* pAssetsEditor, int PackageId) :
		gui::CAbstractTextEdit(pAssetsEditor),
		m_PackageId(PackageId)
	{ }
};

CDialog::CDialog(CGuiEditor* pAssetsEditor) :
	gui::CPopup(pAssetsEditor, pAssetsEditor->GetDrawRect(), 400, 300, gui::CPopup::ALIGNMENT_INNER),
	m_pAssetsEditor(pAssetsEditor)
{
	
}

PackagePropertiesDialog::PackagePropertiesDialog(CGuiEditor* pAssetsEditor, int PackageId) :
	CDialog(pAssetsEditor),
	m_PackageId(PackageId)
{
	gui::CVScrollLayout* pLayout = new gui::CVScrollLayout(Context());
	pLayout->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Dialog);
	Add(pLayout);
	
	pLayout->Add(new gui::CLabelHeader(Context(), _GUI("Package Properties")), false);
	pLayout->Add(new gui::CFiller(Context()), true);
	
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Name")), true);
		pHList->Add(new CPackageNameEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Version")), true);
		pHList->Add(new CPackageVersionEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Author")), true);
		pHList->Add(new CPackageAuthorEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("Credits")), true);
		pHList->Add(new CPackageCreditsEntry(m_pAssetsEditor, m_PackageId), true);
	}
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CLabel(Context(), _GUI("License")), true);
		pHList->Add(new CPackageLicenseEntry(m_pAssetsEditor, m_PackageId), true);
	}
	
	pLayout->Add(new gui::CFiller(Context()), true);
	pLayout->AddSeparator();
	
	//Buttonlist
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CFiller(Context()), true);
		pHList->Add(new CClose(this), false);
	}
}

CErrorDialog::CErrorDialog(CGuiEditor* pAssetsEditor, const CLocalizableString& LString) :
	CDialog(pAssetsEditor)
{
	gui::CVScrollLayout* pLayout = new gui::CVScrollLayout(Context());
	pLayout->SetBoxStyle(m_pAssetsEditor->m_Path_Box_Dialog);
	Add(pLayout);
	
	pLayout->Add(new gui::CLabelHeader(Context(), _GUI("Error")), false);
	
	gui::CLabel* pMessage = new gui::CLabel(Context(), LString);
	pMessage->SetLabelStyle(m_pAssetsEditor->m_Path_Label_DialogMessage);
	pMessage->NoTextClipping();
	pLayout->Add(pMessage, true);
	
	pLayout->AddSeparator();
	
	//Buttonlist
	{
		gui::CHListLayout* pHList = new gui::CHListLayout(Context());
		pLayout->Add(pHList, false);
		
		pHList->Add(new gui::CFiller(Context()), true);
		pHList->Add(new CClose(this), false);
	}
}

class COpenSavePackageDialog : public gui::CPopup
{
public:
	enum
	{
		FORMAT_PACKAGE=0,
		FORMAT_MAP_TW,
		FORMAT_MAP_INFCLASS,
		FORMAT_MAP_OPENFNG,
		FORMAT_IMAGE,
	};
	
protected:
	class CItem_Directory : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		CGuiEditor* m_pAssetsEditor;
		dynamic_string m_Directory;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->SelectDirectory(m_Directory.buffer());
		}
		
	public:
		CItem_Directory(COpenSavePackageDialog* pPopup, const char* pFilename, const char* pDir) :
			gui::CButton(pPopup->Context(), pFilename, pPopup->m_pAssetsEditor->m_Path_Sprite_IconFolder),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			m_Directory.copy(pDir);
			SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
		
		CItem_Directory(COpenSavePackageDialog* pPopup, const CLocalizableString& Title, const char* pDir) :
			gui::CButton(pPopup->Context(), Title, pPopup->m_pAssetsEditor->m_Path_Sprite_IconFolder),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			m_Directory.copy(pDir);
			SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
	};
	
	class CItem_Load : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		CGuiEditor* m_pAssetsEditor;
		dynamic_string m_Filename;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->SelectName(m_Filename.buffer());
		}
		
	public:
		CItem_Load(COpenSavePackageDialog* pPopup, const char* pFilename) :
			gui::CButton(pPopup->Context(), pFilename),
			m_pPopup(pPopup),
			m_pAssetsEditor(pPopup->m_pAssetsEditor)
		{
			switch(m_pPopup->GetFormat())
			{
				case FORMAT_IMAGE:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconImage);
					break;
				case FORMAT_MAP_TW:
				case FORMAT_MAP_INFCLASS:
				case FORMAT_MAP_OPENFNG:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconMap);
					break;
				default:
					SetIcon(pPopup->m_pAssetsEditor->m_Path_Sprite_IconAsset);
					break;
			}
			m_Filename.copy(pFilename);
		}
		
		virtual void Update(bool ParentEnabled)
		{
			if(m_Filename == m_pPopup->m_Filename)
				SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItemHL);
			else
				SetButtonStyle(m_pAssetsEditor->m_Path_Button_ListItem);
		}
	};
	
	class COpen : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->Open();
		}
		
	public:
		COpen(COpenSavePackageDialog* pPopup) :
			gui::CButton(pPopup->Context(), _GUI("Open")),
			m_pPopup(pPopup)
		{
			SetButtonStyle(pPopup->m_pAssetsEditor->m_Path_Button_Dialog);
		}
		
		virtual void Update(bool ParentEnabled)
		{
			if(ParentEnabled)
			{
				if(m_pPopup->m_Filename.empty())
					Editable(false);
				else
					Editable(true);
			}
			
			gui::CButton::Update(ParentEnabled);
		}
	};
	
	class CSave : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		
	protected:
		virtual void MouseClickAction()
		{
			m_pPopup->Save();
		}
		
	public:
		CSave(COpenSavePackageDialog* pPopup) :
			gui::CButton(pPopup->Context(), _GUI("Save")),
			m_pPopup(pPopup)
		{
			SetButtonStyle(pPopup->m_pAssetsEditor->m_Path_Button_Dialog);
		}
	};
	
	class CCancel : public gui::CButton
	{
	protected:
		COpenSavePackageDialog* m_pPopup;
		
{'fraction_non_alphanumeric': 0.13606427203512542, 'fraction_numerical': 0.0017749544584053434, 'mean_word_length': 5.478063540090772, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 204, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2620378', 'n_tokens_mistral': 8477, 'n_tokens_neox': 7744, 'n_words': 1281}