diff options
| author | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
|---|---|---|
| committer | oy <Tom_Adams@web.de> | 2011-04-13 20:37:12 +0200 |
| commit | 06115dd49dca2f8eb5f14606437e8fd20037cc4d (patch) | |
| tree | 5ec4bca6158319b3f5285d7689c5f94ae8da8c93 /src/game/client/components | |
| parent | 63e059b8fff6498e42b765a1dca000e53005ea77 (diff) | |
| download | zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.tar.gz zcatch-06115dd49dca2f8eb5f14606437e8fd20037cc4d.zip | |
added "Whitespace and line Endings cleanup" by GreYFoX
Diffstat (limited to 'src/game/client/components')
54 files changed, 706 insertions, 706 deletions
diff --git a/src/game/client/components/binds.cpp b/src/game/client/components/binds.cpp index 1632b26f..3feba98e 100644 --- a/src/game/client/components/binds.cpp +++ b/src/game/client/components/binds.cpp @@ -12,11 +12,11 @@ bool CBinds::CBindsSpecial::OnInput(IInput::CEvent Event) int Stroke = 0; if(Event.m_Flags&IInput::FLAG_PRESS) Stroke = 1; - + m_pBinds->GetConsole()->ExecuteLineStroked(Stroke, m_pBinds->m_aaKeyBindings[Event.m_Key]); return true; } - + return false; } @@ -30,7 +30,7 @@ void CBinds::Bind(int KeyID, const char *pStr) { if(KeyID < 0 || KeyID >= KEY_LAST) return; - + str_copy(m_aaKeyBindings[KeyID], pStr, sizeof(m_aaKeyBindings[KeyID])); char aBuf[256]; if(!m_aaKeyBindings[KeyID][0]) @@ -74,11 +74,11 @@ const char *CBinds::GetKey(const char *pBindStr) const char *pBind = Get(KeyId); if(!pBind[0]) continue; - + if(str_comp(pBind, pBindStr) == 0) return Input()->KeyName(KeyId); } - + return ""; } @@ -108,15 +108,15 @@ void CBinds::SetDefaults() Bind('3', "+weapon3"); Bind('4', "+weapon4"); Bind('5', "+weapon5"); - + Bind(KEY_MOUSE_WHEEL_UP, "+prevweapon"); Bind(KEY_MOUSE_WHEEL_DOWN, "+nextweapon"); - + Bind('t', "chat all"); - Bind('y', "chat team"); + Bind('y', "chat team"); Bind(KEY_F3, "vote yes"); - Bind(KEY_F4, "vote no"); + Bind(KEY_F4, "vote no"); } void CBinds::OnConsoleInit() @@ -125,12 +125,12 @@ void CBinds::OnConsoleInit() IConfig *pConfig = Kernel()->RequestInterface<IConfig>(); if(pConfig) pConfig->RegisterCallback(ConfigSaveCallback, this); - + Console()->Register("bind", "sr", CFGFLAG_CLIENT, ConBind, this, "Bind key to execute the command"); Console()->Register("unbind", "s", CFGFLAG_CLIENT, ConUnbind, this, "Unbind key"); Console()->Register("unbindall", "", CFGFLAG_CLIENT, ConUnbindAll, this, "Unbind all keys"); Console()->Register("dump_binds", "", CFGFLAG_CLIENT, ConDumpBinds, this, "Dump binds"); - + // default bindings SetDefaults(); } @@ -140,7 +140,7 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData) CBinds *pBinds = (CBinds *)pUserData; const char *pKeyName = pResult->GetString(0); int id = pBinds->GetKeyID(pKeyName); - + if(!id) { char aBuf[256]; @@ -148,7 +148,7 @@ void CBinds::ConBind(IConsole::IResult *pResult, void *pUserData) pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); return; } - + pBinds->Bind(id, pResult->GetString(1)); } @@ -158,7 +158,7 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData) CBinds *pBinds = (CBinds *)pUserData; const char *pKeyName = pResult->GetString(0); int id = pBinds->GetKeyID(pKeyName); - + if(!id) { char aBuf[256]; @@ -166,7 +166,7 @@ void CBinds::ConUnbind(IConsole::IResult *pResult, void *pUserData) pBinds->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "binds", aBuf); return; } - + pBinds->Bind(id, ""); } @@ -200,21 +200,21 @@ int CBinds::GetKeyID(const char *pKeyName) if(i > 0 && i < KEY_LAST) return i; // numeric } - + // search for key for(int i = 0; i < KEY_LAST; i++) { if(str_comp(pKeyName, Input()->KeyName(i)) == 0) return i; } - + return 0; } void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) { CBinds *pSelf = (CBinds *)pUserData; - + char aBuffer[256]; char *pEnd = aBuffer+sizeof(aBuffer)-8; pConfig->WriteLine("unbindall"); @@ -223,7 +223,7 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) if(pSelf->m_aaKeyBindings[i][0] == 0) continue; str_format(aBuffer, sizeof(aBuffer), "bind %s ", pSelf->Input()->KeyName(i)); - + // process the string. we need to escape some characters const char *pSrc = pSelf->m_aaKeyBindings[i]; char *pDst = aBuffer + str_length(aBuffer); @@ -236,7 +236,7 @@ void CBinds::ConfigSaveCallback(IConfig *pConfig, void *pUserData) } *pDst++ = '"'; *pDst++ = 0; - + pConfig->WriteLine(aBuffer); } } diff --git a/src/game/client/components/binds.h b/src/game/client/components/binds.h index ad51a47c..7812242c 100644 --- a/src/game/client/components/binds.h +++ b/src/game/client/components/binds.h @@ -16,27 +16,27 @@ class CBinds : public CComponent static void ConUnbindAll(IConsole::IResult *pResult, void *pUserData); static void ConDumpBinds(IConsole::IResult *pResult, void *pUserData); class IConsole *GetConsole() const { return Console(); } - + static void ConfigSaveCallback(class IConfig *pConfig, void *pUserData); - + public: CBinds(); - + class CBindsSpecial : public CComponent { public: CBinds *m_pBinds; virtual bool OnInput(IInput::CEvent Event); }; - + CBindsSpecial m_SpecialBinds; - + void Bind(int KeyID, const char *pStr); void SetDefaults(); void UnbindAll(); const char *Get(int KeyID); const char *GetKey(const char *pBindStr); - + virtual void OnConsoleInit(); virtual bool OnInput(IInput::CEvent Event); }; diff --git a/src/game/client/components/broadcast.cpp b/src/game/client/components/broadcast.cpp index 17b2d66b..ccf49bf6 100644 --- a/src/game/client/components/broadcast.cpp +++ b/src/game/client/components/broadcast.cpp @@ -12,7 +12,7 @@ #include <game/client/components/scoreboard.h> #include "broadcast.h" - + void CBroadcast::OnReset() { m_BroadcastTime = 0; @@ -24,7 +24,7 @@ void CBroadcast::OnRender() return; Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); - + if(time_get() < m_BroadcastTime) { CTextCursor Cursor; diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index f02b2861..5a8dc8c8 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -20,7 +20,7 @@ void CCamera::OnRender() //vec2 center; m_Zoom = 1.0f; - // update camera center + // update camera center if(m_pClient->m_Snap.m_SpecInfo.m_Active && !m_pClient->m_Snap.m_SpecInfo.m_UsePosition) { if(m_CamType != CAMTYPE_SPEC) @@ -50,7 +50,7 @@ void CCamera::OnRender() CameraOffset = normalize(m_pClient->m_pControls->m_MousePos)*OffsetAmount; } - + if(m_pClient->m_Snap.m_SpecInfo.m_Active) m_Center = m_pClient->m_Snap.m_SpecInfo.m_Position + CameraOffset; else diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 19264194..ee294dc4 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -32,7 +32,7 @@ void CChat::OnReset() m_aLines[i].m_aText[0] = 0; m_aLines[i].m_aName[0] = 0; } - + m_Show = false; m_InputUpdate = false; m_ChatStringOffset = 0; @@ -126,7 +126,7 @@ bool CChat::OnInput(IInput::CEvent Event) for(m_PlaceholderLength = 0; *pCursor && *pCursor != ' '; ++pCursor) ++m_PlaceholderLength; - + str_copy(m_aCompletionBuffer, m_Input.GetString()+m_PlaceholderOffset, min(static_cast<int>(sizeof(m_aCompletionBuffer)), m_PlaceholderLength+1)); } @@ -204,7 +204,7 @@ bool CChat::OnInput(IInput::CEvent Event) else m_Input.Clear(); } - + return true; } @@ -220,7 +220,7 @@ void CChat::EnableMode(int Team) m_Mode = MODE_TEAM; else m_Mode = MODE_ALL; - + m_Input.Clear(); Input()->ClearEvents(); m_CompletionChosen = -1; @@ -241,7 +241,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) if(ClientID != -1 && (m_pClient->m_aClients[ClientID].m_aName[0] == '\0' || // unknown client m_pClient->m_aClients[ClientID].m_ChatIgnore)) return; - + bool Highlighted = false; char *p = const_cast<char*>(pLine); while(*p) @@ -285,11 +285,11 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) else if(m_pClient->m_aClients[ClientID].m_Team == TEAM_BLUE) m_aLines[m_CurrentLine].m_NameColor = TEAM_BLUE; } - + str_copy(m_aLines[m_CurrentLine].m_aName, m_pClient->m_aClients[ClientID].m_aName, sizeof(m_aLines[m_CurrentLine].m_aName)); str_format(m_aLines[m_CurrentLine].m_aText, sizeof(m_aLines[m_CurrentLine].m_aText), ": %s", pLine); } - + char aBuf[1024]; str_format(aBuf, sizeof(aBuf), "%s%s", m_aLines[m_CurrentLine].m_aName, m_aLines[m_CurrentLine].m_aText); Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "chat", aBuf); @@ -317,7 +317,7 @@ void CChat::OnRender() TextRender()->SetCursor(&Cursor, x, y, 8.0f, TEXTFLAG_RENDER); Cursor.m_LineWidth = Width-190.0f; Cursor.m_MaxLines = 2; - + if(m_Mode == MODE_ALL) TextRender()->TextEx(&Cursor, Localize("All"), -1); else if(m_Mode == MODE_TEAM) @@ -326,7 +326,7 @@ void CChat::OnRender() TextRender()->TextEx(&Cursor, Localize("Chat"), -1); TextRender()->TextEx(&Cursor, ": ", -1); - + // check if the visible text has to be moved if(m_InputUpdate) { @@ -373,7 +373,7 @@ void CChat::OnRender() int r = ((m_CurrentLine-i)+MAX_LINES)%MAX_LINES; if(Now > m_aLines[r].m_Time+16*time_freq() && !m_Show) break; - + // get the y offset (calculate it if we haven't done that yet) if(m_aLines[r].m_YOffset[OffsetType] < 0.0f) { @@ -388,7 +388,7 @@ void CChat::OnRender() // cut off if msgs waste too much space if(y < HeightLimit) break; - + float Blend = Now > m_aLines[r].m_Time+14*time_freq() && !m_Show ? 1.0f-(Now-m_aLines[r].m_Time-14*time_freq())/(2.0f*time_freq()) : 1.0f; // reset the cursor @@ -408,7 +408,7 @@ void CChat::OnRender() TextRender()->TextColor(0.75f, 0.5f, 0.75f, Blend); // spectator else TextRender()->TextColor(0.8f, 0.8f, 0.8f, Blend); - + TextRender()->TextEx(&Cursor, m_aLines[r].m_aName, -1); // render line diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index bb68d7be..60e18387 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -9,8 +9,8 @@ class CChat : public CComponent { CLineInput m_Input; - - enum + + enum { MAX_LINES = 25, }; @@ -49,23 +49,23 @@ class CChat : public CComponent int m_PlaceholderLength; char *m_pHistoryEntry; TStaticRingBuffer<char, 64*1024, CRingBufferBase::FLAG_RECYCLE> m_History; - + static void ConSay(IConsole::IResult *pResult, void *pUserData); static void ConSayTeam(IConsole::IResult *pResult, void *pUserData); static void ConChat(IConsole::IResult *pResult, void *pUserData); static void ConShowChat(IConsole::IResult *pResult, void *pUserData); - + public: CChat(); bool IsActive() const { return m_Mode != MODE_NONE; } - + void AddLine(int ClientID, int Team, const char *pLine); - + void EnableMode(int Team); - + void Say(int Team, const char *pLine); - + virtual void OnReset(); virtual void OnConsoleInit(); virtual void OnStateChange(int NewState, int OldState); diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index a7da3075..33c6db43 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -39,9 +39,9 @@ enum CGameConsole::CInstance::CInstance(int Type) { m_pHistoryEntry = 0x0; - + m_Type = Type; - + if(Type == CGameConsole::CONSOLETYPE_LOCAL) m_CompletionFlagmask = CFGFLAG_CLIENT; else @@ -50,7 +50,7 @@ CGameConsole::CInstance::CInstance(int Type) m_aCompletionBuffer[0] = 0; m_CompletionChosen = -1; m_CompletionRenderOffset = 0.0f; - + m_pCommand = 0x0; } @@ -95,7 +95,7 @@ void CGameConsole::CInstance::PossibleCommandsCompleteCallback(const char *pStr, void CGameConsole::CInstance::OnInput(IInput::CEvent Event) { bool Handled = false; - + if(Event.m_Flags&IInput::FLAG_PRESS) { if(Event.m_Key == KEY_RETURN || Event.m_Key == KEY_KP_ENTER) @@ -111,7 +111,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) m_Input.Clear(); m_pHistoryEntry = 0x0; } - + Handled = true; } else if (Event.m_Key == KEY_UP) @@ -197,7 +197,7 @@ void CGameConsole::CInstance::OnInput(IInput::CEvent Event) for(; i < (int)sizeof(aBuf)-1 && *pSrc && *pSrc != ' '; i++, pSrc++) aBuf[i] = *pSrc; aBuf[i] = 0; - + m_pCommand = m_pGameConsole->m_pConsole->GetCommandInfo(aBuf, m_CompletionFlagmask); } } @@ -233,9 +233,9 @@ float CGameConsole::TimeNow() CGameConsole::CInstance *CGameConsole::CurrentConsole() { - if(m_ConsoleType == CONSOLETYPE_REMOTE) - return &m_RemoteConsole; - return &m_LocalConsole; + if(m_ConsoleType == CONSOLETYPE_REMOTE) + return &m_RemoteConsole; + return &m_LocalConsole; } void CGameConsole::OnReset() @@ -263,7 +263,7 @@ struct CRenderInfo void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) { CRenderInfo *pInfo = static_cast<CRenderInfo *>(pUser); - + if(pInfo->m_EnumCount == pInfo->m_WantedCompletion) { float tw = pInfo->m_pSelf->TextRender()->TextWidth(pInfo->m_Cursor.m_pFont, pInfo->m_Cursor.m_FontSize, pStr, -1); @@ -272,7 +272,7 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) pInfo->m_pSelf->Graphics()->SetColor(229.0f/255.0f,185.0f/255.0f,4.0f/255.0f,0.85f); pInfo->m_pSelf->RenderTools()->DrawRoundRect(pInfo->m_Cursor.m_X-3, pInfo->m_Cursor.m_Y, tw+5, pInfo->m_Cursor.m_FontSize+4, pInfo->m_Cursor.m_FontSize/3); pInfo->m_pSelf->Graphics()->QuadsEnd(); - + // scroll when out of sight if(pInfo->m_Cursor.m_X < 3.0f) pInfo->m_Offset = 0.0f; @@ -285,7 +285,7 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) else { const char *pMatchStart = str_find_nocase(pStr, pInfo->m_pCurrentCmd); - + if(pMatchStart) { pInfo->m_pSelf->TextRender()->TextColor(0.5f,0.5f,0.5f,1); @@ -301,14 +301,14 @@ void CGameConsole::PossibleCommandsRenderCallback(const char *pStr, void *pUser) pInfo->m_pSelf->TextRender()->TextEx(&pInfo->m_Cursor, pStr, -1); } } - + pInfo->m_EnumCount++; pInfo->m_Cursor.m_X += 7.0f; } void CGameConsole::OnRender() { - CUIRect Screen = *UI()->Screen(); + CUIRect Screen = *UI()->Screen(); float ConsoleMaxHeight = Screen.h*3/5.0f; float ConsoleHeight; @@ -325,11 +325,11 @@ void CGameConsole::OnRender() } if (m_ConsoleState == CONSOLE_OPEN && g_Config.m_ClEditor) - Toggle(CONSOLETYPE_LOCAL); - + Toggle(CONSOLETYPE_LOCAL); + if (m_ConsoleState == CONSOLE_CLOSED) return; - + if (m_ConsoleState == CONSOLE_OPEN) Input()->MouseModeAbsolute(); @@ -348,31 +348,31 @@ void CGameConsole::OnRender() // do console shadow Graphics()->TextureSet(-1); - Graphics()->QuadsBegin(); + Graphics()->QuadsBegin(); IGraphics::CColorVertex Array[4] = { - IGraphics::CColorVertex(0, 0,0,0, 0.5f), - IGraphics::CColorVertex(1, 0,0,0, 0.5f), - IGraphics::CColorVertex(2, 0,0,0, 0.0f), + IGraphics::CColorVertex(0, 0,0,0, 0.5f), + IGraphics::CColorVertex(1, 0,0,0, 0.5f), + IGraphics::CColorVertex(2, 0,0,0, 0.0f), IGraphics::CColorVertex(3, 0,0,0, 0.0f)}; Graphics()->SetColorVertex(Array, 4); IGraphics::CQuadItem QuadItem(0, ConsoleHeight, Screen.w, 10.0f); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); // do background Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BG].m_Id); - Graphics()->QuadsBegin(); - Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f); - if(m_ConsoleType == CONSOLETYPE_REMOTE) - Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f); - Graphics()->QuadsSetSubset(0,-ConsoleHeight*0.075f,Screen.w*0.075f*0.5f,0); + Graphics()->QuadsBegin(); + Graphics()->SetColor(0.2f, 0.2f, 0.2f,0.9f); + if(m_ConsoleType == CONSOLETYPE_REMOTE) + Graphics()->SetColor(0.4f, 0.2f, 0.2f,0.9f); + Graphics()->QuadsSetSubset(0,-ConsoleHeight*0.075f,Screen.w*0.075f*0.5f,0); QuadItem = IGraphics::CQuadItem(0, 0, Screen.w, ConsoleHeight); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); // do small bar shadow Graphics()->TextureSet(-1); - Graphics()->QuadsBegin(); + Graphics()->QuadsBegin(); Array[0] = IGraphics::CColorVertex(0, 0,0,0, 0.0f); Array[1] = IGraphics::CColorVertex(1, 0,0,0, 0.0f); Array[2] = IGraphics::CColorVertex(2, 0,0,0, 0.25f); @@ -380,20 +380,20 @@ void CGameConsole::OnRender() Graphics()->SetColorVertex(Array, 4); QuadItem = IGraphics::CQuadItem(0, ConsoleHeight-20, Screen.w, 10); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); // do the lower bar Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CONSOLE_BAR].m_Id); - Graphics()->QuadsBegin(); - Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); - Graphics()->QuadsSetSubset(0,0.1f,Screen.w*0.015f,1-0.1f); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1.0f, 1.0f, 1.0f, 0.9f); + Graphics()->QuadsSetSubset(0,0.1f,Screen.w*0.015f,1-0.1f); QuadItem = IGraphics::CQuadItem(0,ConsoleHeight-10.0f,Screen.w,10.0f); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); - - ConsoleHeight -= 22.0f; - - CInstance *pConsole = CurrentConsole(); + Graphics()->QuadsEnd(); + + ConsoleHeight -= 22.0f; + + CInstance *pConsole = CurrentConsole(); { float FontSize = 10.0f; @@ -410,7 +410,7 @@ void CGameConsole::OnRender() Info.m_pCurrentCmd = pConsole->m_aCompletionBuffer; TextRender()->SetCursor(&Info.m_Cursor, x+Info.m_Offset, y+RowHeight+2.0f, FontSize, TEXTFLAG_RENDER); - // render prompt + // render prompt CTextCursor Cursor; TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); const char *pPrompt = "> "; @@ -427,7 +427,7 @@ void CGameConsole::OnRender() pPrompt = "NOT CONNECTED> "; } TextRender()->TextEx(&Cursor, pPrompt, -1); - + x = Cursor.m_X; // render console input (wrap line) @@ -435,7 +435,7 @@ void CGameConsole::OnRender() y -= (Lines - 1) * FontSize; TextRender()->SetCursor(&Cursor, x, y, FontSize, TEXTFLAG_RENDER); Cursor.m_LineWidth = Screen.w - 10.0f - x; - + //hide rcon password char aInputString[256]; str_copy(aInputString, pConsole->m_Input.GetString(), sizeof(aInputString)); @@ -444,12 +444,12 @@ void CGameConsole::OnRender() for(int i = 0; i < pConsole->m_Input.GetLength(); ++i) aInputString[i] = '*'; } - + TextRender()->TextEx(&Cursor, aInputString, pConsole->m_Input.GetCursorOffset()); CTextCursor Marker = Cursor; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, aInputString+pConsole->m_Input.GetCursorOffset(), -1); - + // render possible commands if(m_ConsoleType == CONSOLETYPE_LOCAL || Client()->RconAuthed()) { @@ -457,12 +457,12 @@ void CGameConsole::OnRender() { m_pConsole->PossibleCommands(pConsole->m_aCompletionBuffer, pConsole->m_CompletionFlagmask, PossibleCommandsRenderCallback, &Info); pConsole->m_CompletionRenderOffset = Info.m_Offset; - + if(Info.m_EnumCount <= 0) { if(pConsole->m_pCommand) { - + char aBuf[512]; str_format(aBuf, sizeof(aBuf), "Help: %s ", pConsole->m_pCommand->m_pHelp); TextRender()->TextEx(&Info.m_Cursor, aBuf, -1); @@ -492,7 +492,7 @@ void CGameConsole::OnRender() pEntry->m_YOffset = Cursor.m_Y+Cursor.m_FontSize+LineOffset; } OffsetY += pEntry->m_YOffset; - + // next page when lines reach the top if(y-OffsetY <= RowHeight) break; @@ -533,7 +533,7 @@ void CGameConsole::OnRender() str_format(aBuf, sizeof(aBuf), "v%s", GAME_VERSION); float Width = TextRender()->TextWidth(0, FontSize, aBuf, -1); TextRender()->Text(0, Screen.w-Width-10.0f, 0.0f, FontSize, aBuf, -1); - } + } } void CGameConsole::OnMessage(int MsgType, void *pRawMsg) @@ -551,7 +551,7 @@ bool CGameConsole::OnInput(IInput::CEvent Event) Toggle(m_ConsoleType); else CurrentConsole()->OnInput(Event); - + return true; } @@ -562,7 +562,7 @@ void CGameConsole::Toggle(int Type) // don't toggle console, just switch what console to use } else - { + { if (m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_OPEN) { m_StateChangeEnd = TimeNow()+m_StateChangeDuration; @@ -671,10 +671,10 @@ void CGameConsole::OnConsoleInit() m_RemoteConsole.Init(this); m_pConsole = Kernel()->RequestInterface<IConsole>(); - + // Console()->RegisterPrintCallback(ClientConsolePrintCallback, this); - + Console()->Register("toggle_local_console", "", CFGFLAG_CLIENT, ConToggleLocalConsole, this, "Toggle local console"); Console()->Register("toggle_remote_console", "", CFGFLAG_CLIENT, ConToggleRemoteConsole, this, "Toggle remote console"); Console()->Register("clear_local_console", "", CFGFLAG_CLIENT, ConClearLocalConsole, this, "Clear local console"); diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index 2739724b..003a9423 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -24,15 +24,15 @@ class CGameConsole : public CComponent int m_Type; int m_CompletionEnumerationCount; int m_BacklogActPage; - + public: CGameConsole *m_pGameConsole; - + char m_aCompletionBuffer[128]; int m_CompletionChosen; int m_CompletionFlagmask; float m_CompletionRenderOffset; - + IConsole::CCommandInfo *m_pCommand; CInstance(int t); @@ -42,22 +42,22 @@ class CGameConsole : public CComponent void ClearHistory(); void ExecuteLine(const char *pLine); - + void OnInput(IInput::CEvent Event); void PrintLine(const char *pLine); - + const char *GetString() const { return m_Input.GetString(); } static void PossibleCommandsCompleteCallback(const char *pStr, void *pUser); }; - + class IConsole *m_pConsole; - + CInstance m_LocalConsole; CInstance m_RemoteConsole; - + CInstance *CurrentConsole(); float TimeNow(); - + int m_ConsoleType; int m_ConsoleState; float m_StateChangeEnd; @@ -74,7 +74,7 @@ class CGameConsole : public CComponent static void ConClearRemoteConsole(IConsole::IResult *pResult, void *pUserData); static void ConDumpLocalConsole(IConsole::IResult *pResult, void *pUserData); static void ConDumpRemoteConsole(IConsole::IResult *pResult, void *pUserData); - + public: enum { diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 56b6e63b..81c4d5ae 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -28,7 +28,7 @@ void CControls::OnReset() m_LastData.m_Fire &= INPUT_STATE_MASK; m_LastData.m_Jump = 0; m_InputData = m_LastData; - + m_InputDirectionLeft = 0; m_InputDirectionRight = 0; } @@ -86,31 +86,31 @@ void CControls::OnConsoleInit() Console()->Register("+hook", "", CFGFLAG_CLIENT, ConKeyInputState, &m_InputData.m_Hook, "Hook"); Console()->Register("+fire", "", CFGFLAG_CLIENT, ConKeyInputCounter, &m_InputData.m_Fire, "Fire"); - { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 1}; Console()->Register("+weapon1", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to hammer"); } - { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 2}; Console()->Register("+weapon2", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to gun"); } - { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 3}; Console()->Register("+weapon3", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to shotgun"); } - { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 4}; Console()->Register("+weapon4", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to grenade"); } - { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 5}; Console()->Register("+weapon5", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to rifle"); } + { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 1}; Console()->Register("+weapon1", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to hammer"); } + { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 2}; Console()->Register("+weapon2", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to gun"); } + { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 3}; Console()->Register("+weapon3", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to shotgun"); } + { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 4}; Console()->Register("+weapon4", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to grenade"); } + { static CInputSet s_Set = {this, &m_InputData.m_WantedWeapon, 5}; Console()->Register("+weapon5", "", CFGFLAG_CLIENT, ConKeyInputSet, (void *)&s_Set, "Switch to rifle"); } - { static CInputSet s_Set = {this, &m_InputData.m_NextWeapon, 0}; Console()->Register("+nextweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to next weapon"); } - { static CInputSet s_Set = {this, &m_InputData.m_PrevWeapon, 0}; Console()->Register("+prevweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to previous weapon"); } + { static CInputSet s_Set = {this, &m_InputData.m_NextWeapon, 0}; Console()->Register("+nextweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to next weapon"); } + { static CInputSet s_Set = {this, &m_InputData.m_PrevWeapon, 0}; Console()->Register("+prevweapon", "", CFGFLAG_CLIENT, ConKeyInputNextPrevWeapon, (void *)&s_Set, "Switch to previous weapon"); } } void CControls::OnMessage(int Msg, void *pRawMsg) { - if(Msg == NETMSGTYPE_SV_WEAPONPICKUP) - { - CNetMsg_Sv_WeaponPickup *pMsg = (CNetMsg_Sv_WeaponPickup *)pRawMsg; - if(g_Config.m_ClAutoswitchWeapons) - m_InputData.m_WantedWeapon = pMsg->m_Weapon+1; - } + if(Msg == NETMSGTYPE_SV_WEAPONPICKUP) + { + CNetMsg_Sv_WeaponPickup *pMsg = (CNetMsg_Sv_WeaponPickup *)pRawMsg; + if(g_Config.m_ClAutoswitchWeapons) + m_InputData.m_WantedWeapon = pMsg->m_Weapon+1; + } } int CControls::SnapInput(int *pData) { static int64 LastSendTime = 0; bool Send = false; - + // update player state if(m_pClient->m_pChat->IsActive()) m_InputData.m_PlayerFlags = PLAYERFLAG_CHATTING; @@ -118,20 +118,20 @@ int CControls::SnapInput(int *pData) m_InputData.m_PlayerFlags = PLAYERFLAG_IN_MENU; else m_InputData.m_PlayerFlags = PLAYERFLAG_PLAYING; - + if(m_pClient->m_pScoreboard->Active()) m_InputData.m_PlayerFlags |= PLAYERFLAG_SCOREBOARD; if(m_LastData.m_PlayerFlags != m_InputData.m_PlayerFlags) Send = true; - + m_LastData.m_PlayerFlags = m_InputData.m_PlayerFlags; - + // we freeze the input if chat or menu is activated if(!(m_InputData.m_PlayerFlags&PLAYERFLAG_PLAYING)) { OnReset(); - + mem_copy(pData, &m_InputData, sizeof(m_InputData)); // send once a second just to be sure @@ -140,7 +140,7 @@ int CControls::SnapInput(int *pData) } else { - + m_InputData.m_TargetX = (int)m_MousePos.x; m_InputData.m_TargetY = (int)m_MousePos.y; if(!m_InputData.m_TargetX && !m_InputData.m_TargetY) @@ -148,7 +148,7 @@ int CControls::SnapInput(int *pData) m_InputData.m_TargetX = 1; m_MousePos.x = 1; } - + // set direction m_InputData.m_Direction = 0; if(m_InputDirectionLeft && !m_InputDirectionRight) @@ -184,16 +184,16 @@ int CControls::SnapInput(int *pData) if(time_get() > LastSendTime + time_freq()/25) Send = true; } - - // copy and return size + + // copy and return size m_LastData = m_InputData; - + if(!Send) return 0; - + LastSendTime = time_get(); mem_copy(pData, &m_InputData, sizeof(m_InputData)); - return sizeof(m_InputData); + return sizeof(m_InputData); } void CControls::OnRender() @@ -211,7 +211,7 @@ bool CControls::OnMouseMove(float x, float y) { if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_PAUSED) return false; - + m_MousePos += vec2(x, y); // TODO: ugly ClampMousePos(); @@ -224,14 +224,14 @@ void CControls::ClampMousePos() { m_MousePos.x = clamp(m_MousePos.x, 200.0f, Collision()->GetWidth()*32-200.0f); m_MousePos.y = clamp(m_MousePos.y, 200.0f, Collision()->GetHeight()*32-200.0f); - + } else { float CameraMaxDistance = 200.0f; float FollowFactor = g_Config.m_ClMouseFollowfactor/100.0f; float MouseMax = min(CameraMaxDistance/FollowFactor + g_Config.m_ClMouseDeadzone, (float)g_Config.m_ClMouseMaxDistance); - + if(length(m_MousePos) > MouseMax) m_MousePos = normalize(m_MousePos)*MouseMax; } diff --git a/src/game/client/components/controls.h b/src/game/client/components/controls.h index a50318f5..aefc850c 100644 --- a/src/game/client/components/controls.h +++ b/src/game/client/components/controls.h @@ -6,7 +6,7 @@ #include <game/client/component.h> class CControls : public CComponent -{ +{ public: vec2 m_MousePos; vec2 m_TargetPos; @@ -17,7 +17,7 @@ public: int m_InputDirectionRight; CControls(); - + virtual void OnReset(); virtual void OnRelease(); virtual void OnRender(); @@ -25,7 +25,7 @@ public: virtual bool OnMouseMove(float x, float y); virtual void OnConsoleInit(); virtual void OnPlayerDeath(); - + int SnapInput(int *pData); void ClampMousePos(); }; diff --git a/src/game/client/components/countryflags.cpp b/src/game/client/components/countryflags.cpp index ae0217b2..2429ad3f 100644 --- a/src/game/client/components/countryflags.cpp +++ b/src/game/client/components/countryflags.cpp @@ -19,7 +19,7 @@ void CCountryFlags::LoadCountryflagsIndexfile() Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "couldn't open index file"); return; } - + char aOrigin[128]; CLineReader LineReader; LineReader.Init(File); @@ -28,7 +28,7 @@ void CCountryFlags::LoadCountryflagsIndexfile() { if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments continue; - + str_copy(aOrigin, pLine, sizeof(aOrigin)); char *pReplacement = LineReader.Get(); if(!pReplacement) @@ -36,7 +36,7 @@ void CCountryFlags::LoadCountryflagsIndexfile() Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", "unexpected end of index file"); break; } - + if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { char aBuf[128]; @@ -44,7 +44,7 @@ void CCountryFlags::LoadCountryflagsIndexfile() Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "countryflags", aBuf); continue; } - + // load the graphic file char aBuf[128]; str_format(aBuf, sizeof(aBuf), "countryflags/%s.png", aOrigin); diff --git a/src/game/client/components/countryflags.h b/src/game/client/components/countryflags.h index b0960661..cd629094 100644 --- a/src/game/client/components/countryflags.h +++ b/src/game/client/components/countryflags.h @@ -13,16 +13,16 @@ public: { int m_CountryCode; int m_Texture; - + bool operator<(const CCountryFlag &Other) { return m_CountryCode < Other.m_CountryCode; } }; - + void OnInit(); - + int Num() const; const CCountryFlag *Get(int Index) const; int Find(int CountryCode) const; - + private: sorted_array<CCountryFlag> m_aCountryFlags; diff --git a/src/game/client/components/damageind.h b/src/game/client/components/damageind.h index 0515f646..2f89e422 100644 --- a/src/game/client/components/damageind.h +++ b/src/game/client/components/damageind.h @@ -27,7 +27,7 @@ class CDamageInd : public CComponent CItem *CreateI(); void DestroyI(CItem *i); -public: +public: CDamageInd(); void Create(vec2 Pos, vec2 Dir); diff --git a/src/game/client/components/debughud.cpp b/src/game/client/components/debughud.cpp index b904f60a..7145705c 100644 --- a/src/game/client/components/debughud.cpp +++ b/src/game/client/components/debughud.cpp @@ -22,16 +22,16 @@ void CDebugHud::RenderNetCorrections() if(!g_Config.m_Debug || g_Config.m_DbgGraphs || !m_pClient->m_Snap.m_pLocalCharacter || !m_pClient->m_Snap.m_pLocalPrevCharacter) return; - float Width = 300*Graphics()->ScreenAspect(); + float Width = 300*Graphics()->ScreenAspect(); Graphics()->MapScreen(0, 0, Width, 300); - + /*float speed = distance(vec2(netobjects.local_prev_character->x, netobjects.local_prev_character->y), vec2(netobjects.local_character->x, netobjects.local_character->y));*/ float Velspeed = length(vec2(m_pClient->m_Snap.m_pLocalCharacter->m_VelX/256.0f, m_pClient->m_Snap.m_pLocalCharacter->m_VelY/256.0f))*50; float Ramp = VelocityRamp(Velspeed, m_pClient->m_Tuning.m_VelrampStart, m_pClient->m_Tuning.m_VelrampRange, m_pClient->m_Tuning.m_VelrampCurvature); - - const char *paStrings[] = {"velspeed:", "velspeed*ramp:", "ramp:", "Pos", " x:", " y:", "netobj corrections", " num:", " on:"}; + + const char *paStrings[] = {"velspeed:", "velspeed*ramp:", "ramp:", "Pos", " x:", " y:", "netobj corrections", " num:", " on:"}; const int Num = sizeof(paStrings)/sizeof(char *); const float LineHeight = 6.0f; const float Fontsize = 5.0f; @@ -75,11 +75,11 @@ void CDebugHud::RenderTuning() // render tuning debugging if(!g_Config.m_DbgTuning) return; - + CTuningParams StandardTuning; - + Graphics()->MapScreen(0, 0, 300*Graphics()->ScreenAspect(), 300); - + float y = 50.0f; int Count = 0; for(int i = 0; i < m_pClient->m_Tuning.Num(); i++) @@ -88,7 +88,7 @@ void CDebugHud::RenderTuning() float Current, Standard; m_pClient->m_Tuning.Get(i, &Current); StandardTuning.Get(i, &Standard); - + if(Standard == Current) TextRender()->TextColor(1,1,1,1.0f); else @@ -96,7 +96,7 @@ void CDebugHud::RenderTuning() float w; float x = 5.0f; - + str_format(aBuf, sizeof(aBuf), "%.2f", Standard); x += 20.0f; w = TextRender()->TextWidth(0, 5, aBuf, -1); @@ -109,12 +109,12 @@ void CDebugHud::RenderTuning() x += 5.0f; TextRender()->Text(0x0, x, y+Count*6, 5, m_pClient->m_Tuning.m_apNames[i], -1); - + Count++; } - + y = y+Count*6; - + Graphics()->TextureSet(-1); Graphics()->BlendNormal(); Graphics()->LinesBegin(); diff --git a/src/game/client/components/debughud.h b/src/game/client/components/debughud.h index ad378dc8..145f921a 100644 --- a/src/game/client/components/debughud.h +++ b/src/game/client/components/debughud.h @@ -5,7 +5,7 @@ #include <game/client/component.h> class CDebugHud : public CComponent -{ +{ void RenderNetCorrections(); void RenderTuning(); public: diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index 9a5ff2d3..573ac410 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -43,7 +43,7 @@ void CEffects::AirJump(vec2 Pos) p.m_Pos = Pos + vec2(6.0f, 16.0f); m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); - + m_pClient->m_pSounds->Play(CSounds::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, Pos); } @@ -56,7 +56,7 @@ void CEffects::PowerupShine(vec2 Pos, vec2 size) { if(!m_Add50hz) return; - + CParticle p; p.SetDefault(); p.m_Spr = SPRITE_PART_SLICE; @@ -77,7 +77,7 @@ void CEffects::SmokeTrail(vec2 Pos, vec2 Vel) { if(!m_Add50hz) return; - + CParticle p; p.SetDefault(); p.m_Spr = SPRITE_PART_SMOKE; @@ -96,7 +96,7 @@ void CEffects::SkidTrail(vec2 Pos, vec2 Vel) { if(!m_Add100hz) return; - + CParticle p; p.SetDefault(); p.m_Spr = SPRITE_PART_SMOKE; @@ -108,14 +108,14 @@ void CEffects::SkidTrail(vec2 Pos, vec2 Vel) p.m_Friction = 0.7f; p.m_Gravity = frandom()*-500.0f; p.m_Color = vec4(0.75f,0.75f,0.75f,1.0f); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); } void CEffects::BulletTrail(vec2 Pos) { if(!m_Add100hz) return; - + CParticle p; p.SetDefault(); p.m_Spr = SPRITE_PART_BALL; @@ -145,7 +145,7 @@ void CEffects::PlayerSpawn(vec2 Pos) p.m_Friction = 0.7f; p.m_Color = vec4(0xb5/255.0f, 0x50/255.0f, 0xcb/255.0f, 1.0f); m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); - + } m_pClient->m_pSounds->Play(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos); } @@ -154,7 +154,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID) { vec3 BloodColor(1.0f,1.0f,1.0f); - if(ClientID >= 0) + if(ClientID >= 0) { if(m_pClient->m_aClients[ClientID].m_UseCustomColor) BloodColor = m_pClient->m_pSkins->GetColorV3(m_pClient->m_aClients[ClientID].m_ColorBody); @@ -165,7 +165,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID) BloodColor = s->m_BloodColor; } } - + for(int i = 0; i < 64; i++) { CParticle p; @@ -195,11 +195,11 @@ void CEffects::Explosion(vec2 Pos) { if(x == 0 && y == 0) continue; - + float a = 1 - (length(vec2(x,y)) / length(vec2(8,8))); m_pClient->m_pFlow->Add(Pos+vec2(x,y)*16, normalize(vec2(x,y))*5000.0f*a, 10.0f); } - + // add the explosion CParticle p; p.SetDefault(); @@ -210,7 +210,7 @@ void CEffects::Explosion(vec2 Pos) p.m_EndSize = 0; p.m_Rot = frandom()*pi*2; m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p); - + // add the smoke for(int i = 0; i < 24; i++) { @@ -241,7 +241,7 @@ void CEffects::HammerHit(vec2 Pos) p.m_StartSize = 120.0f; p.m_EndSize = 0; p.m_Rot = frandom()*pi*2; - m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p); + m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p); m_pClient->m_pSounds->Play(CSounds::CHN_WORLD, SOUND_HAMMER_HIT, 1.0f, Pos); } @@ -253,7 +253,7 @@ void CEffects::OnRender() if(Client()->State() == IClient::STATE_DEMOPLAYBACK) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); - + if(time_get()-LastUpdate100hz > time_freq()/(100*pInfo->m_Speed)) { m_Add100hz = true; @@ -269,10 +269,10 @@ void CEffects::OnRender() } else m_Add50hz = false; - + if(m_Add50hz) m_pClient->m_pFlow->Update(); - + return; } @@ -291,7 +291,7 @@ void CEffects::OnRender() } else m_Add50hz = false; - + if(m_Add50hz) m_pClient->m_pFlow->Update(); } diff --git a/src/game/client/components/effects.h b/src/game/client/components/effects.h index b3924382..9ededb83 100644 --- a/src/game/client/components/effects.h +++ b/src/game/client/components/effects.h @@ -5,7 +5,7 @@ #include <game/client/component.h> class CEffects : public CComponent -{ +{ bool m_Add50hz; bool m_Add100hz; public: diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index 64b47b74..741a604f 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -53,7 +53,7 @@ bool CEmoticon::OnMouseMove(float x, float y) { if(!m_Active) return false; - + m_SelectorMouse += vec2(x,y); return true; } @@ -90,7 +90,7 @@ void CEmoticon::DrawCircle(float x, float y, float r, int Segments) m_pClient->Graphics()->QuadsDrawFreeform(Array, NumItems); } - + void CEmoticon::OnRender() { if(!m_Active) @@ -100,9 +100,9 @@ void CEmoticon::OnRender() m_WasActive = false; return; } - + m_WasActive = true; - + if (length(m_SelectorMouse) > 140) m_SelectorMouse = normalize(m_SelectorMouse) * 140; @@ -113,7 +113,7 @@ void CEmoticon::OnRender() if (length(m_SelectorMouse) > 100) m_SelectedEmote = (int)(SelectedAngle / (2*pi) * NUM_EMOTICONS); - CUIRect Screen = *UI()->Screen(); + CUIRect Screen = *UI()->Screen(); Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); @@ -147,12 +147,12 @@ void CEmoticon::OnRender() Graphics()->QuadsEnd(); - Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id); - Graphics()->QuadsBegin(); - Graphics()->SetColor(1,1,1,1); + Graphics()->TextureSet(g_pData->m_aImages[IMAGE_CURSOR].m_Id); + Graphics()->QuadsBegin(); + Graphics()->SetColor(1,1,1,1); IGraphics::CQuadItem QuadItem(m_SelectorMouse.x+Screen.w/2,m_SelectorMouse.y+Screen.h/2,24,24); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); } void CEmoticon::Emote(int Emoticon) diff --git a/src/game/client/components/emoticon.h b/src/game/client/components/emoticon.h index add6c9b9..37bc8372 100644 --- a/src/game/client/components/emoticon.h +++ b/src/game/client/components/emoticon.h @@ -8,19 +8,19 @@ class CEmoticon : public CComponent { void DrawCircle(float x, float y, float r, int Segments); - + bool m_WasActive; bool m_Active; - + vec2 m_SelectorMouse; int m_SelectedEmote; static void ConKeyEmoticon(IConsole::IResult *pResult, void *pUserData); static void ConEmote(IConsole::IResult *pResult, void *pUserData); - + public: CEmoticon(); - + virtual void OnReset(); virtual void OnConsoleInit(); virtual void OnRender(); diff --git a/src/game/client/components/flow.cpp b/src/game/client/components/flow.cpp index 824687c0..8cfc54e7 100644 --- a/src/game/client/components/flow.cpp +++ b/src/game/client/components/flow.cpp @@ -12,7 +12,7 @@ CFlow::CFlow() m_Width = 0; m_Spacing = 16; } - + void CFlow::DbgRender() { if(!m_pCells) @@ -34,7 +34,7 @@ void CFlow::DbgRender() NumItems = 0; } } - + if(NumItems) Graphics()->LinesDraw(Array, NumItems); Graphics()->LinesEnd(); @@ -47,12 +47,12 @@ void CFlow::Init() mem_free(m_pCells); m_pCells = 0; } - + CMapItemLayerTilemap *pTilemap = Layers()->GameLayer(); m_Width = pTilemap->m_Width*32/m_Spacing; m_Height = pTilemap->m_Height*32/m_Spacing; - // allocate and clear + // allocate and clear m_pCells = (CCell *)mem_alloc(sizeof(CCell)*m_Width*m_Height, 1); for(int y = 0; y < m_Height; y++) for(int x = 0; x < m_Width; x++) @@ -63,7 +63,7 @@ void CFlow::Update() { if(!m_pCells) return; - + for(int y = 0; y < m_Height; y++) for(int x = 0; x < m_Width; x++) m_pCells[y*m_Width+x].m_Vel *= 0.85f; @@ -73,24 +73,24 @@ vec2 CFlow::Get(vec2 Pos) { if(!m_pCells) return vec2(0,0); - + int x = (int)(Pos.x / m_Spacing); int y = (int)(Pos.y / m_Spacing); if(x < 0 || y < 0 || x >= m_Width || y >= m_Height) return vec2(0,0); - - return m_pCells[y*m_Width+x].m_Vel; + + return m_pCells[y*m_Width+x].m_Vel; } void CFlow::Add(vec2 Pos, vec2 Vel, float Size) { if(!m_pCells) return; - + int x = (int)(Pos.x / m_Spacing); int y = (int)(Pos.y / m_Spacing); if(x < 0 || y < 0 || x >= m_Width || y >= m_Height) return; - + m_pCells[y*m_Width+x].m_Vel += Vel; } diff --git a/src/game/client/components/flow.h b/src/game/client/components/flow.h index 3785ab56..0b8e590f 100644 --- a/src/game/client/components/flow.h +++ b/src/game/client/components/flow.h @@ -16,12 +16,12 @@ class CFlow : public CComponent int m_Height; int m_Width; int m_Spacing; - + void DbgRender(); void Init(); public: CFlow(); - + vec2 Get(vec2 Pos); void Add(vec2 Pos, vec2 Vel, float Size); void Update(); diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 00fdd88d..188691a1 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -22,7 +22,7 @@ CHud::CHud() // won't work if zero m_AverageFPS = 1.0f; } - + void CHud::OnReset() { } @@ -30,7 +30,7 @@ void CHud::OnReset() void CHud::RenderGameTimer() { float Half = 300.0f*Graphics()->ScreenAspect()/2.0f; - + if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_SUDDENDEATH)) { char Buf[32]; @@ -40,7 +40,7 @@ void CHud::RenderGameTimer() Time = m_pClient->m_Snap.m_pGameInfoObj->m_TimeLimit*60 - ((Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed()); if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER) - Time = 0; + Time = 0; } else Time = (Client()->GameTick()-m_pClient->m_Snap.m_pGameInfoObj->m_RoundStartTick)/Client()->GameTickSpeed(); @@ -72,7 +72,7 @@ void CHud::RenderSuddenDeath() } void CHud::RenderScoreHud() -{ +{ // render small score hud if(!(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER)) { @@ -89,7 +89,7 @@ void CHud::RenderScoreHud() float ScoreWidthMax = max(max(aScoreTeamWidth[TEAM_RED], aScoreTeamWidth[TEAM_BLUE]), TextRender()->TextWidth(0, 14.0f, "100", -1)); float Split = 3.0f; float ImageSize = GameFlags&GAMEFLAG_FLAGS ? 16.0f : Split; - + for(int t = 0; t < 2; t++) { // draw box @@ -178,7 +178,7 @@ void CHud::RenderScoreHud() float aScoreWidth[2] = {TextRender()->TextWidth(0, 14.0f, aScore[0], -1), TextRender()->TextWidth(0, 14.0f, aScore[1], -1)}; float ScoreWidthMax = max(max(aScoreWidth[0], aScoreWidth[1]), TextRender()->TextWidth(0, 14.0f, "10", -1)); float Split = 3.0f, ImageSize = 16.0f, PosSize = 16.0f; - + for(int t = 0; t < 2; t++) { // draw box @@ -230,7 +230,7 @@ void CHud::RenderWarmupTimer() str_format(Buf, sizeof(Buf), "%d", Seconds); w = TextRender()->TextWidth(0, FontSize, Buf, -1); TextRender()->Text(0, 150*Graphics()->ScreenAspect()+-w/2, 75, FontSize, Buf, -1); - } + } } void CHud::MapscreenToGroup(float CenterX, float CenterY, CMapItemGroup *pGroup) @@ -269,7 +269,7 @@ void CHud::RenderTeambalanceWarning() // render prompt about team-balance bool Flash = time_get()/(time_freq()/2)%2 == 0; if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) - { + { int TeamDiff = m_pClient->m_Snap.m_aTeamSize[TEAM_RED]-m_pClient->m_Snap.m_aTeamSize[TEAM_BLUE]; if (g_Config.m_ClWarningTeambalance && (TeamDiff >= 2 || TeamDiff <= -2)) { @@ -289,7 +289,7 @@ void CHud::RenderVoting() { if(!m_pClient->m_pVoting->IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; - + Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->SetColor(0,0,0,0.40f); @@ -309,7 +309,7 @@ void CHud::RenderVoting() Cursor.m_LineWidth = 100.0f-tw; Cursor.m_MaxLines = 3; TextRender()->TextEx(&Cursor, m_pClient->m_pVoting->VoteDescription(), -1); - + // reason str_format(aBuf, sizeof(aBuf), "%s %s", Localize("Reason:"), m_pClient->m_pVoting->VoteReason()); TextRender()->SetCursor(&Cursor, 5.0f, 79.0f, 6.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); @@ -318,7 +318,7 @@ void CHud::RenderVoting() CUIRect Base = {5, 88, 100, 4}; m_pClient->m_pVoting->RenderBars(Base, false); - + const char *pYesKey = m_pClient->m_pBinds->GetKey("vote yes"); const char *pNoKey = m_pClient->m_pBinds->GetKey("vote no"); str_format(aBuf, sizeof(aBuf), "%s - %s", pYesKey, Localize("Vote yes")); @@ -333,7 +333,7 @@ void CHud::RenderCursor() { if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; - + MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); @@ -359,9 +359,9 @@ void CHud::RenderHealthAndAmmo(const CNetObj_Character *pCharacter) // render gui stuff Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); - + Graphics()->QuadsBegin(); - + // if weaponstage is active, put a "glow" around the stage ammo RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[pCharacter->m_Weapon%NUM_WEAPONS].m_pSpriteProj); IGraphics::CQuadItem Array[10]; @@ -421,7 +421,7 @@ void CHud::OnRender() { if(!m_pClient->m_Snap.m_pGameInfoObj) return; - + m_Width = 300.0f*Graphics()->ScreenAspect(); m_Height = 300.0f; Graphics()->MapScreen(0.0f, 0.0f, m_Width, m_Height); diff --git a/src/game/client/components/hud.h b/src/game/client/components/hud.h index 75702d51..f0250c7b 100644 --- a/src/game/client/components/hud.h +++ b/src/game/client/components/hud.h @@ -5,12 +5,12 @@ #include <game/client/component.h> class CHud : public CComponent -{ +{ float m_Width, m_Height; float m_AverageFPS; - + void RenderCursor(); - + void RenderFps(); void RenderConnectionWarning(); void RenderTeambalanceWarning(); @@ -25,7 +25,7 @@ class CHud : public CComponent void MapscreenToGroup(float CenterX, float CenterY, struct CMapItemGroup *PGroup); public: CHud(); - + virtual void OnReset(); virtual void OnRender(); }; diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 5eeb3209..827b28a7 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -45,7 +45,7 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID) float Ct = (Client()->PrevGameTick()-pCurrent->m_StartTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime(); if(Ct < 0) return; // projectile havn't been shot yet - + vec2 StartPos(pCurrent->m_X, pCurrent->m_Y); vec2 StartVel(pCurrent->m_VelX/100.0f, pCurrent->m_VelY/100.0f); vec2 Pos = CalcPos(StartPos, StartVel, Curvature, Speed, Ct); @@ -54,29 +54,29 @@ void CItems::RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID) Graphics()->TextureSet(g_pData->m_aImages[IMAGE_GAME].m_Id); Graphics()->QuadsBegin(); - + RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[clamp(pCurrent->m_Type, 0, NUM_WEAPONS-1)].m_pSpriteProj); vec2 Vel = Pos-PrevPos; //vec2 pos = mix(vec2(prev->x, prev->y), vec2(current->x, current->y), Client()->IntraGameTick()); - + // add particle for this projectile if(pCurrent->m_Type == WEAPON_GRENADE) { m_pClient->m_pEffects->SmokeTrail(Pos, Vel*-1); m_pClient->m_pFlow->Add(Pos, Vel*1000*Client()->FrameTime(), 10.0f); - + if(Client()->State() == IClient::STATE_DEMOPLAYBACK) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); static float Time = 0; static float LastLocalTime = Client()->LocalTime(); - + if(!pInfo->m_Paused) Time += (Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed; - + Graphics()->QuadsSetRotation(Time*pi*2*2 + ItemID); - + LastLocalTime = Client()->LocalTime(); } else @@ -139,13 +139,13 @@ void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCu const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); static float Time = 0; static float LastLocalTime = Client()->LocalTime(); - + if(!pInfo->m_Paused) Time += (Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed; - + Pos.x += cosf(Time*2.0f+Offset)*2.5f; Pos.y += sinf(Time*2.0f+Offset)*2.5f; - + LastLocalTime = Client()->LocalTime(); } else @@ -174,7 +174,7 @@ void CItems::RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent, Graphics()->QuadsSetRotation(Angle); vec2 Pos = mix(vec2(pPrev->m_X, pPrev->m_Y), vec2(pCurrent->m_X, pCurrent->m_Y), Client()->IntraGameTick()); - + if(pCurGameData) { // make sure that the flag isn't interpolated between capture and return @@ -204,16 +204,16 @@ void CItems::RenderLaser(const struct CNetObj_Laser *pCurrent) float Ticks = Client()->GameTick() + Client()->IntraGameTick() - pCurrent->m_StartTick; float Ms = (Ticks/50.0f) * 1000.0f; - float a = Ms / m_pClient->m_Tuning.m_LaserBounceDelay; + float a = Ms / m_pClient->m_Tuning.m_LaserBounceDelay; a = clamp(a, 0.0f, 1.0f); float Ia = 1-a; - + vec2 Out, Border; - + Graphics()->BlendNormal(); Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); - + //vec4 inner_color(0.15f,0.35f,0.75f,1.0f); //vec4 outer_color(0.65f,0.85f,1.0f,1.0f); @@ -229,20 +229,20 @@ void CItems::RenderLaser(const struct CNetObj_Laser *pCurrent) Pos.x+Out.x, Pos.y+Out.y); Graphics()->QuadsDrawFreeform(&Freeform, 1); - // do inner + // do inner vec4 InnerColor(0.5f, 0.5f, 1.0f, 1.0f); Out = vec2(Dir.y, -Dir.x) * (5.0f*Ia); Graphics()->SetColor(InnerColor.r, InnerColor.g, InnerColor.b, 1.0f); // center - + Freeform = IGraphics::CFreeformItem( From.x-Out.x, From.y-Out.y, From.x+Out.x, From.y+Out.y, Pos.x-Out.x, Pos.y-Out.y, Pos.x+Out.x, Pos.y+Out.y); Graphics()->QuadsDrawFreeform(&Freeform, 1); - + Graphics()->QuadsEnd(); - + // render head { Graphics()->BlendNormal(); @@ -260,8 +260,8 @@ void CItems::RenderLaser(const struct CNetObj_Laser *pCurrent) Graphics()->QuadsDraw(&QuadItem, 1); Graphics()->QuadsEnd(); } - - Graphics()->BlendNormal(); + + Graphics()->BlendNormal(); } void CItems::OnRender() @@ -302,7 +302,7 @@ void CItems::OnRender() const void *pPrev = Client()->SnapFindItem(IClient::SNAP_PREV, Item.m_Type, Item.m_ID); if (pPrev) { - const void *pPrevGameData = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_GAMEDATA, m_pClient->m_Snap.m_GameDataSnapID); + const void *pPrevGameData = Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_GAMEDATA, m_pClient->m_Snap.m_GameDataSnapID); RenderFlag(static_cast<const CNetObj_Flag *>(pPrev), static_cast<const CNetObj_Flag *>(pData), static_cast<const CNetObj_GameData *>(pPrevGameData), m_pClient->m_Snap.m_pGameDataObj); } diff --git a/src/game/client/components/items.h b/src/game/client/components/items.h index c366b8d9..604c1b1c 100644 --- a/src/game/client/components/items.h +++ b/src/game/client/components/items.h @@ -5,24 +5,24 @@ #include <game/client/component.h> class CItems : public CComponent -{ +{ enum { MAX_EXTRA_PROJECTILES=32, }; - + CNetObj_Projectile aExtraProjectiles[MAX_EXTRA_PROJECTILES]; int ExtraProjectilesNum; - + void RenderProjectile(const CNetObj_Projectile *pCurrent, int ItemID); void RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCurrent); void RenderFlag(const CNetObj_Flag *pPrev, const CNetObj_Flag *pCurrent, const CNetObj_GameData *pPrevGameData, const CNetObj_GameData *pCurGameData); void RenderLaser(const struct CNetObj_Laser *pCurrent); - + public: virtual void OnReset(); virtual void OnRender(); - + void AddExtraProjectile(CNetObj_Projectile *pProj); }; diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index 869199cf..03f6380a 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -21,7 +21,7 @@ void CKillMessages::OnMessage(int MsgType, void *pRawMsg) if(MsgType == NETMSGTYPE_SV_KILLMSG) { CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg; - + // unpack messages CKillMsg Kill; Kill.m_VictimID = pMsg->m_Victim; @@ -69,7 +69,7 @@ void CKillMessages::OnRender() // render victim tee x -= 24.0f; - + if(m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_FLAGS) { if(m_aKillmsgs[r].m_ModeSpecial&1) @@ -82,17 +82,17 @@ void CKillMessages::OnRender() RenderTools()->SelectSprite(SPRITE_FLAG_BLUE); else RenderTools()->SelectSprite(SPRITE_FLAG_RED); - + float Size = 56.0f; IGraphics::CQuadItem QuadItem(x, y-16, Size/2, Size); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); } } - + RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_VictimRenderInfo, EMOTE_PAIN, vec2(-1,0), vec2(x, y+28)); x -= 32.0f; - + // render weapon x -= 44.0f; if (m_aKillmsgs[r].m_Weapon >= 0) @@ -119,14 +119,14 @@ void CKillMessages::OnRender() RenderTools()->SelectSprite(SPRITE_FLAG_BLUE, SPRITE_FLAG_FLIP_X); else RenderTools()->SelectSprite(SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); - + float Size = 56.0f; IGraphics::CQuadItem QuadItem(x-56, y-16, Size/2, Size); Graphics()->QuadsDrawTL(&QuadItem, 1); - Graphics()->QuadsEnd(); + Graphics()->QuadsEnd(); } - } - + } + // render killer tee x -= 24.0f; RenderTools()->RenderTee(CAnimState::GetIdle(), &m_aKillmsgs[r].m_KillerRenderInfo, EMOTE_ANGRY, vec2(1,0), vec2(x, y+28)); diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index 8bf93758..a4c3e40f 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -22,7 +22,7 @@ public: int m_ModeSpecial; // for CTF, if the guy is carrying a flag for example int m_Tick; }; - + enum { MAX_KILLMSGS = 5, diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index 2a9cecd4..dc136343 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -16,7 +16,7 @@ CMapImages::CMapImages() void CMapImages::OnMapLoad() { IMap *pMap = Kernel()->RequestInterface<IMap>(); - + // unload all textures for(int i = 0; i < m_Count; i++) { @@ -27,12 +27,12 @@ void CMapImages::OnMapLoad() int Start; pMap->GetType(MAPITEMTYPE_IMAGE, &Start, &m_Count); - + // load new textures for(int i = 0; i < m_Count; i++) { m_aTextures[i] = 0; - + CMapItemImage *pImg = (CMapItemImage *)pMap->GetItem(Start+i, 0, 0); if(pImg->m_External) { diff --git a/src/game/client/components/mapimages.h b/src/game/client/components/mapimages.h index 2aaa51fc..66101274 100644 --- a/src/game/client/components/mapimages.h +++ b/src/game/client/components/mapimages.h @@ -5,12 +5,12 @@ #include <game/client/component.h> class CMapImages : public CComponent -{ +{ int m_aTextures[64]; int m_Count; public: CMapImages(); - + int Get(int Index) const { return m_aTextures[Index]; } int Num() const { return m_Count; } diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 2fdd2acc..848651ca 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -54,26 +54,26 @@ void CMapLayers::EnvelopeEval(float TimeOffset, int Env, float *pChannels, void if(Num) pPoints = (CEnvPoint *)pThis->m_pLayers->Map()->GetItem(Start, 0, 0); } - + int Start, Num; pThis->m_pLayers->Map()->GetType(MAPITEMTYPE_ENVELOPE, &Start, &Num); - + if(Env >= Num) return; - + CMapItemEnvelope *pItem = (CMapItemEnvelope *)pThis->m_pLayers->Map()->GetItem(Start+Env, 0, 0); - + if(pThis->Client()->State() == IClient::STATE_DEMOPLAYBACK) { const IDemoPlayer::CInfo *pInfo = pThis->DemoPlayer()->BaseInfo(); static float Time = 0; static float LastLocalTime = pThis->Client()->LocalTime(); - + if(!pInfo->m_Paused) Time += (pThis->Client()->LocalTime()-LastLocalTime)*pInfo->m_Speed; - + pThis->RenderTools()->RenderEvalEnvelope(pPoints+pItem->m_StartPoint, pItem->m_NumPoints, 4, Time+TimeOffset, pChannels); - + LastLocalTime = pThis->Client()->LocalTime(); } else @@ -84,20 +84,20 @@ void CMapLayers::OnRender() { if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) return; - + CUIRect Screen; Graphics()->GetScreen(&Screen.x, &Screen.y, &Screen.w, &Screen.h); - + vec2 Center = m_pClient->m_pCamera->m_Center; //float center_x = gameclient.camera->center.x; //float center_y = gameclient.camera->center.y; - + bool PassedGameLayer = false; - + for(int g = 0; g < m_pLayers->NumGroups(); g++) { CMapItemGroup *pGroup = m_pLayers->GetGroup(g); - + if(!g_Config.m_GfxNoclip && pGroup->m_Version >= 2 && pGroup->m_UseClipping) { // set clipping @@ -108,29 +108,29 @@ void CMapLayers::OnRender() float y0 = (pGroup->m_ClipY - Points[1]) / (Points[3]-Points[1]); float x1 = ((pGroup->m_ClipX+pGroup->m_ClipW) - Points[0]) / (Points[2]-Points[0]); float y1 = ((pGroup->m_ClipY+pGroup->m_ClipH) - Points[1]) / (Points[3]-Points[1]); - + Graphics()->ClipEnable((int)(x0*Graphics()->ScreenWidth()), (int)(y0*Graphics()->ScreenHeight()), (int)((x1-x0)*Graphics()->ScreenWidth()), (int)((y1-y0)*Graphics()->ScreenHeight())); - } - + } + MapScreenToGroup(Center.x, Center.y, pGroup); - + for(int l = 0; l < pGroup->m_NumLayers; l++) { CMapItemLayer *pLayer = m_pLayers->GetLayer(pGroup->m_StartLayer+l); bool Render = false; bool IsGameLayer = false; - + if(pLayer == (CMapItemLayer*)m_pLayers->GameLayer()) { IsGameLayer = true; PassedGameLayer = 1; } - + // skip rendering if detail layers if not wanted if(pLayer->m_Flags&LAYERFLAG_DETAIL && !g_Config.m_GfxHighDetail && !IsGameLayer) continue; - + if(m_Type == -1) Render = true; else if(m_Type == 0) @@ -144,7 +144,7 @@ void CMapLayers::OnRender() if(PassedGameLayer && !IsGameLayer) Render = true; } - + if(Render && pLayer->m_Type == LAYERTYPE_TILES && Input()->KeyPressed(KEY_LCTRL) && Input()->KeyPressed(KEY_LSHIFT) && Input()->KeyDown(KEY_KP0)) { CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer; @@ -169,12 +169,12 @@ void CMapLayers::OnRender() } io_close(File); } - } - + } + if(Render && !IsGameLayer) { //layershot_begin(); - + if(pLayer->m_Type == LAYERTYPE_TILES) { CMapItemLayerTilemap *pTMap = (CMapItemLayerTilemap *)pLayer; @@ -182,7 +182,7 @@ void CMapLayers::OnRender() Graphics()->TextureSet(-1); else Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pTMap->m_Image)); - + CTile *pTiles = (CTile *)m_pLayers->Map()->GetData(pTMap->m_Data); Graphics()->BlendNone(); vec4 Color = vec4(pTMap->m_Color.r/255.0f, pTMap->m_Color.g/255.0f, pTMap->m_Color.b/255.0f, pTMap->m_Color.a/255.0f); @@ -199,23 +199,23 @@ void CMapLayers::OnRender() Graphics()->TextureSet(m_pClient->m_pMapimages->Get(pQLayer->m_Image)); CQuad *pQuads = (CQuad *)m_pLayers->Map()->GetDataSwapped(pQLayer->m_Data); - + Graphics()->BlendNone(); RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_OPAQUE, EnvelopeEval, this); Graphics()->BlendNormal(); RenderTools()->RenderQuads(pQuads, pQLayer->m_NumQuads, LAYERRENDERFLAG_TRANSPARENT, EnvelopeEval, this); } - - //layershot_end(); + + //layershot_end(); } } if(!g_Config.m_GfxNoclip) Graphics()->ClipDisable(); } - + if(!g_Config.m_GfxNoclip) Graphics()->ClipDisable(); - + // reset the screen like it was before Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); } diff --git a/src/game/client/components/maplayers.h b/src/game/client/components/maplayers.h index ac78bebf..694633ee 100644 --- a/src/game/client/components/maplayers.h +++ b/src/game/client/components/maplayers.h @@ -5,7 +5,7 @@ #include <game/client/component.h> class CMapLayers : public CComponent -{ +{ CLayers *m_pLayers; // todo refactor: maybe remove it and access it through client* int m_Type; diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 060384ec..53192714 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -52,20 +52,20 @@ CMenus::CMenus() m_Popup = POPUP_NONE; m_ActivePage = PAGE_INTERNET; m_GamePage = PAGE_GAME; - + m_NeedRestartGraphics = false; m_NeedRestartSound = false; m_NeedSendinfo = false; m_MenuActive = true; m_UseMouseButtons = true; - + m_EscapePressed = false; m_EnterPressed = false; m_DeletePressed = false; m_NumInputEvents = 0; - + m_LastInput = time_get(); - + str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder)); m_aCallvoteReason[0] = 0; @@ -84,13 +84,13 @@ vec4 CMenus::ButtonColorMul(const void *pID) int CMenus::DoButton_Icon(int ImageId, int SpriteId, const CUIRect *pRect) { Graphics()->TextureSet(g_pData->m_aImages[ImageId].m_Id); - + Graphics()->QuadsBegin(); RenderTools()->SelectSprite(SpriteId); IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - + return 0; } @@ -108,7 +108,7 @@ int CMenus::DoButton_Toggle(const void *pID, int Checked, const CUIRect *pRect) Graphics()->QuadsDrawTL(&QuadItem, 1); } Graphics()->QuadsEnd(); - + return UI()->DoButtonLogic(pID, "", Checked, pRect); } @@ -138,7 +138,7 @@ int CMenus::DoButton_MenuTab(const void *pID, const char *pText, int Checked, co CUIRect Temp; pRect->HMargin(2.0f, &Temp); UI()->DoLabel(&Temp, pText, Temp.h*ms_FontmodHeight, 0); - + return UI()->DoButtonLogic(pID, pText, Checked, pRect); } @@ -162,7 +162,7 @@ int CMenus::DoButton_CheckBox_Common(const void *pID, const char *pText, const c t.x += c.w; t.w -= c.w; t.VSplitLeft(5.0f, 0, &t); - + c.Margin(2.0f, &c); RenderTools()->DrawUIRect(&c, vec4(1,1,1,0.25f)*ButtonColorMul(pID), CUI::CORNER_ALL, 3.0f); c.y += 2; @@ -186,7 +186,7 @@ int CMenus::DoButton_CheckBox_Number(const void *pID, const char *pText, int Che int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrSize, float FontSize, float *Offset, bool Hidden, int Corners) { - int Inside = UI()->MouseInside(pRect); + int Inside = UI()->MouseInside(pRect); bool ReturnValue = false; bool UpdateOffset = false; static int s_AtIndex = 0; @@ -200,7 +200,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS int Len = str_length(pStr); if(Len == 0) s_AtIndex = 0; - + if(Inside && UI()->MouseButton(0)) { s_DoScroll = true; @@ -246,7 +246,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS } bool JustGotActive = false; - + if(UI()->ActiveItem() == pID) { if(!UI()->MouseButton(0)) @@ -264,7 +264,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS UI()->SetActiveItem(pID); } } - + if(Inside) UI()->SetHotItem(pID); @@ -272,10 +272,10 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS RenderTools()->DrawUIRect(&Textbox, vec4(1, 1, 1, 0.5f), Corners, 3.0f); Textbox.VMargin(2.0f, &Textbox); Textbox.HMargin(2.0f, &Textbox); - + const char *pDisplayStr = pStr; char aStars[128]; - + if(Hidden) { unsigned s = str_length(pStr); @@ -315,7 +315,7 @@ int CMenus::DoEditBox(void *pID, const CUIRect *pRect, char *pStr, unsigned StrS Textbox.x -= *Offset; UI()->DoLabel(&Textbox, pDisplayStr, FontSize, -1); - + // render the cursor if(UI()->LastActiveItem() == pID && !JustGotActive) { @@ -341,14 +341,14 @@ float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current) Handle.y += (pRect->h-Handle.h)*Current; // logic - float ReturnValue = Current; - int Inside = UI()->MouseInside(&Handle); + float ReturnValue = Current; + int Inside = UI()->MouseInside(&Handle); if(UI()->ActiveItem() == pID) { if(!UI()->MouseButton(0)) UI()->SetActiveItem(0); - + float Min = pRect->y; float Max = pRect->h-Handle.h; float Cur = UI()->MouseY()-OffsetY; @@ -364,7 +364,7 @@ float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current) OffsetY = UI()->MouseY()-Handle.y; } } - + if(Inside) UI()->SetHotItem(pID); @@ -382,8 +382,8 @@ float CMenus::DoScrollbarV(const void *pID, const CUIRect *pRect, float Current) Slider = Handle; Slider.Margin(5.0f, &Slider); RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f)*ButtonColorMul(pID), CUI::CORNER_ALL, 2.5f); - - return ReturnValue; + + return ReturnValue; } @@ -397,14 +397,14 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current) Handle.x += (pRect->w-Handle.w)*Current; // logic - float ReturnValue = Current; - int Inside = UI()->MouseInside(&Handle); + float ReturnValue = Current; + int Inside = UI()->MouseInside(&Handle); if(UI()->ActiveItem() == pID) { if(!UI()->MouseButton(0)) UI()->SetActiveItem(0); - + float Min = pRect->x; float Max = pRect->w-Handle.w; float Cur = UI()->MouseX()-OffsetX; @@ -420,7 +420,7 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current) OffsetX = UI()->MouseX()-Handle.x; } } - + if(Inside) UI()->SetHotItem(pID); @@ -438,8 +438,8 @@ float CMenus::DoScrollbarH(const void *pID, const CUIRect *pRect, float Current) Slider = Handle; Slider.Margin(5.0f, &Slider); RenderTools()->DrawUIRect(&Slider, vec4(1,1,1,0.25f)*ButtonColorMul(pID), CUI::CORNER_ALL, 2.5f); - - return ReturnValue; + + return ReturnValue; } int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key) @@ -450,7 +450,7 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key) static int ButtonUsed = 0; int Inside = UI()->MouseInside(pRect); int NewKey = Key; - + if(!UI()->MouseButton(0) && !UI()->MouseButton(1) && pGrabbedID == pID) MouseReleased = true; @@ -493,7 +493,7 @@ int CMenus::DoKeyReader(void *pID, const CUIRect *pRect, int Key) } } } - + if(Inside) UI()->SetHotItem(pID); @@ -515,13 +515,13 @@ int CMenus::RenderMenubar(CUIRect r) { CUIRect Box = r; CUIRect Button; - + m_ActivePage = g_Config.m_UiPage; int NewPage = -1; - + if(Client()->State() != IClient::STATE_OFFLINE) m_ActivePage = m_GamePage; - + if(Client()->State() == IClient::STATE_OFFLINE) { // offline menus @@ -531,7 +531,7 @@ int CMenus::RenderMenubar(CUIRect r) static int s_NewsButton=0; if (DoButton_MenuTab(&s_NewsButton, Localize("News"), m_ActivePage==PAGE_NEWS, &Button, 0)) NewPage = PAGE_NEWS; - Box.VSplitLeft(30.0f, 0, &Box); + Box.VSplitLeft(30.0f, 0, &Box); } Box.VSplitLeft(100.0f, &Button, &Box); @@ -557,17 +557,17 @@ int CMenus::RenderMenubar(CUIRect r) if(DoButton_MenuTab(&s_FavoritesButton, Localize("Favorites"), m_ActivePage==PAGE_FAVORITES, &Button, CUI::CORNER_TR)) { ServerBrowser()->Refresh(IServerBrowser::TYPE_FAVORITES); - NewPage = PAGE_FAVORITES; + NewPage = PAGE_FAVORITES; } - + Box.VSplitLeft(4.0f*5, 0, &Box); Box.VSplitLeft(100.0f, &Button, &Box); static int s_DemosButton=0; if(DoButton_MenuTab(&s_DemosButton, Localize("Demos"), m_ActivePage==PAGE_DEMOS, &Button, CUI::CORNER_T)) { DemolistPopulate(); - NewPage = PAGE_DEMOS; - } + NewPage = PAGE_DEMOS; + } } else { @@ -592,16 +592,16 @@ int CMenus::RenderMenubar(CUIRect r) if(DoButton_MenuTab(&s_CallVoteButton, Localize("Call vote"), m_ActivePage==PAGE_CALLVOTE, &Button, CUI::CORNER_TR)) NewPage = PAGE_CALLVOTE; } - + /* box.VSplitRight(110.0f, &box, &button); static int system_button=0; if (UI()->DoButton(&system_button, "System", g_Config.m_UiPage==PAGE_SYSTEM, &button)) g_Config.m_UiPage = PAGE_SYSTEM; - + box.VSplitRight(30.0f, &box, 0); */ - + Box.VSplitRight(90.0f, &Box, &Button); static int s_QuitButton=0; if(DoButton_MenuTab(&s_QuitButton, Localize("Quit"), 0, &Button, CUI::CORNER_T)) @@ -612,7 +612,7 @@ int CMenus::RenderMenubar(CUIRect r) static int s_SettingsButton=0; if(DoButton_MenuTab(&s_SettingsButton, Localize("Settings"), m_ActivePage==PAGE_SETTINGS, &Button, CUI::CORNER_T)) NewPage = PAGE_SETTINGS; - + if(NewPage != -1) { if(Client()->State() == IClient::STATE_OFFLINE) @@ -620,7 +620,7 @@ int CMenus::RenderMenubar(CUIRect r) else m_GamePage = NewPage; } - + return 0; } @@ -633,14 +633,14 @@ void CMenus::RenderLoading() // because that will slow down loading if we have vsync if(time_get()-LastLoadRender < time_freq()/60) return; - + LastLoadRender = time_get(); - + // need up date this here to get correct vec3 Rgb = HslToRgb(vec3(g_Config.m_UiColorHue/255.0f, g_Config.m_UiColorSat/255.0f, g_Config.m_UiColorLht/255.0f)); ms_GuiColor = vec4(Rgb.r, Rgb.g, Rgb.b, g_Config.m_UiColorAlpha/255.0f); - - CUIRect Screen = *UI()->Screen(); + + CUIRect Screen = *UI()->Screen(); Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); RenderBackground(); @@ -701,14 +701,14 @@ void CMenus::OnInit() for(array<string>::range r = my_strings.all(); !r.empty(); r.pop_front()) dbg_msg("", "%s", r.front().cstr()); - + sort(my_strings.all()); - + dbg_msg("", "after:"); for(array<string>::range r = my_strings.all(); !r.empty(); r.pop_front()) dbg_msg("", "%s", r.front().cstr()); - - + + array<int> myarray; myarray.add(4); myarray.add(6); @@ -720,17 +720,17 @@ void CMenus::OnInit() for(array<int>::range r = myarray.all(); !r.empty(); r.pop_front()) dbg_msg("", "%d", r.front()); - + sort(myarray.all()); sort_verify(myarray.all()); - + dbg_msg("", "after:"); for(array<int>::range r = myarray.all(); !r.empty(); r.pop_front()) dbg_msg("", "%d", r.front()); - + exit(-1); // */ - + if(g_Config.m_ClShowWelcome) m_Popup = POPUP_LANGUAGE; g_Config.m_ClShowWelcome = 0; @@ -759,7 +759,7 @@ void CMenus::PopupMessage(const char *pTopic, const char *pBody, const char *pBu int CMenus::Render() { - CUIRect Screen = *UI()->Screen(); + CUIRect Screen = *UI()->Screen(); Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); static bool s_First = true; @@ -774,7 +774,7 @@ int CMenus::Render() m_pClient->m_pSounds->Enqueue(CSounds::CHN_MUSIC, SOUND_MENU); s_First = false; } - + if(Client()->State() == IClient::STATE_ONLINE) { ms_ColorTabbarInactive = ms_ColorTabbarInactiveIngame; @@ -786,13 +786,13 @@ int CMenus::Render() ms_ColorTabbarInactive = ms_ColorTabbarInactiveOutgame; ms_ColorTabbarActive = ms_ColorTabbarActiveOutgame; } - + CUIRect TabBar; CUIRect MainView; // some margin around the screen Screen.Margin(10.0f, &Screen); - + static bool s_SoundCheck = false; if(!s_SoundCheck && m_Popup == POPUP_NONE) { @@ -807,14 +807,14 @@ int CMenus::Render() Screen.HSplitTop(24.0f, &TabBar, &MainView); TabBar.VMargin(20.0f, &TabBar); RenderMenubar(TabBar); - + // news is not implemented yet if(g_Config.m_UiPage <= PAGE_NEWS || g_Config.m_UiPage > PAGE_SETTINGS || (Client()->State() == IClient::STATE_OFFLINE && g_Config.m_UiPage >= PAGE_GAME && g_Config.m_UiPage <= PAGE_CALLVOTE)) { ServerBrowser()->Refresh(IServerBrowser::TYPE_INTERNET); g_Config.m_UiPage = PAGE_INTERNET; } - + // render current page if(Client()->State() != IClient::STATE_OFFLINE) { @@ -852,7 +852,7 @@ int CMenus::Render() const char *pExtraText = ""; const char *pButtonText = ""; int ExtraAlign = 0; - + if(m_Popup == POPUP_MESSAGE) { pTitle = m_aMessageTopic; @@ -862,7 +862,7 @@ int CMenus::Render() else if(m_Popup == POPUP_CONNECTING) { pTitle = Localize("Connecting to"); - pExtraText = g_Config.m_UiServerAddress; // TODO: query the client about the address + pExtraText = g_Config.m_UiServerAddress; // TODO: query the client about the address pButtonText = Localize("Abort"); if(Client()->MapDownloadTotalsize() > 0) { @@ -928,22 +928,22 @@ int CMenus::Render() pButtonText = Localize("Ok"); ExtraAlign = -1; } - + CUIRect Box, Part; Box = Screen; Box.VMargin(150.0f/UI()->Scale(), &Box); Box.HMargin(150.0f/UI()->Scale(), &Box); - + // render the box RenderTools()->DrawUIRect(&Box, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 15.0f); - + Box.HSplitTop(20.f/UI()->Scale(), &Part, &Box); Box.HSplitTop(24.f/UI()->Scale(), &Part, &Box); UI()->DoLabelScaled(&Part, pTitle, 24.f, 0); Box.HSplitTop(20.f/UI()->Scale(), &Part, &Box); Box.HSplitTop(24.f/UI()->Scale(), &Part, &Box); Part.VMargin(20.f/UI()->Scale(), &Part); - + if(ExtraAlign == -1) UI()->DoLabelScaled(&Part, pExtraText, 20.f, -1, (int)Part.w); else @@ -982,16 +982,16 @@ int CMenus::Render() else if(m_Popup == POPUP_PASSWORD) { CUIRect Label, TextBox, TryAgain, Abort; - + Box.HSplitBottom(20.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(80.0f, &Part); - + Part.VSplitMid(&Abort, &TryAgain); - + TryAgain.VMargin(20.0f, &TryAgain); Abort.VMargin(20.0f, &Abort); - + static int s_ButtonAbort = 0; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; @@ -1001,10 +1001,10 @@ int CMenus::Render() { Client()->Connect(g_Config.m_UiServerAddress); } - + Box.HSplitBottom(60.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); - + Part.VSplitLeft(60.0f, 0, &Label); Label.VSplitLeft(100.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox); @@ -1055,7 +1055,7 @@ int CMenus::Render() Box.HSplitTop(24.f, &Part, &Box); str_format(aBuf, sizeof(aBuf), "%d/%d KiB (%.1f KiB/s)", Client()->MapDownloadAmount()/1024, Client()->MapDownloadTotalsize()/1024, m_DownloadSpeed/1024.0f); UI()->DoLabel(&Part, aBuf, 20.f, 0, -1); - + // time left const char *pTimeLeftString; int TimeLeft = m_DownloadSpeed > 0.0f ? (Client()->MapDownloadTotalsize()-Client()->MapDownloadAmount())/m_DownloadSpeed : 0.0f; @@ -1103,9 +1103,9 @@ int CMenus::Render() Box.HSplitBottom(20.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(80.0f, &Part); - + Part.VSplitMid(&No, &Yes); - + Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); @@ -1135,16 +1135,16 @@ int CMenus::Render() else if(m_Popup == POPUP_RENAME_DEMO) { CUIRect Label, TextBox, Ok, Abort; - + Box.HSplitBottom(20.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(80.0f, &Part); - + Part.VSplitMid(&Abort, &Ok); - + Ok.VMargin(20.0f, &Ok); Abort.VMargin(20.0f, &Abort); - + static int s_ButtonAbort = 0; if(DoButton_Menu(&s_ButtonAbort, Localize("Abort"), 0, &Abort) || m_EscapePressed) m_Popup = POPUP_NONE; @@ -1173,10 +1173,10 @@ int CMenus::Render() PopupMessage(Localize("Error"), Localize("Unable to rename the demo"), Localize("Ok")); } } - + Box.HSplitBottom(60.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); - + Part.VSplitLeft(60.0f, 0, &Label); Label.VSplitLeft(120.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox); @@ -1191,9 +1191,9 @@ int CMenus::Render() Box.HSplitBottom(20.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(80.0f, &Part); - + Part.VSplitMid(&No, &Yes); - + Yes.VMargin(20.0f, &Yes); No.VMargin(20.0f, &No); @@ -1216,18 +1216,18 @@ int CMenus::Render() else if(m_Popup == POPUP_FIRST_LAUNCH) { CUIRect Label, TextBox; - + Box.HSplitBottom(20.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); Part.VMargin(80.0f, &Part); - + static int s_EnterButton = 0; if(DoButton_Menu(&s_EnterButton, Localize("Enter"), 0, &Part) || m_EnterPressed) m_Popup = POPUP_NONE; - + Box.HSplitBottom(40.f, &Box, &Part); Box.HSplitBottom(24.f, &Box, &Part); - + Part.VSplitLeft(60.0f, 0, &Label); Label.VSplitLeft(100.0f, 0, &TextBox); TextBox.VSplitLeft(20.0f, 0, &TextBox); @@ -1247,7 +1247,7 @@ int CMenus::Render() m_Popup = POPUP_NONE; } } - + return 0; } @@ -1281,24 +1281,24 @@ void CMenus::OnReset() bool CMenus::OnMouseMove(float x, float y) { m_LastInput = time_get(); - + if(!m_MenuActive) return false; - + m_MousePos.x += x; m_MousePos.y += y; if(m_MousePos.x < 0) m_MousePos.x = 0; if(m_MousePos.y < 0) m_MousePos.y = 0; if(m_MousePos.x > Graphics()->ScreenWidth()) m_MousePos.x = Graphics()->ScreenWidth(); if(m_MousePos.y > Graphics()->ScreenHeight()) m_MousePos.y = Graphics()->ScreenHeight(); - + return true; } bool CMenus::OnInput(IInput::CEvent e) { m_LastInput = time_get(); - + // special handle esc and enter for popup purposes if(e.m_Flags&IInput::FLAG_PRESS) { @@ -1309,7 +1309,7 @@ bool CMenus::OnInput(IInput::CEvent e) return true; } } - + if(IsActive()) { if(e.m_Flags&IInput::FLAG_PRESS) @@ -1320,7 +1320,7 @@ bool CMenus::OnInput(IInput::CEvent e) else if(e.m_Key == KEY_DELETE) m_DeletePressed = true; } - + if(m_NumInputEvents < MAX_INPUTEVENTS) m_aInputEvents[m_NumInputEvents++] = e; return true; @@ -1380,13 +1380,13 @@ void CMenus::OnRender() TextRender()->SetCursor(&cursor, 10, 30, 15, TEXTFLAG_RENDER); TextRender()->TextEx(&cursor, "ようこそ - ガイド", -1); - + //Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); Graphics()->QuadsDrawTL(60, 60, 5000, 5000); Graphics()->QuadsEnd(); return;*/ - + if(Client()->State() != IClient::STATE_ONLINE && Client()->State() != IClient::STATE_DEMOPLAYBACK) SetActive(true); @@ -1396,14 +1396,14 @@ void CMenus::OnRender() Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h); RenderDemoPlayer(Screen); } - + if(Client()->State() == IClient::STATE_ONLINE && m_pClient->m_ServerMode == m_pClient->SERVERMODE_PUREMOD) { Client()->Disconnect(); SetActive(true); m_Popup = POPUP_PURE; } - + if(!IsActive()) { m_EscapePressed = false; @@ -1412,7 +1412,7 @@ void CMenus::OnRender() m_NumInputEvents = 0; return; } - + // update colors vec3 Rgb = HslToRgb(vec3(g_Config.m_UiColorHue/255.0f, g_Config.m_UiColorSat/255.0f, g_Config.m_UiColorLht/255.0f)); ms_GuiColor = vec4(Rgb.r, Rgb.g, Rgb.b, g_Config.m_UiColorAlpha/255.0f); @@ -1427,18 +1427,18 @@ void CMenus::OnRender() ms_GuiColor.g*ColorIngameScaleI, ms_GuiColor.b*ColorIngameScaleI, ms_GuiColor.a*0.8f); - + ms_ColorTabbarActiveIngame = vec4( ms_GuiColor.r*ColorIngameAcaleA, ms_GuiColor.g*ColorIngameAcaleA, ms_GuiColor.b*ColorIngameAcaleA, ms_GuiColor.a); - + // update the ui CUIRect *pScreen = UI()->Screen(); float mx = (m_MousePos.x/(float)Graphics()->ScreenWidth())*pScreen->w; float my = (m_MousePos.y/(float)Graphics()->ScreenHeight())*pScreen->h; - + int Buttons = 0; if(m_UseMouseButtons) { @@ -1446,9 +1446,9 @@ void CMenus::OnRender() if(Input()->KeyPressed(KEY_MOUSE_2)) Buttons |= 2; if(Input()->KeyPressed(KEY_MOUSE_3)) Buttons |= 4; } - + UI()->Update(mx,my,mx*3.0f,my*3.0f,Buttons); - + // render if(Client()->State() != IClient::STATE_DEMOPLAYBACK) Render(); @@ -1510,7 +1510,7 @@ void CMenus::RenderBackground() IGraphics::CQuadItem QuadItem(0, 0, sw, sh); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - + // render the tiles Graphics()->TextureSet(-1); Graphics()->QuadsBegin(); @@ -1533,7 +1533,7 @@ void CMenus::RenderBackground() Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - // restore screen - {CUIRect Screen = *UI()->Screen(); - Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);} + // restore screen + {CUIRect Screen = *UI()->Screen(); + Graphics()->MapScreen(Screen.x, Screen.y, Screen.w, Screen.h);} } diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 11047a0b..51b8a1f8 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -25,7 +25,7 @@ public: }; class CMenus : public CComponent -{ +{ static vec4 ms_GuiColor; static vec4 ms_ColorTabbarInactiveOutgame; static vec4 ms_ColorTabbarActiveOutgame; @@ -33,7 +33,7 @@ class CMenus : public CComponent static vec4 ms_ColorTabbarActiveIngame; static vec4 ms_ColorTabbarInactive; static vec4 ms_ColorTabbarActive; - + vec4 ButtonColorMul(const void *pID); @@ -58,7 +58,7 @@ class CMenus : public CComponent //static void ui_draw_browse_icon(int what, const CUIRect *r); //static void ui_draw_grid_header(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); - + /*static void ui_draw_checkbox_common(const void *id, const char *text, const char *boxtext, const CUIRect *r, const void *extra); static void ui_draw_checkbox(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); static void ui_draw_checkbox_number(const void *id, const char *text, int checked, const CUIRect *r, const void *extra); @@ -81,13 +81,13 @@ class CMenus : public CComponent CUIRect m_Rect; CUIRect m_HitRect; }; - + void UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHeight, const char *pTitle, const char *pBottomText, int NumItems, - int ItemsPerRow, int SelectedIndex, float ScrollValue); + int ItemsPerRow, int SelectedIndex, float ScrollValue); CListboxItem UiDoListboxNextItem(const void *pID, bool Selected = false); CListboxItem UiDoListboxNextRow(); int UiDoListboxEnd(float *pScrollValue, bool *pItemActivated); - + //static void demolist_listdir_callback(const char *name, int is_dir, void *user); //static void demolist_list_callback(const CUIRect *rect, int index, void *user); @@ -105,7 +105,7 @@ class CMenus : public CComponent POPUP_REMOVE_FRIEND, POPUP_SOUNDERROR, POPUP_PASSWORD, - POPUP_QUIT, + POPUP_QUIT, }; enum @@ -129,36 +129,36 @@ class CMenus : public CComponent bool m_MenuActive; bool m_UseMouseButtons; vec2 m_MousePos; - + int64 m_LastInput; // loading int m_LoadCurrent; int m_LoadTotal; - + // char m_aMessageTopic[512]; char m_aMessageBody[512]; char m_aMessageButton[512]; - + void PopupMessage(const char *pTopic, const char *pBody, const char *pButton); - // TODO: this is a bit ugly but.. well.. yeah + // TODO: this is a bit ugly but.. well.. yeah enum { MAX_INPUTEVENTS = 32 }; static IInput::CEvent m_aInputEvents[MAX_INPUTEVENTS]; static int m_NumInputEvents; - + // some settings static float ms_ButtonHeight; static float ms_ListheaderHeight; static float ms_FontmodHeight; - + // for settings bool m_NeedRestartGraphics; bool m_NeedRestartSound; bool m_NeedSendinfo; int m_SettingPlayerPage; - + // bool m_EscapePressed; bool m_EnterPressed; @@ -168,12 +168,12 @@ class CMenus : public CComponent int64 m_DownloadLastCheckTime; int m_DownloadLastCheckSize; float m_DownloadSpeed; - + // for call vote int m_CallvoteSelectedOption; int m_CallvoteSelectedPlayer; char m_aCallvoteReason[VOTE_REASON_LENGTH]; - + // demo struct CDemoItem { @@ -181,40 +181,40 @@ class CMenus : public CComponent char m_aName[128]; bool m_IsDir; int m_StorageType; - + bool m_InfosLoaded; bool m_Valid; CDemoHeader m_Info; - + bool operator<(const CDemoItem &Other) { return !str_comp(m_aFilename, "..") ? true : !str_comp(Other.m_aFilename, "..") ? false : m_IsDir && !Other.m_IsDir ? true : !m_IsDir && Other.m_IsDir ? false : str_comp_filenames(m_aFilename, Other.m_aFilename) < 0; } }; - + sorted_array<CDemoItem> m_lDemos; char m_aCurrentDemoFolder[256]; char m_aCurrentDemoFile[64]; int m_DemolistSelectedIndex; bool m_DemolistSelectedIsDir; int m_DemolistStorageType; - + void DemolistOnUpdate(bool Reset); void DemolistPopulate(); static int DemolistFetchCallback(const char *pName, int IsDir, int StorageType, void *pUser); int m_FriendlistSelectedIndex; - + // found in menus.cpp int Render(); //void render_background(); //void render_loading(float percent); int RenderMenubar(CUIRect r); void RenderNews(CUIRect MainView); - + // found in menus_demo.cpp void RenderDemoPlayer(CUIRect MainView); void RenderDemoList(CUIRect MainView); - + // found in menus_ingame.cpp void RenderGame(CUIRect MainView); void RenderPlayers(CUIRect MainView); @@ -222,7 +222,7 @@ class CMenus : public CComponent void RenderServerControl(CUIRect MainView); void RenderServerControlKick(CUIRect MainView, bool FilterSpectators); void RenderServerControlServer(CUIRect MainView); - + // found in menus_browser.cpp int m_SelectedIndex; void RenderServerbrowserServerList(CUIRect View); @@ -231,7 +231,7 @@ class CMenus : public CComponent void RenderServerbrowserFriends(CUIRect View); void RenderServerbrowser(CUIRect MainView); static void ConchainServerbrowserUpdate(IConsole::IResult *pResult, void *pUserData, IConsole::FCommandCallback pfnCallback, void *pCallbackUserData); - + // found in menus_settings.cpp void RenderLanguageSelection(CUIRect MainView); void RenderSettingsGeneral(CUIRect MainView); @@ -241,7 +241,7 @@ class CMenus : public CComponent void RenderSettingsGraphics(CUIRect MainView); void RenderSettingsSound(CUIRect MainView); void RenderSettings(CUIRect MainView); - + void SetActive(bool Active); public: void RenderBackground(); @@ -249,7 +249,7 @@ public: void UseMouseButtons(bool Use) { m_UseMouseButtons = Use; } static CMenusKeyBinder m_Binder; - + CMenus(); void RenderLoading(); diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index b9e61401..3ab02db8 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -65,7 +65,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) {COL_FLAG_LOCK, -1, " ", -1, 14.0f, 0, {0}, {0}}, {COL_FLAG_PURE, -1, " ", -1, 14.0f, 0, {0}, {0}}, {COL_FLAG_FAV, -1, " ", -1, 14.0f, 0, {0}, {0}}, - {COL_NAME, IServerBrowser::SORT_NAME, "Name", 0, 300.0f, 0, {0}, {0}}, // Localize - these strings are localized within CLocConstString + {COL_NAME, IServerBrowser::SORT_NAME, "Name", 0, 300.0f, 0, {0}, {0}}, // Localize - these strings are localized within CLocConstString {COL_GAMETYPE, IServerBrowser::SORT_GAMETYPE, "Type", 1, 50.0f, 0, {0}, {0}}, {COL_MAP, IServerBrowser::SORT_MAP, "Map", 1, 100.0f, 0, {0}, {0}}, {COL_PLAYERS, IServerBrowser::SORT_NUMPLAYERS, "Players", 1, 60.0f, 0, {0}, {0}}, @@ -161,8 +161,8 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) } else ScrollNum = 0; - - if(m_SelectedIndex > -1) + + if(m_SelectedIndex > -1) { for(int i = 0; i < m_NumInputEvents; i++) { @@ -174,10 +174,10 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) } if(NewIndex > -1 && NewIndex < NumServers) { - //scroll - float IndexY = View.y - s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h + NewIndex*s_aCols[0].m_Rect.h; + //scroll + float IndexY = View.y - s_ScrollValue*ScrollNum*s_aCols[0].m_Rect.h + NewIndex*s_aCols[0].m_Rect.h; int Scroll = View.y > IndexY ? -1 : View.y+View.h < IndexY+s_aCols[0].m_Rect.h ? 1 : 0; - if(Scroll) + if(Scroll) { if(Scroll < 0) { @@ -192,15 +192,15 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) } m_SelectedIndex = NewIndex; - + const CServerInfo *pItem = ServerBrowser()->SortedGet(m_SelectedIndex); str_copy(g_Config.m_UiServerAddress, pItem->m_aAddress, sizeof(g_Config.m_UiServerAddress)); } } } - - if(s_ScrollValue < 0) s_ScrollValue = 0; - if(s_ScrollValue > 1) s_ScrollValue = 1; + + if(s_ScrollValue < 0) s_ScrollValue = 0; + if(s_ScrollValue > 1) s_ScrollValue = 1; // set clipping UI()->ClipEnable(&View); @@ -224,7 +224,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) int ItemIndex = i; const CServerInfo *pItem = ServerBrowser()->SortedGet(ItemIndex); CUIRect Row; - CUIRect SelectHitBox; + CUIRect SelectHitBox; int Selected = str_comp(pItem->m_aAddress, g_Config.m_UiServerAddress) == 0; //selected_index==ItemIndex; @@ -422,7 +422,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) Client()->ServerBrowserUpdate(); } } - + // render status char aBuf[128]; if(ServerBrowser()->IsRefreshing()) @@ -481,7 +481,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) ServerFilter.HSplitTop(20.0f, &Button, &ServerFilter); if (DoButton_CheckBox((char *)&g_Config.m_BrFilterPureMap, Localize("Standard map"), g_Config.m_BrFilterPureMap, &Button)) g_Config.m_BrFilterPureMap ^= 1; - + ServerFilter.HSplitTop(5.0f, 0, &ServerFilter); ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter); @@ -496,9 +496,9 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter); CUIRect EditBox; Button.VSplitRight(60.0f, &Button, &EditBox); - + UI()->DoLabelScaled(&Button, Localize("Maximum ping:"), FontSize, -1); - + char aBuf[5]; str_format(aBuf, sizeof(aBuf), "%d", g_Config.m_BrFilterPing); static float Offset = 0.0f; @@ -510,7 +510,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) ServerFilter.HSplitTop(3.0f, 0, &ServerFilter); ServerFilter.HSplitTop(19.0f, &Button, &ServerFilter); UI()->DoLabelScaled(&Button, Localize("Server address:"), FontSize, -1); - Button.VSplitRight(60.0f, 0, &Button); + Button.VSplitRight(60.0f, 0, &Button); static float OffsetAddr = 0.0f; if(DoEditBox(&g_Config.m_BrFilterServerAddress, &Button, g_Config.m_BrFilterServerAddress, sizeof(g_Config.m_BrFilterServerAddress), FontSize, &OffsetAddr)) Client()->ServerBrowserUpdate(); @@ -639,7 +639,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View) Cursor.m_LineWidth = Score.w; TextRender()->TextEx(&Cursor, aTemp, -1); } - + // name TextRender()->SetCursor(&Cursor, Name.x, Name.y, FontSize-2, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = Name.w; @@ -716,12 +716,12 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) static int s_FriendList = 0; static float s_ScrollValue = 0; UiDoListboxStart(&s_FriendList, &List, 40.0f, "", "", m_pClient->Friends()->NumFriends(), 1, m_FriendlistSelectedIndex, s_ScrollValue); - + for(int i = 0; i < m_pClient->Friends()->NumFriends(); ++i) { const CFriendInfo *pFriend = m_pClient->Friends()->GetFriend(i); CListboxItem Item = UiDoListboxNextItem(pFriend); - + if(Item.m_Visible) { Item.m_Rect.Margin(2.5f, &Item.m_Rect); @@ -732,7 +732,7 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) UI()->DoLabelScaled(&Button, pFriend->m_aClan, FontSize, -1); } } - + m_FriendlistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, 0); ServerFriends.HSplitTop(2.5f, 0, &ServerFriends); @@ -780,14 +780,14 @@ void CMenus::RenderServerbrowserFriends(CUIRect View) void CMenus::RenderServerbrowser(CUIRect MainView) { /* - +-----------------+ +------+ - | | | | - | | | tool | - | server list | | box | - | | | | - | | | | - +-----------------+ | | - status box tab +------+ + +-----------------+ +-------+ + | | | | + | | | tool | + | server list | | box | + | | | | + | | | | + +-----------------+ | | + status box tab +-------+ */ CUIRect ServerList, ToolBox, StatusBox, TabBar; @@ -843,7 +843,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView) // tool box { RenderTools()->DrawUIRect(&ToolBox, vec4(0.0f, 0.0f, 0.0f, 0.15f), CUI::CORNER_T, 4.0f); - + if(ToolboxPage == 0) RenderServerbrowserFilters(ToolBox); @@ -877,7 +877,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView) ButtonArea.VSplitRight(150.0f, 0, &ButtonArea); ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea); Button.VMargin(2.0f, &Button); - + static int s_RefreshButton = 0; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &Button)) { @@ -892,7 +892,7 @@ void CMenus::RenderServerbrowser(CUIRect MainView) ButtonArea.HSplitTop(5.0f, 0, &ButtonArea); ButtonArea.HSplitTop(20.0f, &Button, &ButtonArea); Button.VMargin(2.0f, &Button); - + static int s_JoinButton = 0; if(DoButton_Menu(&s_JoinButton, Localize("Connect"), 0, &Button) || m_EnterPressed) { diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 7e73c3eb..7fcfab99 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -28,7 +28,7 @@ int CMenus::DoButton_DemoPlayer(const void *pID, const char *pText, int Checked, int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Checked, const CUIRect *pRect, int Corners) { - RenderTools()->DrawUIRect(pRect, Checked ? vec4(1.0f, 1.0f, 1.0f, 0.10f) : vec4(1.0f, 1.0f, 1.0f, 0.5f)*ButtonColorMul(pID), Corners, 5.0f); + RenderTools()->DrawUIRect(pRect, Checked ? vec4(1.0f, 1.0f, 1.0f, 0.10f) : vec4(1.0f, 1.0f, 1.0f, 0.5f)*ButtonColorMul(pID), Corners, 5.0f); Graphics()->TextureSet(g_pData->m_aImages[ImageID].m_Id); Graphics()->QuadsBegin(); if(!Checked) @@ -37,38 +37,38 @@ int CMenus::DoButton_Sprite(const void *pID, int ImageID, int SpriteID, int Chec IGraphics::CQuadItem QuadItem(pRect->x, pRect->y, pRect->w, pRect->h); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - + return UI()->DoButtonLogic(pID, "", Checked, pRect); } void CMenus::RenderDemoPlayer(CUIRect MainView) { const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); - + const float SeekBarHeight = 15.0f; const float ButtonbarHeight = 20.0f; const float NameBarHeight = 20.0f; const float Margins = 5.0f; float TotalHeight; - + if(m_MenuActive) TotalHeight = SeekBarHeight+ButtonbarHeight+NameBarHeight+Margins*3; else TotalHeight = SeekBarHeight+Margins*2; - + MainView.HSplitBottom(TotalHeight, 0, &MainView); MainView.VSplitLeft(50.0f, 0, &MainView); MainView.VSplitRight(450.0f, &MainView, 0); - + RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_T, 10.0f); - + MainView.Margin(5.0f, &MainView); - + CUIRect SeekBar, ButtonBar, NameBar; - + int CurrentTick = pInfo->m_CurrentTick - pInfo->m_FirstTick; int TotalTicks = pInfo->m_LastTick - pInfo->m_FirstTick; - + if(m_MenuActive) { MainView.HSplitTop(SeekBarHeight, &SeekBar, &ButtonBar); @@ -84,24 +84,24 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) static int s_SeekBarID = 0; void *id = &s_SeekBarID; char aBuffer[128]; - + RenderTools()->DrawUIRect(&SeekBar, vec4(0,0,0,0.5f), CUI::CORNER_ALL, 5.0f); - + float Amount = CurrentTick/(float)TotalTicks; - + CUIRect FilledBar = SeekBar; FilledBar.w = 10.0f + (FilledBar.w-10.0f)*Amount; - + RenderTools()->DrawUIRect(&FilledBar, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 5.0f); - + str_format(aBuffer, sizeof(aBuffer), "%d:%02d / %d:%02d", CurrentTick/SERVER_TICK_SPEED/60, (CurrentTick/SERVER_TICK_SPEED)%60, TotalTicks/SERVER_TICK_SPEED/60, (TotalTicks/SERVER_TICK_SPEED)%60); UI()->DoLabel(&SeekBar, aBuffer, SeekBar.h*0.70f, 0); // do the logic - int Inside = UI()->MouseInside(&SeekBar); - + int Inside = UI()->MouseInside(&SeekBar); + if(UI()->ActiveItem() == id) { if(!UI()->MouseButton(0)) @@ -124,11 +124,11 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { if(UI()->MouseButton(0)) UI()->SetActiveItem(id); - } - + } + if(Inside) UI()->SetHotItem(id); - } + } if(CurrentTick == TotalTicks) { @@ -143,7 +143,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) { // do buttons CUIRect Button; - + // combined play and pause button ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_PlayPauseButton = 0; @@ -157,16 +157,16 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) if(DoButton_Sprite(&s_PlayPauseButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_PLAY, false, &Button, CUI::CORNER_ALL)) DemoPlayer()->Unpause(); } - + // stop button - + ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); static int s_ResetButton = 0; if(DoButton_Sprite(&s_ResetButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_STOP, false, &Button, CUI::CORNER_ALL)) { m_pClient->OnReset(); - DemoPlayer()->Pause(); + DemoPlayer()->Pause(); DemoPlayer()->SetPos(0); } @@ -176,7 +176,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) static int s_SlowDownButton = 0; if(DoButton_Sprite(&s_SlowDownButton, IMAGE_DEMOBUTTONS, SPRITE_DEMOBUTTON_SLOWER, 0, &Button, CUI::CORNER_ALL) || Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) DecreaseDemoSpeed = true; - + // fastforward ButtonBar.VSplitLeft(Margins, 0, &ButtonBar); ButtonBar.VSplitLeft(ButtonbarHeight, &Button, &ButtonBar); @@ -250,15 +250,15 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe CUIRect Scroll, Row; CUIRect View = *pRect; CUIRect Header, Footer; - + // draw header View.HSplitTop(ms_ListheaderHeight, &Header, &View); - RenderTools()->DrawUIRect(&Header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); + RenderTools()->DrawUIRect(&Header, vec4(1,1,1,0.25f), CUI::CORNER_T, 5.0f); UI()->DoLabel(&Header, pTitle, Header.h*ms_FontmodHeight, 0); // draw footers View.HSplitBottom(ms_ListheaderHeight, &View, &Footer); - RenderTools()->DrawUIRect(&Footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); + RenderTools()->DrawUIRect(&Footer, vec4(1,1,1,0.25f), CUI::CORNER_B, 5.0f); Footer.VSplitLeft(10.0f, 0, &Footer); UI()->DoLabel(&Footer, pBottomText, Header.h*ms_FontmodHeight, 0); @@ -268,7 +268,7 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe // prepare the scroll View.VSplitRight(15, &View, &Scroll); - // setup the variables + // setup the variables gs_ListBoxOriginalView = View; gs_ListBoxSelectedIndex = SelectedIndex; gs_ListBoxNewSelected = SelectedIndex; @@ -282,7 +282,7 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe // do the scrollbar View.HSplitTop(gs_ListBoxRowHeight, &Row, 0); - + int NumViewable = (int)(gs_ListBoxOriginalView.h/Row.h) + 1; int Num = (NumItems+gs_ListBoxItemsPerRow-1)/gs_ListBoxItemsPerRow-NumViewable+1; if(Num < 0) @@ -293,14 +293,14 @@ void CMenus::UiDoListboxStart(const void *pID, const CUIRect *pRect, float RowHe gs_ListBoxScrollValue -= 3.0f/Num; if(Input()->KeyPresses(KEY_MOUSE_WHEEL_DOWN)) gs_ListBoxScrollValue += 3.0f/Num; - + if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f; if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f; } - + Scroll.HMargin(5.0f, &Scroll); gs_ListBoxScrollValue = DoScrollbarV(pID, &Scroll, gs_ListBoxScrollValue); - + // the list gs_ListBoxView = gs_ListBoxOriginalView; gs_ListBoxView.VMargin(5.0f, &gs_ListBoxView); @@ -319,24 +319,24 @@ CMenus::CListboxItem CMenus::UiDoListboxNextRow() Item.m_Visible = 1; //item.rect = row; - + Item.m_HitRect = Item.m_Rect; - + //CUIRect select_hit_box = item.rect; if(gs_ListBoxSelectedIndex == gs_ListBoxItemIndex) Item.m_Selected = 1; - + // make sure that only those in view can be selected if(Item.m_Rect.y+Item.m_Rect.h > gs_ListBoxOriginalView.y) { - + if(Item.m_HitRect.y < Item.m_HitRect.y) // clip the selection { Item.m_HitRect.h -= gs_ListBoxOriginalView.y-Item.m_HitRect.y; Item.m_HitRect.y = gs_ListBoxOriginalView.y; } - + } else Item.m_Visible = 0; @@ -344,7 +344,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextRow() // check if we need to do more if(Item.m_Rect.y > gs_ListBoxOriginalView.y+gs_ListBoxOriginalView.h) Item.m_Visible = 0; - + gs_ListBoxItemIndex++; return Item; } @@ -358,12 +358,12 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected) gs_ListBoxNewSelected = ThisItemIndex; gs_ListBoxSelectedIndex = ThisItemIndex; } - + CListboxItem Item = UiDoListboxNextRow(); if(Item.m_Visible && UI()->DoButtonLogic(pId, "", gs_ListBoxSelectedIndex == gs_ListBoxItemIndex, &Item.m_HitRect)) gs_ListBoxNewSelected = ThisItemIndex; - + // process input, regard selected index if(gs_ListBoxSelectedIndex == ThisItemIndex) { @@ -377,7 +377,7 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected) UI()->SetActiveItem(0); } else - { + { for(int i = 0; i < m_NumInputEvents; i++) { int NewIndex = -1; @@ -410,18 +410,18 @@ CMenus::CListboxItem CMenus::UiDoListboxNextItem(const void *pId, bool Selected) if(gs_ListBoxScrollValue < 0.0f) gs_ListBoxScrollValue = 0.0f; if(gs_ListBoxScrollValue > 1.0f) gs_ListBoxScrollValue = 1.0f; } - + gs_ListBoxNewSelected = NewIndex; } } } } - + //selected_index = i; CUIRect r = Item.m_Rect; r.Margin(1.5f, &r); RenderTools()->DrawUIRect(&r, vec4(1,1,1,0.5f), CUI::CORNER_ALL, 4.0f); - } + } return Item; } @@ -444,7 +444,7 @@ int CMenus::DemolistFetchCallback(const char *pName, int IsDir, int StorageType, (pName[1] == '.' && pName[2] == 0 && !str_comp(pSelf->m_aCurrentDemoFolder, "demos")))) || (!IsDir && (Length < 5 || str_comp(pName+Length-5, ".demo")))) return 0; - + CDemoItem Item; str_copy(Item.m_aFilename, pName, sizeof(Item.m_aFilename)); if(IsDir) @@ -513,11 +513,11 @@ void CMenus::RenderDemoList(CUIRect MainView) str_copy(aFooterLabel, Localize("Demo details"), sizeof(aFooterLabel)); } } - + // render background RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); MainView.Margin(10.0f, &MainView); - + CUIRect ButtonBar, RefreshRect, PlayRect, DeleteRect, RenameRect, FileIcon, ListBox; MainView.HSplitBottom(ms_ButtonHeight+5.0f, &MainView, &ButtonBar); ButtonBar.HSplitTop(5.0f, 0, &ButtonBar); @@ -595,7 +595,7 @@ void CMenus::RenderDemoList(CUIRect MainView) UI()->DoLabelScaled(&Left, Localize("Netversion:"), 14.0f, -1); UI()->DoLabelScaled(&Right, m_lDemos[m_DemolistSelectedIndex].m_Info.m_aNetversion, 14.0f, -1); } - + static int s_DemoListId = 0; static float s_ScrollValue = 0; UiDoListboxStart(&s_DemoListId, &ListBox, 17.0f, Localize("Demos"), aFooterLabel, m_lDemos.size(), 1, m_DemolistSelectedIndex, s_ScrollValue); @@ -613,7 +613,7 @@ void CMenus::RenderDemoList(CUIRect MainView) bool Activated = false; m_DemolistSelectedIndex = UiDoListboxEnd(&s_ScrollValue, &Activated); DemolistOnUpdate(false); - + static int s_RefreshButton = 0; if(DoButton_Menu(&s_RefreshButton, Localize("Refresh"), 0, &RefreshRect)) { @@ -655,7 +655,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } } } - + if(!m_DemolistSelectedIsDir) { static int s_DeleteButton = 0; diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 4737f38d..33aaa14f 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -28,12 +28,12 @@ void CMenus::RenderGame(CUIRect MainView) CUIRect Button, ButtonBar; MainView.HSplitTop(45.0f, &ButtonBar, &MainView); RenderTools()->DrawUIRect(&ButtonBar, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); - + // button bar ButtonBar.HSplitTop(10.0f, 0, &ButtonBar); ButtonBar.HSplitTop(25.0f, &ButtonBar, 0); ButtonBar.VMargin(10.0f, &ButtonBar); - + ButtonBar.VSplitRight(120.0f, &ButtonBar, &Button); static int s_DisconnectButton = 0; if(DoButton_Menu(&s_DisconnectButton, Localize("Disconnect"), 0, &Button)) @@ -52,7 +52,7 @@ void CMenus::RenderGame(CUIRect MainView) SetActive(false); } } - + if(m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS) { if(m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_RED) @@ -193,7 +193,7 @@ void CMenus::RenderPlayers(CUIRect MainView) else m_pClient->Friends()->AddFriend(m_pClient->m_aClients[i].m_aName, m_pClient->m_aClients[i].m_aClan); } - + /* CUIRect bars; votearea.HSplitTop(10.0f, 0, &votearea); @@ -220,7 +220,7 @@ void CMenus::RenderPlayers(CUIRect MainView) static int no_button = 0; if(UI()->DoButton(&no_button, "No", 0, &button, ui_draw_menu_button, 0)) gameclient.voting->vote(-1); - + // do time left votearea.VSplitRight(50.0f, &votearea, &button); char buf[256]; @@ -236,10 +236,10 @@ void CMenus::RenderPlayers(CUIRect MainView) // do bars bars.HSplitTop(10.0f, 0, &bars); bars.HMargin(5.0f, &bars); - + gameclient.voting->render_bars(bars, true); - } + } else { UI()->DoLabel(&votearea, "No vote in progress", 18.0f, -1); @@ -254,33 +254,33 @@ void CMenus::RenderServerInfo(CUIRect MainView) // fetch server info CServerInfo CurrentServerInfo; Client()->GetServerInfo(&CurrentServerInfo); - + // render background RenderTools()->DrawUIRect(&MainView, ms_ColorTabbarActive, CUI::CORNER_ALL, 10.0f); - + CUIRect View, ServerInfo, GameInfo, Motd; - + float x = 0.0f; float y = 0.0f; - + char aBuf[1024]; - + // set view to use for all sub-modules MainView.Margin(10.0f, &View); - + // serverinfo View.HSplitTop(View.h/2/UI()->Scale()-5.0f, &ServerInfo, &Motd); ServerInfo.VSplitLeft(View.w/2/UI()->Scale()-5.0f, &ServerInfo, &GameInfo); RenderTools()->DrawUIRect(&ServerInfo, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); - + ServerInfo.Margin(5.0f, &ServerInfo); - + x = 5.0f; y = 0.0f; - + TextRender()->Text(0, ServerInfo.x+x, ServerInfo.y+y, 32, Localize("Server info"), 250); y += 32.0f+5.0f; - + mem_zero(aBuf, sizeof(aBuf)); str_format( aBuf, @@ -296,9 +296,9 @@ void CMenus::RenderServerInfo(CUIRect MainView) Localize("Version"), CurrentServerInfo.m_aVersion, Localize("Password"), CurrentServerInfo.m_Flags &1 ? Localize("Yes") : Localize("No") ); - + TextRender()->Text(0, ServerInfo.x+x, ServerInfo.y+y, 20, aBuf, 250); - + { CUIRect Button; int IsFavorite = ServerBrowser()->IsFavorite(CurrentServerInfo.m_NetAddr); @@ -312,19 +312,19 @@ void CMenus::RenderServerInfo(CUIRect MainView) ServerBrowser()->AddFavorite(CurrentServerInfo.m_NetAddr); } } - + // gameinfo GameInfo.VSplitLeft(10.0f, 0x0, &GameInfo); RenderTools()->DrawUIRect(&GameInfo, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); - + GameInfo.Margin(5.0f, &GameInfo); - + x = 5.0f; y = 0.0f; - + TextRender()->Text(0, GameInfo.x+x, GameInfo.y+y, 32, Localize("Game info"), 250); y += 32.0f+5.0f; - + if(m_pClient->m_Snap.m_pGameInfoObj) { mem_zero(aBuf, sizeof(aBuf)); @@ -346,7 +346,7 @@ void CMenus::RenderServerInfo(CUIRect MainView) ); TextRender()->Text(0, GameInfo.x+x, GameInfo.y+y, 20, aBuf, 250); } - + // motd Motd.HSplitTop(10.0f, 0, &Motd); RenderTools()->DrawUIRect(&Motd, vec4(1,1,1,0.25f), CUI::CORNER_ALL, 10.0f); @@ -364,15 +364,15 @@ void CMenus::RenderServerControlServer(CUIRect MainView) static float s_ScrollValue = 0; CUIRect List = MainView; UiDoListboxStart(&s_VoteList, &List, 24.0f, "", "", m_pClient->m_pVoting->m_NumVoteOptions, 1, m_CallvoteSelectedOption, s_ScrollValue); - + for(CVoteOptionClient *pOption = m_pClient->m_pVoting->m_pFirst; pOption; pOption = pOption->m_pNext) { CListboxItem Item = UiDoListboxNextItem(pOption); - + if(Item.m_Visible) UI()->DoLabelScaled(&Item.m_Rect, pOption->m_aDescription, 16.0f, -1); } - + m_CallvoteSelectedOption = UiDoListboxEnd(&s_ScrollValue, 0); } @@ -396,11 +396,11 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) static float s_ScrollValue = 0; CUIRect List = MainView; UiDoListboxStart(&s_VoteList, &List, 24.0f, "", "", NumOptions, 1, Selected, s_ScrollValue); - + for(int i = 0; i < NumOptions; i++) { CListboxItem Item = UiDoListboxNextItem(&aPlayerIDs[i]); - + if(Item.m_Visible) { CTeeRenderInfo Info = m_pClient->m_aClients[aPlayerIDs[i]].m_RenderInfo; @@ -411,7 +411,7 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) UI()->DoLabelScaled(&Item.m_Rect, m_pClient->m_aClients[aPlayerIDs[i]].m_aName, 16.0f, -1); } } - + Selected = UiDoListboxEnd(&s_ScrollValue, 0); m_CallvoteSelectedPlayer = Selected != -1 ? aPlayerIDs[Selected] : -1; } @@ -419,7 +419,7 @@ void CMenus::RenderServerControlKick(CUIRect MainView, bool FilterSpectators) void CMenus::RenderServerControl(CUIRect MainView) { static int s_ControlPage = 0; - + // render background CUIRect Bottom, Extended, TabBar, Button; MainView.HSplitTop(20.0f, &Bottom, &MainView); @@ -461,7 +461,7 @@ void CMenus::RenderServerControl(CUIRect MainView) { CUIRect Button; Bottom.VSplitRight(120.0f, &Bottom, &Button); - + static int s_CallVoteButton = 0; if(DoButton_Menu(&s_CallVoteButton, Localize("Call vote"), 0, &Button)) { @@ -487,7 +487,7 @@ void CMenus::RenderServerControl(CUIRect MainView) } m_aCallvoteReason[0] = 0; } - + // render kick reason CUIRect Reason; Bottom.VSplitRight(40.0f, &Bottom, 0); @@ -499,7 +499,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Reason.VSplitLeft(w+10.0f, 0, &Reason); static float s_Offset = 0.0f; DoEditBox(&m_aCallvoteReason, &Reason, m_aCallvoteReason, sizeof(m_aCallvoteReason), 14.0f, &s_Offset, false, CUI::CORNER_ALL); - + // extended features (only available when authed in rcon) if(Client()->RconAuthed()) { @@ -545,7 +545,7 @@ void CMenus::RenderServerControl(CUIRect MainView) static int s_RemoveVoteButton = 0; if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button)) m_pClient->m_pVoting->RemovevoteOption(m_CallvoteSelectedOption); - + // add vote Extended.HSplitTop(20.0f, &Bottom, &Extended); @@ -571,7 +571,7 @@ void CMenus::RenderServerControl(CUIRect MainView) static float s_OffsetDesc = 0.0f; DoEditBox(&s_aVoteDescription, &Button, s_aVoteDescription, sizeof(s_aVoteDescription), 14.0f, &s_OffsetDesc, false, CUI::CORNER_ALL); - Bottom.VMargin(20.0f, &Button); + Bottom.VMargin(20.0f, &Button); static float s_OffsetCmd = 0.0f; DoEditBox(&s_aVoteCommand, &Button, s_aVoteCommand, sizeof(s_aVoteCommand), 14.0f, &s_OffsetCmd, false, CUI::CORNER_ALL); } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index 959af2f3..28f3559d 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -108,7 +108,7 @@ void CMenus::RenderSettingsGeneral(CUIRect MainView) Right.HSplitTop(20.0f, &Button, &Right); if(DoButton_CheckBox(&g_Config.m_ClNameplatesAlways, Localize("Always show name plates"), g_Config.m_ClNameplatesAlways, &Button)) g_Config.m_ClNameplatesAlways ^= 1; - + Right.HSplitTop(2.5f, 0, &Right); Right.HSplitTop(20.0f, &Label, &Right); Right.HSplitTop(20.0f, &Button, &Right); @@ -245,7 +245,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) MainView.HSplitTop(10.0f, 0, &MainView); // skin info - const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin)); + const CSkins::CSkin *pOwnSkin = m_pClient->m_pSkins->Get(m_pClient->m_pSkins->Find(g_Config.m_PlayerSkin)); CTeeRenderInfo OwnSkinInfo; if(g_Config.m_PlayerUseCustomColor) { @@ -273,7 +273,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) RenderTools()->RenderTee(CAnimState::GetIdle(), &OwnSkinInfo, 0, vec2(1, 0), vec2(Label.x+30.0f, Label.y+28.0f)); Label.HSplitTop(15.0f, 0, &Label);; Label.VSplitLeft(70.0f, 0, &Label); - UI()->DoLabelScaled(&Label, g_Config.m_PlayerSkin, 14.0f, -1, 150.0f); + UI()->DoLabelScaled(&Label, g_Config.m_PlayerSkin, 14.0f, -1, 150.0f); // custom colour selector MainView.HSplitTop(20.0f, 0, &MainView); @@ -322,7 +322,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) Label.VSplitLeft(100.0f, &Label, &Button); Button.HMargin(2.0f, &Button); - float k = ((PrevColor>>((2-s)*8))&0xff) / 255.0f; + 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); @@ -643,7 +643,7 @@ void CMenus::RenderSettingsGraphics(CUIRect MainView) CListboxItem Item = UiDoListboxNextItem(&s_aModes[i], OldSelected == i); if(Item.m_Visible) { - str_format(aBuf, sizeof(aBuf), " %dx%d %d bit", s_aModes[i].m_Width, s_aModes[i].m_Height, Depth); + str_format(aBuf, sizeof(aBuf), " %dx%d %d bit", s_aModes[i].m_Width, s_aModes[i].m_Height, Depth); UI()->DoLabelScaled(&Item.m_Rect, aBuf, 16.0f, -1); } } @@ -826,7 +826,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "couldn't open index file"); return; } - + char aOrigin[128]; CLineReader LineReader; LineReader.Init(File); @@ -835,7 +835,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< { if(!str_length(pLine) || pLine[0] == '#') // skip empty lines and comments continue; - + str_copy(aOrigin, pLine, sizeof(aOrigin)); char *pReplacement = LineReader.Get(); if(!pReplacement) @@ -843,7 +843,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", "unexpected end of index file"); break; } - + if(pReplacement[0] != '=' || pReplacement[1] != '=' || pReplacement[2] != ' ') { char aBuf[128]; @@ -851,7 +851,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< pConsole->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "localization", aBuf); continue; } - + char aFileName[128]; str_format(aFileName, sizeof(aFileName), "languages/%s.txt", aOrigin); pLanguages->add(CLanguage(pReplacement+3, aFileName)); @@ -861,7 +861,7 @@ void LoadLanguageIndexfile(IStorage *pStorage, IConsole *pConsole, sorted_array< void CMenus::RenderLanguageSelection(CUIRect MainView) { - static int s_LanguageList = 0; + static int s_LanguageList = 0; static int s_SelectedLanguage = 0; static sorted_array<CLanguage> s_Languages; static float s_ScrollValue = 0; diff --git a/src/game/client/components/motd.cpp b/src/game/client/components/motd.cpp index 96347933..76203c47 100644 --- a/src/game/client/components/motd.cpp +++ b/src/game/client/components/motd.cpp @@ -18,7 +18,7 @@ void CMotd::Clear() bool CMotd::IsActive() { - return time_get() < m_ServerMotdTime; + return time_get() < m_ServerMotdTime; } void CMotd::OnStateChange(int NewState, int OldState) @@ -31,12 +31,12 @@ void CMotd::OnRender() { if(!IsActive()) return; - + float Width = 400*3.0f*Graphics()->ScreenAspect(); float Height = 400*3.0f; Graphics()->MapScreen(0, 0, Width, Height); - + float h = 800.0f; float w = 650.0f; float x = Width/2 - w/2; @@ -61,7 +61,7 @@ void CMotd::OnMessage(int MsgType, void *pRawMsg) { CNetMsg_Sv_Motd *pMsg = (CNetMsg_Sv_Motd *)pRawMsg; - // process escaping + // process escaping str_copy(m_aServerMotd, pMsg->m_pMessage, sizeof(m_aServerMotd)); for(int i = 0; m_aServerMotd[i]; i++) { diff --git a/src/game/client/components/motd.h b/src/game/client/components/motd.h index e2240fa2..f47adaff 100644 --- a/src/game/client/components/motd.h +++ b/src/game/client/components/motd.h @@ -13,7 +13,7 @@ public: void Clear(); bool IsActive(); - + virtual void OnRender(); virtual void OnStateChange(int NewState, int OldState); virtual void OnMessage(int MsgType, void *pRawMsg); diff --git a/src/game/client/components/nameplates.cpp b/src/game/client/components/nameplates.cpp index fecd6227..6699fe24 100644 --- a/src/game/client/components/nameplates.cpp +++ b/src/game/client/components/nameplates.cpp @@ -17,9 +17,9 @@ void CNamePlates::RenderNameplate( ) { float IntraTick = Client()->IntraGameTick(); - + vec2 Position = mix(vec2(pPrevChar->m_X, pPrevChar->m_Y), vec2(pPlayerChar->m_X, pPlayerChar->m_Y), IntraTick); - + float FontSize = 18.0f + 20.0f * g_Config.m_ClNameplatesSize / 100.0f; // render name plate @@ -28,10 +28,10 @@ void CNamePlates::RenderNameplate( float a = 1; if(g_Config.m_ClNameplatesAlways == 0) a = clamp(1-powf(distance(m_pClient->m_pControls->m_TargetPos, Position)/200.0f,16.0f), 0.0f, 1.0f); - + const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName; float tw = TextRender()->TextWidth(0, FontSize, pName, -1); - + TextRender()->TextOutlineColor(0.0f, 0.0f, 0.0f, 0.5f*a); TextRender()->TextColor(1.0f, 1.0f, 1.0f, a); if(g_Config.m_ClNameplatesTeamcolors && m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) @@ -41,9 +41,9 @@ void CNamePlates::RenderNameplate( else if(pPlayerInfo->m_Team == TEAM_BLUE) TextRender()->TextColor(0.7f, 0.7f, 1.0f, a); } - + TextRender()->Text(0, Position.x-tw/2.0f, Position.y-FontSize-38.0f, FontSize, pName, -1); - + if(g_Config.m_Debug) // render client id when in debug aswell { char aBuf[128]; diff --git a/src/game/client/components/particles.cpp b/src/game/client/components/particles.cpp index 25c9dd36..c4583cb1 100644 --- a/src/game/client/components/particles.cpp +++ b/src/game/client/components/particles.cpp @@ -26,7 +26,7 @@ void CParticles::OnReset() m_aParticles[i].m_PrevPart = i-1; m_aParticles[i].m_NextPart = i+1; } - + m_aParticles[0].m_PrevPart = 0; m_aParticles[MAX_PARTICLES-1].m_NextPart = -1; m_FirstFree = 0; @@ -39,30 +39,30 @@ void CParticles::Add(int Group, CParticle *pPart) { if(Client()->State() == IClient::STATE_DEMOPLAYBACK) { - const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); + const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); if(pInfo->m_Paused) return; } if (m_FirstFree == -1) return; - + // remove from the free list int Id = m_FirstFree; m_FirstFree = m_aParticles[Id].m_NextPart; if(m_FirstFree != -1) m_aParticles[m_FirstFree].m_PrevPart = -1; - + // copy data m_aParticles[Id] = *pPart; - + // insert to the group list m_aParticles[Id].m_PrevPart = -1; m_aParticles[Id].m_NextPart = m_aFirstPart[Group]; if(m_aFirstPart[Group] != -1) m_aParticles[m_aFirstPart[Group]].m_PrevPart = Id; m_aFirstPart[Group] = Id; - + // set some parameters m_aParticles[Id].m_Life = 0; } @@ -74,14 +74,14 @@ void CParticles::Update(float TimePassed) if(FrictionFraction > 2.0f) // safty messure FrictionFraction = 0; - + int FrictionCount = 0; while(FrictionFraction > 0.05f) { FrictionCount++; FrictionFraction -= 0.05f; } - + for(int g = 0; g < NUM_GROUPS; g++) { int i = m_aFirstPart[g]; @@ -90,15 +90,15 @@ void CParticles::Update(float TimePassed) int Next = m_aParticles[i].m_NextPart; //m_aParticles[i].vel += flow_get(m_aParticles[i].pos)*time_passed * m_aParticles[i].flow_affected; m_aParticles[i].m_Vel.y += m_aParticles[i].m_Gravity*TimePassed; - + for(int f = 0; f < FrictionCount; f++) // apply friction m_aParticles[i].m_Vel *= m_aParticles[i].m_Friction; - + // move the point vec2 Vel = m_aParticles[i].m_Vel*TimePassed; Collision()->MovePoint(&m_aParticles[i].m_Pos, &Vel, 0.1f+0.9f*frandom(), NULL); m_aParticles[i].m_Vel = Vel* (1.0f/TimePassed); - + m_aParticles[i].m_Life += TimePassed; m_aParticles[i].m_Rot += TimePassed * m_aParticles[i].m_Rotspeed; @@ -110,10 +110,10 @@ void CParticles::Update(float TimePassed) m_aParticles[m_aParticles[i].m_PrevPart].m_NextPart = m_aParticles[i].m_NextPart; else m_aFirstPart[g] = m_aParticles[i].m_NextPart; - + if(m_aParticles[i].m_NextPart != -1) m_aParticles[m_aParticles[i].m_NextPart].m_PrevPart = m_aParticles[i].m_PrevPart; - + // insert to the free list if(m_FirstFree != -1) m_aParticles[m_FirstFree].m_PrevPart = i; @@ -121,7 +121,7 @@ void CParticles::Update(float TimePassed) m_aParticles[i].m_NextPart = m_FirstFree; m_FirstFree = i; } - + i = Next; } } @@ -134,16 +134,16 @@ void CParticles::OnRender() static int64 LastTime = 0; int64 t = time_get(); - + if(Client()->State() == IClient::STATE_DEMOPLAYBACK) { - const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); + const IDemoPlayer::CInfo *pInfo = DemoPlayer()->BaseInfo(); if(!pInfo->m_Paused) Update((float)((t-LastTime)/(double)time_freq())*pInfo->m_Speed); } else Update((float)((t-LastTime)/(double)time_freq())); - + LastTime = t; } @@ -168,11 +168,11 @@ void CParticles::RenderGroup(int Group) m_aParticles[i].m_Color.r, m_aParticles[i].m_Color.g, m_aParticles[i].m_Color.b, - m_aParticles[i].m_Color.a); // pow(a, 0.75f) * + m_aParticles[i].m_Color.a); // pow(a, 0.75f) * IGraphics::CQuadItem QuadItem(p.x, p.y, Size, Size); Graphics()->QuadsDraw(&QuadItem, 1); - + i = m_aParticles[i].m_NextPart; } Graphics()->QuadsEnd(); diff --git a/src/game/client/components/particles.h b/src/game/client/components/particles.h index 641ec261..176a2b05 100644 --- a/src/game/client/components/particles.h +++ b/src/game/client/components/particles.h @@ -21,7 +21,7 @@ struct CParticle m_FlowAffected = 1.0f; m_Color = vec4(1,1,1,1); } - + vec2 m_Pos; vec2 m_Vel; @@ -30,7 +30,7 @@ struct CParticle float m_FlowAffected; float m_LifeSpan; - + float m_StartSize; float m_EndSize; @@ -41,7 +41,7 @@ struct CParticle float m_Friction; vec4 m_Color; - + // set by the particle system float m_Life; int m_PrevPart; @@ -61,14 +61,14 @@ public: }; CParticles(); - + void Add(int Group, CParticle *pPart); - + virtual void OnReset(); virtual void OnRender(); private: - + enum { MAX_PARTICLES=1024*8, @@ -77,7 +77,7 @@ private: CParticle m_aParticles[MAX_PARTICLES]; int m_FirstFree; int m_aFirstPart[NUM_GROUPS]; - + void RenderGroup(int Group); void Update(float TimePassed); @@ -88,7 +88,7 @@ private: CParticles *m_pParts; virtual void OnRender() { m_pParts->RenderGroup(TGROUP); } }; - + CRenderGroup<GROUP_PROJECTILE_TRAIL> m_RenderTrail; CRenderGroup<GROUP_EXPLOSIONS> m_RenderExplosions; CRenderGroup<GROUP_GENERAL> m_RenderGeneral; diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 74a48503..6811c2ad 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -25,7 +25,7 @@ void CPlayers::RenderHand(CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float { // for drawing hand //const skin *s = skin_get(skin_id); - + float BaseSize = 10.0f; //dir = normalize(hook_pos-pos); @@ -102,7 +102,7 @@ void CPlayers::RenderHook( if(m_pClient->m_Snap.m_pGameInfoObj) IsTeamplay = (m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) != 0; - // check for ninja + // check for ninja if (Player.m_Weapon == WEAPON_NINJA) { // change the skin for the player to the ninja @@ -117,7 +117,7 @@ void CPlayers::RenderHook( RenderInfo.m_ColorBody = vec4(1,1,1,1); RenderInfo.m_ColorFeet = vec4(1,1,1,1); } - } + } } float IntraTick = Client()->IntraGameTick(); @@ -125,7 +125,7 @@ void CPlayers::RenderHook( // set size RenderInfo.m_Size = 64.0f; - + // use preditect players if needed if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { @@ -152,7 +152,7 @@ void CPlayers::RenderHook( vec2 Pos = Position; vec2 HookPos; - + if(pPlayerChar->m_HookedPlayer != -1) { if(m_pClient->m_Snap.m_pLocalInfo && pPlayerChar->m_HookedPlayer == m_pClient->m_Snap.m_pLocalInfo->m_ClientID) @@ -226,7 +226,7 @@ void CPlayers::RenderPlayer( if(m_pClient->m_Snap.m_pGameInfoObj) IsTeamplay = (m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags&GAMEFLAG_TEAMS) != 0; - // check for ninja + // check for ninja if (Player.m_Weapon == WEAPON_NINJA) { // change the skin for the player to the ninja @@ -241,18 +241,18 @@ void CPlayers::RenderPlayer( RenderInfo.m_ColorBody = vec4(1,1,1,1); RenderInfo.m_ColorFeet = vec4(1,1,1,1); } - } + } } - + // set size RenderInfo.m_Size = 64.0f; float IntraTick = Client()->IntraGameTick(); - + float Angle = mix((float)Prev.m_Angle, (float)Player.m_Angle, IntraTick)/256.0f; - + //float angle = 0; - + if(pInfo.m_Local && Client()->State() != IClient::STATE_DEMOPLAYBACK) { // just use the direct input if it's local player we are rendering @@ -264,14 +264,14 @@ void CPlayers::RenderPlayer( float mixspeed = Client()->FrameTime()*2.5f; if(player.attacktick != prev.attacktick) // shooting boosts the mixing speed mixspeed *= 15.0f; - + // move the delta on a constant speed on a x^2 curve float current = g_GameClient.m_aClients[info.cid].angle; float target = player.angle/256.0f; float delta = angular_distance(current, target); float sign = delta < 0 ? -1 : 1; float new_delta = delta - 2*mixspeed*sqrt(delta*sign)*sign + mixspeed*mixspeed; - + // make sure that it doesn't vibrate when it's still if(fabs(delta) < 2/256.0f) angle = target; @@ -280,7 +280,7 @@ void CPlayers::RenderPlayer( g_GameClient.m_aClients[info.cid].angle = angle;*/ } - + // use preditect players if needed if(pInfo.m_Local && g_Config.m_ClPredict && Client()->State() != IClient::STATE_DEMOPLAYBACK) { @@ -296,16 +296,16 @@ void CPlayers::RenderPlayer( NewTick = m_pClient->m_NewPredictedTick; } } - + vec2 Direction = GetDirection((int)(Angle*256.0f)); vec2 Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); vec2 Vel = mix(vec2(Prev.m_VelX/256.0f, Prev.m_VelY/256.0f), vec2(Player.m_VelX/256.0f, Player.m_VelY/256.0f), IntraTick); - + m_pClient->m_pFlow->Add(Position, Vel*100.0f, 10.0f); - + RenderInfo.m_GotAirJump = Player.m_Jumped&2?0:1; - - + + // detect events if(NewTick) { @@ -340,7 +340,7 @@ void CPlayers::RenderPlayer( float ct = (Client()->PrevGameTick()-Player.m_AttackTick)/(float)SERVER_TICK_SPEED + Client()->GameTickTime(); State.Add(&g_pData->m_aAnimations[ANIM_NINJA_SWING], clamp(ct*2.0f,0.0f,1.0f), 1.0f); } - + // do skidding if(!InAir && WantOtherDir && length(Vel*50) > 500.0f) { @@ -350,7 +350,7 @@ void CPlayers::RenderPlayer( m_pClient->m_pSounds->Play(CSounds::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, Position); SkidSoundTime = time_get(); } - + m_pClient->m_pEffects->SkidTrail( Position+vec2(-Player.m_Direction*6,12), vec2(-Player.m_Direction*100*length(Vel),-50) @@ -422,7 +422,7 @@ void CPlayers::RenderPlayer( { vec2 Dir = vec2(pPlayerChar->m_X,pPlayerChar->m_Y) - vec2(pPrevChar->m_X, pPrevChar->m_Y); Dir = normalize(Dir); - float HadOkenAngle = GetAngle(Dir); + float HadOkenAngle = GetAngle(Dir); Graphics()->QuadsSetRotation(HadOkenAngle ); //float offsety = -data->weapons[iw].muzzleoffsety; RenderTools()->SelectSprite(g_pData->m_Weapons.m_aId[iw].m_aSpriteMuzzles[IteX], 0); @@ -564,7 +564,7 @@ void CPlayers::OnRender() bool Local = ((const CNetObj_PlayerInfo *)pInfo)->m_Local !=0; if((p % 2) == 0 && Local) continue; if((p % 2) == 1 && !Local) continue; - + CNetObj_Character PrevChar = m_pClient->m_Snap.m_aCharacters[i].m_Prev; CNetObj_Character CurChar = m_pClient->m_Snap.m_aCharacters[i].m_Cur; @@ -582,7 +582,7 @@ void CPlayers::OnRender() (const CNetObj_PlayerInfo *)pPrevInfo, (const CNetObj_PlayerInfo *)pInfo ); - } + } } } } diff --git a/src/game/client/components/players.h b/src/game/client/components/players.h index 34cebd90..cedad0ff 100644 --- a/src/game/client/components/players.h +++ b/src/game/client/components/players.h @@ -5,21 +5,21 @@ #include <game/client/component.h> class CPlayers : public CComponent -{ +{ void RenderHand(class CTeeRenderInfo *pInfo, vec2 CenterPos, vec2 Dir, float AngleOffset, vec2 PostRotOffset); void RenderPlayer( const CNetObj_Character *pPrevChar, const CNetObj_Character *pPlayerChar, const CNetObj_PlayerInfo *pPrevInfo, const CNetObj_PlayerInfo *pPlayerInfo - ); + ); void RenderHook( const CNetObj_Character *pPrevChar, const CNetObj_Character *pPlayerChar, const CNetObj_PlayerInfo *pPrevInfo, const CNetObj_PlayerInfo *pPlayerInfo ); - + public: virtual void OnRender(); }; diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 47603255..2cec5e62 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -82,7 +82,7 @@ void CScoreboard::RenderGoals(float x, float y, float w) void CScoreboard::RenderSpectators(float x, float y, float w) { - float h = 140.0f; + float h = 140.0f; // background Graphics()->BlendNormal(); @@ -194,19 +194,19 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch float NameOffset = TeeOffset+TeeLength, NameLength = 300.0f-TeeLength; float PingOffset = x+610.0f, PingLength = 65.0f; float CountryOffset = PingOffset-(LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f, CountryLength = (LineHeight-Spacing-TeeSizeMod*5.0f)*2.0f; - float ClanOffset = x+370.0f, ClanLength = 230.0f-CountryLength; + float ClanOffset = x+370.0f, ClanLength = 230.0f-CountryLength; // render headlines y += 50.0f; float HeadlineFontsize = 22.0f; tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Score"), -1); TextRender()->Text(0, ScoreOffset+ScoreLength-tw, y, HeadlineFontsize, Localize("Score"), -1); - + TextRender()->Text(0, NameOffset, y, HeadlineFontsize, Localize("Name"), -1); - + tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Clan"), -1); TextRender()->Text(0, ClanOffset+ClanLength/2-tw/2, y, HeadlineFontsize, Localize("Clan"), -1); - + tw = TextRender()->TextWidth(0, HeadlineFontsize, Localize("Ping"), -1); TextRender()->Text(0, PingOffset+PingLength-tw, y, HeadlineFontsize, Localize("Ping"), -1); @@ -214,7 +214,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch y += HeadlineFontsize*2.0f; float FontSize = 24.0f; CTextCursor Cursor; - + for(int i = 0; i < MAX_CLIENTS; i++) { // make sure that we render the correct team @@ -249,13 +249,13 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch Graphics()->QuadsBegin(); RenderTools()->SelectSprite(pInfo->m_Team==TEAM_RED ? SPRITE_FLAG_BLUE : SPRITE_FLAG_RED, SPRITE_FLAG_FLIP_X); - + float Size = LineHeight; IGraphics::CQuadItem QuadItem(TeeOffset+0.0f, y-5.0f-Spacing/2.0f, Size/2.0f, Size); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); } - + // avatar CTeeRenderInfo TeeInfo = m_pClient->m_aClients[pInfo->m_ClientID].m_RenderInfo; TeeInfo.m_Size *= TeeSizeMod; @@ -279,7 +279,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch IGraphics::CQuadItem QuadItem(CountryOffset, y+(Spacing+TeeSizeMod*5.0f)/2.0f, CountryLength, LineHeight-Spacing-TeeSizeMod*5.0f); Graphics()->QuadsDrawTL(&QuadItem, 1); Graphics()->QuadsEnd(); - + // ping str_format(aBuf, sizeof(aBuf), "%d", clamp(pInfo->m_Latency, 0, 1000)); tw = TextRender()->TextWidth(0, FontSize, aBuf, -1); @@ -321,15 +321,15 @@ void CScoreboard::OnRender() { if(!Active()) return; - + // if the score board is active, then we should clear the motd message aswell if(m_pClient->m_pMotd->IsActive()) m_pClient->m_pMotd->Clear(); - + float Width = 400*3.0f*Graphics()->ScreenAspect(); float Height = 400*3.0f; - + Graphics()->MapScreen(0, 0, Width, Height); float w = 700.0f; @@ -342,12 +342,12 @@ void CScoreboard::OnRender() { const char *pRedClanName = GetClanName(TEAM_RED); const char *pBlueClanName = GetClanName(TEAM_BLUE); - + if(m_pClient->m_Snap.m_pGameInfoObj->m_GameStateFlags&GAMESTATEFLAG_GAMEOVER && m_pClient->m_Snap.m_pGameDataObj) { char aText[256]; str_copy(aText, Localize("Draw!"), sizeof(aText)); - + if(m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreRed > m_pClient->m_Snap.m_pGameDataObj->m_TeamscoreBlue) { if(pRedClanName) @@ -362,11 +362,11 @@ void CScoreboard::OnRender() else str_copy(aText, Localize("Blue team wins!"), sizeof(aText)); } - + float w = TextRender()->TextWidth(0, 86.0f, aText, -1); TextRender()->Text(0, Width/2-w/2, 39, 86.0f, aText, -1); } - + RenderScoreboard(Width/2-w-5.0f, 150.0f, w, TEAM_RED, pRedClanName ? pRedClanName : Localize("Red team")); RenderScoreboard(Width/2+5.0f, 150.0f, w, TEAM_BLUE, pBlueClanName ? pBlueClanName : Localize("Blue team")); } @@ -379,10 +379,10 @@ void CScoreboard::OnRender() bool CScoreboard::Active() { - // if we activly wanna look on the scoreboard + // if we activly wanna look on the scoreboard if(m_Active) return true; - + if(m_pClient->m_Snap.m_pLocalInfo && m_pClient->m_Snap.m_pLocalInfo->m_Team != TEAM_SPECTATORS) { // we are not a spectator, check if we are dead @@ -406,7 +406,7 @@ const char *CScoreboard::GetClanName(int Team) const CNetObj_PlayerInfo *pInfo = m_pClient->m_Snap.m_paInfoByScore[i]; if(!pInfo || pInfo->m_Team != Team) continue; - + if(!pClanName) { pClanName = m_pClient->m_aClients[pInfo->m_ClientID].m_aClan; @@ -420,7 +420,7 @@ const char *CScoreboard::GetClanName(int Team) return 0; } } - + if(ClanPlayers > 1 && pClanName[0]) return pClanName; else diff --git a/src/game/client/components/scoreboard.h b/src/game/client/components/scoreboard.h index 5ac43a49..ea920d35 100644 --- a/src/game/client/components/scoreboard.h +++ b/src/game/client/components/scoreboard.h @@ -12,11 +12,11 @@ class CScoreboard : public CComponent void RenderRecordingNotification(float x); static void ConKeyScoreboard(IConsole::IResult *pResult, void *pUserData); - + const char *GetClanName(int Team); - + bool m_Active; - + public: CScoreboard(); virtual void OnReset(); diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index d8550da4..dd38e9ea 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -10,13 +10,13 @@ #include "skins.h" -int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) +int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) { CSkins *pSelf = (CSkins *)pUser; int l = str_length(pName); if(l < 4 || IsDir || str_comp(pName+l-4, ".png") != 0) return 0; - + char aBuf[512]; str_format(aBuf, sizeof(aBuf), "skins/%s", pName); CImageInfo Info; @@ -26,10 +26,10 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); return 0; } - + CSkin Skin; Skin.m_OrgTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); - + int BodySize = 96; // body size unsigned char *d = (unsigned char *)Info.m_pData; int Pitch = Info.m_Width*4; @@ -47,10 +47,10 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) aColors[2] += d[y*Pitch+x*4+2]; } } - + Skin.m_BloodColor = normalize(vec3(aColors[0], aColors[1], aColors[2])); } - + // create colorless version int Step = Info.m_Format == CImageInfo::FORMAT_RGBA ? 4 : 3; @@ -63,11 +63,11 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) d[i*Step+2] = v; } - + int Freq[256] = {0}; int OrgWeight = 0; int NewWeight = 192; - + // find most common frequence for(int y = 0; y < BodySize; y++) for(int x = 0; x < BodySize; x++) @@ -75,7 +75,7 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) if(d[y*Pitch+x*4+3] > 128) Freq[d[y*Pitch+x*4]]++; } - + for(int i = 1; i < 256; i++) { if(Freq[OrgWeight] < Freq[i]) @@ -97,11 +97,11 @@ int CSkins::SkinScan(const char *pName, int IsDir, int DirType, void *pUser) d[y*Pitch+x*4+1] = v; d[y*Pitch+x*4+2] = v; } - + Skin.m_ColorTexture = pSelf->Graphics()->LoadTextureRaw(Info.m_Width, Info.m_Height, Info.m_Format, Info.m_pData, Info.m_Format, 0); mem_free(Info.m_pData); - // set skin data + // set skin data str_copy(Skin.m_aName, pName, min((int)sizeof(Skin.m_aName),l-3)); str_format(aBuf, sizeof(aBuf), "load skin %s", Skin.m_aName); pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_ADDINFO, "game", aBuf); @@ -130,7 +130,7 @@ void CSkins::OnInit() int CSkins::Num() { - return m_aSkins.size(); + return m_aSkins.size(); } const CSkins::CSkin *CSkins::Get(int Index) diff --git a/src/game/client/components/skins.h b/src/game/client/components/skins.h index d76ad85b..519f4521 100644 --- a/src/game/client/components/skins.h +++ b/src/game/client/components/skins.h @@ -19,15 +19,15 @@ public: bool operator<(const CSkin &Other) { return str_comp(m_aName, Other.m_aName) < 0; } }; - + void OnInit(); - + vec3 GetColorV3(int v); vec4 GetColorV4(int v); int Num(); const CSkin *Get(int Index); int Find(const char *pName); - + private: sorted_array<CSkin> m_aSkins; diff --git a/src/game/client/components/sounds.cpp b/src/game/client/components/sounds.cpp index 24bd0ebf..ffafa128 100644 --- a/src/game/client/components/sounds.cpp +++ b/src/game/client/components/sounds.cpp @@ -19,7 +19,7 @@ struct CUserData static int LoadSoundsThread(void *pUser) { CUserData *pData = static_cast<CUserData *>(pUser); - + for(int s = 0; s < g_pData->m_NumSounds; s++) { for(int i = 0; i < g_pData->m_aSounds[s].m_NumSounds; i++) @@ -86,7 +86,7 @@ void CSounds::OnRender() // play sound from queue if(m_QueuePos > 0) { - int64 Now = time_get(); + int64 Now = time_get(); if(m_QueueWaitTime <= Now) { Play(m_aQueue[0].m_Channel, m_aQueue[0].m_SetId, 1.0f, vec2(0,0)); @@ -122,7 +122,7 @@ void CSounds::PlayAndRecord(int Chn, int SetId, float Vol, vec2 Pos) CNetMsg_Sv_SoundGlobal Msg; Msg.m_SoundID = SetId; Client()->SendPackMsg(&Msg, MSGFLAG_NOSEND|MSGFLAG_RECORD); - + Play(Chn, SetId, Vol, Pos); } diff --git a/src/game/client/components/sounds.h b/src/game/client/components/sounds.h index ca8cfd77..2670f793 100644 --- a/src/game/client/components/sounds.h +++ b/src/game/client/components/sounds.h @@ -33,7 +33,7 @@ public: virtual void OnInit(); virtual void OnReset(); virtual void OnRender(); - + void ClearQueue(); void Enqueue(int Channel, int SetId); void Play(int Channel, int SetId, float Vol, vec2 Pos); diff --git a/src/game/client/components/spectator.cpp b/src/game/client/components/spectator.cpp index 94889de7..41c7b48f 100644 --- a/src/game/client/components/spectator.cpp +++ b/src/game/client/components/spectator.cpp @@ -32,7 +32,7 @@ void CSpectator::ConSpectateNext(IConsole::IResult *pResult, void *pUserData) CSpectator *pSelf = (CSpectator *)pUserData; int NewSpectatorID; bool GotNewSpectatorID = false; - + if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { for(int i = 0; i < MAX_CLIENTS; i++) @@ -56,7 +56,7 @@ void CSpectator::ConSpectateNext(IConsole::IResult *pResult, void *pUserData) GotNewSpectatorID = true; break; } - + if(!GotNewSpectatorID) { for(int i = 0; i < pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; i++) @@ -79,7 +79,7 @@ void CSpectator::ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData CSpectator *pSelf = (CSpectator *)pUserData; int NewSpectatorID; bool GotNewSpectatorID = false; - + if(pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { for(int i = MAX_CLIENTS -1; i > -1; i--) @@ -103,7 +103,7 @@ void CSpectator::ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData GotNewSpectatorID = true; break; } - + if(!GotNewSpectatorID) { for(int i = MAX_CLIENTS - 1; i > pSelf->m_pClient->m_Snap.m_SpecInfo.m_SpectatorID; i--) @@ -138,7 +138,7 @@ bool CSpectator::OnMouseMove(float x, float y) { if(!m_Active) return false; - + m_SelectorMouse += vec2(x,y); return true; } @@ -147,7 +147,7 @@ void CSpectator::OnRelease() { OnReset(); } - + void CSpectator::OnRender() { if(!m_Active) @@ -160,14 +160,14 @@ void CSpectator::OnRender() } return; } - + m_WasActive = true; m_SelectedSpectatorID = NO_SELECTION; // draw background float Width = 400*3.0f*Graphics()->ScreenAspect(); float Height = 400*3.0f; - + Graphics()->MapScreen(0, 0, Width, Height); Graphics()->BlendNormal(); @@ -185,7 +185,7 @@ void CSpectator::OnRender() float FontSize = 20.0f; float StartY = -190.0f; float LineHeight = 60.0f; - bool Selected = false; + bool Selected = false; if(m_pClient->m_Snap.m_SpecInfo.m_SpectatorID == SPEC_FREEVIEW) { @@ -238,7 +238,7 @@ void CSpectator::OnRender() CTeeRenderInfo TeeInfo = m_pClient->m_aClients[i].m_RenderInfo; RenderTools()->RenderTee(CAnimState::GetIdle(), &TeeInfo, EMOTE_NORMAL, vec2(1.0f, 0.0f), vec2(Width/2.0f+x+20.0f, Height/2.0f+y+20.0f)); - + y += LineHeight; } TextRender()->TextColor(1.0f, 1.0f, 1.0f, 1.0f); diff --git a/src/game/client/components/spectator.h b/src/game/client/components/spectator.h index 7dfbf856..8e775cff 100644 --- a/src/game/client/components/spectator.h +++ b/src/game/client/components/spectator.h @@ -15,7 +15,7 @@ class CSpectator : public CComponent bool m_Active; bool m_WasActive; - + int m_SelectedSpectatorID; vec2 m_SelectorMouse; @@ -23,10 +23,10 @@ class CSpectator : public CComponent static void ConSpectate(IConsole::IResult *pResult, void *pUserData); static void ConSpectateNext(IConsole::IResult *pResult, void *pUserData); static void ConSpectatePrevious(IConsole::IResult *pResult, void *pUserData); - + public: CSpectator(); - + virtual void OnConsoleInit(); virtual bool OnMouseMove(float x, float y); virtual void OnRender(); diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index feeb96f7..675d6770 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -80,7 +80,7 @@ void CVoting::CallvoteOption(int OptionID, const char *pReason, bool ForceVote) Callvote("option", pOption->m_aDescription, pReason); break; } - + OptionID--; pOption = pOption->m_pNext; } @@ -98,7 +98,7 @@ void CVoting::RemovevoteOption(int OptionID) Client()->Rcon(aBuf); break; } - + OptionID--; pOption = pOption->m_pNext; } @@ -145,7 +145,7 @@ void CVoting::AddOption(const char *pDescription) m_pLast = pOption; if(!m_pFirst) m_pFirst = pOption; - + str_copy(pOption->m_aDescription, pDescription, sizeof(pOption->m_aDescription)); ++m_NumVoteOptions; } @@ -154,7 +154,7 @@ void CVoting::ClearOptions() { m_Heap.Reset(); - m_NumVoteOptions = 0; + m_NumVoteOptions = 0; m_pFirst = 0; m_pLast = 0; @@ -199,7 +199,7 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg) m_No = pMsg->m_No; m_Pass = pMsg->m_Pass; m_Total = pMsg->m_Total; - } + } else if(MsgType == NETMSGTYPE_SV_VOTECLEAROPTIONS) { ClearOptions(); @@ -238,7 +238,7 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg) else if(MsgType == NETMSGTYPE_SV_VOTEOPTIONREMOVE) { CNetMsg_Sv_VoteOptionRemove *pMsg = (CNetMsg_Sv_VoteOptionRemove *)pRawMsg; - + for(CVoteOptionClient *pOption = m_pFirst; pOption; pOption = pOption->m_pNext) { if(str_comp(pOption->m_aDescription, pMsg->m_pDescription) == 0) @@ -277,13 +277,13 @@ void CVoting::OnRender() void CVoting::RenderBars(CUIRect Bars, bool Text) { RenderTools()->DrawUIRect(&Bars, vec4(0.8f,0.8f,0.8f,0.5f), CUI::CORNER_ALL, Bars.h/3); - + CUIRect Splitter = Bars; Splitter.x = Splitter.x+Splitter.w/2; Splitter.w = Splitter.h/2.0f; Splitter.x -= Splitter.w/2; RenderTools()->DrawUIRect(&Splitter, vec4(0.4f,0.4f,0.4f,0.5f), CUI::CORNER_ALL, Splitter.h/4); - + if(m_Total) { CUIRect PassArea = Bars; @@ -292,25 +292,25 @@ void CVoting::RenderBars(CUIRect Bars, bool Text) CUIRect YesArea = Bars; YesArea.w *= m_Yes/(float)m_Total; RenderTools()->DrawUIRect(&YesArea, vec4(0.2f,0.9f,0.2f,0.85f), CUI::CORNER_ALL, Bars.h/3); - + if(Text) { char Buf[256]; str_format(Buf, sizeof(Buf), "%d", m_Yes); UI()->DoLabel(&YesArea, Buf, Bars.h*0.75f, 0); } - + PassArea.x += YesArea.w; PassArea.w -= YesArea.w; } - + if(m_No) { CUIRect NoArea = Bars; NoArea.w *= m_No/(float)m_Total; NoArea.x = (Bars.x + Bars.w)-NoArea.w; RenderTools()->DrawUIRect(&NoArea, vec4(0.9f,0.2f,0.2f,0.85f), CUI::CORNER_ALL, Bars.h/3); - + if(Text) { char Buf[256]; @@ -327,7 +327,7 @@ void CVoting::RenderBars(CUIRect Bars, bool Text) str_format(Buf, sizeof(Buf), "%d", m_Pass); UI()->DoLabel(&PassArea, Buf, Bars.h*0.75f, 0); } - } + } } diff --git a/src/game/client/components/voting.h b/src/game/client/components/voting.h index 1f8fb8cf..8a3d824f 100644 --- a/src/game/client/components/voting.h +++ b/src/game/client/components/voting.h @@ -15,19 +15,19 @@ class CVoting : public CComponent static void ConCallvote(IConsole::IResult *pResult, void *pUserData); static void ConVote(IConsole::IResult *pResult, void *pUserData); - + int64 m_Closetime; char m_aDescription[VOTE_DESC_LENGTH]; char m_aReason[VOTE_REASON_LENGTH]; int m_Voted; int m_Yes, m_No, m_Pass, m_Total; - + void AddOption(const char *pDescription); void ClearOptions(); void Callvote(const char *pType, const char *pValue, const char *pReason); - + public: - int m_NumVoteOptions; + int m_NumVoteOptions; CVoteOptionClient *m_pFirst; CVoteOptionClient *m_pLast; @@ -39,17 +39,17 @@ public: virtual void OnConsoleInit(); virtual void OnMessage(int Msgtype, void *pRawMsg); virtual void OnRender(); - + void RenderBars(CUIRect Bars, bool Text); - + void CallvoteSpectate(int ClientID, const char *pReason, bool ForceVote = false); void CallvoteKick(int ClientID, const char *pReason, bool ForceVote = false); void CallvoteOption(int OptionID, const char *pReason, bool ForceVote = false); void RemovevoteOption(int OptionID); void AddvoteOption(const char *pDescription, const char *pCommand); - + void Vote(int v); // -1 = no, 1 = yes - + int SecondsLeft() { return (m_Closetime - time_get())/time_freq(); } bool IsVoting() { return m_Closetime != 0; } int TakenChoice() const { return m_Voted; } |