2010-11-20 10:37:14 +00:00
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
2010-05-29 07:25:38 +00:00
# include <base/math.h>
2022-05-18 16:00:05 +00:00
# include <base/system.h>
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
# include <engine/graphics.h>
2020-09-26 19:41:58 +00:00
# include <engine/shared/config.h>
# include <engine/shared/linereader.h>
2010-09-16 11:32:56 +00:00
# include <engine/storage.h>
2010-05-29 07:25:38 +00:00
# include <engine/textrender.h>
2015-04-18 19:17:27 +00:00
# include <engine/updater.h>
2008-08-27 15:48:50 +00:00
2020-09-26 19:41:58 +00:00
# include <game/generated/protocol.h>
2008-08-27 15:48:50 +00:00
2020-09-18 16:45:42 +00:00
# include <game/client/animstate.h>
2020-10-13 20:08:52 +00:00
# include <game/client/components/chat.h>
2020-09-18 16:45:42 +00:00
# include <game/client/components/menu_background.h>
2011-04-13 18:00:54 +00:00
# include <game/client/components/sounds.h>
2010-05-29 07:25:38 +00:00
# include <game/client/gameclient.h>
2020-09-18 16:45:42 +00:00
# include <game/client/render.h>
# include <game/client/ui.h>
2010-05-29 07:25:38 +00:00
# include <game/localization.h>
2008-08-27 15:48:50 +00:00
2010-05-29 07:25:38 +00:00
# include "binds.h"
2011-03-16 20:31:55 +00:00
# include "countryflags.h"
2010-05-29 07:25:38 +00:00
# include "menus.h"
# include "skins.h"
2008-08-27 15:48:50 +00:00
2022-05-29 16:33:38 +00:00
# include <array>
# include <chrono>
2022-03-20 17:03:25 +00:00
# include <memory>
2022-05-29 16:33:38 +00:00
# include <numeric>
2022-05-06 21:51:24 +00:00
# include <string>
2022-03-20 17:03:25 +00:00
# include <vector>
2020-10-09 07:07:05 +00:00
2022-05-18 16:00:05 +00:00
using namespace std : : chrono_literals ;
2010-05-29 07:25:38 +00:00
CMenusKeyBinder CMenus : : m_Binder ;
2008-10-20 23:10:00 +00:00
2010-05-29 07:25:38 +00:00
CMenusKeyBinder : : CMenusKeyBinder ( )
2008-10-20 23:10:00 +00:00
{
2010-05-29 07:25:38 +00:00
m_TakeKey = false ;
m_GotKey = false ;
2022-02-06 22:14:26 +00:00
m_ModifierCombination = 0 ;
2008-10-20 23:10:00 +00:00
}
2010-05-29 07:25:38 +00:00
bool CMenusKeyBinder : : OnInput ( IInput : : CEvent Event )
2008-10-20 23:10:00 +00:00
{
2010-05-29 07:25:38 +00:00
if ( m_TakeKey )
2008-10-20 23:10:00 +00:00
{
2019-04-28 17:22:19 +00:00
int TriggeringEvent = ( Event . m_Key = = KEY_MOUSE_1 ) ? IInput : : FLAG_PRESS : IInput : : FLAG_RELEASE ;
2020-09-26 19:41:58 +00:00
if ( Event . m_Flags & TriggeringEvent )
2008-10-20 23:10:00 +00:00
{
2010-05-29 07:25:38 +00:00
m_Key = Event ;
m_GotKey = true ;
m_TakeKey = false ;
2019-04-28 17:22:19 +00:00
2022-02-06 22:40:06 +00:00
m_ModifierCombination = CBinds : : GetModifierMask ( Input ( ) ) ;
if ( m_ModifierCombination = = CBinds : : GetModifierMaskOfKey ( Event . m_Key ) )
2019-04-28 17:22:19 +00:00
{
2022-02-06 22:14:26 +00:00
m_ModifierCombination = 0 ;
2019-04-28 17:22:19 +00:00
}
2008-10-20 23:10:00 +00:00
}
return true ;
}
2010-05-29 07:25:38 +00:00
2008-10-20 23:10:00 +00:00
return false ;
}
2011-04-01 17:36:44 +00:00
void CMenus : : RenderSettingsGeneral ( CUIRect MainView )
2008-08-27 15:48:50 +00:00
{
2022-03-20 11:57:50 +00:00
char aBuf [ 128 + IO_MAX_PATH_LENGTH ] ;
2020-09-18 16:45:42 +00:00
CUIRect Label , Button , Left , Right , Game , Client ;
2020-09-19 06:53:26 +00:00
MainView . HSplitTop ( 150.0f , & Game , & Client ) ;
2008-08-27 15:48:50 +00:00
2011-04-01 17:36:44 +00:00
// game
2010-05-29 07:25:38 +00:00
{
2011-04-01 17:36:44 +00:00
// headline
2020-09-29 01:23:39 +00:00
Game . HSplitTop ( 20.0f , & Label , & Game ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Game " ) , 20.0f , TEXTALIGN_LEFT ) ;
2011-04-01 17:36:44 +00:00
Game . Margin ( 5.0f , & Game ) ;
Game . VSplitMid ( & Left , & Right ) ;
Left . VSplitRight ( 5.0f , & Left , 0 ) ;
Right . VMargin ( 5.0f , & Right ) ;
2009-06-15 08:15:53 +00:00
2011-04-01 17:36:44 +00:00
// dynamic camera
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2020-09-24 07:57:23 +00:00
bool IsDyncam = g_Config . m_ClDyncam | | g_Config . m_ClMouseFollowfactor > 0 ;
2020-09-29 06:25:34 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClDyncam , Localize ( " Dynamic Camera " ) , IsDyncam , & Button ) )
2020-09-24 07:57:23 +00:00
{
if ( IsDyncam )
{
g_Config . m_ClDyncam = 0 ;
g_Config . m_ClMouseFollowfactor = 0 ;
}
else
{
g_Config . m_ClDyncam = 1 ;
}
}
2008-08-27 15:48:50 +00:00
2020-11-07 10:29:23 +00:00
// smooth dynamic camera
2020-10-14 00:43:30 +00:00
Left . HSplitTop ( 5.0f , 0 , & Left ) ;
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2020-11-07 10:29:23 +00:00
if ( g_Config . m_ClDyncam )
2020-10-14 00:43:30 +00:00
{
2020-11-07 10:29:23 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClDyncamSmoothness , Localize ( " Smooth Dynamic Camera " ) , g_Config . m_ClDyncamSmoothness , & Button ) )
2020-10-14 00:43:30 +00:00
{
2020-11-07 10:29:23 +00:00
if ( g_Config . m_ClDyncamSmoothness )
{
g_Config . m_ClDyncamSmoothness = 0 ;
}
else
{
g_Config . m_ClDyncamSmoothness = 50 ;
g_Config . m_ClDyncamStabilizing = 50 ;
}
2020-10-14 00:43:30 +00:00
}
}
2011-04-01 17:36:44 +00:00
// weapon pickup
Left . HSplitTop ( 5.0f , 0 , & Left ) ;
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2010-05-29 07:25:38 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClAutoswitchWeapons , Localize ( " Switch weapon on pickup " ) , g_Config . m_ClAutoswitchWeapons , & Button ) )
g_Config . m_ClAutoswitchWeapons ^ = 1 ;
2014-06-16 11:29:18 +00:00
// weapon out of ammo autoswitch
Left . HSplitTop ( 5.0f , 0 , & Left ) ;
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAutoswitchWeaponsOutOfAmmo , Localize ( " Switch weapon when out of ammo " ) , g_Config . m_ClAutoswitchWeaponsOutOfAmmo , & Button ) )
g_Config . m_ClAutoswitchWeaponsOutOfAmmo ^ = 1 ;
2011-03-16 20:31:55 +00:00
}
2010-05-29 07:25:38 +00:00
2011-04-01 17:36:44 +00:00
// client
2011-03-16 20:31:55 +00:00
{
2011-04-01 17:36:44 +00:00
// headline
2020-09-29 01:23:39 +00:00
Client . HSplitTop ( 20.0f , & Label , & Client ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Client " ) , 20.0f , TEXTALIGN_LEFT ) ;
2011-04-01 17:36:44 +00:00
Client . Margin ( 5.0f , & Client ) ;
Client . VSplitMid ( & Left , & Right ) ;
Left . VSplitRight ( 5.0f , & Left , 0 ) ;
Right . VMargin ( 5.0f , & Right ) ;
2010-05-29 07:25:38 +00:00
2020-09-03 12:08:26 +00:00
// skip main menu
Left . HSplitTop ( 5.0f , 0 , & Left ) ;
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClSkipStartMenu , Localize ( " Skip the main menu " ) , g_Config . m_ClSkipStartMenu , & Button ) )
2020-09-10 18:14:47 +00:00
g_Config . m_ClSkipStartMenu ^ = 1 ;
2020-09-03 12:08:26 +00:00
2020-10-11 14:23:59 +00:00
float SliderGroupMargin = 10.0f ;
2020-09-29 01:23:39 +00:00
2011-04-01 17:36:44 +00:00
// auto demo settings
{
2020-10-11 14:23:59 +00:00
Right . HSplitTop ( 40.0f , 0 , & Right ) ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2011-04-01 17:36:44 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClAutoDemoRecord , Localize ( " Automatically record demos " ) , g_Config . m_ClAutoDemoRecord , & Button ) )
g_Config . m_ClAutoDemoRecord ^ = 1 ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
2011-04-01 17:36:44 +00:00
if ( g_Config . m_ClAutoDemoMax )
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Max demos " ) , g_Config . m_ClAutoDemoMax ) ;
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Max demos " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClAutoDemoMax = static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClAutoDemoMax , & Button , g_Config . m_ClAutoDemoMax / 1000.0f ) * 1000.0f + 0.1f ) ;
2011-04-01 17:36:44 +00:00
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( SliderGroupMargin , 0 , & Right ) ;
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAutoScreenshot , Localize ( " Automatically take game over screenshot " ) , g_Config . m_ClAutoScreenshot , & Button ) )
g_Config . m_ClAutoScreenshot ^ = 1 ;
2011-04-01 17:36:44 +00:00
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
if ( g_Config . m_ClAutoScreenshotMax )
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Max Screenshots " ) , g_Config . m_ClAutoScreenshotMax ) ;
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Max Screenshots " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClAutoScreenshotMax = static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClAutoScreenshotMax , & Button , g_Config . m_ClAutoScreenshotMax / 1000.0f ) * 1000.0f + 0.1f ) ;
2011-04-01 17:36:44 +00:00
}
2014-06-16 13:43:11 +00:00
2020-09-29 01:23:39 +00:00
Left . HSplitTop ( 10.0f , 0 , & Left ) ;
2014-06-16 13:43:11 +00:00
Left . HSplitTop ( 20.0f , & Label , & Left ) ;
2017-06-02 19:33:45 +00:00
if ( g_Config . m_ClRefreshRate )
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i Hz " , Localize ( " Refresh Rate " ) , g_Config . m_ClRefreshRate ) ;
2014-06-16 13:43:11 +00:00
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Refresh Rate " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2020-09-18 16:45:42 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClRefreshRate = static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClRefreshRate , & Button , g_Config . m_ClRefreshRate / 10000.0f ) * 10000.0f + 0.1f ) ;
2015-05-21 10:26:50 +00:00
2021-12-19 00:23:29 +00:00
Left . HSplitTop ( 15.0f , 0 , & Left ) ;
CUIRect SettingsButton ;
Left . HSplitBottom ( 25.0f , & Left , & SettingsButton ) ;
SettingsButton . HSplitTop ( 5.0f , 0 , & SettingsButton ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_SettingsButtonID ;
2021-12-19 00:23:29 +00:00
if ( DoButton_Menu ( & s_SettingsButtonID , Localize ( " Settings file " ) , 0 , & SettingsButton ) )
{
2022-02-01 20:39:45 +00:00
Storage ( ) - > GetCompletePath ( IStorage : : TYPE_SAVE , CONFIG_FILE , aBuf , sizeof ( aBuf ) ) ;
2021-12-19 00:23:29 +00:00
if ( ! open_file ( aBuf ) )
{
dbg_msg ( " menus " , " couldn't open file " ) ;
}
}
Left . HSplitTop ( 15.0f , 0 , & Left ) ;
CUIRect ConfigButton ;
Left . HSplitBottom ( 25.0f , & Left , & ConfigButton ) ;
ConfigButton . HSplitTop ( 5.0f , 0 , & ConfigButton ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ConfigButtonID ;
2021-12-19 00:23:29 +00:00
if ( DoButton_Menu ( & s_ConfigButtonID , Localize ( " Config directory " ) , 0 , & ConfigButton ) )
{
Storage ( ) - > GetCompletePath ( IStorage : : TYPE_SAVE , " " , aBuf , sizeof ( aBuf ) ) ;
if ( ! open_file ( aBuf ) )
{
dbg_msg ( " menus " , " couldn't open file " ) ;
}
}
2020-09-29 01:23:39 +00:00
Left . HSplitTop ( 15.0f , 0 , & Left ) ;
CUIRect DirectoryButton ;
Left . HSplitBottom ( 25.0f , & Left , & DirectoryButton ) ;
2020-09-18 16:45:42 +00:00
RenderThemeSelection ( Left ) ;
2020-09-29 01:23:39 +00:00
DirectoryButton . HSplitTop ( 5.0f , 0 , & DirectoryButton ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ThemesButtonID ;
2021-05-17 07:11:36 +00:00
if ( DoButton_Menu ( & s_ThemesButtonID , Localize ( " Themes directory " ) , 0 , & DirectoryButton ) )
2020-09-29 01:23:39 +00:00
{
Storage ( ) - > GetCompletePath ( IStorage : : TYPE_SAVE , " themes " , aBuf , sizeof ( aBuf ) ) ;
Storage ( ) - > CreateFolder ( " themes " , IStorage : : TYPE_SAVE ) ;
2021-12-19 00:13:08 +00:00
if ( ! open_file ( aBuf ) )
2020-09-29 01:23:39 +00:00
{
2021-12-19 00:13:08 +00:00
dbg_msg ( " menus " , " couldn't open file " ) ;
2020-09-29 01:23:39 +00:00
}
}
2015-05-21 12:34:20 +00:00
// auto statboard screenshot
2015-05-21 10:26:50 +00:00
{
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( SliderGroupMargin , 0 , & Right ) ;
2015-05-21 10:26:50 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAutoStatboardScreenshot ,
2020-09-26 19:41:58 +00:00
Localize ( " Automatically take statboard screenshot " ) ,
g_Config . m_ClAutoStatboardScreenshot , & Button ) )
2015-05-21 10:26:50 +00:00
{
g_Config . m_ClAutoStatboardScreenshot ^ = 1 ;
}
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
if ( g_Config . m_ClAutoStatboardScreenshotMax )
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Max Screenshots " ) , g_Config . m_ClAutoStatboardScreenshotMax ) ;
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Max Screenshots " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2015-05-21 10:26:50 +00:00
g_Config . m_ClAutoStatboardScreenshotMax =
2021-12-03 18:54:22 +00:00
static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClAutoStatboardScreenshotMax ,
2020-09-26 19:41:58 +00:00
& Button ,
g_Config . m_ClAutoStatboardScreenshotMax / 1000.0f ) *
1000.0f +
0.1f ) ;
2015-05-21 10:26:50 +00:00
}
2017-04-26 03:10:31 +00:00
// auto statboard csv
{
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( SliderGroupMargin , 0 , & Right ) ; //
2017-04-26 03:10:31 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2018-03-13 20:59:07 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClAutoCSV ,
2020-09-26 19:41:58 +00:00
Localize ( " Automatically create statboard csv " ) ,
g_Config . m_ClAutoCSV , & Button ) )
2017-04-26 03:10:31 +00:00
{
g_Config . m_ClAutoCSV ^ = 1 ;
}
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
2018-03-13 20:59:07 +00:00
if ( g_Config . m_ClAutoCSVMax )
2017-04-26 03:10:31 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Max CSVs " ) , g_Config . m_ClAutoCSVMax ) ;
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Max CSVs " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2020-09-29 01:23:39 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2017-04-26 03:10:31 +00:00
g_Config . m_ClAutoCSVMax =
2021-12-03 18:54:22 +00:00
static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClAutoCSVMax ,
2020-09-26 19:41:58 +00:00
& Button ,
g_Config . m_ClAutoCSVMax / 1000.0f ) *
1000.0f +
0.1f ) ;
2017-04-26 03:10:31 +00:00
}
2011-04-01 17:36:44 +00:00
}
2011-03-16 20:31:55 +00:00
}
2010-05-29 07:25:38 +00:00
2020-09-28 22:19:03 +00:00
void CMenus : : SetNeedSendInfo ( )
{
if ( m_Dummy )
m_NeedSendDummyinfo = true ;
else
m_NeedSendinfo = true ;
}
2011-04-01 17:36:44 +00:00
void CMenus : : RenderSettingsPlayer ( CUIRect MainView )
2011-03-16 20:31:55 +00:00
{
2014-04-26 18:29:42 +00:00
CUIRect Button , Label , Dummy ;
2011-03-16 20:31:55 +00:00
MainView . HSplitTop ( 10.0f , 0 , & MainView ) ;
2008-08-27 15:48:50 +00:00
2020-08-20 10:19:03 +00:00
char * pName = g_Config . m_PlayerName ;
const char * pNameFallback = Client ( ) - > PlayerName ( ) ;
char * pClan = g_Config . m_PlayerClan ;
int * pCountry = & g_Config . m_PlayerCountry ;
2014-04-26 18:29:42 +00:00
2015-08-28 18:44:07 +00:00
if ( m_Dummy )
2014-04-26 18:29:42 +00:00
{
2020-08-20 10:19:03 +00:00
pName = g_Config . m_ClDummyName ;
2020-08-25 14:22:03 +00:00
pNameFallback = Client ( ) - > DummyName ( ) ;
2020-08-20 10:19:03 +00:00
pClan = g_Config . m_ClDummyClan ;
pCountry = & g_Config . m_ClDummyCountry ;
2014-04-26 18:29:42 +00:00
}
2011-03-16 20:31:55 +00:00
// player name
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 80.0f , & Label , & Button ) ;
Button . VSplitLeft ( 150.0f , & Button , 0 ) ;
char aBuf [ 128 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( " Name " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2011-03-16 20:31:55 +00:00
static float s_OffsetName = 0.0f ;
2022-03-13 18:09:33 +00:00
SUIExEditBoxProperties EditProps ;
EditProps . m_pEmptyText = pNameFallback ;
if ( UIEx ( ) - > DoEditBox ( pName , & Button , pName , sizeof ( g_Config . m_PlayerName ) , 14.0f , & s_OffsetName , false , CUI : : CORNER_ALL , EditProps ) )
2014-04-28 13:34:56 +00:00
{
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2014-04-28 13:34:56 +00:00
}
2011-03-16 20:31:55 +00:00
// player clan
MainView . HSplitTop ( 5.0f , 0 , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 80.0f , & Label , & Button ) ;
2020-08-20 10:19:03 +00:00
Button . VSplitLeft ( 200.0f , & Button , & Dummy ) ;
2011-03-16 20:31:55 +00:00
Button . VSplitLeft ( 150.0f , & Button , 0 ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( " Clan " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2011-03-16 20:31:55 +00:00
static float s_OffsetClan = 0.0f ;
2021-12-03 19:15:44 +00:00
if ( UIEx ( ) - > DoEditBox ( pClan , & Button , pClan , sizeof ( g_Config . m_PlayerClan ) , 14.0f , & s_OffsetClan ) )
2014-04-28 13:34:56 +00:00
{
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2014-04-28 13:34:56 +00:00
}
2011-03-16 20:31:55 +00:00
2020-08-20 10:19:03 +00:00
if ( DoButton_CheckBox ( & m_Dummy , Localize ( " Dummy settings " ) , m_Dummy , & Dummy ) )
{
m_Dummy ^ = 1 ;
}
2018-02-13 02:44:43 +00:00
static bool s_ListBoxUsed = false ;
2022-05-27 08:55:32 +00:00
if ( UI ( ) - > CheckActiveItem ( pClan ) | | UI ( ) - > CheckActiveItem ( pName ) )
2018-02-13 02:44:43 +00:00
s_ListBoxUsed = false ;
2011-03-16 20:31:55 +00:00
// country flag selector
MainView . HSplitTop ( 20.0f , 0 , & MainView ) ;
static float s_ScrollValue = 0.0f ;
int OldSelected = - 1 ;
2021-07-12 09:43:56 +00:00
UiDoListboxStart ( & s_ScrollValue , & MainView , 50.0f , Localize ( " Country / Region " ) , " " , m_pClient - > m_CountryFlags . Num ( ) , 6 , OldSelected , s_ScrollValue ) ;
2010-05-29 07:25:38 +00:00
2022-05-23 17:51:54 +00:00
for ( size_t i = 0 ; i < m_pClient - > m_CountryFlags . Num ( ) ; + + i )
2011-03-16 20:31:55 +00:00
{
2021-07-12 09:43:56 +00:00
const CCountryFlags : : CCountryFlag * pEntry = m_pClient - > m_CountryFlags . GetByIndex ( i ) ;
2020-08-20 10:19:03 +00:00
if ( pEntry - > m_CountryCode = = * pCountry )
2011-03-16 20:31:55 +00:00
OldSelected = i ;
2010-05-29 07:25:38 +00:00
2022-05-23 17:51:54 +00:00
CListboxItem Item = UiDoListboxNextItem ( & pEntry - > m_CountryCode , OldSelected > = 0 & & ( size_t ) OldSelected = = i , s_ListBoxUsed ) ;
2011-03-16 20:31:55 +00:00
if ( Item . m_Visible )
2008-08-27 15:48:50 +00:00
{
2011-07-31 00:04:46 +00:00
Item . m_Rect . Margin ( 5.0f , & Item . m_Rect ) ;
Item . m_Rect . HSplitBottom ( 10.0f , & Item . m_Rect , & Label ) ;
2011-03-16 20:31:55 +00:00
float OldWidth = Item . m_Rect . w ;
2020-09-26 19:41:58 +00:00
Item . m_Rect . w = Item . m_Rect . h * 2 ;
Item . m_Rect . x + = ( OldWidth - Item . m_Rect . w ) / 2.0f ;
2019-04-26 21:47:34 +00:00
ColorRGBA Color ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2021-07-12 09:43:56 +00:00
m_pClient - > m_CountryFlags . Render ( pEntry - > m_CountryCode , & Color , Item . m_Rect . x , Item . m_Rect . y , Item . m_Rect . w , Item . m_Rect . h ) ;
2012-08-12 12:02:50 +00:00
if ( pEntry - > m_Texture . IsValid ( ) )
2022-01-21 15:20:15 +00:00
UI ( ) - > DoLabel ( & Label , pEntry - > m_aCountryCodeString , 10.0f , TEXTALIGN_CENTER ) ;
2008-08-27 15:48:50 +00:00
}
2011-03-16 20:31:55 +00:00
}
2010-05-29 07:25:38 +00:00
2018-02-13 02:44:43 +00:00
bool Clicked = false ;
const int NewSelected = UiDoListboxEnd ( & s_ScrollValue , 0 , & Clicked ) ;
if ( Clicked )
s_ListBoxUsed = true ;
2011-03-16 20:31:55 +00:00
if ( OldSelected ! = NewSelected )
{
2021-07-12 09:43:56 +00:00
* pCountry = m_pClient - > m_CountryFlags . GetByIndex ( NewSelected ) - > m_CountryCode ;
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2011-03-16 20:31:55 +00:00
}
}
2010-05-29 07:25:38 +00:00
2021-03-23 12:20:35 +00:00
struct CUISkin
{
const CSkin * m_pSkin ;
CUISkin ( ) :
m_pSkin ( nullptr ) { }
CUISkin ( const CSkin * pSkin ) :
m_pSkin ( pSkin ) { }
bool operator < ( const CUISkin & Other ) const { return str_comp_nocase ( m_pSkin - > m_aName , Other . m_pSkin - > m_aName ) < 0 ; }
bool operator < ( const char * pOther ) const { return str_comp_nocase ( m_pSkin - > m_aName , pOther ) < 0 ; }
bool operator = = ( const char * pOther ) const { return ! str_comp_nocase ( m_pSkin - > m_aName , pOther ) ; }
} ;
2011-04-01 17:36:44 +00:00
void CMenus : : RenderSettingsTee ( CUIRect MainView )
2011-03-16 20:31:55 +00:00
{
2022-04-18 05:55:50 +00:00
CUIRect Button , Label , Dummy , DummyLabel , SkinList , QuickSearch , QuickSearchClearButton , SkinDB , SkinPrefix , SkinPrefixLabel , DirectoryButton , RefreshButton , Eyes , EyesLabel , EyesTee , EyesRight ;
2016-05-07 13:59:58 +00:00
2013-12-26 17:02:37 +00:00
static bool s_InitSkinlist = true ;
2022-04-18 05:55:50 +00:00
Eyes = MainView ;
2010-05-29 07:25:38 +00:00
2021-12-03 19:15:44 +00:00
char * pSkinName = g_Config . m_ClPlayerSkin ;
2022-06-30 22:36:32 +00:00
int * pUseCustomColor = & g_Config . m_ClPlayerUseCustomColor ;
unsigned * pColorBody = & g_Config . m_ClPlayerColorBody ;
unsigned * pColorFeet = & g_Config . m_ClPlayerColorFeet ;
2014-04-26 18:29:42 +00:00
2015-08-28 18:44:07 +00:00
if ( m_Dummy )
2014-04-26 18:29:42 +00:00
{
2021-12-03 19:15:44 +00:00
pSkinName = g_Config . m_ClDummySkin ;
2022-06-30 22:36:32 +00:00
pUseCustomColor = & g_Config . m_ClDummyUseCustomColor ;
pColorBody = & g_Config . m_ClDummyColorBody ;
pColorFeet = & g_Config . m_ClDummyColorFeet ;
2014-04-26 18:29:42 +00:00
}
2011-03-16 20:31:55 +00:00
// skin info
CTeeRenderInfo OwnSkinInfo ;
2021-12-03 19:15:44 +00:00
const CSkin * pSkin = m_pClient - > m_Skins . Get ( m_pClient - > m_Skins . Find ( pSkinName ) ) ;
2020-10-09 07:07:05 +00:00
OwnSkinInfo . m_OriginalRenderSkin = pSkin - > m_OriginalSkin ;
OwnSkinInfo . m_ColorableRenderSkin = pSkin - > m_ColorableSkin ;
2020-11-08 05:39:16 +00:00
OwnSkinInfo . m_SkinMetrics = pSkin - > m_Metrics ;
2022-06-30 22:36:32 +00:00
OwnSkinInfo . m_CustomColoredSkin = * pUseCustomColor ;
if ( * pUseCustomColor )
2011-03-16 20:31:55 +00:00
{
2022-06-30 22:36:32 +00:00
OwnSkinInfo . m_ColorBody = color_cast < ColorRGBA > ( ColorHSLA ( * pColorBody ) . UnclampLighting ( ) ) ;
OwnSkinInfo . m_ColorFeet = color_cast < ColorRGBA > ( ColorHSLA ( * pColorFeet ) . UnclampLighting ( ) ) ;
2011-03-16 20:31:55 +00:00
}
else
{
2019-04-26 12:06:32 +00:00
OwnSkinInfo . m_ColorBody = ColorRGBA ( 1.0f , 1.0f , 1.0f ) ;
OwnSkinInfo . m_ColorFeet = ColorRGBA ( 1.0f , 1.0f , 1.0f ) ;
2011-03-16 20:31:55 +00:00
}
2022-06-12 08:34:09 +00:00
OwnSkinInfo . m_Size = 50.0f ;
2010-05-29 07:25:38 +00:00
2022-06-12 11:31:33 +00:00
MainView . HSplitTop ( 10.0f , & Label , & MainView ) ;
2014-04-26 18:29:42 +00:00
Label . VSplitLeft ( 280.0f , & Label , & Dummy ) ;
2011-03-16 20:31:55 +00:00
Label . VSplitLeft ( 230.0f , & Label , 0 ) ;
2018-12-23 21:56:45 +00:00
Dummy . VSplitLeft ( 170.0f , & Dummy , & SkinPrefix ) ;
2022-04-18 05:55:50 +00:00
SkinPrefix . VSplitLeft ( 120.0f , & SkinPrefix , & EyesRight ) ;
2022-03-20 11:57:50 +00:00
char aBuf [ 128 + IO_MAX_PATH_LENGTH ] ;
2011-03-16 20:31:55 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( " Your skin " ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2011-03-16 20:31:55 +00:00
2014-08-17 03:34:16 +00:00
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2018-07-06 09:24:57 +00:00
if ( DoButton_CheckBox ( & m_Dummy , Localize ( " Dummy settings " ) , m_Dummy , & DummyLabel ) )
2014-04-26 18:29:42 +00:00
{
2015-08-28 18:44:07 +00:00
m_Dummy ^ = 1 ;
2014-04-26 18:29:42 +00:00
}
2022-04-28 14:46:18 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & m_Dummy , & DummyLabel , Localize ( " Toggle to edit your dummy settings " ) ) ;
2014-04-26 18:29:42 +00:00
2014-08-17 03:34:16 +00:00
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2020-09-20 00:19:24 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClDownloadSkins , Localize ( " Download skins " ) , g_Config . m_ClDownloadSkins , & DummyLabel ) )
{
g_Config . m_ClDownloadSkins ^ = 1 ;
}
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2022-06-12 11:31:33 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClDownloadCommunitySkins , Localize ( " Download community skins " ) , g_Config . m_ClDownloadCommunitySkins , & DummyLabel ) )
{
g_Config . m_ClDownloadCommunitySkins ^ = 1 ;
}
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2017-07-24 21:48:26 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClVanillaSkinsOnly , Localize ( " Vanilla skins only " ) , g_Config . m_ClVanillaSkinsOnly , & DummyLabel ) )
2014-08-17 03:34:16 +00:00
{
2015-08-28 18:44:07 +00:00
g_Config . m_ClVanillaSkinsOnly ^ = 1 ;
2018-07-25 12:13:07 +00:00
s_InitSkinlist = true ;
2016-05-07 13:59:58 +00:00
}
2017-07-24 21:48:26 +00:00
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2020-09-26 19:41:58 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClFatSkins , Localize ( " Fat skins (DDFat) " ) , g_Config . m_ClFatSkins , & DummyLabel ) )
2017-07-24 21:48:26 +00:00
{
g_Config . m_ClFatSkins ^ = 1 ;
}
2018-07-25 06:16:57 +00:00
2018-07-24 15:26:39 +00:00
SkinPrefix . HSplitTop ( 20.0f , & SkinPrefixLabel , & SkinPrefix ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & SkinPrefixLabel , Localize ( " Skin prefix " ) , 14.0f , TEXTALIGN_LEFT ) ;
2018-07-24 15:26:39 +00:00
SkinPrefix . HSplitTop ( 20.0f , & SkinPrefixLabel , & SkinPrefix ) ;
2018-09-20 05:48:14 +00:00
{
static int s_ClearButton = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
UIEx ( ) - > DoClearableEditBox ( g_Config . m_ClSkinPrefix , & s_ClearButton , & SkinPrefixLabel , g_Config . m_ClSkinPrefix , sizeof ( g_Config . m_ClSkinPrefix ) , 14.0f , & s_Offset ) ;
2018-09-20 05:48:14 +00:00
}
2017-07-24 21:48:26 +00:00
2018-07-25 06:16:57 +00:00
SkinPrefix . HSplitTop ( 2.0f , 0 , & SkinPrefix ) ;
{
2022-06-30 22:36:32 +00:00
static const char * s_apSkinPrefixes [ ] = { " kitty " , " santa " } ;
for ( auto & pPrefix : s_apSkinPrefixes )
2018-07-25 06:16:57 +00:00
{
2018-09-20 05:50:17 +00:00
SkinPrefix . HSplitTop ( 20.0f , & Button , & SkinPrefix ) ;
2018-07-25 06:16:57 +00:00
Button . HMargin ( 2.0f , & Button ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_PrefixButton ;
if ( DoButton_Menu ( & s_PrefixButton , pPrefix , 0 , & Button ) )
2018-07-25 06:16:57 +00:00
{
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_ClSkinPrefix , pPrefix ) ;
2018-07-25 06:16:57 +00:00
}
}
}
2017-07-24 21:48:26 +00:00
2014-08-17 03:34:16 +00:00
Dummy . HSplitTop ( 20.0f , & DummyLabel , & Dummy ) ;
2011-03-16 20:31:55 +00:00
MainView . HSplitTop ( 50.0f , & Label , & MainView ) ;
Label . VSplitLeft ( 230.0f , & Label , 0 ) ;
2021-03-12 20:23:29 +00:00
CAnimState * pIdleState = CAnimState : : GetIdle ( ) ;
vec2 OffsetToMid ;
RenderTools ( ) - > GetRenderTeeOffsetToRenderedTee ( pIdleState , & OwnSkinInfo , OffsetToMid ) ;
vec2 TeeRenderPos ( Label . x + 30.0f , Label . y + Label . h / 2.0f + OffsetToMid . y ) ;
2022-04-18 05:55:50 +00:00
int Emote = m_Dummy ? g_Config . m_ClDummyDefaultEyes : g_Config . m_ClPlayerDefaultEyes ;
RenderTools ( ) - > RenderTee ( pIdleState , & OwnSkinInfo , Emote , vec2 ( 1 , 0 ) , TeeRenderPos ) ;
2011-03-16 20:31:55 +00:00
Label . VSplitLeft ( 70.0f , 0 , & Label ) ;
2020-09-21 08:35:13 +00:00
Label . HMargin ( 15.0f , & Label ) ;
2021-12-03 19:15:44 +00:00
2022-04-18 05:55:50 +00:00
// default eyes
bool RenderEyesBelow = MainView . w < 750.0f ;
if ( RenderEyesBelow )
{
Eyes . VSplitLeft ( 190.0f , 0 , & Eyes ) ;
2022-06-12 11:31:33 +00:00
Eyes . HSplitTop ( 105.0f , 0 , & Eyes ) ;
2022-04-18 05:55:50 +00:00
}
else
{
Eyes = EyesRight ;
if ( MainView . w < 810.0f )
Eyes . VSplitRight ( 205.0f , 0 , & Eyes ) ;
Eyes . HSplitTop ( 50.0f , & Eyes , 0 ) ;
}
Eyes . HSplitTop ( 120.0f , & EyesLabel , & Eyes ) ;
EyesLabel . VSplitLeft ( 20.0f , 0 , & EyesLabel ) ;
EyesLabel . HSplitTop ( 50.0f , & EyesLabel , & Eyes ) ;
float Highlight = 0.0f ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_aEyeButtons [ 6 ] ;
2022-04-18 05:55:50 +00:00
static int s_aEyesToolTip [ 6 ] ;
for ( int CurrentEyeEmote = 0 ; CurrentEyeEmote < 6 ; CurrentEyeEmote + + )
{
EyesLabel . VSplitLeft ( 10.0f , 0 , & EyesLabel ) ;
EyesLabel . VSplitLeft ( 50.0f , & EyesTee , & EyesLabel ) ;
if ( CurrentEyeEmote = = 2 & & ! RenderEyesBelow )
{
Eyes . HSplitTop ( 60.0f , & EyesLabel , 0 ) ;
EyesLabel . HSplitTop ( 10.0f , 0 , & EyesLabel ) ;
}
Highlight = ( m_Dummy ) ? g_Config . m_ClDummyDefaultEyes = = CurrentEyeEmote : g_Config . m_ClPlayerDefaultEyes = = CurrentEyeEmote ;
if ( DoButton_Menu ( & s_aEyeButtons [ CurrentEyeEmote ] , " " , 0 , & EyesTee , 0 , CUI : : CORNER_ALL , 10.0f , 0.0f , vec4 ( 1 , 1 , 1 , 0.5f + Highlight * 0.25f ) , vec4 ( 1 , 1 , 1 , 0.25f + Highlight * 0.25f ) ) )
{
if ( m_Dummy )
{
g_Config . m_ClDummyDefaultEyes = CurrentEyeEmote ;
if ( g_Config . m_ClDummy )
GameClient ( ) - > m_Emoticon . EyeEmote ( CurrentEyeEmote ) ;
}
else
{
g_Config . m_ClPlayerDefaultEyes = CurrentEyeEmote ;
if ( ! g_Config . m_ClDummy )
GameClient ( ) - > m_Emoticon . EyeEmote ( CurrentEyeEmote ) ;
}
}
2022-04-28 14:46:18 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & s_aEyesToolTip [ CurrentEyeEmote ] , & EyesTee , Localize ( " Choose default eyes when joining a server " ) ) ;
2022-04-18 05:55:50 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & OwnSkinInfo , CurrentEyeEmote , vec2 ( 1 , 0 ) , vec2 ( EyesTee . x + 25.0f , EyesTee . y + EyesTee . h / 2.0f + OffsetToMid . y ) ) ;
}
2020-09-21 08:35:13 +00:00
static float s_OffsetSkin = 0.0f ;
static int s_ClearButton = 0 ;
2022-03-13 18:09:33 +00:00
SUIExEditBoxProperties EditProps ;
EditProps . m_pEmptyText = " default " ;
if ( UIEx ( ) - > DoClearableEditBox ( pSkinName , & s_ClearButton , & Label , pSkinName , sizeof ( g_Config . m_ClPlayerSkin ) , 14.0f , & s_OffsetSkin , false , CUI : : CORNER_ALL , EditProps ) )
2020-09-28 22:19:03 +00:00
{
SetNeedSendInfo ( ) ;
}
2011-03-16 20:31:55 +00:00
2020-09-26 07:37:35 +00:00
// custom color selector
2022-04-18 05:55:50 +00:00
MainView . HSplitTop ( 20.0f + RenderEyesBelow * 25.0f , 0 , & MainView ) ;
2011-03-16 20:31:55 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2022-04-18 05:55:50 +00:00
Button . VSplitLeft ( 150.0f , & Button , 0 ) ;
2021-05-17 07:11:36 +00:00
static int s_CustomColorID = 0 ;
2022-06-30 22:36:32 +00:00
if ( DoButton_CheckBox ( & s_CustomColorID , Localize ( " Custom colors " ) , * pUseCustomColor , & Button ) )
2011-03-16 20:31:55 +00:00
{
2022-06-30 22:36:32 +00:00
* pUseCustomColor = * pUseCustomColor ? 0 : 1 ;
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2011-03-16 20:31:55 +00:00
}
2010-05-29 07:25:38 +00:00
2011-03-16 20:31:55 +00:00
MainView . HSplitTop ( 5.0f , 0 , & MainView ) ;
MainView . HSplitTop ( 82.5f , & Label , & MainView ) ;
2022-06-30 22:36:32 +00:00
if ( * pUseCustomColor )
2011-03-16 20:31:55 +00:00
{
CUIRect aRects [ 2 ] ;
2022-01-26 19:19:44 +00:00
Label . VSplitMid ( & aRects [ 0 ] , & aRects [ 1 ] , 20.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-30 22:36:32 +00:00
unsigned * apColors [ 2 ] = { pColorBody , pColorFeet } ;
const char * apParts [ ] = { Localize ( " Body " ) , Localize ( " Feet " ) } ;
2010-05-29 07:25:38 +00:00
2011-03-16 20:31:55 +00:00
for ( int i = 0 ; i < 2 ; i + + )
2008-08-27 15:48:50 +00:00
{
2011-03-16 20:31:55 +00:00
aRects [ i ] . HSplitTop ( 20.0f , & Label , & aRects [ i ] ) ;
2022-06-30 22:36:32 +00:00
UI ( ) - > DoLabel ( & Label , apParts [ i ] , 14.0f , TEXTALIGN_LEFT ) ;
2020-06-27 13:08:35 +00:00
aRects [ i ] . VSplitLeft ( 10.0f , 0 , & aRects [ i ] ) ;
2011-03-16 20:31:55 +00:00
aRects [ i ] . HSplitTop ( 2.5f , 0 , & aRects [ i ] ) ;
2022-06-30 22:36:32 +00:00
unsigned PrevColor = * apColors [ i ] ;
RenderHSLScrollbars ( & aRects [ i ] , apColors [ i ] , false , true ) ;
2010-05-29 07:25:38 +00:00
2022-06-30 22:36:32 +00:00
if ( PrevColor ! = * apColors [ i ] )
2014-04-28 13:19:57 +00:00
{
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2014-04-28 13:19:57 +00:00
}
2010-05-29 07:25:38 +00:00
}
2011-03-16 20:31:55 +00:00
}
2009-10-27 14:38:53 +00:00
2011-03-16 20:31:55 +00:00
// skin selector
MainView . HSplitTop ( 20.0f , 0 , & MainView ) ;
2022-04-18 05:55:50 +00:00
MainView . HSplitTop ( 230.0f - RenderEyesBelow * 25.0f , & SkinList , & MainView ) ;
2022-05-23 16:05:16 +00:00
static std : : vector < CUISkin > s_vSkinList ;
2020-09-21 08:19:13 +00:00
static int s_SkinCount = 0 ;
2011-03-16 20:31:55 +00:00
static float s_ScrollValue = 0.0f ;
2021-07-12 09:43:56 +00:00
if ( s_InitSkinlist | | m_pClient - > m_Skins . Num ( ) ! = s_SkinCount )
2011-03-16 20:31:55 +00:00
{
2022-05-23 16:05:16 +00:00
s_vSkinList . clear ( ) ;
2021-07-12 09:43:56 +00:00
for ( int i = 0 ; i < m_pClient - > m_Skins . Num ( ) ; + + i )
2009-10-27 14:38:53 +00:00
{
2022-06-30 22:36:32 +00:00
const CSkin * pSkinToBeSelected = m_pClient - > m_Skins . Get ( i ) ;
2016-02-12 17:52:10 +00:00
// filter quick search
2022-06-30 22:36:32 +00:00
if ( g_Config . m_ClSkinFilterString [ 0 ] ! = ' \0 ' & & ! str_utf8_find_nocase ( pSkinToBeSelected - > m_aName , g_Config . m_ClSkinFilterString ) )
2016-02-12 17:52:10 +00:00
continue ;
2011-03-16 20:31:55 +00:00
// no special skins
2022-06-30 22:36:32 +00:00
if ( ( pSkinToBeSelected - > m_aName [ 0 ] = = ' x ' & & pSkinToBeSelected - > m_aName [ 1 ] = = ' _ ' ) )
2010-05-29 07:25:38 +00:00
continue ;
2016-02-12 17:52:10 +00:00
2018-07-25 12:13:07 +00:00
// vanilla skins only
2022-06-30 22:36:32 +00:00
if ( g_Config . m_ClVanillaSkinsOnly & & ! pSkinToBeSelected - > m_IsVanilla )
2018-07-25 12:13:07 +00:00
continue ;
2022-06-30 22:36:32 +00:00
if ( pSkinToBeSelected = = 0 )
2020-12-16 06:11:52 +00:00
continue ;
2022-06-30 22:36:32 +00:00
s_vSkinList . emplace_back ( pSkinToBeSelected ) ;
2011-03-16 20:31:55 +00:00
}
2022-05-23 16:05:16 +00:00
std : : sort ( s_vSkinList . begin ( ) , s_vSkinList . end ( ) ) ;
2011-03-16 20:31:55 +00:00
s_InitSkinlist = false ;
2021-07-12 09:43:56 +00:00
s_SkinCount = m_pClient - > m_Skins . Num ( ) ;
2011-03-16 20:31:55 +00:00
}
2010-05-29 07:25:38 +00:00
2011-03-16 20:31:55 +00:00
int OldSelected = - 1 ;
2022-05-23 16:05:16 +00:00
UiDoListboxStart ( & s_InitSkinlist , & SkinList , 50.0f , Localize ( " Skins " ) , " " , s_vSkinList . size ( ) , 4 , OldSelected , s_ScrollValue ) ;
for ( size_t i = 0 ; i < s_vSkinList . size ( ) ; + + i )
2011-03-16 20:31:55 +00:00
{
2022-06-30 22:36:32 +00:00
const CSkin * pSkinToBeDraw = s_vSkinList [ i ] . m_pSkin ;
2010-05-29 07:25:38 +00:00
2022-06-30 22:36:32 +00:00
if ( str_comp ( pSkinToBeDraw - > m_aName , pSkinName ) = = 0 )
2011-03-16 20:31:55 +00:00
OldSelected = i ;
2010-05-29 07:25:38 +00:00
2022-06-30 22:36:32 +00:00
CListboxItem Item = UiDoListboxNextItem ( pSkinToBeDraw , OldSelected > = 0 & & ( size_t ) OldSelected = = i ) ;
2011-03-16 20:31:55 +00:00
if ( Item . m_Visible )
2008-08-27 15:48:50 +00:00
{
2019-05-09 22:25:48 +00:00
CTeeRenderInfo Info = OwnSkinInfo ;
2022-06-30 22:36:32 +00:00
Info . m_CustomColoredSkin = * pUseCustomColor ;
2020-10-09 07:07:05 +00:00
2022-06-30 22:36:32 +00:00
Info . m_OriginalRenderSkin = pSkinToBeDraw - > m_OriginalSkin ;
Info . m_ColorableRenderSkin = pSkinToBeDraw - > m_ColorableSkin ;
Info . m_SkinMetrics = pSkinToBeDraw - > m_Metrics ;
2019-05-09 22:25:48 +00:00
2021-03-12 20:23:29 +00:00
RenderTools ( ) - > GetRenderTeeOffsetToRenderedTee ( pIdleState , & Info , OffsetToMid ) ;
TeeRenderPos = vec2 ( Item . m_Rect . x + 30 , Item . m_Rect . y + Item . m_Rect . h / 2 + OffsetToMid . y ) ;
2022-05-12 01:24:42 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & Info , Emote , vec2 ( 1.0f , 0.0f ) , TeeRenderPos ) ;
2010-05-29 07:25:38 +00:00
2014-10-05 20:26:47 +00:00
Item . m_Rect . VSplitLeft ( 60.0f , 0 , & Item . m_Rect ) ;
2022-03-11 16:34:48 +00:00
SLabelProperties Props ;
Props . m_MaxWidth = Item . m_Rect . w ;
2022-06-30 22:36:32 +00:00
UI ( ) - > DoLabel ( & Item . m_Rect , pSkinToBeDraw - > m_aName , 12.0f , TEXTALIGN_LEFT , Props ) ;
2011-03-16 20:31:55 +00:00
if ( g_Config . m_Debug )
2009-10-27 14:38:53 +00:00
{
2022-06-30 22:36:32 +00:00
ColorRGBA BloodColor = * pUseCustomColor ? color_cast < ColorRGBA > ( ColorHSLA ( * pColorBody ) ) : pSkinToBeDraw - > m_BloodColor ;
2012-08-12 10:41:50 +00:00
Graphics ( ) - > TextureClear ( ) ;
2011-03-16 20:31:55 +00:00
Graphics ( ) - > QuadsBegin ( ) ;
Graphics ( ) - > SetColor ( BloodColor . r , BloodColor . g , BloodColor . b , 1.0f ) ;
IGraphics : : CQuadItem QuadItem ( Item . m_Rect . x , Item . m_Rect . y , 12.0f , 12.0f ) ;
Graphics ( ) - > QuadsDrawTL ( & QuadItem , 1 ) ;
Graphics ( ) - > QuadsEnd ( ) ;
2009-10-27 14:38:53 +00:00
}
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
}
2008-10-20 23:38:23 +00:00
2011-03-16 20:31:55 +00:00
const int NewSelected = UiDoListboxEnd ( & s_ScrollValue , 0 ) ;
if ( OldSelected ! = NewSelected )
{
2022-05-23 16:05:16 +00:00
mem_copy ( pSkinName , s_vSkinList [ NewSelected ] . m_pSkin - > m_aName , sizeof ( g_Config . m_ClPlayerSkin ) ) ;
2020-09-28 22:19:03 +00:00
SetNeedSendInfo ( ) ;
2010-05-29 07:25:38 +00:00
}
2016-02-12 17:52:10 +00:00
// render quick search
{
MainView . HSplitBottom ( ms_ButtonHeight , & MainView , & QuickSearch ) ;
2020-09-21 08:39:42 +00:00
QuickSearch . VSplitLeft ( 240.0f , & QuickSearch , & SkinDB ) ;
2016-02-12 17:52:10 +00:00
QuickSearch . HSplitTop ( 5.0f , 0 , & QuickSearch ) ;
2022-03-19 17:50:33 +00:00
const char * pSearchLabel = " \xEF \x80 \x82 " ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
2020-10-06 10:25:10 +00:00
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-03-11 16:34:48 +00:00
SLabelProperties Props ;
Props . m_AlignVertically = 0 ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & QuickSearch , pSearchLabel , 14.0f , TEXTALIGN_LEFT , Props ) ;
2020-07-15 19:10:13 +00:00
float wSearch = TextRender ( ) - > TextWidth ( 0 , 14.0f , pSearchLabel , - 1 , - 1.0f ) ;
2018-03-13 20:59:07 +00:00
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2016-02-12 17:52:10 +00:00
QuickSearch . VSplitLeft ( wSearch , 0 , & QuickSearch ) ;
QuickSearch . VSplitLeft ( 5.0f , 0 , & QuickSearch ) ;
2020-09-26 19:41:58 +00:00
QuickSearch . VSplitLeft ( QuickSearch . w - 15.0f , & QuickSearch , & QuickSearchClearButton ) ;
2022-03-20 11:57:50 +00:00
static int s_ClearButtonSearch = 0 ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
2022-03-20 11:57:50 +00:00
SUIExEditBoxProperties EditPropsSearch ;
2021-12-18 11:23:20 +00:00
if ( Input ( ) - > KeyPress ( KEY_F ) & & Input ( ) - > ModifierIsPressed ( ) )
2022-03-13 18:09:33 +00:00
{
2017-07-24 16:05:19 +00:00
UI ( ) - > SetActiveItem ( & g_Config . m_ClSkinFilterString ) ;
2022-03-13 18:09:33 +00:00
2022-03-20 11:57:50 +00:00
EditPropsSearch . m_SelectText = true ;
2022-03-13 18:09:33 +00:00
}
2022-03-20 11:57:50 +00:00
EditPropsSearch . m_pEmptyText = Localize ( " Search " ) ;
if ( UIEx ( ) - > DoClearableEditBox ( & g_Config . m_ClSkinFilterString , & s_ClearButtonSearch , & QuickSearch , g_Config . m_ClSkinFilterString , sizeof ( g_Config . m_ClSkinFilterString ) , 14.0f , & s_Offset , false , CUI : : CORNER_ALL , EditPropsSearch ) )
2016-02-12 17:52:10 +00:00
s_InitSkinlist = true ;
}
2008-08-27 15:48:50 +00:00
2020-09-29 01:23:39 +00:00
SkinDB . VSplitLeft ( 150.0f , & SkinDB , & DirectoryButton ) ;
2020-09-21 08:39:42 +00:00
SkinDB . HSplitTop ( 5.0f , 0 , & SkinDB ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_SkinDBDirID ;
2021-05-17 07:11:36 +00:00
if ( DoButton_Menu ( & s_SkinDBDirID , Localize ( " Skin Database " ) , 0 , & SkinDB ) )
2020-09-21 08:39:42 +00:00
{
if ( ! open_link ( " https://ddnet.tw/skins/ " ) )
{
dbg_msg ( " menus " , " couldn't open link " ) ;
}
}
2020-09-29 01:23:39 +00:00
DirectoryButton . HSplitTop ( 5.0f , 0 , & DirectoryButton ) ;
DirectoryButton . VSplitRight ( 175.0f , 0 , & DirectoryButton ) ;
2020-10-06 14:00:18 +00:00
DirectoryButton . VSplitRight ( 25.0f , & DirectoryButton , & RefreshButton ) ;
DirectoryButton . VSplitRight ( 10.0f , & DirectoryButton , 0 ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DirectoryButtonID ;
2021-05-17 07:11:36 +00:00
if ( DoButton_Menu ( & s_DirectoryButtonID , Localize ( " Skins directory " ) , 0 , & DirectoryButton ) )
2020-09-29 01:23:39 +00:00
{
Storage ( ) - > GetCompletePath ( IStorage : : TYPE_SAVE , " skins " , aBuf , sizeof ( aBuf ) ) ;
Storage ( ) - > CreateFolder ( " skins " , IStorage : : TYPE_SAVE ) ;
2021-12-19 00:13:08 +00:00
if ( ! open_file ( aBuf ) )
2020-09-29 01:23:39 +00:00
{
2021-12-19 00:13:08 +00:00
dbg_msg ( " menus " , " couldn't open file " ) ;
2020-09-29 01:23:39 +00:00
}
}
2020-10-06 14:00:18 +00:00
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
2020-10-06 10:25:10 +00:00
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_SkinRefreshButtonID ;
2022-07-09 15:06:03 +00:00
if ( DoButton_Menu ( & s_SkinRefreshButtonID , " \xEF \x80 \x9E " , 0 , & RefreshButton , nullptr , CUI : : CORNER_ALL , 5 , 0 , vec4 ( 1.0f , 1.0f , 1.0f , 0.75f ) , vec4 ( 1 , 1 , 1 , 0.5f ) , 0 ) )
2020-10-06 14:00:18 +00:00
{
2022-04-02 11:37:59 +00:00
// reset render flags for possible loading screen
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2022-06-13 16:07:29 +00:00
auto SkinStartLoadTime = time_get_nanoseconds ( ) ;
2022-04-02 11:37:59 +00:00
m_pClient - > m_Skins . Refresh ( [ & ] ( int ) {
// if skin refreshing takes to long, swap to a loading screen
2022-06-13 16:07:29 +00:00
if ( time_get_nanoseconds ( ) - SkinStartLoadTime > 500 ms )
2022-04-02 11:37:59 +00:00
{
2022-06-23 17:59:38 +00:00
RenderLoading ( Localize ( " Loading skin files " ) , " " , 0 , false ) ;
2022-04-02 11:37:59 +00:00
}
} ) ;
2020-10-06 14:00:18 +00:00
s_InitSkinlist = true ;
2020-10-09 07:07:05 +00:00
if ( Client ( ) - > State ( ) > = IClient : : STATE_ONLINE )
{
m_pClient - > RefindSkins ( ) ;
}
2020-10-06 14:00:18 +00:00
}
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2008-08-27 15:48:50 +00:00
}
2011-04-01 17:36:44 +00:00
2010-05-29 07:25:38 +00:00
typedef struct
2008-10-05 18:27:20 +00:00
{
2010-05-29 07:25:38 +00:00
CLocConstString m_Name ;
const char * m_pCommand ;
int m_KeyId ;
2022-02-06 22:14:26 +00:00
int m_ModifierCombination ;
2010-05-29 07:25:38 +00:00
} CKeyInfo ;
2008-10-05 18:27:20 +00:00
2010-05-29 07:25:38 +00:00
static CKeyInfo gs_aKeys [ ] =
2020-09-26 19:41:58 +00:00
{
{ " Move left " , " +left " , 0 , 0 } , // Localize - these strings are localized within CLocConstString
{ " Move right " , " +right " , 0 , 0 } ,
{ " Jump " , " +jump " , 0 , 0 } ,
{ " Fire " , " +fire " , 0 , 0 } ,
{ " Hook " , " +hook " , 0 , 0 } ,
{ " Hook collisions " , " +showhookcoll " , 0 , 0 } ,
{ " Pause " , " say /pause " , 0 , 0 } ,
{ " Kill " , " kill " , 0 , 0 } ,
{ " Zoom in " , " zoom+ " , 0 , 0 } ,
{ " Zoom out " , " zoom- " , 0 , 0 } ,
{ " Default zoom " , " zoom " , 0 , 0 } ,
{ " Show others " , " say /showothers " , 0 , 0 } ,
{ " Show all " , " say /showall " , 0 , 0 } ,
{ " Toggle dyncam " , " toggle cl_dyncam 0 1 " , 0 , 0 } ,
{ " Toggle ghost " , " toggle cl_race_show_ghost 0 1 " , 0 , 0 } ,
{ " Hammer " , " +weapon1 " , 0 , 0 } ,
{ " Pistol " , " +weapon2 " , 0 , 0 } ,
{ " Shotgun " , " +weapon3 " , 0 , 0 } ,
{ " Grenade " , " +weapon4 " , 0 , 0 } ,
{ " Laser " , " +weapon5 " , 0 , 0 } ,
{ " Next weapon " , " +nextweapon " , 0 , 0 } ,
{ " Prev. weapon " , " +prevweapon " , 0 , 0 } ,
{ " Vote yes " , " vote yes " , 0 , 0 } ,
{ " Vote no " , " vote no " , 0 , 0 } ,
{ " Chat " , " +show_chat; chat all " , 0 , 0 } ,
{ " Team chat " , " +show_chat; chat team " , 0 , 0 } ,
{ " Converse " , " +show_chat; chat all /c " , 0 , 0 } ,
2020-12-18 18:13:07 +00:00
{ " Chat command " , " +show_chat; chat all / " , 0 , 0 } ,
2020-09-26 19:41:58 +00:00
{ " Show chat " , " +show_chat " , 0 , 0 } ,
2020-12-18 18:13:07 +00:00
{ " Toggle dummy " , " toggle cl_dummy 0 1 " , 0 , 0 } ,
{ " Dummy copy " , " toggle cl_dummy_copy_moves 0 1 " , 0 , 0 } ,
{ " Hammerfly dummy " , " toggle cl_dummy_hammer 0 1 " , 0 , 0 } ,
2020-09-26 19:41:58 +00:00
{ " Emoticon " , " +emote " , 0 , 0 } ,
{ " Spectator mode " , " +spectate " , 0 , 0 } ,
{ " Spectate next " , " spectate_next " , 0 , 0 } ,
{ " Spectate previous " , " spectate_previous " , 0 , 0 } ,
{ " Console " , " toggle_local_console " , 0 , 0 } ,
{ " Remote console " , " toggle_remote_console " , 0 , 0 } ,
{ " Screenshot " , " screenshot " , 0 , 0 } ,
{ " Scoreboard " , " +scoreboard " , 0 , 0 } ,
{ " Statboard " , " +statboard " , 0 , 0 } ,
{ " Lock team " , " say /lock " , 0 , 0 } ,
{ " Show entities " , " toggle cl_overlay_entities 0 100 " , 0 , 0 } ,
{ " Show HUD " , " toggle cl_showhud 0 1 " , 0 , 0 } ,
2008-10-05 18:27:20 +00:00
} ;
2011-04-06 19:15:58 +00:00
2019-12-02 08:08:56 +00:00
/* This is for scripts/languages to work, don't remove!
Localize ( " Move left " ) ; Localize ( " Move right " ) ; Localize ( " Jump " ) ; Localize ( " Fire " ) ; Localize ( " Hook " ) ;
Localize ( " Hook collisions " ) ; Localize ( " Pause " ) ; Localize ( " Kill " ) ; Localize ( " Zoom in " ) ; Localize ( " Zoom out " ) ;
Localize ( " Default zoom " ) ; Localize ( " Show others " ) ; Localize ( " Show all " ) ; Localize ( " Toggle dyncam " ) ;
Localize ( " Toggle dummy " ) ; Localize ( " Toggle ghost " ) ; Localize ( " Dummy copy " ) ; Localize ( " Hammerfly dummy " ) ;
Localize ( " Hammer " ) ; Localize ( " Pistol " ) ; Localize ( " Shotgun " ) ; Localize ( " Grenade " ) ; Localize ( " Laser " ) ;
Localize ( " Next weapon " ) ; Localize ( " Prev. weapon " ) ; Localize ( " Vote yes " ) ; Localize ( " Vote no " ) ;
Localize ( " Chat " ) ; Localize ( " Team chat " ) ; Localize ( " Converse " ) ; Localize ( " Show chat " ) ; Localize ( " Emoticon " ) ;
Localize ( " Spectator mode " ) ; Localize ( " Spectate next " ) ; Localize ( " Spectate previous " ) ; Localize ( " Console " ) ;
Localize ( " Remote console " ) ; Localize ( " Screenshot " ) ; Localize ( " Scoreboard " ) ; Localize ( " Statboard " ) ;
2021-03-03 14:21:02 +00:00
Localize ( " Lock team " ) ; Localize ( " Show entities " ) ; Localize ( " Show HUD " ) ; Localize ( " Chat command " ) ;
2010-08-08 22:35:37 +00:00
*/
2008-10-05 18:27:20 +00:00
2022-06-07 19:37:43 +00:00
void CMenus : : DoSettingsControlsButtons ( int Start , int Stop , CUIRect View )
2008-10-05 18:27:20 +00:00
{
2017-07-22 15:35:30 +00:00
for ( int i = Start ; i < Stop ; i + + )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
CKeyInfo & Key = gs_aKeys [ i ] ;
CUIRect Button , Label ;
View . HSplitTop ( 20.0f , & Button , & View ) ;
2011-04-01 15:57:04 +00:00
Button . VSplitLeft ( 135.0f , & Label , & Button ) ;
2010-05-29 07:25:38 +00:00
2022-05-13 19:26:35 +00:00
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: " , Localize ( ( const char * ) Key . m_Name ) ) ;
2017-07-22 20:43:20 +00:00
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2022-05-13 19:26:35 +00:00
int OldId = Key . m_KeyId , OldModifierCombination = Key . m_ModifierCombination , NewModifierCombination ;
int NewId = DoKeyReader ( ( void * ) & Key . m_Name , & Button , OldId , OldModifierCombination , & NewModifierCombination ) ;
if ( NewId ! = OldId | | NewModifierCombination ! = OldModifierCombination )
{
if ( OldId ! = 0 | | NewId = = 0 )
m_pClient - > m_Binds . Bind ( OldId , " " , false , OldModifierCombination ) ;
if ( NewId ! = 0 )
m_pClient - > m_Binds . Bind ( NewId , gs_aKeys [ i ] . m_pCommand , false , NewModifierCombination ) ;
2008-10-05 18:27:20 +00:00
}
2017-07-22 20:43:20 +00:00
2015-05-31 20:40:38 +00:00
View . HSplitTop ( 2.0f , 0 , & View ) ;
2008-10-05 18:27:20 +00:00
}
}
2008-08-27 15:48:50 +00:00
2022-06-07 21:11:13 +00:00
float CMenus : : RenderSettingsControlsJoystick ( CUIRect View )
{
2022-06-15 11:00:27 +00:00
bool JoystickEnabled = g_Config . m_InpControllerEnable ;
2022-06-07 21:11:13 +00:00
int NumJoysticks = Input ( ) - > NumJoysticks ( ) ;
int NumOptions = 1 ; // expandable header
if ( JoystickEnabled )
{
if ( NumJoysticks = = 0 )
NumOptions + + ; // message
else
{
if ( NumJoysticks > 1 )
NumOptions + + ; // joystick selection
NumOptions + = 3 ; // mode, ui sens, tolerance
2022-06-15 11:00:27 +00:00
if ( ! g_Config . m_InpControllerAbsolute )
2022-06-07 21:11:13 +00:00
NumOptions + + ; // ingame sens
NumOptions + = Input ( ) - > GetActiveJoystick ( ) - > GetNumAxes ( ) + 1 ; // axis selection + header
}
}
const float ButtonHeight = 20.0f ;
const float Spacing = 2.0f ;
const float BackgroundHeight = NumOptions * ( ButtonHeight + Spacing ) + ( NumOptions = = 1 ? 0 : Spacing ) ;
if ( View . h < BackgroundHeight )
return BackgroundHeight ; // TODO: make this less hacky by porting CScrollRegion from vanilla
View . HSplitTop ( BackgroundHeight , & View , 0 ) ;
CUIRect Button ;
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
if ( DoButton_CheckBox ( & g_Config . m_InpControllerEnable , Localize ( " Enable controller " ) , g_Config . m_InpControllerEnable , & Button ) )
2022-06-07 21:11:13 +00:00
{
2022-06-15 11:00:27 +00:00
g_Config . m_InpControllerEnable ^ = 1 ;
2022-06-07 21:11:13 +00:00
}
if ( JoystickEnabled )
{
if ( NumJoysticks > 0 )
{
// show joystick device selection if more than one available
if ( NumJoysticks > 1 )
{
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ButtonJoystickId ;
2022-06-07 21:11:13 +00:00
char aBuf [ 96 ] ;
2022-06-15 11:00:27 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " Controller %d: %s " ) , Input ( ) - > GetActiveJoystick ( ) - > GetIndex ( ) , Input ( ) - > GetActiveJoystick ( ) - > GetName ( ) ) ;
2022-06-07 21:11:13 +00:00
if ( DoButton_Menu ( & s_ButtonJoystickId , aBuf , 0 , & Button ) )
Input ( ) - > SelectNextJoystick ( ) ;
2022-06-15 11:00:27 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & s_ButtonJoystickId , & Button , Localize ( " Click to cycle through all available controllers. " ) ) ;
2022-06-07 21:11:13 +00:00
}
{
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
const char * apLabels [ ] = { Localize ( " Relative " , " Ingame controller mode " ) , Localize ( " Absolute " , " Ingame controller mode " ) } ;
UIEx ( ) - > DoScrollbarOptionLabeled ( & g_Config . m_InpControllerAbsolute , & g_Config . m_InpControllerAbsolute , & Button , Localize ( " Ingame controller mode " ) , apLabels , std : : size ( apLabels ) ) ;
2022-06-07 21:11:13 +00:00
}
2022-06-15 11:00:27 +00:00
if ( ! g_Config . m_InpControllerAbsolute )
2022-06-07 21:11:13 +00:00
{
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
UIEx ( ) - > DoScrollbarOption ( & g_Config . m_InpControllerSens , & g_Config . m_InpControllerSens , & Button , Localize ( " Ingame controller sens. " ) , 1 , 500 , & CUIEx : : ms_LogarithmicScrollbarScale , CUIEx : : SCROLLBAR_OPTION_NOCLAMPVALUE ) ;
2022-06-07 21:11:13 +00:00
}
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
UIEx ( ) - > DoScrollbarOption ( & g_Config . m_UiControllerSens , & g_Config . m_UiControllerSens , & Button , Localize ( " UI controller sens. " ) , 1 , 500 , & CUIEx : : ms_LogarithmicScrollbarScale , CUIEx : : SCROLLBAR_OPTION_NOCLAMPVALUE ) ;
2022-06-07 21:11:13 +00:00
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
UIEx ( ) - > DoScrollbarOption ( & g_Config . m_InpControllerTolerance , & g_Config . m_InpControllerTolerance , & Button , Localize ( " Controller jitter tolerance " ) , 0 , 50 ) ;
2022-06-07 21:11:13 +00:00
View . HSplitTop ( Spacing , 0 , & View ) ;
RenderTools ( ) - > DrawUIRect ( & View , ColorRGBA ( 0.0f , 0.0f , 0.0f , 0.125f ) , CUI : : CORNER_ALL , 5.0f ) ;
DoJoystickAxisPicker ( View ) ;
}
else
{
View . HSplitTop ( ( View . h - ButtonHeight ) / 2.0f , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Button , & View ) ;
2022-06-15 11:00:27 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " No controller found. Plug in a controller and restart the game. " ) , 13.0f , TEXTALIGN_CENTER ) ;
2022-06-07 21:11:13 +00:00
}
}
return BackgroundHeight ;
}
void CMenus : : DoJoystickAxisPicker ( CUIRect View )
{
float ButtonHeight = 20.0f ;
float Spacing = 2.0f ;
float DeviceLabelWidth = View . w * 0.30f ;
float StatusWidth = View . w * 0.30f ;
float BindWidth = View . w * 0.1f ;
float StatusMargin = View . w * 0.05f ;
CUIRect Row , Button ;
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Row , & View ) ;
Row . VSplitLeft ( StatusWidth , & Button , & Row ) ;
UI ( ) - > DoLabel ( & Button , Localize ( " Device " ) , 13.0f , TEXTALIGN_CENTER ) ;
Row . VSplitLeft ( StatusMargin , 0 , & Row ) ;
Row . VSplitLeft ( StatusWidth , & Button , & Row ) ;
UI ( ) - > DoLabel ( & Button , Localize ( " Status " ) , 13.0f , TEXTALIGN_CENTER ) ;
Row . VSplitLeft ( 2 * StatusMargin , 0 , & Row ) ;
Row . VSplitLeft ( 2 * BindWidth , & Button , & Row ) ;
UI ( ) - > DoLabel ( & Button , Localize ( " Aim bind " ) , 13.0f , TEXTALIGN_CENTER ) ;
IInput : : IJoystick * pJoystick = Input ( ) - > GetActiveJoystick ( ) ;
static int s_aActive [ NUM_JOYSTICK_AXES ] [ 2 ] ;
for ( int i = 0 ; i < minimum < int > ( pJoystick - > GetNumAxes ( ) , NUM_JOYSTICK_AXES ) ; i + + )
{
2022-06-15 11:00:27 +00:00
bool Active = g_Config . m_InpControllerX = = i | | g_Config . m_InpControllerY = = i ;
2022-06-07 21:11:13 +00:00
View . HSplitTop ( Spacing , 0 , & View ) ;
View . HSplitTop ( ButtonHeight , & Row , & View ) ;
RenderTools ( ) - > DrawUIRect ( & Row , ColorRGBA ( 0.0f , 0.0f , 0.0f , 0.125f ) , CUI : : CORNER_ALL , 5.0f ) ;
// Device label
Row . VSplitLeft ( DeviceLabelWidth , & Button , & Row ) ;
char aBuf [ 64 ] ;
2022-06-15 11:00:27 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " Controller Axis #%d " ) , i + 1 ) ;
2022-06-07 21:11:13 +00:00
if ( ! Active )
TextRender ( ) - > TextColor ( 0.7f , 0.7f , 0.7f , 1.0f ) ;
else
TextRender ( ) - > TextColor ( TextRender ( ) - > DefaultTextColor ( ) ) ;
UI ( ) - > DoLabel ( & Button , aBuf , 13.0f , TEXTALIGN_CENTER ) ;
// Device status
Row . VSplitLeft ( StatusMargin , 0 , & Row ) ;
Row . VSplitLeft ( StatusWidth , & Button , & Row ) ;
Button . HMargin ( ( ButtonHeight - 14.0f ) / 2.0f , & Button ) ;
2022-06-15 11:00:27 +00:00
DoJoystickBar ( & Button , ( pJoystick - > GetAxisValue ( i ) + 1.0f ) / 2.0f , g_Config . m_InpControllerTolerance / 50.0f , Active ) ;
2022-06-07 21:11:13 +00:00
// Bind to X,Y
Row . VSplitLeft ( 2 * StatusMargin , 0 , & Row ) ;
Row . VSplitLeft ( BindWidth , & Button , & Row ) ;
2022-06-15 11:00:27 +00:00
if ( DoButton_CheckBox ( & s_aActive [ i ] [ 0 ] , " X " , g_Config . m_InpControllerX = = i , & Button ) )
2022-06-07 21:11:13 +00:00
{
2022-06-15 11:00:27 +00:00
if ( g_Config . m_InpControllerY = = i )
g_Config . m_InpControllerY = g_Config . m_InpControllerX ;
g_Config . m_InpControllerX = i ;
2022-06-07 21:11:13 +00:00
}
Row . VSplitLeft ( BindWidth , & Button , & Row ) ;
2022-06-15 11:00:27 +00:00
if ( DoButton_CheckBox ( & s_aActive [ i ] [ 1 ] , " Y " , g_Config . m_InpControllerY = = i , & Button ) )
2022-06-07 21:11:13 +00:00
{
2022-06-15 11:00:27 +00:00
if ( g_Config . m_InpControllerX = = i )
g_Config . m_InpControllerX = g_Config . m_InpControllerY ;
g_Config . m_InpControllerY = i ;
2022-06-07 21:11:13 +00:00
}
Row . VSplitLeft ( StatusMargin , 0 , & Row ) ;
}
TextRender ( ) - > TextColor ( TextRender ( ) - > DefaultTextColor ( ) ) ;
}
void CMenus : : DoJoystickBar ( const CUIRect * pRect , float Current , float Tolerance , bool Active )
{
CUIRect Handle ;
pRect - > VSplitLeft ( 7.0f , & Handle , 0 ) ; // Slider size
Handle . x + = ( pRect - > w - Handle . w ) * Current ;
CUIRect Rail ;
pRect - > HMargin ( 4.0f , & Rail ) ;
RenderTools ( ) - > DrawUIRect ( & Rail , ColorRGBA ( 1.0f , 1.0f , 1.0f , Active ? 0.25f : 0.125f ) , CUI : : CORNER_ALL , Rail . h / 2.0f ) ;
CUIRect ToleranceArea = Rail ;
ToleranceArea . w * = Tolerance ;
ToleranceArea . x + = ( Rail . w - ToleranceArea . w ) / 2.0f ;
ColorRGBA ToleranceColor = Active ? ColorRGBA ( 0.8f , 0.35f , 0.35f , 1.0f ) : ColorRGBA ( 0.7f , 0.5f , 0.5f , 1.0f ) ;
RenderTools ( ) - > DrawUIRect ( & ToleranceArea , ToleranceColor , CUI : : CORNER_ALL , ToleranceArea . h / 2.0f ) ;
CUIRect Slider = Handle ;
Slider . HMargin ( 4.0f , & Slider ) ;
ColorRGBA SliderColor = Active ? ColorRGBA ( 0.95f , 0.95f , 0.95f , 1.0f ) : ColorRGBA ( 0.8f , 0.8f , 0.8f , 1.0f ) ;
RenderTools ( ) - > DrawUIRect ( & Slider , SliderColor , CUI : : CORNER_ALL , Slider . h / 2.0f ) ;
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderSettingsControls ( CUIRect MainView )
2008-10-05 18:27:20 +00:00
{
2008-08-27 15:48:50 +00:00
// this is kinda slow, but whatever
2020-10-26 14:14:07 +00:00
for ( auto & Key : gs_aKeys )
2022-02-06 22:14:26 +00:00
Key . m_KeyId = Key . m_ModifierCombination = 0 ;
2010-05-29 07:25:38 +00:00
2022-02-06 22:42:44 +00:00
for ( int Mod = 0 ; Mod < CBinds : : MODIFIER_COMBINATION_COUNT ; Mod + + )
2008-08-27 15:48:50 +00:00
{
2019-04-28 13:32:14 +00:00
for ( int KeyId = 0 ; KeyId < KEY_LAST ; KeyId + + )
{
2021-07-12 09:43:56 +00:00
const char * pBind = m_pClient - > m_Binds . Get ( KeyId , Mod ) ;
2019-04-28 13:32:14 +00:00
if ( ! pBind [ 0 ] )
continue ;
2010-05-29 07:25:38 +00:00
2020-10-26 14:14:07 +00:00
for ( auto & Key : gs_aKeys )
if ( str_comp ( pBind , Key . m_pCommand ) = = 0 )
2019-04-28 13:32:14 +00:00
{
2020-10-26 14:14:07 +00:00
Key . m_KeyId = KeyId ;
2022-02-06 22:14:26 +00:00
Key . m_ModifierCombination = Mod ;
2019-04-28 13:32:14 +00:00
break ;
}
}
2008-08-27 15:48:50 +00:00
}
2008-10-05 18:27:20 +00:00
2017-07-22 11:41:18 +00:00
// controls in a scrollable listbox
static int s_ControlsList = 0 ;
static int s_SelectedControl = - 1 ;
static float s_ScrollValue = 0 ;
2021-05-17 07:11:36 +00:00
static int s_OldSelected = 0 ;
2022-06-07 21:11:13 +00:00
static float s_JoystickSettingsHeight = 0.0f ; // we calculate this later and don't render until enough space is available
2021-03-23 22:15:39 +00:00
// Hacky values: Size of 10.0f per item for smoother scrolling, 72 elements
// fits the current size of controls settings
2022-06-07 21:11:13 +00:00
const float PseudoItemSize = 10.0f ;
UiDoListboxStart ( & s_ControlsList , & MainView , PseudoItemSize , Localize ( " Controls " ) , " " , 72 + ( int ) ceilf ( s_JoystickSettingsHeight / PseudoItemSize + 0.5f ) , 1 , s_SelectedControl , s_ScrollValue ) ;
2017-07-22 11:41:18 +00:00
2022-06-07 21:11:13 +00:00
CUIRect MouseSettings , MovementSettings , WeaponSettings , VotingSettings , ChatSettings , DummySettings , MiscSettings , JoystickSettings , ResetButton ;
2021-05-17 07:11:36 +00:00
CListboxItem Item = UiDoListboxNextItem ( & s_OldSelected , false , false , true ) ;
2017-07-22 11:41:18 +00:00
Item . m_Rect . HSplitTop ( 10.0f , 0 , & Item . m_Rect ) ;
2022-06-07 21:11:13 +00:00
Item . m_Rect . VSplitMid ( & MouseSettings , & VotingSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
const float FontSize = 14.0f ;
const float Margin = 10.0f ;
const float HeaderHeight = FontSize + 5.0f + Margin ;
// mouse settings
2008-10-05 15:59:36 +00:00
{
2022-06-07 21:11:13 +00:00
MouseSettings . VMargin ( 5.0f , & MouseSettings ) ;
MouseSettings . HSplitTop ( 80.0f , & MouseSettings , & JoystickSettings ) ;
RenderTools ( ) - > DrawUIRect ( & MouseSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
MouseSettings . VMargin ( 10.0f , & MouseSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , MouseSettings . x , MouseSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Mouse " ) , - 1.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
MouseSettings . HSplitTop ( HeaderHeight , 0 , & MouseSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-11 10:49:26 +00:00
CUIRect Button ;
MouseSettings . HSplitTop ( 20.0f , & Button , & MouseSettings ) ;
UIEx ( ) - > DoScrollbarOption ( & g_Config . m_InpMousesens , & g_Config . m_InpMousesens , & Button , Localize ( " Ingame mouse sens. " ) , 1 , 500 , & CUIEx : : ms_LogarithmicScrollbarScale , CUIEx : : SCROLLBAR_OPTION_NOCLAMPVALUE ) ;
2017-07-22 20:31:14 +00:00
2022-06-07 21:11:13 +00:00
MouseSettings . HSplitTop ( 2.0f , 0 , & MouseSettings ) ;
2022-06-11 10:49:26 +00:00
MouseSettings . HSplitTop ( 20.0f , & Button , & MouseSettings ) ;
UIEx ( ) - > DoScrollbarOption ( & g_Config . m_UiMousesens , & g_Config . m_UiMousesens , & Button , Localize ( " UI mouse sens. " ) , 1 , 500 , & CUIEx : : ms_LogarithmicScrollbarScale , CUIEx : : SCROLLBAR_OPTION_NOCLAMPVALUE ) ;
2022-06-07 21:11:13 +00:00
}
// joystick settings
{
JoystickSettings . HSplitTop ( Margin , 0 , & JoystickSettings ) ;
JoystickSettings . HSplitTop ( s_JoystickSettingsHeight , & JoystickSettings , & MovementSettings ) ;
RenderTools ( ) - > DrawUIRect ( & JoystickSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
JoystickSettings . VMargin ( Margin , & JoystickSettings ) ;
2022-06-15 11:00:27 +00:00
TextRender ( ) - > Text ( 0 , JoystickSettings . x , JoystickSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Controller " ) , - 1.0f ) ;
2022-06-07 21:11:13 +00:00
JoystickSettings . HSplitTop ( HeaderHeight , 0 , & JoystickSettings ) ;
s_JoystickSettingsHeight = RenderSettingsControlsJoystick ( JoystickSettings ) + HeaderHeight + Margin ; // + Margin for another bottom margin
}
2021-10-23 11:48:21 +00:00
2022-06-07 21:11:13 +00:00
// movement settings
{
MovementSettings . HSplitTop ( Margin , 0 , & MovementSettings ) ;
MovementSettings . HSplitTop ( 365.0f , & MovementSettings , & WeaponSettings ) ;
RenderTools ( ) - > DrawUIRect ( & MovementSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
MovementSettings . VMargin ( Margin , & MovementSettings ) ;
TextRender ( ) - > Text ( 0 , MovementSettings . x , MovementSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Movement " ) , - 1.0f ) ;
MovementSettings . HSplitTop ( HeaderHeight , 0 , & MovementSettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 0 , 15 , MovementSettings ) ;
2008-10-05 15:59:36 +00:00
}
2010-05-29 07:25:38 +00:00
// weapon settings
2008-10-05 18:27:20 +00:00
{
2022-06-07 21:11:13 +00:00
WeaponSettings . HSplitTop ( Margin , 0 , & WeaponSettings ) ;
2021-06-02 10:28:14 +00:00
WeaponSettings . HSplitTop ( 190.0f , & WeaponSettings , & ResetButton ) ;
2020-09-26 19:41:58 +00:00
RenderTools ( ) - > DrawUIRect ( & WeaponSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2022-06-07 21:11:13 +00:00
WeaponSettings . VMargin ( Margin , & WeaponSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , WeaponSettings . x , WeaponSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Weapon " ) , - 1.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
WeaponSettings . HSplitTop ( HeaderHeight , 0 , & WeaponSettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 15 , 22 , WeaponSettings ) ;
2008-10-05 18:27:20 +00:00
}
2011-08-11 08:59:14 +00:00
2011-04-06 19:15:58 +00:00
// defaults
{
2022-06-07 21:11:13 +00:00
ResetButton . HSplitTop ( Margin , 0 , & ResetButton ) ;
2017-07-22 11:41:18 +00:00
ResetButton . HSplitTop ( 40.0f , & ResetButton , 0 ) ;
2020-09-26 19:41:58 +00:00
RenderTools ( ) - > DrawUIRect ( & ResetButton , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2011-04-06 19:15:58 +00:00
ResetButton . HMargin ( 10.0f , & ResetButton ) ;
ResetButton . VMargin ( 30.0f , & ResetButton ) ;
2011-12-04 17:06:48 +00:00
ResetButton . HSplitTop ( 20.0f , & ResetButton , 0 ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_DefaultButton ;
if ( DoButton_Menu ( & s_DefaultButton , Localize ( " Reset to defaults " ) , 0 , & ResetButton ) )
2022-06-07 21:11:13 +00:00
{
2021-07-12 09:43:56 +00:00
m_pClient - > m_Binds . SetDefaults ( ) ;
2022-06-07 21:11:13 +00:00
2022-06-14 21:41:21 +00:00
g_Config . m_InpMousesens = 200 ;
g_Config . m_UiMousesens = 200 ;
2022-06-15 11:00:27 +00:00
g_Config . m_InpControllerEnable = 0 ;
g_Config . m_InpControllerGUID [ 0 ] = ' \0 ' ;
g_Config . m_InpControllerAbsolute = 0 ;
g_Config . m_InpControllerSens = 100 ;
g_Config . m_InpControllerX = 0 ;
g_Config . m_InpControllerY = 1 ;
g_Config . m_InpControllerTolerance = 5 ;
g_Config . m_UiControllerSens = 100 ;
2022-06-07 21:11:13 +00:00
}
2011-04-06 19:15:58 +00:00
}
2011-08-11 08:59:14 +00:00
2010-05-29 07:25:38 +00:00
// voting settings
2008-10-05 18:27:20 +00:00
{
2011-12-04 17:06:48 +00:00
VotingSettings . VMargin ( 5.0f , & VotingSettings ) ;
2017-07-22 11:41:18 +00:00
VotingSettings . HSplitTop ( 80.0f , & VotingSettings , & ChatSettings ) ;
2020-09-26 19:41:58 +00:00
RenderTools ( ) - > DrawUIRect ( & VotingSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2022-06-07 21:11:13 +00:00
VotingSettings . VMargin ( Margin , & VotingSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , VotingSettings . x , VotingSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Voting " ) , - 1.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
VotingSettings . HSplitTop ( HeaderHeight , 0 , & VotingSettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 22 , 24 , VotingSettings ) ;
2008-10-05 18:27:20 +00:00
}
2010-05-29 07:25:38 +00:00
// chat settings
2008-10-05 18:27:20 +00:00
{
2022-06-07 21:11:13 +00:00
ChatSettings . HSplitTop ( Margin , 0 , & ChatSettings ) ;
2020-12-18 18:13:07 +00:00
ChatSettings . HSplitTop ( 145.0f , & ChatSettings , & DummySettings ) ;
2020-09-26 19:41:58 +00:00
RenderTools ( ) - > DrawUIRect ( & ChatSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2022-06-07 21:11:13 +00:00
ChatSettings . VMargin ( Margin , & ChatSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , ChatSettings . x , ChatSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Chat " ) , - 1.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
ChatSettings . HSplitTop ( HeaderHeight , 0 , & ChatSettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 24 , 29 , ChatSettings ) ;
2020-12-18 18:13:07 +00:00
}
// dummy settings
{
2022-06-07 21:11:13 +00:00
DummySettings . HSplitTop ( Margin , 0 , & DummySettings ) ;
2021-03-03 09:11:48 +00:00
DummySettings . HSplitTop ( 100.0f , & DummySettings , & MiscSettings ) ;
2020-12-18 18:13:07 +00:00
RenderTools ( ) - > DrawUIRect ( & DummySettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2022-06-07 21:11:13 +00:00
DummySettings . VMargin ( Margin , & DummySettings ) ;
2020-12-18 18:13:07 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , DummySettings . x , DummySettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Dummy " ) , - 1.0f ) ;
2020-12-18 18:13:07 +00:00
2022-06-07 21:11:13 +00:00
DummySettings . HSplitTop ( HeaderHeight , 0 , & DummySettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 29 , 32 , DummySettings ) ;
2008-10-05 18:27:20 +00:00
}
2010-05-29 07:25:38 +00:00
// misc settings
2008-10-05 18:27:20 +00:00
{
2022-06-07 21:11:13 +00:00
MiscSettings . HSplitTop ( Margin , 0 , & MiscSettings ) ;
2017-07-22 11:41:18 +00:00
MiscSettings . HSplitTop ( 300.0f , & MiscSettings , 0 ) ;
2020-09-26 19:41:58 +00:00
RenderTools ( ) - > DrawUIRect ( & MiscSettings , ColorRGBA ( 1 , 1 , 1 , 0.25f ) , CUI : : CORNER_ALL , 10.0f ) ;
2022-06-07 21:11:13 +00:00
MiscSettings . VMargin ( Margin , & MiscSettings ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
TextRender ( ) - > Text ( 0 , MiscSettings . x , MiscSettings . y + ( HeaderHeight - FontSize ) / 2.f , FontSize , Localize ( " Miscellaneous " ) , - 1.0f ) ;
2010-05-29 07:25:38 +00:00
2022-06-07 21:11:13 +00:00
MiscSettings . HSplitTop ( HeaderHeight , 0 , & MiscSettings ) ;
2022-06-07 19:37:43 +00:00
DoSettingsControlsButtons ( 32 , 44 , MiscSettings ) ;
2008-10-05 18:27:20 +00:00
}
2010-05-29 07:25:38 +00:00
2017-07-22 11:41:18 +00:00
UiDoListboxEnd ( & s_ScrollValue , 0 ) ;
2008-08-27 15:48:50 +00:00
}
2022-07-16 13:32:06 +00:00
int CMenus : : RenderDropDown ( int & CurDropDownState , CUIRect * pRect , int CurSelection , const void * * pIDs , const char * * pStr , int PickNum , CButtonContainer * pButtonContainer , float & ScrollVal )
2021-01-31 20:54:04 +00:00
{
if ( CurDropDownState ! = 0 )
{
CUIRect ListRect ;
pRect - > HSplitTop ( 24.0f * PickNum , & ListRect , pRect ) ;
char aBuf [ 1024 ] ;
2022-07-16 13:32:06 +00:00
UiDoListboxStart ( & pButtonContainer , & ListRect , 24.0f , " " , aBuf , PickNum , 1 , CurSelection , ScrollVal ) ;
2021-01-31 20:54:04 +00:00
for ( int i = 0 ; i < PickNum ; + + i )
{
CListboxItem Item = UiDoListboxNextItem ( pIDs [ i ] , CurSelection = = i ) ;
if ( Item . m_Visible )
{
str_format ( aBuf , sizeof ( aBuf ) , " %s " , pStr [ i ] ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Item . m_Rect , aBuf , 16.0f , TEXTALIGN_CENTER ) ;
2021-01-31 20:54:04 +00:00
}
}
bool ClickedItem = false ;
int NewIndex = UiDoListboxEnd ( & ScrollVal , NULL , & ClickedItem ) ;
if ( ClickedItem )
{
CurDropDownState = 0 ;
return NewIndex ;
}
else
return CurSelection ;
}
else
{
CUIRect Button ;
pRect - > HSplitTop ( 24.0f , & Button , pRect ) ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( pButtonContainer , CurSelection > - 1 ? pStr [ CurSelection ] : " " , 0 , & Button , CUI : : CORNER_ALL , NULL , NULL , NULL , NULL , 4.0f ) )
2021-01-31 20:54:04 +00:00
CurDropDownState = 1 ;
2022-03-24 12:04:17 +00:00
CUIRect DropDownIcon = Button ;
DropDownIcon . HMargin ( 2.0f , & DropDownIcon ) ;
DropDownIcon . VSplitRight ( 5.0f , & DropDownIcon , nullptr ) ;
TextRender ( ) - > SetCurFont ( TextRender ( ) - > GetFont ( TEXT_FONT_ICON_FONT ) ) ;
TextRender ( ) - > SetRenderFlags ( ETextRenderFlags : : TEXT_RENDER_FLAG_ONLY_ADVANCE_WIDTH | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_X_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_Y_BEARING | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_PIXEL_ALIGMENT | ETextRenderFlags : : TEXT_RENDER_FLAG_NO_OVERSIZE ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & DropDownIcon , " \xEF \x84 \xBA " , DropDownIcon . h * CUI : : ms_FontmodHeight , TEXTALIGN_RIGHT ) ;
2022-03-24 12:04:17 +00:00
TextRender ( ) - > SetRenderFlags ( 0 ) ;
TextRender ( ) - > SetCurFont ( NULL ) ;
2021-01-31 20:54:04 +00:00
return CurSelection ;
}
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderSettingsGraphics ( CUIRect MainView )
2008-08-27 15:48:50 +00:00
{
2016-05-10 15:43:27 +00:00
CUIRect Button , Label ;
2010-05-29 07:25:38 +00:00
char aBuf [ 128 ] ;
2010-10-16 09:24:42 +00:00
bool CheckSettings = false ;
2010-05-29 07:25:38 +00:00
2008-08-27 15:48:50 +00:00
static const int MAX_RESOLUTIONS = 256 ;
2010-05-29 07:25:38 +00:00
static CVideoMode s_aModes [ MAX_RESOLUTIONS ] ;
2015-08-24 20:46:28 +00:00
static int s_NumNodes = Graphics ( ) - > GetVideoModes ( s_aModes , MAX_RESOLUTIONS , g_Config . m_GfxScreen ) ;
2010-12-08 00:55:13 +00:00
static int s_GfxFsaaSamples = g_Config . m_GfxFsaaSamples ;
2022-03-20 17:04:00 +00:00
static bool s_GfxBackendChanged = false ;
2022-04-18 08:16:24 +00:00
static bool s_GfxGPUChanged = false ;
2020-04-07 20:37:46 +00:00
static int s_GfxHighdpi = g_Config . m_GfxHighdpi ;
2022-04-18 08:16:24 +00:00
2021-08-21 19:41:51 +00:00
static int s_InitDisplayAllVideoModes = g_Config . m_GfxDisplayAllVideoModes ;
2010-05-29 07:25:38 +00:00
2021-08-21 19:41:51 +00:00
static bool s_WasInit = false ;
static bool s_ModesReload = false ;
if ( ! s_WasInit )
{
s_WasInit = true ;
Graphics ( ) - > AddWindowResizeListener ( [ & ] ( void * pUser ) {
s_ModesReload = true ;
} ,
this ) ;
}
if ( s_ModesReload | | g_Config . m_GfxDisplayAllVideoModes ! = s_InitDisplayAllVideoModes )
{
s_NumNodes = Graphics ( ) - > GetVideoModes ( s_aModes , MAX_RESOLUTIONS , g_Config . m_GfxScreen ) ;
s_ModesReload = false ;
s_InitDisplayAllVideoModes = g_Config . m_GfxDisplayAllVideoModes ;
}
CUIRect ModeList , ModeLabel ;
2021-01-31 19:27:07 +00:00
MainView . VSplitLeft ( 350.0f , & MainView , & ModeList ) ;
2021-08-21 19:41:51 +00:00
ModeList . HSplitTop ( 24.0f , & ModeLabel , & ModeList ) ;
2021-01-31 19:27:07 +00:00
MainView . VSplitLeft ( 340.0f , & MainView , 0 ) ;
2010-05-29 07:25:38 +00:00
// display mode list
static float s_ScrollValue = 0 ;
2021-08-21 19:41:51 +00:00
static const float sc_RowHeightResList = 22.0f ;
static const float sc_FontSizeResListHeader = 12.0f ;
static const float sc_FontSizeResList = 10.0f ;
2010-05-29 07:25:38 +00:00
int OldSelected = - 1 ;
2022-03-20 11:57:50 +00:00
{
2022-04-25 16:23:03 +00:00
int G = std : : gcd ( g_Config . m_GfxScreenWidth , g_Config . m_GfxScreenHeight ) ;
2022-03-20 11:57:50 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %dx%d @%dhz %d bit (%d:%d) " , Localize ( " Current " ) , int ( g_Config . m_GfxScreenWidth * Graphics ( ) - > ScreenHiDPIScale ( ) ) , int ( g_Config . m_GfxScreenHeight * Graphics ( ) - > ScreenHiDPIScale ( ) ) , g_Config . m_GfxScreenRefreshRate , g_Config . m_GfxColorDepth , g_Config . m_GfxScreenWidth / G , g_Config . m_GfxScreenHeight / G ) ;
}
2021-08-21 19:41:51 +00:00
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & ModeLabel , aBuf , sc_FontSizeResListHeader , TEXTALIGN_CENTER ) ;
2021-08-21 19:41:51 +00:00
UiDoListboxStart ( & s_NumNodes , & ModeList , sc_RowHeightResList , Localize ( " Display Modes " ) , aBuf , s_NumNodes - 1 , 1 , OldSelected , s_ScrollValue ) ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < s_NumNodes ; + + i )
2008-08-27 15:48:50 +00:00
{
2020-09-26 19:41:58 +00:00
const int Depth = s_aModes [ i ] . m_Red + s_aModes [ i ] . m_Green + s_aModes [ i ] . m_Blue > 16 ? 24 : 16 ;
2010-05-29 07:25:38 +00:00
if ( g_Config . m_GfxColorDepth = = Depth & &
2021-05-06 10:59:30 +00:00
g_Config . m_GfxScreenWidth = = s_aModes [ i ] . m_WindowWidth & &
2021-08-21 19:41:51 +00:00
g_Config . m_GfxScreenHeight = = s_aModes [ i ] . m_WindowHeight & &
g_Config . m_GfxScreenRefreshRate = = s_aModes [ i ] . m_RefreshRate )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
OldSelected = i ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
CListboxItem Item = UiDoListboxNextItem ( & s_aModes [ i ] , OldSelected = = i ) ;
if ( Item . m_Visible )
2008-08-27 15:48:50 +00:00
{
2022-04-25 16:23:03 +00:00
int G = std : : gcd ( s_aModes [ i ] . m_CanvasWidth , s_aModes [ i ] . m_CanvasHeight ) ;
2021-08-21 19:41:51 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %dx%d @%dhz %d bit (%d:%d) " , s_aModes [ i ] . m_CanvasWidth , s_aModes [ i ] . m_CanvasHeight , s_aModes [ i ] . m_RefreshRate , Depth , s_aModes [ i ] . m_CanvasWidth / G , s_aModes [ i ] . m_CanvasHeight / G ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Item . m_Rect , aBuf , sc_FontSizeResList , TEXTALIGN_LEFT ) ;
2008-08-27 15:48:50 +00:00
}
}
2010-05-29 07:25:38 +00:00
const int NewSelected = UiDoListboxEnd ( & s_ScrollValue , 0 ) ;
if ( OldSelected ! = NewSelected )
{
2020-09-26 19:41:58 +00:00
const int Depth = s_aModes [ NewSelected ] . m_Red + s_aModes [ NewSelected ] . m_Green + s_aModes [ NewSelected ] . m_Blue > 16 ? 24 : 16 ;
2010-05-29 07:25:38 +00:00
g_Config . m_GfxColorDepth = Depth ;
2021-05-06 10:59:30 +00:00
g_Config . m_GfxScreenWidth = s_aModes [ NewSelected ] . m_WindowWidth ;
g_Config . m_GfxScreenHeight = s_aModes [ NewSelected ] . m_WindowHeight ;
2021-08-21 19:41:51 +00:00
g_Config . m_GfxScreenRefreshRate = s_aModes [ NewSelected ] . m_RefreshRate ;
2022-01-15 15:20:01 +00:00
Graphics ( ) - > Resize ( g_Config . m_GfxScreenWidth , g_Config . m_GfxScreenHeight , g_Config . m_GfxScreenRefreshRate ) ;
2010-05-29 07:25:38 +00:00
}
2008-08-27 15:48:50 +00:00
// switches
2021-01-31 20:54:04 +00:00
static float s_ScrollValueDrop = 0 ;
2022-06-30 22:36:32 +00:00
const char * apWindowModes [ ] = { Localize ( " Windowed " ) , Localize ( " Windowed borderless " ) , Localize ( " Windowed fullscreen " ) , Localize ( " Desktop fullscreen " ) , Localize ( " Fullscreen " ) } ;
static const int s_NumWindowMode = std : : size ( apWindowModes ) ;
2021-01-31 20:54:04 +00:00
static int s_aWindowModeIDs [ s_NumWindowMode ] ;
2022-06-30 22:36:32 +00:00
const void * apWindowModeIDs [ s_NumWindowMode ] ;
2021-01-31 20:54:04 +00:00
for ( int i = 0 ; i < s_NumWindowMode ; + + i )
2022-06-30 22:36:32 +00:00
apWindowModeIDs [ i ] = & s_aWindowModeIDs [ i ] ;
2021-01-31 20:54:04 +00:00
static int s_WindowModeDropDownState = 0 ;
2022-03-20 17:04:00 +00:00
static int s_OldSelectedBackend = - 1 ;
2022-04-18 08:16:24 +00:00
static int s_OldSelectedGPU = - 1 ;
2022-03-20 17:04:00 +00:00
2022-02-04 10:13:38 +00:00
OldSelected = ( g_Config . m_GfxFullscreen ? ( g_Config . m_GfxFullscreen = = 1 ? 4 : ( g_Config . m_GfxFullscreen = = 2 ? 3 : 2 ) ) : ( g_Config . m_GfxBorderless ? 1 : 0 ) ) ;
2021-01-31 20:54:04 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer s_WindowButton ;
const int NewWindowMode = RenderDropDown ( s_WindowModeDropDownState , & MainView , OldSelected , apWindowModeIDs , apWindowModes , s_NumWindowMode , & s_WindowButton , s_ScrollValueDrop ) ;
2021-01-31 20:54:04 +00:00
if ( OldSelected ! = NewWindowMode )
2008-08-27 15:48:50 +00:00
{
2021-01-31 20:54:04 +00:00
if ( NewWindowMode = = 0 )
2022-02-04 10:13:38 +00:00
Client ( ) - > SetWindowParams ( 0 , false , true ) ;
2021-01-31 20:54:04 +00:00
else if ( NewWindowMode = = 1 )
2022-02-04 10:13:38 +00:00
Client ( ) - > SetWindowParams ( 0 , true , true ) ;
2021-01-31 20:54:04 +00:00
else if ( NewWindowMode = = 2 )
2022-02-04 10:13:38 +00:00
Client ( ) - > SetWindowParams ( 3 , false , false ) ;
2021-04-02 20:45:49 +00:00
else if ( NewWindowMode = = 3 )
2022-02-04 10:13:38 +00:00
Client ( ) - > SetWindowParams ( 2 , false , true ) ;
else if ( NewWindowMode = = 4 )
Client ( ) - > SetWindowParams ( 1 , false , true ) ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2017-08-08 17:53:16 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s (%s) " , Localize ( " V-Sync " ) , Localize ( " may cause delay " ) ) ;
if ( DoButton_CheckBox ( & g_Config . m_GfxVsync , aBuf , g_Config . m_GfxVsync , & Button ) )
2009-01-21 20:55:07 +00:00
{
2016-04-29 22:34:12 +00:00
Client ( ) - > ToggleWindowVSync ( ) ;
}
if ( Graphics ( ) - > GetNumScreens ( ) > 1 )
{
int NumScreens = Graphics ( ) - > GetNumScreens ( ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
int Screen_MouseButton = DoButton_CheckBox_Number ( & g_Config . m_GfxScreen , Localize ( " Screen " ) , g_Config . m_GfxScreen , & Button ) ;
2022-03-20 17:03:25 +00:00
if ( Screen_MouseButton = = 1 ) // inc
2016-04-29 22:34:12 +00:00
{
2020-09-26 19:41:58 +00:00
Client ( ) - > SwitchWindowScreen ( ( g_Config . m_GfxScreen + 1 ) % NumScreens ) ;
2016-04-29 22:34:12 +00:00
s_NumNodes = Graphics ( ) - > GetVideoModes ( s_aModes , MAX_RESOLUTIONS , g_Config . m_GfxScreen ) ;
}
2022-03-20 17:03:25 +00:00
else if ( Screen_MouseButton = = 2 ) // dec
2016-04-29 22:34:12 +00:00
{
2020-09-26 19:41:58 +00:00
Client ( ) - > SwitchWindowScreen ( ( g_Config . m_GfxScreen - 1 + NumScreens ) % NumScreens ) ;
2016-04-29 22:34:12 +00:00
s_NumNodes = Graphics ( ) - > GetVideoModes ( s_aModes , MAX_RESOLUTIONS , g_Config . m_GfxScreen ) ;
}
2009-01-21 20:55:07 +00:00
}
2008-08-27 15:48:50 +00:00
2022-04-26 18:09:47 +00:00
bool MultiSamplingChanged = false ;
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2017-08-08 17:53:16 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s (%s) " , Localize ( " FSAA samples " ) , Localize ( " may cause delay " ) ) ;
int GfxFsaaSamples_MouseButton = DoButton_CheckBox_Number ( & g_Config . m_GfxFsaaSamples , aBuf , g_Config . m_GfxFsaaSamples , & Button ) ;
2022-04-26 18:09:47 +00:00
int CurFSAA = g_Config . m_GfxFsaaSamples = = 0 ? 1 : g_Config . m_GfxFsaaSamples ;
2022-03-20 17:03:25 +00:00
if ( GfxFsaaSamples_MouseButton = = 1 ) // inc
2008-08-27 15:48:50 +00:00
{
2022-04-26 18:09:47 +00:00
g_Config . m_GfxFsaaSamples = std : : pow ( 2 , ( int ) std : : log2 ( CurFSAA ) + 1 ) ;
if ( g_Config . m_GfxFsaaSamples > 64 )
g_Config . m_GfxFsaaSamples = 0 ;
MultiSamplingChanged = true ;
2008-08-27 15:48:50 +00:00
}
2022-03-20 17:03:25 +00:00
else if ( GfxFsaaSamples_MouseButton = = 2 ) // dec
2016-04-29 22:34:12 +00:00
{
2022-04-26 18:09:47 +00:00
if ( CurFSAA = = 1 )
g_Config . m_GfxFsaaSamples = 64 ;
else if ( CurFSAA = = 2 )
g_Config . m_GfxFsaaSamples = 0 ;
else
g_Config . m_GfxFsaaSamples = std : : pow ( 2 , ( int ) std : : log2 ( CurFSAA ) - 1 ) ;
MultiSamplingChanged = true ;
}
uint32_t MultiSamplingCountBackend = 0 ;
if ( MultiSamplingChanged )
{
if ( Graphics ( ) - > SetMultiSampling ( g_Config . m_GfxFsaaSamples , MultiSamplingCountBackend ) )
{
// try again with 0 if mouse click was increasing multi sampling
// else just accept the current value as is
if ( ( uint32_t ) g_Config . m_GfxFsaaSamples > MultiSamplingCountBackend & & GfxFsaaSamples_MouseButton = = 1 )
Graphics ( ) - > SetMultiSampling ( 0 , MultiSamplingCountBackend ) ;
g_Config . m_GfxFsaaSamples = ( int ) MultiSamplingCountBackend ;
}
else
{
CheckSettings = true ;
}
2016-04-29 22:34:12 +00:00
}
2015-05-20 20:23:58 +00:00
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_GfxHighDetail , Localize ( " High Detail " ) , g_Config . m_GfxHighDetail , & Button ) )
g_Config . m_GfxHighDetail ^ = 1 ;
2022-04-28 14:46:18 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & g_Config . m_GfxHighDetail , & Button , Localize ( " Allows maps to render with more detail " ) ) ;
2008-08-27 15:48:50 +00:00
2020-04-07 20:37:46 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_GfxHighdpi , Localize ( " Use high DPI " ) , g_Config . m_GfxHighdpi , & Button ) )
{
CheckSettings = true ;
g_Config . m_GfxHighdpi ^ = 1 ;
}
2016-05-10 15:43:27 +00:00
MainView . HSplitTop ( 20.0f , & Label , & MainView ) ;
2021-01-31 19:27:07 +00:00
Label . VSplitLeft ( 160.0f , & Label , & Button ) ;
2017-09-07 18:51:46 +00:00
if ( g_Config . m_GfxRefreshRate )
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i Hz " , Localize ( " Refresh Rate " ) , g_Config . m_GfxRefreshRate ) ;
else
2017-10-20 20:45:12 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %s " , Localize ( " Refresh Rate " ) , " ∞ " ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
int NewRefreshRate = static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_GfxRefreshRate , & Button , ( minimum ( g_Config . m_GfxRefreshRate , 1000 ) ) / 1000.0f ) * 1000.0f + 0.1f ) ;
2018-03-02 02:29:02 +00:00
if ( g_Config . m_GfxRefreshRate < = 1000 | | NewRefreshRate < 1000 )
g_Config . m_GfxRefreshRate = NewRefreshRate ;
2016-05-10 15:43:27 +00:00
2010-05-29 07:25:38 +00:00
CUIRect Text ;
MainView . HSplitTop ( 20.0f , 0 , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Text , & MainView ) ;
2009-10-27 14:38:53 +00:00
//text.VSplitLeft(15.0f, 0, &text);
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Text , Localize ( " UI Color " ) , 14.0f , TEXTALIGN_LEFT ) ;
2022-03-20 17:03:25 +00:00
CUIRect HSLBar = MainView ;
RenderHSLScrollbars ( & HSLBar , & g_Config . m_UiColor , true ) ;
MainView . y = HSLBar . y ;
MainView . h = MainView . h - MainView . y ;
2022-03-20 17:04:00 +00:00
// Backend list
struct SMenuBackendInfo
{
int m_Major = 0 ;
int m_Minor = 0 ;
int m_Patch = 0 ;
const char * m_pBackendName = " " ;
bool m_Found = false ;
} ;
std : : array < std : : array < SMenuBackendInfo , EGraphicsDriverAgeType : : GRAPHICS_DRIVER_AGE_TYPE_COUNT > , EBackendType : : BACKEND_TYPE_COUNT > aaSupportedBackends { } ;
uint32_t FoundBackendCount = 0 ;
for ( uint32_t i = 0 ; i < BACKEND_TYPE_COUNT ; + + i )
{
if ( EBackendType ( i ) = = BACKEND_TYPE_AUTO )
continue ;
for ( uint32_t n = 0 ; n < GRAPHICS_DRIVER_AGE_TYPE_COUNT ; + + n )
{
auto & Info = aaSupportedBackends [ i ] [ n ] ;
if ( Graphics ( ) - > GetDriverVersion ( EGraphicsDriverAgeType ( n ) , Info . m_Major , Info . m_Minor , Info . m_Patch , Info . m_pBackendName , EBackendType ( i ) ) )
{
// don't count blocked opengl drivers
if ( EBackendType ( i ) ! = BACKEND_TYPE_OPENGL | | EGraphicsDriverAgeType ( n ) = = GRAPHICS_DRIVER_AGE_TYPE_LEGACY | | g_Config . m_GfxDriverIsBlocked = = 0 )
{
Info . m_Found = true ;
+ + FoundBackendCount ;
}
}
}
}
if ( FoundBackendCount > 1 )
{
MainView . HSplitTop ( 10.0f , nullptr , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Text , & MainView ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Text , Localize ( " Renderer " ) , 16.0f , TEXTALIGN_CENTER ) ;
2022-03-20 17:04:00 +00:00
static float s_ScrollValueDropBackend = 0 ;
static int s_BackendDropDownState = 0 ;
static std : : vector < std : : unique_ptr < int > > vBackendIDs ;
static std : : vector < const void * > vBackendIDPtrs ;
static std : : vector < std : : string > vBackendIDNames ;
static std : : vector < const char * > vBackendIDNamesCStr ;
static std : : vector < SMenuBackendInfo > vBackendInfos ;
size_t BackendCount = FoundBackendCount + 1 ;
vBackendIDs . resize ( BackendCount ) ;
vBackendIDPtrs . resize ( BackendCount ) ;
vBackendIDNames . resize ( BackendCount ) ;
vBackendIDNamesCStr . resize ( BackendCount ) ;
vBackendInfos . resize ( BackendCount ) ;
char aTmpBackendName [ 256 ] ;
auto IsInfoDefault = [ ] ( const SMenuBackendInfo & CheckInfo ) {
return str_comp_nocase ( CheckInfo . m_pBackendName , " OpenGL " ) = = 0 & & CheckInfo . m_Major = = 3 & & CheckInfo . m_Minor = = 0 & & CheckInfo . m_Patch = = 0 ;
} ;
int OldSelectedBackend = - 1 ;
uint32_t CurCounter = 0 ;
for ( uint32_t i = 0 ; i < BACKEND_TYPE_COUNT ; + + i )
{
for ( uint32_t n = 0 ; n < GRAPHICS_DRIVER_AGE_TYPE_COUNT ; + + n )
{
auto & Info = aaSupportedBackends [ i ] [ n ] ;
if ( Info . m_Found )
{
if ( vBackendIDs [ CurCounter ] . get ( ) = = nullptr )
vBackendIDs [ CurCounter ] = std : : make_unique < int > ( ) ;
vBackendIDPtrs [ CurCounter ] = vBackendIDs [ CurCounter ] . get ( ) ;
{
bool IsDefault = IsInfoDefault ( Info ) ;
str_format ( aTmpBackendName , sizeof ( aTmpBackendName ) , " %s (%d.%d.%d)%s%s " , Info . m_pBackendName , Info . m_Major , Info . m_Minor , Info . m_Patch , IsDefault ? " - " : " " , IsDefault ? Localize ( " default " ) : " " ) ;
vBackendIDNames [ CurCounter ] = aTmpBackendName ;
vBackendIDNamesCStr [ CurCounter ] = vBackendIDNames [ CurCounter ] . c_str ( ) ;
if ( str_comp_nocase ( Info . m_pBackendName , g_Config . m_GfxBackend ) = = 0 & & g_Config . m_GfxGLMajor = = Info . m_Major & & g_Config . m_GfxGLMinor = = Info . m_Minor & & g_Config . m_GfxGLPatch = = Info . m_Patch )
{
OldSelectedBackend = CurCounter ;
}
vBackendInfos [ CurCounter ] = Info ;
}
+ + CurCounter ;
}
}
}
if ( OldSelectedBackend ! = - 1 )
{
// no custom selected
BackendCount - = 1 ;
}
else
{
// custom selected one
if ( vBackendIDs [ CurCounter ] . get ( ) = = nullptr )
vBackendIDs [ CurCounter ] = std : : make_unique < int > ( ) ;
vBackendIDPtrs [ CurCounter ] = vBackendIDs [ CurCounter ] . get ( ) ;
str_format ( aTmpBackendName , sizeof ( aTmpBackendName ) , " %s (%s %d.%d.%d) " , Localize ( " custom " ) , g_Config . m_GfxBackend , g_Config . m_GfxGLMajor , g_Config . m_GfxGLMinor , g_Config . m_GfxGLPatch ) ;
vBackendIDNames [ CurCounter ] = aTmpBackendName ;
vBackendIDNamesCStr [ CurCounter ] = vBackendIDNames [ CurCounter ] . c_str ( ) ;
OldSelectedBackend = CurCounter ;
vBackendInfos [ CurCounter ] . m_pBackendName = " custom " ;
vBackendInfos [ CurCounter ] . m_Major = g_Config . m_GfxGLMajor ;
vBackendInfos [ CurCounter ] . m_Minor = g_Config . m_GfxGLMinor ;
vBackendInfos [ CurCounter ] . m_Patch = g_Config . m_GfxGLPatch ;
}
if ( s_OldSelectedBackend = = - 1 )
s_OldSelectedBackend = OldSelectedBackend ;
static int s_BackendCount = 0 ;
s_BackendCount = BackendCount ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_BackendButton ;
const int NewBackend = RenderDropDown ( s_BackendDropDownState , & MainView , OldSelectedBackend , vBackendIDPtrs . data ( ) , vBackendIDNamesCStr . data ( ) , s_BackendCount , & s_BackendButton , s_ScrollValueDropBackend ) ;
2022-03-20 17:04:00 +00:00
if ( OldSelectedBackend ! = NewBackend )
{
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_GfxBackend , vBackendInfos [ NewBackend ] . m_pBackendName ) ;
2022-03-20 17:04:00 +00:00
g_Config . m_GfxGLMajor = vBackendInfos [ NewBackend ] . m_Major ;
g_Config . m_GfxGLMinor = vBackendInfos [ NewBackend ] . m_Minor ;
g_Config . m_GfxGLPatch = vBackendInfos [ NewBackend ] . m_Patch ;
CheckSettings = true ;
s_GfxBackendChanged = s_OldSelectedBackend ! = NewBackend ;
}
}
2022-03-20 17:03:25 +00:00
// GPU list
const auto & GPUList = Graphics ( ) - > GetGPUs ( ) ;
2022-06-11 19:38:18 +00:00
if ( GPUList . m_vGPUs . size ( ) > 1 )
2022-03-20 17:03:25 +00:00
{
MainView . HSplitTop ( 10.0f , nullptr , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Text , & MainView ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Text , Localize ( " Graphics cards " ) , 16.0f , TEXTALIGN_CENTER ) ;
2022-03-20 17:03:25 +00:00
static float s_ScrollValueDropGPU = 0 ;
static int s_GPUDropDownState = 0 ;
static std : : vector < std : : unique_ptr < int > > vGPUIDs ;
static std : : vector < const void * > vGPUIDPtrs ;
static std : : vector < const char * > vGPUIDNames ;
2022-06-11 19:38:18 +00:00
size_t GPUCount = GPUList . m_vGPUs . size ( ) + 1 ;
2022-03-20 17:03:25 +00:00
vGPUIDs . resize ( GPUCount ) ;
vGPUIDPtrs . resize ( GPUCount ) ;
vGPUIDNames . resize ( GPUCount ) ;
char aCurDeviceName [ 256 + 4 ] ;
int OldSelectedGPU = - 1 ;
for ( size_t i = 0 ; i < GPUCount ; + + i )
{
if ( vGPUIDs [ i ] . get ( ) = = nullptr )
2022-03-20 17:04:00 +00:00
vGPUIDs [ i ] = std : : make_unique < int > ( ) ;
2022-03-20 17:03:25 +00:00
vGPUIDPtrs [ i ] = vGPUIDs [ i ] . get ( ) ;
if ( i = = 0 )
{
2022-06-30 22:36:32 +00:00
str_format ( aCurDeviceName , sizeof ( aCurDeviceName ) , " %s(%s) " , Localize ( " auto " ) , GPUList . m_AutoGPU . m_aName ) ;
2022-03-20 17:03:25 +00:00
vGPUIDNames [ i ] = aCurDeviceName ;
if ( str_comp ( " auto " , g_Config . m_GfxGPUName ) = = 0 )
{
OldSelectedGPU = 0 ;
}
}
else
{
2022-06-30 22:36:32 +00:00
vGPUIDNames [ i ] = GPUList . m_vGPUs [ i - 1 ] . m_aName ;
if ( str_comp ( GPUList . m_vGPUs [ i - 1 ] . m_aName , g_Config . m_GfxGPUName ) = = 0 )
2022-03-20 17:03:25 +00:00
{
OldSelectedGPU = i ;
}
}
}
static int s_GPUCount = 0 ;
s_GPUCount = GPUCount ;
2022-04-18 08:16:24 +00:00
if ( s_OldSelectedGPU = = - 1 )
s_OldSelectedGPU = OldSelectedGPU ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_GpuButton ;
const int NewGPU = RenderDropDown ( s_GPUDropDownState , & MainView , OldSelectedGPU , vGPUIDPtrs . data ( ) , vGPUIDNames . data ( ) , s_GPUCount , & s_GpuButton , s_ScrollValueDropGPU ) ;
2022-03-20 17:03:25 +00:00
if ( OldSelectedGPU ! = NewGPU )
{
if ( NewGPU = = 0 )
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_GfxGPUName , " auto " ) ;
2022-03-20 17:03:25 +00:00
else
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_GfxGPUName , GPUList . m_vGPUs [ NewGPU - 1 ] . m_aName ) ;
2022-04-18 08:16:24 +00:00
CheckSettings = true ;
s_GfxGPUChanged = NewGPU ! = s_OldSelectedGPU ;
2022-03-20 17:03:25 +00:00
}
}
2022-03-20 17:04:00 +00:00
// check if the new settings require a restart
if ( CheckSettings )
{
m_NeedRestartGraphics = ! ( s_GfxFsaaSamples = = g_Config . m_GfxFsaaSamples & &
! s_GfxBackendChanged & &
2022-04-18 08:16:24 +00:00
! s_GfxGPUChanged & &
2022-03-20 17:04:00 +00:00
s_GfxHighdpi = = g_Config . m_GfxHighdpi ) ;
}
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderSettingsSound ( CUIRect MainView )
2008-08-27 15:48:50 +00:00
{
2022-03-20 11:57:50 +00:00
CUIRect Button , Label ;
2010-12-08 00:55:13 +00:00
static int s_SndEnable = g_Config . m_SndEnable ;
2010-10-16 09:24:42 +00:00
static int s_SndRate = g_Config . m_SndRate ;
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndEnable , Localize ( " Use sounds " ) , g_Config . m_SndEnable , & Button ) )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
g_Config . m_SndEnable ^ = 1 ;
2022-06-26 20:07:10 +00:00
UpdateMusicState ( ) ;
2011-03-27 10:12:50 +00:00
m_NeedRestartSound = g_Config . m_SndEnable & & ( ! s_SndEnable | | s_SndRate ! = g_Config . m_SndRate ) ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
if ( ! g_Config . m_SndEnable )
2008-08-27 15:48:50 +00:00
return ;
2010-05-29 07:25:38 +00:00
2011-04-13 18:00:54 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndMusic , Localize ( " Play background music " ) , g_Config . m_SndMusic , & Button ) )
{
g_Config . m_SndMusic ^ = 1 ;
2022-06-26 20:07:10 +00:00
UpdateMusicState ( ) ;
2011-04-13 18:00:54 +00:00
}
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndNonactiveMute , Localize ( " Mute when not active " ) , g_Config . m_SndNonactiveMute , & Button ) )
g_Config . m_SndNonactiveMute ^ = 1 ;
2013-10-08 15:23:00 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2014-03-22 09:24:10 +00:00
if ( DoButton_CheckBox ( & g_Config . m_SndGame , Localize ( " Enable game sounds " ) , g_Config . m_SndGame , & Button ) )
g_Config . m_SndGame ^ = 1 ;
2014-10-25 23:00:30 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndGun , Localize ( " Enable gun sound " ) , g_Config . m_SndGun , & Button ) )
g_Config . m_SndGun ^ = 1 ;
2017-06-06 16:58:23 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndLongPain , Localize ( " Enable long pain sound (used when shooting in freeze) " ) , g_Config . m_SndLongPain , & Button ) )
g_Config . m_SndLongPain ^ = 1 ;
2014-03-22 09:24:10 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndServerMessage , Localize ( " Enable server message sound " ) , g_Config . m_SndServerMessage , & Button ) )
g_Config . m_SndServerMessage ^ = 1 ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndChat , Localize ( " Enable regular chat sound " ) , g_Config . m_SndChat , & Button ) )
2013-10-08 15:23:00 +00:00
g_Config . m_SndChat ^ = 1 ;
2014-05-04 16:35:37 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_SndTeamChat , Localize ( " Enable team chat sound " ) , g_Config . m_SndTeamChat , & Button ) )
g_Config . m_SndTeamChat ^ = 1 ;
2013-10-21 00:16:45 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2014-03-22 09:24:10 +00:00
if ( DoButton_CheckBox ( & g_Config . m_SndHighlight , Localize ( " Enable highlighted chat sound " ) , g_Config . m_SndHighlight , & Button ) )
g_Config . m_SndHighlight ^ = 1 ;
2013-10-21 00:16:45 +00:00
2013-02-24 18:43:09 +00:00
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClThreadsoundloading , Localize ( " Threaded sound loading " ) , g_Config . m_ClThreadsoundloading , & Button ) )
g_Config . m_ClThreadsoundloading ^ = 1 ;
2008-08-27 15:48:50 +00:00
// sample rate box
{
2010-05-29 07:25:38 +00:00
char aBuf [ 64 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " %d " , g_Config . m_SndRate ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Button , Localize ( " Sample rate " ) , 14.0f , TEXTALIGN_LEFT ) ;
2011-04-01 15:57:04 +00:00
Button . VSplitLeft ( 190.0f , 0 , & Button ) ;
2021-12-03 19:15:44 +00:00
static float s_Offset = 0.0f ;
UIEx ( ) - > DoEditBox ( & g_Config . m_SndRate , & Button , aBuf , sizeof ( aBuf ) , 14.0f , & s_Offset ) ;
2019-04-26 19:36:49 +00:00
g_Config . m_SndRate = maximum ( 1 , str_toint ( aBuf ) ) ;
2011-03-27 10:12:50 +00:00
m_NeedRestartSound = ! s_SndEnable | | s_SndRate ! = g_Config . m_SndRate ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
2008-08-27 15:48:50 +00:00
// volume slider
{
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 5.0f , & Button , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
2011-04-01 15:57:04 +00:00
Button . VSplitLeft ( 190.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Sound volume " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_SndVolume = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_SndVolume , & Button , g_Config . m_SndVolume / 100.0f ) * 100.0f ) ;
2008-08-27 15:48:50 +00:00
}
2014-10-12 15:02:47 +00:00
2020-10-09 21:14:20 +00:00
// volume slider game sounds
{
MainView . HSplitTop ( 5.0f , & Button , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 190.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Game sound volume " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_SndGameSoundVolume = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_SndGameSoundVolume , & Button , g_Config . m_SndGameSoundVolume / 100.0f ) * 100.0f ) ;
2020-10-09 21:14:20 +00:00
}
// volume slider gui sounds
{
MainView . HSplitTop ( 5.0f , & Button , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 190.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Chat sound volume " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_SndChatSoundVolume = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_SndChatSoundVolume , & Button , g_Config . m_SndChatSoundVolume / 100.0f ) * 100.0f ) ;
2020-10-09 21:14:20 +00:00
}
2014-10-12 15:02:47 +00:00
// volume slider map sounds
{
MainView . HSplitTop ( 5.0f , & Button , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 190.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Map sound volume " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_SndMapSoundVolume = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_SndMapSoundVolume , & Button , g_Config . m_SndMapSoundVolume / 100.0f ) * 100.0f ) ;
2014-10-12 15:02:47 +00:00
}
2020-09-30 08:06:54 +00:00
// volume slider background music
{
MainView . HSplitTop ( 5.0f , & Button , & MainView ) ;
MainView . HSplitTop ( 20.0f , & Button , & MainView ) ;
Button . VSplitLeft ( 190.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Background music volume " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_SndBackgroundMusicVolume = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_SndBackgroundMusicVolume , & Button , g_Config . m_SndBackgroundMusicVolume / 100.0f ) * 100.0f ) ;
2020-09-30 08:06:54 +00:00
}
2008-08-27 15:48:50 +00:00
}
2010-07-09 22:55:42 +00:00
class CLanguage
2009-06-15 08:15:53 +00:00
{
2010-07-09 22:55:42 +00:00
public :
2022-02-14 23:17:57 +00:00
CLanguage ( ) = default ;
2022-06-30 22:36:32 +00:00
CLanguage ( const char * pName , const char * pFileName , int Code ) :
m_Name ( pName ) , m_FileName ( pFileName ) , m_CountryCode ( Code ) { }
2010-05-29 07:25:38 +00:00
2022-05-06 21:51:24 +00:00
std : : string m_Name ;
std : : string m_FileName ;
2011-07-12 18:33:53 +00:00
int m_CountryCode ;
2010-05-29 07:25:38 +00:00
2020-10-08 05:28:53 +00:00
bool operator < ( const CLanguage & Other ) const { return m_Name < Other . m_Name ; }
2009-06-15 08:15:53 +00:00
} ;
2022-06-15 17:34:41 +00:00
void LoadLanguageIndexfile ( IStorage * pStorage , IConsole * pConsole , std : : vector < CLanguage > & vLanguages )
2008-08-27 15:48:50 +00:00
{
2021-12-17 20:58:28 +00:00
IOHANDLE File = pStorage - > OpenFile ( " languages/index.txt " , IOFLAG_READ | IOFLAG_SKIP_BOM , IStorage : : TYPE_ALL ) ;
2010-09-16 11:32:56 +00:00
if ( ! File )
{
pConsole - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " localization " , " couldn't open index file " ) ;
2009-06-15 08:15:53 +00:00
return ;
2010-09-16 11:32:56 +00:00
}
2011-04-13 18:37:12 +00:00
2011-02-10 11:07:00 +00:00
char aOrigin [ 128 ] ;
2011-07-12 18:33:53 +00:00
char aReplacement [ 128 ] ;
2010-09-16 11:32:56 +00:00
CLineReader LineReader ;
LineReader . Init ( File ) ;
char * pLine ;
while ( ( pLine = LineReader . Get ( ) ) )
{
if ( ! str_length ( pLine ) | | pLine [ 0 ] = = ' # ' ) // skip empty lines and comments
continue ;
2011-04-13 18:37:12 +00:00
2022-07-09 16:14:56 +00:00
str_copy ( aOrigin , pLine ) ;
2011-07-12 18:33:53 +00:00
pLine = LineReader . Get ( ) ;
if ( ! pLine )
2010-09-16 11:32:56 +00:00
{
pConsole - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " localization " , " unexpected end of index file " ) ;
break ;
}
2011-04-13 18:37:12 +00:00
2011-07-12 18:33:53 +00:00
if ( pLine [ 0 ] ! = ' = ' | | pLine [ 1 ] ! = ' = ' | | pLine [ 2 ] ! = ' ' )
{
char aBuf [ 128 ] ;
str_format ( aBuf , sizeof ( aBuf ) , " malform replacement for index '%s' " , aOrigin ) ;
pConsole - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " localization " , aBuf ) ;
( void ) LineReader . Get ( ) ;
continue ;
}
2022-07-09 16:14:56 +00:00
str_copy ( aReplacement , pLine + 3 ) ;
2011-07-12 18:33:53 +00:00
pLine = LineReader . Get ( ) ;
if ( ! pLine )
2010-09-16 11:32:56 +00:00
{
pConsole - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " localization " , " unexpected end of index file " ) ;
break ;
}
2011-04-13 18:37:12 +00:00
2011-07-12 18:33:53 +00:00
if ( pLine [ 0 ] ! = ' = ' | | pLine [ 1 ] ! = ' = ' | | pLine [ 2 ] ! = ' ' )
2010-09-16 11:32:56 +00:00
{
char aBuf [ 128 ] ;
2011-02-10 11:07:00 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " malform replacement for index '%s' " , aOrigin ) ;
2010-09-16 11:32:56 +00:00
pConsole - > Print ( IConsole : : OUTPUT_LEVEL_ADDINFO , " localization " , aBuf ) ;
continue ;
}
2011-04-13 18:37:12 +00:00
2021-09-13 08:06:34 +00:00
char aFileName [ IO_MAX_PATH_LENGTH ] ;
2011-02-10 11:07:00 +00:00
str_format ( aFileName , sizeof ( aFileName ) , " languages/%s.txt " , aOrigin ) ;
2022-06-15 17:34:41 +00:00
vLanguages . emplace_back ( aReplacement , aFileName , str_toint ( pLine + 3 ) ) ;
2010-09-16 11:32:56 +00:00
}
io_close ( File ) ;
2009-06-15 08:15:53 +00:00
}
2010-12-12 18:20:30 +00:00
void CMenus : : RenderLanguageSelection ( CUIRect MainView )
2009-06-15 08:15:53 +00:00
{
2011-04-13 18:37:12 +00:00
static int s_LanguageList = 0 ;
2010-05-29 07:25:38 +00:00
static int s_SelectedLanguage = 0 ;
2022-06-15 17:34:41 +00:00
static std : : vector < CLanguage > s_vLanguages ;
2010-05-29 07:25:38 +00:00
static float s_ScrollValue = 0 ;
2022-06-15 17:34:41 +00:00
if ( s_vLanguages . empty ( ) )
2008-08-27 15:48:50 +00:00
{
2022-06-15 17:34:41 +00:00
s_vLanguages . emplace_back ( " English " , " " , 826 ) ;
LoadLanguageIndexfile ( Storage ( ) , Console ( ) , s_vLanguages ) ;
std : : sort ( s_vLanguages . begin ( ) , s_vLanguages . end ( ) ) ;
for ( size_t i = 0 ; i < s_vLanguages . size ( ) ; i + + )
if ( str_comp ( s_vLanguages [ i ] . m_FileName . c_str ( ) , g_Config . m_ClLanguagefile ) = = 0 )
2009-06-15 08:15:53 +00:00
{
2010-05-29 07:25:38 +00:00
s_SelectedLanguage = i ;
2009-06-15 08:15:53 +00:00
break ;
}
}
2010-05-29 07:25:38 +00:00
int OldSelected = s_SelectedLanguage ;
2022-06-15 17:34:41 +00:00
UiDoListboxStart ( & s_LanguageList , & MainView , 24.0f , Localize ( " Language " ) , " " , s_vLanguages . size ( ) , 1 , s_SelectedLanguage , s_ScrollValue ) ;
2010-12-12 18:20:30 +00:00
2022-06-15 17:34:41 +00:00
for ( auto & Language : s_vLanguages )
2010-12-12 18:20:30 +00:00
{
2022-05-23 15:55:48 +00:00
CListboxItem Item = UiDoListboxNextItem ( & Language . m_Name ) ;
2010-12-12 18:20:30 +00:00
if ( Item . m_Visible )
2011-07-12 18:33:53 +00:00
{
CUIRect Rect ;
2020-09-26 19:41:58 +00:00
Item . m_Rect . VSplitLeft ( Item . m_Rect . h * 2.0f , & Rect , & Item . m_Rect ) ;
2011-07-12 18:33:53 +00:00
Rect . VMargin ( 6.0f , & Rect ) ;
Rect . HMargin ( 3.0f , & Rect ) ;
2019-04-26 21:47:34 +00:00
ColorRGBA Color ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2022-05-23 15:55:48 +00:00
m_pClient - > m_CountryFlags . Render ( Language . m_CountryCode , & Color , Rect . x , Rect . y , Rect . w , Rect . h ) ;
2011-07-12 18:33:53 +00:00
Item . m_Rect . HSplitTop ( 2.0f , 0 , & Item . m_Rect ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Item . m_Rect , Language . m_Name . c_str ( ) , 16.0f , TEXTALIGN_LEFT ) ;
2011-07-12 18:33:53 +00:00
}
2010-12-12 18:20:30 +00:00
}
s_SelectedLanguage = UiDoListboxEnd ( & s_ScrollValue , 0 ) ;
if ( OldSelected ! = s_SelectedLanguage )
{
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_ClLanguagefile , s_vLanguages [ s_SelectedLanguage ] . m_FileName . c_str ( ) ) ;
2022-06-15 17:34:41 +00:00
g_Localization . Load ( s_vLanguages [ s_SelectedLanguage ] . m_FileName . c_str ( ) , Storage ( ) , Console ( ) ) ;
2020-10-12 10:29:47 +00:00
GameClient ( ) - > OnLanguageChange ( ) ;
2010-12-12 18:20:30 +00:00
}
}
2010-05-29 07:25:38 +00:00
void CMenus : : RenderSettings ( CUIRect MainView )
2008-08-27 15:48:50 +00:00
{
// render background
2010-10-16 09:27:49 +00:00
CUIRect Temp , TabBar , RestartWarning ;
2010-05-29 07:25:38 +00:00
MainView . VSplitRight ( 120.0f , & MainView , & TabBar ) ;
2019-03-24 22:15:38 +00:00
RenderTools ( ) - > DrawUIRect ( & MainView , ms_ColorTabbarActive , CUI : : CORNER_B , 10.0f ) ;
2015-03-08 17:51:13 +00:00
MainView . Margin ( 10.0f , & MainView ) ;
MainView . HSplitBottom ( 15.0f , & MainView , & RestartWarning ) ;
2010-05-29 07:25:38 +00:00
TabBar . HSplitTop ( 50.0f , & Temp , & TabBar ) ;
2019-03-24 22:15:38 +00:00
RenderTools ( ) - > DrawUIRect ( & Temp , ms_ColorTabbarActive , CUI : : CORNER_BR , 10.0f ) ;
2010-05-29 07:25:38 +00:00
MainView . HSplitTop ( 10.0f , 0 , & MainView ) ;
CUIRect Button ;
2022-06-30 22:36:32 +00:00
const char * apTabs [ ] = {
2011-04-01 17:36:44 +00:00
Localize ( " Language " ) ,
2010-05-29 07:25:38 +00:00
Localize ( " General " ) ,
Localize ( " Player " ) ,
2011-04-01 17:36:44 +00:00
( " Tee " ) ,
2022-06-26 22:38:49 +00:00
Localize ( " Appearance " ) ,
2010-05-29 07:25:38 +00:00
Localize ( " Controls " ) ,
Localize ( " Graphics " ) ,
2011-04-09 20:45:34 +00:00
Localize ( " Sound " ) ,
2020-09-26 07:37:35 +00:00
Localize ( " DDNet " ) ,
Localize ( " Assets " ) } ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_aTabButtons [ sizeof ( apTabs ) ] ;
2010-05-29 07:25:38 +00:00
2022-06-30 22:36:32 +00:00
int NumTabs = ( int ) std : : size ( apTabs ) ;
2020-12-16 04:55:41 +00:00
int PreviousPage = g_Config . m_UiSettingsPage ;
2010-05-29 07:25:38 +00:00
for ( int i = 0 ; i < NumTabs ; i + + )
2008-08-27 15:48:50 +00:00
{
2010-05-29 07:25:38 +00:00
TabBar . HSplitTop ( 10 , & Button , & TabBar ) ;
TabBar . HSplitTop ( 26 , & Button , & TabBar ) ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aTabButtons [ i ] , apTabs [ i ] , g_Config . m_UiSettingsPage = = i , & Button , CUI : : CORNER_R , & m_aAnimatorsSettingsTab [ i ] ) )
2019-11-17 17:11:33 +00:00
g_Config . m_UiSettingsPage = i ;
2008-08-27 15:48:50 +00:00
}
2010-05-29 07:25:38 +00:00
2020-12-16 04:55:41 +00:00
if ( PreviousPage ! = g_Config . m_UiSettingsPage )
ms_ColorPicker . m_Active = false ;
2010-05-29 07:25:38 +00:00
MainView . Margin ( 10.0f , & MainView ) ;
2019-11-17 17:11:33 +00:00
if ( g_Config . m_UiSettingsPage = = SETTINGS_LANGUAGE )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_LANGUAGE ) ;
2011-04-01 17:36:44 +00:00
RenderLanguageSelection ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_GENERAL )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_GENERAL ) ;
2011-04-01 17:36:44 +00:00
RenderSettingsGeneral ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_PLAYER )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_PLAYER ) ;
2011-04-01 17:36:44 +00:00
RenderSettingsPlayer ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_TEE )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_TEE ) ;
2011-04-01 17:36:44 +00:00
RenderSettingsTee ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2022-06-26 22:38:49 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_APPEARANCE )
2020-09-18 16:45:42 +00:00
{
2022-06-26 22:38:49 +00:00
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_APPEARANCE ) ;
RenderSettingsAppearance ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_CONTROLS )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_CONTROLS ) ;
2014-07-07 13:47:11 +00:00
RenderSettingsControls ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_GRAPHICS )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_GRAPHICS ) ;
2014-07-07 13:47:11 +00:00
RenderSettingsGraphics ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_SOUND )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_SOUND ) ;
2014-07-07 13:47:11 +00:00
RenderSettingsSound ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2019-11-17 17:11:33 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_DDNET )
2020-09-18 16:45:42 +00:00
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_DDNET ) ;
2016-05-07 13:59:13 +00:00
RenderSettingsDDNet ( MainView ) ;
2020-09-18 16:45:42 +00:00
}
2020-09-26 07:37:35 +00:00
else if ( g_Config . m_UiSettingsPage = = SETTINGS_ASSETS )
{
m_pBackground - > ChangePosition ( CMenuBackground : : POS_SETTINGS_ASSETS ) ;
RenderSettingsCustom ( MainView ) ;
}
2010-05-29 07:25:38 +00:00
2015-03-08 17:51:13 +00:00
if ( m_NeedRestartUpdate )
{
TextRender ( ) - > TextColor ( 1.0f , 0.4f , 0.4f , 1.0f ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & RestartWarning , Localize ( " DDNet Client needs to be restarted to complete update! " ) , 14.0f , TEXTALIGN_LEFT ) ;
2015-03-08 17:51:13 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
}
2019-07-18 23:53:27 +00:00
else if ( m_NeedRestartGeneral | | m_NeedRestartSkins | | m_NeedRestartGraphics | | m_NeedRestartSound | | m_NeedRestartDDNet )
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & RestartWarning , Localize ( " You must restart the game for all settings to take effect. " ) , 14.0f , TEXTALIGN_LEFT ) ;
2020-12-16 04:55:41 +00:00
RenderColorPicker ( ) ;
2008-08-27 15:48:50 +00:00
}
2017-03-06 09:24:00 +00:00
2020-10-29 00:55:01 +00:00
ColorHSLA CMenus : : RenderHSLColorPicker ( const CUIRect * pRect , unsigned int * pColor , bool Alpha )
2020-10-28 02:59:50 +00:00
{
ColorHSLA HSLColor ( * pColor , false ) ;
ColorRGBA RGBColor = color_cast < ColorRGBA > ( HSLColor ) ;
2020-12-18 17:45:52 +00:00
2020-10-29 00:55:01 +00:00
ColorRGBA Outline ( 1 , 1 , 1 , 0.25f ) ;
2020-10-29 21:39:07 +00:00
const float OutlineSize = 3.0f ;
2021-11-26 20:55:31 +00:00
Outline . a * = UI ( ) - > ButtonColorMul ( pColor ) ;
2020-10-28 02:59:50 +00:00
CUIRect Rect ;
pRect - > Margin ( OutlineSize , & Rect ) ;
2020-10-29 00:55:01 +00:00
RenderTools ( ) - > DrawUIRect ( pRect , Outline , CUI : : CORNER_ALL , 4.0f ) ;
RenderTools ( ) - > DrawUIRect ( & Rect , RGBColor , CUI : : CORNER_ALL , 4.0f ) ;
2020-10-28 02:59:50 +00:00
if ( UI ( ) - > DoButtonLogic ( pColor , 0 , pRect ) )
{
if ( ms_ColorPicker . m_Active )
{
CUIRect PickerRect ;
PickerRect . x = ms_ColorPicker . m_X ;
PickerRect . y = ms_ColorPicker . m_Y ;
PickerRect . w = ms_ColorPicker . ms_Width ;
PickerRect . h = ms_ColorPicker . ms_Height ;
2021-02-01 18:34:41 +00:00
if ( ms_ColorPicker . m_pColor = = pColor | | UI ( ) - > MouseInside ( & PickerRect ) )
return HSLColor ;
2020-10-28 02:59:50 +00:00
}
2021-02-01 18:34:41 +00:00
CUIRect * pScreen = UI ( ) - > Screen ( ) ;
ms_ColorPicker . m_X = minimum ( UI ( ) - > MouseX ( ) , pScreen - > w - ms_ColorPicker . ms_Width ) ;
ms_ColorPicker . m_Y = minimum ( UI ( ) - > MouseY ( ) , pScreen - > h - ms_ColorPicker . ms_Height ) ;
ms_ColorPicker . m_pColor = pColor ;
ms_ColorPicker . m_Active = true ;
ms_ColorPicker . m_AttachedRect = * pRect ;
ms_ColorPicker . m_HSVColor = color_cast < ColorHSVA , ColorHSLA > ( HSLColor ) . Pack ( false ) ;
2020-10-28 02:59:50 +00:00
}
return HSLColor ;
}
2021-05-03 03:59:50 +00:00
ColorHSLA CMenus : : RenderHSLScrollbars ( CUIRect * pRect , unsigned int * pColor , bool Alpha , bool ClampedLight )
2020-06-27 13:08:35 +00:00
{
ColorHSLA Color ( * pColor , Alpha ) ;
2021-05-03 03:59:50 +00:00
CUIRect Preview , Button , Label ;
2020-06-27 13:08:47 +00:00
char aBuf [ 32 ] ;
2022-06-30 22:36:32 +00:00
float * apComponent [ ] = { & Color . h , & Color . s , & Color . l , & Color . a } ;
const char * apLabels [ ] = { Localize ( " Hue " ) , Localize ( " Sat. " ) , Localize ( " Lht. " ) , Localize ( " Alpha " ) } ;
2020-06-27 13:08:35 +00:00
2021-05-03 03:59:50 +00:00
float SizePerEntry = 20.0f ;
float MarginPerEntry = 5.0f ;
float OffY = ( SizePerEntry + MarginPerEntry ) * ( 3 + ( Alpha ? 1 : 0 ) ) - 40.0f ;
pRect - > VSplitLeft ( 40.0f , & Preview , pRect ) ;
Preview . HSplitTop ( OffY / 2.0f , NULL , & Preview ) ;
Preview . HSplitTop ( 40.0f , & Preview , NULL ) ;
Graphics ( ) - > TextureClear ( ) ;
{
const float SizeBorder = 5.0f ;
2021-09-25 07:50:11 +00:00
Graphics ( ) - > SetColor ( ColorRGBA ( 0.15f , 0.15f , 0.15f , 1 ) ) ;
2021-05-03 03:59:50 +00:00
int TmpCont = RenderTools ( ) - > CreateRoundRectQuadContainer ( Preview . x - SizeBorder / 2.0f , Preview . y - SizeBorder / 2.0f , Preview . w + SizeBorder , Preview . h + SizeBorder , 4.0f + SizeBorder / 2.0f , CUI : : CORNER_ALL ) ;
Graphics ( ) - > RenderQuadContainer ( TmpCont , - 1 ) ;
Graphics ( ) - > DeleteQuadContainer ( TmpCont ) ;
}
2021-09-25 07:50:11 +00:00
ColorHSLA RenderColorHSLA ( Color . r , Color . g , Color . b , Color . a ) ;
2021-05-03 03:59:50 +00:00
if ( ClampedLight )
RenderColorHSLA = RenderColorHSLA . UnclampLighting ( ) ;
2021-09-25 07:50:11 +00:00
Graphics ( ) - > SetColor ( color_cast < ColorRGBA > ( RenderColorHSLA ) ) ;
2021-05-03 03:59:50 +00:00
int TmpCont = RenderTools ( ) - > CreateRoundRectQuadContainer ( Preview . x , Preview . y , Preview . w , Preview . h , 4.0f , CUI : : CORNER_ALL ) ;
Graphics ( ) - > RenderQuadContainer ( TmpCont , - 1 ) ;
Graphics ( ) - > DeleteQuadContainer ( TmpCont ) ;
auto & & RenderHSLColorsRect = [ & ] ( CUIRect * pColorRect ) {
Graphics ( ) - > TextureClear ( ) ;
Graphics ( ) - > TrianglesBegin ( ) ;
float CurXOff = pColorRect - > x ;
float SizeColor = pColorRect - > w / 6 ;
// red to yellow
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 1 , 0 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 1 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 1 , 0 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 1 , 1 , 0 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
// yellow to green
CurXOff + = SizeColor ;
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 1 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 0 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 1 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 0 , 1 , 0 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
CurXOff + = SizeColor ;
// green to turquoise
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 0 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 0 , 1 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 0 , 1 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 0 , 1 , 1 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
CurXOff + = SizeColor ;
// turquoise to blue
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 0 , 1 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 0 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 0 , 1 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 0 , 0 , 1 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
CurXOff + = SizeColor ;
// blue to purple
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 0 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 1 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 0 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 1 , 0 , 1 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
CurXOff + = SizeColor ;
// purple to red
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , 1 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 1 , 1 , 0 , 0 , 1 ) ,
IGraphics : : CColorVertex ( 2 , 1 , 0 , 1 , 1 ) ,
IGraphics : : CColorVertex ( 3 , 1 , 0 , 0 , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
Graphics ( ) - > TrianglesEnd ( ) ;
} ;
auto & & RenderHSLSatRect = [ & ] ( CUIRect * pColorRect , ColorRGBA & CurColor ) {
Graphics ( ) - > TextureClear ( ) ;
Graphics ( ) - > TrianglesBegin ( ) ;
float CurXOff = pColorRect - > x ;
float SizeColor = pColorRect - > w ;
ColorHSLA RightColor = color_cast < ColorHSLA > ( CurColor ) ;
ColorHSLA LeftColor = color_cast < ColorHSLA > ( CurColor ) ;
LeftColor . g = 0 ;
RightColor . g = 1 ;
ColorRGBA RightColorRGBA = color_cast < ColorRGBA > ( RightColor ) ;
ColorRGBA LeftColorRGBA = color_cast < ColorRGBA > ( LeftColor ) ;
// saturation
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 1 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 2 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 3 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
Graphics ( ) - > TrianglesEnd ( ) ;
} ;
auto & & RenderHSLLightRect = [ & ] ( CUIRect * pColorRect , ColorRGBA & CurColorSat ) {
Graphics ( ) - > TextureClear ( ) ;
Graphics ( ) - > TrianglesBegin ( ) ;
float CurXOff = pColorRect - > x ;
float SizeColor = pColorRect - > w / ( ClampedLight ? 1.0f : 2.0f ) ;
ColorHSLA RightColor = color_cast < ColorHSLA > ( CurColorSat ) ;
ColorHSLA LeftColor = color_cast < ColorHSLA > ( CurColorSat ) ;
LeftColor . b = ColorHSLA : : DARKEST_LGT ;
RightColor . b = 1 ;
ColorRGBA RightColorRGBA = color_cast < ColorRGBA > ( RightColor ) ;
ColorRGBA LeftColorRGBA = color_cast < ColorRGBA > ( LeftColor ) ;
if ( ! ClampedLight )
CurXOff + = SizeColor ;
// light
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 1 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 2 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 3 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
if ( ! ClampedLight )
{
CurXOff - = SizeColor ;
LeftColor . b = 0 ;
RightColor . b = ColorHSLA : : DARKEST_LGT ;
2022-03-20 11:57:50 +00:00
RightColorRGBA = color_cast < ColorRGBA > ( RightColor ) ;
LeftColorRGBA = color_cast < ColorRGBA > ( LeftColor ) ;
2021-05-03 03:59:50 +00:00
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 1 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 2 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , 1 ) ,
IGraphics : : CColorVertex ( 3 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , 1 ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
Graphics ( ) - > TrianglesEnd ( ) ;
} ;
auto & & RenderHSLAlphaRect = [ & ] ( CUIRect * pColorRect , ColorRGBA & CurColorFull ) {
Graphics ( ) - > TextureClear ( ) ;
Graphics ( ) - > TrianglesBegin ( ) ;
float CurXOff = pColorRect - > x ;
float SizeColor = pColorRect - > w ;
ColorHSLA RightColor = color_cast < ColorHSLA > ( CurColorFull ) ;
ColorHSLA LeftColor = color_cast < ColorHSLA > ( CurColorFull ) ;
LeftColor . a = 0 ;
RightColor . a = 1 ;
ColorRGBA RightColorRGBA = color_cast < ColorRGBA > ( RightColor ) ;
ColorRGBA LeftColorRGBA = color_cast < ColorRGBA > ( LeftColor ) ;
// alpha
{
IGraphics : : CColorVertex Array [ 4 ] = {
IGraphics : : CColorVertex ( 0 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , LeftColorRGBA . a ) ,
IGraphics : : CColorVertex ( 1 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , RightColorRGBA . a ) ,
IGraphics : : CColorVertex ( 2 , LeftColorRGBA . r , LeftColorRGBA . g , LeftColorRGBA . b , LeftColorRGBA . a ) ,
IGraphics : : CColorVertex ( 3 , RightColorRGBA . r , RightColorRGBA . g , RightColorRGBA . b , RightColorRGBA . a ) } ;
Graphics ( ) - > SetColorVertex ( Array , 4 ) ;
IGraphics : : CFreeformItem Freeform (
CurXOff , pColorRect - > y ,
CurXOff + SizeColor , pColorRect - > y ,
CurXOff , pColorRect - > y + pColorRect - > h ,
CurXOff + SizeColor , pColorRect - > y + pColorRect - > h ) ;
Graphics ( ) - > QuadsDrawFreeform ( & Freeform , 1 ) ;
}
Graphics ( ) - > TrianglesEnd ( ) ;
} ;
2020-06-27 13:08:35 +00:00
for ( int i = 0 ; i < 3 + Alpha ; i + + )
{
2021-05-03 03:59:50 +00:00
pRect - > HSplitTop ( SizePerEntry , & Button , pRect ) ;
pRect - > HSplitTop ( MarginPerEntry , NULL , pRect ) ;
2020-06-27 13:08:35 +00:00
Button . VSplitLeft ( 10.0f , 0 , & Button ) ;
Button . VSplitLeft ( 100.0f , & Label , & Button ) ;
2021-05-03 03:59:50 +00:00
2021-09-25 07:50:11 +00:00
RenderTools ( ) - > DrawUIRect ( & Button , ColorRGBA ( 0.15f , 0.15f , 0.15f , 1.0f ) , CUI : : CORNER_ALL , 1.0f ) ;
2021-05-03 03:59:50 +00:00
2021-11-26 20:55:31 +00:00
CUIRect Rail ;
Button . Margin ( 2.0f , & Rail ) ;
2022-06-30 22:36:32 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %03d " , apLabels [ i ] , ( int ) ( * apComponent [ i ] * 255 ) ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2021-05-03 03:59:50 +00:00
2021-09-25 07:50:11 +00:00
ColorHSLA CurColorPureHSLA ( RenderColorHSLA . r , 1 , 0.5f , 1 ) ;
2021-05-03 03:59:50 +00:00
ColorRGBA CurColorPure = color_cast < ColorRGBA > ( CurColorPureHSLA ) ;
2021-09-25 07:50:11 +00:00
ColorRGBA ColorInner ( 1 , 1 , 1 , 0.25f ) ;
2021-05-03 03:59:50 +00:00
if ( i = = 0 )
{
ColorInner = CurColorPure ;
2021-11-26 20:55:31 +00:00
RenderHSLColorsRect ( & Rail ) ;
2021-05-03 03:59:50 +00:00
}
else if ( i = = 1 )
{
2021-11-26 20:55:31 +00:00
RenderHSLSatRect ( & Rail , CurColorPure ) ;
2022-06-30 22:36:32 +00:00
ColorInner = color_cast < ColorRGBA > ( ColorHSLA ( CurColorPureHSLA . r , * apComponent [ 1 ] , CurColorPureHSLA . b , 1 ) ) ;
2021-05-03 03:59:50 +00:00
}
else if ( i = = 2 )
{
2022-06-30 22:36:32 +00:00
ColorRGBA CurColorSat = color_cast < ColorRGBA > ( ColorHSLA ( CurColorPureHSLA . r , * apComponent [ 1 ] , 0.5f , 1 ) ) ;
2021-11-26 20:55:31 +00:00
RenderHSLLightRect ( & Rail , CurColorSat ) ;
2022-06-30 22:36:32 +00:00
float LightVal = * apComponent [ 2 ] ;
2021-05-03 03:59:50 +00:00
if ( ClampedLight )
LightVal = ColorHSLA : : DARKEST_LGT + LightVal * ( 1.0f - ColorHSLA : : DARKEST_LGT ) ;
2022-06-30 22:36:32 +00:00
ColorInner = color_cast < ColorRGBA > ( ColorHSLA ( CurColorPureHSLA . r , * apComponent [ 1 ] , LightVal , 1 ) ) ;
2021-05-03 03:59:50 +00:00
}
else if ( i = = 3 )
{
2022-06-30 22:36:32 +00:00
ColorRGBA CurColorFull = color_cast < ColorRGBA > ( ColorHSLA ( CurColorPureHSLA . r , * apComponent [ 1 ] , * apComponent [ 2 ] , 1 ) ) ;
2021-11-26 20:55:31 +00:00
RenderHSLAlphaRect ( & Rail , CurColorFull ) ;
2022-06-30 22:36:32 +00:00
float LightVal = * apComponent [ 2 ] ;
2021-05-03 03:59:50 +00:00
if ( ClampedLight )
LightVal = ColorHSLA : : DARKEST_LGT + LightVal * ( 1.0f - ColorHSLA : : DARKEST_LGT ) ;
2022-06-30 22:36:32 +00:00
ColorInner = color_cast < ColorRGBA > ( ColorHSLA ( CurColorPureHSLA . r , * apComponent [ 1 ] , LightVal , * apComponent [ 3 ] ) ) ;
2021-05-03 03:59:50 +00:00
}
2022-06-30 22:36:32 +00:00
* apComponent [ i ] = UIEx ( ) - > DoScrollbarH ( & ( ( char * ) pColor ) [ i ] , & Button , * apComponent [ i ] , & ColorInner ) ;
2020-06-27 13:08:35 +00:00
}
2020-06-27 17:40:04 +00:00
* pColor = Color . Pack ( Alpha ) ;
2020-06-27 13:08:35 +00:00
return Color ;
}
2022-06-26 22:38:49 +00:00
enum
{
APPEARANCE_TAB_HUD = 0 ,
APPEARANCE_TAB_CHAT = 1 ,
APPEARANCE_TAB_NAME_PLATE = 2 ,
APPEARANCE_TAB_HOOK_COLLISION = 3 ,
APPEARANCE_TAB_KILL_MESSAGES = 4 ,
APPEARANCE_TAB_LASER = 5 ,
NUMBER_OF_APPEARANCE_TABS = 6 ,
} ;
void CMenus : : RenderSettingsAppearance ( CUIRect MainView )
2011-04-09 06:41:31 +00:00
{
2022-06-14 19:51:14 +00:00
char aBuf [ 128 ] ;
2021-10-02 21:15:59 +00:00
static int s_CurTab = 0 ;
2011-04-09 06:41:31 +00:00
2022-06-30 12:17:07 +00:00
CUIRect TabBar , Page1Tab , Page2Tab , Page3Tab , Page4Tab , Page5Tab , Page6Tab , LeftView , RightView , Section , Button , Label ;
2022-06-26 22:38:49 +00:00
MainView . HSplitTop ( 20 , & TabBar , & MainView ) ;
float TabsW = TabBar . w ;
TabBar . VSplitLeft ( TabsW / NUMBER_OF_APPEARANCE_TABS , & Page1Tab , & Page2Tab ) ;
Page2Tab . VSplitLeft ( TabsW / NUMBER_OF_APPEARANCE_TABS , & Page2Tab , & Page3Tab ) ;
Page3Tab . VSplitLeft ( TabsW / NUMBER_OF_APPEARANCE_TABS , & Page3Tab , & Page4Tab ) ;
Page4Tab . VSplitLeft ( TabsW / NUMBER_OF_APPEARANCE_TABS , & Page4Tab , & Page5Tab ) ;
Page5Tab . VSplitLeft ( TabsW / NUMBER_OF_APPEARANCE_TABS , & Page5Tab , & Page6Tab ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_aPageTabs [ NUMBER_OF_APPEARANCE_TABS ] = { } ;
2022-06-26 22:38:49 +00:00
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_HUD ] , Localize ( " HUD " ) , s_CurTab = = APPEARANCE_TAB_HUD , & Page1Tab , CUI : : CORNER_L , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_HUD ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_CHAT ] , Localize ( " Chat " ) , s_CurTab = = APPEARANCE_TAB_CHAT , & Page2Tab , 0 , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_CHAT ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_NAME_PLATE ] , Localize ( " Name Plate " ) , s_CurTab = = APPEARANCE_TAB_NAME_PLATE , & Page3Tab , 0 , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_NAME_PLATE ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_HOOK_COLLISION ] , Localize ( " Hook Collisions " ) , s_CurTab = = APPEARANCE_TAB_HOOK_COLLISION , & Page4Tab , 0 , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_HOOK_COLLISION ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_KILL_MESSAGES ] , Localize ( " Kill Messages " ) , s_CurTab = = APPEARANCE_TAB_KILL_MESSAGES , & Page5Tab , 0 , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_KILL_MESSAGES ;
2022-07-16 13:32:06 +00:00
if ( DoButton_MenuTab ( & s_aPageTabs [ APPEARANCE_TAB_LASER ] , Localize ( " Laser " ) , s_CurTab = = APPEARANCE_TAB_LASER , & Page6Tab , CUI : : CORNER_R , NULL , NULL , NULL , NULL , 4 ) )
2022-06-26 22:38:49 +00:00
s_CurTab = APPEARANCE_TAB_LASER ;
2021-10-02 21:15:59 +00:00
2022-06-30 12:17:07 +00:00
MainView . HSplitTop ( 10.0f , 0x0 , & MainView ) ; // Margin
2017-02-27 20:38:24 +00:00
2022-06-30 12:17:07 +00:00
const float LineSize = 20.0f ;
const float ColorPickerLineSize = 25.0f ;
const float SectionMargin = 5.0f ;
const float SectionTotalMargin = 10.0f ; // SectionMargin * 2;
const float HeadlineFontSize = 20.0f ;
const float HeadlineAndVMargin = 30.0f ; // HeadlineFontSize + SectionTotalMargin;
const float MarginToNextSection = 5.0f ;
const float ColorPickerLabelSize = 13.0f ;
const float ColorPickerLineSpacing = 5.0f ;
const float LeftViewColorPickerPosition = 210.0f ;
2017-02-27 20:38:24 +00:00
2022-06-26 22:38:49 +00:00
if ( s_CurTab = = APPEARANCE_TAB_HUD )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2011-04-09 06:41:31 +00:00
2021-10-02 21:15:59 +00:00
// ***** HUD ***** //
2022-06-30 12:17:07 +00:00
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " HUD " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2011-04-09 06:41:31 +00:00
2022-06-30 12:17:07 +00:00
// Switch of the entire HUD
LeftView . HSplitTop ( SectionTotalMargin + LineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2021-05-09 11:21:07 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhud , Localize ( " Show ingame HUD " ) , & g_Config . m_ClShowhud , & Section , LineSize ) ;
2021-05-09 11:21:07 +00:00
2022-06-30 12:17:07 +00:00
// Switches of the various normal HUD elements
LeftView . HSplitTop ( SectionTotalMargin + 5 * LineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2021-05-09 11:21:07 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudHealthAmmo , Localize ( " Show health, shields and ammo " ) , & g_Config . m_ClShowhudHealthAmmo , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowChat , Localize ( " Show chat " ) , & g_Config . m_ClShowChat , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClNameplates , Localize ( " Show name plates " ) , & g_Config . m_ClNameplates , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowKillMessages , Localize ( " Show kill messages " ) , & g_Config . m_ClShowKillMessages , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudScore , Localize ( " Show score " ) , & g_Config . m_ClShowhudScore , & Section , LineSize ) ;
2021-05-09 11:21:07 +00:00
2022-06-30 12:17:07 +00:00
// Settings of the HUD element for votes
LeftView . HSplitTop ( SectionTotalMargin + LineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2020-10-28 02:59:50 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowVotesAfterVoting , Localize ( " Show votes window after voting " ) , & g_Config . m_ClShowVotesAfterVoting , & Section , LineSize ) ;
2020-10-28 02:59:50 +00:00
2022-06-26 22:38:49 +00:00
// ***** DDRace HUD ***** //
2022-06-30 12:17:07 +00:00
RightView . HSplitTop ( HeadlineAndVMargin , & Label , & RightView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " DDRace HUD " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-15 19:37:54 +00:00
2022-06-30 12:17:07 +00:00
// Switches of various DDRace HUD elements
RightView . HSplitTop ( SectionTotalMargin + 4 * LineSize , & Section , & RightView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-03-12 03:19:17 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClDDRaceScoreBoard , Localize ( " Use DDRace Scoreboard " ) , & g_Config . m_ClDDRaceScoreBoard , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowIDs , Localize ( " Show client IDs in scoreboard " ) , & g_Config . m_ClShowIDs , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudDDRace , Localize ( " Show DDRace HUD " ) , & g_Config . m_ClShowhudDDRace , & Section , LineSize ) ;
2022-06-26 22:38:49 +00:00
if ( g_Config . m_ClShowhudDDRace )
2022-03-12 03:19:17 +00:00
{
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudJumpsIndicator , Localize ( " Show jumps indicator " ) , & g_Config . m_ClShowhudJumpsIndicator , & Section , LineSize ) ;
2022-03-12 03:19:17 +00:00
}
2022-06-30 12:17:07 +00:00
else
2022-03-31 01:15:27 +00:00
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , 0x0 , & Section ) ; // Create empty space for hidden option
2022-03-31 01:15:27 +00:00
}
2017-02-27 20:39:06 +00:00
2022-06-30 12:17:07 +00:00
// Switch for dummy actions display
RightView . HSplitTop ( SectionTotalMargin + LineSize , & Section , & RightView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2017-03-10 17:49:39 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudDummyActions , Localize ( " Show dummy actions " ) , & g_Config . m_ClShowhudDummyActions , & Section , LineSize ) ;
2022-06-15 19:37:54 +00:00
2022-06-30 12:17:07 +00:00
// Player movement information display settings
RightView . HSplitTop ( SectionTotalMargin + 3 * LineSize , & Section , & RightView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-15 19:37:54 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudPlayerPosition , Localize ( " Show player position " ) , & g_Config . m_ClShowhudPlayerPosition , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudPlayerSpeed , Localize ( " Show player speed " ) , & g_Config . m_ClShowhudPlayerSpeed , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowhudPlayerAngle , Localize ( " Show player target angle " ) , & g_Config . m_ClShowhudPlayerAngle , & Section , LineSize ) ;
2022-06-15 19:37:54 +00:00
2022-06-30 12:17:07 +00:00
// Freeze bar settings
RightView . HSplitTop ( SectionTotalMargin + 3 * LineSize , & Section , & RightView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-15 19:37:54 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowFreezeBars , Localize ( " Show freeze bars " ) , & g_Config . m_ClShowFreezeBars , & Section , LineSize ) ;
2022-06-26 22:38:49 +00:00
{
if ( g_Config . m_ClShowFreezeBars )
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
Section . HSplitTop ( LineSize , & Button , & Section ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i%% " , Localize ( " Opacity of freeze bars inside freeze " ) , g_Config . m_ClFreezeBarsAlphaInsideFreeze ) ;
2022-06-26 22:38:49 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
g_Config . m_ClFreezeBarsAlphaInsideFreeze = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClFreezeBarsAlphaInsideFreeze , & Button , g_Config . m_ClFreezeBarsAlphaInsideFreeze / 100.0f ) * 100.0f ) ;
}
2022-06-30 12:17:07 +00:00
else
{
Section . HSplitTop ( 2 * LineSize , 0x0 , & Section ) ; // Create empty space for hidden option
}
2022-06-26 22:38:49 +00:00
}
2021-10-02 21:15:59 +00:00
}
2022-06-26 22:38:49 +00:00
else if ( s_CurTab = = APPEARANCE_TAB_CHAT )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2019-04-25 16:49:27 +00:00
2022-06-30 12:17:07 +00:00
// ***** Chat ***** //
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Chat " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2019-04-25 16:49:27 +00:00
2022-06-30 12:17:07 +00:00
// General chat settings
LeftView . HSplitTop ( SectionTotalMargin + 3 * LineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2014-07-07 13:47:11 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClChatTeamColors , Localize ( " Show names in chat in team colors " ) , & g_Config . m_ClChatTeamColors , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClShowChatFriends , Localize ( " Show only chat messages from friends " ) , & g_Config . m_ClShowChatFriends , & Section , LineSize ) ;
2020-08-05 10:39:13 +00:00
2022-06-30 12:17:07 +00:00
if ( DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClChatOld , Localize ( " Use old chat style " ) , & g_Config . m_ClChatOld , & Section , LineSize ) )
2021-10-02 21:15:59 +00:00
GameClient ( ) - > m_Chat . RebuildChat ( ) ;
2020-08-05 10:39:13 +00:00
2022-06-30 12:17:07 +00:00
// ***** Messages ***** //
LeftView . HSplitTop ( MarginToNextSection , 0x0 , & LeftView ) ;
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Messages " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2014-07-07 13:47:11 +00:00
2022-06-30 12:17:07 +00:00
// Message Colors and extra settings
LeftView . HSplitTop ( SectionTotalMargin + 6 * ColorPickerLineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2020-08-05 10:39:13 +00:00
2021-10-02 21:15:59 +00:00
int i = 0 ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_aResetIDs [ 24 ] ;
2020-08-05 10:39:13 +00:00
2022-06-30 22:36:32 +00:00
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " System message " ) , & g_Config . m_ClMessageSystemColor , ColorRGBA ( 1.0f , 1.0f , 0.5f ) , true , true , & g_Config . m_ClShowChatSystem ) ;
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Highlighted message " ) , & g_Config . m_ClMessageHighlightColor , ColorRGBA ( 1.0f , 0.5f , 0.5f ) ) ;
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Team message " ) , & g_Config . m_ClMessageTeamColor , ColorRGBA ( 0.65f , 1.0f , 0.65f ) ) ;
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Friend message " ) , & g_Config . m_ClMessageFriendColor , ColorRGBA ( 1.0f , 0.137f , 0.137f ) , true , true , & g_Config . m_ClMessageFriend ) ;
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Normal message " ) , & g_Config . m_ClMessageColor , ColorRGBA ( 1.0f , 1.0f , 1.0f ) ) ;
2020-12-14 00:51:31 +00:00
2021-10-02 21:15:59 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s (echo) " , Localize ( " Client message " ) ) ;
2022-06-30 22:36:32 +00:00
DoLine_ColorPicker ( & s_aResetIDs [ i + + ] , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , aBuf , & g_Config . m_ClMessageClientColor , ColorRGBA ( 0.5f , 0.78f , 1.0f ) ) ;
2020-12-14 00:51:31 +00:00
2021-10-02 21:15:59 +00:00
// ***** Chat Preview ***** //
2022-06-30 12:17:07 +00:00
RightView . HSplitTop ( HeadlineAndVMargin , & Label , & RightView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Preview " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2019-04-25 16:49:27 +00:00
2022-06-30 12:17:07 +00:00
// Use the rest of the view for preview
Section = RightView ;
Section . Margin ( SectionMargin , & Section ) ;
2021-10-02 21:15:59 +00:00
2022-06-30 12:17:07 +00:00
RenderTools ( ) - > DrawUIRect ( & Section , ColorRGBA ( 1 , 1 , 1 , 0.1f ) , CUI : : CORNER_ALL , 8.0f ) ;
2021-10-02 21:15:59 +00:00
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( 10.0f , 0x0 , & Section ) ; // Margin
2021-10-02 21:15:59 +00:00
ColorRGBA SystemColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageSystemColor ) ) ;
ColorRGBA HighlightedColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageHighlightColor ) ) ;
ColorRGBA TeamColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageTeamColor ) ) ;
ColorRGBA FriendColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageFriendColor ) ) ;
ColorRGBA NormalColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageColor ) ) ;
ColorRGBA ClientColor = color_cast < ColorRGBA , ColorHSLA > ( ColorHSLA ( g_Config . m_ClMessageClientColor ) ) ;
ColorRGBA DefaultNameColor ( 0.8f , 0.8f , 0.8f , 1.0f ) ;
constexpr float RealFontSize = CChat : : FONT_SIZE * 2 ;
const float RealMsgPaddingX = ( ! g_Config . m_ClChatOld ? CChat : : MESSAGE_PADDING_X : 0 ) * 2 ;
const float RealMsgPaddingY = ( ! g_Config . m_ClChatOld ? CChat : : MESSAGE_PADDING_Y : 0 ) * 2 ;
const float RealMsgPaddingTee = ( ! g_Config . m_ClChatOld ? CChat : : MESSAGE_TEE_SIZE + CChat : : MESSAGE_TEE_PADDING_RIGHT : 0 ) * 2 ;
const float RealOffsetY = RealFontSize + RealMsgPaddingY ;
2022-06-30 12:17:07 +00:00
const float X = 5.0f + RealMsgPaddingX / 2.0f + Section . x ;
float Y = Section . y ;
2021-10-02 21:15:59 +00:00
CTextCursor Cursor ;
TextRender ( ) - > SetCursor ( & Cursor , X , Y , RealFontSize , TEXTFLAG_RENDER ) ;
2022-07-09 16:14:56 +00:00
str_copy ( aBuf , Client ( ) - > PlayerName ( ) ) ;
2021-10-02 21:15:59 +00:00
CAnimState * pIdleState = CAnimState : : GetIdle ( ) ;
constexpr int PreviewTeeCount = 4 ;
constexpr float RealTeeSize = CChat : : MESSAGE_TEE_SIZE * 2 ;
constexpr float RealTeeSizeHalved = CChat : : MESSAGE_TEE_SIZE ;
constexpr float TWSkinUnreliableOffset = - 0.25f ;
constexpr float OffsetTeeY = RealTeeSizeHalved ;
const float FullHeightMinusTee = RealOffsetY - RealTeeSize ;
2022-06-30 22:36:32 +00:00
CTeeRenderInfo aRenderInfo [ PreviewTeeCount ] ;
2021-10-02 21:15:59 +00:00
// Backgrounds first
if ( ! g_Config . m_ClChatOld )
2014-07-07 13:47:11 +00:00
{
2021-10-02 21:15:59 +00:00
Graphics ( ) - > TextureClear ( ) ;
Graphics ( ) - > QuadsBegin ( ) ;
Graphics ( ) - > SetColor ( 0 , 0 , 0 , 0.12f ) ;
2022-06-30 22:36:32 +00:00
char aLineBuilder [ 128 ] ;
2021-10-02 21:15:59 +00:00
float Width ;
float TempY = Y ;
constexpr float RealBackgroundRounding = CChat : : MESSAGE_ROUNDING * 2.0f ;
if ( g_Config . m_ClShowChatSystem )
{
2022-06-30 22:36:32 +00:00
str_format ( aLineBuilder , sizeof ( aLineBuilder ) , " *** '%s' entered and joined the game " , aBuf ) ;
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , aLineBuilder , - 1 , - 1 ) ;
2021-10-02 21:15:59 +00:00
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
TempY + = RealOffsetY ;
}
2022-06-30 22:36:32 +00:00
str_format ( aLineBuilder , sizeof ( aLineBuilder ) , " %sRandom Tee: Hey, how are you %s? " , g_Config . m_ClShowIDs ? " 7: " : " " , aBuf ) ;
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , aLineBuilder , - 1 , - 1 ) ;
2021-10-02 21:15:59 +00:00
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX + RealMsgPaddingTee , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
2020-10-29 00:55:01 +00:00
TempY + = RealOffsetY ;
2014-07-07 13:47:11 +00:00
2022-06-30 22:36:32 +00:00
str_format ( aLineBuilder , sizeof ( aLineBuilder ) , " %sYour Teammate: Let's speedrun this! " , g_Config . m_ClShowIDs ? " 11: " : " " ) ;
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , aLineBuilder , - 1 , - 1 ) ;
2021-10-02 21:15:59 +00:00
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX + RealMsgPaddingTee , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
TempY + = RealOffsetY ;
2020-10-29 00:55:01 +00:00
2022-06-30 22:36:32 +00:00
str_format ( aLineBuilder , sizeof ( aLineBuilder ) , " %s%sFriend: Hello there " , g_Config . m_ClMessageFriend ? " ♥ " : " " , g_Config . m_ClShowIDs ? " 8: " : " " ) ;
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , aLineBuilder , - 1 , - 1 ) ;
2021-10-02 21:15:59 +00:00
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX + RealMsgPaddingTee , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
2020-10-29 00:55:01 +00:00
TempY + = RealOffsetY ;
2022-06-30 22:36:32 +00:00
str_format ( aLineBuilder , sizeof ( aLineBuilder ) , " %sSpammer [6]: Hey fools, I'm spamming here! " , g_Config . m_ClShowIDs ? " 9: " : " " ) ;
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , aLineBuilder , - 1 , - 1 ) ;
2021-10-02 21:15:59 +00:00
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX + RealMsgPaddingTee , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
TempY + = RealOffsetY ;
2019-04-25 16:49:27 +00:00
2021-10-02 21:15:59 +00:00
Width = TextRender ( ) - > TextWidth ( 0 , RealFontSize , " *** Echo command executed " , - 1 , - 1 ) ;
RenderTools ( ) - > DrawRoundRectExt ( X - RealMsgPaddingX / 2.0f , TempY - RealMsgPaddingY / 2.0f , Width + RealMsgPaddingX , RealFontSize + RealMsgPaddingY , RealBackgroundRounding , CUI : : CORNER_ALL ) ;
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
Graphics ( ) - > QuadsEnd ( ) ;
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
// Load skins
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
int DefaultInd = GameClient ( ) - > m_Skins . Find ( " default " ) ;
2014-07-07 13:47:11 +00:00
2022-06-30 22:36:32 +00:00
for ( auto & Info : aRenderInfo )
2021-10-02 21:15:59 +00:00
{
2022-03-20 11:57:50 +00:00
Info . m_Size = RealTeeSize ;
Info . m_CustomColoredSkin = false ;
2021-10-02 21:15:59 +00:00
}
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
int ind = - 1 ;
2022-03-20 11:57:50 +00:00
int pos = 0 ;
2014-07-07 13:47:11 +00:00
2022-06-30 22:36:32 +00:00
aRenderInfo [ pos + + ] . m_OriginalRenderSkin = GameClient ( ) - > m_Skins . Get ( DefaultInd ) - > m_OriginalSkin ;
aRenderInfo [ pos + + ] . m_OriginalRenderSkin = ( ind = GameClient ( ) - > m_Skins . Find ( " pinky " ) ) ! = - 1 ? GameClient ( ) - > m_Skins . Get ( ind ) - > m_OriginalSkin : aRenderInfo [ 0 ] . m_OriginalRenderSkin ;
aRenderInfo [ pos + + ] . m_OriginalRenderSkin = ( ind = GameClient ( ) - > m_Skins . Find ( " cammostripes " ) ) ! = - 1 ? GameClient ( ) - > m_Skins . Get ( ind ) - > m_OriginalSkin : aRenderInfo [ 0 ] . m_OriginalRenderSkin ;
aRenderInfo [ pos + + ] . m_OriginalRenderSkin = ( ind = GameClient ( ) - > m_Skins . Find ( " beast " ) ) ! = - 1 ? GameClient ( ) - > m_Skins . Get ( ind ) - > m_OriginalSkin : aRenderInfo [ 0 ] . m_OriginalRenderSkin ;
2021-10-02 21:15:59 +00:00
}
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
// System
if ( g_Config . m_ClShowChatSystem )
2014-07-07 13:47:11 +00:00
{
2021-10-02 21:15:59 +00:00
TextRender ( ) - > TextColor ( SystemColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " *** ' " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , aBuf , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " ' entered and joined the game " , - 1 ) ;
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y + = RealOffsetY ) ;
2014-07-07 13:47:11 +00:00
}
2021-10-02 21:15:59 +00:00
// Highlighted
TextRender ( ) - > MoveCursor ( & Cursor , RealMsgPaddingTee , 0 ) ;
TextRender ( ) - > TextColor ( DefaultNameColor ) ;
if ( g_Config . m_ClShowIDs )
TextRender ( ) - > TextEx ( & Cursor , " 7: " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " Random Tee: " , - 1 ) ;
TextRender ( ) - > TextColor ( HighlightedColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " Hey, how are you " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , aBuf , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " ? " , - 1 ) ;
if ( ! g_Config . m_ClChatOld )
2022-06-30 22:36:32 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & aRenderInfo [ 1 ] , EMOTE_NORMAL , vec2 ( 1 , 0.1f ) , vec2 ( X + RealTeeSizeHalved , Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset ) ) ;
2021-10-02 21:15:59 +00:00
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y + = RealOffsetY ) ;
2014-07-07 13:47:11 +00:00
2021-10-02 21:15:59 +00:00
// Team
TextRender ( ) - > MoveCursor ( & Cursor , RealMsgPaddingTee , 0 ) ;
TextRender ( ) - > TextColor ( TeamColor ) ;
if ( g_Config . m_ClShowIDs )
TextRender ( ) - > TextEx ( & Cursor , " 11: " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " Your Teammate: Let's speedrun this! " , - 1 ) ;
if ( ! g_Config . m_ClChatOld )
2022-06-30 22:36:32 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & aRenderInfo [ 0 ] , EMOTE_NORMAL , vec2 ( 1 , 0.1f ) , vec2 ( X + RealTeeSizeHalved , Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset ) ) ;
2021-10-02 21:15:59 +00:00
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y + = RealOffsetY ) ;
2020-10-29 00:55:01 +00:00
2021-10-02 21:15:59 +00:00
// Friend
TextRender ( ) - > MoveCursor ( & Cursor , RealMsgPaddingTee , 0 ) ;
if ( g_Config . m_ClMessageFriend )
{
TextRender ( ) - > TextColor ( FriendColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " ♥ " , - 1 ) ;
}
TextRender ( ) - > TextColor ( DefaultNameColor ) ;
if ( g_Config . m_ClShowIDs )
TextRender ( ) - > TextEx ( & Cursor , " 8: " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " Friend: " , - 1 ) ;
TextRender ( ) - > TextColor ( NormalColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " Hello there " , - 1 ) ;
if ( ! g_Config . m_ClChatOld )
2022-06-30 22:36:32 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & aRenderInfo [ 2 ] , EMOTE_NORMAL , vec2 ( 1 , 0.1f ) , vec2 ( X + RealTeeSizeHalved , Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset ) ) ;
2020-10-29 00:55:01 +00:00
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y + = RealOffsetY ) ;
2021-10-02 21:15:59 +00:00
// Normal
TextRender ( ) - > MoveCursor ( & Cursor , RealMsgPaddingTee , 0 ) ;
TextRender ( ) - > TextColor ( DefaultNameColor ) ;
if ( g_Config . m_ClShowIDs )
TextRender ( ) - > TextEx ( & Cursor , " 9: " , - 1 ) ;
TextRender ( ) - > TextEx ( & Cursor , " Spammer " , - 1 ) ;
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 0.3f ) ;
TextRender ( ) - > TextEx ( & Cursor , " [6] " , - 1 ) ;
TextRender ( ) - > TextColor ( NormalColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " : Hey fools, I'm spamming here! " , - 1 ) ;
if ( ! g_Config . m_ClChatOld )
2022-06-30 22:36:32 +00:00
RenderTools ( ) - > RenderTee ( pIdleState , & aRenderInfo [ 3 ] , EMOTE_NORMAL , vec2 ( 1 , 0.1f ) , vec2 ( X + RealTeeSizeHalved , Y + OffsetTeeY + FullHeightMinusTee / 2.0f + TWSkinUnreliableOffset ) ) ;
2021-10-02 21:15:59 +00:00
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y + = RealOffsetY ) ;
// Client
TextRender ( ) - > TextColor ( ClientColor ) ;
TextRender ( ) - > TextEx ( & Cursor , " *** Echo command executed " , - 1 ) ;
TextRender ( ) - > SetCursorPosition ( & Cursor , X , Y ) ;
2021-10-28 22:11:21 +00:00
TextRender ( ) - > TextColor ( TextRender ( ) - > DefaultTextColor ( ) ) ;
2021-10-02 21:15:59 +00:00
}
2022-06-26 22:38:49 +00:00
else if ( s_CurTab = = APPEARANCE_TAB_NAME_PLATE )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// ***** Name Plate ***** //
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Name Plate " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// General chat settings
LeftView . HSplitTop ( SectionTotalMargin + 9 * LineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-26 22:38:49 +00:00
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
Section . HSplitTop ( LineSize , & Button , & Section ) ;
2022-06-26 22:38:49 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Name plates size " ) , g_Config . m_ClNameplatesSize ) ;
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
g_Config . m_ClNameplatesSize = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClNameplatesSize , & Button , g_Config . m_ClNameplatesSize / 100.0f ) * 100.0f + 0.1f ) ;
}
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClNameplatesClan , Localize ( " Show clan above name plates " ) , & g_Config . m_ClNameplatesClan , & Section , LineSize ) ;
2022-06-26 22:38:49 +00:00
if ( g_Config . m_ClNameplatesClan )
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
Section . HSplitTop ( LineSize , & Button , & Section ) ;
2022-06-26 22:38:49 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Clan plates size " ) , g_Config . m_ClNameplatesClanSize ) ;
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
g_Config . m_ClNameplatesClanSize = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClNameplatesClanSize , & Button , g_Config . m_ClNameplatesClanSize / 100.0f ) * 100.0f + 0.1f ) ;
}
2022-06-30 12:17:07 +00:00
else
{
Section . HSplitTop ( 2 * LineSize , 0x0 , & Section ) ; // Create empty space for hidden option
}
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClNameplatesTeamcolors , Localize ( " Use team colors for name plates " ) , & g_Config . m_ClNameplatesTeamcolors , & Section , LineSize ) ;
DoButton_CheckBoxAutoVMarginAndSet ( & g_Config . m_ClNameplatesStrong , Localize ( " Show hook strength indicator " ) , & g_Config . m_ClNameplatesStrong , & Section , LineSize ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Button , & Section ) ;
2022-06-26 22:38:49 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClShowDirection , Localize ( " Show other players' key presses " ) , g_Config . m_ClShowDirection > = 1 , & Button ) )
{
g_Config . m_ClShowDirection = g_Config . m_ClShowDirection > = 1 ? 0 : 1 ;
}
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Button , & Section ) ;
2022-06-26 22:38:49 +00:00
static int s_ShowLocalPlayer = 0 ;
if ( DoButton_CheckBox ( & s_ShowLocalPlayer , Localize ( " Show local player's key presses " ) , g_Config . m_ClShowDirection = = 2 , & Button ) )
{
g_Config . m_ClShowDirection = g_Config . m_ClShowDirection ! = 2 ? 2 : 1 ;
}
}
else if ( s_CurTab = = APPEARANCE_TAB_HOOK_COLLISION )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// ***** Hookline ***** //
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Hook collision line " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// General hookline settings
LeftView . HSplitTop ( SectionTotalMargin + 6 * LineSize + 3 * ColorPickerLineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Button , & Section ) ;
2022-06-26 22:38:49 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClShowHookCollOther , Localize ( " Show other players' hook collision lines " ) , g_Config . m_ClShowHookCollOther , & Button ) )
{
g_Config . m_ClShowHookCollOther = g_Config . m_ClShowHookCollOther > = 1 ? 0 : 1 ;
}
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
Section . HSplitTop ( LineSize , & Button , & Section ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Hook collision line width " ) , g_Config . m_ClHookCollSize ) ;
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
g_Config . m_ClHookCollSize = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClHookCollSize , & Button , g_Config . m_ClHookCollSize / 20.0f ) * 20.0f ) ;
}
{
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
Section . HSplitTop ( LineSize , & Button , & Section ) ;
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i%% " , Localize ( " Hook collision line opacity " ) , g_Config . m_ClHookCollAlpha ) ;
UI ( ) - > DoLabel ( & Label , aBuf , 13.0f , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
g_Config . m_ClHookCollAlpha = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClHookCollAlpha , & Button , g_Config . m_ClHookCollAlpha / 100.0f ) * 100.0f ) ;
}
2022-07-16 13:32:06 +00:00
static CButtonContainer HookCollNoCollResetID , HookCollHookableCollResetID , HookCollTeeCollResetID , HookCollToolTop ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
Section . HSplitTop ( LineSize , & Label , & Section ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Colors of the hook collision line, in case of a possible collision with: " ) , 13.0f , TEXTALIGN_LEFT ) ;
GameClient ( ) - > m_Tooltips . DoToolTip ( & HookCollToolTop , & Label , Localize ( " Your movements are not taken into account when calculating the line colors " ) ) ;
DoLine_ColorPicker ( & HookCollNoCollResetID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Nothing hookable " ) , & g_Config . m_ClHookCollColorNoColl , ColorRGBA ( 1.0f , 0.0f , 0.0f , 1.0f ) , false ) ;
DoLine_ColorPicker ( & HookCollHookableCollResetID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Something hookable " ) , & g_Config . m_ClHookCollColorHookableColl , ColorRGBA ( 130.0f / 255.0f , 232.0f / 255.0f , 160.0f / 255.0f , 1.0f ) , false ) ;
DoLine_ColorPicker ( & HookCollTeeCollResetID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " A Tee " ) , & g_Config . m_ClHookCollColorTeeColl , ColorRGBA ( 1.0f , 1.0f , 0.0f , 1.0f ) , false ) ;
2022-06-26 22:38:49 +00:00
}
else if ( s_CurTab = = APPEARANCE_TAB_KILL_MESSAGES )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// ***** Kill Messages ***** //
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Kill Messages " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// General kill messages settings
LeftView . HSplitTop ( SectionTotalMargin + 2 * ColorPickerLineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-26 22:38:49 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer KillMessageNormalColorID , KillMessageHighlightColorID ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
DoLine_ColorPicker ( & KillMessageNormalColorID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Normal Color " ) , & g_Config . m_ClKillMessageNormalColor , ColorRGBA ( 1.0f , 1.0f , 1.0f ) , false ) ;
DoLine_ColorPicker ( & KillMessageHighlightColorID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Highlight Color " ) , & g_Config . m_ClKillMessageHighlightColor , ColorRGBA ( 1.0f , 1.0f , 1.0f ) , false ) ;
2022-06-26 22:38:49 +00:00
}
else if ( s_CurTab = = APPEARANCE_TAB_LASER )
{
2022-06-30 12:17:07 +00:00
MainView . VSplitMid ( & LeftView , & RightView ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// ***** Laser ***** //
LeftView . HSplitTop ( HeadlineAndVMargin , & Label , & LeftView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Laser " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
// General laser settings
LeftView . HSplitTop ( SectionTotalMargin + 2 * ColorPickerLineSize , & Section , & LeftView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-26 22:38:49 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer LaserOutResetID , LaserInResetID ;
2022-06-26 22:38:49 +00:00
2022-06-30 15:04:29 +00:00
ColorHSLA LaserOutlineColor = DoLine_ColorPicker ( & LaserOutResetID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Laser Outline Color " ) , & g_Config . m_ClLaserOutlineColor , ColorRGBA ( 0.074402f , 0.074402f , 0.247166f , 1.0f ) , false ) ;
2022-06-30 12:17:07 +00:00
ColorHSLA LaserInnerColor = DoLine_ColorPicker ( & LaserInResetID , ColorPickerLineSize , LeftViewColorPickerPosition , ColorPickerLabelSize , ColorPickerLineSpacing , & Section , Localize ( " Laser Inner Color " ) , & g_Config . m_ClLaserInnerColor , ColorRGBA ( 0.498039f , 0.498039f , 1.0f , 1.0f ) , false ) ;
2022-06-26 22:38:49 +00:00
// ***** Laser Preview ***** //
2022-06-30 12:17:07 +00:00
RightView . HSplitTop ( HeadlineAndVMargin , & Label , & RightView ) ;
UI ( ) - > DoLabel ( & Label , Localize ( " Preview " ) , HeadlineFontSize , TEXTALIGN_LEFT ) ;
2022-06-26 22:38:49 +00:00
2022-06-30 12:17:07 +00:00
RightView . HSplitTop ( SectionTotalMargin + 50.0f , & Section , & RightView ) ;
Section . Margin ( SectionMargin , & Section ) ;
2022-06-26 22:38:49 +00:00
DoLaserPreview ( & Section , LaserOutlineColor , LaserInnerColor ) ;
}
2014-07-07 13:47:11 +00:00
}
2016-05-07 13:59:13 +00:00
void CMenus : : RenderSettingsDDNet ( CUIRect MainView )
2014-07-07 13:47:11 +00:00
{
2015-08-27 07:10:13 +00:00
CUIRect Button , Left , Right , LeftLeft , Demo , Gameplay , Miscellaneous , Label , Background ;
2011-04-09 06:41:31 +00:00
2021-10-23 11:48:21 +00:00
bool CheckSettings = false ;
static int s_InpMouseOld = g_Config . m_InpMouseOld ;
2020-09-26 19:41:58 +00:00
MainView . HSplitTop ( 100.0f , & Demo , & MainView ) ;
2011-04-09 06:41:31 +00:00
2014-04-15 20:10:46 +00:00
Demo . HSplitTop ( 30.0f , & Label , & Demo ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Demo " ) , 20.0f , TEXTALIGN_LEFT ) ;
2014-04-15 20:10:46 +00:00
Demo . Margin ( 5.0f , & Demo ) ;
Demo . VSplitMid ( & Left , & Right ) ;
Left . VSplitRight ( 5.0f , & Left , 0 ) ;
Right . VMargin ( 5.0f , & Right ) ;
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAutoRaceRecord , Localize ( " Save the best demo of each race " ) , g_Config . m_ClAutoRaceRecord , & Button ) )
2011-04-17 17:14:49 +00:00
{
2014-04-15 20:10:46 +00:00
g_Config . m_ClAutoRaceRecord ^ = 1 ;
2011-04-17 17:14:49 +00:00
}
2013-08-30 07:50:05 +00:00
2019-05-20 21:55:40 +00:00
{
2019-05-21 21:59:57 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2022-03-05 09:22:50 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClReplays , Localize ( " Enable replays " ) , g_Config . m_ClReplays , & Button ) )
2019-05-21 15:21:53 +00:00
{
2019-06-05 17:17:55 +00:00
g_Config . m_ClReplays ^ = 1 ;
if ( ! g_Config . m_ClReplays )
2019-05-21 21:59:57 +00:00
{
// stop recording and remove the tmp demo file
Client ( ) - > DemoRecorder_Stop ( RECORDER_REPLAYS , true ) ;
}
else
{
// start recording
Client ( ) - > DemoRecorder_HandleAutoStart ( ) ;
}
2019-05-21 15:21:53 +00:00
}
2022-03-05 09:22:50 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
Button . VSplitLeft ( 140.0f , & Label , & Button ) ;
char aBuf [ 256 ] ;
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " Default length: %d " ) , g_Config . m_ClReplayLength ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2022-03-05 09:22:50 +00:00
int NewValue = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClReplayLength , & Button , ( minimum ( g_Config . m_ClReplayLength , 600 ) - 10 ) / 590.0f ) * 590.0f ) + 10 ;
if ( g_Config . m_ClReplayLength < 600 | | NewValue < 600 )
g_Config . m_ClReplayLength = minimum ( NewValue , 600 ) ;
2019-05-20 21:55:40 +00:00
}
2014-04-15 20:10:46 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClRaceGhost , Localize ( " Ghost " ) , g_Config . m_ClRaceGhost , & Button ) )
2013-10-09 14:02:23 +00:00
{
2014-04-15 20:10:46 +00:00
g_Config . m_ClRaceGhost ^ = 1 ;
2013-10-09 14:02:23 +00:00
}
2022-04-28 14:46:18 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & g_Config . m_ClRaceGhost , & Button , Localize ( " When you cross the start line, show a ghost tee replicating the movements of your best time " ) ) ;
2013-10-09 14:02:23 +00:00
2014-12-14 16:16:44 +00:00
if ( g_Config . m_ClRaceGhost )
2013-10-15 16:08:06 +00:00
{
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClRaceShowGhost , Localize ( " Show ghost " ) , g_Config . m_ClRaceShowGhost , & Button ) )
{
g_Config . m_ClRaceShowGhost ^ = 1 ;
}
2013-10-15 16:08:06 +00:00
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClRaceSaveGhost , Localize ( " Save ghost " ) , g_Config . m_ClRaceSaveGhost , & Button ) )
{
g_Config . m_ClRaceSaveGhost ^ = 1 ;
}
2013-11-02 02:09:56 +00:00
}
2020-10-02 14:16:16 +00:00
MainView . HSplitTop ( 330.0f , & Gameplay , & MainView ) ;
2014-04-15 20:10:46 +00:00
Gameplay . HSplitTop ( 30.0f , & Label , & Gameplay ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Gameplay " ) , 20.0f , TEXTALIGN_LEFT ) ;
2014-04-15 20:10:46 +00:00
Gameplay . Margin ( 5.0f , & Gameplay ) ;
Gameplay . VSplitMid ( & Left , & Right ) ;
Left . VSplitRight ( 5.0f , & Left , 0 ) ;
Right . VMargin ( 5.0f , & Right ) ;
2013-11-02 02:09:56 +00:00
{
2014-05-01 15:44:35 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2014-05-01 16:17:39 +00:00
Button . VSplitLeft ( 120.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Overlay entities " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClOverlayEntities = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClOverlayEntities , & Button , g_Config . m_ClOverlayEntities / 100.0f ) * 100.0f ) ;
2013-11-02 02:09:56 +00:00
}
2019-10-02 11:54:52 +00:00
{
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
Button . VSplitMid ( & LeftLeft , & Button ) ;
Button . VSplitLeft ( 50.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Size " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClTextEntitiesSize = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClTextEntitiesSize , & Button , g_Config . m_ClTextEntitiesSize / 100.0f ) * 100.0f ) ;
2019-10-02 11:54:52 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClTextEntities , Localize ( " Show text entities " ) , g_Config . m_ClTextEntities , & LeftLeft ) )
{
g_Config . m_ClTextEntities ^ = 1 ;
}
}
2013-11-14 15:23:15 +00:00
{
2014-05-17 21:00:52 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2014-05-24 22:59:52 +00:00
Button . VSplitMid ( & LeftLeft , & Button ) ;
2015-01-03 02:13:21 +00:00
Button . VSplitLeft ( 50.0f , & Label , & Button ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Opacity " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClShowOthersAlpha = ( int ) ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClShowOthersAlpha , & Button , g_Config . m_ClShowOthersAlpha / 100.0f ) * 100.0f ) ;
2014-05-24 22:59:52 +00:00
2022-03-03 21:56:32 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClShowOthers , Localize ( " Show others " ) , g_Config . m_ClShowOthers = = SHOW_OTHERS_ON , & LeftLeft ) )
2014-05-24 22:59:52 +00:00
{
2022-03-03 21:56:32 +00:00
g_Config . m_ClShowOthers = g_Config . m_ClShowOthers ! = SHOW_OTHERS_ON ? SHOW_OTHERS_ON : SHOW_OTHERS_OFF ;
2014-05-24 22:59:52 +00:00
}
2022-04-18 07:34:05 +00:00
2022-05-14 09:05:31 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & g_Config . m_ClShowOthersAlpha , & Button , Localize ( " Adjust the opacity of entities belonging to other teams, such as tees and nameplates " ) ) ;
2013-11-14 15:23:15 +00:00
}
2020-06-28 08:20:07 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2021-05-17 07:11:36 +00:00
static int s_ShowOwnTeamID = 0 ;
2022-03-03 21:56:32 +00:00
if ( DoButton_CheckBox ( & s_ShowOwnTeamID , Localize ( " Show others (own team only) " ) , g_Config . m_ClShowOthers = = SHOW_OTHERS_ONLY_TEAM , & Button ) )
2020-06-28 08:20:07 +00:00
{
2022-03-03 21:56:32 +00:00
g_Config . m_ClShowOthers = g_Config . m_ClShowOthers ! = SHOW_OTHERS_ONLY_TEAM ? SHOW_OTHERS_ONLY_TEAM : SHOW_OTHERS_OFF ;
2020-06-28 08:20:07 +00:00
}
2014-04-15 20:10:46 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2014-04-26 18:29:42 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClShowQuads , Localize ( " Show quads " ) , g_Config . m_ClShowQuads , & Button ) )
2014-01-15 14:25:13 +00:00
{
2014-04-15 20:10:46 +00:00
g_Config . m_ClShowQuads ^ = 1 ;
2014-01-15 14:25:13 +00:00
}
2022-04-18 07:34:05 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & g_Config . m_ClShowQuads , & Button , Localize ( " Quads are used for background decoration " ) ) ;
2014-01-15 14:25:13 +00:00
2015-01-03 02:13:21 +00:00
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
Label . VSplitLeft ( 130.0f , & Label , & Button ) ;
2022-03-20 11:57:50 +00:00
char aBuf [ 256 ] ;
2015-01-03 02:13:21 +00:00
str_format ( aBuf , sizeof ( aBuf ) , " %s: %i " , Localize ( " Default zoom " ) , g_Config . m_ClDefaultZoom ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 18:54:22 +00:00
g_Config . m_ClDefaultZoom = static_cast < int > ( UIEx ( ) - > DoScrollbarH ( & g_Config . m_ClDefaultZoom , & Button , g_Config . m_ClDefaultZoom / 20.0f ) * 20.0f + 0.1f ) ;
2015-01-03 02:13:21 +00:00
2014-04-15 20:10:46 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2014-12-08 12:49:39 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClAntiPing , Localize ( " AntiPing " ) , g_Config . m_ClAntiPing , & Button ) )
2014-01-13 23:25:25 +00:00
{
2014-04-15 20:10:46 +00:00
g_Config . m_ClAntiPing ^ = 1 ;
2014-01-13 23:25:25 +00:00
}
2022-04-28 14:46:18 +00:00
GameClient ( ) - > m_Tooltips . DoToolTip ( & g_Config . m_ClAntiPing , & Button , Localize ( " Tries to predict other entities to give a feel of low latency " ) ) ;
2014-01-13 23:25:25 +00:00
2014-12-14 16:16:44 +00:00
if ( g_Config . m_ClAntiPing )
2014-03-21 13:01:14 +00:00
{
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAntiPingPlayers , Localize ( " AntiPing: predict other players " ) , g_Config . m_ClAntiPingPlayers , & Button ) )
{
g_Config . m_ClAntiPingPlayers ^ = 1 ;
}
2014-03-21 13:01:14 +00:00
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAntiPingWeapons , Localize ( " AntiPing: predict weapons " ) , g_Config . m_ClAntiPingWeapons , & Button ) )
{
g_Config . m_ClAntiPingWeapons ^ = 1 ;
}
2014-03-28 12:39:30 +00:00
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClAntiPingGrenade , Localize ( " AntiPing: predict grenade paths " ) , g_Config . m_ClAntiPingGrenade , & Button ) )
{
g_Config . m_ClAntiPingGrenade ^ = 1 ;
}
2014-05-06 14:25:00 +00:00
}
2014-12-14 16:16:44 +00:00
else
2014-09-29 19:13:35 +00:00
{
2014-12-14 16:16:44 +00:00
Right . HSplitTop ( 60.0f , 0 , & Right ) ;
2014-09-29 19:13:35 +00:00
}
2020-09-30 08:17:17 +00:00
Right . HSplitTop ( 40.0f , 0 , & Right ) ;
2020-06-28 08:20:07 +00:00
2015-06-21 22:34:10 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
2016-05-07 13:59:13 +00:00
if ( DoButton_CheckBox ( & g_Config . m_InpMouseOld , Localize ( " Old mouse mode " ) , g_Config . m_InpMouseOld , & Button ) )
{
g_Config . m_InpMouseOld ^ = 1 ;
2021-10-23 11:48:21 +00:00
CheckSettings = true ;
2016-05-07 13:59:13 +00:00
}
2021-10-23 11:48:21 +00:00
if ( CheckSettings )
m_NeedRestartDDNet = s_InpMouseOld ! = g_Config . m_InpMouseOld ;
2014-04-15 20:10:46 +00:00
Left . HSplitTop ( 5.0f , & Button , & Left ) ;
2020-12-16 04:55:41 +00:00
Left . VSplitRight ( 10.0f , & Left , 0x0 ) ;
Right . VSplitLeft ( 10.0f , 0x0 , & Right ) ;
Left . HSplitTop ( 25.0f , 0x0 , & Left ) ;
2022-03-05 09:22:50 +00:00
CUIRect TempLabel ;
2020-12-18 20:28:33 +00:00
Left . HSplitTop ( 25.0f , & TempLabel , & Left ) ;
Left . HSplitTop ( 5.0f , 0x0 , & Left ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & TempLabel , Localize ( " Background " ) , 20.0f , TEXTALIGN_LEFT ) ;
2020-12-18 20:28:33 +00:00
2020-12-16 04:55:41 +00:00
Right . HSplitTop ( 25.0f , & TempLabel , & Right ) ;
2020-12-18 20:28:33 +00:00
Right . HSplitTop ( 5.0f , 0x0 , & Miscellaneous ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & TempLabel , Localize ( " Miscellaneous " ) , 20.0f , TEXTALIGN_LEFT ) ;
2013-08-30 07:50:05 +00:00
2022-07-16 13:32:06 +00:00
static CButtonContainer ResetID1 ;
static CButtonContainer ResetID2 ;
2020-12-16 04:55:41 +00:00
ColorRGBA GreyDefault ( 0.5f , 0.5f , 0.5f , 1 ) ;
2020-12-18 20:28:33 +00:00
DoLine_ColorPicker ( & ResetID2 , 25.0f , 194.0f , 13.0f , 5.0f , & Left , Localize ( " Entities Background color " ) , & g_Config . m_ClBackgroundEntitiesColor , GreyDefault , false ) ;
2016-05-03 22:24:54 +00:00
2020-12-18 20:35:22 +00:00
Left . VSplitLeft ( 5.0f , 0x0 , & Left ) ;
Left . HSplitTop ( 25.0f , & Background , & Left ) ;
Background . HSplitTop ( 20.0f , & Background , 0 ) ;
Background . VSplitLeft ( 100.0f , & Label , & TempLabel ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Map " ) , 14.0f , TEXTALIGN_LEFT ) ;
2021-12-03 19:15:44 +00:00
static float s_Map = 0.0f ;
UIEx ( ) - > DoEditBox ( g_Config . m_ClBackgroundEntities , & TempLabel , g_Config . m_ClBackgroundEntities , sizeof ( g_Config . m_ClBackgroundEntities ) , 14.0f , & s_Map ) ;
2020-10-02 14:16:16 +00:00
2020-12-18 20:35:22 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
bool UseCurrentMap = str_comp ( g_Config . m_ClBackgroundEntities , CURRENT_MAP ) = = 0 ;
2021-05-17 07:11:36 +00:00
static int s_UseCurrentMapID = 0 ;
if ( DoButton_CheckBox ( & s_UseCurrentMapID , Localize ( " Use current map as background " ) , UseCurrentMap , & Button ) )
2020-12-18 20:35:22 +00:00
{
if ( UseCurrentMap )
g_Config . m_ClBackgroundEntities [ 0 ] = ' \0 ' ;
else
2022-07-09 16:14:56 +00:00
str_copy ( g_Config . m_ClBackgroundEntities , CURRENT_MAP ) ;
2015-08-27 07:10:13 +00:00
}
2016-05-03 22:24:54 +00:00
2020-12-18 20:35:22 +00:00
Left . HSplitTop ( 20.0f , & Button , & Left ) ;
if ( DoButton_CheckBox ( & g_Config . m_ClBackgroundShowTilesLayers , Localize ( " Show tiles layers from BG map " ) , g_Config . m_ClBackgroundShowTilesLayers , & Button ) )
g_Config . m_ClBackgroundShowTilesLayers ^ = 1 ;
2014-05-24 19:46:42 +00:00
2020-12-18 20:28:33 +00:00
Miscellaneous . HSplitTop ( 25.0f , & Button , & Right ) ;
DoLine_ColorPicker ( & ResetID1 , 25.0f , 194.0f , 13.0f , 5.0f , & Button , Localize ( " Regular Background Color " ) , & g_Config . m_ClBackgroundColor , GreyDefault , false ) ;
Right . HSplitTop ( 5.0f , 0x0 , & Right ) ;
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
2015-01-19 23:21:28 +00:00
if ( DoButton_CheckBox ( & g_Config . m_ClHttpMapDownload , Localize ( " Try fast HTTP map download first " ) , g_Config . m_ClHttpMapDownload , & Button ) )
g_Config . m_ClHttpMapDownload ^ = 1 ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ButtonTimeout ;
2020-12-18 20:35:22 +00:00
Right . HSplitTop ( 10.0f , 0x0 , & Right ) ;
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
if ( DoButton_Menu ( & s_ButtonTimeout , Localize ( " New random timeout code " ) , 0 , & Button ) )
2020-12-18 20:28:33 +00:00
{
2020-12-18 20:35:22 +00:00
Client ( ) - > GenerateTimeoutSeed ( ) ;
2020-12-18 20:28:33 +00:00
}
2021-11-23 15:39:59 +00:00
static float s_RunOnJoin = 0.0f ;
Right . HSplitTop ( 5.0f , 0 , & Right ) ;
2022-03-05 09:22:50 +00:00
Right . HSplitTop ( 20.0f , & Label , & Right ) ;
Label . VSplitLeft ( 5.0f , 0 , & Label ) ;
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , Localize ( " Run on join " ) , 14.0f , TEXTALIGN_LEFT ) ;
2022-03-05 09:22:50 +00:00
Right . HSplitTop ( 20.0f , & Button , & Right ) ;
Button . VSplitLeft ( 5.0f , 0 , & Button ) ;
2022-03-13 18:09:33 +00:00
SUIExEditBoxProperties EditProps ;
EditProps . m_pEmptyText = Localize ( " Chat command (e.g. showall 1) " ) ;
UIEx ( ) - > DoEditBox ( g_Config . m_ClRunOnJoin , & Button , g_Config . m_ClRunOnJoin , sizeof ( g_Config . m_ClRunOnJoin ) , 14.0f , & s_RunOnJoin , false , CUI : : CORNER_ALL , EditProps ) ;
2020-12-18 20:35:22 +00:00
// Updater
2018-12-04 16:59:42 +00:00
# if defined(CONF_AUTOUPDATE)
2015-03-05 21:09:14 +00:00
{
2020-12-18 20:28:33 +00:00
MainView . VSplitMid ( & Left , & Right ) ;
Left . w + = 20.0f ;
2021-11-23 15:39:59 +00:00
Left . HSplitBottom ( 20.0f , 0x0 , & Label ) ;
2015-03-05 21:09:14 +00:00
bool NeedUpdate = str_comp ( Client ( ) - > LatestVersion ( ) , " 0 " ) ;
2015-04-18 19:17:27 +00:00
int State = Updater ( ) - > GetCurrentState ( ) ;
2015-03-08 17:51:13 +00:00
2017-09-03 15:36:51 +00:00
// Update Button
2015-04-18 19:17:27 +00:00
if ( NeedUpdate & & State < = IUpdater : : CLEAN )
2015-03-05 21:09:14 +00:00
{
2015-06-26 18:44:55 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " DDNet %s is available: " ) , Client ( ) - > LatestVersion ( ) ) ;
2020-07-15 19:10:13 +00:00
Label . VSplitLeft ( TextRender ( ) - > TextWidth ( 0 , 14.0f , aBuf , - 1 , - 1.0f ) + 10.0f , & Label , & Button ) ;
2015-03-13 15:49:52 +00:00
Button . VSplitLeft ( 100.0f , & Button , 0 ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ButtonUpdate ;
2020-12-18 20:35:22 +00:00
if ( DoButton_Menu ( & s_ButtonUpdate , Localize ( " Update now " ) , 0 , & Button ) )
2020-12-18 20:28:33 +00:00
{
2015-04-18 19:17:27 +00:00
Updater ( ) - > InitiateUpdate ( ) ;
2020-12-18 20:28:33 +00:00
}
2015-03-05 21:09:14 +00:00
}
2015-04-18 19:17:27 +00:00
else if ( State > = IUpdater : : GETTING_MANIFEST & & State < IUpdater : : NEED_RESTART )
2015-06-26 18:44:55 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " Updating... " ) ) ;
2017-03-04 14:43:49 +00:00
else if ( State = = IUpdater : : NEED_RESTART )
{
2015-06-26 18:44:55 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " DDNet Client updated! " ) ) ;
2015-03-08 17:51:13 +00:00
m_NeedRestartUpdate = true ;
}
2015-03-05 21:09:14 +00:00
else
2015-03-14 09:45:11 +00:00
{
2015-06-26 18:44:55 +00:00
str_format ( aBuf , sizeof ( aBuf ) , Localize ( " No updates available " ) ) ;
2020-07-15 19:10:13 +00:00
Label . VSplitLeft ( TextRender ( ) - > TextWidth ( 0 , 14.0f , aBuf , - 1 , - 1.0f ) + 10.0f , & Label , & Button ) ;
2015-03-14 09:45:11 +00:00
Button . VSplitLeft ( 100.0f , & Button , 0 ) ;
2022-07-16 13:32:06 +00:00
static CButtonContainer s_ButtonUpdate ;
2015-06-26 18:44:55 +00:00
if ( DoButton_Menu ( & s_ButtonUpdate , Localize ( " Check now " ) , 0 , & Button ) )
2015-03-14 09:45:11 +00:00
{
2017-09-03 15:36:51 +00:00
Client ( ) - > RequestDDNetInfo ( ) ;
2015-03-14 09:45:11 +00:00
}
}
2022-06-12 08:34:09 +00:00
UI ( ) - > DoLabel ( & Label , aBuf , 14.0f , TEXTALIGN_LEFT ) ;
2015-03-08 17:51:13 +00:00
TextRender ( ) - > TextColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
2015-03-05 21:09:14 +00:00
}
2015-03-13 14:13:19 +00:00
# endif
2011-04-09 06:41:31 +00:00
}