From 4d8c4ffadb9c788eb83d244dc509e56251d09030 Mon Sep 17 00:00:00 2001 From: Fujnky Date: Tue, 27 Jul 2010 22:25:36 +0200 Subject: [PATCH] Improved the replay control buttons in the demo player a lot. * Now there is a combined play/pause button + a reset button * Replaced the ugly strings with nice graphics --- data/demo_buttons.png | Bin 0 -> 599 bytes datasrc/content.py | 12 +++++- src/game/client/components/menus.h | 1 + src/game/client/components/menus_demo.cpp | 46 +++++++++++++++------- 4 files changed, 43 insertions(+), 16 deletions(-) create mode 100644 data/demo_buttons.png diff --git a/data/demo_buttons.png b/data/demo_buttons.png new file mode 100644 index 0000000000000000000000000000000000000000..47a5c2f11e750612f6c080541a25921eb48d49a3 GIT binary patch literal 599 zcmeAS@N?(olHy`uVBq!ia0vp^3xHUGgAGVdtuOuxq!^2X+?^QKos)S9URktgaY8ZX2_|rc5yQhc9x6d~| zdomuEaNuU~D$x`*!EZR-b3Tk5znj&YtjP_X^=YxfctgiMuxYdWXq*LSMb%?GH zv-BBuZ{@a_xq0*RMeCkUZJ6{&#MI+g>=n*4#tb`{Z>;k@aPr1l+xEnF80H! zGaEAJ1nB+Ze!!Km*@1C=S-s_~{hcTM1Kp05&h@KF`StReWU}6|8JC&XyXgZZEmF^| z?>xuZ`qH-H^C9_z>AU??s#sQky8lH`=DCaRN2#B}LMmO0+MXzhi5cAMjCy2R#;Yu( z`bf%6D=FULz`hm2TaRRaQK|}?!XkdrPH-_K2!LXLLgxfGwXA=%=jSacmA`tgfM!Jr z2PiFab2u-NUzfok - #include #include +#include #include #include @@ -11,6 +11,8 @@ #include +#include + #include "menus.h" int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, const CUIRect *pRect) @@ -20,6 +22,19 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, return UI()->DoButtonLogic(pID, pText, Checked, pRect); } +int CMenus::DoButton_DemoPlayer_Sprite(const void *pID, int spriteId, int Checked, const CUIRect *pRect) +{ + RenderTools()->DrawUIRect(pRect, vec4(1,1,1, Checked ? 0.10f : 0.5f)*ButtonColorMul(pID), CUI::CORNER_ALL, 5.0f); + Graphics()->TextureSet(g_pData->m_aImages[IMAGE_DEMOBUTTONS].m_Id); + Graphics()->QuadsBegin(); + RenderTools()->SelectSprite(spriteId); + IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); + Graphics()->QuadsDrawTL(&QuadItem, 1); + Graphics()->QuadsEnd(); + + return UI()->DoButtonLogic(pID, "", Checked, pRect); +} + void CMenus::RenderDemoPlayer(CUIRect MainView) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); @@ -111,33 +126,34 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { // do buttons CUIRect Button; - - // pause button + + // combined play and pause button ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_PauseButton = 0; - if(DoButton_DemoPlayer(&s_PauseButton, "| |", pInfo->m_Paused, &Button)) + static int s_PlayPauseButton = 0; + if(!pInfo->m_Paused) { - if(pInfo->m_Paused) - DemoPlayer()->Unpause(); - else + if(DoButton_DemoPlayer_Sprite(&s_PlayPauseButton, SPRITE_DEMOBUTTON_PAUSE, pInfo->m_Paused, &Button)) DemoPlayer()->Pause(); } + else + { + if(DoButton_DemoPlayer_Sprite(&s_PlayPauseButton, SPRITE_DEMOBUTTON_PLAY, !pInfo->m_Paused, &Button)) + DemoPlayer()->Unpause(); + } - // play button ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); - static int s_PlayButton = 0; - if(DoButton_DemoPlayer(&s_PlayButton, ">", !pInfo->m_Paused, &Button)) + static int s_ResetButton = 0; + if(DoButton_DemoPlayer_Sprite(&s_ResetButton, SPRITE_DEMOBUTTON_RESET, false, &Button)) { - DemoPlayer()->Unpause(); - DemoPlayer()->SetSpeed(1.0f); + DemoPlayer()->SetPos(0); } // slowdown ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_SlowDownButton = 0; - if(DoButton_DemoPlayer(&s_SlowDownButton, "<<", 0, &Button)) + if(DoButton_DemoPlayer_Sprite(&s_SlowDownButton, SPRITE_DEMOBUTTON_SLOWER, 0, &Button)) { if(pInfo->m_Speed > 4.0f) DemoPlayer()->SetSpeed(4.0f); else if(pInfo->m_Speed > 2.0f) DemoPlayer()->SetSpeed(2.0f); @@ -150,7 +166,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_FastForwardButton = 0; - if(DoButton_DemoPlayer(&s_FastForwardButton, ">>", 0, &Button)) + if(DoButton_DemoPlayer_Sprite(&s_FastForwardButton, SPRITE_DEMOBUTTON_FASTER, 0, &Button)) { if(pInfo->m_Speed < 0.5f) DemoPlayer()->SetSpeed(0.5f); else if(pInfo->m_Speed < 1.0f) DemoPlayer()->SetSpeed(1.0f);