mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
added icons in the demo browser and the editor's file dialog. Closes #209
This commit is contained in:
parent
4383e10933
commit
d94355729d
|
@ -226,6 +226,7 @@ image_game = Image("game", "game.png")
|
|||
image_browseicons = Image("browseicons", "browse_icons.png")
|
||||
image_emoticons = Image("emoticons", "emoticons.png")
|
||||
image_demobuttons = Image("demobuttons", "demo_buttons.png")
|
||||
image_fileicons = Image("fileicons", "file_icons.png")
|
||||
|
||||
container.images.Add(image_null)
|
||||
container.images.Add(image_game)
|
||||
|
@ -237,6 +238,7 @@ container.images.Add(image_browseicons)
|
|||
container.images.Add(Image("console_bg", "console.png"))
|
||||
container.images.Add(Image("console_bar", "console_bar.png"))
|
||||
container.images.Add(image_demobuttons)
|
||||
container.images.Add(image_fileicons)
|
||||
|
||||
container.pickups.Add(Pickup("health"))
|
||||
container.pickups.Add(Pickup("armor"))
|
||||
|
@ -249,6 +251,7 @@ set_tee = SpriteSet("tee", image_null, 8, 4)
|
|||
set_browseicons = SpriteSet("browseicons", image_browseicons, 4, 1)
|
||||
set_emoticons = SpriteSet("emoticons", image_emoticons, 4, 4)
|
||||
set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
|
||||
set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1)
|
||||
|
||||
container.spritesets.Add(set_particles)
|
||||
container.spritesets.Add(set_game)
|
||||
|
@ -256,6 +259,7 @@ container.spritesets.Add(set_tee)
|
|||
container.spritesets.Add(set_browseicons)
|
||||
container.spritesets.Add(set_emoticons)
|
||||
container.spritesets.Add(set_demobuttons)
|
||||
container.spritesets.Add(set_fileicons)
|
||||
|
||||
container.sprites.Add(Sprite("part_slice", set_particles, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("part_ball", set_particles, 1,0,1,1))
|
||||
|
@ -372,6 +376,12 @@ container.sprites.Add(Sprite("demobutton_stop", set_demobuttons, 2,0,1,1))
|
|||
container.sprites.Add(Sprite("demobutton_slower", set_demobuttons, 3,0,1,1))
|
||||
container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1))
|
||||
|
||||
container.sprites.Add(Sprite("file_demo1", set_fileicons, 0,0,1,1))
|
||||
container.sprites.Add(Sprite("file_demo2", set_fileicons, 1,0,1,1))
|
||||
container.sprites.Add(Sprite("file_folder", set_fileicons, 2,0,1,1))
|
||||
container.sprites.Add(Sprite("file_map1", set_fileicons, 5,0,1,1))
|
||||
container.sprites.Add(Sprite("file_map2", set_fileicons, 6,0,1,1))
|
||||
|
||||
|
||||
anim = Animation("base")
|
||||
anim.body.frames.Add(AnimKeyframe(0, 0, -4, 0))
|
||||
|
|
|
@ -112,12 +112,12 @@ vec4 CMenus::ButtonColorMul(const void *pID)
|
|||
return vec4(1,1,1,1);
|
||||
}
|
||||
|
||||
int CMenus::DoButton_BrowseIcon(int What, const CUIRect *pRect)
|
||||
int CMenus::DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect)
|
||||
{
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_BROWSEICONS].m_Id);
|
||||
Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id);
|
||||
|
||||
Graphics()->QuadsBegin();
|
||||
RenderTools()->SelectSprite(What);
|
||||
RenderTools()->SelectSprite(SpriteId);
|
||||
IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
|
|
|
@ -47,7 +47,7 @@ class CMenus : public CComponent
|
|||
static void ui_draw_settings_tab_button(const void *id, const char *text, int checked, const CUIRect *r, const void *extra);
|
||||
*/
|
||||
|
||||
int DoButton_BrowseIcon(int Checked, const CUIRect *pRect);
|
||||
int DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect);
|
||||
int DoButton_GridHeader(const void *pID, const char *pText, int Checked, const CUIRect *pRect);
|
||||
|
||||
//static void ui_draw_browse_icon(int what, const CUIRect *r);
|
||||
|
|
|
@ -273,7 +273,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
if(Id == COL_FLAG_LOCK)
|
||||
{
|
||||
if(pItem->m_Flags & SERVER_FLAG_PASSWORD)
|
||||
DoButton_BrowseIcon(SPRITE_BROWSE_LOCK, &Button);
|
||||
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_LOCK, &Button);
|
||||
}
|
||||
else if(Id == COL_FLAG_PURE)
|
||||
{
|
||||
|
@ -286,13 +286,13 @@ void CMenus::RenderServerbrowserServerList(CUIRect View)
|
|||
else
|
||||
{
|
||||
// unpure
|
||||
DoButton_BrowseIcon(SPRITE_BROWSE_UNPURE, &Button);
|
||||
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_UNPURE, &Button);
|
||||
}
|
||||
}
|
||||
else if(Id == COL_FLAG_FAV)
|
||||
{
|
||||
if(pItem->m_Favorite)
|
||||
DoButton_BrowseIcon(SPRITE_BROWSE_HEART, &Button);
|
||||
DoButton_Icon(IMAGE_BROWSEICONS, SPRITE_BROWSE_HEART, &Button);
|
||||
}
|
||||
else if(Id == COL_NAME)
|
||||
{
|
||||
|
|
|
@ -442,7 +442,7 @@ void CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType
|
|||
}
|
||||
else
|
||||
{
|
||||
str_format(Item.m_aName, min(static_cast<int>(sizeof(Item.m_aName)), Length), " %s", pName);
|
||||
str_copy(Item.m_aName, pName, min(static_cast<int>(sizeof(Item.m_aName)), Length));
|
||||
char aBuffer[512];
|
||||
str_format(aBuffer, sizeof(aBuffer), "%s/%s", pSelf->m_aCurrentDemoFolder, Item.m_aFilename);
|
||||
// TODO: many items slow this down, don't load the info from every file when making the filelist
|
||||
|
@ -509,7 +509,7 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f);
|
||||
MainView.Margin(10.0f, &MainView);
|
||||
|
||||
CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect;
|
||||
CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, FileIcon;
|
||||
MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar);
|
||||
ButtonBar.HSplitTop(5.0f, 0, &ButtonBar);
|
||||
ButtonBar.VSplitRight(130.0f, &ButtonBar, &PlayRect);
|
||||
|
@ -524,7 +524,12 @@ void CMenus::RenderDemoList(CUIRect MainView)
|
|||
{
|
||||
CListboxItem Item = UiDoListboxNextItem((void*)(&r.front()));
|
||||
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);
|
||||
DoButton_Icon(IMAGE_FILEICONS, r.front().m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_DEMO1, &FileIcon);
|
||||
UI()->DoLabel(&Item.m_Rect, r.front().m_aName, Item.m_Rect.h*ms_FontmodHeight, -1);
|
||||
}
|
||||
}
|
||||
bool Activated = false;
|
||||
m_DemolistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <game/client/ui.h>
|
||||
#include <game/gamecore.h>
|
||||
#include <game/client/render.h>
|
||||
#include <game/generated/client_data.h>
|
||||
|
||||
#include "ed_editor.h"
|
||||
#include <game/client/lineinput.h>
|
||||
|
@ -2136,7 +2137,7 @@ static void EditorListdirCallback(const char *pName, int IsDir, int StorageType,
|
|||
if(IsDir)
|
||||
str_format(Item.m_aName, sizeof(Item.m_aName), "%s/", pName);
|
||||
else
|
||||
str_format(Item.m_aName, min(static_cast<int>(sizeof(Item.m_aName)), Length+1), " %s", pName);
|
||||
str_copy(Item.m_aName, pName, min(static_cast<int>(sizeof(Item.m_aName)), Length+1));
|
||||
Item.m_IsDir = IsDir != 0;
|
||||
Item.m_IsLink = false;
|
||||
Item.m_StorageType = StorageType;
|
||||
|
@ -2149,9 +2150,18 @@ void CEditor::AddFileDialogEntry(int Index, CUIRect *pView)
|
|||
if(m_FilesCur-1 < m_FilesStartAt || m_FilesCur >= m_FilesStopAt)
|
||||
return;
|
||||
|
||||
CUIRect Button;
|
||||
CUIRect Button, FileIcon;
|
||||
pView->HSplitTop(15.0f, &Button, pView);
|
||||
pView->HSplitTop(2.0f, 0, pView);
|
||||
Button.VSplitLeft(Button.h, &FileIcon, &Button);
|
||||
Button.VSplitLeft(5.0f, 0, &Button);
|
||||
|
||||
Graphics()->TextureSet(g_pData->m_aImages[IMAGE_FILEICONS].m_Id);
|
||||
Graphics()->QuadsBegin();
|
||||
RenderTools()->SelectSprite(m_FileList[Index].m_IsDir?SPRITE_FILE_FOLDER:SPRITE_FILE_MAP2);
|
||||
IGraphics::CQuadItem QuadItem(FileIcon.x, FileIcon.y, FileIcon.w, FileIcon.h);
|
||||
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
||||
Graphics()->QuadsEnd();
|
||||
|
||||
if(DoButton_File((void*)(10+(int)Button.y), m_FileList[Index].m_aName, m_FilesSelectedIndex == Index, &Button, 0, 0))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue