[Project64] Remove SelColorBrush from ROM_INFO

This commit is contained in:
zilmar 2016-04-15 08:26:02 +10:00
parent 5b5d30cb69
commit 3007139446
4 changed files with 17 additions and 56 deletions

View File

@ -122,7 +122,8 @@ private:
NoOfSortKeys = 3
};
void AllocateBrushs(void);
typedef std::map<int32_t, HBRUSH> HBRUSH_MAP;
void RomListReset(void);
void RomListLoaded(void);
void RomAddedToList(int32_t ListPos);
@ -156,5 +157,6 @@ private:
bool m_ShowingRomBrowser;
bool m_AllowSelectionLastRom;
static std::wstring m_UnknownGoodName;
HBRUSH_MAP m_Brushes;
std::string m_LastRom;
};

View File

@ -253,8 +253,6 @@ int32_t CRomBrowser::CalcSortPosition(uint32_t lParam)
void CRomBrowser::RomAddedToList(int32_t ListPos)
{
m_RomInfo[ListPos].SelColorBrush = NULL;
LVITEMW lvItem;
memset(&lvItem, 0, sizeof(lvItem));
lvItem.mask = LVIF_TEXT | LVIF_PARAM;
@ -277,21 +275,6 @@ void CRomBrowser::RomAddedToList(int32_t ListPos)
}
}
void CRomBrowser::AllocateBrushs(void)
{
for (size_t count = 0; count < m_RomInfo.size(); count++)
{
if (m_RomInfo[count].SelColor == -1)
{
m_RomInfo[count].SelColorBrush = (uint32_t)((HBRUSH)(COLOR_HIGHLIGHT + 1));
}
else
{
m_RomInfo[count].SelColorBrush = (uint32_t)CreateSolidBrush(m_RomInfo[count].SelColor);
}
}
}
void CRomBrowser::RomListReset(void)
{
WriteTrace(TraceUserInterface, TraceDebug, "1");
@ -313,23 +296,15 @@ void CRomBrowser::CreateRomListControl(void)
void CRomBrowser::DeallocateBrushs(void)
{
for (size_t count = 0; count < m_RomInfo.size(); count++)
for (HBRUSH_MAP::iterator itr = m_Brushes.begin(); itr != m_Brushes.end(); itr++)
{
if (m_RomInfo[count].SelColor == -1)
{
continue;
}
if (m_RomInfo[count].SelColorBrush)
{
DeleteObject((HBRUSH)m_RomInfo[count].SelColorBrush);
m_RomInfo[count].SelColorBrush = NULL;
}
DeleteObject(itr->second);
}
m_Brushes.clear();
}
void CRomBrowser::RomListLoaded(void)
{
AllocateBrushs();
RomList_SortList();
}
@ -498,7 +473,7 @@ bool CRomBrowser::RomListDrawItem(int32_t idCtrl, uint32_t lParam)
RECT rcItem, rcDraw;
wchar_t String[300];
LVITEMW lvItem;
HBRUSH hBrush;
HBRUSH hBrush = (HBRUSH)(COLOR_WINDOW + 1);
LV_COLUMN lvc;
int32_t nColumn;
@ -519,12 +494,20 @@ bool CRomBrowser::RomListDrawItem(int32_t idCtrl, uint32_t lParam)
}
if (bSelected)
{
hBrush = (HBRUSH)pRomInfo->SelColorBrush;
HBRUSH_MAP::iterator itr = m_Brushes.find(pRomInfo->SelColor);
if (itr != m_Brushes.end())
{
hBrush = itr->second;
}
else
{
std::pair<HBRUSH_MAP::iterator, bool> res = m_Brushes.insert(HBRUSH_MAP::value_type(pRomInfo->SelColor, CreateSolidBrush(pRomInfo->SelColor)));
hBrush = res.first->second;
}
SetTextColor(ditem->hDC, pRomInfo->SelTextColor);
}
else
{
hBrush = (HBRUSH)(COLOR_WINDOW + 1);
SetTextColor(ditem->hDC, pRomInfo->TextColor);
}
FillRect(ditem->hDC, &ditem->rcItem, hBrush);

View File

@ -148,10 +148,6 @@ void CRomList::FillRomList(strlist & FileList, const CPath & BaseDirectory, cons
do
{
uint8_t ext_ID;
int8_t new_list_entry = 0;
const uint8_t exts = sizeof(ROM_extensions) / sizeof(ROM_extensions[0]);
WriteTrace(TraceRomList, TraceVerbose, "Found: \"%s\" m_StopRefresh = %s", (const char *)SearchPath, m_StopRefresh ? "true" : "false");
if (m_StopRefresh)
{
@ -314,14 +310,6 @@ void CRomList::FillRomList(strlist & FileList, const CPath & BaseDirectory, cons
WriteTrace(TraceUserInterface, TraceDebug, "16");
FillRomExtensionInfo(&RomInfo);
if (RomInfo.SelColor == -1)
{
RomInfo.SelColorBrush = (uint32_t)((HBRUSH)(COLOR_HIGHLIGHT + 1));
}
else
{
RomInfo.SelColorBrush = (uint32_t)CreateSolidBrush(RomInfo.SelColor);
}
WriteTrace(TraceUserInterface, TraceDebug, "17");
int32_t ListPos = m_RomInfo.size();
m_RomInfo.push_back(RomInfo);
@ -469,18 +457,7 @@ bool CRomList::FillRomInfo(ROM_INFO * pRomInfo)
pRomInfo->CRC1 = *(uint32_t *)(RomData + 0x10);
pRomInfo->CRC2 = *(uint32_t *)(RomData + 0x14);
pRomInfo->CicChip = GetCicChipID(RomData);
FillRomExtensionInfo(pRomInfo);
if (pRomInfo->SelColor == -1)
{
pRomInfo->SelColorBrush = (uint32_t)((HBRUSH)(COLOR_HIGHLIGHT + 1));
}
else
{
pRomInfo->SelColorBrush = (uint32_t)CreateSolidBrush(pRomInfo->SelColor);
}
return true;
}
return false;

View File

@ -39,7 +39,6 @@ public:
uint32_t TextColor;
int32_t SelColor;
uint32_t SelTextColor;
uint32_t SelColorBrush;
int32_t RomSize;
uint8_t Manufacturer;
uint8_t Country;