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. */
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <base/math.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <engine/graphics.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>
|
|
|
|
#include <engine/shared/config.h>
|
2010-09-16 11:32:56 +00:00
|
|
|
#include <engine/shared/linereader.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/generated/protocol.h>
|
|
|
|
#include <game/generated/client_data.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include <game/client/ui.h>
|
|
|
|
#include <game/client/render.h>
|
|
|
|
#include <game/client/gameclient.h>
|
|
|
|
#include <game/client/animstate.h>
|
|
|
|
#include <game/localization.h>
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
#include "binds.h"
|
|
|
|
#include "menus.h"
|
|
|
|
#include "skins.h"
|
2008-08-27 15:48:50 +00:00
|
|
|
|
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;
|
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
|
|
|
{
|
2010-09-12 11:40:24 +00:00
|
|
|
if(Event.m_Flags&IInput::FLAG_PRESS)
|
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;
|
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;
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMenus::RenderSettingsPlayer(CUIRect MainView)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button;
|
|
|
|
CUIRect LeftView, RightView;
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
MainView.VSplitMid(&LeftView, &RightView);
|
2010-05-29 07:25:38 +00:00
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
|
|
|
// render settings
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Name"));
|
|
|
|
UI()->DoLabel(&Button, aBuf, 14.0, -1);
|
|
|
|
Button.VSplitLeft(80.0f, 0, &Button);
|
|
|
|
Button.VSplitLeft(180.0f, &Button, 0);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
|
|
|
if(DoEditBox(g_Config.m_PlayerName, &Button, g_Config.m_PlayerName, sizeof(g_Config.m_PlayerName), 14.0f, &Offset))
|
2010-05-29 07:25:38 +00:00
|
|
|
m_NeedSendinfo = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2009-06-15 08:15:53 +00:00
|
|
|
// extra spacing
|
2010-05-29 07:25:38 +00:00
|
|
|
LeftView.HSplitTop(10.0f, 0, &LeftView);
|
2009-06-15 08:15:53 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_DynamicCameraButton = 0;
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
if(DoButton_CheckBox(&s_DynamicCameraButton, Localize("Dynamic Camera"), g_Config.m_ClMouseDeadzone != 0, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
if(g_Config.m_ClMouseDeadzone)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_ClMouseFollowfactor = 0;
|
|
|
|
g_Config.m_ClMouseMaxDistance = 400;
|
|
|
|
g_Config.m_ClMouseDeadzone = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_ClMouseFollowfactor = 60;
|
|
|
|
g_Config.m_ClMouseMaxDistance = 1000;
|
|
|
|
g_Config.m_ClMouseDeadzone = 300;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_ClAutoswitchWeapons, Localize("Switch weapon on pickup"), g_Config.m_ClAutoswitchWeapons, &Button))
|
|
|
|
g_Config.m_ClAutoswitchWeapons ^= 1;
|
|
|
|
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_ClNameplates, Localize("Show name plates"), g_Config.m_ClNameplates, &Button))
|
|
|
|
g_Config.m_ClNameplates ^= 1;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2011-01-04 12:11:01 +00:00
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
if(g_Config.m_ClNameplates)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
Button.VSplitLeft(15.0f, 0, &Button);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_ClNameplatesAlways, Localize("Always show name plates"), g_Config.m_ClNameplatesAlways, &Button))
|
|
|
|
g_Config.m_ClNameplatesAlways ^= 1;
|
2011-01-04 12:11:01 +00:00
|
|
|
|
|
|
|
// draw nameplates size slider
|
|
|
|
CUIRect Label;
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
Button.VSplitLeft(15.0f, 0, &Button);
|
|
|
|
Button.VSplitRight(10.0f, &Button, 0);
|
|
|
|
Button.VSplitLeft(140.0f, &Label, &Button);
|
|
|
|
Button.HMargin(2.0f, &Button);
|
|
|
|
UI()->DoLabel(&Label, Localize("Name plates size"), 13.0f, -1);
|
|
|
|
g_Config.m_ClNameplatesSize = (int)(DoScrollbarH(&g_Config.m_ClNameplatesSize, &Button, g_Config.m_ClNameplatesSize/100.0f)*100.0f+0.1f);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2011-01-04 12:11:01 +00:00
|
|
|
else
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(max(0, m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin)));
|
|
|
|
|
|
|
|
CTeeRenderInfo OwnSkinInfo;
|
|
|
|
OwnSkinInfo.m_Texture = pOwnSkin->m_OrgTexture;
|
|
|
|
OwnSkinInfo.m_ColorBody = vec4(1, 1, 1, 1);
|
|
|
|
OwnSkinInfo.m_ColorFeet = vec4(1, 1, 1, 1);
|
|
|
|
|
|
|
|
if(g_Config.m_PlayerUseCustomColor)
|
|
|
|
{
|
2010-11-24 00:11:56 +00:00
|
|
|
OwnSkinInfo.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);
|
|
|
|
OwnSkinInfo.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);
|
2010-05-29 07:25:38 +00:00
|
|
|
OwnSkinInfo.m_Texture = pOwnSkin->m_ColorTexture;
|
|
|
|
}
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
OwnSkinInfo.m_Size = 50.0f*UI()->Scale();
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s:", Localize("Your skin"));
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Button, aBuf, 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
CUIRect SkinRect;
|
2010-12-14 00:20:47 +00:00
|
|
|
LeftView.VSplitLeft(LeftView.w/1.2f/UI()->Scale(), &SkinRect, 0);
|
2010-05-29 07:25:38 +00:00
|
|
|
SkinRect.HSplitTop(50.0f, &SkinRect, 0);
|
|
|
|
RenderTools()->DrawUIRect(&SkinRect, vec4(1, 1, 1, 0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
|
|
|
|
Button.VSplitLeft(30.0f, 0, &Button);
|
|
|
|
Button.HSplitTop(50.0f, 0, &Button);
|
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Button.x, Button.y));
|
|
|
|
|
|
|
|
LeftView.HSplitTop(20.0f, &Button, &LeftView);
|
|
|
|
Button.HSplitTop(15.0f, 0, &Button);
|
|
|
|
Button.VSplitLeft(100.0f, 0, &Button);
|
|
|
|
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s", g_Config.m_PlayerSkin);
|
2010-08-07 18:52:33 +00:00
|
|
|
CTextCursor Cursor;
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->SetCursor(&Cursor, Button.x, Button.y, 14.0f*UI()->Scale(), TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END);
|
2010-08-07 18:52:33 +00:00
|
|
|
Cursor.m_LineWidth = SkinRect.w-(Button.x-SkinRect.x)-5.0f;
|
|
|
|
TextRender()->TextEx(&Cursor, aBuf, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
RightView.HSplitTop(20.0f, &Button, &RightView);
|
|
|
|
RightView.HSplitTop(20.0f, &Button, &RightView);
|
|
|
|
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_PlayerColorBody, Localize("Custom colors"), g_Config.m_PlayerUseCustomColor, &Button))
|
2008-10-20 23:38:23 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_PlayerUseCustomColor = g_Config.m_PlayerUseCustomColor?0:1;
|
|
|
|
m_NeedSendinfo = true;
|
2008-10-20 23:38:23 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
if(g_Config.m_PlayerUseCustomColor)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
int *paColors[2];
|
|
|
|
paColors[0] = &g_Config.m_PlayerColorBody;
|
|
|
|
paColors[1] = &g_Config.m_PlayerColorFeet;
|
|
|
|
|
|
|
|
const char *paParts[] = {
|
|
|
|
Localize("Body"),
|
|
|
|
Localize("Feet")};
|
|
|
|
const char *paLabels[] = {
|
|
|
|
Localize("Hue"),
|
|
|
|
Localize("Sat."),
|
|
|
|
Localize("Lht.")};
|
|
|
|
static int s_aColorSlider[2][3] = {{0}};
|
2008-08-27 15:48:50 +00:00
|
|
|
//static float v[2][3] = {{0, 0.5f, 0.25f}, {0, 0.5f, 0.25f}};
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
for(int i = 0; i < 2; i++)
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Text;
|
|
|
|
RightView.HSplitTop(20.0f, &Text, &RightView);
|
|
|
|
Text.VSplitLeft(15.0f, 0, &Text);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Text, paParts[i], 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
int PrevColor = *paColors[i];
|
|
|
|
int Color = 0;
|
2008-08-27 15:48:50 +00:00
|
|
|
for(int s = 0; s < 3; s++)
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Text;
|
|
|
|
RightView.HSplitTop(19.0f, &Button, &RightView);
|
|
|
|
Button.VSplitLeft(30.0f, 0, &Button);
|
|
|
|
Button.VSplitLeft(70.0f, &Text, &Button);
|
|
|
|
Button.VSplitRight(5.0f, &Button, 0);
|
|
|
|
Button.HSplitTop(4.0f, 0, &Button);
|
|
|
|
|
|
|
|
float k = ((PrevColor>>((2-s)*8))&0xff) / 255.0f;
|
|
|
|
k = DoScrollbarH(&s_aColorSlider[i][s], &Button, k);
|
|
|
|
Color <<= 8;
|
|
|
|
Color += clamp((int)(k*255), 0, 255);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Text, paLabels[s], 15.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
if(*paColors[i] != Color)
|
|
|
|
m_NeedSendinfo = true;
|
|
|
|
|
|
|
|
*paColors[i] = Color;
|
|
|
|
RightView.HSplitTop(5.0f, 0, &RightView);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
MainView.HSplitTop(MainView.h/2, 0, &MainView);
|
|
|
|
|
2009-10-27 14:38:53 +00:00
|
|
|
// render skinselector
|
2010-09-24 11:21:03 +00:00
|
|
|
static bool s_InitSkinlist = true;
|
|
|
|
static sorted_array<const CSkins::CSkin *> s_paSkinList;
|
2010-05-29 07:25:38 +00:00
|
|
|
static float s_ScrollValue = 0;
|
2010-09-24 11:21:03 +00:00
|
|
|
if(s_InitSkinlist)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
2010-09-24 11:21:03 +00:00
|
|
|
s_paSkinList.clear();
|
|
|
|
for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i)
|
2010-05-29 07:25:38 +00:00
|
|
|
{
|
|
|
|
const CSkins::CSkin *s = m_pClient->m_pSkins->Get(i);
|
|
|
|
// no special skins
|
|
|
|
if(s->m_aName[0] == 'x' && s->m_aName[1] == '_')
|
|
|
|
continue;
|
2010-09-24 11:21:03 +00:00
|
|
|
s_paSkinList.add(s);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2010-09-24 11:21:03 +00:00
|
|
|
s_InitSkinlist = false;
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2009-10-27 14:38:53 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
int OldSelected = -1;
|
2010-09-24 11:21:03 +00:00
|
|
|
UiDoListboxStart(&s_InitSkinlist, &MainView, 50.0f, Localize("Skins"), "", s_paSkinList.size(), 4, OldSelected, s_ScrollValue);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-09-24 11:21:03 +00:00
|
|
|
for(int i = 0; i < s_paSkinList.size(); ++i)
|
2009-10-27 14:38:53 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const CSkins::CSkin *s = s_paSkinList[i];
|
|
|
|
if(s == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(str_comp(s->m_aName, g_Config.m_PlayerSkin) == 0)
|
|
|
|
OldSelected = i;
|
|
|
|
|
|
|
|
CListboxItem Item = UiDoListboxNextItem(&s_paSkinList[i], OldSelected == i);
|
|
|
|
if(Item.m_Visible)
|
2009-10-27 14:38:53 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CTeeRenderInfo Info;
|
|
|
|
Info.m_Texture = s->m_OrgTexture;
|
|
|
|
Info.m_ColorBody = vec4(1, 1, 1, 1);
|
|
|
|
Info.m_ColorFeet = vec4(1, 1, 1, 1);
|
|
|
|
|
|
|
|
if(g_Config.m_PlayerUseCustomColor)
|
2009-10-27 14:38:53 +00:00
|
|
|
{
|
2010-11-24 00:11:56 +00:00
|
|
|
Info.m_ColorBody = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorBody);
|
|
|
|
Info.m_ColorFeet = m_pClient->m_pSkins->GetColorV4(g_Config.m_PlayerColorFeet);
|
2010-05-29 07:25:38 +00:00
|
|
|
Info.m_Texture = s->m_ColorTexture;
|
2009-10-27 14:38:53 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
Info.m_Size = UI()->Scale()*50.0f;
|
|
|
|
Item.m_Rect.HSplitTop(5.0f, 0, &Item.m_Rect); // some margin from the top
|
|
|
|
RenderTools()->RenderTee(CAnimState::GetIdle(), &Info, 0, vec2(1, 0), vec2(Item.m_Rect.x+Item.m_Rect.w/2, Item.m_Rect.y+Item.m_Rect.h/2));
|
|
|
|
|
|
|
|
if(g_Config.m_Debug)
|
2009-10-27 14:38:53 +00:00
|
|
|
{
|
2010-11-24 00:11:56 +00:00
|
|
|
vec3 BloodColor = g_Config.m_PlayerUseCustomColor ? m_pClient->m_pSkins->GetColorV3(g_Config.m_PlayerColorBody) : s->m_BloodColor;
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->TextureSet(-1);
|
|
|
|
Graphics()->QuadsBegin();
|
2010-11-24 00:11:56 +00:00
|
|
|
Graphics()->SetColor(BloodColor.r, BloodColor.g, BloodColor.b, 1.0f);
|
2010-05-29 07:25:38 +00:00
|
|
|
IGraphics::CQuadItem QuadItem(Item.m_Rect.x, Item.m_Rect.y, 12, 12);
|
|
|
|
Graphics()->QuadsDrawTL(&QuadItem, 1);
|
2009-10-27 14:38:53 +00:00
|
|
|
Graphics()->QuadsEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-10-20 23:38:23 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0);
|
|
|
|
if(OldSelected != NewSelected)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
mem_copy(g_Config.m_PlayerSkin, s_paSkinList[NewSelected]->m_aName, sizeof(g_Config.m_PlayerSkin));
|
|
|
|
m_NeedSendinfo = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
typedef void (*pfnAssignFuncCallback)(CConfiguration *pConfig, int Value);
|
2008-08-27 15:48:50 +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;
|
|
|
|
} CKeyInfo;
|
2008-10-05 18:27:20 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
static CKeyInfo gs_aKeys[] =
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-31 11:07:58 +00:00
|
|
|
{ "Move left", "+left", 0}, // Localize - these strings are localized within CLocConstString
|
|
|
|
{ "Move right", "+right", 0 },
|
|
|
|
{ "Jump", "+jump", 0 },
|
|
|
|
{ "Fire", "+fire", 0 },
|
|
|
|
{ "Hook", "+hook", 0 },
|
|
|
|
{ "Hammer", "+weapon1", 0 },
|
|
|
|
{ "Pistol", "+weapon2", 0 },
|
|
|
|
{ "Shotgun", "+weapon3", 0 },
|
|
|
|
{ "Grenade", "+weapon4", 0 },
|
|
|
|
{ "Rifle", "+weapon5", 0 },
|
|
|
|
{ "Next weapon", "+nextweapon", 0 },
|
|
|
|
{ "Prev. weapon", "+prevweapon", 0 },
|
|
|
|
{ "Vote yes", "vote yes", 0 },
|
|
|
|
{ "Vote no", "vote no", 0 },
|
|
|
|
{ "Chat", "chat all", 0 },
|
|
|
|
{ "Team chat", "chat team", 0 },
|
|
|
|
{ "Show chat", "+show_chat", 0 },
|
|
|
|
{ "Emoticon", "+emote", 0 },
|
|
|
|
{ "Console", "toggle_local_console", 0 },
|
|
|
|
{ "Remote console", "toggle_remote_console", 0 },
|
|
|
|
{ "Screenshot", "screenshot", 0 },
|
|
|
|
{ "Scoreboard", "+scoreboard", 0 },
|
2008-10-05 18:27:20 +00:00
|
|
|
};
|
2010-08-08 22:35:37 +00:00
|
|
|
/* This is for scripts/update_localization.py to work, don't remove!
|
|
|
|
Localize("Move left");Localize("Move right");Localize("Jump");Localize("Fire");Localize("Hook");Localize("Hammer");
|
|
|
|
Localize("Pistol");Localize("Shotgun");Localize("Grenade");Localize("Rifle");Localize("Next weapon");Localize("Prev. weapon");
|
|
|
|
Localize("Vote yes");Localize("Vote no");Localize("Chat");Localize("Team chat");Localize("Show chat");Localize("Emoticon");
|
|
|
|
Localize("Console");Localize("Remote console");Localize("Screenshot");Localize("Scoreboard");
|
|
|
|
*/
|
2008-10-05 18:27:20 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
const int g_KeyCount = sizeof(gs_aKeys) / sizeof(CKeyInfo);
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View)
|
2008-10-05 18:27:20 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +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);
|
|
|
|
Button.VSplitLeft(130.0f, &Label, &Button);
|
|
|
|
|
|
|
|
char aBuf[64];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s:", (const char *)Key.m_Name);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Label, aBuf, 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
int OldId = Key.m_KeyId;
|
|
|
|
int NewId = DoKeyReader((void *)&gs_aKeys[i].m_Name, &Button, OldId);
|
|
|
|
if(NewId != OldId)
|
2008-10-05 18:27:20 +00:00
|
|
|
{
|
2010-09-12 15:15:09 +00:00
|
|
|
if(OldId != 0 || NewId == 0)
|
|
|
|
m_pClient->m_pBinds->Bind(OldId, "");
|
|
|
|
if(NewId != 0)
|
|
|
|
m_pClient->m_pBinds->Bind(NewId, gs_aKeys[i].m_pCommand);
|
2008-10-05 18:27:20 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
View.HSplitTop(5.0f, 0, &View);
|
2008-10-05 18:27:20 +00:00
|
|
|
}
|
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
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
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < g_KeyCount; i++)
|
|
|
|
gs_aKeys[i].m_KeyId = 0;
|
|
|
|
|
|
|
|
for(int KeyId = 0; KeyId < KEY_LAST; KeyId++)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const char *pBind = m_pClient->m_pBinds->Get(KeyId);
|
|
|
|
if(!pBind[0])
|
2008-08-27 15:48:50 +00:00
|
|
|
continue;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
for(int i = 0; i < g_KeyCount; i++)
|
|
|
|
if(str_comp(pBind, gs_aKeys[i].m_pCommand) == 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
gs_aKeys[i].m_KeyId = KeyId;
|
2008-08-27 15:48:50 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-10-05 18:27:20 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect MovementSettings, WeaponSettings, VotingSettings, ChatSettings, MiscSettings, ResetButton;
|
|
|
|
MainView.VSplitLeft(MainView.w/2-5.0f, &MovementSettings, &VotingSettings);
|
|
|
|
|
|
|
|
// movement settings
|
2008-10-05 15:59:36 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
MovementSettings.HSplitTop(MainView.h/2-5.0f, &MovementSettings, &WeaponSettings);
|
|
|
|
RenderTools()->DrawUIRect(&MovementSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
MovementSettings.Margin(10.0f, &MovementSettings);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->Text(0, MovementSettings.x, MovementSettings.y, 14.0f*UI()->Scale(), Localize("Movement"), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
MovementSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MovementSettings);
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button, Label;
|
|
|
|
MovementSettings.HSplitTop(20.0f, &Button, &MovementSettings);
|
|
|
|
Button.VSplitLeft(130.0f, &Label, &Button);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabel(&Label, Localize("Mouse sens."), 14.0f*UI()->Scale(), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
Button.HMargin(2.0f, &Button);
|
|
|
|
g_Config.m_InpMousesens = (int)(DoScrollbarH(&g_Config.m_InpMousesens, &Button, (g_Config.m_InpMousesens-5)/500.0f)*500.0f)+5;
|
|
|
|
//*key.key = ui_do_key_reader(key.key, &Button, *key.key);
|
|
|
|
MovementSettings.HSplitTop(20.0f, 0, &MovementSettings);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
UiDoGetButtons(0, 5, MovementSettings);
|
2008-10-05 18:27:20 +00:00
|
|
|
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
WeaponSettings.HSplitTop(10.0f, 0, &WeaponSettings);
|
|
|
|
RenderTools()->DrawUIRect(&WeaponSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
WeaponSettings.Margin(10.0f, &WeaponSettings);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->Text(0, WeaponSettings.x, WeaponSettings.y, 14.0f*UI()->Scale(), Localize("Weapon"), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
WeaponSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &WeaponSettings);
|
|
|
|
UiDoGetButtons(5, 12, WeaponSettings);
|
2008-10-05 18:27:20 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// voting settings
|
2008-10-05 18:27:20 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
VotingSettings.VSplitLeft(10.0f, 0, &VotingSettings);
|
|
|
|
VotingSettings.HSplitTop(MainView.h/4-5.0f, &VotingSettings, &ChatSettings);
|
|
|
|
RenderTools()->DrawUIRect(&VotingSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
VotingSettings.Margin(10.0f, &VotingSettings);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->Text(0, VotingSettings.x, VotingSettings.y, 14.0f*UI()->Scale(), Localize("Voting"), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
VotingSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &VotingSettings);
|
|
|
|
UiDoGetButtons(12, 14, 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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
ChatSettings.HSplitTop(10.0f, 0, &ChatSettings);
|
|
|
|
ChatSettings.HSplitTop(MainView.h/4-10.0f, &ChatSettings, &MiscSettings);
|
|
|
|
RenderTools()->DrawUIRect(&ChatSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
ChatSettings.Margin(10.0f, &ChatSettings);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->Text(0, ChatSettings.x, ChatSettings.y, 14.0f*UI()->Scale(), Localize("Chat"), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
ChatSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &ChatSettings);
|
2010-05-30 12:01:11 +00:00
|
|
|
UiDoGetButtons(14, 17, ChatSettings);
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
MiscSettings.HSplitTop(10.0f, 0, &MiscSettings);
|
2011-01-05 11:19:06 +00:00
|
|
|
MiscSettings.HSplitBottom(50.0f*UI()->Scale(), &MiscSettings, &ResetButton);
|
2010-05-29 07:25:38 +00:00
|
|
|
RenderTools()->DrawUIRect(&MiscSettings, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f);
|
|
|
|
MiscSettings.Margin(10.0f, &MiscSettings);
|
|
|
|
|
2010-12-14 00:20:47 +00:00
|
|
|
TextRender()->Text(0, MiscSettings.x, MiscSettings.y, 14.0f*UI()->Scale(), Localize("Miscellaneous"), -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
MiscSettings.HSplitTop(14.0f+5.0f+10.0f, 0, &MiscSettings);
|
2011-01-06 12:17:54 +00:00
|
|
|
UiDoGetButtons(17, 22, MiscSettings);
|
2008-10-05 18:27:20 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2008-10-05 15:59:36 +00:00
|
|
|
// defaults
|
2010-05-29 07:25:38 +00:00
|
|
|
ResetButton.HSplitTop(10.0f, 0, &ResetButton);
|
|
|
|
static int s_DefaultButton = 0;
|
|
|
|
if(DoButton_Menu((void*)&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton))
|
|
|
|
m_pClient->m_pBinds->SetDefaults();
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMenus::RenderSettingsGraphics(CUIRect MainView)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button;
|
|
|
|
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];
|
2010-10-16 09:24:42 +00:00
|
|
|
static int s_NumNodes = Graphics()->GetVideoModes(s_aModes, MAX_RESOLUTIONS);
|
|
|
|
static int s_GfxScreenWidth = g_Config.m_GfxScreenWidth;
|
|
|
|
static int s_GfxScreenHeight = g_Config.m_GfxScreenHeight;
|
|
|
|
static int s_GfxColorDepth = g_Config.m_GfxColorDepth;
|
2010-12-08 00:55:13 +00:00
|
|
|
static int s_GfxFullscreen = g_Config.m_GfxFullscreen;
|
|
|
|
static int s_GfxVsync = g_Config.m_GfxVsync;
|
|
|
|
static int s_GfxFsaaSamples = g_Config.m_GfxFsaaSamples;
|
|
|
|
static int s_GfxTextureQuality = g_Config.m_GfxTextureQuality;
|
2010-10-16 09:24:42 +00:00
|
|
|
static int s_GfxTextureCompression = g_Config.m_GfxTextureCompression;
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
CUIRect ModeList;
|
|
|
|
MainView.VSplitLeft(300.0f, &MainView, &ModeList);
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// draw allmodes switch
|
2010-05-29 07:25:38 +00:00
|
|
|
ModeList.HSplitTop(20, &Button, &ModeList);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_GfxDisplayAllModes, Localize("Show only supported"), g_Config.m_GfxDisplayAllModes^1, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxDisplayAllModes ^= 1;
|
|
|
|
s_NumNodes = Graphics()->GetVideoModes(s_aModes, MAX_RESOLUTIONS);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
// display mode list
|
|
|
|
static float s_ScrollValue = 0;
|
|
|
|
int OldSelected = -1;
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %dx%d %d bit", Localize("Current"), s_GfxScreenWidth, s_GfxScreenHeight, s_GfxColorDepth);
|
|
|
|
UiDoListboxStart(&s_NumNodes , &ModeList, 24.0f, Localize("Display Modes"), aBuf, s_NumNodes, 1, OldSelected, s_ScrollValue);
|
|
|
|
|
|
|
|
for(int i = 0; i < s_NumNodes; ++i)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
const int Depth = s_aModes[i].m_Red+s_aModes[i].m_Green+s_aModes[i].m_Blue > 16 ? 24 : 16;
|
|
|
|
if(g_Config.m_GfxColorDepth == Depth &&
|
|
|
|
g_Config.m_GfxScreenWidth == s_aModes[i].m_Width &&
|
|
|
|
g_Config.m_GfxScreenHeight == s_aModes[i].m_Height)
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
str_format(aBuf, sizeof(aBuf), " %dx%d %d bit", s_aModes[i].m_Width, s_aModes[i].m_Height, Depth);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Item.m_Rect, aBuf, 16.0f, -1);
|
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)
|
|
|
|
{
|
|
|
|
const int Depth = s_aModes[NewSelected].m_Red+s_aModes[NewSelected].m_Green+s_aModes[NewSelected].m_Blue > 16 ? 24 : 16;
|
|
|
|
g_Config.m_GfxColorDepth = Depth;
|
|
|
|
g_Config.m_GfxScreenWidth = s_aModes[NewSelected].m_Width;
|
|
|
|
g_Config.m_GfxScreenHeight = s_aModes[NewSelected].m_Height;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// switches
|
2010-05-29 07:25:38 +00:00
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_GfxFullscreen, Localize("Fullscreen"), g_Config.m_GfxFullscreen, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxFullscreen ^= 1;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_GfxVsync, Localize("V-Sync"), g_Config.m_GfxVsync, &Button))
|
2009-01-21 20:55:07 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxVsync ^= 1;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2009-01-21 20:55:07 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
if(DoButton_CheckBox_Number(&g_Config.m_GfxFsaaSamples, Localize("FSAA samples"), g_Config.m_GfxFsaaSamples, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxFsaaSamples = (g_Config.m_GfxFsaaSamples+1)%17;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
MainView.HSplitTop(40.0f, &Button, &MainView);
|
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_GfxTextureQuality, Localize("Quality Textures"), g_Config.m_GfxTextureQuality, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxTextureQuality ^= 1;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
if(DoButton_CheckBox(&g_Config.m_GfxTextureCompression, Localize("Texture Compression"), g_Config.m_GfxTextureCompression, &Button))
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_GfxTextureCompression ^= 1;
|
2010-10-16 09:24:42 +00:00
|
|
|
CheckSettings = true;
|
2008-08-27 15:48:50 +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;
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-12-08 00:55:13 +00:00
|
|
|
// check if the new settings require a restart
|
|
|
|
if(CheckSettings)
|
|
|
|
{
|
|
|
|
if(s_GfxScreenWidth == g_Config.m_GfxScreenWidth &&
|
|
|
|
s_GfxScreenHeight == g_Config.m_GfxScreenHeight &&
|
|
|
|
s_GfxColorDepth == g_Config.m_GfxColorDepth &&
|
|
|
|
s_GfxFullscreen == g_Config.m_GfxFullscreen &&
|
|
|
|
s_GfxVsync == g_Config.m_GfxVsync &&
|
|
|
|
s_GfxFsaaSamples == g_Config.m_GfxFsaaSamples &&
|
|
|
|
s_GfxTextureQuality == g_Config.m_GfxTextureQuality &&
|
|
|
|
s_GfxTextureCompression == g_Config.m_GfxTextureCompression)
|
|
|
|
m_NeedRestartGraphics = false;
|
|
|
|
else
|
|
|
|
m_NeedRestartGraphics = true;
|
2010-10-16 09:24:42 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 15:48:50 +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);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Text, Localize("UI Color"), 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
const char *paLabels[] = {
|
|
|
|
Localize("Hue"),
|
|
|
|
Localize("Sat."),
|
|
|
|
Localize("Lht."),
|
|
|
|
Localize("Alpha")};
|
|
|
|
int *pColorSlider[4] = {&g_Config.m_UiColorHue, &g_Config.m_UiColorSat, &g_Config.m_UiColorLht, &g_Config.m_UiColorAlpha};
|
2008-08-27 15:48:50 +00:00
|
|
|
for(int s = 0; s < 4; s++)
|
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Text;
|
|
|
|
MainView.HSplitTop(19.0f, &Button, &MainView);
|
|
|
|
Button.VMargin(15.0f, &Button);
|
|
|
|
Button.VSplitLeft(50.0f, &Text, &Button);
|
|
|
|
Button.VSplitRight(5.0f, &Button, 0);
|
|
|
|
Button.HSplitTop(4.0f, 0, &Button);
|
|
|
|
|
|
|
|
float k = (*pColorSlider[s]) / 255.0f;
|
|
|
|
k = DoScrollbarH(pColorSlider[s], &Button, k);
|
|
|
|
*pColorSlider[s] = (int)(k*255.0f);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Text, paLabels[s], 15.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
}
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
CUIRect Button;
|
|
|
|
MainView.VSplitLeft(300.0f, &MainView, 0);
|
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;
|
2010-10-16 09:24:42 +00:00
|
|
|
m_NeedRestartSound = s_SndEnable == g_Config.m_SndEnable && (!s_SndEnable || s_SndRate == g_Config.m_SndRate) ? false : true;
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
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);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Button, Localize("Sample rate"), 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
Button.VSplitLeft(110.0f, 0, &Button);
|
|
|
|
Button.VSplitLeft(180.0f, &Button, 0);
|
2010-05-29 15:53:57 +00:00
|
|
|
static float Offset = 0.0f;
|
|
|
|
DoEditBox(&g_Config.m_SndRate, &Button, aBuf, sizeof(aBuf), 14.0f, &Offset);
|
2010-05-29 07:25:38 +00:00
|
|
|
int Before = g_Config.m_SndRate;
|
2010-10-16 09:24:42 +00:00
|
|
|
g_Config.m_SndRate = max(1, str_toint(aBuf));
|
2010-05-29 07:25:38 +00:00
|
|
|
|
2010-12-08 00:55:13 +00:00
|
|
|
if(g_Config.m_SndRate != Before)
|
2010-10-16 09:24:42 +00:00
|
|
|
m_NeedRestartSound = s_SndEnable == g_Config.m_SndEnable && s_SndRate == g_Config.m_SndRate ? false : true;
|
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
|
|
|
CUIRect Button, Label;
|
|
|
|
MainView.HSplitTop(5.0f, &Button, &MainView);
|
|
|
|
MainView.HSplitTop(20.0f, &Button, &MainView);
|
|
|
|
Button.VSplitLeft(110.0f, &Label, &Button);
|
|
|
|
Button.HMargin(2.0f, &Button);
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Label, Localize("Sound volume"), 14.0f, -1);
|
2010-05-29 07:25:38 +00:00
|
|
|
g_Config.m_SndVolume = (int)(DoScrollbarH(&g_Config.m_SndVolume, &Button, g_Config.m_SndVolume/100.0f)*100.0f);
|
|
|
|
MainView.HSplitTop(20.0f, 0, &MainView);
|
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:
|
|
|
|
CLanguage() {}
|
|
|
|
CLanguage(const char *n, const char *f) : m_Name(n), m_FileName(f) {}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
string m_Name;
|
|
|
|
string m_FileName;
|
|
|
|
|
2010-07-09 22:55:42 +00:00
|
|
|
bool operator<(const CLanguage &Other) { return m_Name < Other.m_Name; }
|
2009-06-15 08:15:53 +00:00
|
|
|
};
|
|
|
|
|
2010-09-16 11:32:56 +00:00
|
|
|
void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array<CLanguage> *pLanguages)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-10-06 21:07:35 +00:00
|
|
|
IOHANDLE File = pStorage->OpenFile("languages/index.txt", IOFLAG_READ, 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
|
|
|
}
|
|
|
|
|
|
|
|
CLineReader LineReader;
|
|
|
|
LineReader.Init(File);
|
|
|
|
char *pLine;
|
|
|
|
while((pLine = LineReader.Get()))
|
|
|
|
{
|
|
|
|
if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments
|
|
|
|
continue;
|
|
|
|
|
|
|
|
char *pReplacement = LineReader.Get();
|
|
|
|
if(!pReplacement)
|
|
|
|
{
|
|
|
|
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "unexpected end of index file");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ')
|
|
|
|
{
|
|
|
|
char aBuf[128];
|
|
|
|
str_format(aBuf, sizeof(aBuf), "malform replacement for index '%s'", pLine);
|
|
|
|
pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
char aFileName[128];
|
2010-10-06 21:07:35 +00:00
|
|
|
str_format(aFileName, sizeof(aFileName), "languages/%s.txt", pLine);
|
2010-09-16 11:32:56 +00:00
|
|
|
pLanguages->add(CLanguage(pReplacement+3, aFileName));
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_LanguageList = 0;
|
|
|
|
static int s_SelectedLanguage = 0;
|
2010-07-09 22:55:42 +00:00
|
|
|
static sorted_array<CLanguage> s_Languages;
|
2010-05-29 07:25:38 +00:00
|
|
|
static float s_ScrollValue = 0;
|
|
|
|
|
|
|
|
if(s_Languages.size() == 0)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-07-09 22:55:42 +00:00
|
|
|
s_Languages.add(CLanguage("English", ""));
|
2010-09-16 11:32:56 +00:00
|
|
|
LoadLanguageIndexfile(Storage(), Console(), &s_Languages);
|
2010-05-29 07:25:38 +00:00
|
|
|
for(int i = 0; i < s_Languages.size(); i++)
|
|
|
|
if(str_comp(s_Languages[i].m_FileName, 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;
|
|
|
|
|
2010-12-12 18:20:30 +00:00
|
|
|
UiDoListboxStart(&s_LanguageList , &MainView, 24.0f, Localize("Language"), "", s_Languages.size(), 1, s_SelectedLanguage, s_ScrollValue);
|
|
|
|
|
|
|
|
for(sorted_array<CLanguage>::range r = s_Languages.all(); !r.empty(); r.pop_front())
|
|
|
|
{
|
|
|
|
CListboxItem Item = UiDoListboxNextItem(&r.front());
|
|
|
|
|
|
|
|
if(Item.m_Visible)
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, 16.0f, -1);
|
2010-12-12 18:20:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s_SelectedLanguage = UiDoListboxEnd(&s_ScrollValue, 0);
|
|
|
|
|
|
|
|
if(OldSelected != s_SelectedLanguage)
|
|
|
|
{
|
|
|
|
str_copy(g_Config.m_ClLanguagefile, s_Languages[s_SelectedLanguage].m_FileName, sizeof(g_Config.m_ClLanguagefile));
|
|
|
|
g_Localization.Load(s_Languages[s_SelectedLanguage].m_FileName, Storage(), Console());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CMenus::RenderSettingsGeneral(CUIRect MainView)
|
|
|
|
{
|
2010-12-12 15:48:13 +00:00
|
|
|
CUIRect List, Button, Label, Left, Right;
|
2010-12-08 00:55:13 +00:00
|
|
|
MainView.HSplitBottom(10.0f, &MainView, 0);
|
2010-12-11 17:55:28 +00:00
|
|
|
MainView.HSplitBottom(70.0f, &MainView, &Left);
|
2010-12-12 15:48:13 +00:00
|
|
|
Left.VSplitMid(&Left, &Right);
|
2010-12-08 00:55:13 +00:00
|
|
|
MainView.HSplitBottom(20.0f, &List, &MainView);
|
|
|
|
|
2010-12-11 17:55:28 +00:00
|
|
|
// auto demo settings
|
|
|
|
{
|
2010-12-12 15:48:13 +00:00
|
|
|
Left.HSplitTop(20.0f, &Button, &Left);
|
2010-12-11 17:55:28 +00:00
|
|
|
if(DoButton_CheckBox(&g_Config.m_ClAutoDemoRecord, Localize("Automatically record demos"), g_Config.m_ClAutoDemoRecord, &Button))
|
|
|
|
g_Config.m_ClAutoDemoRecord ^= 1;
|
|
|
|
|
2010-12-12 15:48:13 +00:00
|
|
|
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;
|
|
|
|
|
2010-12-11 17:55:28 +00:00
|
|
|
Left.HSplitTop(10.0f, 0, &Left);
|
|
|
|
Left.VSplitLeft(20.0f, 0, &Left);
|
|
|
|
Left.HSplitTop(20.0f, &Label, &Button);
|
|
|
|
Button.VSplitRight(20.0f, &Button, 0);
|
|
|
|
char aBuf[64];
|
|
|
|
if(g_Config.m_ClAutoDemoMax)
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max demos"), g_Config.m_ClAutoDemoMax);
|
|
|
|
else
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max demos"), Localize("no limit"));
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
2010-12-11 17:55:28 +00:00
|
|
|
g_Config.m_ClAutoDemoMax = static_cast<int>(DoScrollbarH(&g_Config.m_ClAutoDemoMax, &Button, g_Config.m_ClAutoDemoMax/1000.0f)*1000.0f+0.1f);
|
2010-12-12 15:48:13 +00:00
|
|
|
|
|
|
|
Right.HSplitTop(10.0f, 0, &Right);
|
|
|
|
Right.VSplitLeft(20.0f, 0, &Right);
|
|
|
|
Right.HSplitTop(20.0f, &Label, &Button);
|
|
|
|
Button.VSplitRight(20.0f, &Button, 0);
|
|
|
|
if(g_Config.m_ClAutoScreenshotMax)
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %i", Localize("Max Screenshots"), g_Config.m_ClAutoScreenshotMax);
|
|
|
|
else
|
|
|
|
str_format(aBuf, sizeof(aBuf), "%s: %s", Localize("Max Screenshots"), Localize("no limit"));
|
2010-12-14 00:20:47 +00:00
|
|
|
UI()->DoLabelScaled(&Label, aBuf, 13.0f, -1);
|
2010-12-12 15:48:13 +00:00
|
|
|
g_Config.m_ClAutoScreenshotMax = static_cast<int>(DoScrollbarH(&g_Config.m_ClAutoScreenshotMax, &Button, g_Config.m_ClAutoScreenshotMax/1000.0f)*1000.0f+0.1f);
|
2010-12-11 17:55:28 +00:00
|
|
|
}
|
2010-12-08 00:55:13 +00:00
|
|
|
|
2010-12-12 18:20:30 +00:00
|
|
|
RenderLanguageSelection(List);
|
2009-06-15 08:15:53 +00:00
|
|
|
}
|
2008-08-27 15:48:50 +00:00
|
|
|
|
2010-05-29 07:25:38 +00:00
|
|
|
void CMenus::RenderSettings(CUIRect MainView)
|
2008-08-27 15:48:50 +00:00
|
|
|
{
|
2010-05-29 07:25:38 +00:00
|
|
|
static int s_SettingsPage = 0;
|
|
|
|
|
2008-08-27 15:48:50 +00:00
|
|
|
// render background
|
2010-10-16 09:27:49 +00:00
|
|
|
CUIRect Temp, TabBar, RestartWarning;
|
|
|
|
MainView.HSplitBottom(15.0f, &MainView, &RestartWarning);
|
2010-05-29 07:25:38 +00:00
|
|
|
MainView.VSplitRight(120.0f, &MainView, &TabBar);
|
|
|
|
RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_B|CUI::CORNER_TL, 10.0f);
|
|
|
|
TabBar.HSplitTop(50.0f, &Temp, &TabBar);
|
|
|
|
RenderTools()->DrawUIRect(&Temp, ms_ColorTabbarActive, CUI::CORNER_R, 10.0f);
|
|
|
|
|
|
|
|
MainView.HSplitTop(10.0f, 0, &MainView);
|
|
|
|
|
|
|
|
CUIRect Button;
|
|
|
|
|
|
|
|
const char *aTabs[] = {
|
|
|
|
Localize("General"),
|
|
|
|
Localize("Player"),
|
|
|
|
Localize("Controls"),
|
|
|
|
Localize("Graphics"),
|
|
|
|
Localize("Sound")};
|
|
|
|
|
|
|
|
int NumTabs = (int)(sizeof(aTabs)/sizeof(*aTabs));
|
|
|
|
|
|
|
|
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);
|
2010-10-20 19:33:48 +00:00
|
|
|
if(DoButton_MenuTab(aTabs[i], aTabs[i], s_SettingsPage == i, &Button, CUI::CORNER_R))
|
2010-05-29 07:25:38 +00:00
|
|
|
s_SettingsPage = i;
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|
2010-05-29 07:25:38 +00:00
|
|
|
|
|
|
|
MainView.Margin(10.0f, &MainView);
|
|
|
|
|
|
|
|
if(s_SettingsPage == 0)
|
|
|
|
RenderSettingsGeneral(MainView);
|
|
|
|
else if(s_SettingsPage == 1)
|
|
|
|
RenderSettingsPlayer(MainView);
|
|
|
|
else if(s_SettingsPage == 2)
|
|
|
|
RenderSettingsControls(MainView);
|
|
|
|
else if(s_SettingsPage == 3)
|
|
|
|
RenderSettingsGraphics(MainView);
|
|
|
|
else if(s_SettingsPage == 4)
|
|
|
|
RenderSettingsSound(MainView);
|
|
|
|
|
2010-10-16 09:24:42 +00:00
|
|
|
if(m_NeedRestartGraphics || m_NeedRestartSound)
|
2010-10-16 09:27:49 +00:00
|
|
|
UI()->DoLabel(&RestartWarning, Localize("You must restart the game for all settings to take effect."), 15.0f, -1);
|
2008-08-27 15:48:50 +00:00
|
|
|
}
|