diff --git a/main/source/cl_dll/message.cpp b/main/source/cl_dll/message.cpp index 2c188c13..c158a0eb 100644 --- a/main/source/cl_dll/message.cpp +++ b/main/source/cl_dll/message.cpp @@ -686,10 +686,18 @@ int CHudMessage::MsgFunc_HudText2( const char *pszName, int iSize, void *pbuf ) string content; int flags; NetMsg_HudText2( pbuf, iSize, content, flags ); - bool theIsAutoHelp = (flags & 1) != 0; - - gHUD.AddTooltip(content.c_str(), theIsAutoHelp); + switch (flags) + { + case 2: + gHUD.SetCenterText(content.c_str()); + break; + default: + bool theIsAutoHelp = (flags & 1) != 0; + gHUD.AddTooltip(content.c_str(), theIsAutoHelp); + break; + } + return 2; } diff --git a/main/source/dlls/util.cpp b/main/source/dlls/util.cpp index 09343f47..7452bbc4 100644 --- a/main/source/dlls/util.cpp +++ b/main/source/dlls/util.cpp @@ -986,12 +986,12 @@ void UTIL_ShowMessage( const char *pString, CBaseEntity *pEntity) NetMsg_HudText( pEntity->pev, string( pString ) ); } -void UTIL_ShowMessage2( const char *pString, CBaseEntity *pEntity, bool inIsAutoHelp) +void UTIL_ShowMessage2( const char *pString, CBaseEntity *pEntity, SHOWMESSAGE_TYPE type) { if ( !pEntity || !pEntity->IsNetClient() ) return; - - NetMsg_HudText2( pEntity->pev, string( pString ), inIsAutoHelp ? 1 : 0 ); + + NetMsg_HudText2( pEntity->pev, string( pString ), type ); } diff --git a/main/source/dlls/util.h b/main/source/dlls/util.h index bc45113d..929918e8 100644 --- a/main/source/dlls/util.h +++ b/main/source/dlls/util.h @@ -265,7 +265,8 @@ extern void UTIL_ParticleEffect ( const Vector &vecOrigin, const Vector &vecD extern void UTIL_ScreenShake ( const Vector ¢er, float amplitude, float frequency, float duration, float radius ); extern void UTIL_ScreenShakeAll ( const Vector ¢er, float amplitude, float frequency, float duration ); extern void UTIL_ShowMessage ( const char *pString, CBaseEntity *pPlayer); -extern void UTIL_ShowMessage2 ( const char *pString, CBaseEntity *pPlayer, bool inIsToolTip = false); +typedef enum { NORMAL = 0, TOOLTIP = 1, CENTER = 2} SHOWMESSAGE_TYPE; +extern void UTIL_ShowMessage2 ( const char *pString, CBaseEntity *pPlayer, SHOWMESSAGE_TYPE type = NORMAL); extern void UTIL_ShowMessageAll ( const char *pString ); extern void UTIL_ScreenFadeAll ( const Vector &color, float fadeTime, float holdTime, int alpha, int flags ); extern void UTIL_ScreenFade ( CBaseEntity *pEntity, const Vector &color, float fadeTime, float fadeHold, int alpha, int flags ); diff --git a/main/source/mod/AvHConsoleCommands.cpp b/main/source/mod/AvHConsoleCommands.cpp index 0b911ee5..804daa2f 100644 --- a/main/source/mod/AvHConsoleCommands.cpp +++ b/main/source/mod/AvHConsoleCommands.cpp @@ -566,7 +566,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) { bool theIsToolTip = (theMode == 2); - theAvHPlayer->SendMessage(theTooltipText, theIsToolTip); + theAvHPlayer->SendMessage(theTooltipText, (theIsToolTip)?TOOLTIP:NORMAL); } theSuccess = true; @@ -614,7 +614,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) //} } - theTargetPlayer->SendMessage(theToolTip.c_str(), true); + theTargetPlayer->SendMessage(theToolTip.c_str(), TOOLTIP); theSuccess = true; } else @@ -889,12 +889,12 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) uint32 theParticleIndex; if(gParticleTemplateList.GetTemplateIndexWithName(theName, theParticleIndex)) { - theAvHPlayer->SendMessage(kEditingParticleSystem, true); + theAvHPlayer->SendMessage(kEditingParticleSystem, TOOLTIP); NetMsg_EditPS( theAvHPlayer->pev, theParticleIndex ); } else { - theAvHPlayer->SendMessage(kNoParticleSystem, true); + theAvHPlayer->SendMessage(kNoParticleSystem, TOOLTIP); } theSuccess = true; } @@ -1419,7 +1419,7 @@ BOOL AvHGamerules::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) } else { - theAvHPlayer->SendMessage(kSpectatorsNotAllowed, true); + theAvHPlayer->SendMessage(kSpectatorsNotAllowed, TOOLTIP); } theSuccess = true; } diff --git a/main/source/mod/AvHGamerules.cpp b/main/source/mod/AvHGamerules.cpp index d3a53df6..9b354a01 100644 --- a/main/source/mod/AvHGamerules.cpp +++ b/main/source/mod/AvHGamerules.cpp @@ -458,11 +458,11 @@ void AvHGamerules::RewardPlayerForKill(AvHPlayer* inPlayer, CBaseEntity* inTarge AvHClassType theClassType = inPlayer->GetClassType(); if(theClassType == AVH_CLASS_TYPE_MARINE) { - inPlayer->SendMessageOnce(kMarinePointsAwarded, true); + inPlayer->SendMessageOnce(kMarinePointsAwarded, TOOLTIP); } else if(theClassType == AVH_CLASS_TYPE_ALIEN) { - inPlayer->SendMessageOnce(kAlienPointsAwarded, true); + inPlayer->SendMessageOnce(kAlienPointsAwarded, TOOLTIP); } // Increment resource score in tourny mode @@ -3504,7 +3504,7 @@ void AvHGamerules::UpdateCountdown(float inTime) } FOR_ALL_ENTITIES(kAvHPlayerClassName, AvHPlayer*) - theEntity->SendMessageOnce(theMessage, true); + theEntity->SendMessageOnce(theMessage, TOOLTIP); END_FOR_ALL_ENTITIES(kAvHPlayerClassName) this->mTimeLastWontStartMessageSent = inTime; @@ -3808,7 +3808,7 @@ void AvHGamerules::UpdateVictoryStatus(void) UTIL_ScreenFade(theEntity, theFadeColor, 1.0f, 0.0f, 255, FFADE_OUT | FFADE_STAYOUT); } theEntity->PlayHUDSound(theHUDSound); - theEntity->SendMessage(theVictoryMessage); + theEntity->SendMessage(theVictoryMessage, CENTER); // Final game time update to all clients have same winning time this->SendGameTimeUpdate(true); diff --git a/main/source/mod/AvHHud.cpp b/main/source/mod/AvHHud.cpp index bc47fba7..2a448710 100644 --- a/main/source/mod/AvHHud.cpp +++ b/main/source/mod/AvHHud.cpp @@ -2029,6 +2029,21 @@ void AvHHud::ModifyAmbientSoundEntryIfChanged(bool inSoundOn, int inSoundIndex, } } +// tankefugl: +void AvHHud::SetCenterText(const char* inText) +{ + LocalizeString(inText, this->mCenterText); + this->mCenterTextTime = this->mTimeOfLastUpdate; +} + +void AvHHud::ClearCenterText() +{ + this->mCenterText.clear(); + this->mCenterTextTime = -1; +} + +// :tankefugl + // Look at incoming order. If we are one of the receivers, play a HUD sound // indicating our new order void AvHHud::OrderNotification(const AvHOrder& inOrder) @@ -2547,6 +2562,9 @@ void AvHHud::ResetGame(bool inMapChanged) this->mDisplayOrderText1 = ""; this->mDisplayOrderText2 = ""; this->mDisplayOrderText3 = ""; + + this->mCenterText.clear(); + this->mCenterTextTime = -1; // :tankefugl } diff --git a/main/source/mod/AvHHud.h b/main/source/mod/AvHHud.h index 1a5f1863..56132c7a 100644 --- a/main/source/mod/AvHHud.h +++ b/main/source/mod/AvHHud.h @@ -433,8 +433,19 @@ public: float GetServerVariableFloat(const char* inName) const; + // tankefugl: + void SetCenterText(const char* inText); + void DrawCenterText(); + void ClearCenterText(); + // :tankefugl + private: + // tankefugl: + std::string mCenterText; + float mCenterTextTime; + // :tankefugl + bool GetCommanderLabelText(std::string& outCommanderName) const; void AddCommands(); diff --git a/main/source/mod/AvHHudRender.cpp b/main/source/mod/AvHHudRender.cpp index c19b8772..501fae85 100644 --- a/main/source/mod/AvHHudRender.cpp +++ b/main/source/mod/AvHHudRender.cpp @@ -1107,6 +1107,33 @@ void AvHHud::DrawOrderText(const AvHOrder& inOrder) // :tankefugl } +// tankefugl: +#define CENTER_TEXT_LENGTH 10 +#define CENTER_TEXT_FADEOUT 2 +void AvHHud::DrawCenterText() +{ + if ((this->mCenterTextTime > -1) && (this->mTimeOfLastUpdate < this->mCenterTextTime + CENTER_TEXT_LENGTH + CENTER_TEXT_FADEOUT)) + { + int theR, theG, theB; + this->GetPrimaryHudColor(theR, theG, theB, false, false); + + if (this->mTimeOfLastUpdate > this->mCenterTextTime + CENTER_TEXT_LENGTH) + { + float fraction = this->mTimeOfLastUpdate - (this->mCenterTextTime + CENTER_TEXT_LENGTH); + fraction = 1 - fraction / CENTER_TEXT_FADEOUT; + theR *= fraction; + theG *= fraction; + theB *= fraction; + } + + int posX = 0.5 * ScreenWidth() - this->mFont.GetStringWidth(this->mCenterText.c_str()) / 2; + int posY = 0.4 * ScreenHeight(); + + this->mFont.DrawString(posX, posY, this->mCenterText.c_str(), theR, theG, theB); + } +} +// :tankefugl + // tankefugl: 0000992 void AvHHud::SetDisplayOrder(int inOrderType, int inOrderIndex, string inText1, string inText2, string inText3) { @@ -2639,6 +2666,7 @@ void AvHHud::Render() this->DrawReticleInfo(); this->DrawPlayerNames(); this->DrawToolTips(); + this->DrawCenterText(); } } diff --git a/main/source/mod/AvHMarineEquipment.cpp b/main/source/mod/AvHMarineEquipment.cpp index ddbaefb7..24024332 100644 --- a/main/source/mod/AvHMarineEquipment.cpp +++ b/main/source/mod/AvHMarineEquipment.cpp @@ -1919,7 +1919,7 @@ void AvHCommandStation::CommandTouch(CBaseEntity* pOther) // Check to see if we already have a commander and don't make the person a commander if so if(GetGameRules()->GetNumCommandersOnTeam(theStationTeamNumber) == 0) { - thePlayer->SendMessage(kHelpTextCSAttractMode, true); + thePlayer->SendMessage(kHelpTextCSAttractMode, TOOLTIP); } } } @@ -1967,7 +1967,7 @@ void AvHCommandStation::CommandUse( CBaseEntity* pActivator, CBaseEntity* pCalle } else { - thePlayer->SendMessage(kCommandStationDestroyed, true); + thePlayer->SendMessage(kCommandStationDestroyed, TOOLTIP); } } else @@ -1980,13 +1980,13 @@ void AvHCommandStation::CommandUse( CBaseEntity* pActivator, CBaseEntity* pCalle // The player somehow touches the command station while still a commander if(thePlayer->GetUser3() != AVH_USER3_COMMANDER_PLAYER) { - thePlayer->SendMessage(kCommandStationInUse, true); + thePlayer->SendMessage(kCommandStationInUse, TOOLTIP); } } } else { - thePlayer->SendMessage(kCommandStationForOtherTeam, true); + thePlayer->SendMessage(kCommandStationForOtherTeam, TOOLTIP); } } } diff --git a/main/source/mod/AvHPlayer.cpp b/main/source/mod/AvHPlayer.cpp index 6b3f03f7..673ff184 100644 --- a/main/source/mod/AvHPlayer.cpp +++ b/main/source/mod/AvHPlayer.cpp @@ -1224,7 +1224,7 @@ bool AvHPlayer::ExecuteMessage(AvHMessageID inMessageID, bool inInstantaneous, b break; case WEAPON_DROP: if(!this->DropItem()) - this->SendMessageOnce(kWeaponCantBeDropped, true); + this->SendMessageOnce(kWeaponCantBeDropped, TOOLTIP); break; case ADMIN_VOTEDOWNCOMMANDER: @@ -3240,7 +3240,7 @@ void AvHPlayer::ItemPostFrame(void) { if((this->pev->button & IN_ATTACK) || (this->pev->button & IN_ATTACK2) || (this->pev->button & IN_RELOAD)) { - this->SendMessageOnce(kReadyRoomMessage, true); + this->SendMessageOnce(kReadyRoomMessage, TOOLTIP); } } @@ -4167,7 +4167,7 @@ void AvHPlayer::HandleTopDownInput() if(!this->GiveOrderToSelection(ORDERTYPEL_DEFAULT, this->mAttackTwoPressedWorldPos)) { // This location better be off the map or something, default orders should nearly always go through - this->SendMessage(kInvalidOrderGiven, true); + this->SendMessage(kInvalidOrderGiven, TOOLTIP); } else { @@ -6802,7 +6802,7 @@ void AvHPlayer::PreThink( void ) PROFILE_START() if(this->mQueuedThinkMessage != "") { - this->SendMessage(this->mQueuedThinkMessage.c_str(), true); + this->SendMessage(this->mQueuedThinkMessage.c_str(), TOOLTIP); this->mQueuedThinkMessage = ""; } if(this->mPendingCommand) @@ -7238,7 +7238,7 @@ void AvHPlayer::SetViewForUser3() } -bool AvHPlayer::SendMessage(const char *pMessage, bool inIsToolTip) +bool AvHPlayer::SendMessage(const char *pMessage, SHOWMESSAGE_TYPE type) { bool theSuccess = false; @@ -7248,7 +7248,7 @@ bool AvHPlayer::SendMessage(const char *pMessage, bool inIsToolTip) string theMessage(pMessage); if(theMessage != this->mLastMessageSent) { - UTIL_ShowMessage2(pMessage, this, inIsToolTip); + UTIL_ShowMessage2(pMessage, this, type); this->mLastMessageSent = theMessage; @@ -7270,7 +7270,7 @@ bool AvHPlayer::SendMessage(const char *pMessage, bool inIsToolTip) return theSuccess; } -bool AvHPlayer::SendMessageOnce(const char *pMessage, bool inIsToolTip) +bool AvHPlayer::SendMessageOnce(const char *pMessage, SHOWMESSAGE_TYPE type) { bool theSentMessage = false; @@ -7282,7 +7282,7 @@ bool AvHPlayer::SendMessageOnce(const char *pMessage, bool inIsToolTip) { // If not // Call SendMessage - theSentMessage = this->SendMessage(pMessage, inIsToolTip); + theSentMessage = this->SendMessage(pMessage, type); this->mLastMessageSent = theMessage; @@ -7544,7 +7544,7 @@ void AvHPlayer::SetPlayMode(AvHPlayMode inPlayMode, bool inForceSpawn) this->StartObservingIfNotAlready(); - this->SendMessage(kReinforcingMessage, true); + this->SendMessage(kReinforcingMessage, TOOLTIP); this->mHasLeftReadyRoom = true; break; @@ -7574,7 +7574,7 @@ void AvHPlayer::SetPlayMode(AvHPlayMode inPlayMode, bool inForceSpawn) case PLAYMODE_REINFORCINGCOMPLETE: this->pev->playerclass = PLAYMODE_REINFORCINGCOMPLETE; - this->SendMessage(kReinforcementComplete, false); + this->SendMessage(kReinforcementComplete, NORMAL); break; } @@ -7827,7 +7827,7 @@ void AvHPlayer::SetUser3(AvHUser3 inUser3, bool inForceChange, bool inGiveWeapon if(theMessage != "") { // Send instructions to player - this->SendMessageOnce(theMessage.c_str(), true); + this->SendMessageOnce(theMessage.c_str(), TOOLTIP); } this->LogEmitRoleChange(); } diff --git a/main/source/mod/AvHPlayer.h b/main/source/mod/AvHPlayer.h index 86a1d06a..7c368408 100644 --- a/main/source/mod/AvHPlayer.h +++ b/main/source/mod/AvHPlayer.h @@ -428,8 +428,8 @@ public: void SetResources(float inResources, bool inPlaySound = false); // Send messages to player's screen - bool SendMessage(const char* pMessage, bool inIsToolTip = false); - bool SendMessageOnce(const char* pMessage, bool inIsToolTip = false); + bool SendMessage(const char* pMessage, SHOWMESSAGE_TYPE type = NORMAL); + bool SendMessageOnce(const char* pMessage, SHOWMESSAGE_TYPE type = NORMAL); bool SendMessageNextThink(const char* pMessage); virtual int GetEffectivePlayerClass(); diff --git a/main/source/mod/AvHScriptServer.cpp b/main/source/mod/AvHScriptServer.cpp index ef85db40..154ffb8c 100644 --- a/main/source/mod/AvHScriptServer.cpp +++ b/main/source/mod/AvHScriptServer.cpp @@ -430,7 +430,7 @@ static int sendMessage(lua_State* inState) AvHPlayer* thePlayer = dynamic_cast(theEntity); if(thePlayer) { - thePlayer->SendMessage(theCString, true); + thePlayer->SendMessage(theCString, TOOLTIP); theSuccess = true; } } diff --git a/main/source/mod/AvHTeam.cpp b/main/source/mod/AvHTeam.cpp index 92c461d0..9edff8db 100644 --- a/main/source/mod/AvHTeam.cpp +++ b/main/source/mod/AvHTeam.cpp @@ -1059,7 +1059,7 @@ void AvHTeam::SetGameStarted(bool inGameStarted) theMessage = kYouAreDefending; } - theEntity->SendMessage(theMessage.c_str(), false); + theEntity->SendMessage(theMessage.c_str(), NORMAL); } } END_FOR_ALL_ENTITIES(kAvHPlayerClassName); diff --git a/main/source/mod/AvHWebSpinner.cpp b/main/source/mod/AvHWebSpinner.cpp index 4f4c049d..b4ceee69 100644 --- a/main/source/mod/AvHWebSpinner.cpp +++ b/main/source/mod/AvHWebSpinner.cpp @@ -133,13 +133,13 @@ bool AvHWebProjectile::CreateWeb() else { // Send player message indicating they've reached the limit for this particular area - thePlayer->SendMessage(kTooManyWebsNearby, true); + thePlayer->SendMessage(kTooManyWebsNearby, TOOLTIP); } } else { // Send player message indicating they've reached the limit - thePlayer->SendMessage(kTooManyWebs, true); + thePlayer->SendMessage(kTooManyWebs, TOOLTIP); } } } diff --git a/main/titles.txt b/main/titles.txt index 9817e118..bd3121e2 100644 --- a/main/titles.txt +++ b/main/titles.txt @@ -1576,12 +1576,12 @@ There are too many webs nearby. TeamOneWon { -The marines won the game! +The TSA Marines have exterminated the alien infestation } TeamTwoWon { -The aliens won the game! +The alien Kharaa have eradicated the human presence } GameDraw