[Project64] Cleanup Rom Browser Class.cpp

This commit is contained in:
zilmar 2015-11-29 01:25:55 +11:00
parent 819b721eaf
commit 8acffb73e7
3 changed files with 1685 additions and 1685 deletions

View File

@ -23,11 +23,11 @@ class CriticalSection;
enum enum
{ {
WM_HIDE_CUROSR = WM_USER + 10, WM_HIDE_CUROSR = WM_USER + 10,
WM_MAKE_FOCUS = WM_USER + 17, WM_MAKE_FOCUS = WM_USER + 17,
WM_RESET_PLUGIN = WM_USER + 18, WM_RESET_PLUGIN = WM_USER + 18,
WM_GAME_CLOSED = WM_USER + 19, WM_GAME_CLOSED = WM_USER + 19,
WM_BROWSER_TOP = WM_USER + 40, WM_BROWSER_TOP = WM_USER + 40,
}; };
class CMainGui : class CMainGui :

File diff suppressed because it is too large Load Diff

View File

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