2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class CMainGui;
|
|
|
|
class CNotification;
|
|
|
|
class CPlugins;
|
|
|
|
|
|
|
|
class ROMBROWSER_FIELDS {
|
2008-11-14 20:51:06 +00:00
|
|
|
stdstr m_Name;
|
2012-10-05 09:20:53 +00:00
|
|
|
size_t m_Pos, m_DefaultPos;
|
2008-11-14 20:51:06 +00:00
|
|
|
int m_ID;
|
|
|
|
ULONG m_ColWidth;
|
|
|
|
LanguageStringID m_LangID;
|
|
|
|
bool m_PosChanged;
|
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
public:
|
2008-11-14 20:51:06 +00:00
|
|
|
ROMBROWSER_FIELDS (const char * Name, int Pos, int ID, int ColWidth, LanguageStringID LangID, bool UseDefault) :
|
|
|
|
m_Name(Name),
|
|
|
|
m_Pos(Pos),
|
|
|
|
m_DefaultPos(Pos),
|
|
|
|
m_ID(ID),
|
|
|
|
m_ColWidth(ColWidth),
|
|
|
|
m_LangID(LangID),
|
|
|
|
m_PosChanged(false)
|
|
|
|
|
|
|
|
{
|
|
|
|
if (!UseDefault)
|
|
|
|
{
|
2012-11-17 01:02:04 +00:00
|
|
|
m_PosChanged = g_Settings->LoadDwordIndex(RomBrowser_PosIndex,m_ID,(ULONG &)m_Pos );
|
|
|
|
g_Settings->LoadDwordIndex(RomBrowser_WidthIndex,m_ID,m_ColWidth);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
inline LPCSTR Name ( void ) const { return m_Name.c_str(); }
|
2012-10-05 09:20:53 +00:00
|
|
|
inline size_t Pos ( void ) const { return m_Pos; }
|
2008-11-14 20:51:06 +00:00
|
|
|
inline bool PosChanged ( void ) const { return m_PosChanged; }
|
|
|
|
inline int ID ( void ) const { return m_ID; }
|
|
|
|
inline int ColWidth ( void ) const { return m_ColWidth; }
|
|
|
|
inline LanguageStringID LangID ( void ) const { return m_LangID; }
|
|
|
|
|
|
|
|
void SetColWidth ( int ColWidth )
|
|
|
|
{
|
|
|
|
m_ColWidth = ColWidth;
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveDwordIndex(RomBrowser_WidthIndex,m_ID,m_ColWidth);
|
2008-11-14 20:51:06 +00:00
|
|
|
}
|
|
|
|
void SetColPos ( int Pos)
|
|
|
|
{
|
|
|
|
m_Pos = Pos;
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->SaveDwordIndex(RomBrowser_PosIndex,m_ID,m_Pos);
|
2008-11-14 20:51:06 +00:00
|
|
|
m_PosChanged = true;
|
|
|
|
}
|
|
|
|
void ResetPos ( void )
|
|
|
|
{
|
|
|
|
m_Pos = m_DefaultPos;
|
2012-11-17 01:02:04 +00:00
|
|
|
g_Settings->DeleteSettingIndex(RomBrowser_PosIndex,m_ID);
|
2008-11-14 20:51:06 +00:00
|
|
|
m_PosChanged = false;
|
2008-09-18 03:15:49 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<ROMBROWSER_FIELDS> ROMBROWSER_FIELDS_LIST;
|
|
|
|
typedef std::vector<int> FIELD_TYPE_LIST;
|
|
|
|
|
|
|
|
class CRomBrowser;
|
2015-05-04 00:08:53 +00:00
|
|
|
struct SORT_FIELD {
|
2008-09-18 03:15:49 +00:00
|
|
|
CRomBrowser * _this;
|
|
|
|
int Key;
|
|
|
|
bool KeyAscend;
|
2015-05-04 00:08:53 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
class C7zip;
|
2010-05-22 04:47:15 +00:00
|
|
|
class CRomBrowser
|
|
|
|
{
|
2008-09-18 03:15:49 +00:00
|
|
|
enum { IDC_ROMLIST = 223 };
|
|
|
|
enum { RB_FileName = 0, RB_InternalName = 1, RB_GoodName = 2,
|
|
|
|
RB_Status = 3, RB_RomSize = 4, RB_CoreNotes = 5,
|
|
|
|
RB_PluginNotes = 6, RB_UserNotes = 7, RB_CartridgeID = 8,
|
|
|
|
RB_Manufacturer = 9, RB_Country = 10, RB_Developer = 11,
|
|
|
|
RB_Crc1 = 12, RB_Crc2 = 13, RB_CICChip = 14,
|
|
|
|
RB_ReleaseDate = 15, RB_Genre = 16, RB_Players = 17,
|
|
|
|
RB_ForceFeedback = 18, RB_FileFormat = 19 };
|
|
|
|
|
|
|
|
enum FILE_FORMAT {
|
|
|
|
Format_Uncompressed,
|
|
|
|
Format_Zip,
|
|
|
|
Format_7zip,
|
|
|
|
} ;
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
NoOfSortKeys = 3
|
|
|
|
};
|
|
|
|
|
2015-05-04 00:08:53 +00:00
|
|
|
struct ROM_INFO {
|
2008-09-18 03:15:49 +00:00
|
|
|
char szFullFileName[300];
|
|
|
|
FILE_FORMAT FileFormat;
|
|
|
|
char Status[60];
|
|
|
|
char FileName[200];
|
|
|
|
char InternalName[22];
|
|
|
|
char GoodName[200];
|
|
|
|
char CartID[3];
|
|
|
|
char PluginNotes[250];
|
|
|
|
char CoreNotes[250];
|
|
|
|
char UserNotes[250];
|
|
|
|
char Developer[30];
|
|
|
|
char ReleaseDate[30];
|
|
|
|
char Genre[15];
|
|
|
|
int Players;
|
|
|
|
DWORD TextColor;
|
|
|
|
int SelColor;
|
|
|
|
DWORD SelTextColor;
|
|
|
|
DWORD SelColorBrush;
|
|
|
|
int RomSize;
|
|
|
|
BYTE Manufacturer;
|
|
|
|
BYTE Country;
|
|
|
|
DWORD CRC1;
|
|
|
|
DWORD CRC2;
|
|
|
|
int CicChip;
|
|
|
|
char ForceFeedback[15];
|
2015-05-04 00:08:53 +00:00
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
typedef std::vector<ROM_INFO> ROMINFO_LIST;
|
|
|
|
|
2015-01-27 05:07:44 +00:00
|
|
|
HWND & m_MainWindow;
|
|
|
|
HWND & m_StatusWindow;
|
|
|
|
HWND m_hRomList;
|
2008-09-18 03:15:49 +00:00
|
|
|
ROMBROWSER_FIELDS_LIST m_Fields;
|
|
|
|
FIELD_TYPE_LIST m_FieldType;
|
|
|
|
ROMINFO_LIST m_RomInfo;
|
|
|
|
stdstr m_SelectedRom;
|
|
|
|
bool m_Visible;
|
|
|
|
bool m_ShowingRomBrowser;
|
|
|
|
HANDLE m_RefreshThread;
|
|
|
|
bool m_StopRefresh;
|
|
|
|
CIniFile * m_RomIniFile;
|
|
|
|
CIniFile * m_NotesIniFile;
|
|
|
|
CIniFile * m_ExtIniFile;
|
|
|
|
CIniFile * m_ZipIniFile;
|
|
|
|
bool m_AllowSelectionLastRom;
|
|
|
|
|
2012-10-05 09:20:53 +00:00
|
|
|
void AddFileNameToList ( strlist & FileList, const stdstr & Directory, CPath & File );
|
2008-09-18 03:15:49 +00:00
|
|
|
void AddRomToList ( const char * RomLocation, const char * lpLastRom );
|
|
|
|
void AddRomInfoToList ( ROM_INFO &RomInfo, const char * lpLastRom );
|
|
|
|
void AllocateBrushs ( void );
|
|
|
|
DWORD AsciiToHex ( char * HexValue );
|
|
|
|
static void ByteSwapRomData ( BYTE * Data, int DataLen );
|
|
|
|
int CalcSortPosition ( DWORD lParam );
|
|
|
|
void CreateRomListControl ( void );
|
|
|
|
void DeallocateBrushs ( void );
|
|
|
|
void FillRomExtensionInfo ( ROM_INFO * pRomInfo );
|
|
|
|
bool FillRomInfo ( ROM_INFO * pRomInfo );
|
2012-10-05 09:20:53 +00:00
|
|
|
void FillRomList ( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, const char * lpLastRom );
|
2008-09-18 03:15:49 +00:00
|
|
|
void FixRomListWindow ( void );
|
|
|
|
static int GetCicChipID ( BYTE * RomData );
|
|
|
|
bool LoadDataFromRomFile ( char * FileName, BYTE * Data,int DataLen, int * RomSize, FILE_FORMAT & FileFormat );
|
|
|
|
void LoadRomList ( void );
|
2015-04-20 19:41:25 +00:00
|
|
|
void MenuSetText ( HMENU hMenu, int MenuPos, const wchar_t * Title, char * ShortCut);
|
2008-09-18 03:15:49 +00:00
|
|
|
void SaveRomList ( strlist & FileList );
|
|
|
|
void RomList_ColoumnSortList ( DWORD pnmh );
|
|
|
|
void RomList_GetDispInfo ( DWORD pnmh );
|
|
|
|
void RomList_OpenRom ( DWORD pnmh );
|
|
|
|
void RomList_PopupMenu ( DWORD pnmh );
|
|
|
|
void RomList_SortList ( void );
|
2012-10-05 09:20:53 +00:00
|
|
|
bool GetRomFileNames ( strlist & FileList, const CPath & BaseDirectory, const stdstr & Directory, bool InWatchThread );
|
2008-09-18 03:15:49 +00:00
|
|
|
MD5 RomListHash ( strlist & FileList );
|
|
|
|
|
2015-03-05 06:09:58 +00:00
|
|
|
static void __stdcall NotificationCB ( LPCWSTR Status, CRomBrowser * _this );
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Watch Directory Changed function
|
|
|
|
HANDLE m_WatchThread, m_WatchStopEvent;
|
|
|
|
DWORD m_WatchThreadID;
|
|
|
|
stdstr m_WatchRomDir;
|
|
|
|
void WatchThreadStart (void);
|
|
|
|
void WatchThreadStop (void);
|
|
|
|
bool RomDirNeedsRefresh ( void ); // Called from watch thread
|
|
|
|
static void WatchRomDirChanged ( CRomBrowser * _this );
|
|
|
|
static void RefreshRomBrowserStatic ( CRomBrowser * _this );
|
2008-11-14 20:51:06 +00:00
|
|
|
static void AddField (ROMBROWSER_FIELDS_LIST & Fields, LPCSTR Name, int Pos,int ID,int Width,LanguageStringID LangID, bool UseDefault);
|
2008-09-18 03:15:49 +00:00
|
|
|
|
|
|
|
//Callback
|
2015-01-27 05:07:44 +00:00
|
|
|
static int CALLBACK SelectRomDirCallBack ( HWND hwnd,DWORD uMsg,DWORD lp, DWORD lpData );
|
2008-09-18 03:15:49 +00:00
|
|
|
static int CALLBACK RomList_CompareItems ( DWORD lParam1, DWORD lParam2, DWORD lParamSort );
|
|
|
|
|
|
|
|
public:
|
2015-01-27 05:07:44 +00:00
|
|
|
CRomBrowser ( HWND & hMainWindow, HWND & StatusWindow );
|
2008-09-18 03:15:49 +00:00
|
|
|
~CRomBrowser ( void );
|
|
|
|
void HighLightLastRom ( void );
|
|
|
|
void HideRomList ( void );
|
|
|
|
void RefreshRomBrowser ( void );
|
|
|
|
void ResetRomBrowserColomuns ( void );
|
|
|
|
void ResizeRomList ( WORD nWidth, WORD nHeight );
|
|
|
|
void RomBrowserToTop ( void );
|
|
|
|
void RomBrowserMaximize ( bool Mazimize ) ;
|
|
|
|
bool RomBrowserVisible ( void );
|
|
|
|
bool RomListDrawItem ( int idCtrl, DWORD lParam );
|
|
|
|
bool RomListNotify ( int idCtrl, DWORD pnmh );
|
|
|
|
void SaveRomListColoumnInfo ( void );
|
2010-05-22 04:47:15 +00:00
|
|
|
void SelectRomDir ( void );
|
2008-09-18 03:15:49 +00:00
|
|
|
void ShowRomList ( void );
|
|
|
|
bool ShowingRomBrowser ( void ) { return m_ShowingRomBrowser; }
|
|
|
|
LPCSTR CurrentedSelectedRom ( void ) { return m_SelectedRom.c_str(); }
|
2010-06-29 02:11:22 +00:00
|
|
|
void Store7ZipInfo ( C7zip & ZipFile, int FileNo );
|
2008-11-14 20:51:06 +00:00
|
|
|
|
|
|
|
static void GetFieldInfo ( ROMBROWSER_FIELDS_LIST & Fields, bool UseDefault = false );
|
2015-01-31 19:27:27 +00:00
|
|
|
};
|