mirror of
https://github.com/ddnet/ddnet.git
synced 2024-09-20 09:34:19 +00:00
Render demo file icon in name column, remove DoIcon
centering
This commit is contained in:
parent
97e36fa4be
commit
f727199060
|
@ -110,30 +110,13 @@ CMenus::CMenus()
|
||||||
|
|
||||||
void CMenus::DoIcon(int ImageId, int SpriteId, const CUIRect *pRect, const ColorRGBA *pColor)
|
void CMenus::DoIcon(int ImageId, int SpriteId, const CUIRect *pRect, const ColorRGBA *pColor)
|
||||||
{
|
{
|
||||||
int x = pRect->x;
|
|
||||||
int y = pRect->y;
|
|
||||||
int w = pRect->w;
|
|
||||||
int h = pRect->h;
|
|
||||||
|
|
||||||
// Square and center
|
|
||||||
if(w > h)
|
|
||||||
{
|
|
||||||
x += (w - h) / 2;
|
|
||||||
w = h;
|
|
||||||
}
|
|
||||||
else if(h > w)
|
|
||||||
{
|
|
||||||
y += (h - w) / 2;
|
|
||||||
h = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id);
|
Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id);
|
||||||
|
|
||||||
Graphics()->QuadsBegin();
|
Graphics()->QuadsBegin();
|
||||||
RenderTools()->SelectSprite(SpriteId);
|
RenderTools()->SelectSprite(SpriteId);
|
||||||
if(pColor)
|
if(pColor)
|
||||||
Graphics()->SetColor(pColor->r * pColor->a, pColor->g * pColor->a, pColor->b * pColor->a, pColor->a);
|
Graphics()->SetColor(pColor->r * pColor->a, pColor->g * pColor->a, pColor->b * pColor->a, pColor->a);
|
||||||
IGraphics::CQuadItem QuadItem(x, y, w, h);
|
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
|
||||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||||
Graphics()->QuadsEnd();
|
Graphics()->QuadsEnd();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1003,15 +1003,13 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COL_ICON = 0,
|
COL_DEMONAME = 0,
|
||||||
COL_DEMONAME,
|
|
||||||
COL_MARKERS,
|
COL_MARKERS,
|
||||||
COL_LENGTH,
|
COL_LENGTH,
|
||||||
COL_DATE,
|
COL_DATE,
|
||||||
};
|
};
|
||||||
|
|
||||||
static CColumn s_aCols[] = {
|
static CColumn s_aCols[] = {
|
||||||
{COL_ICON, -1, " ", -1, 14.0f, 0, {0}, {0}},
|
|
||||||
{COL_DEMONAME, SORT_DEMONAME, "Demo", 0, 0.0f, 0, {0}, {0}},
|
{COL_DEMONAME, SORT_DEMONAME, "Demo", 0, 0.0f, 0, {0}, {0}},
|
||||||
{COL_MARKERS, SORT_MARKERS, "Markers", 1, 75.0f, 0, {0}, {0}},
|
{COL_MARKERS, SORT_MARKERS, "Markers", 1, 75.0f, 0, {0}, {0}},
|
||||||
{COL_LENGTH, SORT_LENGTH, "Length", 1, 75.0f, 0, {0}, {0}},
|
{COL_LENGTH, SORT_LENGTH, "Length", 1, 75.0f, 0, {0}, {0}},
|
||||||
|
@ -1140,6 +1138,14 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUIRect FileIcon;
|
||||||
|
Row.VSplitLeft(Row.h, &FileIcon, &Row);
|
||||||
|
Row.VSplitLeft(5.0f, 0, &Row);
|
||||||
|
FileIcon.Margin(2.0f, &FileIcon);
|
||||||
|
FileIcon.x += 2.0f;
|
||||||
|
|
||||||
|
DoIcon(IMAGE_FILEICONS, Item.m_IsDir ? SPRITE_FILE_FOLDER : SPRITE_FILE_DEMO1, &FileIcon);
|
||||||
|
|
||||||
for(int c = 0; c < NumCols; c++)
|
for(int c = 0; c < NumCols; c++)
|
||||||
{
|
{
|
||||||
CUIRect Button;
|
CUIRect Button;
|
||||||
|
@ -1150,12 +1156,9 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
||||||
|
|
||||||
int ID = s_aCols[c].m_ID;
|
int ID = s_aCols[c].m_ID;
|
||||||
|
|
||||||
if(ID == COL_ICON)
|
if(ID == COL_DEMONAME)
|
||||||
{
|
|
||||||
DoIcon(IMAGE_FILEICONS, Item.m_IsDir ? SPRITE_FILE_FOLDER : SPRITE_FILE_DEMO1, &Button);
|
|
||||||
}
|
|
||||||
else if(ID == COL_DEMONAME)
|
|
||||||
{
|
{
|
||||||
|
Button.x += FileIcon.w + 6.0f;
|
||||||
CTextCursor Cursor;
|
CTextCursor Cursor;
|
||||||
TextRender()->SetCursor(&Cursor, Button.x, Button.y + (Button.h - 12.0f) / 2.f, 12.0f, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y + (Button.h - 12.0f) / 2.f, 12.0f, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END);
|
||||||
Cursor.m_LineWidth = Button.w;
|
Cursor.m_LineWidth = Button.w;
|
||||||
|
|
Loading…
Reference in a new issue