2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
#pragma hdrstop
|
|
|
|
#include "../../idLib/precompiled.h"
|
|
|
|
#include "../Game_local.h"
|
|
|
|
|
|
|
|
static const int TIP_DISPLAY_TIME = 5000;
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::Update
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_HUD::Update()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( gui == NULL || !gui->IsActive() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( nextScreen != activeScreen )
|
|
|
|
{
|
|
|
|
|
|
|
|
if( activeScreen > HUD_AREA_INVALID && activeScreen < HUD_NUM_AREAS && menuScreens[ activeScreen ] != NULL )
|
|
|
|
{
|
|
|
|
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>( transition ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( nextScreen > HUD_AREA_INVALID && nextScreen < HUD_NUM_AREAS && menuScreens[ nextScreen ] != NULL )
|
|
|
|
{
|
|
|
|
menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>( transition ) );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
transition = MENU_TRANSITION_INVALID;
|
|
|
|
activeScreen = nextScreen;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player != NULL )
|
|
|
|
{
|
|
|
|
if( player->IsTipVisible() && autoHideTip && !hiding )
|
|
|
|
{
|
|
|
|
if( gameLocal.time >= tipStartTime + TIP_DISPLAY_TIME )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
player->HideTip();
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO ) && GetHud() != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
GetHud()->UpdateAudioLog( true );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
GetHud()->UpdateAudioLog( false );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( radioMessage )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
GetHud()->UpdateCommunication( true, player );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
GetHud()->UpdateCommunication( false, player );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuHandler::Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::ActivateMenu
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_HUD::ActivateMenu( bool show )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
idMenuHandler::ActivateMenu( show );
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idPlayer* player = gameLocal.GetLocalPlayer();
|
|
|
|
if( player == NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if( show )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
activeScreen = HUD_AREA_INVALID;
|
|
|
|
nextScreen = HUD_AREA_PLAYING;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
activeScreen = HUD_AREA_INVALID;
|
|
|
|
nextScreen = HUD_AREA_INVALID;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::Initialize
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_HUD::Initialize( const char* swfFile, idSoundWorld* sw )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idMenuHandler::Initialize( swfFile, sw );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
//---------------------
|
|
|
|
// Initialize the menus
|
|
|
|
//---------------------
|
|
|
|
#define BIND_HUD_SCREEN( screenId, className, menuHandler ) \
|
|
|
|
menuScreens[ (screenId) ] = new className(); \
|
|
|
|
menuScreens[ (screenId) ]->Initialize( menuHandler ); \
|
|
|
|
menuScreens[ (screenId) ]->AddRef();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( int i = 0; i < HUD_NUM_AREAS; ++i )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
menuScreens[ i ] = NULL;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
BIND_HUD_SCREEN( HUD_AREA_PLAYING, idMenuScreen_HUD, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::GetMenuScreen
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen* idMenuHandler_HUD::GetMenuScreen( int index )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( index < 0 || index >= HUD_NUM_AREAS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
return menuScreens[ index ];
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::GetHud
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen_HUD* idMenuHandler_HUD::GetHud()
|
|
|
|
{
|
|
|
|
idMenuScreen_HUD* screen = dynamic_cast< idMenuScreen_HUD* >( menuScreens[ HUD_AREA_PLAYING ] );
|
2012-11-26 18:58:24 +00:00
|
|
|
return screen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::ShowTip
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_HUD::ShowTip( const char* title, const char* tip, bool autoHide )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
autoHideTip = autoHideTip;
|
|
|
|
tipStartTime = gameLocal.time;
|
|
|
|
hiding = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
idMenuScreen_HUD* screen = GetHud();
|
|
|
|
if( screen != NULL )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->ShowTip( title, tip );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================
|
|
|
|
idMenuHandler_HUD::HideTip
|
|
|
|
========================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idMenuHandler_HUD::HideTip()
|
|
|
|
{
|
|
|
|
idMenuScreen_HUD* screen = GetHud();
|
|
|
|
if( screen != NULL && !hiding )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
screen->HideTip();
|
|
|
|
}
|
|
|
|
hiding = true;
|
|
|
|
}
|