Green colored icon when demo has markers, display maker count in the demo info section

This commit is contained in:
LordSk 2018-12-21 18:22:22 +01:00
parent 4084242c40
commit 6d12b4ca3a
3 changed files with 44 additions and 6 deletions

View file

@ -107,6 +107,18 @@ int CMenus::DoIcon(int ImageId, int SpriteId, const CUIRect *pRect)
return 0;
}
void CMenus::DoIconColor(int ImageId, int SpriteId, const CUIRect* pRect, const vec4& Color)
{
Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id);
Graphics()->QuadsBegin();
RenderTools()->SelectSprite(SpriteId);
Graphics()->SetColor(Color.r*Color.a, Color.g*Color.a, Color.b*Color.a, Color.a);
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
Graphics()->QuadsDrawTL(&QuadItem, 1);
Graphics()->QuadsEnd();
}
int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect, bool Active)
{
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GUIBUTTONS].m_Id);

View file

@ -71,6 +71,7 @@ private:
*/
int DoIcon(int ImageId, int SpriteId, const CUIRect *pRect);
void DoIconColor(int ImageId, int SpriteId, const CUIRect *pRect, const vec4& Color);
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
int DoButton_GridHeaderIcon(CButtonContainer *pBC, int ImageID, int SpriteID, const CUIRect *pRect, int Corners);

View file

@ -310,6 +310,15 @@ void CMenus::DemolistOnUpdate(bool Reset)
m_DemolistSelectedIsDir = m_DemolistSelectedIndex < 0 ? false : m_lDemos[m_DemolistSelectedIndex].m_IsDir;
}
inline int DemoGetMarkerCount(CDemoHeader Demo)
{
int DemoMarkerCount = ((Demo.m_aNumTimelineMarkers[0]<<24)&0xFF000000) |
((Demo.m_aNumTimelineMarkers[1]<<16)&0xFF0000) |
((Demo.m_aNumTimelineMarkers[2]<<8)&0xFF00) |
(Demo.m_aNumTimelineMarkers[3]&0xFF);
return DemoMarkerCount;
}
void CMenus::RenderDemoList(CUIRect MainView)
{
CUIRect BottomView;
@ -364,13 +373,20 @@ void CMenus::RenderDemoList(CUIRect MainView)
for(sorted_array<CDemoItem>::range r = m_lDemos.all(); !r.empty(); r.pop_front())
{
CListboxItem Item = UiDoListboxNextItem(&s_ListBoxState, (void*)(&r.front()));
// marker count
const CDemoItem& DemoItem = r.front();
int DemoMarkerCount = 0;
if(DemoItem.m_Valid && DemoItem.m_InfosLoaded)
DemoMarkerCount = DemoGetMarkerCount(DemoItem.m_Info);
if(Item.m_Visible)
{
Item.m_Rect.VSplitLeft(Item.m_Rect.h, &FileIcon, &Item.m_Rect);
Item.m_Rect.VSplitLeft(5.0f, 0, &Item.m_Rect);
FileIcon.Margin(3.0f, &FileIcon);
FileIcon.x += 3.0f;
DoIcon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon);
const vec4 IconColor = DemoMarkerCount > 0 ? vec4(0.5, 1, 0.5, 1) : vec4(1,1,1,1);
DoIconColor(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon, IconColor);
if((&r.front() - m_lDemos.base_ptr()) == m_DemolistSelectedIndex) // selected
{
TextRender()->TextColor(0.0f, 0.0f, 0.0f, 1.0f);
@ -431,6 +447,15 @@ void CMenus::RenderDemoList(CUIRect MainView)
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
DoInfoBox(&Button, Localize("Netversion"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion);
MainView.HSplitTop(Spacing, 0, &MainView);
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
const int MarkerCount = DemoGetMarkerCount(m_lDemos[m_DemolistSelectedIndex].m_Info);
str_format(aBuf, sizeof(aBuf), "%d", MarkerCount);
if(MarkerCount > 0)
TextRender()->TextColor(0.5, 1, 0.5, 1);
DoInfoBox(&Button, Localize("Markers"), aBuf);
TextRender()->TextColor(1, 1, 1, 1);
MainView.HSplitTop(Spacing, 0, &MainView);
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
DoInfoBox(&Button, Localize("Map"), m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapName);
@ -438,18 +463,18 @@ void CMenus::RenderDemoList(CUIRect MainView)
MainView.HSplitTop(Spacing, 0, &MainView);
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
Button.VSplitLeft(ButtonHeight, 0, &Button);
CUIRect ButtonRight;
Button.VSplitMid(&Button, &ButtonRight);
float Size = float((m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[1]<<16) |
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapSize[3]))/1024.0f;
str_format(aBuf, sizeof(aBuf), Localize("%.3f KiB"), Size);
DoInfoBox(&Button, Localize("Size"), aBuf);
MainView.HSplitTop(Spacing, 0, &MainView);
MainView.HSplitTop(ButtonHeight, &Button, &MainView);
Button.VSplitLeft(ButtonHeight, 0, &Button);
unsigned Crc = (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[0]<<24) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[1]<<16) |
(m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[2]<<8) | (m_lDemos[m_DemolistSelectedIndex].m_Info.m_aMapCrc[3]);
str_format(aBuf, sizeof(aBuf), "%08x", Crc);
DoInfoBox(&Button, Localize("Crc"), aBuf);
DoInfoBox(&ButtonRight, Localize("Crc"), aBuf);
}
// demo buttons