Add toggle keyboard shortcuts button to demo player

Demo shortcuts can be annoying if you have other binds on them.

Icons made by eNJi
This commit is contained in:
12pm 2019-10-05 18:04:43 +02:00
parent 112d0432e2
commit 36df86fcd2
4 changed files with 15 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 262 B

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -270,7 +270,7 @@ set_demobuttons = SpriteSet("demobuttons", image_demobuttons, 5, 1)
set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1) set_fileicons = SpriteSet("fileicons", image_fileicons, 8, 1)
set_guibuttons = SpriteSet("guibuttons", image_guibuttons, 12, 4) set_guibuttons = SpriteSet("guibuttons", image_guibuttons, 12, 4)
set_guiicons = SpriteSet("guiicons", image_guiicons, 8, 2) set_guiicons = SpriteSet("guiicons", image_guiicons, 8, 2)
set_demobuttons2 = SpriteSet("demobuttons2", image_demobuttons2, 3, 1) set_demobuttons2 = SpriteSet("demobuttons2", image_demobuttons2, 4, 1)
set_audio_source = SpriteSet("audio_source", image_audio_source, 1, 1) set_audio_source = SpriteSet("audio_source", image_audio_source, 1, 1)
container.spritesets.Add(set_particles) container.spritesets.Add(set_particles)
@ -408,6 +408,8 @@ container.sprites.Add(Sprite("demobutton_faster", set_demobuttons, 4,0,1,1))
container.sprites.Add(Sprite("demobutton_slice_begin", set_demobuttons2, 0,0,1,1)) container.sprites.Add(Sprite("demobutton_slice_begin", set_demobuttons2, 0,0,1,1))
container.sprites.Add(Sprite("demobutton_slice_end", set_demobuttons2, 1,0,1,1)) container.sprites.Add(Sprite("demobutton_slice_end", set_demobuttons2, 1,0,1,1))
container.sprites.Add(Sprite("demobutton_shortcuts_enabled", set_demobuttons2, 2,0,1,1))
container.sprites.Add(Sprite("demobutton_shortcuts_disabled", set_demobuttons2, 3,0,1,1))
container.sprites.Add(Sprite("file_demo1", set_fileicons, 0,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_demo2", set_fileicons, 1,0,1,1))

View file

@ -358,6 +358,7 @@ MACRO_CONFIG_INT(ClConfigVersion, cl_config_version, 0, 0, 0, CFGFLAG_CLIENT|CFG
MACRO_CONFIG_INT(ClDemoSliceBegin, cl_demo_slice_begin, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Begin marker for demo slice") MACRO_CONFIG_INT(ClDemoSliceBegin, cl_demo_slice_begin, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Begin marker for demo slice")
MACRO_CONFIG_INT(ClDemoSliceEnd, cl_demo_slice_end, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "End marker for demo slice") MACRO_CONFIG_INT(ClDemoSliceEnd, cl_demo_slice_end, -1, 0, 0, CFGFLAG_SAVE|CFGFLAG_CLIENT, "End marker for demo slice")
MACRO_CONFIG_INT(ClDemoShowSpeed, cl_demo_show_speed, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Show speed meter on change") MACRO_CONFIG_INT(ClDemoShowSpeed, cl_demo_show_speed, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Show speed meter on change")
MACRO_CONFIG_INT(ClDemoKeyboardShortcuts, cl_demo_keyboard_shortcuts, 1, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Enable keyboard shortcuts in demo player")
//opengl //opengl
MACRO_CONFIG_INT(GfxOpenGL3, gfx_opengl3, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use new OpenGL3 with shaders") MACRO_CONFIG_INT(GfxOpenGL3, gfx_opengl3, 0, 0, 1, CFGFLAG_SAVE|CFGFLAG_CLIENT, "Use new OpenGL3 with shaders")

View file

@ -164,7 +164,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
} }
// handle keyboard shortcuts independent of active menu // handle keyboard shortcuts independent of active menu
if(m_pClient->m_pGameConsole->IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE) if(m_pClient->m_pGameConsole->IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts)
{ {
// increase/decrease speed // increase/decrease speed
if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP) || Input()->KeyPress(KEY_UP)) if(Input()->KeyPress(KEY_MOUSE_WHEEL_UP) || Input()->KeyPress(KEY_UP))
@ -467,6 +467,16 @@ void CMenus::RenderDemoPlayer(CUIRect MainView)
DemolistOnUpdate(false); DemolistOnUpdate(false);
} }
// toggle keyboard shortcuts button
ButtonBar.VSplitRight(Margins*3, &ButtonBar, 0);
ButtonBar.VSplitRight(ButtonbarHeight, &ButtonBar, &Button);
static int s_KeyboardShortcutsButton = 0;
int Sprite = g_Config.m_ClDemoKeyboardShortcuts ? SPRITE_DEMOBUTTON_SHORTCUTS_ENABLED : SPRITE_DEMOBUTTON_SHORTCUTS_DISABLED;
if(DoButton_Sprite(&s_KeyboardShortcutsButton, IMAGE_DEMOBUTTONS2, Sprite, 0, &Button, CUI::CORNER_ALL))
{
g_Config.m_ClDemoKeyboardShortcuts ^= 1;
}
// demo name // demo name
char aDemoName[64] = {0}; char aDemoName[64] = {0};
DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName)); DemoPlayer()->GetDemoName(aDemoName, sizeof(aDemoName));