/*******************************************************************************/

#ifndef __KAMILOXNUMETAL_S_MHPB_PKR3_EDITORFRM_H__
#define __KAMILOXNUMETAL_S_MHPB_PKR3_EDITORFRM_H__

/*******************************************************************************/

#ifdef __BORLANDC__
	#pragma hdrstop
#endif

#ifndef WX_PRECOMP
	#include <wx/wx.h>
	#include <wx/frame.h>
#else
	#include <wx/wxprec.h>
#endif

/*******************************************************************************/

////Header Include Start
#include <wx/msgdlg.h>
#include <wx/checkbox.h>
#include <wx/filedlg.h>
#include <wx/html/htmlwin.h>
#include <wx/textctrl.h>
#include <wx/button.h>
#include <wx/listbox.h>
////Header Include End

/*******************************************************************************/

////Dialog Style Start
#undef Kamiloxnumetal_s_MHPB_PKR3_EditorFrm_STYLE
#define Kamiloxnumetal_s_MHPB_PKR3_EditorFrm_STYLE wxCAPTION | wxSYSTEM_MENU | wxMINIMIZE_BOX | wxCLOSE_BOX
////Dialog Style End

/*******************************************************************************/

using namespace std;

#include <cstdlib>
#include <cstring>
#include <wx/file.h>
#include <windows.h>
#include <mmsystem.h>

/*******************************************************************************/

struct pkr3dir
{
    char dname[32];
    unsigned int dcount;
    unsigned int dfiles;
};

/*******************************************************************************/

struct pkr3file
{
    char fname[32]; // File Name
    bool zip; // 0xfffffffe Uncompressed 0x00000002 Compressed
    unsigned int crc32; // CRC32
    unsigned int usize; // Uncompressed Size
    unsigned int csize; // Compressed Size
    unsigned int foffset;
    unsigned char* fdata;
};

/*******************************************************************************/

class Kamiloxnumetal_s_MHPB_PKR3_EditorFrm : public wxFrame
{
	public:
		Kamiloxnumetal_s_MHPB_PKR3_EditorFrm(wxWindow *parent, wxWindowID id = 1, const wxString &title = wxT("Kamiloxnumetal's MHPB PKR3 Editor"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = Kamiloxnumetal_s_MHPB_PKR3_EditorFrm_STYLE);
		virtual ~Kamiloxnumetal_s_MHPB_PKR3_EditorFrm();
		void BTNMediaPkrClick(wxCommandEvent& event);
		void BTNOpenDataClick(wxCommandEvent& event);
		void Print(const wxChar*);
		void ReadPkr();
		void PreviewCBMP();
		void MakeFileList(unsigned short);
		unsigned short GetExtension(char*);
		void LSTFilesAction();
		void LSTDirsSelected(wxCommandEvent& event);
		void LSTFilesSelected(wxCommandEvent& event);
		void LSTFilesDoubleClicked(wxCommandEvent& event);
		void BTNPreviewClick(wxCommandEvent& event);
		void writezip(const wxChar*,unsigned short,unsigned short,const wxChar*);
		void BTNExportClick(wxCommandEvent& event);
		void BTNImportClick(wxCommandEvent& event);
		void BTNSaveFileClick(wxCommandEvent& event);
	private:
        DECLARE_EVENT_TABLE();
        unsigned int aux;
        unsigned short saux;
        pkr3dir dir[33];
        pkr3file file[1510];
        wxFile FHandler;
        wxFile AuxHandler;
        wxString Str;
        bool pkr; // false data.pkr true media.pkr
		////GUI Control Declaration Start
		wxMessageDialog *DLGCaution;
		wxCheckBox *CHKPreview;
		wxFileDialog *DLGOpenDataPkr;
		wxFileDialog *DLGImport;
		wxFileDialog *DLGOpenMediaPkr;
		wxFileDialog *DLGExport;
		wxFileDialog *DLGSaveFile;
		wxButton *BTNPreview;
		wxTextCtrl *EDTTxt;
		wxHtmlWindow *HTMLBmp;
		wxButton *BTNSaveFile;
		wxButton *BTNMediaPkr;
		wxButton *BTNOpenData;
		wxTextCtrl *EDTConsole;
		wxButton *BTNImport;
		wxButton *BTNExport;
		wxListBox *LSTFiles;
		wxListBox *LSTDirs;
		////GUI Control Declaration End
		
		enum
		{
			////GUI Enum Control ID Start
			ID_CHKPREVIEW = 1013,
			ID_BTNPREVIEW = 1012,
			ID_EDTTXT = 1011,
			ID_HTMLBMP = 1010,
			ID_BTNSAVEFILE = 1009,
			ID_BTNMEDIAPKR = 1008,
			ID_BTNOPENDATA = 1007,
			ID_EDTCONSOLE = 1006,
			ID_BTNIMPORT = 1005,
			ID_BTNEXPORT = 1004,
			ID_LSTFILES = 1002,
			ID_LSTDIRS = 1001,
			////GUI Enum Control ID End
			ID_DUMMY_VALUE_ //don't remove this value unless you have other enum values
		};
		
		void OnClose(wxCloseEvent& event);
		void CreateGUIControls();
};

#endif

/*******************************************************************************/

