Initial commit

This commit is contained in:
Brian Harris
2012-11-26 12:58:24 -06:00
parent a5214f79ef
commit 5016f605b8
1115 changed files with 587266 additions and 0 deletions

View File

@@ -0,0 +1,449 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
extern idCVar in_useJoystick;
/*
================================================
idMenuHandler::~idMenuHandler
================================================
*/
idMenuHandler::idMenuHandler() {
scrollingMenu = false;
scrollCounter = 0;
activeScreen = -1;
nextScreen = -1;
transition = -1;
platform = 0;
gui = NULL;
cmdBar = NULL;
for ( int index = 0; index < MAX_SCREEN_AREAS; ++index ) {
menuScreens[ index ] = NULL;
}
sounds.SetNum( NUM_GUI_SOUNDS );
}
/*
================================================
idMenuHandler::~idMenuHandler
================================================
*/
idMenuHandler::~idMenuHandler() {
Cleanup();
}
/*
================================================
idMenuHandler::Initialize
================================================
*/
void idMenuHandler::Initialize( const char * swfFile, idSoundWorld * sw ) {
Cleanup();
gui = new idSWF( swfFile, sw );
platform = 2;
}
/*
================================================
idMenuHandler::AddChild
================================================
*/
void idMenuHandler::AddChild( idMenuWidget * widget ) {
widget->SetSWFObj( gui );
widget->SetHandlerIsParent( true );
children.Append( widget );
widget->AddRef();
}
/*
================================================
idMenuHandler::GetChildFromIndex
================================================
*/
idMenuWidget * idMenuHandler::GetChildFromIndex( int index ) {
if ( children.Num() == 0 ) {
return NULL;
}
if ( index > children.Num() ) {
return NULL;
}
return children[ index ];
}
/*
================================================
idMenuHandler::GetPlatform
================================================
*/
int idMenuHandler::GetPlatform( bool realPlatform ) {
if ( platform == 2 && in_useJoystick.GetBool() && !realPlatform ) {
return 0;
}
return platform;
}
/*
================================================
idMenuHandler::GetPlatform
================================================
*/
void idMenuHandler::PlaySound( menuSounds_t type, int channel ) {
if ( gui == NULL ) {
return;
}
if ( type >= sounds.Num() ) {
return;
}
if ( sounds[ type ].IsEmpty() ) {
return;
}
int c = SCHANNEL_ANY;
if ( channel != -1 ) {
c = channel;
}
gui->PlaySound( sounds[ type ], c );
}
/*
================================================
idMenuHandler::StopSound
================================================
*/
void idMenuHandler::StopSound( int channel ) {
gui->StopSound();
}
/*
================================================
idMenuHandler::Cleanup
================================================
*/
void idMenuHandler::Cleanup() {
for ( int index = 0; index < children.Num(); ++index ) {
assert( children[ index ]->GetRefCount() > 0 );
children[ index ]->Release();
}
children.Clear();
for ( int index = 0; index < MAX_SCREEN_AREAS; ++index ) {
if ( menuScreens[ index ] != NULL ) {
menuScreens[ index ]->Release();
}
}
delete gui;
gui = NULL;
}
/*
================================================
idMenuHandler::TriggerMenu
================================================
*/
void idMenuHandler::TriggerMenu() {
}
/*
================================================
idMenuHandler::IsActive
================================================
*/
bool idMenuHandler::IsActive() {
if ( gui == NULL ) {
return false;
}
return gui->IsActive();
}
/*
================================================
idMenuHandler::ActivateMenu
================================================
*/
void idMenuHandler::ActivateMenu( bool show ) {
if ( gui == NULL ) {
return;
}
if ( !show ) {
gui->Activate( show );
return;
}
class idSWFScriptFunction_updateMenuDisplay : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_updateMenuDisplay( idSWF * _gui, idMenuHandler * _handler ) {
gui = _gui;
handler = _handler;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( handler != NULL ) {
int screen = parms[0].ToInteger();
handler->UpdateMenuDisplay( screen );
}
return idSWFScriptVar();
}
private:
idSWF * gui;
idMenuHandler * handler;
};
class idSWFScriptFunction_activateMenu : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_activateMenu( idMenuHandler * _handler ) {
handler = _handler;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( handler != NULL ) {
handler->TriggerMenu();
}
return idSWFScriptVar();
}
private:
idMenuHandler * handler;
};
gui->SetGlobal( "updateMenuDisplay", new (TAG_SWF) idSWFScriptFunction_updateMenuDisplay( gui, this ) );
gui->SetGlobal( "activateMenus", new (TAG_SWF) idSWFScriptFunction_activateMenu( this ) );
gui->Activate( show );
}
/*
================================================
idMenuHandler::Update
================================================
*/
void idMenuHandler::Update() {
PumpWidgetActionRepeater();
if ( gui != NULL && gui->IsActive() ) {
gui->Render( renderSystem, Sys_Milliseconds() );
}
}
/*
================================================
idMenuHandler::UpdateChildren
================================================
*/
void idMenuHandler::UpdateChildren() {
for ( int index = 0; index < children.Num(); ++index ) {
if ( children[ index ] != NULL ) {
children[index]->Update();
}
}
}
/*
================================================
idMenuHandler::UpdateMenuDisplay
================================================
*/
void idMenuHandler::UpdateMenuDisplay( int menu ) {
if ( menuScreens[ menu ] != NULL ) {
menuScreens[ menu ]->Update();
}
UpdateChildren();
}
/*
================================================
idMenuHandler::Update
================================================
*/
bool idMenuHandler::HandleGuiEvent( const sysEvent_t * sev ) {
if ( gui != NULL && activeScreen != -1 ) {
return gui->HandleEvent( sev );
}
return false;
}
/*
================================================
idMenuHandler::Update
================================================
*/
bool idMenuHandler::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_ADJUST_FIELD: {
if ( widget != NULL && widget->GetDataSource() != NULL ) {
widget->GetDataSource()->AdjustField( widget->GetDataSourceFieldIndex(), parms[ 0 ].ToInteger() );
widget->Update();
}
return true;
}
case WIDGET_ACTION_FUNCTION: {
if ( verify( action.GetScriptFunction() != NULL ) ) {
action.GetScriptFunction()->Call( event.thisObject, event.parms );
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
idMenuScreen * const screen = menuScreens[ activeScreen ];
if ( screen != NULL ) {
idWidgetEvent pressEvent( WIDGET_EVENT_PRESS, 0, event.thisObject, idSWFParmList() );
screen->ReceiveEvent( pressEvent );
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() >= 2 );
int repeatDelay = DEFAULT_REPEAT_TIME;
if ( parms.Num() >= 3 ) {
repeatDelay = parms[2].ToInteger();
}
repeatAction.Set( repeatActionType, parms[ 1 ], repeatDelay );
StartWidgetActionRepeater( widget, repeatAction, event );
return true;
}
case WIDGET_ACTION_STOP_REPEATER: {
ClearWidgetActionRepeater();
return true;
}
}
if ( !widget->GetHandlerIsParent() ) {
for ( int index = 0; index < children.Num(); ++index ) {
if ( children[index] != NULL ) {
if ( children[index]->HandleAction( action, event, widget, forceHandled ) ) {
return true;
}
}
}
}
return false;
}
/*
========================
idMenuHandler::StartWidgetActionRepeater
========================
*/
void idMenuHandler::StartWidgetActionRepeater( idMenuWidget * widget, const idWidgetAction & action, const idWidgetEvent & event ) {
if ( actionRepeater.isActive && actionRepeater.action == action ) {
return; // don't attempt to reactivate an already active repeater
}
actionRepeater.isActive = true;
actionRepeater.action = action;
actionRepeater.widget = widget;
actionRepeater.event = event;
actionRepeater.numRepetitions = 0;
actionRepeater.nextRepeatTime = 0;
actionRepeater.screenIndex = activeScreen; // repeaters are cleared between screens
if ( action.GetParms().Num() == 2 ) {
actionRepeater.repeatDelay = action.GetParms()[ 1 ].ToInteger();
} else {
actionRepeater.repeatDelay = DEFAULT_REPEAT_TIME;
}
// do the first event immediately
PumpWidgetActionRepeater();
}
/*
========================
idMenuHandler::PumpWidgetActionRepeater
========================
*/
void idMenuHandler::PumpWidgetActionRepeater() {
if ( !actionRepeater.isActive ) {
return;
}
if ( activeScreen != actionRepeater.screenIndex || nextScreen != activeScreen ) { // || common->IsDialogActive() ) {
actionRepeater.isActive = false;
return;
}
if ( actionRepeater.nextRepeatTime > Sys_Milliseconds() ) {
return;
}
// need to hold down longer on the first iteration before we continue to scroll
if ( actionRepeater.numRepetitions == 0 ) {
actionRepeater.nextRepeatTime = Sys_Milliseconds() + 400;
} else {
actionRepeater.nextRepeatTime = Sys_Milliseconds() + actionRepeater.repeatDelay;
}
if ( verify( actionRepeater.widget != NULL ) ) {
actionRepeater.widget->HandleAction( actionRepeater.action, actionRepeater.event, actionRepeater.widget );
actionRepeater.numRepetitions++;
}
}
/*
========================
idMenuHandler::ClearWidgetActionRepeater
========================
*/
void idMenuHandler::ClearWidgetActionRepeater() {
actionRepeater.isActive = false;
}

View File

@@ -0,0 +1,516 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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.
===========================================================================
*/
#ifndef __MENUDATA_H__
#define __MENUDATA_H__
enum shellAreas_t {
SHELL_AREA_INVALID = -1,
SHELL_AREA_START,
SHELL_AREA_ROOT,
SHELL_AREA_DEV,
SHELL_AREA_CAMPAIGN,
SHELL_AREA_LOAD,
SHELL_AREA_SAVE,
SHELL_AREA_NEW_GAME,
SHELL_AREA_GAME_OPTIONS,
SHELL_AREA_SYSTEM_OPTIONS,
SHELL_AREA_MULTIPLAYER,
SHELL_AREA_GAME_LOBBY,
SHELL_AREA_STEREOSCOPICS,
SHELL_AREA_PARTY_LOBBY,
SHELL_AREA_SETTINGS,
SHELL_AREA_AUDIO,
SHELL_AREA_VIDEO,
SHELL_AREA_KEYBOARD,
SHELL_AREA_CONTROLS,
SHELL_AREA_CONTROLLER_LAYOUT,
SHELL_AREA_GAMEPAD,
SHELL_AREA_PAUSE,
SHELL_AREA_LEADERBOARDS,
SHELL_AREA_PLAYSTATION,
SHELL_AREA_DIFFICULTY,
SHELL_AREA_RESOLUTION,
SHELL_AREA_MATCH_SETTINGS,
SHELL_AREA_MODE_SELECT,
SHELL_AREA_BROWSER,
SHELL_AREA_CREDITS,
SHELL_NUM_AREAS
};
enum shellState_t {
SHELL_STATE_INVALID = -1,
SHELL_STATE_PRESS_START,
SHELL_STATE_IDLE,
SHELL_STATE_PARTY_LOBBY,
SHELL_STATE_GAME_LOBBY,
SHELL_STATE_PAUSED,
SHELL_STATE_CONNECTING,
SHELL_STATE_SEARCHING,
SHELL_STATE_LOADING,
SHELL_STATE_BUSY,
SHELL_STATE_IN_GAME
};
enum pdaAreas_t {
PDA_AREA_INVALID = -1,
PDA_AREA_USER_DATA,
PDA_AREA_USER_EMAIL,
PDA_AREA_VIDEO_DISKS,
PDA_AREA_INVENTORY,
PDA_NUM_AREAS
};
enum hudArea_t {
HUD_AREA_INVALID = -1,
HUD_AREA_PLAYING,
HUD_NUM_AREAS
};
enum scoreboardArea_t {
SCOREBOARD_AREA_INVALID = -1,
SCOREBOARD_AREA_DEFAULT,
SCOREBOARD_AREA_TEAM,
SCOREBOARD_AREA_CTF,
SCOREBOARD_NUM_AREAS
};
enum pdaHandlerWidgets_t {
PDA_WIDGET_NAV_BAR,
PDA_WIDGET_PDA_LIST,
PDA_WIDGET_PDA_LIST_SCROLLBAR,
PDA_WIDGET_CMD_BAR
};
enum scoreboardHandlerWidgets_t {
SCOREBOARD_WIDGET_CMD_BAR,
};
enum menuSounds_t {
GUI_SOUND_MUSIC,
GUI_SOUND_SCROLL,
GUI_SOUND_ADVANCE,
GUI_SOUND_BACK,
GUI_SOUND_BUILD_ON,
GUI_SOUND_BUILD_OFF,
GUI_SOUND_FOCUS,
GUI_SOUND_ROLL_OVER,
GUI_SOUND_ROLL_OUT,
NUM_GUI_SOUNDS,
};
static const int MAX_SCREEN_AREAS = 32;
static const int DEFAULT_REPEAT_TIME = 150;
static const int WAIT_START_TIME_LONG = 30000;
static const int WAIT_START_TIME_SHORT = 5000;
struct actionRepeater_t {
actionRepeater_t() :
widget( NULL ),
numRepetitions( 0 ),
nextRepeatTime( 0 ),
screenIndex( -1 ),
repeatDelay( DEFAULT_REPEAT_TIME ),
isActive( false ) {
}
idMenuWidget * widget;
idWidgetEvent event;
idWidgetAction action;
int numRepetitions;
int nextRepeatTime;
int repeatDelay;
int screenIndex;
bool isActive;
};
class mpScoreboardInfo{
public:
mpScoreboardInfo() :
voiceState( VOICECHAT_DISPLAY_NONE ),
score( 0 ),
wins( 0 ),
ping( 0 ),
team( -1 ),
playerNum( 0 ) {
}
mpScoreboardInfo( const mpScoreboardInfo & src ) {
voiceState = src.voiceState;
score = src.score;
wins = src.wins;
ping = src.ping;
spectateData = src.spectateData;
name = src.name;
team = src.team;
playerNum = src.playerNum;
}
void operator=( const mpScoreboardInfo & src ) {
voiceState = src.voiceState;
score = src.score;
wins = src.wins;
ping = src.ping;
spectateData = src.spectateData;
name = src.name;
team = src.team;
playerNum = src.playerNum;
}
bool operator!=( const mpScoreboardInfo & otherInfo ) const {
if ( otherInfo.score != score || otherInfo.wins != wins || otherInfo.ping != ping ||
otherInfo.spectateData != spectateData || otherInfo.name != name || otherInfo.team != team ||
otherInfo.playerNum != playerNum || otherInfo.voiceState != voiceState ) {
return true;
}
return false;
}
bool operator==( const mpScoreboardInfo & otherInfo ) const {
if ( otherInfo.score != score || otherInfo.wins != wins || otherInfo.ping != ping ||
otherInfo.spectateData != spectateData || otherInfo.name != name || otherInfo.team != team ||
otherInfo.playerNum != playerNum || otherInfo.voiceState != voiceState ) {
return false;
}
return true;
}
voiceStateDisplay_t voiceState;
int score;
int wins;
int ping;
int team;
int playerNum;
idStr spectateData;
idStr name;
};
/*
================================================
idMenuHandler
================================================
*/
class idMenuHandler {
public:
idMenuHandler();
virtual ~idMenuHandler();
virtual void Initialize( const char * swfFile, idSoundWorld * sw );
virtual void Cleanup();
virtual void Update();
virtual void UpdateChildren();
virtual void UpdateMenuDisplay( int menu );
virtual bool HandleGuiEvent( const sysEvent_t * sev );
virtual bool IsActive();
virtual void ActivateMenu( bool show );
virtual void TriggerMenu();
virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
virtual int ActiveScreen() { return activeScreen; }
virtual int NextScreen() { return nextScreen; }
virtual int MenuTransition() { return transition; }
virtual idMenuScreen * GetMenuScreen( int index ) { return NULL; }
virtual void SetNextScreen( int screen, int trans ) { nextScreen = screen; transition = trans; }
virtual void StartWidgetActionRepeater( idMenuWidget * widget, const idWidgetAction & action, const idWidgetEvent & event );
virtual void PumpWidgetActionRepeater();
virtual void ClearWidgetActionRepeater();
virtual idSWF * GetGUI() { return gui; }
virtual void AddChild( idMenuWidget * widget );
virtual idMenuWidget * GetChildFromIndex( int index );
virtual int GetPlatform( bool realPlatform = false );
virtual void PlaySound( menuSounds_t type, int channel = -1 );
virtual void StopSound( int channel = SCHANNEL_ANY );
idMenuWidget_CommandBar * GetCmdBar() { return cmdBar; }
protected:
bool scrollingMenu;
int scrollCounter;
int activeScreen;
int nextScreen;
int transition;
int platform;
idSWF * gui;
actionRepeater_t actionRepeater;
idMenuScreen * menuScreens[MAX_SCREEN_AREAS];
idList< idMenuWidget *, TAG_IDLIB_LIST_MENU> children;
idStaticList< idStr, NUM_GUI_SOUNDS > sounds;
idMenuWidget_CommandBar * cmdBar;
};
/*
================================================
lobbyPlayerInfo_t
================================================
*/
struct lobbyPlayerInfo_t {
lobbyPlayerInfo_t() :
partyToken( 0 ),
voiceState( VOICECHAT_DISPLAY_NONE ) {
}
idStr name;
int partyToken;
voiceStateDisplay_t voiceState;
};
/*
================================================
idMenuHandler_Shell
================================================
*/
class idMenuHandler_Shell : public idMenuHandler {
public:
idMenuHandler_Shell() :
state( SHELL_STATE_INVALID ),
nextState( SHELL_STATE_INVALID ),
smallFrameShowing( false ),
largeFrameShowing( false ),
bgShowing( true ),
nextPeerUpdateMs( 0 ),
inGame( false ),
waitForBinding( false ),
waitBind( NULL ),
newGameType( 0 ),
menuBar( NULL ),
pacifier( NULL ),
showingIntro( false ),
introGui( NULL ),
doom3Intro( NULL ),
roeIntro( NULL ),
lmIntro( NULL ),
typeSoundShader( NULL ),
continueWaitForEnumerate( false ),
gameComplete( false ),
marsRotation( NULL ) {
}
virtual void Update();
virtual void ActivateMenu( bool show );
virtual void Initialize( const char * swfFile, idSoundWorld * sw );
virtual void Cleanup();
virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
virtual idMenuScreen * GetMenuScreen( int index );
virtual bool HandleGuiEvent( const sysEvent_t * sev );
void UpdateSavedGames();
void ShowSmallFrame( bool show );
void ShowMPFrame( bool show );
void ShowLogo( bool show );
void SetShellState( shellState_t s ) { nextState = s; }
bool IsSmallFrameShowing() { return smallFrameShowing; }
void UpdateBGState();
void GetMapName( int index, idStr & name );
void GetModeName( int index, idStr & name );
idMenuWidget * GetPacifier() { return pacifier; }
idMenuWidget_MenuBar * GetMenuBar() { return menuBar; }
bool IsPacifierVisible() const { return ( pacifier != NULL && pacifier->GetSprite() != NULL ) ? pacifier->GetSprite()->IsVisible() : false; }
void ShowPacifier( const idStr & msg );
void HidePacifier();
void SetTimeRemaining( int time ) { timeRemaining = time; }
int GetTimeRemaining() { return timeRemaining; }
void SetNewGameType( int type ) { newGameType = type; }
int GetNewGameType() { return newGameType; }
void SetInGame( bool val ) { inGame = val; }
bool GetInGame() { return inGame; }
void HandleExitGameBtn();
void SetupPCOptions();
void SetWaitForBinding( const char * bind ) { waitForBinding = true; waitBind = bind; }
void ClearWaitForBinding() { waitForBinding = false; }
void UpdateLeaderboard( const idLeaderboardCallback * callback );
void UpdateLobby( idMenuWidget_LobbyList * lobbyList );
void ShowDoomIntro();
void ShowROEIntro();
void ShowLEIntro();
void StartGame( int index );
void SetContinueWaitForEnumerate( bool wait ) { continueWaitForEnumerate = wait; }
void SetCanContinue( bool valid );
void SetGameComplete() { gameComplete = true; }
bool GetGameComplete() { return gameComplete; }
private:
shellState_t state;
shellState_t nextState;
bool smallFrameShowing;
bool largeFrameShowing;
bool bgShowing;
bool waitForBinding;
const char * waitBind;
//idSysSignal deviceRequestedSignal;
idList<const char *, TAG_IDLIB_LIST_MENU> mpGameModes;
idList<mpMap_t, TAG_IDLIB_LIST_MENU> mpGameMaps;
idMenuWidget_MenuBar * menuBar;
idMenuWidget * pacifier;
int timeRemaining;
int nextPeerUpdateMs;
int newGameType;
bool inGame;
bool showingIntro;
bool continueWaitForEnumerate;
bool gameComplete;
idSWF * introGui;
const idSoundShader * typeSoundShader;
const idMaterial * doom3Intro;
const idMaterial * roeIntro;
const idMaterial * lmIntro;
const idMaterial * marsRotation;
idList< idStr, TAG_IDLIB_LIST_MENU> navOptions;
};
/*
================================================
idMenuHandler_PDA
================================================
*/
class idMenuHandler_PDA : public idMenuHandler {
public:
idMenuHandler_PDA() :
audioLogPlaying( false ),
videoPlaying( false ),
audioFile( NULL ) {
}
virtual ~idMenuHandler_PDA();
virtual void Update();
virtual void ActivateMenu( bool show );
virtual void TriggerMenu();
virtual void Initialize( const char * swfFile, idSoundWorld * sw );
virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
virtual idMenuScreen * GetMenuScreen( int index );
void UpdateAudioLogPlaying( bool playing );
void UdpateVideoPlaying( bool playing );
void ClearVideoPlaying() { videoPlaying = false; }
bool PlayPDAAudioLog( int pdaIndex, int audioIndex );
virtual void Cleanup();
protected:
bool audioLogPlaying;
bool videoPlaying;
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > pdaNames;
idList< idStr, TAG_IDLIB_LIST_MENU > navOptions;
const idDeclAudio * audioFile;
idMenuWidget_ScrollBar pdaScrollBar;
idMenuWidget_DynamicList pdaList;
idMenuWidget_NavBar navBar;
idMenuWidget_CommandBar commandBarWidget;
};
/*
================================================
idMenuHandler_PDA
================================================
*/
class idMenuHandler_HUD : public idMenuHandler {
public:
idMenuHandler_HUD() :
autoHideTip( true ),
tipStartTime( 0 ),
hiding( false ),
radioMessage( false ) {
}
virtual void Update();
virtual void ActivateMenu( bool show );
virtual void Initialize( const char * swfFile, idSoundWorld * sw );
virtual idMenuScreen * GetMenuScreen( int index );
idMenuScreen_HUD * GetHud();
void ShowTip( const char * title, const char * tip, bool autoHide );
void HideTip();
void SetRadioMessage( bool show ) { radioMessage = show; }
protected:
bool autoHideTip;
int tipStartTime;
bool hiding;
bool radioMessage;
};
/*
================================================
idMenuHandler_Scoreboard
================================================
*/
class idMenuHandler_Scoreboard : public idMenuHandler {
public:
idMenuHandler_Scoreboard() :
redScore( 0 ),
blueScore( 0 ),
activationScreen( SCOREBOARD_AREA_INVALID ) {
}
virtual void Update();
virtual void TriggerMenu();
virtual void ActivateMenu( bool show );
virtual void Initialize( const char * swfFile, idSoundWorld * sw );
virtual idMenuScreen * GetMenuScreen( int index );
virtual bool HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled = false );
void AddPlayerInfo( int index, voiceStateDisplay_t voiceState, int team, idStr name, int score, int wins, int ping, idStr spectateData );
void UpdateScoreboard( idList< mpScoreboardInfo > & data, idStr gameInfo );
void UpdateVoiceStates();
void UpdateSpectating( idStr spectate, idStr follow );
void SetTeamScores( int r, int b );
int GetNumPlayers( int team );
void SetActivationScreen( int screen, int trans );
void ViewPlayerProfile( int slot );
void MutePlayer( int slot );
void GetUserID( int slot, lobbyUserID_t & luid );
void UpdateScoreboardSelection();
protected:
int redScore;
int blueScore;
int activationScreen;
idList< mpScoreboardInfo > scoreboardInfo;
idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU > redInfo;
idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU> blueInfo;
};
#endif //__MENUDATA_H__

View File

@@ -0,0 +1,182 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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
========================
*/
void idMenuHandler_HUD::Update() {
if ( gui == NULL || !gui->IsActive() ) {
return;
}
if ( nextScreen != activeScreen ) {
if ( activeScreen > HUD_AREA_INVALID && activeScreen < HUD_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) {
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
}
if ( nextScreen > HUD_AREA_INVALID && nextScreen < HUD_NUM_AREAS && menuScreens[ nextScreen ] != NULL ) {
menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>(transition) );
}
transition = MENU_TRANSITION_INVALID;
activeScreen = nextScreen;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
if ( player->IsTipVisible() && autoHideTip && !hiding ) {
if ( gameLocal.time >= tipStartTime + TIP_DISPLAY_TIME ) {
player->HideTip();
}
}
if ( player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO ) && GetHud() != NULL ) {
GetHud()->UpdateAudioLog( true );
} else {
GetHud()->UpdateAudioLog( false );
}
if ( radioMessage ) {
GetHud()->UpdateCommunication( true, player );
} else {
GetHud()->UpdateCommunication( false, player );
}
}
idMenuHandler::Update();
}
/*
========================
idMenuHandler_HUD::ActivateMenu
========================
*/
void idMenuHandler_HUD::ActivateMenu( bool show ) {
idMenuHandler::ActivateMenu( show );
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( show ) {
activeScreen = HUD_AREA_INVALID;
nextScreen = HUD_AREA_PLAYING;
} else {
activeScreen = HUD_AREA_INVALID;
nextScreen = HUD_AREA_INVALID;
}
}
/*
========================
idMenuHandler_HUD::Initialize
========================
*/
void idMenuHandler_HUD::Initialize( const char * swfFile, idSoundWorld * sw ) {
idMenuHandler::Initialize( swfFile, sw );
//---------------------
// Initialize the menus
//---------------------
#define BIND_HUD_SCREEN( screenId, className, menuHandler ) \
menuScreens[ (screenId) ] = new className(); \
menuScreens[ (screenId) ]->Initialize( menuHandler ); \
menuScreens[ (screenId) ]->AddRef();
for ( int i = 0; i < HUD_NUM_AREAS; ++i ) {
menuScreens[ i ] = NULL;
}
BIND_HUD_SCREEN( HUD_AREA_PLAYING, idMenuScreen_HUD, this );
}
/*
========================
idMenuHandler_HUD::GetMenuScreen
========================
*/
idMenuScreen * idMenuHandler_HUD::GetMenuScreen( int index ) {
if ( index < 0 || index >= HUD_NUM_AREAS ) {
return NULL;
}
return menuScreens[ index ];
}
/*
========================
idMenuHandler_HUD::GetHud
========================
*/
idMenuScreen_HUD * idMenuHandler_HUD::GetHud() {
idMenuScreen_HUD * screen = dynamic_cast< idMenuScreen_HUD * >( menuScreens[ HUD_AREA_PLAYING ] );
return screen;
}
/*
========================
idMenuHandler_HUD::ShowTip
========================
*/
void idMenuHandler_HUD::ShowTip( const char * title, const char * tip, bool autoHide ) {
autoHideTip = autoHideTip;
tipStartTime = gameLocal.time;
hiding = false;
idMenuScreen_HUD * screen = GetHud();
if ( screen != NULL ) {
screen->ShowTip( title, tip );
}
}
/*
========================
idMenuHandler_HUD::HideTip
========================
*/
void idMenuHandler_HUD::HideTip() {
idMenuScreen_HUD * screen = GetHud();
if ( screen != NULL && !hiding ) {
screen->HideTip();
}
hiding = true;
}

View File

@@ -0,0 +1,599 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 MAX_PDA_ITEMS = 15;
static const int MAX_NAV_OPTIONS = 4;
/*
========================
idMenuHandler_PDA::Update
========================
*/
void idMenuHandler_PDA::Update() {
if ( gui == NULL || !gui->IsActive() ) {
return;
}
if ( activeScreen != nextScreen ) {
if ( nextScreen == PDA_AREA_INVALID ) {
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
cmdBar->Update();
}
idSWFSpriteInstance * menu = gui->GetRootObject().GetNestedSprite( "navBar" );
idSWFSpriteInstance * bg = gui->GetRootObject().GetNestedSprite( "background" );
idSWFSpriteInstance * edging = gui->GetRootObject().GetNestedSprite( "_fullScreen" );
if ( menu != NULL ) {
menu->PlayFrame( "rollOff" );
}
if ( bg != NULL ) {
bg->PlayFrame( "rollOff" );
}
if ( edging != NULL ) {
edging->PlayFrame( "rollOff" );
}
} else {
if ( activeScreen > PDA_AREA_INVALID && activeScreen < PDA_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) {
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
}
if ( nextScreen > PDA_AREA_INVALID && nextScreen < PDA_NUM_AREAS && menuScreens[ nextScreen ] != NULL ) {
menuScreens[ nextScreen ]->UpdateCmds();
menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>(transition) );
}
}
transition = MENU_TRANSITION_INVALID;
activeScreen = nextScreen;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
if ( activeScreen == PDA_AREA_USER_DATA ) {
bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO );
UpdateAudioLogPlaying( isPlaying );
}
if ( activeScreen == PDA_AREA_VIDEO_DISKS ) {
bool isPlaying = player->IsSoundChannelPlaying( SND_CHANNEL_PDA_VIDEO );
UdpateVideoPlaying( isPlaying );
}
}
idMenuHandler::Update();
}
/*
================================================
idMenuHandler::TriggerMenu
================================================
*/
void idMenuHandler_PDA::TriggerMenu() {
nextScreen = PDA_AREA_USER_DATA;
transition = MENU_TRANSITION_FORCE;
}
/*
========================
idMenuHandler_PDA::ActivateMenu
========================
*/
void idMenuHandler_PDA::ActivateMenu( bool show ) {
idMenuHandler::ActivateMenu( show );
if ( show ) {
// Add names to pda
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
pdaNames.Clear();
for ( int j = 0; j < player->GetInventory().pdas.Num(); j++ ) {
const idDeclPDA * pda = player->GetInventory().pdas[ j ];
idList< idStr > names;
names.Append( pda->GetPdaName() );
pdaNames.Append( names );
}
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
pdaList->SetListData( pdaNames );
}
navOptions.Clear();
navOptions.Append( idLocalization::GetString( "#str_04190" ) );
navOptions.Append( idLocalization::GetString( "#str_01442" ) );
navOptions.Append( idLocalization::GetString( "#str_01440" ) );
navOptions.Append( idLocalization::GetString( "#str_01414" ) );
idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
if ( navBar != NULL ) {
navBar->SetListHeadings( navOptions );
navBar->SetFocusIndex( 0 );
navBar->Update();
}
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
cmdBar->Update();
}
} else {
nextScreen = PDA_AREA_INVALID;
activeScreen = PDA_AREA_INVALID;
}
}
/*
========================
idMenuHandler_PDA::Initialize
========================
*/
void idMenuHandler_PDA::Initialize( const char * swfFile, idSoundWorld * sw ) {
idMenuHandler::Initialize( swfFile, sw );
//---------------------
// Initialize the menus
//---------------------
#define BIND_PDA_SCREEN( screenId, className, menuHandler ) \
menuScreens[ (screenId) ] = new (TAG_SWF) className(); \
menuScreens[ (screenId) ]->Initialize( menuHandler ); \
menuScreens[ (screenId) ]->AddRef(); \
menuScreens[ (screenId) ]->SetNoAutoFree( true );
for ( int i = 0; i < PDA_NUM_AREAS; ++i ) {
menuScreens[ i ] = NULL;
}
BIND_PDA_SCREEN( PDA_AREA_USER_DATA, idMenuScreen_PDA_UserData, this );
BIND_PDA_SCREEN( PDA_AREA_USER_EMAIL, idMenuScreen_PDA_UserEmails, this );
BIND_PDA_SCREEN( PDA_AREA_VIDEO_DISKS, idMenuScreen_PDA_VideoDisks, this );
BIND_PDA_SCREEN( PDA_AREA_INVENTORY, idMenuScreen_PDA_Inventory, this );
pdaScrollBar.SetSpritePath( "pda_persons", "info", "scrollbar" );
pdaScrollBar.Initialize( this );
pdaScrollBar.SetNoAutoFree( true );
pdaList.SetSpritePath( "pda_persons", "info", "list" );
pdaList.SetNumVisibleOptions( MAX_PDA_ITEMS );
pdaList.SetWrappingAllowed( true );
pdaList.SetNoAutoFree( true );
while ( pdaList.GetChildren().Num() < MAX_PDA_ITEMS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_USER, pdaList.GetChildren().Num() );
buttonWidget->Initialize( this );
if ( menuScreens[ PDA_AREA_USER_DATA ] != NULL ) {
idMenuScreen_PDA_UserData * userDataScreen = dynamic_cast< idMenuScreen_PDA_UserData * >( menuScreens[ PDA_AREA_USER_DATA ] );
if ( userDataScreen != NULL ) {
buttonWidget->RegisterEventObserver( userDataScreen->GetUserData() );
buttonWidget->RegisterEventObserver( userDataScreen->GetObjective() );
buttonWidget->RegisterEventObserver( userDataScreen->GetAudioFiles() );
}
}
if ( menuScreens[ PDA_AREA_USER_EMAIL ] != NULL ) {
idMenuScreen_PDA_UserEmails * userEmailScreen = dynamic_cast< idMenuScreen_PDA_UserEmails * >( menuScreens[ PDA_AREA_USER_EMAIL ] );
if ( userEmailScreen != NULL ) {
buttonWidget->RegisterEventObserver( &userEmailScreen->GetInbox() );
buttonWidget->RegisterEventObserver( userEmailScreen );
}
}
buttonWidget->RegisterEventObserver( &pdaScrollBar );
pdaList.AddChild( buttonWidget );
}
pdaList.AddChild( &pdaScrollBar );
pdaList.Initialize( this );
navBar.SetSpritePath( "navBar", "options" );
navBar.Initialize( this );
navBar.SetNumVisibleOptions( MAX_NAV_OPTIONS );
navBar.SetWrappingAllowed( true );
navBar.SetButtonSpacing( 20.0f, 25.0f, 75.0f );
navBar.SetInitialXPos( 40.0f );
navBar.SetNoAutoFree( true );
for ( int count = 0; count < ( MAX_NAV_OPTIONS * 2 - 1 ); ++count ) {
idMenuWidget_NavButton * const navButton = new (TAG_SWF) idMenuWidget_NavButton();
if ( count < MAX_NAV_OPTIONS - 1 ) {
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, count );
} else if ( count < ( ( MAX_NAV_OPTIONS - 1 ) * 2 ) ) {
int index = ( count - ( MAX_NAV_OPTIONS - 1 ) ) + 1;
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, index );
} else {
navButton->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_NAV, -1 );
}
navBar.AddChild( navButton );
}
//
// command bar
//
commandBarWidget.SetAlignment( idMenuWidget_CommandBar::LEFT );
commandBarWidget.SetSpritePath( "prompts" );
commandBarWidget.Initialize( this );
commandBarWidget.SetNoAutoFree( true );
AddChild( &navBar );
AddChild( &pdaList );
AddChild( &pdaScrollBar );
AddChild( &commandBarWidget );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
pdaList.AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
menuScreens[ PDA_AREA_USER_DATA ]->RegisterEventObserver( &pdaList );
menuScreens[ PDA_AREA_USER_EMAIL ]->RegisterEventObserver( &pdaList );
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
for ( int j = 0; j < MAX_WEAPONS; j++ ) {
const char * weaponDefName = va( "def_weapon%d", j );
const char *weap = player->spawnArgs.GetString( weaponDefName );
if ( weap != NULL && *weap != NULL ) {
const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
if ( weaponDef != NULL ) {
declManager->FindMaterial( weaponDef->dict.GetString( "pdaIcon" ) );
declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ) );
}
}
}
}
class idPDAGGUIClose : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
player->TogglePDA();
}
return idSWFScriptVar();
}
};
if ( gui != NULL ) {
gui->SetGlobal( "closePDA", new idPDAGGUIClose() );
}
// precache sounds
// don't load gui music for the pause menu to save some memory
const idSoundShader * soundShader = NULL;
soundShader = declManager->FindSound( "gui/list_scroll", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_SCROLL ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_PDA_advance", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ADVANCE ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_PDA_back", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BACK ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/pda_next_tab", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/pda_prev_tab", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BUILD_OFF ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_set_focus", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_FOCUS ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_roll_over", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ROLL_OVER ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_roll_out", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ROLL_OUT ] = soundShader->GetName();
}
}
/*
========================
idMenuHandler_PDA::HandleAction
========================
*/
bool idMenuHandler_PDA::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( activeScreen == PDA_AREA_INVALID ) {
return true;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
if ( event.type == WIDGET_EVENT_COMMAND ) {
if ( menuScreens[ activeScreen ] != NULL && !forceHandled ) {
if ( menuScreens[ activeScreen ]->HandleAction( action, event, widget, true ) ) {
if ( actionType == WIDGET_ACTION_GO_BACK ) {
PlaySound( GUI_SOUND_BACK );
} else {
PlaySound( GUI_SOUND_ADVANCE );
}
return true;
}
}
}
switch ( actionType ) {
case WIDGET_ACTION_PDA_SELECT_USER: {
int index = parms[0].ToInteger();
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
pdaList->SetViewIndex( pdaList->GetViewOffset() + index );
pdaList->SetFocusIndex( index );
}
return true;
}
case WIDGET_ACTION_SCROLL_TAB: {
if ( transition != MENU_TRANSITION_INVALID ) {
return true;
}
int delta = parms[0].ToInteger();
idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
if ( navBar != NULL ) {
int focused = navBar->GetFocusIndex();
focused += delta;
if ( focused < 0 ) {
focused = navBar->GetNumVisibleOptions() - 1;
} else if ( focused >= navBar->GetNumVisibleOptions() ) {
focused = 0;
}
navBar->SetViewIndex( focused );
navBar->SetFocusIndex( focused, true );
navBar->Update();
nextScreen = activeScreen + delta;
if ( nextScreen < 0 ) {
nextScreen = PDA_NUM_AREAS - 1;
} else if ( nextScreen == PDA_NUM_AREAS ) {
nextScreen = 0;
}
if ( delta < 0 ) {
transition = MENU_TRANSITION_BACK;
} else {
transition = MENU_TRANSITION_ADVANCE;
}
}
return true;
}
case WIDGET_ACTION_PDA_SELECT_NAV: {
int index = parms[0].ToInteger();
if ( index == -1 && activeScreen == PDA_AREA_USER_EMAIL ) {
idMenuScreen_PDA_UserEmails * screen = dynamic_cast< idMenuScreen_PDA_UserEmails * const >( menuScreens[ PDA_AREA_USER_EMAIL ] );
if ( screen ) {
screen->ShowEmail( false );
}
return true;
}
// click on the current nav tab
if ( index == -1 ) {
return true;
}
idMenuWidget_NavBar * navBar = dynamic_cast< idMenuWidget_NavBar * >( GetChildFromIndex( PDA_WIDGET_NAV_BAR ) );
if ( navBar != NULL ) {
navBar->SetViewIndex( navBar->GetViewOffset() + index );
navBar->SetFocusIndex( index, true );
navBar->Update();
if ( index < activeScreen ) {
nextScreen = index;
transition = MENU_TRANSITION_BACK;
} else if ( index > activeScreen ) {
nextScreen = index;
transition = MENU_TRANSITION_ADVANCE;
}
}
return true;
}
case WIDGET_ACTION_SELECT_PDA_AUDIO: {
if ( activeScreen == PDA_AREA_USER_DATA ) {
int index = parms[0].ToInteger();
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
bool change = false;
if ( pdaList != NULL ) {
int pdaIndex = pdaList->GetViewIndex();
change = PlayPDAAudioLog( pdaIndex, index );
}
if ( change ) {
if ( widget->GetParent() != NULL ) {
idMenuWidget_DynamicList * audioList = dynamic_cast< idMenuWidget_DynamicList * >( widget->GetParent() );
int index = parms[0].ToInteger();
if ( audioList != NULL ) {
audioList->SetFocusIndex( index );
}
}
}
}
return true;
}
case WIDGET_ACTION_SELECT_PDA_VIDEO: {
if ( activeScreen == PDA_AREA_VIDEO_DISKS ) {
int index = parms[0].ToInteger();
if ( menuScreens[ PDA_AREA_VIDEO_DISKS ] != NULL ) {
idMenuScreen_PDA_VideoDisks * screen = dynamic_cast< idMenuScreen_PDA_VideoDisks * const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
if ( screen != NULL ) {
screen->SelectedVideoToPlay( index );
}
}
}
return true;
}
}
return idMenuHandler::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuHandler_PDA::PlayPDAAudioLog
========================
*/
bool idMenuHandler_PDA::PlayPDAAudioLog( int pdaIndex, int audioIndex ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
if ( pda != NULL && pda->GetNumAudios() > audioIndex ) {
const idDeclAudio *aud = pda->GetAudioByIndex( audioIndex );
if ( audioFile == aud ) {
player->EndAudioLog();
return true;
} else if ( aud != NULL ) {
audioFile = aud;
player->EndAudioLog();
player->PlayAudioLog( aud->GetWave() );
return true;
}
}
}
return false;
}
/*
========================
idMenuHandler_PDA::GetMenuScreen
========================
*/
idMenuScreen * idMenuHandler_PDA::GetMenuScreen( int index ) {
if ( index < 0 || index >= PDA_NUM_AREAS ) {
return NULL;
}
return menuScreens[ index ];
}
/*
========================
idMenuHandler_PDA::GetMenuScreen
========================
*/
void idMenuHandler_PDA::UpdateAudioLogPlaying( bool playing ) {
if ( playing != audioLogPlaying && activeScreen == PDA_AREA_USER_DATA && menuScreens[ activeScreen ] != NULL ) {
menuScreens[ activeScreen ]->Update();
}
audioLogPlaying = playing;
if ( !playing ) {
audioFile = NULL;
}
}
/*
========================
idMenuHandler_PDA::GetMenuScreen
========================
*/
void idMenuHandler_PDA::UdpateVideoPlaying( bool playing ) {
if ( playing != videoPlaying ) {
if ( activeScreen == PDA_AREA_VIDEO_DISKS && menuScreens[ activeScreen ] != NULL ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( !playing ) {
player->EndVideoDisk();
}
idMenuScreen_PDA_VideoDisks * screen = dynamic_cast< idMenuScreen_PDA_VideoDisks * const >( menuScreens[ PDA_AREA_VIDEO_DISKS ] );
if ( screen != NULL ) {
if ( !playing ) {
screen->ClearActiveVideo();
}
screen->Update();
}
}
videoPlaying = playing;
}
}
/*
================================================
idMenuHandler_PDA::Cleanup
================================================
*/
void idMenuHandler_PDA::Cleanup() {
idMenuHandler::Cleanup();
for ( int index = 0; index < MAX_SCREEN_AREAS; ++index ) {
delete menuScreens[ index ];
menuScreens[ index ] = NULL;
}
}
/*
================================================
idMenuHandler_PDA::~idMenuHandler_PDA
================================================
*/
idMenuHandler_PDA::~idMenuHandler_PDA() {
pdaScrollBar.Cleanup();
pdaList.Cleanup();
navBar.Cleanup();
commandBarWidget.Cleanup();
Cleanup();
}

View File

@@ -0,0 +1,510 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuHandler_Scoreboard::Update
========================
*/
void idMenuHandler_Scoreboard::Update() {
if ( gui == NULL || !gui->IsActive() ) {
return;
}
if ( nextScreen != activeScreen ) {
if ( nextScreen == SCOREBOARD_AREA_INVALID ) {
if ( activeScreen > SCOREBOARD_AREA_INVALID && activeScreen < SCOREBOARD_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) {
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
}
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( SCOREBOARD_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
cmdBar->Update();
}
idSWFSpriteInstance * bg = gui->GetRootObject().GetNestedSprite( "background" );
if ( bg != NULL ) {
bg->PlayFrame( "rollOff" );
}
} else {
if ( activeScreen > SCOREBOARD_AREA_INVALID && activeScreen < SCOREBOARD_NUM_AREAS && menuScreens[ activeScreen ] != NULL ) {
menuScreens[ activeScreen ]->HideScreen( static_cast<mainMenuTransition_t>(transition) );
}
if ( nextScreen > SCOREBOARD_AREA_INVALID && nextScreen < SCOREBOARD_NUM_AREAS && menuScreens[ nextScreen ] != NULL ) {
menuScreens[ nextScreen ]->UpdateCmds();
menuScreens[ nextScreen ]->ShowScreen( static_cast<mainMenuTransition_t>(transition) );
}
}
transition = MENU_TRANSITION_INVALID;
activeScreen = nextScreen;
}
idMenuHandler::Update();
}
/*
========================
idMenuHandler_Scoreboard::ActivateMenu
========================
*/
void idMenuHandler_Scoreboard::TriggerMenu() {
nextScreen = activationScreen;
}
/*
========================
idMenuHandler_Scoreboard::ActivateMenu
========================
*/
void idMenuHandler_Scoreboard::ActivateMenu( bool show ) {
idMenuHandler::ActivateMenu( show );
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( show ) {
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * >( GetChildFromIndex( SCOREBOARD_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
cmdBar->Update();
}
nextScreen = SCOREBOARD_AREA_INVALID;
activeScreen = SCOREBOARD_AREA_INVALID;
} else {
activeScreen = SCOREBOARD_AREA_INVALID;
nextScreen = SCOREBOARD_AREA_INVALID;
}
class idSWFScriptFunction_activateMenu : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_activateMenu( idMenuHandler * _handler ) {
handler = _handler;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( handler != NULL ) {
handler->TriggerMenu();
}
return idSWFScriptVar();
}
private:
idMenuHandler * handler;
};
gui->SetGlobal( "activateMenus", new (TAG_SWF) idSWFScriptFunction_activateMenu( this ) );
}
/*
========================
idMenuHandler_Scoreboard::Initialize
========================
*/
void idMenuHandler_Scoreboard::Initialize( const char * swfFile, idSoundWorld * sw ) {
idMenuHandler::Initialize( swfFile, sw );
//---------------------
// Initialize the menus
//---------------------
#define BIND_SCOREBOARD_SCREEN( screenId, className, menuHandler ) \
menuScreens[ (screenId) ] = new className(); \
menuScreens[ (screenId) ]->Initialize( menuHandler ); \
menuScreens[ (screenId) ]->AddRef();
for ( int i = 0; i < SCOREBOARD_NUM_AREAS; ++i ) {
menuScreens[ i ] = NULL;
}
BIND_SCOREBOARD_SCREEN( SCOREBOARD_AREA_DEFAULT, idMenuScreen_Scoreboard, this );
BIND_SCOREBOARD_SCREEN( SCOREBOARD_AREA_TEAM, idMenuScreen_Scoreboard_Team, this );
//
// command bar
//
idMenuWidget_CommandBar * const commandBarWidget = new (TAG_SWF) idMenuWidget_CommandBar();
commandBarWidget->SetAlignment( idMenuWidget_CommandBar::LEFT );
commandBarWidget->SetSpritePath( "prompts" );
commandBarWidget->Initialize( this );
AddChild( commandBarWidget );
class idScoreboardGUIClose : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
gameLocal.mpGame.SetScoreboardActive( false );
return idSWFScriptVar();
}
};
if ( gui != NULL ) {
gui->SetGlobal( "closeScoreboard", new idScoreboardGUIClose() );
}
// precache sounds
// don't load gui music for the pause menu to save some memory
const idSoundShader * soundShader = NULL;
soundShader = declManager->FindSound( "gui/list_scroll", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_SCROLL ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_PDA_advance", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ADVANCE ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_PDA_back", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BACK ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/pda_next_tab", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BUILD_ON ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/pda_prev_tab", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_BUILD_OFF ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_set_focus", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_FOCUS ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_roll_over", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ROLL_OVER ] = soundShader->GetName();
}
soundShader = declManager->FindSound( "gui/btn_roll_out", true );
if ( soundShader != NULL ) {
sounds[ GUI_SOUND_ROLL_OUT ] = soundShader->GetName();
}
}
/*
========================
idMenuHandler_Scoreboard::GetMenuScreen
========================
*/
idMenuScreen * idMenuHandler_Scoreboard::GetMenuScreen( int index ) {
if ( index < 0 || index >= SCOREBOARD_NUM_AREAS ) {
return NULL;
}
return menuScreens[ index ];
}
/*
========================
idMenuHandler_Scoreboard::HandleAction
========================
*/
bool idMenuHandler_Scoreboard::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( activeScreen == SCOREBOARD_AREA_INVALID ) {
return true;
}
widgetAction_t actionType = action.GetType();
//const idSWFParmList & parms = action.GetParms();
if ( event.type == WIDGET_EVENT_COMMAND ) {
if ( menuScreens[ activeScreen ] != NULL && !forceHandled ) {
if ( menuScreens[ activeScreen ]->HandleAction( action, event, widget, true ) ) {
if ( actionType == WIDGET_ACTION_GO_BACK ) {
PlaySound( GUI_SOUND_BACK );
} else {
PlaySound( GUI_SOUND_ADVANCE );
}
return true;
}
}
}
return idMenuHandler::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuHandler_Scoreboard::AddPlayerInfo
========================
*/
void idMenuHandler_Scoreboard::AddPlayerInfo( int index, voiceStateDisplay_t voiceState, int team, idStr name, int score, int wins, int ping, idStr spectateData ) {
scoreboardInfo_t info;
idList< idStr > values;
values.Append( name );
if ( spectateData.IsEmpty() || gameLocal.mpGame.GetGameState() == idMultiplayerGame::GAMEREVIEW ) {
values.Append( va( "%i", score ) );
} else {
values.Append( spectateData );
}
values.Append( va( "%i", wins ) );
values.Append( va( "%i", ping ) );
info.index = index;
info.voiceState = voiceState;
info.values = values;
if ( team == 1 ) {
blueInfo.Append( info );
} else {
redInfo.Append( info );
}
}
/*
========================
idMenuHandler_Scoreboard::UpdateScoreboard
========================
*/
void idMenuHandler_Scoreboard::UpdateSpectating( idStr spectate, idStr follow ) {
if ( nextScreen == SCOREBOARD_AREA_DEFAULT ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_DEFAULT ] );
if ( screen ) {
screen->UpdateSpectating( spectate, follow );
}
} else if ( nextScreen == SCOREBOARD_AREA_TEAM ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_TEAM ] );
if ( screen ) {
screen->UpdateSpectating( spectate, follow );
}
}
}
/*
========================
idMenuHandler_Scoreboard::UpdateScoreboard
========================
*/
void idMenuHandler_Scoreboard::UpdateScoreboard( idList< mpScoreboardInfo > & data, idStr gameInfo ) {
bool changed = false;
if ( data.Num() != scoreboardInfo.Num() ) {
changed = true;
} else {
for ( int i = 0; i < data.Num(); ++i ) {
if ( data[i] != scoreboardInfo[i] ) {
changed = true;
break;
}
}
}
if ( nextScreen == SCOREBOARD_AREA_DEFAULT ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_DEFAULT ] );
if ( screen ) {
screen->UpdateGameInfo( gameInfo );
screen->UpdateTeamScores( redScore, blueScore );
}
} else if ( nextScreen == SCOREBOARD_AREA_TEAM ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_TEAM ] );
if ( screen ) {
screen->UpdateGameInfo( gameInfo );
screen->UpdateTeamScores( redScore, blueScore );
}
}
redInfo.Clear();
blueInfo.Clear();
for ( int i = 0; i < data.Num(); ++i ) {
AddPlayerInfo( data[i].playerNum, data[i].voiceState, data[i].team, data[i].name, data[i].score, data[i].wins, data[i].ping, data[i].spectateData );
}
idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU > listItemInfo;
for ( int i = 0; i < redInfo.Num(); ++i ) {
listItemInfo.Append( redInfo[i] );
}
// add empty items to list
if ( blueInfo.Num() > 0 ) {
while ( listItemInfo.Num() < 4 ) {
scoreboardInfo_t info;
listItemInfo.Append( info );
}
}
for ( int i = 0; i < blueInfo.Num(); ++i ) {
listItemInfo.Append( blueInfo[i] );
}
while ( listItemInfo.Num() < 8 ) {
scoreboardInfo_t info;
listItemInfo.Append( info );
}
if ( nextScreen == SCOREBOARD_AREA_DEFAULT || activationScreen == SCOREBOARD_AREA_DEFAULT ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_DEFAULT ] );
if ( screen ) {
screen->SetPlayerData( listItemInfo );
}
} else if ( nextScreen == SCOREBOARD_AREA_TEAM || activationScreen == SCOREBOARD_AREA_TEAM ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_TEAM ] );
if ( screen ) {
screen->SetPlayerData( listItemInfo );
}
}
scoreboardInfo = data;
}
/*
========================
idMenuHandler_Scoreboard::SetTeamScore
========================
*/
void idMenuHandler_Scoreboard::SetTeamScores( int r, int b ) {
redScore = r;
blueScore = b;
}
/*
========================
idMenuHandler_Scoreboard::GetNumPlayers
========================
*/
int idMenuHandler_Scoreboard::GetNumPlayers( int team ) {
if ( team == 1 ) {
return blueInfo.Num();
} else {
return redInfo.Num();
}
}
/*
========================
idMenuHandler_Scoreboard::SetActivationScreen
========================
*/
void idMenuHandler_Scoreboard::SetActivationScreen( int screen, int trans ) {
activationScreen = screen;
transition = trans;
}
/*
========================
idMenuHandler_Scoreboard::GetUserID
========================
*/
void idMenuHandler_Scoreboard::GetUserID( int slot, lobbyUserID_t & luid ) {
idList< int > redList;
idList< int > blueList;
for ( int i = 0; i < scoreboardInfo.Num(); ++i ) {
if ( scoreboardInfo[i].team == 1 ) {
blueList.Append( scoreboardInfo[i].playerNum );
} else {
redList.Append( scoreboardInfo[i].playerNum );
}
}
idList< int > displayList;
for ( int i = 0; i < redList.Num(); ++i ) {
displayList.Append( redList[ i ] );
}
for ( int i = 0; i < blueList.Num(); ++i ) {
displayList.Append( blueList[ i ] );
}
if ( slot >= displayList.Num() ) {
return;
}
luid = gameLocal.lobbyUserIDs[ displayList[ slot ] ];
}
/*
========================
idMenuHandler_Scoreboard::ViewPlayerProfile
========================
*/
void idMenuHandler_Scoreboard::ViewPlayerProfile( int slot ) {
lobbyUserID_t luid;
GetUserID( slot, luid );
if ( luid.IsValid() ) {
session->ShowLobbyUserGamerCardUI( luid );
}
}
/*
========================
idMenuHandler_Scoreboard::MutePlayer
========================
*/
void idMenuHandler_Scoreboard::MutePlayer( int slot ) {
lobbyUserID_t luid;
GetUserID( slot, luid );
if ( luid.IsValid() ) {
session->ToggleLobbyUserVoiceMute( luid );
}
}
/*
========================
idMenuHandler_Scoreboard::UpdateScoreboardSelection
========================
*/
void idMenuHandler_Scoreboard::UpdateScoreboardSelection() {
if ( nextScreen == SCOREBOARD_AREA_DEFAULT || activationScreen == SCOREBOARD_AREA_DEFAULT ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_DEFAULT ] );
if ( screen ) {
screen->UpdateHighlight();
}
} else if ( nextScreen == SCOREBOARD_AREA_TEAM || activationScreen == SCOREBOARD_AREA_TEAM ) {
idMenuScreen_Scoreboard * screen = dynamic_cast< idMenuScreen_Scoreboard * >( menuScreens[ SCOREBOARD_AREA_TEAM ] );
if ( screen ) {
screen->UpdateHighlight();
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,330 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
idMenuScreen::idMenuScreen() {
menuGUI = NULL;
transition = MENU_TRANSITION_INVALID;
}
idMenuScreen::~idMenuScreen() {
}
/*
========================
idMenuScreen::ObserveEvent
========================
*/
void idMenuScreen::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
if ( event.type == WIDGET_EVENT_COMMAND ) {
switch ( event.arg ) {
case idMenuWidget_CommandBar::BUTTON_JOY1: {
ReceiveEvent( idWidgetEvent( WIDGET_EVENT_PRESS, 0, event.thisObject, event.parms ) );
break;
}
case idMenuWidget_CommandBar::BUTTON_JOY2: {
ReceiveEvent( idWidgetEvent( WIDGET_EVENT_BACK, 0, event.thisObject, event.parms ) );
break;
}
}
}
}
/*
========================
idMenuScreen::Update
========================
*/
void idMenuScreen::Update() {
if ( menuGUI == NULL ) {
return;
}
//
// Display
//
for ( int childIndex = 0; childIndex < GetChildren().Num(); ++childIndex ) {
GetChildByIndex( childIndex ).Update();
}
if ( menuData != NULL ) {
menuData->UpdateChildren();
}
}
/*
========================
idMenuScreen::UpdateCmds
========================
*/
void idMenuScreen::UpdateCmds() {
idSWF * const gui = menuGUI;
idSWFScriptObject * const shortcutKeys = gui->GetGlobal( "shortcutKeys" ).GetObject();
if ( !verify( shortcutKeys != NULL ) ) {
return;
}
idSWFScriptVar clearFunc = shortcutKeys->Get( "clear" );
if ( clearFunc.IsFunction() ) {
clearFunc.GetFunction()->Call( NULL, idSWFParmList() );
}
// NAVIGATION: UP/DOWN, etc.
idSWFScriptObject * const buttons = gui->GetRootObject().GetObject( "buttons" );
if ( buttons != NULL ) {
idSWFScriptObject * const btnUp = buttons->GetObject( "btnUp" );
if ( btnUp != NULL ) {
btnUp->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP, SCROLL_SINGLE ) );
btnUp->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_RELEASE, 0 ) );
shortcutKeys->Set( "UP", btnUp );
shortcutKeys->Set( "MWHEEL_UP", btnUp );
}
idSWFScriptObject * const btnDown = buttons->GetObject( "btnDown" );
if ( btnDown != NULL ) {
btnDown->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN, SCROLL_SINGLE ) );
btnDown->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_RELEASE, 0 ) );
shortcutKeys->Set( "DOWN", btnDown );
shortcutKeys->Set( "MWHEEL_DOWN", btnDown );
}
idSWFScriptObject * const btnUp_LStick = buttons->GetObject( "btnUp_LStick" );
if ( btnUp_LStick != NULL ) {
btnUp_LStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_LSTICK, SCROLL_SINGLE ) );
btnUp_LStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK1_UP", btnUp_LStick );
}
idSWFScriptObject * const btnDown_LStick = buttons->GetObject( "btnDown_LStick" );
if ( btnDown_LStick != NULL ) {
btnDown_LStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_LSTICK, SCROLL_SINGLE ) );
btnDown_LStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK1_DOWN", btnDown_LStick );
}
idSWFScriptObject * const btnUp_RStick = buttons->GetObject( "btnUp_RStick" );
if ( btnUp_RStick != NULL ) {
btnUp_RStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_RSTICK, SCROLL_SINGLE ) );
btnUp_RStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK2_UP", btnUp_RStick );
}
idSWFScriptObject * const btnDown_RStick = buttons->GetObject( "btnDown_RStick" );
if ( btnDown_RStick != NULL ) {
btnDown_RStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_RSTICK, SCROLL_SINGLE ) );
btnDown_RStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK2_DOWN", btnDown_RStick );
}
idSWFScriptObject * const btnPageUp = buttons->GetObject( "btnPageUp" );
if ( btnPageUp != NULL ) {
btnPageUp->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_PAGEUP, SCROLL_PAGE ) );
btnPageUp->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_PAGEUP_RELEASE, 0 ) );
shortcutKeys->Set( "PGUP", btnPageUp );
}
idSWFScriptObject * const btnPageDown = buttons->GetObject( "btnPageDown" );
if ( btnPageDown != NULL ) {
btnPageDown->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_PAGEDWN, SCROLL_PAGE ) );
btnPageDown->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_PAGEDWN_RELEASE, 0 ) );
shortcutKeys->Set( "PGDN", btnPageDown );
}
idSWFScriptObject * const btnHome = buttons->GetObject( "btnHome" );
if ( btnHome != NULL ) {
btnHome->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP, SCROLL_FULL ) );
btnHome->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_UP_RELEASE, 0 ) );
shortcutKeys->Set( "HOME", btnHome );
}
idSWFScriptObject * const btnEnd = buttons->GetObject( "btnEnd" );
if ( btnEnd != NULL ) {
btnEnd->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN, SCROLL_FULL ) );
btnEnd->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_DOWN_RELEASE, 0 ) );
shortcutKeys->Set( "END", btnEnd );
}
idSWFScriptObject * const btnLeft = buttons->GetObject( "btnLeft" );
if ( btnLeft != NULL ) {
btnLeft->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT, 0 ) );
btnLeft->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RELEASE, 0 ) );
shortcutKeys->Set( "LEFT", btnLeft );
}
idSWFScriptObject * const btnRight = buttons->GetObject( "btnRight" );
if ( btnRight != NULL ) {
btnRight->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT, 0 ) );
btnRight->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RELEASE, 0 ) );
shortcutKeys->Set( "RIGHT", btnRight );
}
idSWFScriptObject * const btnLeft_LStick = buttons->GetObject( "btnLeft_LStick" );
if ( btnLeft_LStick != NULL ) {
btnLeft_LStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_LSTICK, 0 ) );
btnLeft_LStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK1_LEFT", btnLeft_LStick );
}
idSWFScriptObject * const btnRight_LStick = buttons->GetObject( "btnRight_LStick" );
if ( btnRight_LStick != NULL ) {
btnRight_LStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_LSTICK, 0 ) );
btnRight_LStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK1_RIGHT", btnRight_LStick );
}
idSWFScriptObject * const btnLeft_RStick = buttons->GetObject( "btnLeft_RStick" );
if ( btnLeft_RStick != NULL ) {
btnLeft_RStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RSTICK, 0 ) );
btnLeft_RStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK2_LEFT", btnLeft_RStick );
}
idSWFScriptObject * const btnRight_RStick = buttons->GetObject( "btnRight_RStick" );
if ( btnRight_RStick != NULL ) {
btnRight_RStick->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RSTICK, 0 ) );
btnRight_RStick->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RSTICK_RELEASE, 0 ) );
shortcutKeys->Set( "STICK2_RIGHT", btnRight_RStick );
}
}
idSWFScriptObject * const navigation = gui->GetRootObject().GetObject( "navBar" );
if ( navigation != NULL ) {
// TAB NEXT
idSWFScriptObject * const btnTabNext = navigation->GetNestedObj( "options", "btnTabNext" );
if ( btnTabNext != NULL ) {
btnTabNext->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_TAB_NEXT, 0 ) );
shortcutKeys->Set( "JOY6", btnTabNext );
if ( btnTabNext->GetSprite() != NULL && menuData != NULL ) {
btnTabNext->GetSprite()->StopFrame( menuData->GetPlatform() + 1 );
}
}
// TAB PREV
idSWFScriptObject * const btnTabPrev = navigation->GetNestedObj( "options", "btnTabPrev" );
if ( btnTabPrev != NULL ) {
btnTabPrev->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_TAB_PREV, 0 ) );
shortcutKeys->Set( "JOY5", btnTabPrev );
if ( btnTabPrev->GetSprite() != NULL && menuData != NULL ) {
btnTabPrev->GetSprite()->StopFrame( menuData->GetPlatform() + 1 );
}
}
}
}
/*
========================
idMenuScreen::HideScreen
========================
*/
void idMenuScreen::HideScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI == NULL ) {
return;
}
if ( !BindSprite( menuGUI->GetRootObject() ) ) {
return;
}
if ( transitionType == MENU_TRANSITION_SIMPLE ) {
GetSprite()->PlayFrame( "rollOff" );
} else if ( transitionType == MENU_TRANSITION_ADVANCE ) {
GetSprite()->PlayFrame( "rollOffBack" );
} else {
GetSprite()->PlayFrame( "rollOffFront" );
}
Update();
}
/*
========================
idMenuScreen::ShowScreen
========================
*/
void idMenuScreen::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI == NULL ) {
return;
}
if ( !BindSprite( menuGUI->GetRootObject() ) ) {
return;
}
GetSprite()->SetVisible( true );
if ( transitionType == MENU_TRANSITION_SIMPLE ) {
if ( menuData != NULL && menuData->ActiveScreen() != -1 ) {
menuData->PlaySound( GUI_SOUND_BUILD_ON );
}
GetSprite()->PlayFrame( "rollOn" );
} else if ( transitionType == MENU_TRANSITION_ADVANCE ) {
if ( menuData != NULL && menuData->ActiveScreen() != -1 ) {
menuData->PlaySound( GUI_SOUND_BUILD_ON );
}
GetSprite()->PlayFrame( "rollOnFront" );
} else {
if ( menuData != NULL ) {
menuData->PlaySound( GUI_SOUND_BUILD_OFF );
}
GetSprite()->PlayFrame( "rollOnBack" );
}
Update();
SetFocusIndex( GetFocusIndex(), true );
}
/*
========================
idMenuScreen::HandleMenu
NOTE: This is holdover from the way the menu system was setup before. It should be able to
be removed when the old way is fully replaced, and instead events will just be sent directly
to the screen.
========================
*/
void idMenuScreen::HandleMenu( const mainMenuTransition_t type ) {
if ( type == MENU_TRANSITION_ADVANCE ) {
ReceiveEvent( idWidgetEvent( WIDGET_EVENT_PRESS, 0, NULL, idSWFParmList() ) );
} else if ( type == MENU_TRANSITION_BACK ) {
ReceiveEvent( idWidgetEvent( WIDGET_EVENT_BACK, 0, NULL, idSWFParmList() ) );
}
transition = type;
}

1642
neo/d3xp/menus/MenuScreen.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,384 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 NUM_INVENTORY_ITEMS_VISIBLE = 9;
/*
========================
idMenuScreen_PDA_Inventory::Initialize
========================
*/
void idMenuScreen_PDA_Inventory::Initialize( idMenuHandler * data ) {
AddEventAction( WIDGET_EVENT_TAB_NEXT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_NEXT, WIDGET_EVENT_TAB_NEXT ) );
AddEventAction( WIDGET_EVENT_TAB_PREV ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_PREV, WIDGET_EVENT_TAB_PREV ) );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuItems" );
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
BindSprite( root );
}
infoBox.SetSpritePath( GetSpritePath(), "info", "details" );
infoBox.Initialize( data );
infoBox.SetNoAutoFree( true );
itemList.SetSpritePath( GetSpritePath(), "info", "options" );
itemList.SetNumVisibleOptions( NUM_INVENTORY_ITEMS_VISIBLE );
itemList.SetNoAutoFree( true );
while ( itemList.GetChildren().Num() < NUM_INVENTORY_ITEMS_VISIBLE ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_PDA_ITEM, itemList.GetChildren().Num() );
itemList.AddChild( buttonWidget );
}
itemList.Initialize( data );
AddChild( &itemList );
AddChild( &infoBox );
//AddChild( assignment );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER, WIDGET_EVENT_SCROLL_LEFT ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER, WIDGET_EVENT_SCROLL_RIGHT ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_LEFT_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER, WIDGET_EVENT_SCROLL_LEFT_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ) );
idMenuScreen::Initialize( data );
}
/*
========================
idMenuScreen_PDA_Inventory::ShowScreen
========================
*/
void idMenuScreen_PDA_Inventory::ShowScreen( const mainMenuTransition_t transitionType ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
int numItems = player->GetInventory().items.Num();
for ( int j = 0; j < numItems; j++ ) {
idDict *item = player->GetInventory().items[j];
if ( !item->GetBool( "inv_pda" ) ) {
const char *iname = item->GetString( "inv_name" );
const char *iicon = item->GetString( "inv_icon" );
const char *itext = item->GetString( "inv_text" );
iname = iname;
iicon = iicon;
itext = itext;
const idKeyValue *kv = item->MatchPrefix( "inv_id", NULL );
if ( kv ) {
//objectiveSystem->SetStateString( va( "inv_id_%i", j ), kv->GetValue() );
}
}
}
idList<const idMaterial *> weaponIcons;
for ( int j = 0; j < MAX_WEAPONS; j++ ) {
const char * weap = GetWeaponName( j );
if ( weap == NULL || *weap == NULL ){
continue;
}
if ( !IsVisibleWeapon( j ) ) {
continue;
}
const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
if ( weaponDef != NULL ) {
weaponIcons.Append( declManager->FindMaterial( weaponDef->dict.GetString( "hudIcon" ), false ) );
}
}
itemList.SetListImages( weaponIcons );
itemList.SetViewIndex( 0 );
itemList.SetMoveToIndex( 0 );
itemList.SetMoveDiff( 0 );
}
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_Inventory::HideScreen
========================
*/
void idMenuScreen_PDA_Inventory::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_Inventory::GetWeaponName
========================
*/
const char * idMenuScreen_PDA_Inventory::GetWeaponName( int index ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return NULL;
}
const char * weaponDefName = va( "def_weapon%d", index );
if ( player->GetInventory().weapons & ( 1 << index ) ) {
return player->spawnArgs.GetString( weaponDefName );
}
return NULL;
}
/*
========================
idMenuScreen_PDA_Inventory::GetWeaponName
========================
*/
bool idMenuScreen_PDA_Inventory::IsVisibleWeapon( int index ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return false;
}
if ( player->GetInventory().weapons & ( 1 << index ) ) {
return player->spawnArgs.GetBool( va( "weapon%d_visible", index ) );
}
return false;
}
/*
========================
idMenuScreen_PDA_Inventory::Update
========================
*/
void idMenuScreen_PDA_Inventory::Update() {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
idMenuScreen::Update();
return;
}
int validIndex = 0;
for ( int j = 0; j < MAX_WEAPONS; j++ ) {
const char * weap = GetWeaponName( j );
if ( weap == NULL || *weap == NULL ){
continue;
}
if ( !IsVisibleWeapon( j ) ) {
return;
}
const idDeclEntityDef * weaponDef = gameLocal.FindEntityDef( weap, false );
if ( weaponDef == NULL ) {
continue;
}
if ( validIndex == itemList.GetMoveToIndex() ) {
idStr itemName = weaponDef->dict.GetString( "display_name" );
idStr itemDesc = weaponDef->dict.GetString( "inv_desc" );
infoBox.SetHeading( idLocalization::GetString( itemName.c_str() ) );
infoBox.SetBody( idLocalization::GetString( itemDesc.c_str() ) );
break;
}
validIndex++;
}
if ( GetSprite() != NULL ) {
idSWFSpriteInstance * dpad = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "dpad" );
if ( dpad != NULL ) {
dpad->SetVisible( false );
}
}
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * const >( menuData->GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
buttonInfo->label = "#str_SWF_EQUIP";
buttonInfo->action.Set( WIDGET_ACTION_JOY3_ON_PRESS );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_PDA_Inventory::EquipWeapon
========================
*/
void idMenuScreen_PDA_Inventory::EquipWeapon() {
if ( itemList.GetViewIndex() != itemList.GetMoveToIndex() ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
int validIndex = 0;
for ( int j = 0; j < MAX_WEAPONS; j++ ) {
const char * weap = GetWeaponName( j );
if ( weap == NULL || *weap == NULL ){
continue;
}
if ( !IsVisibleWeapon( j ) ) {
continue;
}
if ( validIndex == itemList.GetMoveToIndex() ) {
int slot = player->SlotForWeapon( weap );
player->SetPreviousWeapon( slot );
break;
}
validIndex++;
}
player->TogglePDA();
}
/*
========================
idMenuScreen_PDA_Inventory::HandleAction
========================
*/
bool idMenuScreen_PDA_Inventory::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != PDA_AREA_INVENTORY ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_JOY3_ON_PRESS: {
EquipWeapon();
return true;
}
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
return true;
}
case WIDGET_ACTION_START_REPEATER: {
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() == 2 );
repeatAction.Set( repeatActionType, parms[ 1 ] );
menuData->StartWidgetActionRepeater( widget, repeatAction, event );
return true;
}
case WIDGET_ACTION_SELECT_PDA_ITEM: {
if ( itemList.GetMoveDiff() > 0 ) {
itemList.MoveToIndex( itemList.GetMoveToIndex(), true );
}
int index = parms[0].ToInteger();
if ( index != 0 ) {
itemList.MoveToIndex( index );
Update();
}
return true;
}
case WIDGET_ACTION_STOP_REPEATER: {
menuData->ClearWidgetActionRepeater();
return true;
}
case WIDGET_ACTION_SCROLL_HORIZONTAL: {
if ( itemList.GetTotalNumberOfOptions() <= 1 ) {
return true;
}
if ( itemList.GetMoveDiff() > 0 ) {
itemList.MoveToIndex( itemList.GetMoveToIndex(), true );
}
int direction = parms[0].ToInteger();
if ( direction == 1 ) {
if ( itemList.GetViewIndex() == itemList.GetTotalNumberOfOptions() - 1 ) {
return true;
} else {
itemList.MoveToIndex( 1 );
}
} else {
if ( itemList.GetViewIndex() == 0 ) {
return true;
} else {
itemList.MoveToIndex( ( itemList.GetNumVisibleOptions() / 2 ) + 1 );
}
}
Update();
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,247 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuScreen_PDA_UserData::Initialize
========================
*/
void idMenuScreen_PDA_UserData::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuData" );
pdaUserData.SetSpritePath( GetSpritePath(), "info", "pdaData" );
pdaUserData.Initialize( data );
pdaUserData.SetNoAutoFree( true );
AddChild( &pdaUserData );
pdaObjectiveSimple.SetSpritePath( GetSpritePath(), "info", "missionInfo" );
pdaObjectiveSimple.Initialize( data );
pdaObjectiveSimple.SetNoAutoFree( true );
AddChild( &pdaObjectiveSimple );
pdaAudioFiles.SetSpritePath( GetSpritePath(), "info", "audioFiles" );
pdaAudioFiles.Initialize( data );
pdaAudioFiles.SetNoAutoFree( true );
AddChild( &pdaAudioFiles );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaAudioFiles.GetChildByIndex( 0 ), WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaAudioFiles.GetChildByIndex( 0 ), WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaAudioFiles.GetChildByIndex( 0 ), WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaAudioFiles.GetChildByIndex( 0 ), WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_TAB_NEXT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_NEXT, WIDGET_EVENT_TAB_NEXT ) );
AddEventAction( WIDGET_EVENT_TAB_PREV ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_PREV, WIDGET_EVENT_TAB_PREV ) );
}
/*
========================
idMenuScreen_PDA_UserData::Update
========================
*/
void idMenuScreen_PDA_UserData::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * const >( menuData->GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
idPlayer * player = gameLocal.GetLocalPlayer();
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL && player != NULL ) {
int pdaIndex = pdaList->GetViewIndex();
if ( pdaIndex < player->GetInventory().pdas.Num() ) {
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
if ( pda != NULL && pdaIndex != 0 ) {
if ( player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO ) ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_stop";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
} else if ( pda->GetNumAudios() > 0 ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_play";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
}
}
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_PDA_UserData::ShowScreen
========================
*/
void idMenuScreen_PDA_UserData::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI != NULL && menuData != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
idSWFSpriteInstance * pdaSprite = root.GetNestedSprite( "pda_persons" );
if ( pdaSprite != NULL && menuData != NULL && menuData->ActiveScreen() != PDA_AREA_USER_EMAIL ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOn" );
}
idSWFSpriteInstance * navBar = root.GetNestedSprite( "navBar" );
if ( navBar != NULL && menuData != NULL && menuData->ActiveScreen() == PDA_AREA_INVALID ) {
navBar->PlayFrame( "rollOn" );
}
}
idMenuScreen::ShowScreen( transitionType );
if ( menuData != NULL) {
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
pdaList->SetFocusIndex( pdaList->GetFocusIndex() );
}
}
}
/*
========================
idMenuScreen_PDA_UserData::HideScreen
========================
*/
void idMenuScreen_PDA_UserData::HideScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
idSWFSpriteInstance * pdaSprite = root.GetNestedSprite( "pda_persons" );
if ( pdaSprite != NULL && menuData != NULL && menuData->NextScreen() != PDA_AREA_USER_EMAIL ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOff" );
}
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_UserData::HandleAction
========================
*/
bool idMenuScreen_PDA_UserData::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != PDA_AREA_USER_DATA ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_PRESS_FOCUSED: {
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList == NULL ) {
return true;
}
int pdaIndex = pdaList->GetViewIndex();
if ( pdaIndex == 0 ) {
return true;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL && player->IsSoundChannelPlaying( SND_CHANNEL_PDA_AUDIO ) ) {
player->EndAudioLog();
} else {
if ( menuData != NULL && pdaAudioFiles.GetChildren().Num() > 0 ) {
int index = pdaAudioFiles.GetChildByIndex( 0 ).GetFocusIndex();
idMenuHandler_PDA * pdaHandler = dynamic_cast< idMenuHandler_PDA * const >( menuData );
if ( pdaHandler != NULL ) {
pdaHandler->PlayPDAAudioLog( pdaIndex, index );
}
}
}
return true;
}
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
return true;
}
case WIDGET_ACTION_START_REPEATER: {
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() == 2 );
repeatAction.Set( repeatActionType, parms[ 1 ] );
if ( menuData != NULL ) {
menuData->StartWidgetActionRepeater( widget, repeatAction, event );
}
return true;
}
case WIDGET_ACTION_STOP_REPEATER: {
if ( menuData != NULL ) {
menuData->ClearWidgetActionRepeater();
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,478 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuScreen_PDA_UserEmails::Initialize
========================
*/
void idMenuScreen_PDA_UserEmails::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuEmail" );
pdaInbox.SetSpritePath( GetSpritePath(), "info", "inbox" );
pdaInbox.Initialize( data );
pdaInbox.SetNoAutoFree( true );
emailScrollbar.SetSpritePath( GetSpritePath(), "info", "email", "info", "scrollbar" );
emailScrollbar.Initialize( data );
emailScrollbar.SetNoAutoFree( true );
emailInfo.SetSpritePath( GetSpritePath(), "info", "email" );
emailInfo.Initialize( data );
emailInfo.SetScrollbar( &emailScrollbar );
emailInfo.AddChild( &emailScrollbar );
emailInfo.RegisterEventObserver( this );
emailInfo.AddEventAction( WIDGET_EVENT_ROLL_OVER ).Set( WIDGET_ACTION_EMAIL_HOVER, 1 );
emailInfo.AddEventAction( WIDGET_EVENT_ROLL_OUT ).Set( WIDGET_ACTION_EMAIL_HOVER, 0 );
emailInfo.SetNoAutoFree( true );
AddChild( &pdaInbox );
AddChild( &emailInfo );
if ( pdaInbox.GetEmailList() != NULL ) {
pdaInbox.GetEmailList()->RegisterEventObserver( &emailInfo );
pdaInbox.GetEmailList()->RegisterEventObserver( &emailScrollbar );
for ( int i = 0; i < pdaInbox.GetEmailList()->GetChildren().Num(); ++i ) {
idMenuWidget & child = pdaInbox.GetEmailList()->GetChildByIndex( i );
idMenuWidget_Button * const button = dynamic_cast< idMenuWidget_Button * >( &child );
if ( button != NULL ) {
button->RegisterEventObserver( &emailInfo );
}
}
}
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_TAB_NEXT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_NEXT, WIDGET_EVENT_TAB_NEXT ) );
AddEventAction( WIDGET_EVENT_TAB_PREV ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_PREV, WIDGET_EVENT_TAB_PREV ) );
class idInfoBoxRefresh : public idSWFScriptFunction_RefCounted {
public:
idInfoBoxRefresh( idMenuWidget_InfoBox * _widget ) :
widget( _widget ) {
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( widget == NULL ) {
return idSWFScriptVar();
}
widget->Update();
return idSWFScriptVar();
}
private:
idMenuWidget_InfoBox * widget;
};
if ( GetSWFObject() != NULL ) {
GetSWFObject()->SetGlobal( "refreshInfoBox", new (TAG_SWF) idInfoBoxRefresh( &emailInfo ) );
}
}
/*
========================
idMenuScreen_PDA_UserEmails::ShowScreen
========================
*/
void idMenuScreen_PDA_UserEmails::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI != NULL ) {
readingEmails = false;
idSWFScriptObject & root = menuGUI->GetRootObject();
idSWFSpriteInstance * pdaSprite = root.GetNestedSprite( "pda_persons" );
if ( pdaSprite != NULL && menuData != NULL && menuData->ActiveScreen() != PDA_AREA_USER_DATA ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOn" );
}
menuGUI->SetGlobal( "emailRollback", false );
if ( pdaInbox.BindSprite( root ) && pdaInbox.GetSprite() ) {
pdaInbox.GetSprite()->StopFrame( 1 );
}
if ( emailInfo.BindSprite( root ) && emailInfo.GetSprite() ) {
emailInfo.GetSprite()->StopFrame( 1 );
}
}
scrollEmailInfo = false;
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_UserEmails::Update
========================
*/
void idMenuScreen_PDA_UserEmails::Update() {
if ( menuData != NULL ) {
if ( menuData->NextScreen() != PDA_AREA_USER_EMAIL ) {
return;
}
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * const >( menuData->GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
if ( readingEmails ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
} else {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
int pdaIndex = pdaList->GetViewIndex();
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
if ( pdaIndex < player->GetInventory().pdas.Num() ) {
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
if ( pda != NULL && pdaInbox.GetEmailList() != NULL ) {
idStr pdaFullName = pda->GetFullName();
int emailIndex = pdaInbox.GetEmailList()->GetViewIndex();
if ( emailIndex < pda->GetNumEmails() ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01102";
}
buttonInfo->action.Set( WIDGET_ACTION_PDA_SELECT_EMAIL );
}
}
}
}
}
}
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_PDA_CLOSE );
}
}
UpdateEmail();
idMenuScreen::Update();
}
/*
========================
idMenuScreen_PDA_UserEmails::HideScreen
========================
*/
void idMenuScreen_PDA_UserEmails::HideScreen( const mainMenuTransition_t transitionType ) {
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
idSWFSpriteInstance * pdaSprite = root.GetNestedSprite( "pda_persons" );
if ( pdaSprite != NULL && menuData != NULL ) {
if ( menuData->NextScreen() != PDA_AREA_USER_DATA ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOff" );
readingEmails = false;
} else {
if ( readingEmails ) {
readingEmails = false;
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOn" );
}
}
}
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_UserEmails::UpdateEmail
========================
*/
void idMenuScreen_PDA_UserEmails::UpdateEmail() {
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
int pdaIndex = pdaList->GetViewIndex();
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( pdaIndex > player->GetInventory().pdas.Num() ) {
return;
}
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
if ( pda != NULL && pdaInbox.GetEmailList() != NULL ) {
idStr pdaFullName = pda->GetFullName();
int emailIndex = pdaInbox.GetEmailList()->GetViewIndex();
if ( emailIndex < pda->GetNumEmails() ) {
const idDeclEmail * email = pda->GetEmailByIndex( emailIndex );
if ( email != NULL ) {
emailInfo.SetHeading( email->GetSubject() );
emailInfo.SetBody( email->GetBody() );
emailInfo.Update();
}
}
}
}
}
/*
========================
idMenuScreen_PDA_UserEmails::HandleAction
========================
*/
bool idMenuScreen_PDA_UserEmails::ScrollCorrectList( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget ) {
bool handled = false;
bool leftScroll = false;
if ( event.type == WIDGET_EVENT_SCROLL_UP_LSTICK || event.type == WIDGET_EVENT_SCROLL_DOWN_LSTICK ||
event.type == WIDGET_EVENT_SCROLL_UP || event.type == WIDGET_EVENT_SCROLL_DOWN ) {
leftScroll = true;
}
if ( readingEmails ) {
if ( leftScroll && !scrollEmailInfo ) {
idMenuWidget_DynamicList * inbox = pdaInbox.GetEmailList();
if ( inbox != NULL ){
inbox->HandleAction( action, event, inbox );
UpdateEmail();
handled = true;
}
} else {
emailInfo.HandleAction( action, event, &emailInfo );
handled = true;
}
} else if ( !leftScroll ) {
idMenuWidget_DynamicList * inbox = pdaInbox.GetEmailList();
if ( inbox != NULL ){
inbox->HandleAction( action, event, inbox );
UpdateEmail();
handled = true;
}
} else if ( menuData != NULL ) {
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * const >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
pdaList->HandleAction( action, event, pdaList );
handled = true;
}
}
return handled;
}
/*
========================
idMenuScreen_PDA_UserEmails::HandleAction
========================
*/
void idMenuScreen_PDA_UserEmails::ShowEmail( bool show ) {
idSWFSpriteInstance * pdaSprite = NULL;
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
pdaSprite = root.GetNestedSprite( "pda_persons" );
if ( show && !readingEmails ) {
scrollEmailInfo = false;
if ( pdaSprite != NULL ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOff" );
}
if ( emailInfo.BindSprite( root ) && emailInfo.GetSprite() != NULL ) {
emailInfo.GetSprite()->PlayFrame( "rollOn" );
emailInfo.Update();
}
if ( pdaInbox.BindSprite( root ) && pdaInbox.GetSprite() != NULL ) {
pdaInbox.GetSprite()->PlayFrame( "rollOff" );
}
} else if ( !show && readingEmails ) {
if ( emailInfo.BindSprite( root ) && emailInfo.GetSprite() != NULL ) {
emailInfo.GetSprite()->PlayFrame( "rollOff" );
}
if ( pdaInbox.BindSprite( root ) && pdaInbox.GetSprite() != NULL ) {
pdaInbox.GetSprite()->PlayFrame( "rollOn" );
}
if ( pdaSprite != NULL ) {
pdaSprite->SetVisible( true );
pdaSprite->PlayFrame( "rollOn" );
if ( menuData != NULL ) {
idMenuWidget_DynamicList * pdaList = dynamic_cast< idMenuWidget_DynamicList * const >( menuData->GetChildFromIndex( PDA_WIDGET_PDA_LIST ) );
if ( pdaList != NULL ) {
pdaList->SetFocusIndex( pdaList->GetFocusIndex() );
}
}
}
}
}
readingEmails = show;
Update();
}
/*
========================
idMenuScreen_PDA_UserEmails::HandleAction
========================
*/
bool idMenuScreen_PDA_UserEmails::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != PDA_AREA_USER_EMAIL ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_PDA_CLOSE: {
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
return true;
}
case WIDGET_ACTION_GO_BACK: {
if ( readingEmails ) {
ShowEmail( false );
} else {
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
}
return true;
}
case WIDGET_ACTION_REFRESH: {
UpdateEmail();
return true;
}
case WIDGET_ACTION_PDA_SELECT_EMAIL: {
if ( widget->GetParent() != NULL ) {
idMenuWidget_DynamicList * emailList = dynamic_cast< idMenuWidget_DynamicList * >( widget->GetParent() );
int index = parms[0].ToInteger();
if ( emailList != NULL ) {
emailList->SetViewIndex( emailList->GetViewOffset() + index );
emailList->SetFocusIndex( index );
}
}
ShowEmail( true );
return true;
}
case WIDGET_ACTION_EMAIL_HOVER: {
scrollEmailInfo = parms[0].ToBool();
return true;
}
case WIDGET_ACTION_SCROLL_VERTICAL: {
if ( ScrollCorrectList( action, event, widget ) ) {
return true;
}
UpdateEmail();
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_PDA_UserEmails::ObserveEvent
========================
*/
void idMenuScreen_PDA_UserEmails::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
if ( menuData != NULL && menuData->ActiveScreen() != PDA_AREA_USER_EMAIL ) {
return;
}
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
Update();
break;
}
}
}

View File

@@ -0,0 +1,322 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 MAX_VIDEO_ITEMS = 5;
/*
========================
idMenuScreen_PDA_VideoDisks::Initialize
========================
*/
void idMenuScreen_PDA_VideoDisks::Initialize( idMenuHandler * data ) {
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuVideo" );
videoDetails.SetSpritePath( GetSpritePath(), "info", "details" );
videoDetails.Initialize( data );
videoDetails.SetNoAutoFree( true );
scrollbar.SetSpritePath( GetSpritePath(), "info", "videoList", "scrollbar" );
scrollbar.Initialize( data );
scrollbar.SetNoAutoFree( true );
pdaVideoList.SetSpritePath( GetSpritePath(), "info", "videoList", "options" );
pdaVideoList.SetNumVisibleOptions( MAX_VIDEO_ITEMS );
pdaVideoList.SetWrappingAllowed( true );
pdaVideoList.SetNoAutoFree( true );
while ( pdaVideoList.GetChildren().Num() < MAX_VIDEO_ITEMS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_PDA_VIDEO, pdaVideoList.GetChildren().Num() );
buttonWidget->RegisterEventObserver( &videoDetails );
buttonWidget->RegisterEventObserver( &scrollbar );
buttonWidget->Initialize( data );
pdaVideoList.AddChild( buttonWidget );
}
pdaVideoList.Initialize( data );
pdaVideoList.AddChild( &scrollbar );
AddChild( &pdaVideoList );
AddChild( &videoDetails );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( &pdaVideoList, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_TAB_NEXT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_NEXT, WIDGET_EVENT_TAB_NEXT ) );
AddEventAction( WIDGET_EVENT_TAB_PREV ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_TAB_PREV, WIDGET_EVENT_TAB_PREV ) );
idMenuScreen::Initialize( data );
}
/*
========================
idMenuScreen_PDA_VideoDisks::Update
========================
*/
void idMenuScreen_PDA_VideoDisks::Update() {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * const >( menuData->GetChildFromIndex( PDA_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
if ( player != NULL && player->GetInventory().videos.Num() > 0 ) {
if ( player->GetVideoMaterial() == NULL ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_play";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
} else {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_stop";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
}
}
if ( player != NULL ) {
//if ( pdaVideoList == NULL ) {
// idMenuScreen::Update();
// return;
//}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
int index = pdaVideoList.GetViewIndex();
const idDeclVideo * video = player->GetVideo( index );
if ( video == NULL ) {
idMenuScreen::Update();
return;
}
if ( player->GetVideoMaterial() != NULL ) {
// update video material
if ( BindSprite( root ) && GetSprite() != NULL ) {
idSWFSpriteInstance * videoSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "details", "video", "img" );
const idMaterial * mat = player->GetVideoMaterial();
if ( videoSprite != NULL && mat != NULL ) {
videoSprite->SetMaterial( mat );
}
}
} else {
idSWFSpriteInstance * videoSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "details", "video", "img" );
if ( videoSprite != NULL ) {
videoSprite->SetMaterial( video->GetPreview() );
}
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_PDA_VideoDisks::ShowScreen
========================
*/
void idMenuScreen_PDA_VideoDisks::ShowScreen( const mainMenuTransition_t transitionType ) {
videoItems.Clear();
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
int numVideos = player->GetInventory().videos.Num();
for ( int i = 0; i < numVideos; ++i ) {
const idDeclVideo * video = player->GetVideo( i );
if( video != NULL ) {
idList< idStr > item;
item.Append( video->GetVideoName() );
videoItems.Append( item );
}
}
}
pdaVideoList.SetListData( videoItems );
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_VideoDisks::ToggleVideoDiskPlay
========================
*/
void idMenuScreen_PDA_VideoDisks::ToggleVideoDiskPlay() {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
int index = pdaVideoList.GetViewIndex();
const idDeclVideo * video = player->GetVideo( index );
if ( video == NULL ) {
return;
}
if ( video == activeVideo ) {
player->EndVideoDisk();
activeVideo = NULL;
return;
}
activeVideo = video;
if ( player->GetVideoMaterial() == NULL ) {
player->PlayVideoDisk( video );
} else {
player->EndVideoDisk();
}
}
/*
========================
idMenuScreen_PDA_VideoDisks::SelectedVideoToPlay
========================
*/
void idMenuScreen_PDA_VideoDisks::SelectedVideoToPlay( int index ) {
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
player->EndVideoDisk();
if ( menuData != NULL ) {
idMenuHandler_PDA * pdaHandler = dynamic_cast< idMenuHandler_PDA * const >( menuData );
pdaHandler->ClearVideoPlaying();
}
pdaVideoList.SetViewIndex( pdaVideoList.GetViewOffset() + index );
pdaVideoList.SetFocusIndex( index );
const idDeclVideo * video = player->GetVideo( pdaVideoList.GetViewOffset() + index );
if ( video == NULL ) {
return;
}
if ( video == activeVideo ) {
activeVideo = NULL;
return;
}
activeVideo = video;
player->PlayVideoDisk( video );
}
/*
========================
idMenuScreen_PDA_VideoDisks::HideScreen
========================
*/
void idMenuScreen_PDA_VideoDisks::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_PDA_VideoDisks::HandleAction
========================
*/
bool idMenuScreen_PDA_VideoDisks::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != PDA_AREA_VIDEO_DISKS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( PDA_AREA_INVALID, MENU_TRANSITION_ADVANCE );
return true;
}
case WIDGET_ACTION_START_REPEATER: {
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() == 2 );
repeatAction.Set( repeatActionType, parms[ 1 ] );
if ( menuData != NULL ) {
menuData->StartWidgetActionRepeater( widget, repeatAction, event );
}
return true;
}
case WIDGET_ACTION_STOP_REPEATER: {
if ( menuData != NULL ) {
menuData->ClearWidgetActionRepeater();
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
ToggleVideoDiskPlay();
Update();
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,570 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
//***************************************************************
// DEFAULT SCOREBOARD
//***************************************************************
static const int MAX_SCOREBOARD_SLOTS = 8;
/*
========================
idMenuScreen_Scoreboard::Initialize
========================
*/
void idMenuScreen_Scoreboard::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "sbDefault" );
playerList = new (TAG_SWF) idMenuWidget_ScoreboardList();
playerList->SetSpritePath( GetSpritePath(), "info", "playerList" );
playerList->SetNumVisibleOptions( MAX_SCOREBOARD_SLOTS );
playerList->SetWrappingAllowed( true );
while ( playerList->GetChildren().Num() < MAX_SCOREBOARD_SLOTS ) {
idMenuWidget_ScoreboardButton * const buttonWidget = new (TAG_SWF) idMenuWidget_ScoreboardButton();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, playerList->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, playerList->GetChildren().Num() );
buttonWidget->Initialize( data );
playerList->AddChild( buttonWidget );
}
playerList->Initialize( data );
AddChild( playerList );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
}
/*
========================
idMenuScreen_Scoreboard::Update
========================
*/
void idMenuScreen_Scoreboard::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = dynamic_cast< idMenuWidget_CommandBar * const >( menuData->GetChildFromIndex( SCOREBOARD_WIDGET_CMD_BAR ) );
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
if ( gameLocal.mpGame.GetGameState() != idMultiplayerGame::GAMEREVIEW ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_01345";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_TAB );
buttonInfo->label = "";
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
}
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_view_profile";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Scoreboard::ShowScreen
========================
*/
void idMenuScreen_Scoreboard::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
if ( GetSWFObject() ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtScoreboard" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02618" );
txtVal->SetStrokeInfo( true, 0.9f, 2.0f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtGameType" );
if ( txtVal != NULL ) {
idStr mode = idLocalization::GetString( "#str_02376" );
mode.Append( ": " );
const idStrList & modes = common->GetModeDisplayList();
idStr modeName = idLocalization::GetString( modes[ idMath::ClampInt( 0, modes.Num() - 1, gameLocal.gameType ) ] );
mode.Append( idLocalization::GetString( idLocalization::GetString( modeName ) ) );
txtVal->SetText( mode );
txtVal->SetStrokeInfo( true, 0.9f, 1.8f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtNameHeading" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02181" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtScore" );
if ( txtVal != NULL ) {
if ( gameLocal.gameType == GAME_LASTMAN ) {
txtVal->SetText( idLocalization::GetString( "#str_04242" ) );
} else if ( gameLocal.gameType == GAME_CTF ) {
txtVal->SetText( idLocalization::GetString( "#str_11112" ) );
} else {
txtVal->SetText( idLocalization::GetString( "#str_04243" ) );
}
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtWins" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02619" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtPing" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02048" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtNameHeading2" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02181" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtScore2" );
if ( txtVal != NULL ) {
if ( gameLocal.gameType == GAME_LASTMAN ) {
txtVal->SetText( idLocalization::GetString( "#str_04242" ) );
} else if ( gameLocal.gameType == GAME_CTF ) {
txtVal->SetText( idLocalization::GetString( "#str_11112" ) );
} else {
txtVal->SetText( idLocalization::GetString( "#str_04243" ) );
}
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtWins2" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02619" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtPing2" );
if ( txtVal != NULL ) {
txtVal->SetText( "#str_02048" );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
}
}
/*
========================
idMenuScreen_Scoreboard::SetPlayerData
========================
*/
void idMenuScreen_Scoreboard::SetPlayerData( idList< scoreboardInfo_t, TAG_IDLIB_LIST_MENU > data ) {
if ( playerList != NULL ) {
for ( int i = 0; i < data.Num(); ++i ) {
if ( i < playerList->GetChildren().Num() ) {
idMenuWidget_ScoreboardButton * button = dynamic_cast< idMenuWidget_ScoreboardButton * >( &playerList->GetChildByIndex( i ) );
if ( button != NULL ) {
button->SetButtonInfo( data[i].index, data[i].values, data[i].voiceState );
}
}
playerList->Update();
}
}
}
/*
========================
idMenuScreen_Scoreboard::UpdateGameInfo
========================
*/
void idMenuScreen_Scoreboard::UpdateGameInfo( idStr gameInfo ) {
if ( GetSWFObject() ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtGameInfo" );
if ( txtVal != NULL ) {
txtVal->SetText( gameInfo );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
}
}
/*
========================
idMenuScreen_Scoreboard::UpdateSpectating
========================
*/
void idMenuScreen_Scoreboard::UpdateSpectating( idStr spectating, idStr follow ) {
if ( GetSWFObject() ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtSpectating" );
if ( txtVal != NULL ) {
txtVal->tooltip = true;
txtVal->SetText( spectating );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtFollow" );
if ( txtVal != NULL ) {
txtVal->SetText( follow );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
}
}
/*
========================
idMenuScreen_Scoreboard::UpdateTeamScores
========================
*/
void idMenuScreen_Scoreboard::UpdateTeamScores( int r, int b ) {
if ( GetSWFObject() ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtRedScore" );
if ( txtVal != NULL ) {
txtVal->SetText( va( "%i", r ) );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBlueScore" );
if ( txtVal != NULL ) {
txtVal->SetText( va( "%i", b ) );
txtVal->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
}
}
/*
========================
idMenuScreen_Scoreboard::UpdateHighlight
========================
*/
void idMenuScreen_Scoreboard::UpdateHighlight() {
if ( playerList == NULL || menuData == NULL ) {
return;
}
idMenuHandler_Scoreboard * data = dynamic_cast< idMenuHandler_Scoreboard * >( menuData );
int curIndex = playerList->GetViewIndex();
int newIndex = playerList->GetViewIndex();
int numRed = data->GetNumPlayers( 0 );
int numBlue = data->GetNumPlayers( 1 );
if ( numBlue == 0 ) {
if ( curIndex >= numRed ) {
newIndex = numRed - 1;
}
} else {
if ( curIndex > 3 + numBlue ) {
newIndex = 3 + numBlue;
} else if ( curIndex <= 3 ) {
if ( numRed == 0 ) {
newIndex = 4;
} else {
if ( curIndex >= numRed ) {
newIndex = numRed - 1;
}
}
}
}
// newIndex can be -1 if all players are spectating ( no rankedplayers )
if ( newIndex != curIndex && newIndex != -1 ) {
playerList->SetViewIndex( newIndex );
playerList->SetFocusIndex( newIndex );
}
}
/*
========================
idMenuScreen_Scoreboard::HandleAction
========================
*/
bool idMenuScreen_Scoreboard::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SCOREBOARD_AREA_INVALID, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_MUTE_PLAYER: {
if ( parms.Num() != 1 ) {
return true;
}
idMenuHandler_Scoreboard * data = dynamic_cast< idMenuHandler_Scoreboard * >( menuData );
if ( !data ) {
return true;
}
int index = parms[0].ToInteger();
data->MutePlayer( index );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( playerList == NULL ) {
return true;
}
int selectionIndex = playerList->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != playerList->GetFocusIndex() ) {
playerList->SetViewIndex( playerList->GetViewOffset() + selectionIndex );
playerList->SetFocusIndex( selectionIndex );
}
idMenuHandler_Scoreboard * data = dynamic_cast< idMenuHandler_Scoreboard * >( menuData );
if ( !data ) {
return true;
}
int numRed = data->GetNumPlayers( 0 );
int numBlue = data->GetNumPlayers( 1 );
if ( selectionIndex >= 4 && numBlue != 0 ) {
int index = numRed + ( selectionIndex - 4 );
data->ViewPlayerProfile( index );
} else {
data->ViewPlayerProfile( selectionIndex );
}
return true;
}
case WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE: {
if ( parms.Num() == 0 ) {
return true;
}
if ( playerList ) {
int dir = parms[ 0 ].ToInteger();
int scroll = 0;
int curIndex = playerList->GetFocusIndex();
idMenuHandler_Scoreboard * data = dynamic_cast< idMenuHandler_Scoreboard * >( menuData );
if ( !data ) {
return true;
}
int numRed = data->GetNumPlayers( 0 );
int numBlue = data->GetNumPlayers( 1 );
if ( numRed + numBlue <= 1 ) {
return true;
}
if ( dir > 0 ) {
if ( numBlue == 0 ) {
if ( curIndex + 1 >= numRed ) {
scroll = MAX_SCOREBOARD_SLOTS - curIndex;
} else {
scroll = dir;
}
} else {
if ( curIndex < 4 ) {
if ( curIndex + 1 >= numRed ) {
scroll = ( MAX_SCOREBOARD_SLOTS * 0.5f ) - curIndex;
} else {
scroll = dir;
}
} else {
if ( curIndex - 3 >= numBlue ) {
scroll = MAX_SCOREBOARD_SLOTS - curIndex;
} else {
scroll = dir;
}
}
}
} else if ( dir < 0 ) {
if ( numBlue == 0 ) {
if ( curIndex - 1 < 0 ) {
scroll = numRed - 1;
} else {
scroll = dir;
}
} else {
if ( curIndex < 4 ) {
if ( curIndex - 1 < 0 ) {
scroll = ( ( MAX_SCOREBOARD_SLOTS * 0.5f ) + numBlue ) - 1;
} else {
scroll = dir;
}
} else {
if ( curIndex - 1 < 4 ) {
scroll = -( ( MAX_SCOREBOARD_SLOTS * 0.5f ) - ( numRed - 1 ) );
} else {
scroll = dir;
}
}
}
}
if ( scroll != 0 ) {
playerList->Scroll( scroll );
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
//***************************************************************
// CTF SCOREBOARD
//***************************************************************
/*
========================
idMenuScreen_Scoreboard_CTF::Initialize
========================
*/
void idMenuScreen_Scoreboard_CTF::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "sbCTF" );
playerList = new (TAG_SWF) idMenuWidget_ScoreboardList();
playerList->SetSpritePath( GetSpritePath(), "info", "playerList" );
playerList->SetNumVisibleOptions( MAX_SCOREBOARD_SLOTS );
playerList->SetWrappingAllowed( true );
while ( playerList->GetChildren().Num() < MAX_SCOREBOARD_SLOTS ) {
idMenuWidget_ScoreboardButton * const buttonWidget = new (TAG_SWF) idMenuWidget_ScoreboardButton();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, playerList->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, playerList->GetChildren().Num() );
buttonWidget->Initialize( data );
playerList->AddChild( buttonWidget );
}
playerList->Initialize( data );
AddChild( playerList );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
}
//***************************************************************
// TEAM SCOREBOARD
//***************************************************************
/*
========================
idMenuScreen_Scoreboard_Team::Initialize
========================
*/
void idMenuScreen_Scoreboard_Team::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "sbTeam" );
playerList = new (TAG_SWF) idMenuWidget_ScoreboardList();
playerList->SetSpritePath( GetSpritePath(), "info", "playerList" );
playerList->SetNumVisibleOptions( MAX_SCOREBOARD_SLOTS );
playerList->SetWrappingAllowed( true );
while ( playerList->GetChildren().Num() < MAX_SCOREBOARD_SLOTS ) {
idMenuWidget_ScoreboardButton * const buttonWidget = new (TAG_SWF) idMenuWidget_ScoreboardButton();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, playerList->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, playerList->GetChildren().Num() );
buttonWidget->Initialize( data );
playerList->AddChild( buttonWidget );
}
playerList->Initialize( data );
AddChild( playerList );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
}

View File

@@ -0,0 +1,527 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
typedef struct {
const char * display;
const char * bind;
} bindInfo_t;
static bindInfo_t keyboardBinds[] = {
{ "#str_02090", "" }, // HEADING
{ "#str_02100", "_forward" }, // FORWARD
{ "#str_02101", "_back" }, // BACKPEDAL
{ "#str_02102", "_moveLeft" }, // MOVE LEFT
{ "#str_02103", "_moveRight" }, // MOVE RIGHT
{ "#str_02104", "_moveUp" }, // JUMP
{ "#str_02105", "_moveDown" }, // CROUCH
{ "#str_02106", "_left" }, // TURN LEFT
{ "#str_02107", "_right" }, // TURN RIGHT
{ "#str_02109", "_speed" }, // SPRINT
{ "#str_02095", "" }, // HEADING
{ "#str_02112", "_attack" }, // ATTACK
{ "#str_02114", "_impulse14" }, // PREV. WEAPON
{ "#str_02113", "_impulse15" }, // NEXT WEAPON
{ "#str_02115", "_impulse13" }, // RELOAD
{ "#str_swf_action_use", "_use" }, // USE
{ "#str_02116", "_lookUp" }, // LOOK UP
{ "#str_02117", "_lookDown" }, // LOOK DOWN
{ "#str_02121", "_impulse19" }, // PDA / SCOREBOARD
{ "#str_02093", "" }, // HEADING
{ "#str_00100177", "_impulse0" }, // FISTS / GRABBER
{ "#str_00100178", "_impulse2" }, // PISTOL
{ "#str_00100179", "_impulse3" }, // SHOTGUN / DOUBLE
{ "#str_00100180", "_impulse5" }, // MACHINEGUN
{ "#str_00100181", "_impulse6" }, // CHAINGUN
{ "#str_00100182", "_impulse7" }, // GRENADES
{ "#str_00100183", "_impulse8" }, // PLASMA GUN
{ "#str_00100184", "_impulse9" }, // ROCKETS
{ "#str_00100185", "_impulse10" }, // BFG
{ "#str_swf_soulcube_artifact", "_impulse12" }, // SOULCUBE / ARTIFACT
{ "#str_00100187", "_impulse16" }, // FLASHLIGHT
{ "#str_04065", "" }, // HEADING
{ "#str_04067", "savegame quick" }, // QUICK SAVE
{ "#str_04068", "loadgame quick" }, // QUICK LOAD
{ "#str_04069", "screenshot" }, // SCREENSHOT
{ "#str_02068", "clientMessageMode" }, // SCREENSHOT
{ "#str_02122", "clientMessageMode 1" }, // SCREENSHOT
//{ "#str_04071", "clientDropWeapon" } // DROP WEAPON
};
static const int numBinds = sizeof( keyboardBinds ) / sizeof( keyboardBinds[0] );
static const int NUM_BIND_LISTINGS = 14;
/*
========================
idMenuScreen_Shell_Bindings::Initialize
========================
*/
void idMenuScreen_Shell_Bindings::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuBindings" );
restoreDefault = new idMenuWidget_Button();
restoreDefault->Initialize( data );
restoreDefault->SetLabel( "" );
restoreDefault->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_JOY3_ON_PRESS );
restoreDefault->SetSpritePath( GetSpritePath(), "info", "btnRestore" );
AddChild( restoreDefault );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
idStr controls( idLocalization::GetString( "#str_04158" ) );
controls.ToUpper();
btnBack->SetLabel( controls );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options = new idMenuWidget_DynamicList();
options->SetIgnoreColor( true );
options->SetNumVisibleOptions( NUM_BIND_LISTINGS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
UpdateBindingDisplay();
while ( options->GetChildren().Num() < NUM_BIND_LISTINGS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Bindings::Update
========================
*/
void idMenuScreen_Shell_Bindings::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_controls_keyboard" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Bindings::ShowScreen
========================
*/
void idMenuScreen_Shell_Bindings::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( options != NULL ) {
options->SetViewOffset( 0 );
options->SetViewIndex( 1 );
options->SetFocusIndex( 1 );
}
if ( menuData != NULL ) {
menuGUI = menuData->GetGUI();
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
txtBlinder = root.GetNestedSprite( "menuBindings", "info", "rebind" );
blinder = root.GetNestedSprite( "menuBindings", "info", "blinder" );
if ( restoreDefault != NULL ) {
restoreDefault->BindSprite( root );
}
}
}
ToggleWait( false );
UpdateBindingDisplay();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Bindings::HideScreen
========================
*/
void idMenuScreen_Shell_Bindings::HideScreen( const mainMenuTransition_t transitionType ) {
if ( bindingsChanged ) {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
bindingsChanged = false;
}
idMenuScreen::HideScreen( transitionType );
}
extern idCVar in_useJoystick;
/*
========================
idMenuScreen_Shell_Bindings::UpdateBindingDisplay
========================
*/
void idMenuScreen_Shell_Bindings::UpdateBindingDisplay() {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > bindList;
for ( int i = 0; i < numBinds; ++i ) {
idList< idStr > option;
option.Append( keyboardBinds[i].display );
if ( ( idStr::Icmp( keyboardBinds[i].bind, "" ) != 0 ) ) {
keyBindings_t bind = idKeyInput::KeyBindingsFromBinding( keyboardBinds[i].bind, false, true );
idStr bindings;
if ( !bind.gamepad.IsEmpty() && in_useJoystick.GetBool() ) {
idStrList joyBinds;
int start = 0;
while ( start < bind.gamepad.Length() ) {
int end = bind.gamepad.Find( ", ", true, start );
if ( end < 0 ) {
end = bind.gamepad.Length();
}
joyBinds.Alloc().CopyRange( bind.gamepad, start, end );
start = end + 2;
}
const char * buttonsWithImages[] = {
"JOY1", "JOY2", "JOY3", "JOY4", "JOY5", "JOY6",
"JOY_TRIGGER1", "JOY_TRIGGER2", 0
};
for ( int i = 0; i < joyBinds.Num(); i++ ) {
if ( joyBinds[i].Icmpn( "JOY_STICK", 9 ) == 0 ) {
continue; // Can't rebind the sticks, so don't even show them
}
bool hasImage = false;
for ( const char ** b = buttonsWithImages; *b != 0; b++ ) {
if ( joyBinds[i].Icmp( *b ) == 0 ) {
hasImage = true;
break;
}
}
if ( !bindings.IsEmpty() ) {
bindings.Append( ", " );
}
if ( hasImage ) {
bindings.Append( '<' );
bindings.Append( joyBinds[i] );
bindings.Append( '>' );
} else {
bindings.Append( joyBinds[i] );
}
}
bindings.Replace( "JOY_DPAD", "DPAD" );
}
if ( !bind.keyboard.IsEmpty() ) {
if ( !bindings.IsEmpty() ) {
bindings.Append( ", " );
}
bindings.Append( bind.keyboard );
}
if ( !bind.mouse.IsEmpty() ) {
if ( !bindings.IsEmpty() ) {
bindings.Append( ", " );
}
bindings.Append( bind.mouse );
}
bindings.ToUpper();
option.Append( bindings );
} else {
option.Append( "" );
}
bindList.Append( option );
}
options->SetListData( bindList );
}
/*
========================
idMenuScreen_Shell_Bindings::ToggleWait
========================
*/
void idMenuScreen_Shell_Bindings::ToggleWait( bool wait ) {
if ( wait ) {
if ( blinder != NULL ) {
blinder->SetVisible( true );
if ( options != NULL ) {
blinder->StopFrame( options->GetFocusIndex() + 1 );
}
}
if ( txtBlinder != NULL ) {
txtBlinder->SetVisible( true );
}
if ( restoreDefault != NULL ) {
restoreDefault->SetLabel( "" );
}
} else {
if ( blinder != NULL ) {
blinder->SetVisible( false );
}
if ( txtBlinder != NULL ) {
txtBlinder->SetVisible( false );
}
if ( restoreDefault != NULL ) {
if ( menuData != NULL ) {
menuGUI = menuData->GetGUI();
if ( menuGUI != NULL ) {
idSWFScriptObject & root = menuGUI->GetRootObject();
restoreDefault->SetSpritePath( GetSpritePath(), "info", "btnRestore" );
restoreDefault->BindSprite( root );
}
}
if ( restoreDefault->GetSprite() ) {
restoreDefault->GetSprite()->SetVisible( true );
}
restoreDefault->SetLabel( "#str_swf_restore_defaults" );
}
}
}
/*
========================
idMenuScreen_Shell_Bindings::SetBinding
========================
*/
void idMenuScreen_Shell_Bindings::SetBinding( int keyNum ) {
int listIndex = options->GetViewIndex();
idKeyInput::SetBinding( keyNum, keyboardBinds[ listIndex ].bind );
UpdateBindingDisplay();
ToggleWait( false );
Update();
}
/*
========================
idMenuScreen_Shell_Bindings::HandleRestoreDefaults
========================
*/
void idMenuScreen_Shell_Bindings::HandleRestoreDefaults() {
class idSWFScriptFunction_Restore : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Restore( gameDialogMessages_t _msg, bool _accept, idMenuScreen_Shell_Bindings * _menu ) {
msg = _msg;
accept = _accept;
menu = _menu;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept ) {
idLocalUser * user = session->GetSignInManager().GetMasterLocalUser();
if ( user != NULL ) {
idPlayerProfile * profile = user->GetProfile();
if ( profile != NULL ) {
profile->RestoreDefault();
if ( menu != NULL ) {
menu->UpdateBindingDisplay();
menu->Update();
}
}
}
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
bool accept;
idMenuScreen_Shell_Bindings * menu;
};
common->Dialog().AddDialog( GDM_BINDINGS_RESTORE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_Restore( GDM_BINDINGS_RESTORE, true, this ), new idSWFScriptFunction_Restore( GDM_BINDINGS_RESTORE, false, this ), false );
}
/*
========================
idMenuScreen_Shell_Bindings::HandleAction
========================
*/
bool idMenuScreen_Shell_Bindings::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_KEYBOARD ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_CONTROLS, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_JOY3_ON_PRESS: {
HandleRestoreDefaults();
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
int listIndex = 0;
if ( parms.Num() > 0 ) {
listIndex = options->GetViewOffset() + parms[ 0 ].ToInteger();
} else {
listIndex = options->GetViewIndex();
}
if ( listIndex < 0 || listIndex >= numBinds ) {
return true;
}
if ( options->GetViewIndex() != listIndex ) {
if ( idStr::Icmp( keyboardBinds[ listIndex ].bind, "" ) == 0 ) {
return true;
}
options->SetViewIndex( listIndex );
options->SetFocusIndex( listIndex - options->GetViewOffset() );
} else {
idMenuHandler_Shell * data = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( data != NULL ) {
ToggleWait( true );
Update();
data->SetWaitForBinding( keyboardBinds[ listIndex ].bind );
}
}
return true;
}
case WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE: {
if ( parms.Num() == 0 ) {
return true;
}
if ( options != NULL ) {
int dir = parms[ 0 ].ToInteger();
int scroll = 0;
int curIndex = options->GetViewIndex();
if ( dir != 0 ) {
if ( curIndex + dir >= numBinds ) {
scroll = dir * 2;
} else if ( curIndex + dir < 1 ) {
scroll = dir * 2;
} else {
if ( idStr::Icmp( keyboardBinds[curIndex + dir].bind, "" ) == 0 ) {
scroll = dir * 2;
} else {
scroll = dir;
}
}
}
options->Scroll( scroll, true );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,403 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
enum browserCommand_t {
BROWSER_COMMAND_REFRESH_SERVERS,
BROWSER_COMMAND_SHOW_GAMERTAG,
};
static const int NUM_SERVER_LIST_ITEMS = 10;
/*
================================================
idPair is is a template class Container composed of two objects, which can be of
any type, and provides accessors to these objects as well as Pair equality operators. The main
uses of Pairs in the engine are for the Tools and for callbacks.
================================================
*/
template<class T, class U>
class idPair {
public:
idPair() { }
idPair( const T& f, const U& s ) : first( f ), second( s ) { }
const bool operator==( const idPair<T,U>& rhs ) const {
return ( rhs.first == first ) && ( rhs.second == second );
}
const bool operator!=( const idPair<T,U>& rhs ) const {
return !(*this == rhs);
}
T first;
U second;
};
/*
================================================
idSort_PlayerGamesList
================================================
*/
class idSort_PlayerGamesList : public idSort_Quick< idPair< serverInfo_t, int >, idSort_PlayerGamesList > {
public:
int Compare( const idPair< serverInfo_t, int > & a, const idPair< serverInfo_t, int > & b ) const {
if ( a.first.joinable == b.first.joinable ) {
return a.first.gameMode - b.first.gameMode;
} else if ( a.first.joinable ) {
return 1;
} else {
return -1;
}
}
};
/*
========================
idMenuScreen_Shell_GameBrowser::Initialize
========================
*/
void idMenuScreen_Shell_GameBrowser::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuPWF" );
listWidget = new idMenuWidget_GameBrowserList();
listWidget->SetSpritePath( GetSpritePath(), "info", "options" );
listWidget->SetNumVisibleOptions( NUM_SERVER_LIST_ITEMS );
listWidget->SetWrappingAllowed( true );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, 1 );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, -1 );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, 1 );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, -1 );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
listWidget->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
AddChild( listWidget );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( listWidget->GetChildren().Num() < NUM_SERVER_LIST_ITEMS ) {
idMenuWidget_ServerButton * buttonWidget = new idMenuWidget_ServerButton;
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, listWidget->GetChildren().Num() );
buttonWidget->SetState( WIDGET_STATE_HIDDEN );
buttonWidget->RegisterEventObserver( helpWidget );
listWidget->AddChild( buttonWidget );
}
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_multiplayer" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
}
/*
========================
idMenuScreen_Shell_GameBrowser::ShowScreen
========================
*/
void idMenuScreen_Shell_GameBrowser::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_pwf_heading" ); // MULTIPLAYER
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
listWidget->ClearGames();
if ( mgr->GetCmdBar() != NULL ) {
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
mgr->GetCmdBar()->ClearAllButtons();
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
buttonInfo->label = "#str_02276";
buttonInfo->action.Set( WIDGET_ACTION_COMMAND, BROWSER_COMMAND_REFRESH_SERVERS );
}
mgr->HidePacifier();
idMenuScreen::ShowScreen( transitionType );
UpdateServerList();
}
/*
========================
idMenuScreen_Shell_GameBrowser::HideScreen
========================
*/
void idMenuScreen_Shell_GameBrowser::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr == NULL ) {
return;
}
mgr->HidePacifier();
session->CancelListServers();
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_GameBrowser::UpdateServerList
========================
*/
void idMenuScreen_Shell_GameBrowser::UpdateServerList() {
idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr == NULL ) {
return;
}
for ( int i = 0; i < listWidget->GetChildren().Num(); ++i ) {
idMenuWidget & child = listWidget->GetChildByIndex( i );
child.SetState( WIDGET_STATE_HIDDEN );
}
// need to show the pacifier before actually making the ListServers call, because it can fail
// immediately and send back an error result to SWF. Things get confused if the showLoadingPacifier
// then gets called after that.
mgr->ShowPacifier( "#str_online_mpstatus_searching" );
session->ListServers( MakeCallback( this, &idMenuScreen_Shell_GameBrowser::OnServerListReady ) );
}
/*
========================
idMenuScreen_Shell_GameBrowser::OnServerListReady
========================
*/
void idMenuScreen_Shell_GameBrowser::OnServerListReady() {
idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr == NULL ) {
return;
}
mgr->HidePacifier();
idList< idPair< serverInfo_t, int > > servers;
for ( int i = 0; i < session->NumServers(); ++i ) {
const serverInfo_t * const server = session->ServerInfo( i );
if ( server != NULL && server->joinable ) {
idPair< serverInfo_t, int > & serverPair = servers.Alloc();
serverPair.first = *server;
serverPair.second = i;
}
}
servers.SortWithTemplate( idSort_PlayerGamesList() );
listWidget->ClearGames();
for ( int i = 0; i < servers.Num(); ++i ) {
idPair< serverInfo_t, int > & serverPair = servers[ i ];
DescribeServer( serverPair.first, serverPair.second );
}
if ( servers.Num() > 0 ) {
listWidget->Update();
listWidget->SetViewOffset( 0 );
listWidget->SetViewIndex( 0 );
listWidget->SetFocusIndex( 0 );
} else {
listWidget->AddGame( "#str_swf_no_servers_found", idStrId(), idStr(), -1, 0, 0, false, false );
listWidget->Update();
listWidget->SetViewOffset( 0 );
listWidget->SetViewIndex( 0 );
listWidget->SetFocusIndex( 0 );
}
if ( mgr->GetCmdBar() != NULL ) {
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
mgr->GetCmdBar()->ClearAllButtons();
if ( servers.Num() > 0 ) {
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#STR_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
buttonInfo->label = "#str_02276";
buttonInfo->action.Set( WIDGET_ACTION_COMMAND, BROWSER_COMMAND_REFRESH_SERVERS );
if ( servers.Num() > 0 ) {
buttonInfo = mgr->GetCmdBar()->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
buttonInfo->label = "#str_swf_view_profile";
buttonInfo->action.Set( WIDGET_ACTION_COMMAND, BROWSER_COMMAND_SHOW_GAMERTAG );
}
mgr->GetCmdBar()->Update();
}
}
/*
========================
idMenuScreen_Shell_GameBrowser::DescribeServers
========================
*/
void idMenuScreen_Shell_GameBrowser::DescribeServer( const serverInfo_t & server, const int index ) {
idStr serverName;
int serverIndex = index;
bool joinable = false;
bool validMap = false;
int players = 0;
int maxPlayers = 0;
idStrId mapName;
idStr modeName;
const idList< mpMap_t > maps = common->GetMapList();
const bool isMapValid = ( server.gameMap >= 0 ) && ( server.gameMap < maps.Num() );
if ( !isMapValid ) {
validMap = false;
serverName = server.serverName;
mapName = "#str_online_in_lobby";
modeName = "";
players = server.numPlayers;
maxPlayers = server.maxPlayers;
joinable = server.joinable;
} else {
mapName = common->GetMapList()[ server.gameMap ].mapName;
const idStrList & modes = common->GetModeDisplayList();
idStr mode = idLocalization::GetString( modes[ idMath::ClampInt( 0, modes.Num() - 1, server.gameMode ) ] );
validMap = true;
serverName = server.serverName;
modeName = mode;
players = server.numPlayers;
maxPlayers = server.maxPlayers;
joinable = server.joinable;
}
listWidget->AddGame( serverName, mapName, modeName, serverIndex, players, maxPlayers, joinable, validMap );
}
/*
========================
idMenuScreen_Shell_GameBrowser::HandleAction h
========================
*/
bool idMenuScreen_Shell_GameBrowser::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandle ) {
idMenuHandler_Shell * const mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr == NULL ) {
return false;
}
if ( mgr->ActiveScreen() != SHELL_AREA_BROWSER ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_PARTY_LOBBY, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_COMMAND: {
switch ( parms[ 0 ].ToInteger() ) {
case BROWSER_COMMAND_REFRESH_SERVERS: {
UpdateServerList();
break;
}
case BROWSER_COMMAND_SHOW_GAMERTAG: {
int index = listWidget->GetServerIndex();
if ( index != -1 ) {
session->ShowServerGamerCardUI( index );
}
break;
}
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
int selectionIndex = listWidget->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != listWidget->GetFocusIndex() ) {
listWidget->SetViewIndex( listWidget->GetViewOffset() + selectionIndex );
listWidget->SetFocusIndex( selectionIndex );
return true;
}
int index = listWidget->GetServerIndex();
if ( index != -1 ) {
session->ConnectToServer( index );
}
return true;
}
}
return idMenuScreen::HandleAction( action, event, widget, forceHandle );
}

View File

@@ -0,0 +1,389 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_LAYOUT_OPTIONS = 1;
const static int MAX_CONTROLLER_CONFIGS = 2;
typedef struct {
const char * textField;
int keyNum;
} gamepadBindInfo_t;
static gamepadBindInfo_t gamepadBinds[] = {
{ "txtJoy1", K_JOY1 },
{ "txtJoy2", K_JOY2 },
{ "txtJoy3", K_JOY3 },
{ "txtJoy4", K_JOY4 },
{ "txtDpad", K_JOY_DPAD_UP },
{ "txtStart", K_JOY9 },
{ "txtBack", K_JOY10 },
{ "txtLClick", K_JOY7 },
{ "txtRClick", K_JOY8 },
{ "txtLBumper", K_JOY5 },
{ "txtRBumper", K_JOY6 },
{ "txtLStick", K_JOY_STICK1_UP },
{ "txtRStick", K_JOY_STICK2_UP },
{ "txtLTrigger", K_JOY_TRIGGER1 },
{ "txtRTrigger", K_JOY_TRIGGER2 }
};
static const int numGamepadBinds = sizeof( gamepadBinds ) / sizeof( gamepadBinds[0] );
/*
========================
idMenuScreen_Shell_ControllerLayout::Initialize
========================
*/
void idMenuScreen_Shell_ControllerLayout::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuControllerLayout" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_LAYOUT_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "controlInfo", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_gamepad_heading" ); // CONTROLS
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_BUTTON_FULL_TEXT_SLIDER );
control->SetLabel( "CONTROL LAYOUT" ); // Auto Weapon Reload
control->SetDataSource( &layoutData, idMenuDataSource_LayoutSettings::LAYOUT_FIELD_LAYOUT );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
}
/*
========================
idMenuScreen_Shell_ControllerLayout::Update
========================
*/
void idMenuScreen_Shell_ControllerLayout::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_controller_layout" ); // CONTROLLER LAYOUT
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
if ( menuData != NULL ) {
idSWFSpriteInstance * layout = NULL;
layout = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "controlInfo", "layout360" );
if ( layout != NULL ) {
if ( menuData->GetPlatform( true ) == 2 ) {
layout->StopFrame( 1 );
} else {
layout->StopFrame( menuData->GetPlatform( true ) + 1 );
}
}
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_ControllerLayout::ShowScreen
========================
*/
void idMenuScreen_Shell_ControllerLayout::ShowScreen( const mainMenuTransition_t transitionType ) {
layoutData.LoadData();
idMenuScreen::ShowScreen( transitionType );
if ( GetSprite() != NULL ) {
idSWFSpriteInstance * layout360 = NULL;
idSWFSpriteInstance * layoutPS3 = NULL;
layout360 = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "controlInfo", "layout360" );
layoutPS3 = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "controlInfo", "layoutPS3" );
if ( layout360 != NULL && layoutPS3 != NULL ) {
layout360->SetVisible( true );
layoutPS3->SetVisible( false );
}
}
UpdateBindingInfo();
}
/*
========================
idMenuScreen_Shell_ControllerLayout::HideScreen
========================
*/
void idMenuScreen_Shell_ControllerLayout::HideScreen( const mainMenuTransition_t transitionType ) {
layoutData.CommitData();
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_ControllerLayout::UpdateBindingInfo
========================
*/
void idMenuScreen_Shell_ControllerLayout::UpdateBindingInfo() {
if ( !GetSprite() ) {
return;
}
for ( int i = 0; i < numGamepadBinds; ++i ) {
const char * txtField = gamepadBinds[i].textField;
int keyNum = gamepadBinds[i].keyNum;
idSWFTextInstance * txtVal = NULL;
txtVal = GetSprite()->GetScriptObject()->GetNestedText( "info", "controlInfo", "layout360", txtField );
if ( txtVal != NULL ) {
const char * binding = idKeyInput::GetBinding( keyNum );
if ( binding == NULL || binding[0] == 0 ) {
txtVal->SetText( "" );
} else if ( keyNum == K_JOY7 ) {
idStr action = idLocalization::GetString( va( "#str_swf_action%s", binding ) );
txtVal->SetText( action.c_str() );
} else if ( keyNum == K_JOY8 ) {
idStr action = idLocalization::GetString( va( "#str_swf_action%s", binding ) );
txtVal->SetText( action.c_str() );
} else {
txtVal->SetText( va( "#str_swf_action%s", binding ) );
}
}
}
}
/*
========================
idMenuScreen_Shell_ControllerLayout::HandleAction h
========================
*/
bool idMenuScreen_Shell_ControllerLayout::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_CONTROLLER_LAYOUT ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_GAMEPAD, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( parms.Num() != 1 ) {
return true;
}
if ( options == NULL ) {
return true;
}
int selectionIndex = parms[0].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
layoutData.AdjustField( selectionIndex, 1 );
options->Update();
UpdateBindingInfo();
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
case WIDGET_ACTION_ADJUST_FIELD: {
if ( widget != NULL && widget->GetDataSource() != NULL ) {
widget->GetDataSource()->AdjustField( widget->GetDataSourceFieldIndex(), parms[ 0 ].ToInteger() );
widget->Update();
}
UpdateBindingInfo();
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_AudioSettings::idMenuDataSource_AudioSettings
========================
*/
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_LayoutSettings::idMenuDataSource_LayoutSettings() {
fields.SetNum( MAX_LAYOUT_FIELDS );
originalFields.SetNum( MAX_LAYOUT_FIELDS );
}
/*
========================
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_AudioSettings::LoadData
========================
*/
void idMenuScreen_Shell_ControllerLayout::idMenuDataSource_LayoutSettings::LoadData() {
idPlayerProfile * profile = session->GetProfileFromMasterLocalUser();
if ( profile == NULL ) {
return;
}
int configSet = profile->GetConfig();
fields[ LAYOUT_FIELD_LAYOUT ].SetString( idLocalization::GetString( va( "#str_swf_config_360_%i", configSet ) ) );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_AudioSettings::CommitData
========================
*/
void idMenuScreen_Shell_ControllerLayout::idMenuDataSource_LayoutSettings::CommitData() {
if ( IsDataChanged() ) {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
}
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_AudioSettings::AdjustField
========================
*/
void idMenuScreen_Shell_ControllerLayout::idMenuDataSource_LayoutSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
idPlayerProfile * profile = session->GetProfileFromMasterLocalUser();
if ( profile == NULL ) {
return;
}
int configSet = profile->GetConfig();
if ( fieldIndex == LAYOUT_FIELD_LAYOUT ) {
configSet += adjustAmount;
if ( configSet < 0 ) {
configSet = MAX_CONTROLLER_CONFIGS - 1;
} else if ( configSet >= MAX_CONTROLLER_CONFIGS ) {
configSet = 0;
}
}
fields[ LAYOUT_FIELD_LAYOUT ].SetString( idLocalization::GetString( va( "#str_swf_config_360_%i", configSet ) ) );
profile->SetConfig( configSet, false );
}
/*
========================
idMenuScreen_Shell_ControllerLayout::idMenuDataSource_AudioSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_ControllerLayout::idMenuDataSource_LayoutSettings::IsDataChanged() const {
bool hasLocalChanges = false;
if ( fields[ LAYOUT_FIELD_LAYOUT ].ToString() != originalFields[ LAYOUT_FIELD_LAYOUT ].ToString() ) {
return true;
}
return hasLocalChanges;
}

View File

@@ -0,0 +1,387 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_CONTROLS_OPTIONS = 8;
enum contorlsMenuCmds_t {
CONTROLS_CMD_BINDINGS,
CONTROLS_CMD_GAMEPAD,
CONTROLS_CMD_GAMEPAD_ENABLED,
CONTROLS_CMD_INVERT,
CONTROLS_CMD_MOUSE_SENS
};
/*
========================
idMenuScreen_Shell_Controls::Initialize
========================
*/
void idMenuScreen_Shell_Controls::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuControls" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_CONTROLS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_settings" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_BUTTON_TEXT );
control->SetLabel( "#str_swf_keyboard" ); // KEY BINDINGS
control->SetDescription( "#str_swf_binding_desc" );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, CONTROLS_CMD_BINDINGS );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_BUTTON_TEXT );
control->SetLabel( "#str_swf_gamepad" ); // Gamepad
control->SetDescription( "#str_swf_gamepad_desc" );
control->RegisterEventObserver( helpWidget );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, CONTROLS_CMD_GAMEPAD );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_gamepad_enabled" ); // Gamepad Enabled
control->SetDataSource( &controlData, idMenuDataSource_ControlSettings::CONTROLS_FIELD_GAMEPAD_ENABLED );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, CONTROLS_CMD_GAMEPAD_ENABLED );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_invert_mouse" ); // Invert Mouse
control->SetDataSource( &controlData, idMenuDataSource_ControlSettings::CONTROLS_FIELD_INVERT_MOUSE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, CONTROLS_CMD_INVERT );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_mouse_sens" ); // Mouse Sensitivity
control->SetDataSource( &controlData, idMenuDataSource_ControlSettings::CONTROLS_FIELD_MOUSE_SENS );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, CONTROLS_CMD_MOUSE_SENS );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Controls::Update
========================
*/
void idMenuScreen_Shell_Controls::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
idStr controls( idLocalization::GetString( "#str_04158" ) );
controls.ToUpper();
heading->SetText( controls ); // CONTROLS
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Controls::ShowScreen
========================
*/
void idMenuScreen_Shell_Controls::ShowScreen( const mainMenuTransition_t transitionType ) {
controlData.LoadData();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Controls::HideScreen
========================
*/
void idMenuScreen_Shell_Controls::HideScreen( const mainMenuTransition_t transitionType ) {
if ( controlData.IsDataChanged() ) {
controlData.CommitData();
}
if ( menuData != NULL ) {
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( handler != NULL ) {
handler->SetupPCOptions();
}
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Controls::HandleAction
========================
*/
bool idMenuScreen_Shell_Controls::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_CONTROLS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_COMMAND: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch ( parms[0].ToInteger() ) {
case CONTROLS_CMD_BINDINGS: {
menuData->SetNextScreen( SHELL_AREA_KEYBOARD, MENU_TRANSITION_SIMPLE );
break;
}
case CONTROLS_CMD_GAMEPAD: {
menuData->SetNextScreen( SHELL_AREA_GAMEPAD, MENU_TRANSITION_SIMPLE );
break;
}
case CONTROLS_CMD_INVERT: {
controlData.AdjustField( idMenuDataSource_ControlSettings::CONTROLS_FIELD_INVERT_MOUSE, 1 );
if ( options != NULL ) {
options->Update();
}
break;
}
case CONTROLS_CMD_MOUSE_SENS: {
controlData.AdjustField( idMenuDataSource_ControlSettings::CONTROLS_FIELD_MOUSE_SENS, 1 );
if ( options != NULL ) {
options->Update();
}
break;
}
case CONTROLS_CMD_GAMEPAD_ENABLED: {
controlData.AdjustField( idMenuDataSource_ControlSettings::CONTROLS_FIELD_GAMEPAD_ENABLED, 1 );
if ( options != NULL ) {
options->Update();
}
break;
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
extern idCVar in_mouseInvertLook;
extern idCVar in_mouseSpeed;
extern idCVar in_useJoystick;
/*
========================
idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::idMenuDataSource_AudioSettings
========================
*/
idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::idMenuDataSource_ControlSettings() {
fields.SetNum( MAX_CONTROL_FIELDS );
originalFields.SetNum( MAX_CONTROL_FIELDS );
}
/*
========================
idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::LoadData
========================
*/
void idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::LoadData() {
fields[ CONTROLS_FIELD_INVERT_MOUSE ].SetBool( in_mouseInvertLook.GetBool() );
float mouseSpeed = ( ( in_mouseSpeed.GetFloat() - 0.25f ) / ( 4.0f - 0.25 ) ) * 100.0f;
fields[ CONTROLS_FIELD_MOUSE_SENS ].SetFloat( mouseSpeed );
fields[ CONTROLS_FIELD_GAMEPAD_ENABLED ].SetBool( in_useJoystick.GetBool() );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::CommitData
========================
*/
void idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::CommitData() {
in_mouseInvertLook.SetBool( fields[ CONTROLS_FIELD_INVERT_MOUSE ].ToBool() );
float mouseSpeed = 0.25f + ( ( 4.0f - 0.25 ) * ( fields[ CONTROLS_FIELD_MOUSE_SENS ].ToFloat() / 100.0f ) );
in_mouseSpeed.SetFloat( mouseSpeed );
in_useJoystick.SetBool( fields[ CONTROLS_FIELD_GAMEPAD_ENABLED ].ToBool() );
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::AdjustField
========================
*/
void idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
if ( fieldIndex == CONTROLS_FIELD_INVERT_MOUSE || fieldIndex == CONTROLS_FIELD_GAMEPAD_ENABLED ) {
fields[ fieldIndex ].SetBool( !fields[ fieldIndex ].ToBool() );
} else if ( fieldIndex == CONTROLS_FIELD_MOUSE_SENS ) {
float newValue = idMath::ClampFloat( 0.0f, 100.0f, fields[ fieldIndex ].ToFloat() + adjustAmount );
fields[ fieldIndex ].SetFloat( newValue );
}
}
/*
========================
idMenuScreen_Shell_Controls::idMenuDataSource_AudioSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_Controls::idMenuDataSource_ControlSettings::IsDataChanged() const {
if ( fields[ CONTROLS_FIELD_INVERT_MOUSE ].ToBool() != originalFields[ CONTROLS_FIELD_INVERT_MOUSE ].ToBool() ) {
return true;
}
if ( fields[ CONTROLS_FIELD_MOUSE_SENS ].ToFloat() != originalFields[ CONTROLS_FIELD_MOUSE_SENS ].ToFloat() ) {
return true;
}
if ( fields[ CONTROLS_FIELD_GAMEPAD_ENABLED ].ToFloat() != originalFields[ CONTROLS_FIELD_GAMEPAD_ENABLED ].ToFloat() ) {
return true;
}
return false;
}

View File

@@ -0,0 +1,934 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 NUM_CREDIT_LINES = 16;
void idMenuScreen_Shell_Credits::SetupCreditList() {
class idRefreshCredits : public idSWFScriptFunction_RefCounted {
public:
idRefreshCredits( idMenuScreen_Shell_Credits * _screen ) :
screen( _screen ) {
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( screen == NULL ) {
return idSWFScriptVar();
}
screen->UpdateCredits();
return idSWFScriptVar();
}
private:
idMenuScreen_Shell_Credits * screen;
};
if ( GetSWFObject() ) {
GetSWFObject()->SetGlobal( "updateCredits", new ( TAG_SWF ) idRefreshCredits( this ) );
}
creditList.Clear();
creditList.Append( creditInfo_t( 3, "DOOM 3 BFG EDITION" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 2, "DEVELOPMENT TEAM" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Executive Producer" ) );
creditList.Append( creditInfo_t( 0, "Eric Webb" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Lead Programmer" ) );
creditList.Append( creditInfo_t( 0, "Brian Harris" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Lead Designer" ) );
creditList.Append( creditInfo_t( 0, "Jerry Keehan" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Programming" ) );
creditList.Append( creditInfo_t( 0, "Curtis Arink" ) );
creditList.Append( creditInfo_t( 0, "Robert Duffy" ) );
creditList.Append( creditInfo_t( 0, "Jeff Farrand" ) );
creditList.Append( creditInfo_t( 0, "Ryan Gerleve" ) );
creditList.Append( creditInfo_t( 0, "Billy Khan" ) );
creditList.Append( creditInfo_t( 0, "Gloria Kennickell" ) );
creditList.Append( creditInfo_t( 0, "Mike Maynard" ) );
creditList.Append( creditInfo_t( 0, "John Roberts" ) );
creditList.Append( creditInfo_t( 0, "Steven Serafin" ) );
creditList.Append( creditInfo_t( 0, "Jan Paul Van Waveren" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Design" ) );
creditList.Append( creditInfo_t( 0, "Steve Rescoe" ) );
creditList.Append( creditInfo_t( 0, "Chris Voss" ) );
creditList.Append( creditInfo_t( 0, "David Vargo" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Art" ) );
creditList.Append( creditInfo_t( 0, "Kevin Cloud" ) );
creditList.Append( creditInfo_t( 0, "Andy Chang" ) );
creditList.Append( creditInfo_t( 0, "Pat Duffy" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Audio" ) );
creditList.Append( creditInfo_t( 0, "Christian Antkow" ) );
creditList.Append( creditInfo_t( 0, "Chris Hite" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional Support" ) );
creditList.Append( creditInfo_t( 0, "Roger Berrones" ) );
creditList.Append( creditInfo_t( 0, "Brad Bramlett" ) );
creditList.Append( creditInfo_t( 0, "John Casey" ) );
creditList.Append( creditInfo_t( 0, "Jeremy Cook" ) );
creditList.Append( creditInfo_t( 0, "Chris Hays" ) );
creditList.Append( creditInfo_t( 0, "Matt Hooper" ) );
creditList.Append( creditInfo_t( 0, "Danny Keys" ) );
creditList.Append( creditInfo_t( 0, "Jason Kim" ) );
creditList.Append( creditInfo_t( 0, "Brian Kowalczyk" ) );
creditList.Append( creditInfo_t( 0, "Dustin Land" ) );
creditList.Append( creditInfo_t( 0, "Stephane Lebrun" ) );
creditList.Append( creditInfo_t( 0, "Matt Nelson" ) );
creditList.Append( creditInfo_t( 0, "John Pollard" ) );
creditList.Append( creditInfo_t( 0, "Alan Rogers" ) );
creditList.Append( creditInfo_t( 0, "Jah Raphael" ) );
creditList.Append( creditInfo_t( 0, "Jarrod Showers" ) );
creditList.Append( creditInfo_t( 0, "Shale Williams" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Studio Director" ) );
creditList.Append( creditInfo_t( 0, "Tim Willits" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Studio President" ) );
creditList.Append( creditInfo_t( 0, "Todd Hollenshead" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Technical Director" ) );
creditList.Append( creditInfo_t( 0, "John Carmack" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Human Resources" ) );
creditList.Append( creditInfo_t( 0, "Carrie Barcroft" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "id Mom" ) );
creditList.Append( creditInfo_t( 0, "Donna Jackson" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "id Software IT" ) );
creditList.Append( creditInfo_t( 0, "Duncan Welch" ) );
creditList.Append( creditInfo_t( 0, "Michael Cave" ) );
creditList.Append( creditInfo_t( 0, "Josh Shoemate" ) );
creditList.Append( creditInfo_t( 0, "Michael Musick" ) );
creditList.Append( creditInfo_t( 0, "Alex Brandt" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "DOOM 3 DEVELOPED BY" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 2, "id Software" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Technical Director " ) );
creditList.Append( creditInfo_t( 0, "John Carmack" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Lead Programmer" ) );
creditList.Append( creditInfo_t( 0, "Robert A. Duffy" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Lead Designer" ) );
creditList.Append( creditInfo_t( 0, "Tim Willits" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Lead Artist" ) );
creditList.Append( creditInfo_t( 0, "Kenneth Scott" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Animation" ) );
creditList.Append( creditInfo_t( 0, "James Houska" ) );
creditList.Append( creditInfo_t( 0, "Fredrik Nilsson" ) );
creditList.Append( creditInfo_t( 0, "Eric Webb" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Art" ) );
creditList.Append( creditInfo_t( 0, "Adrian Carmack" ) );
creditList.Append( creditInfo_t( 0, "Andy Chang" ) );
creditList.Append( creditInfo_t( 0, "Kevin Cloud" ) );
creditList.Append( creditInfo_t( 0, "Seneca Menard" ) );
creditList.Append( creditInfo_t( 0, "Patrick Thomas" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Design" ) );
creditList.Append( creditInfo_t( 0, "Mal Blackwell" ) );
creditList.Append( creditInfo_t( 0, "Matt Hooper" ) );
creditList.Append( creditInfo_t( 0, "Jerry Keehan" ) );
creditList.Append( creditInfo_t( 0, "Steve Rescoe" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "UI Artist" ) );
creditList.Append( creditInfo_t( 0, "Pat Duffy" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Programming" ) );
creditList.Append( creditInfo_t( 0, "Timothee Besset" ) );
creditList.Append( creditInfo_t( 0, "Jim Dose" ) );
creditList.Append( creditInfo_t( 0, "Jan Paul van Waveren" ) );
creditList.Append( creditInfo_t( 0, "Jonathan Wright" ) );
creditList.Append( creditInfo_t( 0, "Brian Harris" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sound Design " ) );
creditList.Append( creditInfo_t( 0, "Christian Antkow" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Dir. Business Development" ) );
creditList.Append( creditInfo_t( 0, "Marty Stratton" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Development Assistant" ) );
creditList.Append( creditInfo_t( 0, "Eric Webb" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 2, "3rd PARTY" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "DOOM 3: Ressurection of Evil Developed by" ) );
creditList.Append( creditInfo_t( 0, "Nerve Software" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional Sound Design" ) );
creditList.Append( creditInfo_t( 0, "Ed Lima" ) );
creditList.Append( creditInfo_t( 0, "Danetracks, Inc." ) );
creditList.Append( creditInfo_t( 0, "Defacto Sound" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Theme for DOOM 3 Produced by" ) );
creditList.Append( creditInfo_t( 0, "Chris Vrenna" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Theme for DOOM 3 Composed by" ) );
creditList.Append( creditInfo_t( 0, "Clint Walsh" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional Story and Dialog" ) );
creditList.Append( creditInfo_t( 0, "Matthew J. Costello" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Casting and Voice Direction" ) );
creditList.Append( creditInfo_t( 0, "Margaret Tang - Womb Music" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Voice Editorial and Post" ) );
creditList.Append( creditInfo_t( 0, "Rik Schaffer - Womb Music" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Voice Recording" ) );
creditList.Append( creditInfo_t( 0, "Womb Music" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Voice Performers" ) );
creditList.Append( creditInfo_t( 0, "Paul Eiding" ) );
creditList.Append( creditInfo_t( 0, "Jim Cummings" ) );
creditList.Append( creditInfo_t( 0, "Liam O'Brien" ) );
creditList.Append( creditInfo_t( 0, "Nicholas Guest" ) );
creditList.Append( creditInfo_t( 0, "Vanessa Marshall" ) );
creditList.Append( creditInfo_t( 0, "Neill Ross" ) );
creditList.Append( creditInfo_t( 0, "Phillip Clarke" ) );
creditList.Append( creditInfo_t( 0, "Andy Chanley" ) );
creditList.Append( creditInfo_t( 0, "Charles Dennis" ) );
creditList.Append( creditInfo_t( 0, "Grey Delisle" ) );
creditList.Append( creditInfo_t( 0, "Jennifer Hale" ) );
creditList.Append( creditInfo_t( 0, "Grant Albrecht" ) );
creditList.Append( creditInfo_t( 0, "Dee Baker" ) );
creditList.Append( creditInfo_t( 0, "Michael Bell" ) );
creditList.Append( creditInfo_t( 0, "Steve Blum" ) );
creditList.Append( creditInfo_t( 0, "S. Scott Bullock" ) );
creditList.Append( creditInfo_t( 0, "Cam Clarke" ) );
creditList.Append( creditInfo_t( 0, "Robin Atkin Downes" ) );
creditList.Append( creditInfo_t( 0, "Keith Ferguson" ) );
creditList.Append( creditInfo_t( 0, "Jay Gordon" ) );
creditList.Append( creditInfo_t( 0, "Michael Gough" ) );
creditList.Append( creditInfo_t( 0, "Bill Harper" ) );
creditList.Append( creditInfo_t( 0, "Nick Jameson" ) );
creditList.Append( creditInfo_t( 0, "David Kaye" ) );
creditList.Append( creditInfo_t( 0, "Phil La Marr" ) );
creditList.Append( creditInfo_t( 0, "Scott Menville" ) );
creditList.Append( creditInfo_t( 0, "Jim Meskimen" ) );
creditList.Append( creditInfo_t( 0, "Matt Morton" ) );
creditList.Append( creditInfo_t( 0, "Daran Norris" ) );
creditList.Append( creditInfo_t( 0, "Rob Paulsen" ) );
creditList.Append( creditInfo_t( 0, "Phil Proctor" ) );
creditList.Append( creditInfo_t( 0, "Rino Romoano" ) );
creditList.Append( creditInfo_t( 0, "Andre Sogliuzzo" ) );
creditList.Append( creditInfo_t( 0, "Jim Ward" ) );
creditList.Append( creditInfo_t( 0, "Wally Wingert" ) );
creditList.Append( creditInfo_t( 0, "Edward Yin" ) );
creditList.Append( creditInfo_t( 0, "Keone Young" ) );
creditList.Append( creditInfo_t( 0, "Ryun Yu" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional User Interface" ) );
creditList.Append( creditInfo_t( 0, "Double-Action Design" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Motion Capture Services" ) );
creditList.Append( creditInfo_t( 0, "Janimation" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "UAC Promotional Videos" ) );
creditList.Append( creditInfo_t( 0, "Six Foot Studios" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional Multiplayer Design" ) );
creditList.Append( creditInfo_t( 0, "Splash Damage, Ltd." ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional Programming" ) );
creditList.Append( creditInfo_t( 0, "Graeme Devine" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Localization Services" ) );
creditList.Append( creditInfo_t( 0, "Synthesis" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "BETHESDA SOFTWORKS" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Senior Producer" ) );
creditList.Append( creditInfo_t( 0, "Laffy Taylor" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sr. Producer, Submissions" ) );
creditList.Append( creditInfo_t( 0, "Timothy Beggs" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "VP, Product Development" ) );
creditList.Append( creditInfo_t( 0, "Todd Vaughn" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "External Technical Director" ) );
creditList.Append( creditInfo_t( 0, "Jonathan Williams" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "President" ) );
creditList.Append( creditInfo_t( 0, "Vlatko Andonov" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "VP, Public Relations and Marketing" ) );
creditList.Append( creditInfo_t( 0, "Pete Hines" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Director of Global Marketing" ) );
creditList.Append( creditInfo_t( 0, "Steve Perkins" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Director of Global PR" ) );
creditList.Append( creditInfo_t( 0, "Tracey Thompson" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Senior Brand Manager" ) );
creditList.Append( creditInfo_t( 0, "Rakhi Gupta" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Associate Brand Manager" ) );
creditList.Append( creditInfo_t( 0, "David Clayman" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Event and Trade Show Director" ) );
creditList.Append( creditInfo_t( 0, "Henry Mobley" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Senior Community Manager" ) );
creditList.Append( creditInfo_t( 0, "Matthew Grandstaff" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Community Manager" ) );
creditList.Append( creditInfo_t( 0, "Nick Breckon" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Senior PR Coordinator" ) );
creditList.Append( creditInfo_t( 0, "Angela Ramsey-Chapman" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Marketing Assistant" ) );
creditList.Append( creditInfo_t( 0, "Jenny McWhorter" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Video Production" ) );
creditList.Append( creditInfo_t( 0, "Matt Killmon" ) );
creditList.Append( creditInfo_t( 0, "Sal Goldenburg" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Graphic Design" ) );
creditList.Append( creditInfo_t( 0, "Michael Wagner" ) );
creditList.Append( creditInfo_t( 0, "Lindsay Westcott" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "VP, Sales" ) );
creditList.Append( creditInfo_t( 0, "Ron Seger" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Operations Director" ) );
creditList.Append( creditInfo_t( 0, "Todd Curtis" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales and Operations Manager" ) );
creditList.Append( creditInfo_t( 0, "Jill Bralove" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Account Manager" ) );
creditList.Append( creditInfo_t( 0, "Michelle Ferrara" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Regional Sales Manager" ) );
creditList.Append( creditInfo_t( 0, "Michael Donnellan" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Channel Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Michelle Burgess" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Assistants" ) );
creditList.Append( creditInfo_t( 0, "Sara Simpson" ) );
creditList.Append( creditInfo_t( 0, "Jason Snead" ) );
creditList.Append( creditInfo_t( 0, "Jessica Williams" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Operations Assistant" ) );
creditList.Append( creditInfo_t( 0, "Scott Mills" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Director of Quality Assurance" ) );
creditList.Append( creditInfo_t( 0, "Darren Manes" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Quality Assurance Manager" ) );
creditList.Append( creditInfo_t( 0, "Rob Gray" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Quality Assurance Leads" ) );
creditList.Append( creditInfo_t( 0, "Terry Dunn" ) );
creditList.Append( creditInfo_t( 0, "Matt Weil" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Quality Assurance" ) );
creditList.Append( creditInfo_t( 0, "Dan Silva" ) );
creditList.Append( creditInfo_t( 0, "Alan Webb" ) );
creditList.Append( creditInfo_t( 0, "Cory Andrews" ) );
creditList.Append( creditInfo_t( 0, "George Churchill" ) );
creditList.Append( creditInfo_t( 0, "Jonathan DeVriendt" ) );
creditList.Append( creditInfo_t( 0, "Spencer Gottlieb" ) );
creditList.Append( creditInfo_t( 0, "Gary Powell" ) );
creditList.Append( creditInfo_t( 0, "Samuel Papke" ) );
creditList.Append( creditInfo_t( 0, "Amanda Sheehan" ) );
creditList.Append( creditInfo_t( 0, "Philip Spangrud" ) );
creditList.Append( creditInfo_t( 0, "Larry Waldman" ) );
creditList.Append( creditInfo_t( 0, "Donald Anderson" ) );
creditList.Append( creditInfo_t( 0, "James Audet" ) );
creditList.Append( creditInfo_t( 0, "Hunter Calvert" ) );
creditList.Append( creditInfo_t( 0, "Max Cameron" ) );
creditList.Append( creditInfo_t( 0, "Donald Harris" ) );
creditList.Append( creditInfo_t( 0, "Peter Garcia" ) );
creditList.Append( creditInfo_t( 0, "Joseph Lopatta" ) );
creditList.Append( creditInfo_t( 0, "Scott LoPresti" ) );
creditList.Append( creditInfo_t( 0, "Collin Mackett" ) );
creditList.Append( creditInfo_t( 0, "Gerard Nagy" ) );
creditList.Append( creditInfo_t( 0, "William Pegus" ) );
creditList.Append( creditInfo_t( 0, "Angela Rupinen" ) );
creditList.Append( creditInfo_t( 0, "Gabriel Scaringello" ) );
creditList.Append( creditInfo_t( 0, "Drew Slotkin" ) );
creditList.Append( creditInfo_t( 0, "Kyle Wallace" ) );
creditList.Append( creditInfo_t( 0, "Patrick Walsh" ) );
creditList.Append( creditInfo_t( 0, "John Welkner" ) );
creditList.Append( creditInfo_t( 0, "Jason Wilkin" ) );
creditList.Append( creditInfo_t( 0, "John Benoit" ) );
creditList.Append( creditInfo_t( 0, "Jacob Clayman" ) );
creditList.Append( creditInfo_t( 0, "Colin McInerney" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Additional QA" ) );
creditList.Append( creditInfo_t( 0, "James Costantino" ) );
creditList.Append( creditInfo_t( 0, "Chris Krietz" ) );
creditList.Append( creditInfo_t( 0, "Joseph Mueller" ) );
creditList.Append( creditInfo_t( 0, "Andrew Scharf" ) );
creditList.Append( creditInfo_t( 0, "Jen Tonon" ) );
creditList.Append( creditInfo_t( 0, "Justin McSweeney" ) );
creditList.Append( creditInfo_t( 0, "Sean Palomino" ) );
creditList.Append( creditInfo_t( 0, "Erica Stead" ) );
creditList.Append( creditInfo_t( 0, "Wil Cookman" ) );
creditList.Append( creditInfo_t( 0, "Garrett Hohl" ) );
creditList.Append( creditInfo_t( 0, "Tim Hartgrave" ) );
creditList.Append( creditInfo_t( 0, "Heath Hollenshead" ) );
creditList.Append( creditInfo_t( 0, "Brandon Korbel" ) );
creditList.Append( creditInfo_t( 0, "Daniel Korecki" ) );
creditList.Append( creditInfo_t( 0, "Max Morrison" ) );
creditList.Append( creditInfo_t( 0, "Doug Ransley" ) );
creditList.Append( creditInfo_t( 0, "Mauricio Rivera" ) );
creditList.Append( creditInfo_t( 0, "Aaron Walsh" ) );
creditList.Append( creditInfo_t( 0, "Daniel Wathen" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Special Thanks" ) );
creditList.Append( creditInfo_t( 0, "Jason Bergman" ) );
creditList.Append( creditInfo_t( 0, "Darren Chukitus" ) );
creditList.Append( creditInfo_t( 0, "Matt Dickenson" ) );
creditList.Append( creditInfo_t( 0, "Will Noble" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX MEDIA" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Chairman & CEO" ) );
creditList.Append( creditInfo_t( 0, "Robert Altman" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "President" ) );
creditList.Append( creditInfo_t( 0, "Ernie Del" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "EVP & COO" ) );
creditList.Append( creditInfo_t( 0, "Jamie Leder" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "EVP & CFO" ) );
creditList.Append( creditInfo_t( 0, "Cindy Tallent" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "EVP Legal & Secretary" ) );
creditList.Append( creditInfo_t( 0, "Grif Lesher" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "SVP Finance & Controller" ) );
creditList.Append( creditInfo_t( 0, "Denise Kidd" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Legal Lead" ) );
creditList.Append( creditInfo_t( 0, "Joshua Gillespie" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Legal" ) );
creditList.Append( creditInfo_t( 0, "Diana Bender" ) );
creditList.Append( creditInfo_t( 0, "Adam Carter" ) );
creditList.Append( creditInfo_t( 0, "Candice Garner-Groves" ) );
creditList.Append( creditInfo_t( 0, "Marcia Mitnick" ) );
creditList.Append( creditInfo_t( 0, "Amy Yeung" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "VP, Information Technology" ) );
creditList.Append( creditInfo_t( 0, "Steve Bloom" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Information Technology" ) );
creditList.Append( creditInfo_t( 0, "Rob Havlovick" ) );
creditList.Append( creditInfo_t( 0, "Nicholas Lea" ) );
creditList.Append( creditInfo_t( 0, "Drew McCartney" ) );
creditList.Append( creditInfo_t( 0, "Josh Mosby" ) );
creditList.Append( creditInfo_t( 0, "Joseph Owens" ) );
creditList.Append( creditInfo_t( 0, "Paul Tuttle" ) );
creditList.Append( creditInfo_t( 0, "Keelian Wardle" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Director of Global HR" ) );
creditList.Append( creditInfo_t( 0, "Tammy Boyd-Shumway" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Human Resources" ) );
creditList.Append( creditInfo_t( 0, "Michelle Cool" ) );
creditList.Append( creditInfo_t( 0, "Andrea Glinski" ) );
creditList.Append( creditInfo_t( 0, "Katrina Lang" ) );
creditList.Append( creditInfo_t( 0, "Valery Ridore" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Administration" ) );
creditList.Append( creditInfo_t( 0, "Melissa Ayala" ) );
creditList.Append( creditInfo_t( 0, "Brittany Bezawada-Joseph" ) );
creditList.Append( creditInfo_t( 0, "Rosanna Campanile " ) );
creditList.Append( creditInfo_t( 0, "Katherine Edwards" ) );
creditList.Append( creditInfo_t( 0, "Douglas Fredrick " ) );
creditList.Append( creditInfo_t( 0, "Jon Freund" ) );
creditList.Append( creditInfo_t( 0, "Ken Garcia " ) );
creditList.Append( creditInfo_t( 0, "Gerard Garnica" ) );
creditList.Append( creditInfo_t( 0, "Betty Kouatelay" ) );
creditList.Append( creditInfo_t( 0, "Ho Joong Lee" ) );
creditList.Append( creditInfo_t( 0, "Barb Manning" ) );
creditList.Append( creditInfo_t( 0, "Stephane Marquis" ) );
creditList.Append( creditInfo_t( 0, "Michael Masciola" ) );
creditList.Append( creditInfo_t( 0, "Tanuja Mistry" ) );
creditList.Append( creditInfo_t( 0, "Rissa Monzano" ) );
creditList.Append( creditInfo_t( 0, "Patrick Nolan " ) );
creditList.Append( creditInfo_t( 0, "Patti Pulupa" ) );
creditList.Append( creditInfo_t( 0, "Dave Rasmussen " ) );
creditList.Append( creditInfo_t( 0, "Heather Spurrier" ) );
creditList.Append( creditInfo_t( 0, "Claudia Umana" ) );
creditList.Append( creditInfo_t( 0, "Melissa Washabaugh" ) );
creditList.Append( creditInfo_t( 0, "Eric Weis" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Administrative Assistants" ) );
creditList.Append( creditInfo_t( 0, "Bernice Guice" ) );
creditList.Append( creditInfo_t( 0, "Paula Kasey" ) );
creditList.Append( creditInfo_t( 0, "Shana Reed" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Executive Chef" ) );
creditList.Append( creditInfo_t( 0, "Kenny McDonald" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX EUROPE" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Managing Director" ) );
creditList.Append( creditInfo_t( 0, "Sean Brennan" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Marketing & PR Director" ) );
creditList.Append( creditInfo_t( 0, "Sarah Seaby" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Sales Director" ) );
creditList.Append( creditInfo_t( 0, "Paul Oughton" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Director" ) );
creditList.Append( creditInfo_t( 0, "Greg Baverstock" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Finance Director" ) );
creditList.Append( creditInfo_t( 0, "Robert Ford" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Brand Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Thach Quach" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Brand Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Alex Price" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European PR Manager" ) );
creditList.Append( creditInfo_t( 0, "Alistair Hatch" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "European Assistant PR Manager" ) );
creditList.Append( creditInfo_t( 0, "Nicholas Heller" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "International Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Rosemarie Dalton" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Manager Trade Shows/Events" ) );
creditList.Append( creditInfo_t( 0, "Gareth Swann" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "UK Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Gregory Weller" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "UK Sales Manager" ) );
creditList.Append( creditInfo_t( 0, "Gethyn Deakins" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Creative Services Artist" ) );
creditList.Append( creditInfo_t( 0, "Morgan Gibbons" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Legal Counsel" ) );
creditList.Append( creditInfo_t( 0, "Adam Carter" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Localisation Director" ) );
creditList.Append( creditInfo_t( 0, "Harald Simon" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Localisation Project Manager" ) );
creditList.Append( creditInfo_t( 0, "Ruth Granados Garcia" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Administrator" ) );
creditList.Append( creditInfo_t( 0, "Heather Clarke" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Operations Manager" ) );
creditList.Append( creditInfo_t( 0, "Isabelle Midrouillet" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Operations Coordinator" ) );
creditList.Append( creditInfo_t( 0, "David Gordon" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Financial Controller" ) );
creditList.Append( creditInfo_t( 0, "Paul New" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Accounts Assistant" ) );
creditList.Append( creditInfo_t( 0, "Charlotte Ovens" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Contracts Administrator/Paralegal" ) );
creditList.Append( creditInfo_t( 0, "Katie Brooks" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "IT Manager" ) );
creditList.Append( creditInfo_t( 0, "Joseph Owens" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Office Manager" ) );
creditList.Append( creditInfo_t( 0, "Angela Clement" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX FRANCE" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "General Manager" ) );
creditList.Append( creditInfo_t( 0, "Julie Chalmette" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Manager" ) );
creditList.Append( creditInfo_t( 0, "Yvan Rault" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Key Account Manager" ) );
creditList.Append( creditInfo_t( 0, "Gaelle Gombert" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Trade Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Laurent Chatain" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Geraldine Mazot" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "PR Manager" ) );
creditList.Append( creditInfo_t( 0, "Jerome Firon" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Finance Manager" ) );
creditList.Append( creditInfo_t( 0, "Cecile De Freitas" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Finance Assistant" ) );
creditList.Append( creditInfo_t( 0, "Adeline Nonis" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX GERMANY" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Managing Director" ) );
creditList.Append( creditInfo_t( 0, "Frank Matzke" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Director" ) );
creditList.Append( creditInfo_t( 0, "Thomas Huber" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Head of Marketing & PR" ) );
creditList.Append( creditInfo_t( 0, "Marcel Jung" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Product Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Stefan Dettmering" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "PR Manager" ) );
creditList.Append( creditInfo_t( 0, "Peter Langhofer" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Trade Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Andrea Reuth" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Key Account Manager" ) );
creditList.Append( creditInfo_t( 0, "Juergen Pahl" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Finance Manager" ) );
creditList.Append( creditInfo_t( 0, "Joern Hoehling" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales and Office Administrator" ) );
creditList.Append( creditInfo_t( 0, "Christiane Jauss" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX BENELUX" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "General Manager" ) );
creditList.Append( creditInfo_t( 0, "Menno Eijck" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Manager" ) );
creditList.Append( creditInfo_t( 0, "Stefan Koppers" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Marketing Manager" ) );
creditList.Append( creditInfo_t( 0, "Jurgen Stirnweis" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "PR Manager" ) );
creditList.Append( creditInfo_t( 0, "Maikel van Dijk" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales and Marketing Administrator" ) );
creditList.Append( creditInfo_t( 0, "Pam van Griethuysen" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 3, "ZENIMAX ASIA" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "General Manager" ) );
creditList.Append( creditInfo_t( 0, "Tetsu Takahashi" ) );
creditList.Append( creditInfo_t());
creditList.Append( creditInfo_t( 1, "Localization Producer " ) );
creditList.Append( creditInfo_t( 0, "Kei Iwamoto" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Associate Producer " ) );
creditList.Append( creditInfo_t( 0, "Takayuki Tanaka" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Product Manager " ) );
creditList.Append( creditInfo_t( 0, "Seigen Ko" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Localization Programmer" ) );
creditList.Append( creditInfo_t( 0, "Masayuki Nagahashi" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Marketing and PR Manager " ) );
creditList.Append( creditInfo_t( 0, "Eiichi Yaji" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Sales Manager" ) );
creditList.Append( creditInfo_t( 0, "Hiroaki Yanagiguchi" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Office Manager" ) );
creditList.Append( creditInfo_t( 0, "Myongsuk Rim" ) );
creditList.Append( creditInfo_t() );
creditList.Append( creditInfo_t( 1, "Web Director" ) );
creditList.Append( creditInfo_t( 0, "Tanaka Keisuke" ) );
creditList.Append( creditInfo_t( 0, "Kosuke Fujita" ) );
};
/*
========================
idMenuScreen_Shell_Credits::Initialize
========================
*/
void idMenuScreen_Shell_Credits::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuCredits" );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_02305" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
SetupCreditList();
}
/*
========================
idMenuScreen_Shell_Credits::Update
========================
*/
void idMenuScreen_Shell_Credits::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
bool complete = false;
if ( shell != NULL ) {
complete = shell->GetGameComplete();
}
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
if ( !complete ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
} else {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_continue";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
}
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02218" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Credits::ShowScreen
========================
*/
void idMenuScreen_Shell_Credits::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( menuData != NULL ) {
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
bool complete = false;
if ( shell != NULL ) {
complete = shell->GetGameComplete();
}
if ( complete ) {
menuData->PlaySound( GUI_SOUND_MUSIC );
}
}
idMenuScreen::ShowScreen( transitionType );
creditIndex = 0;
UpdateCredits();
}
/*
========================
idMenuScreen_Shell_Credits::HideScreen
========================
*/
void idMenuScreen_Shell_Credits::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Credits::HandleAction
========================
*/
bool idMenuScreen_Shell_Credits::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_CREDITS ) {
return false;
}
widgetAction_t actionType = action.GetType();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
bool complete = false;
if ( shell != NULL ) {
complete = shell->GetGameComplete();
}
if ( complete ) {
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );
} else {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_Shell_Credits::UpdateCredits
========================
*/
void idMenuScreen_Shell_Credits::UpdateCredits() {
if ( menuData == NULL || GetSWFObject() == NULL ) {
return;
}
if ( menuData->ActiveScreen() != SHELL_AREA_CREDITS && menuData->NextScreen() != SHELL_AREA_CREDITS ) {
return;
}
if ( creditIndex >= creditList.Num() + NUM_CREDIT_LINES ) {
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
bool complete = false;
if ( shell != NULL ) {
complete = shell->GetGameComplete();
}
if ( complete ) {
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "disconnect" );
} else {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
}
return;
}
idSWFScriptObject * options = GetSWFObject()->GetRootObject().GetNestedObj( "menuCredits", "info", "options" );
if ( options != NULL ) {
for ( int i = 15; i >= 0; --i ) {
int curIndex = creditIndex - i;
idSWFTextInstance * heading = options->GetNestedText( va( "item%d", 15 - i ), "heading" );
idSWFTextInstance * subHeading = options->GetNestedText( va( "item%d", 15 - i ), "subHeading" );
idSWFTextInstance * title = options->GetNestedText( va( "item%d", 15 - i ), "title" );
idSWFTextInstance * txtEntry = options->GetNestedText( va( "item%d", 15 - i ), "entry" );
if ( curIndex >= 0 && curIndex < creditList.Num() ) {
int type = creditList[ curIndex ].type;
idStr entry = creditList[ curIndex ].entry;
if ( heading ) {
heading->SetText( type == 3 ? entry : "" );
heading->SetStrokeInfo( true );
}
if ( subHeading ) {
subHeading->SetText( type == 2 ? entry : "" );
subHeading->SetStrokeInfo( true );
}
if ( title ) {
title->SetText( type == 1 ? entry : "" );
title->SetStrokeInfo( true );
}
if ( txtEntry ) {
txtEntry->SetText( type == 0 ? entry : "" );
txtEntry->SetStrokeInfo( true );
}
} else {
if ( heading ) {
heading->SetText( "" );
}
if ( subHeading ) {
subHeading->SetText( "" );
}
if ( txtEntry ) {
txtEntry->SetText( "" );
}
if ( title ) {
title->SetText( "" );
}
}
}
if ( options->GetSprite() ) {
options->GetSprite()->PlayFrame( "roll" );
}
}
creditIndex++;
}

View File

@@ -0,0 +1,268 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_DEV_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_Dev::Initialize
========================
*/
void idMenuScreen_Shell_Dev::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuSettings" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_DEV_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_DEV_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "MAIN MENU" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
SetupDevOptions();
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Dev::SetupDevOptions
========================
*/
void idMenuScreen_Shell_Dev::SetupDevOptions() {
devOptions.Clear();
devOptions.Append( devOption_t( "game/mars_city1", "Mars City 1" ) );
devOptions.Append( devOption_t( "game/mc_underground", "MC Underground" ) );
devOptions.Append( devOption_t( "game/mars_city2", "Mars City 2" ) );
devOptions.Append( devOption_t( "game/admin", "Admin" ) );
devOptions.Append( devOption_t( "game/alphalabs1", "Alpha Labs 1" ) );
devOptions.Append( devOption_t( "game/alphalabs2", "Alpha Labs 2" ) );
devOptions.Append( devOption_t( "game/alphalabs3", "Alpha Labs 3" ) );
devOptions.Append( devOption_t( "game/alphalabs4", "Alpha Labs 4" ) );
devOptions.Append( devOption_t( "game/enpro", "Enpro" ) );
devOptions.Append( devOption_t( "game/commoutside", "Comm outside" ) );
devOptions.Append( devOption_t( "game/comm1", "Comm 1" ) );
devOptions.Append( devOption_t( "game/recycling1", "Recycling 1" ) );
devOptions.Append( devOption_t( "game/recycling2", "Recycling 2" ) );
devOptions.Append( devOption_t( "game/monorail", "Monorail" ) );
devOptions.Append( devOption_t( "game/delta1", "Delta Labs 1" ) );
devOptions.Append( devOption_t( "game/delta2a", "Delta Labs 2a" ) );
devOptions.Append( devOption_t( "game/delta2b", "Delta Labs 2b" ) );
devOptions.Append( devOption_t( "game/delta3", "Delta Labs 3" ) );
devOptions.Append( devOption_t( "game/delta4", "Delta Labs 4" ) );
devOptions.Append( devOption_t( "game/hell1", "Hell 1" ) );
devOptions.Append( devOption_t( "game/delta5", "Delta Labs 5" ) );
devOptions.Append( devOption_t( "game/cpu", "CPU" ) );
devOptions.Append( devOption_t( "game/cpuboss", "CPU Boss" ) );
devOptions.Append( devOption_t( "game/site3", "Site 3" ) );
devOptions.Append( devOption_t( "game/caverns1", "Caverns 1" ) );
devOptions.Append( devOption_t( "game/caverns2", "Caverns 2" ) );
devOptions.Append( devOption_t( "game/hellhole", "Hell Hole" ) );
devOptions.Append( devOption_t( NULL, "-DOOM 3 Expansion-" ) );
devOptions.Append( devOption_t( "game/erebus1", "Erebus 1" ) );
devOptions.Append( devOption_t( "game/erebus2", "Erebus 2" ) );
devOptions.Append( devOption_t( "game/erebus3", "Erebus 3" ) );
devOptions.Append( devOption_t( "game/erebus4", "Erebus 4" ) );
devOptions.Append( devOption_t( "game/erebus5", "Erebus 5" ) );
devOptions.Append( devOption_t( "game/erebus6", "Erebus 6" ) );
devOptions.Append( devOption_t( "game/phobos1", "Phobos 1" ) );
devOptions.Append( devOption_t( "game/phobos2", "Phobos 2" ) );
devOptions.Append( devOption_t( "game/phobos3", "Phobos 3" ) );
devOptions.Append( devOption_t( "game/phobos4", "Phobos 4" ) );
devOptions.Append( devOption_t( "game/deltax", "Delta X" ) );
devOptions.Append( devOption_t( "game/hell", "Hell" ) );
devOptions.Append( devOption_t( NULL, "-Lost Missions-" ) );
devOptions.Append( devOption_t( "game/le_enpro1", "Enpro 1" ) );
devOptions.Append( devOption_t( "game/le_enpro2", "Enpro 2" ) );
devOptions.Append( devOption_t( "game/le_underground", "Undeground" ) );
devOptions.Append( devOption_t( "game/le_underground2", "Undeground 2" ) );
devOptions.Append( devOption_t( "game/le_exis1", "Exis 1" ) );
devOptions.Append( devOption_t( "game/le_exis2", "Exis 2" ) );
devOptions.Append( devOption_t( "game/le_hell", "Hell" ) );
devOptions.Append( devOption_t( "game/le_hell_post", "Hell Post" ) );
devOptions.Append( devOption_t( NULL, "-Test Maps-" ) );
devOptions.Append( devOption_t( "game/pdas", "PDAs" ) );
devOptions.Append( devOption_t( "testmaps/test_box", "Box" ) );
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
for ( int i = 0; i < devOptions.Num(); ++i ) {
idList< idStr > option;
option.Append( devOptions[ i ].name );
menuOptions.Append( option );
}
options->SetListData( menuOptions );
}
/*
========================
idMenuScreen_Shell_Dev::Update
========================
*/
void idMenuScreen_Shell_Dev::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "DEV" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Dev::ShowScreen
========================
*/
void idMenuScreen_Shell_Dev::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Dev::HideScreen
========================
*/
void idMenuScreen_Shell_Dev::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Dev::HandleAction h
========================
*/
bool idMenuScreen_Shell_Dev::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_DEV ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options->GetFocusIndex() != selectionIndex - options->GetViewOffset() ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
int mapIndex = options->GetViewIndex();
if ( ( mapIndex < devOptions.Num() ) && ( devOptions[ mapIndex ].map != NULL ) ) {
cmdSystem->AppendCommandText( va( "devmap %s\n", devOptions[ mapIndex ].map ) );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,293 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SETTING_OPTIONS = 8;
extern idCVar g_nightmare;
extern idCVar g_roeNightmare;
extern idCVar g_leNightmare;
extern idCVar g_skill;
/*
========================
idMenuScreen_Shell_Difficulty::Initialize
========================
*/
void idMenuScreen_Shell_Difficulty::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuDifficulty" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
option.Append( "#str_04089" ); // Easy
menuOptions.Append( option );
option.Clear();
option.Append( "#str_04091" ); // Medium
menuOptions.Append( option );
option.Clear();
option.Append( "#str_04093" ); // Hard
menuOptions.Append( option );
option.Clear();
option.Append( "#str_02357" ); // Nightmare
menuOptions.Append( option );
options->SetListData( menuOptions );
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
const char * tips[] = { "#str_02358", "#str_02360", "#str_02362", "#str_02364" };
while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
if ( options->GetChildren().Num() < menuOptions.Num() ) {
buttonWidget->SetDescription( tips[options->GetChildren().Num()] );
}
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_02207" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER_VARIABLE, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Difficulty::Update
========================
*/
void idMenuScreen_Shell_Difficulty::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_04088" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Difficulty::ShowScreen
========================
*/
void idMenuScreen_Shell_Difficulty::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
nightmareUnlocked = false;
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
int type = 0;
if ( shell != NULL ) {
type = shell->GetNewGameType();
}
if ( type == 0 ) {
nightmareUnlocked = g_nightmare.GetBool();
} else if ( type == 1 ) {
nightmareUnlocked = g_roeNightmare.GetBool();
} else if ( type == 2 ) {
nightmareUnlocked = g_leNightmare.GetBool();
}
int skill = Max( 0, g_skill.GetInteger() );
if ( !nightmareUnlocked ) {
options->GetChildByIndex( 3 ).SetState( WIDGET_STATE_DISABLED );
skill = Min( skill, 2 );
} else {
options->GetChildByIndex( 3 ).SetState( WIDGET_STATE_NORMAL );
skill = Min( skill, 3 );
}
options->SetFocusIndex( skill );
options->SetViewIndex( options->GetViewOffset() + skill );
}
/*
========================
idMenuScreen_Shell_Difficulty::HideScreen
========================
*/
void idMenuScreen_Shell_Difficulty::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Difficulty::HandleAction h
========================
*/
bool idMenuScreen_Shell_Difficulty::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_DIFFICULTY ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_SCROLL_VERTICAL_VARIABLE: {
if ( parms.Num() == 0 ) {
return true;
}
if ( options == NULL ) {
return true;
}
int dir = parms[ 0 ].ToInteger();
int scroll = dir;
bool nightmareEnabled = nightmareUnlocked;
int curIndex = options->GetFocusIndex();
if ( ( curIndex + scroll < 0 && !nightmareEnabled ) || ( curIndex + scroll == 3 && !nightmareEnabled ) ) {
scroll *= 2;
options->Scroll( scroll, true );
} else {
options->Scroll( scroll );
}
return true;
}
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_NEW_GAME, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex == 3 && !nightmareUnlocked ) {
return true;
}
if ( options->GetFocusIndex() != selectionIndex ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
int type = 0;
if ( shell != NULL ) {
type = shell->GetNewGameType();
}
g_skill.SetInteger( selectionIndex );
idMenuHandler_Shell * shellMgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( shellMgr ) {
if ( type == 0 ) {
shellMgr->ShowDoomIntro();
} else if ( type == 1 ) {
shellMgr->ShowROEIntro();
} else if ( type == 2 ) {
shellMgr->ShowLEIntro();
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,706 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_LOBBY_OPTIONS = 8;
extern idCVar net_inviteOnly;
enum gameLobbyCmd_t {
GAME_CMD_START,
GAME_CMD_INVITE,
GAME_CMD_SETTINGS,
GAME_CMD_TOGGLE_PRIVACY,
};
/*
========================
idMenuScreen_Shell_GameLobby::Initialize
========================
*/
void idMenuScreen_Shell_GameLobby::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuGameLobby" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_LOBBY_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( options->GetChildren().Num() < NUM_LOBBY_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
lobby = new (TAG_SWF) idMenuWidget_LobbyList();
lobby->SetNumVisibleOptions( 8 );
lobby->SetSpritePath( GetSpritePath(), "options" );
lobby->SetWrappingAllowed( true );
lobby->Initialize( data );
while ( lobby->GetChildren().Num() < 8 ) {
idMenuWidget_LobbyButton * const buttonWidget = new (TAG_SWF) idMenuWidget_LobbyButton();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_GAMERTAG, lobby->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, lobby->GetChildren().Num() );
buttonWidget->Initialize( data );
lobby->AddChild( buttonWidget );
}
AddChild( lobby );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_multiplayer" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_GameLobby::Update
========================
*/
void idMenuScreen_Shell_GameLobby::Update() {
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
if ( lobby != NULL ) {
if ( activeLobby.GetNumActiveLobbyUsers() != 0 ) {
if ( lobby->GetFocusIndex() >= activeLobby.GetNumActiveLobbyUsers() ) {
lobby->SetFocusIndex( activeLobby.GetNumActiveLobbyUsers() - 1 );
lobby->SetViewIndex( lobby->GetViewOffset() + lobby->GetFocusIndex() );
}
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_multiplayer" ); // MULTIPLAYER
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( privateGameLobby && options != NULL ) {
if ( session->GetActivePlatformLobbyBase().IsHost() && !isHost ) {
menuOptions.Clear();
idList< idStr > option;
isHost = true;
isPeer = false;
option.Append( "#str_swf_start_match" ); // Start match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_match_settings" ); // Match Settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_only" ); // Toggle privacy
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
idMenuWidget_Button * buttonWidget = NULL;
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_START, 0 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_quick_start_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_SETTINGS, 1 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_match_setting_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_TOGGLE_PRIVACY, 2 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_toggle_privacy_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 3 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
index++;
options->SetListData( menuOptions );
} else if ( session->GetActivePlatformLobbyBase().IsPeer() ) {
if ( !isPeer ) {
menuOptions.Clear();
idList< idStr > option;
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
idMenuWidget_Button * buttonWidget = NULL;
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 0 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
options->SetListData( menuOptions );
}
isPeer = true;
isHost = false;
}
}
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_view_profile";
}
buttonInfo->action.Set( WIDGET_ACTION_SELECT_GAMERTAG );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
lobbyUserID_t luid;
if ( isHost && CanKickSelectedPlayer( luid ) ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
buttonInfo->label = "#str_swf_kick";
buttonInfo->action.Set( WIDGET_ACTION_JOY4_ON_PRESS );
}
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_GameLobby::ShowScreen
========================
*/
void idMenuScreen_Shell_GameLobby::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( options != NULL ) {
options->SetFocusIndex( 0 );
options->SetViewIndex( 0 );
}
isHost = false;
isPeer = false;
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
// Make sure map name is up to date.
if ( matchParameters.gameMap >= 0 ) {
matchParameters.mapName = common->GetMapList()[ matchParameters.gameMap ].mapFile;
}
privateGameLobby = MatchTypeIsPrivate( matchParameters.matchFlags );
if ( !privateGameLobby ) { // Public Game Lobby
menuOptions.Clear();
idList< idStr > option;
if ( options != NULL ) {
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
option.Clear();
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAME_CMD_INVITE, 0 );
idMenuWidget_Button * buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
options->SetListData( menuOptions );
}
longCountdown = Sys_Milliseconds() + WAIT_START_TIME_LONG;
longCountRemaining = longCountdown;
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFSpriteInstance * waitTime = GetSprite()->GetScriptObject()->GetNestedSprite( "waitTime" );
if ( waitTime != NULL ) {
waitTime->SetVisible( !privateGameLobby );
}
}
idMenuScreen::ShowScreen( transitionType );
if ( lobby != NULL ) {
lobby->SetFocusIndex( 0 );
}
session->UpdateMatchParms( matchParameters );
}
/*
========================
idMenuScreen_Shell_GameLobby::HideScreen
========================
*/
void idMenuScreen_Shell_GameLobby::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_GameLobby::CanKickSelectedPlayer
========================
*/
bool idMenuScreen_Shell_GameLobby::CanKickSelectedPlayer( lobbyUserID_t & luid ) {
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
const int playerId = lobby->GetFocusIndex();
// can't kick yourself
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
luid = activeLobby.GetLobbyUserIdByOrdinal( playerId );
if ( session->GetSignInManager().GetMasterLocalUser() == activeLobby.GetLocalUserFromLobbyUser( luid ) ) {
return false;
}
return true;
}
/*
========================
idMenuScreen_Shell_GameLobby::HandleAction h
========================
*/
bool idMenuScreen_Shell_GameLobby::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_GAME_LOBBY ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_JOY4_ON_PRESS: {
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
lobbyUserID_t luid;
if ( CanKickSelectedPlayer( luid ) ) {
activeLobby.KickLobbyUser( luid );
}
return true;
}
case WIDGET_ACTION_GO_BACK: {
class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Accept() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY );
session->Cancel();
return idSWFScriptVar();
}
};
class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Cancel() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY );
return idSWFScriptVar();
}
};
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
if( activeLobby.GetNumActiveLobbyUsers() > 1 ) {
common->Dialog().AddDialog( GDM_LEAVE_LOBBY_RET_NEW_PARTY, DIALOG_ACCEPT_CANCEL, new (TAG_SWF) idSWFScriptFunction_Accept(), new (TAG_SWF) idSWFScriptFunction_Cancel(), false );
} else {
session->Cancel();
}
return true;
}
case WIDGET_ACTION_MUTE_PLAYER: {
if ( parms.Num() != 1 ) {
return true;
}
int index = parms[0].ToInteger();
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( index );
if ( luid.IsValid() ) {
session->ToggleLobbyUserVoiceMute( luid );
}
return true;
}
case WIDGET_ACTION_COMMAND: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 1 ) {
selectionIndex = parms[1].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch ( parms[0].ToInteger() ) {
case GAME_CMD_START: {
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * const >( menuData );
if ( handler != NULL ) {
handler->SetTimeRemaining( 0 );
}
break;
}
case GAME_CMD_SETTINGS: {
menuData->SetNextScreen( SHELL_AREA_MATCH_SETTINGS, MENU_TRANSITION_SIMPLE );
break;
}
case GAME_CMD_TOGGLE_PRIVACY: {
idMatchParameters matchParameters = idMatchParameters( session->GetActivePlatformLobbyBase().GetMatchParms() );
matchParameters.matchFlags ^= MATCH_INVITE_ONLY;
session->UpdateMatchParms( matchParameters );
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
net_inviteOnly.SetBool( bitSet != 0 ? true : false );
// Must update the party parameters too for Xbox JSIP to work in game lobbies.
idMatchParameters partyParms = session->GetPartyLobbyBase().GetMatchParms();
if ( MatchTypeInviteOnly( matchParameters.matchFlags ) ) {
partyParms.matchFlags |= MATCH_INVITE_ONLY;
} else {
partyParms.matchFlags &= ~MATCH_INVITE_ONLY;
}
session->UpdatePartyParms( partyParms );
break;
}
case GAME_CMD_INVITE: {
if ( session->GetActivePlatformLobbyBase().IsLobbyFull() ) {
common->Dialog().AddDialog( GDM_CANNOT_INVITE_LOBBY_FULL, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
return true;
}
InvitePartyOrFriends();
break;
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
case WIDGET_ACTION_SELECT_GAMERTAG: {
int selectionIndex = lobby->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != lobby->GetFocusIndex() ) {
lobby->SetViewIndex( lobby->GetViewOffset() + selectionIndex );
lobby->SetFocusIndex( selectionIndex );
return true;
}
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( selectionIndex );
if ( luid.IsValid() ) {
session->ShowLobbyUserGamerCardUI( luid );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_Shell_GameLobby::UpdateLobby
========================
*/
void idMenuScreen_Shell_GameLobby::UpdateLobby() {
if ( menuData != NULL && menuData->ActiveScreen() != SHELL_AREA_GAME_LOBBY ) {
return;
}
// Keep this menu in sync with the session host/peer status.
if ( session->GetActivePlatformLobbyBase().IsHost() && !isHost ) {
Update();
}
if ( session->GetActivePlatformLobbyBase().IsPeer() && !isPeer ) {
Update();
}
if ( !privateGameLobby ) {
int ms = 0;
if ( session->GetActivePlatformLobbyBase().IsHost() ) {
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * const >( menuData );
if ( handler != NULL ) {
if ( session->GetActivePlatformLobbyBase().IsLobbyFull() ) {
longCountdown = Sys_Milliseconds() + longCountRemaining;
int timeRemaining = shortCountdown - Sys_Milliseconds();
if ( timeRemaining < 0 ) {
timeRemaining = 0;
}
ms = (int) ceilf( timeRemaining / 1000.0f );
handler->SetTimeRemaining( timeRemaining );
} else if ( session->GetActivePlatformLobbyBase().GetNumLobbyUsers() > 1 ) {
int timeRemaining = longCountdown - Sys_Milliseconds();
if ( timeRemaining > WAIT_START_TIME_SHORT ) {
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
} else {
shortCountdown = timeRemaining;
}
longCountRemaining = timeRemaining;
if ( timeRemaining < 0 ) {
timeRemaining = 0;
}
ms = (int) ceilf( timeRemaining / 1000.0f );
handler->SetTimeRemaining( timeRemaining );
} else {
ms = 0;
longCountdown = Sys_Milliseconds() + WAIT_START_TIME_LONG;
longCountRemaining = longCountdown;
shortCountdown = Sys_Milliseconds() + WAIT_START_TIME_SHORT;
handler->SetTimeRemaining( longCountRemaining );
}
}
} else {
if ( menuData != NULL ) {
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * const >( menuData );
if ( handler != NULL ) {
ms = (int) ceilf( handler->GetTimeRemaining() / 1000.0f );
}
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * waitTime = GetSprite()->GetScriptObject()->GetNestedText( "waitTime", "txtVal" );
if ( waitTime != NULL ) {
idStr status;
if ( ms == 1 ) {
status = idLocalization::GetString( "#str_online_game_starts_in_second" );
status.Replace( "<DNT_VAL>", idStr( ms ) );
waitTime->SetText( status );
} else if ( ms > 0 && ms < 30 ) {
status = idLocalization::GetString( "#str_online_game_starts_in_seconds" );
status.Replace( "<DNT_VAL>", idStr( ms ) );
waitTime->SetText( status );
} else {
waitTime->SetText( "" );
}
waitTime->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
Update();
} else {
if ( isPeer ) {
Update();
}
}
if ( session->GetState() == idSession::GAME_LOBBY ) {
if ( options != NULL ) {
if ( options->GetFocusIndex() >= options->GetTotalNumberOfOptions() && options->GetTotalNumberOfOptions() > 0 ) {
options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
options->SetFocusIndex( options->GetTotalNumberOfOptions() - 1 );
}
}
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
idSWFTextInstance * mapName = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtMapName" );
idSWFTextInstance * modeName = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtModeName" );
if ( mapName != NULL ){
const idList< mpMap_t > maps = common->GetMapList();
idStr name = idLocalization::GetString( maps[ idMath::ClampInt( 0, maps.Num() - 1, matchParameters.gameMap ) ].mapName );
mapName->SetText( name );
mapName->SetStrokeInfo( true );
}
if ( modeName != NULL ) {
const idStrList & modes = common->GetModeDisplayList();
idStr mode = idLocalization::GetString( modes[ idMath::ClampInt( 0, modes.Num() - 1, matchParameters.gameMode ) ] );
modeName->SetText( mode );
modeName->SetStrokeInfo( true );
}
idSWFTextInstance * privacy = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtPrivacy" );
if ( privacy != NULL ) {
if ( isPeer || !privateGameLobby ) {
privacy->SetText( "" );
} else {
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
bool privacySet = ( bitSet != 0 ? true : false );
if ( privacySet ) {
privacy->SetText( "#str_swf_privacy_closed" );
privacy->SetStrokeInfo( true );
} else if ( !privacySet ) {
privacy->SetText( "#str_swf_privacy_open" );
privacy->SetStrokeInfo( true );
}
}
}
idLocalUser * user = session->GetSignInManager().GetMasterLocalUser();
if ( user != NULL && options != NULL ) {
if ( user->IsInParty() && user->GetPartyCount() > 1 && !session->IsPlatformPartyInLobby() && menuOptions.Num() > 0 ) {
if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_xbox_live_party" ) {
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_xbox_live_party"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
} else if ( menuOptions.Num() > 0 ) {
if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_friends" ) {
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_friends"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
}
}
}
// setup names for lobby;
if ( lobby != NULL ) {
idMenuHandler_Shell * mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr != NULL ) {
mgr->UpdateLobby( lobby );
lobby->Update();
}
if ( lobby->GetNumEntries() > 0 && lobby->GetFocusIndex() >= lobby->GetNumEntries() ) {
lobby->SetFocusIndex( lobby->GetNumEntries() - 1 );
lobby->SetViewIndex( lobby->GetNumEntries() - 1 );
}
}
}

View File

@@ -0,0 +1,371 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_GAME_OPTIONS_OPTIONS = 8;
const float MIN_FOV = 80.0f;
const float MAX_FOV = 100.0f;
const float MIN_FOV_GUN = 3.0f;
const float MAX_FOV_GUN = 0.0f;
/*
========================
idMenuScreen_Shell_GameOptions::Initialize
========================
*/
void idMenuScreen_Shell_GameOptions::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuGameOptions" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_GAME_OPTIONS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_settings" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_swf_fov" );
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_FOV );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_checkpoints" );
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_CHECKPOINTS );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_02135" ); // Auto Weapon Switch
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_AUTO_SWITCH );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_02134" ); // Auto Weapon Reload
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_AUTO_RELOAD );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_aim_assist" ); // Aim Assist
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_AIM_ASSIST );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_04102" ); // Always Run
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_ALWAYS_SPRINT );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_flashlight_shadows" );
control->SetDataSource( &systemData, idMenuDataSource_GameSettings::GAME_FIELD_FLASHLIGHT_SHADOWS );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_GameOptions::Update
========================
*/
void idMenuScreen_Shell_GameOptions::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02129" ); // SYSTEM SETTINGS
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_GameOptions::ShowScreen
========================
*/
void idMenuScreen_Shell_GameOptions::ShowScreen( const mainMenuTransition_t transitionType ) {
systemData.LoadData();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_GameOptions::HideScreen
========================
*/
void idMenuScreen_Shell_GameOptions::HideScreen( const mainMenuTransition_t transitionType ) {
if ( systemData.IsDataChanged() ) {
systemData.CommitData();
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_GameOptions::HandleAction h
========================
*/
bool idMenuScreen_Shell_GameOptions::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_GAME_OPTIONS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
systemData.AdjustField( selectionIndex, 1 );
options->Update();
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
extern idCVar ui_autoSwitch;
extern idCVar ui_autoReload;
extern idCVar aa_targetAimAssistEnable;
extern idCVar in_alwaysRun;
extern idCVar g_checkpoints;
extern idCVar g_weaponShadows;
/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::idMenuDataSource_AudioSettings
========================
*/
idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::idMenuDataSource_GameSettings() {
fields.SetNum( MAX_GAME_FIELDS );
originalFields.SetNum( MAX_GAME_FIELDS );
}
/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::LoadData
========================
*/
void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::LoadData() {
fields[ GAME_FIELD_FOV ].SetInteger( g_fov.GetFloat() );
fields[ GAME_FIELD_CHECKPOINTS ].SetBool( g_checkpoints.GetBool() );
fields[ GAME_FIELD_AUTO_SWITCH ].SetBool( ui_autoSwitch.GetBool() );
fields[ GAME_FIELD_AUTO_RELOAD ].SetBool( ui_autoReload.GetBool() );
fields[ GAME_FIELD_AIM_ASSIST ].SetBool( aa_targetAimAssistEnable.GetBool() );
fields[ GAME_FIELD_ALWAYS_SPRINT ].SetBool( in_alwaysRun.GetBool() );
fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].SetBool( g_weaponShadows.GetBool() );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::CommitData
========================
*/
void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::CommitData() {
g_fov.SetFloat( fields[ GAME_FIELD_FOV ].ToFloat() );
g_gun_x.SetFloat( Lerp( MIN_FOV_GUN, MAX_FOV_GUN, ( fields[ GAME_FIELD_FOV ].ToFloat() - MIN_FOV ) / ( MAX_FOV - MIN_FOV ) ) );
g_checkpoints.SetBool( fields[ GAME_FIELD_CHECKPOINTS ].ToBool() );
ui_autoSwitch.SetBool( fields[ GAME_FIELD_AUTO_SWITCH ].ToBool() );
ui_autoReload.SetBool( fields[ GAME_FIELD_AUTO_RELOAD ].ToBool() );
aa_targetAimAssistEnable.SetBool( fields[ GAME_FIELD_AIM_ASSIST ].ToBool() );
in_alwaysRun.SetBool( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() );
g_weaponShadows.SetBool( fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() );
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::AdjustField
========================
*/
void idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
if ( fieldIndex == GAME_FIELD_FOV ) {
fields[ fieldIndex ].SetInteger( idMath::ClampInt( MIN_FOV, MAX_FOV, fields[ fieldIndex ].ToInteger() + adjustAmount * 5 ) );
} else {
fields[ fieldIndex ].SetBool( !fields[ fieldIndex ].ToBool() );
}
}
/*
========================
idMenuScreen_Shell_GameOptions::idMenuDataSource_AudioSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_GameOptions::idMenuDataSource_GameSettings::IsDataChanged() const {
if ( fields[ GAME_FIELD_FOV ].ToInteger() != originalFields[ GAME_FIELD_FOV ].ToInteger() ) {
return true;
}
if ( fields[ GAME_FIELD_CHECKPOINTS ].ToBool() != originalFields[ GAME_FIELD_CHECKPOINTS ].ToBool() ) {
return true;
}
if ( fields[ GAME_FIELD_AUTO_SWITCH ].ToBool() != originalFields[ GAME_FIELD_AUTO_SWITCH ].ToBool() ) {
return true;
}
if ( fields[ GAME_FIELD_AUTO_RELOAD ].ToBool() != originalFields[ GAME_FIELD_AUTO_RELOAD ].ToBool() ) {
return true;
}
if ( fields[ GAME_FIELD_AIM_ASSIST ].ToBool() != originalFields[ GAME_FIELD_AIM_ASSIST ].ToBool() ) {
return true;
}
if ( fields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() != originalFields[ GAME_FIELD_ALWAYS_SPRINT ].ToBool() ) {
return true;
}
if ( fields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() != originalFields[ GAME_FIELD_FLASHLIGHT_SHADOWS ].ToBool() ) {
return true;
}
return false;
}

View File

@@ -0,0 +1,464 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_CONTROLS_OPTIONS = 8;
enum gamepadMenuCmds_t {
#ifndef ID_PC
GAMEPAD_CMD_CONFIG,
#endif
GAMEPAD_CMD_LEFTY,
GAMEPAD_CMD_INVERT,
GAMEPAD_CMD_VIBRATE,
GAMEPAD_CMD_HOR_SENS,
GAMEPAD_CMD_VERT_SENS,
GAMEPAD_CMD_ACCELERATION,
GAMEPAD_CMD_THRESHOLD,
};
/*
========================
idMenuScreen_Shell_Gamepad::Initialize
========================
*/
void idMenuScreen_Shell_Gamepad::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuGamepad" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_CONTROLS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
idStr controls( idLocalization::GetString( "#str_04158" ) );
controls.ToUpper();
btnBack->SetLabel( controls );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
#ifndef ID_PC
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_BUTTON_TEXT );
control->SetLabel( "#str_swf_gamepad_config" ); // Gamepad Configuration
control->SetDescription( "#str_swf_config_desc" );
control->RegisterEventObserver( helpWidget );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_CONFIG );
options->AddChild( control );
#endif
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_lefty_flip" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_LEFTY );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_LEFTY );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_invert_gamepad" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_INVERT );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_INVERT );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_vibration" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_VIBRATE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_VIBRATE );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_hor_sens" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_HOR_SENS );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_HOR_SENS );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_vert_sens" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_VERT_SENS );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_VERT_SENS );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_joy_gammaLook" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_ACCELERATION );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_ACCELERATION );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_joy_mergedThreshold" );
control->SetDataSource( &gamepadData, idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_THRESHOLD );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, GAMEPAD_CMD_THRESHOLD );
control->RegisterEventObserver( helpWidget );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Gamepad::Update
========================
*/
void idMenuScreen_Shell_Gamepad::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_gamepad_heading" ); // CONTROLS
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Gamepad::ShowScreen
========================
*/
void idMenuScreen_Shell_Gamepad::ShowScreen( const mainMenuTransition_t transitionType ) {
gamepadData.LoadData();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Gamepad::HideScreen
========================
*/
void idMenuScreen_Shell_Gamepad::HideScreen( const mainMenuTransition_t transitionType ) {
if ( gamepadData.IsDataChanged() ) {
gamepadData.CommitData();
}
if ( menuData != NULL ) {
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( handler != NULL ) {
handler->SetupPCOptions();
}
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Gamepad::HandleAction
========================
*/
bool idMenuScreen_Shell_Gamepad::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_GAMEPAD ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_CONTROLS, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_COMMAND: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch ( parms[0].ToInteger() ) {
#ifndef ID_PC
case GAMEPAD_CMD_CONFIG: {
menuData->SetNextScreen( SHELL_AREA_CONTROLLER_LAYOUT, MENU_TRANSITION_SIMPLE );
break;
}
#endif
case GAMEPAD_CMD_INVERT: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_INVERT, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_LEFTY: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_LEFTY, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_VIBRATE: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_VIBRATE, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_HOR_SENS: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_HOR_SENS, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_VERT_SENS: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_VERT_SENS, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_ACCELERATION: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_ACCELERATION, 1 );
options->Update();
break;
}
case GAMEPAD_CMD_THRESHOLD: {
gamepadData.AdjustField( idMenuDataSource_GamepadSettings::GAMEPAD_FIELD_THRESHOLD, 1 );
options->Update();
break;
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
extern idCVar in_invertLook;
extern idCVar in_joystickRumble;
extern idCVar joy_pitchSpeed;
extern idCVar joy_yawSpeed;
extern idCVar joy_gammaLook;
extern idCVar joy_mergedThreshold;
/*
========================
idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::idMenuDataSource_AudioSettings
========================
*/
idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::idMenuDataSource_GamepadSettings() {
fields.SetNum( MAX_GAMEPAD_FIELDS );
originalFields.SetNum( MAX_GAMEPAD_FIELDS );
}
/*
========================
idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::LoadData
========================
*/
void idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::LoadData() {
idPlayerProfile * profile = session->GetProfileFromMasterLocalUser();
fields[ GAMEPAD_FIELD_INVERT ].SetBool( in_invertLook.GetBool() );
fields[ GAMEPAD_FIELD_LEFTY ].SetBool( profile ? profile->GetLeftyFlip() : false );
fields[ GAMEPAD_FIELD_VIBRATE ].SetBool( in_joystickRumble.GetBool() );
fields[ GAMEPAD_FIELD_HOR_SENS ].SetFloat( 100.0f * ( ( joy_yawSpeed.GetFloat() - 100.0f ) / 300.0f ) );
fields[ GAMEPAD_FIELD_VERT_SENS ].SetFloat( 100.0f * ( ( joy_pitchSpeed.GetFloat() - 60.0f ) / 200.0f ) );
fields[ GAMEPAD_FIELD_ACCELERATION ].SetBool( joy_gammaLook.GetBool() );
fields[ GAMEPAD_FIELD_THRESHOLD ].SetBool( joy_mergedThreshold.GetBool() );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::CommitData
========================
*/
void idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::CommitData() {
in_invertLook.SetBool( fields[ GAMEPAD_FIELD_INVERT ].ToBool() );
in_joystickRumble.SetBool( fields[ GAMEPAD_FIELD_VIBRATE ].ToBool() );
joy_yawSpeed.SetFloat( ( ( fields[ GAMEPAD_FIELD_HOR_SENS ].ToFloat() / 100.0f ) * 300.0f ) + 100.0f );
joy_pitchSpeed.SetFloat( ( ( fields[ GAMEPAD_FIELD_VERT_SENS ].ToFloat() / 100.0f ) * 200.0f ) + 60.0f );
joy_gammaLook.SetBool( fields[ GAMEPAD_FIELD_ACCELERATION ].ToBool() );
joy_mergedThreshold.SetBool( fields[ GAMEPAD_FIELD_THRESHOLD ].ToBool() );
idPlayerProfile * profile = session->GetProfileFromMasterLocalUser();
if ( profile != NULL ) {
profile->SetLeftyFlip( fields[ GAMEPAD_FIELD_LEFTY ].ToBool() );
}
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::AdjustField
========================
*/
void idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
if ( fieldIndex == GAMEPAD_FIELD_INVERT || fieldIndex == GAMEPAD_FIELD_LEFTY || fieldIndex == GAMEPAD_FIELD_VIBRATE || fieldIndex == GAMEPAD_FIELD_ACCELERATION || fieldIndex == GAMEPAD_FIELD_THRESHOLD ) {
fields[ fieldIndex ].SetBool( !fields[ fieldIndex ].ToBool() );
} else {
float newValue = idMath::ClampFloat( 0.0f, 100.0f, fields[ fieldIndex ].ToFloat() + adjustAmount );
fields[ fieldIndex ].SetFloat( newValue );
}
}
/*
========================
idMenuScreen_Shell_Gamepad::idMenuDataSource_AudioSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_Gamepad::idMenuDataSource_GamepadSettings::IsDataChanged() const {
if ( fields[ GAMEPAD_FIELD_INVERT ].ToBool() != originalFields[ GAMEPAD_FIELD_INVERT ].ToBool() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_LEFTY ].ToBool() != originalFields[ GAMEPAD_FIELD_LEFTY ].ToBool() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_VIBRATE ].ToBool() != originalFields[ GAMEPAD_FIELD_VIBRATE ].ToBool() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_HOR_SENS ].ToFloat() != originalFields[ GAMEPAD_FIELD_HOR_SENS ].ToFloat() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_VERT_SENS ].ToFloat() != originalFields[ GAMEPAD_FIELD_VERT_SENS ].ToFloat() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_ACCELERATION ].ToBool() != originalFields[ GAMEPAD_FIELD_ACCELERATION ].ToBool() ) {
return true;
}
if ( fields[ GAMEPAD_FIELD_THRESHOLD ].ToBool() != originalFields[ GAMEPAD_FIELD_THRESHOLD ].ToBool() ) {
return true;
}
return false;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,465 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_LOAD_OPTIONS = 10;
/*
========================
idMenuScreen_Shell_Load::Initialize
========================
*/
void idMenuScreen_Shell_Load::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuLoad" );
saveInfo = new (TAG_SWF) idMenuWidget_Shell_SaveInfo();
saveInfo->SetSpritePath( GetSpritePath(), "info", "details" );
saveInfo->Initialize( data );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_LOAD_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_LOAD_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->RegisterEventObserver( saveInfo );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
AddChild( saveInfo );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( data );
if ( handler != NULL && handler->GetInGame() ) {
btnBack->SetLabel( "#str_swf_pause_menu" );
} else {
btnBack->SetLabel( "#str_swf_campaign" );
}
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
btnDelete = new idMenuWidget_Button();
btnDelete->Initialize( data );
btnDelete->SetLabel( "" );
btnDelete->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_JOY3_ON_PRESS );
btnDelete->SetSpritePath( GetSpritePath(), "info", "btnDelete" );
AddChild( btnDelete );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Load::Update
========================
*/
void idMenuScreen_Shell_Load::Update() {
UpdateSaveEnumerations();
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02187" ); // LOAD GAME
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Load::UpdateSaveEnumerations
========================
*/
void idMenuScreen_Shell_Load::UpdateSaveEnumerations() {
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
sortedSaves = saveGameInfo;
sortedSaves.Sort( idSort_SavesByDate() );
if ( options != NULL ) {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > saveList;
if ( session->GetSaveGameManager().IsWorking() ) {
idList< idStr > saveName;
saveName.Append( "#str_dlg_refreshing" );
saveList.Append( saveName );
} else if ( sortedSaves.Num() == 0 ) {
idList< idStr > saveName;
saveName.Append( "#str_no_saves_found" );
saveList.Append( saveName );
} else {
saveList.SetNum( sortedSaves.Num() );
for ( int slot = 0; slot < sortedSaves.Num(); ++slot ) {
idStr & slotSaveName = saveList[slot].Alloc();
const idSaveGameDetails & details = sortedSaves[slot];
if ( details.damaged ) {
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_corrupt_file" ) );
} else if ( details.GetSaveVersion() > BUILD_NUMBER ) {
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_wrong_version" ) );
} else {
if ( details.slotName.Icmp( "autosave" ) == 0 ) {
slotSaveName.Append( S_COLOR_YELLOW );
} else if ( details.slotName.Icmp( "quick" ) == 0 ) {
slotSaveName.Append( S_COLOR_ORANGE );
}
slotSaveName.Append( details.GetMapName() );
}
}
}
options->SetListData( saveList );
options->Update();
}
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395"; // BACK
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
if ( sortedSaves.Num() > 0 && !session->GetSaveGameManager().IsWorking() ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_02187"; // LOAD GAME
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_02315"; // DELETE GAME
}
buttonInfo->action.Set( WIDGET_ACTION_JOY3_ON_PRESS );
if ( btnDelete != NULL ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( btnDelete->BindSprite( root ) ) {
if ( menuData->GetPlatform() != 2 ) {
btnDelete->SetLabel( "" );
} else {
btnDelete->GetSprite()->SetVisible( true );
btnDelete->SetLabel( "#str_02315" );
}
}
btnDelete->Update();
}
} else {
if ( btnDelete != NULL ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( btnDelete->BindSprite( root ) ) {
btnDelete->SetLabel( "" );
btnDelete->Update();
}
}
}
cmdBar->Update();
}
}
if ( saveInfo != NULL ) {
saveInfo->Update();
}
if ( options != NULL && options->GetTotalNumberOfOptions() > 0 && options->GetViewIndex() >= options->GetTotalNumberOfOptions() ) {
options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
if ( options->GetViewOffset() > options->GetViewIndex() ) {
options->SetViewOffset( options->GetViewIndex() );
}
options->SetFocusIndex( options->GetViewIndex() - options->GetViewOffset() );
}
}
/*
========================
idMenuScreen_Shell_Load::ShowScreen
========================
*/
void idMenuScreen_Shell_Load::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Load::HideScreen
========================
*/
void idMenuScreen_Shell_Load::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Load::LoadDamagedGame
========================
*/
void idMenuScreen_Shell_Load::LoadDamagedGame( int index ) {
if ( index >= sortedSaves.Num() ) {
return;
}
class idSWFScriptFunction_LoadDamaged : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_LoadDamaged( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Load * _screen ) {
msg = _msg;
accept = _accept;
index = _index;
screen = _screen;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept ) {
screen->DeleteGame( index );
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
int index;
bool accept;
idMenuScreen_Shell_Load * screen;
};
idStaticList< idSWFScriptFunction *, 4 > callbacks;
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_LoadDamaged( GDM_LOAD_DAMAGED_FILE, true, index, this ) );
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_LoadDamaged( GDM_LOAD_DAMAGED_FILE, false, index, this ) );
idStaticList< idStrId, 4 > optionText;
optionText.Append( idStrId( "#str_02315" ) ); // DELETE
optionText.Append( idStrId( "#STR_SWF_CANCEL" ) );
common->Dialog().AddDynamicDialog( GDM_LOAD_DAMAGED_FILE, callbacks, optionText, false, "" );
}
/*
========================
idMenuScreen_Shell_Load::LoadGame
========================
*/
void idMenuScreen_Shell_Load::LoadGame( int index ) {
if ( menuData == NULL ) {
return;
}
if ( index < GetSortedSaves().Num() && GetSortedSaves()[index].damaged ) {
LoadDamagedGame( index );
return;
}
bool isDead = false;
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL && player->health <= 0 ) {
isDead = true;
}
idMenuHandler_Shell * mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr != NULL && mgr->GetInGame() && !isDead ) {
class idSWFScriptFunction_LoadDialog : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_LoadDialog( gameDialogMessages_t _msg, bool _accept, const char * _name ) {
msg = _msg;
accept = _accept;
name = _name;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept && name != NULL ) {
cmdSystem->AppendCommandText( va( "loadgame %s\n", name ) );
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
bool accept;
const char * name;
};
if ( index < sortedSaves.Num() ) {
const idStr & name = sortedSaves[ index ].slotName;
common->Dialog().AddDialog( GDM_SP_LOAD_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_LoadDialog( GDM_SP_LOAD_SAVE, true, name.c_str() ), new idSWFScriptFunction_LoadDialog( GDM_SP_LOAD_SAVE, false, name.c_str() ), false );
}
} else {
if ( index < sortedSaves.Num() ) {
const idStr & name = sortedSaves[ index ].slotName;
cmdSystem->AppendCommandText( va( "loadgame %s\n", name.c_str() ) );
}
}
}
/*
========================
idMenuScreen_Shell_Save::DeleteGame
========================
*/
void idMenuScreen_Shell_Load::DeleteGame( int index ) {
class idSWFScriptFunction_DeleteGame : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_DeleteGame( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Load * _screen ) {
msg = _msg;
accept = _accept;
index = _index;
screen = _screen;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept && screen != NULL ) {
if ( index < screen->GetSortedSaves().Num() ) {
session->DeleteSaveGameSync( screen->GetSortedSaves()[ index ].slotName );
}
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
int index;
bool accept;
idMenuScreen_Shell_Load * screen;
};
common->Dialog().AddDialog( GDM_DELETE_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, true, index, this ), new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, false, index, this ), false );
}
/*
========================
idMenuScreen_Shell_Load::HandleAction h
========================
*/
bool idMenuScreen_Shell_Load::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData != NULL ) {
if ( menuData->ActiveScreen() != SHELL_AREA_LOAD ) {
return false;
}
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_JOY4_ON_PRESS: {
return true;
}
case WIDGET_ACTION_JOY3_ON_PRESS: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
DeleteGame( selectionIndex );
return true;
}
case WIDGET_ACTION_GO_BACK: {
if ( menuData != NULL ) {
if ( game->IsInGame() ) {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
} else {
menuData->SetNextScreen( SHELL_AREA_CAMPAIGN, MENU_TRANSITION_SIMPLE );
}
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
if ( sortedSaves.Num() == 0 ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
} else {
LoadGame( options->GetViewOffset() + selectionIndex );
}
} else {
LoadGame( options->GetViewIndex() );
}
return true;
}
case WIDGET_ACTION_SCROLL_VERTICAL: {
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,465 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_GAME_OPTIONS_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_MatchSettings::Initialize
========================
*/
void idMenuScreen_Shell_MatchSettings::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuMatchSettings" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_GAME_OPTIONS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_multiplayer" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_swf_mode" ); // Mode
control->SetDataSource( &matchData, idMenuDataSource_MatchSettings::MATCH_FIELD_MODE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_02049" ); // Map
control->SetDataSource( &matchData, idMenuDataSource_MatchSettings::MATCH_FIELD_MAP );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_02183" ); // Time
control->SetDataSource( &matchData, idMenuDataSource_MatchSettings::MATCH_FIELD_TIME );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_00100917" ); // Score
control->SetDataSource( &matchData, idMenuDataSource_MatchSettings::MATCH_FIELD_SCORE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_MatchSettings::Update
========================
*/
void idMenuScreen_Shell_MatchSettings::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_match_settings_heading" ); // SYSTEM SETTINGS
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_MatchSettings::ShowScreen
========================
*/
void idMenuScreen_Shell_MatchSettings::ShowScreen( const mainMenuTransition_t transitionType ) {
matchData.LoadData();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_MatchSettings::HideScreen
========================
*/
void idMenuScreen_Shell_MatchSettings::HideScreen( const mainMenuTransition_t transitionType ) {
if ( matchData.IsDataChanged() ) {
matchData.CommitData();
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_MatchSettings::HandleAction h
========================
*/
bool idMenuScreen_Shell_MatchSettings::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_MATCH_SETTINGS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_ADJUST_FIELD: {
if ( widget != NULL && widget->GetDataSource() != NULL && options != NULL ) {
widget->GetDataSource()->AdjustField( widget->GetDataSourceFieldIndex(), parms[ 0 ].ToInteger() );
widget->Update();
if ( matchData.MapChanged() ) {
idMenuWidget_ControlButton * button = dynamic_cast< idMenuWidget_ControlButton * >( &options->GetChildByIndex( 1 ) );
if ( button != NULL ) {
button->Update();
}
matchData.ClearMapChanged();
}
}
return true;
}
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_GAME_LOBBY, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
matchData.AdjustField( selectionIndex, 1 );
options->Update();
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
extern idCVar si_timeLimit;
extern idCVar si_fragLimit;
extern idCVar si_map;
extern idCVar si_mode;
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::idMenuDataSource_MatchSettings
========================
*/
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::idMenuDataSource_MatchSettings() {
fields.SetNum( MAX_MATCH_FIELDS );
originalFields.SetNum( MAX_MATCH_FIELDS );
updateMap = false;
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::LoadData
========================
*/
void idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::LoadData() {
updateMap = false;
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
idStr val;
GetMapName( matchParameters.gameMap, val );
fields[ MATCH_FIELD_MAP ].SetString( val );
GetModeName( matchParameters.gameMode, val );
fields[ MATCH_FIELD_MODE ].SetString( val );
int time = matchParameters.serverInfo.GetInt( "si_timeLimit" );
if ( time == 0 ) {
fields[ MATCH_FIELD_TIME ].SetString( "#str_02844" ); // none
} else {
fields[ MATCH_FIELD_TIME ].SetString( va( "%i", time ) );
}
int fragLimit = matchParameters.serverInfo.GetInt( "si_fragLimit" );
fields[ MATCH_FIELD_SCORE ].SetInteger( fragLimit );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::CommitData
========================
*/
void idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::CommitData() {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::GetMapName
========================
*/
void idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::GetMapName( int index, idStr & name ) {
idLobbyBase & lobby = session->GetActivePlatformLobbyBase();
const idMatchParameters & matchParameters = lobby.GetMatchParms();
name = "#str_swf_filter_random";
if ( matchParameters.gameMap >= 0 ) {
const idList< mpMap_t > maps = common->GetMapList();
name = idLocalization::GetString( maps[ idMath::ClampInt( 0, maps.Num() - 1, matchParameters.gameMap ) ].mapName );
}
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::GetModeName
========================
*/
void idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::GetModeName( int index, idStr & name ) {
idLobbyBase & lobby = session->GetActivePlatformLobbyBase();
const idMatchParameters & matchParameters = lobby.GetMatchParms();
name = "#str_swf_filter_random";
if ( matchParameters.gameMode >= 0 ) {
const idStrList & modes = common->GetModeDisplayList();
name = idLocalization::GetString( modes[ idMath::ClampInt( 0, modes.Num() - 1, matchParameters.gameMode ) ] );
}
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::AdjustField
========================
*/
void idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
const idStrList & modes = common->GetModeList();
const idList< mpMap_t > maps = common->GetMapList();
idMatchParameters matchParameters = session->GetActivePlatformLobbyBase().GetMatchParms();
if ( fieldIndex == MATCH_FIELD_MAP ) {
for ( int i = 0; i < maps.Num(); i++ ) {
// Don't allow random maps in the game lobby
matchParameters.gameMap += adjustAmount;
if ( matchParameters.gameMap < 0 ) {
matchParameters.gameMap = maps.Num() - 1;
}
matchParameters.gameMap %= maps.Num();
matchParameters.mapName = maps[ matchParameters.gameMap ].mapFile;
if ( ( maps[matchParameters.gameMap].supportedModes & BIT(matchParameters.gameMode) ) != 0 ) {
// This map supports this mode
break;
}
}
session->UpdateMatchParms( matchParameters );
idStr val;
GetMapName( matchParameters.gameMap, val );
si_map.SetInteger( matchParameters.gameMap );
fields[ MATCH_FIELD_MAP ].SetString( val );
} else if ( fieldIndex == MATCH_FIELD_MODE ) {
// Don't allow random modes in the game lobby
matchParameters.gameMode += adjustAmount;
if ( matchParameters.gameMode < 0 ) {
matchParameters.gameMode = modes.Num() - 1;
}
matchParameters.gameMode %= modes.Num();
updateMap = false;
if ( ( maps[matchParameters.gameMap].supportedModes & BIT(matchParameters.gameMode) ) == 0 ) {
for ( int i = 0; i < maps.Num(); ++i ) {
if ( ( maps[i].supportedModes & BIT(matchParameters.gameMode) ) != 0 ) {
matchParameters.gameMap = i;
updateMap = true;
break;
}
}
}
session->UpdateMatchParms( matchParameters );
idStr val;
GetModeName( matchParameters.gameMode, val );
si_mode.SetInteger( matchParameters.gameMode );
fields[ MATCH_FIELD_MODE ].SetString( val );
if ( updateMap ) {
GetMapName( matchParameters.gameMap, val );
si_map.SetInteger( matchParameters.gameMap );
fields[ MATCH_FIELD_MAP ].SetString( val );
}
} else if ( fieldIndex == MATCH_FIELD_TIME ) {
int time = si_timeLimit.GetInteger() + ( adjustAmount * 5 );
if ( time < 0 ) {
time = 60;
} else if ( time > 60 ) {
time = 0;
}
if ( time == 0 ) {
fields[ MATCH_FIELD_TIME ].SetString( "#str_02844" ); // none
} else {
fields[ MATCH_FIELD_TIME ].SetString( va( "%i", time ) );
}
si_timeLimit.SetInteger( time );
matchParameters.serverInfo.SetInt( "si_timeLimit", si_timeLimit.GetInteger() );
session->UpdateMatchParms( matchParameters );
} else if ( fieldIndex == MATCH_FIELD_SCORE ) {
int val = fields[ fieldIndex ].ToInteger() + ( adjustAmount * 5 );
if ( val < 5 ) {
val = MP_PLAYER_MAXFRAGS;
} else if ( val > MP_PLAYER_MAXFRAGS ) {
val = 5;
}
fields[ fieldIndex ].SetInteger( val );
si_fragLimit.SetInteger( val );
matchParameters.serverInfo.SetInt( "si_fragLimit", si_fragLimit.GetInteger() );
session->UpdateMatchParms( matchParameters );
}
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
}
/*
========================
idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_MatchSettings::idMenuDataSource_MatchSettings::IsDataChanged() const {
if ( fields[ MATCH_FIELD_TIME ].ToString() != originalFields[ MATCH_FIELD_TIME ].ToString() ) {
return true;
}
if ( fields[ MATCH_FIELD_MAP ].ToString() != originalFields[ MATCH_FIELD_MAP ].ToString() ) {
return true;
}
if ( fields[ MATCH_FIELD_MODE ].ToString() != originalFields[ MATCH_FIELD_MODE ].ToString() ) {
return true;
}
if ( fields[ MATCH_FIELD_SCORE ].ToInteger() != originalFields[ MATCH_FIELD_SCORE ].ToInteger() ) {
return true;
}
return false;
}

View File

@@ -0,0 +1,228 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SETTING_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_ModeSelect::Initialize
========================
*/
void idMenuScreen_Shell_ModeSelect::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuModeSelect" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
const idStrList & modes = common->GetModeDisplayList();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
for ( int i = 0; i < modes.Num(); ++i ) {
idList< idStr > option;
option.Append( modes[i] );
menuOptions.Append( option );
}
options->SetListData( menuOptions );
const char * tips[] = { "#str_swf_deathmatch_desc", "#str_swf_tourney_desc", "#str_swf_team_deathmatch_desc", "#str_swf_lastman_desc", "#str_swf_ctf_desc" };
while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
if ( options->GetChildren().Num() < menuOptions.Num() ) {
buttonWidget->SetDescription( tips[options->GetChildren().Num()] );
}
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_multiplayer" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_ModeSelect::Update
========================
*/
void idMenuScreen_Shell_ModeSelect::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_find_match_heading" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_ModeSelect::ShowScreen
========================
*/
void idMenuScreen_Shell_ModeSelect::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_ModeSelect::HideScreen
========================
*/
void idMenuScreen_Shell_ModeSelect::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_ModeSelect::HandleAction h
========================
*/
bool idMenuScreen_Shell_ModeSelect::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_MODE_SELECT ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_PARTY_LOBBY, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options->GetFocusIndex() != selectionIndex ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
matchParameters.gameMap = GAME_MAP_RANDOM;
matchParameters.gameMode = selectionIndex;
// Always a public match.
matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
session->UpdatePartyParms( matchParameters );
// Update flags for game lobby.
matchParameters.matchFlags = DefaultPartyFlags | DefaultPublicGameFlags;
cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
// Force a default value for the si_timelimit and si_fraglimit for quickmatch
matchParameters.serverInfo.SetInt( "si_timelimit", 15 );
matchParameters.serverInfo.SetInt( "si_fraglimit", 10 );
session->FindOrCreateMatch( matchParameters );
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,206 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_NEW_GAME_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_NewGame::Initialize
========================
*/
void idMenuScreen_Shell_NewGame::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuNewGame" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
option.Append( "#str_swf_doom3" ); // doom 3
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_resurrection" ); // resurrection of evil
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_lost_episodes" ); // lost episodes
menuOptions.Append( option );
options->SetListData( menuOptions );
options->SetNumVisibleOptions( NUM_NEW_GAME_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_NEW_GAME_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_campaign" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_NewGame::Update
========================
*/
void idMenuScreen_Shell_NewGame::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02207" ); // NEW GAME
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_NewGame::ShowScreen
========================
*/
void idMenuScreen_Shell_NewGame::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_NewGame::HideScreen
========================
*/
void idMenuScreen_Shell_NewGame::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_NewGame::HandleAction h
========================
*/
bool idMenuScreen_Shell_NewGame::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData != NULL ) {
if ( menuData->ActiveScreen() != SHELL_AREA_NEW_GAME ) {
return false;
}
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
if ( menuData != NULL ) {
menuData->SetNextScreen( SHELL_AREA_CAMPAIGN, MENU_TRANSITION_SIMPLE );
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( selectionIndex );
options->SetFocusIndex( selectionIndex );
}
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( shell != NULL ) {
shell->SetNewGameType( selectionIndex );
menuData->SetNextScreen( SHELL_AREA_DIFFICULTY, MENU_TRANSITION_SIMPLE );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,697 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_LOBBY_OPTIONS = 8;
extern idCVar net_inviteOnly;
extern idCVar si_map;
extern idCVar si_mode;
enum partyLobbyCmds_t {
PARTY_CMD_QUICK,
PARTY_CMD_FIND,
PARTY_CMD_CREATE,
PARTY_CMD_PWF,
PARTY_CMD_INVITE,
PARTY_CMD_LEADERBOARDS,
PARTY_CMD_TOGGLE_PRIVACY,
PARTY_CMD_SHOW_PARTY_GAMES,
};
/*
========================
idMenuScreen_Shell_PartyLobby::Initialize
========================
*/
void idMenuScreen_Shell_PartyLobby::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuPartyLobby" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_LOBBY_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( options->GetChildren().Num() < NUM_LOBBY_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_02305" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
lobby = new (TAG_SWF) idMenuWidget_LobbyList();
lobby->SetNumVisibleOptions( 8 );
lobby->SetSpritePath( GetSpritePath(), "options" );
lobby->SetWrappingAllowed( true );
lobby->Initialize( data );
while ( lobby->GetChildren().Num() < 8 ) {
idMenuWidget_LobbyButton * const buttonWidget = new idMenuWidget_LobbyButton();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_GAMERTAG, lobby->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_COMMAND ).Set( WIDGET_ACTION_MUTE_PLAYER, lobby->GetChildren().Num() );
buttonWidget->Initialize( data );
lobby->AddChild( buttonWidget );
}
AddChild( lobby );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( lobby, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_PartyLobby::Update
========================
*/
void idMenuScreen_Shell_PartyLobby::Update() {
idLobbyBase & activeLobby = session->GetPartyLobbyBase();
if ( lobby != NULL ) {
if ( activeLobby.GetNumActiveLobbyUsers() != 0 ) {
if ( lobby->GetFocusIndex() >= activeLobby.GetNumActiveLobbyUsers() ) {
lobby->SetFocusIndex( activeLobby.GetNumActiveLobbyUsers() - 1 );
lobby->SetViewIndex( lobby->GetViewOffset() + lobby->GetFocusIndex() );
}
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_multiplayer" ); // MULTIPLAYER
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
UpdateOptions();
if ( menuData != NULL && menuData->NextScreen() == SHELL_AREA_PARTY_LOBBY ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
lobbyUserID_t luid;
if ( isHost && CanKickSelectedPlayer( luid ) ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY4 );
buttonInfo->label = "#str_swf_kick";
buttonInfo->action.Set( WIDGET_ACTION_JOY4_ON_PRESS );
}
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_swf_view_profile";
}
buttonInfo->action.Set( WIDGET_ACTION_SELECT_GAMERTAG );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
void idMenuScreen_Shell_PartyLobby::UpdateOptions() {
bool forceUpdate = false;
if ( ( session->GetPartyLobbyBase().IsHost() && ( !isHost || forceUpdate ) ) && options != NULL ) {
menuOptions.Clear();
idList< idStr > option;
isHost = true;
isPeer = false;
option.Append( "#str_swf_join_public" ); // Quick Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_find_match" ); // Find Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_create_private" ); // Create Match
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_pwf" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_leaderboards" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_only" ); // Toggle privacy
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends" ); // Invite Friends
menuOptions.Append( option );
idMenuWidget_Button * buttonWidget = NULL;
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_QUICK, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_quick_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_FIND, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_find_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_CREATE, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_create_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_PWF, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_pwf_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_LEADERBOARDS, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_TOGGLE_PRIVACY, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_toggle_privacy_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_INVITE, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
options->SetListData( menuOptions );
} else if ( session->GetPartyLobbyBase().IsPeer() && options != NULL ) {
if ( !isPeer || forceUpdate ) {
menuOptions.Clear();
idList< idStr > option;
idMenuWidget_Button * buttonWidget = NULL;
option.Append( "#str_swf_leaderboards" ); // Play With Friends
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends" ); // Play With Friends
menuOptions.Append( option );
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_LEADERBOARDS, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_leaderboards_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PARTY_CMD_INVITE, index );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
options->SetListData( menuOptions );
}
isPeer = true;
isHost = false;
}
if ( forceUpdate ) {
options->Update();
}
}
/*
========================
idMenuScreen_Shell_PartyLobby::ShowScreen
========================
*/
void idMenuScreen_Shell_PartyLobby::ShowScreen( const mainMenuTransition_t transitionType ) {
isPeer = false;
isHost = false;
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFSpriteInstance * waitTime = GetSprite()->GetScriptObject()->GetNestedSprite( "waitTime" );
if ( waitTime != NULL ) {
waitTime->SetVisible( false );
}
}
if ( session->GetPartyLobbyBase().IsHost() ) {
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
if ( net_inviteOnly.GetBool() ) {
matchParameters.matchFlags |= MATCH_INVITE_ONLY;
} else {
matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
}
matchParameters.numSlots = session->GetTitleStorageInt("MAX_PLAYERS_ALLOWED", 4 );
session->UpdatePartyParms( matchParameters );
}
idMenuScreen::ShowScreen( transitionType );
if ( lobby != NULL ) {
lobby->SetFocusIndex( 0 );
}
}
/*
========================
idMenuScreen_Shell_PartyLobby::HideScreen
========================
*/
void idMenuScreen_Shell_PartyLobby::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer
========================
*/
bool idMenuScreen_Shell_PartyLobby::CanKickSelectedPlayer( lobbyUserID_t & luid ) {
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
const int playerId = lobby->GetFocusIndex();
// can't kick yourself
idLobbyBase & activeLobby = session->GetPartyLobbyBase();
luid = activeLobby.GetLobbyUserIdByOrdinal( playerId );
if ( session->GetSignInManager().GetMasterLocalUser() == activeLobby.GetLocalUserFromLobbyUser( luid ) ) {
return false;
}
return true;
}
/*
========================
idMenuScreen_Shell_PartyLobby::ShowLeaderboards
========================
*/
void idMenuScreen_Shell_PartyLobby::ShowLeaderboards() {
const bool canPlayOnline = session->GetSignInManager().GetMasterLocalUser() != NULL && session->GetSignInManager().GetMasterLocalUser()->CanPlayOnline();
if ( !canPlayOnline ) {
common->Dialog().AddDialog( GDM_LEADERBOARD_ONLINE_NO_PROFILE, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
} else if ( menuData != NULL ) {
menuData->SetNextScreen( SHELL_AREA_LEADERBOARDS, MENU_TRANSITION_SIMPLE );
}
}
/*
========================
idMenuScreen_Shell_PartyLobby::HandleAction h
========================
*/
bool idMenuScreen_Shell_PartyLobby::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_PARTY_LOBBY ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_JOY4_ON_PRESS: {
idLobbyBase & activeLobby = session->GetPartyLobbyBase();
lobbyUserID_t luid;
if ( CanKickSelectedPlayer( luid ) ) {
activeLobby.KickLobbyUser( luid );
}
return true;
}
case WIDGET_ACTION_GO_BACK: {
class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Accept() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_MAIN );
session->Cancel();
return idSWFScriptVar();
}
};
class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Cancel() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_LEAVE_LOBBY_RET_MAIN );
return idSWFScriptVar();
}
};
idLobbyBase & activeLobby = session->GetActivePlatformLobbyBase();
if( activeLobby.GetNumActiveLobbyUsers() > 1 ) {
common->Dialog().AddDialog( GDM_LEAVE_LOBBY_RET_MAIN, DIALOG_ACCEPT_CANCEL, new (TAG_SWF) idSWFScriptFunction_Accept(), new (TAG_SWF) idSWFScriptFunction_Cancel(), false );
} else {
session->Cancel();
}
return true;
}
case WIDGET_ACTION_MUTE_PLAYER: {
if ( parms.Num() != 1 ) {
return true;
}
int index = parms[0].ToInteger();
idLobbyBase & activeLobby = session->GetPartyLobbyBase();
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( index );
if ( luid.IsValid() ) {
session->ToggleLobbyUserVoiceMute( luid );
}
return true;
}
case WIDGET_ACTION_COMMAND: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 1 ) {
selectionIndex = parms[1].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch ( parms[0].ToInteger() ) {
case PARTY_CMD_QUICK: {
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
// Reset these to random for quick match.
matchParameters.gameMap = GAME_MAP_RANDOM;
matchParameters.gameMode = GAME_MODE_RANDOM;
// Always a public match.
matchParameters.matchFlags &= ~MATCH_INVITE_ONLY;
session->UpdatePartyParms( matchParameters );
// Update flags for game lobby.
matchParameters.matchFlags = DefaultPartyFlags | DefaultPublicGameFlags;
cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
// Force a default value for the si_timelimit and si_fraglimit for quickmatch
matchParameters.serverInfo.SetInt( "si_timelimit", 15 );
matchParameters.serverInfo.SetInt( "si_fraglimit", 10 );
session->FindOrCreateMatch( matchParameters );
break;
}
case PARTY_CMD_FIND: {
menuData->SetNextScreen( SHELL_AREA_MODE_SELECT, MENU_TRANSITION_SIMPLE );
break;
}
case PARTY_CMD_CREATE: {
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
const bool isInviteOnly = MatchTypeInviteOnly( matchParameters.matchFlags );
matchParameters.matchFlags = DefaultPartyFlags | DefaultPrivateGameFlags;
if ( isInviteOnly ) {
matchParameters.matchFlags |= MATCH_INVITE_ONLY;
}
int mode = idMath::ClampInt( -1, GAME_COUNT - 1, si_mode.GetInteger() );
const idList< mpMap_t > maps = common->GetMapList();
int map = idMath::ClampInt( -1, maps.Num() - 1, si_map.GetInteger() );
matchParameters.gameMap = map;
matchParameters.gameMode = mode;
cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO, matchParameters.serverInfo );
session->CreateMatch( matchParameters );
break;
}
case PARTY_CMD_PWF: {
menuData->SetNextScreen( SHELL_AREA_BROWSER, MENU_TRANSITION_SIMPLE );
break;
}
case PARTY_CMD_LEADERBOARDS: {
ShowLeaderboards();
break;
}
case PARTY_CMD_TOGGLE_PRIVACY: {
idMatchParameters matchParameters = idMatchParameters( session->GetPartyLobbyBase().GetMatchParms() );
matchParameters.matchFlags ^= MATCH_INVITE_ONLY;
session->UpdatePartyParms( matchParameters );
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
net_inviteOnly.SetBool( bitSet != 0 ? true : false );
break;
}
case PARTY_CMD_SHOW_PARTY_GAMES: {
session->ShowPartySessions();
break;
}
case PARTY_CMD_INVITE: {
if ( session->GetPartyLobbyBase().IsLobbyFull() ) {
common->Dialog().AddDialog( GDM_CANNOT_INVITE_LOBBY_FULL, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
return true;
}
InvitePartyOrFriends();
break;
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
case WIDGET_ACTION_SELECT_GAMERTAG: {
int selectionIndex = lobby->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != lobby->GetFocusIndex() ) {
lobby->SetViewIndex( lobby->GetViewOffset() + selectionIndex );
lobby->SetFocusIndex( selectionIndex );
return true;
}
idLobbyBase & activeLobby = session->GetPartyLobbyBase();
lobbyUserID_t luid = activeLobby.GetLobbyUserIdByOrdinal( selectionIndex );
if ( luid.IsValid() ) {
session->ShowLobbyUserGamerCardUI( luid );
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuScreen_Shell_PartyLobby::UpdateLobby
========================
*/
void idMenuScreen_Shell_PartyLobby::UpdateLobby() {
if ( menuData != NULL && menuData->ActiveScreen() != SHELL_AREA_PARTY_LOBBY ) {
return;
}
// Keep this menu in sync with the session host/peer status.
if ( session->GetPartyLobbyBase().IsHost() && !isHost ) {
Update();
}
if ( session->GetPartyLobbyBase().IsPeer() && !isPeer ) {
Update();
}
if ( isPeer ) {
Update();
}
UpdateOptions();
// setup names for lobby;
if ( lobby != NULL ) {
idMenuHandler_Shell * mgr = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( mgr != NULL ) {
mgr->UpdateLobby( lobby );
lobby->Update();
}
if ( lobby->GetNumEntries() > 0 && lobby->GetFocusIndex() >= lobby->GetNumEntries() ) {
lobby->SetFocusIndex( lobby->GetNumEntries() - 1 );
lobby->SetViewIndex( lobby->GetNumEntries() - 1 );
}
}
if ( session->GetState() == idSession::PARTY_LOBBY ) {
if ( options != NULL ) {
if ( options->GetFocusIndex() >= options->GetTotalNumberOfOptions() && options->GetTotalNumberOfOptions() > 0 ) {
options->SetViewIndex( options->GetTotalNumberOfOptions() - 1 );
options->SetFocusIndex( options->GetTotalNumberOfOptions() - 1 );
}
}
idSWFTextInstance * privacy = GetSprite()->GetScriptObject()->GetNestedText( "matchInfo", "txtPrivacy" );
if ( privacy != NULL ) {
if ( isPeer ) {
privacy->SetText( "" );
} else {
idMatchParameters matchParameters = session->GetPartyLobbyBase().GetMatchParms();
int bitSet = ( matchParameters.matchFlags & MATCH_INVITE_ONLY );
bool privacySet = ( bitSet != 0 ? true : false );
if ( privacySet ) {
privacy->SetText( "#str_swf_privacy_closed" );
privacy->SetStrokeInfo( true );
} else if ( !privacySet ) {
privacy->SetText( "#str_swf_privacy_open" );
privacy->SetStrokeInfo( true );
}
}
}
idLocalUser * user = session->GetSignInManager().GetMasterLocalUser();
if ( user != NULL && options != NULL ) {
if ( user->IsInParty() && user->GetPartyCount() > 1 && !session->IsPlatformPartyInLobby() && menuOptions.Num() > 0 ) {
if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_xbox_live_party" ) {
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_xbox_live_party"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
} else if ( menuOptions.Num() > 0 ) {
if ( menuOptions[ menuOptions.Num() - 1 ][0] != "#str_swf_invite_friends" ) {
menuOptions[ menuOptions.Num() - 1 ][0] = "#str_swf_invite_friends"; // invite Xbox LIVE party
options->SetListData( menuOptions );
options->Update();
}
}
}
}
}

View File

@@ -0,0 +1,481 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
extern idCVar g_demoMode;
const static int NUM_PAUSE_OPTIONS = 6;
enum pauseMenuCmds_t {
PAUSE_CMD_RESTART,
PAUSE_CMD_DEAD_RESTART,
PAUSE_CMD_SETTINGS,
PAUSE_CMD_EXIT,
PAUSE_CMD_LEAVE,
PAUSE_CMD_RETURN,
PAUSE_CMD_LOAD,
PAUSE_CMD_SAVE,
PAUSE_CMD_PS3,
PAUSE_CMD_INVITE_FRIENDS
};
/*
========================
idMenuScreen_Shell_Pause::Initialize
========================
*/
void idMenuScreen_Shell_Pause::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuPause" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_PAUSE_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( options->GetChildren().Num() < NUM_PAUSE_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Pause::Update
========================
*/
void idMenuScreen_Shell_Pause::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
bool isDead = false;
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
if ( player->health <= 0 ) {
isDead = true;
}
}
if ( !isDead ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_RETURN );
}
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Pause::ShowScreen
========================
*/
void idMenuScreen_Shell_Pause::ShowScreen( const mainMenuTransition_t transitionType ) {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
bool isDead = false;
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
if ( player->health <= 0 ) {
isDead = true;
}
}
if ( g_demoMode.GetBool() ) {
isMpPause = false;
if ( isDead ) {
option.Append( "#str_swf_restart_map" ); // retart map
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_exit_game" ); // exit game
menuOptions.Append( option );
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_DEAD_RESTART );
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SETTINGS );
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_LEAVE );
} else {
option.Append( "#str_04106" ); // return to game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_restart_map" ); // retart map
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_exit_game" ); // exit game
menuOptions.Append( option );
int index = 0;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_RETURN );
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_RESTART );
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SETTINGS );
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_EXIT );
}
} else {
if ( common->IsMultiplayer() ) {
isMpPause = true;
option.Append( "#str_04106" ); // return to game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_invite_friends_upper" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_leave_game" ); // leave game
menuOptions.Append( option );
int index = 0;
idMenuWidget_Button * buttonWidget = NULL;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_RETURN );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_resume_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SETTINGS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02206" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_INVITE_FRIENDS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_invite_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_LEAVE );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_exit_game_desc" );
}
} else {
isMpPause = false;
if ( isDead ) {
option.Append( "#str_02187" ); // load game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_exit_game" ); // exit game
menuOptions.Append( option );
int index = 0;
idMenuWidget_Button * buttonWidget = NULL;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_LOAD );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02213" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SETTINGS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02206" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_EXIT );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_exit_game_desc" );
}
} else {
option.Append( "#str_04106" ); // return to game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_02179" ); // save game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_02187" ); // load game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_exit_game" ); // exit game
menuOptions.Append( option );
int index = 0;
idMenuWidget_Button * buttonWidget = NULL;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_RETURN );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_resume_desc" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SAVE );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02211" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_LOAD );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02213" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_SETTINGS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02206" );
}
index++;
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, PAUSE_CMD_EXIT );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_exit_game_desc" );
}
}
}
}
options->SetListData( menuOptions );
idMenuScreen::ShowScreen( transitionType );
if ( options->GetFocusIndex() >= menuOptions.Num() ) {
options->SetViewIndex( 0 );
options->SetFocusIndex( 0 );
}
}
/*
========================
idMenuScreen_Shell_Pause::HideScreen
========================
*/
void idMenuScreen_Shell_Pause::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Pause::HandleExitGameBtn
========================
*/
void idMenuScreen_Shell_Pause::HandleExitGameBtn() {
class idSWFScriptFunction_QuitDialog : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_QuitDialog( idMenuScreen_Shell_Pause * _menu, gameDialogMessages_t _msg, bool _accept ) {
menu = _menu;
msg = _msg;
accept = _accept;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept ) {
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "disconnect\n" );
}
return idSWFScriptVar();
}
private:
idMenuScreen_Shell_Pause * menu;
gameDialogMessages_t msg;
bool accept;
};
gameDialogMessages_t msg = GDM_SP_QUIT_SAVE;
if ( common->IsMultiplayer() ) {
if ( ( session->GetGameLobbyBase().GetNumLobbyUsers() > 1 ) && MatchTypeHasStats( session->GetGameLobbyBase().GetMatchParms().matchFlags ) ) {
msg = GDM_MULTI_VDM_QUIT_LOSE_LEADERBOARDS;
} else {
msg = GDM_MULTI_VDM_QUIT;
}
}
common->Dialog().AddDialog( msg, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_QuitDialog( this, msg, true ), new idSWFScriptFunction_QuitDialog( this, msg, false ), false );
}
/*
========================
idMenuScreen_Shell_Pause::HandleRestartBtn
========================
*/
void idMenuScreen_Shell_Pause::HandleRestartBtn() {
class idSWFScriptFunction_RestartDialog : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_RestartDialog( idMenuScreen_Shell_Pause * _menu, gameDialogMessages_t _msg, bool _accept ) {
menu = _menu;
msg = _msg;
accept = _accept;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept ) {
cmdSystem->AppendCommandText( "restartMap\n" );
}
return idSWFScriptVar();
}
private:
idMenuScreen_Shell_Pause * menu;
gameDialogMessages_t msg;
bool accept;
};
common->Dialog().AddDialog( GDM_SP_RESTART_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_RestartDialog( this, GDM_SP_RESTART_SAVE, true ), new idSWFScriptFunction_RestartDialog( this, GDM_SP_RESTART_SAVE, false ), false );
}
/*
========================
idMenuScreen_Shell_Pause::HandleAction
========================
*/
bool idMenuScreen_Shell_Pause::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_ROOT ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_COMMAND: {
switch ( parms[0].ToInteger() ) {
case PAUSE_CMD_RESTART: {
HandleRestartBtn();
break;
}
case PAUSE_CMD_DEAD_RESTART: {
cmdSystem->AppendCommandText( "restartMap\n" );
break;
}
case PAUSE_CMD_SETTINGS: {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
break;
}
case PAUSE_CMD_LEAVE:
case PAUSE_CMD_EXIT: {
HandleExitGameBtn();
break;
}
case PAUSE_CMD_RETURN: {
menuData->SetNextScreen( SHELL_AREA_INVALID, MENU_TRANSITION_SIMPLE );
break;
}
case PAUSE_CMD_LOAD: {
menuData->SetNextScreen( SHELL_AREA_LOAD, MENU_TRANSITION_SIMPLE );
break;
}
case PAUSE_CMD_SAVE: {
menuData->SetNextScreen( SHELL_AREA_SAVE, MENU_TRANSITION_SIMPLE );
break;
}
case PAUSE_CMD_PS3: {
menuData->SetNextScreen( SHELL_AREA_PLAYSTATION, MENU_TRANSITION_SIMPLE );
break;
}
case PAUSE_CMD_INVITE_FRIENDS: {
session->InviteFriends();
break;
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,207 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SETTING_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_Playstation::Initialize
========================
*/
void idMenuScreen_Shell_Playstation::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuPlaystation" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
option.Append( "#str_swf_friends" ); // FRIENDS
menuOptions.Append( option );
option.Clear();
option.Append( "#str_swf_check_for_invites" ); // CHECK FOR INVITES
menuOptions.Append( option );
options->SetListData( menuOptions );
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( data );
if ( handler != NULL && handler->GetInGame() ) {
btnBack->SetLabel( "#str_swf_pause_menu" );
} else {
btnBack->SetLabel( "#str_02305" );
}
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Playstation::Update
========================
*/
void idMenuScreen_Shell_Playstation::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_playstation" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Playstation::ShowScreen
========================
*/
void idMenuScreen_Shell_Playstation::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Playstation::HideScreen
========================
*/
void idMenuScreen_Shell_Playstation::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Playstation::HandleAction h
========================
*/
bool idMenuScreen_Shell_Playstation::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_PLAYSTATION ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options->GetFocusIndex() != selectionIndex ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
if ( selectionIndex == 0 ) {
} else if ( selectionIndex == 1 ) {
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,302 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
#include "../../framework/Common_local.h"
static const int NUM_GAME_SELECTIONS_VISIBLE = 5;
extern idCVar g_demoMode;
namespace {
/*
================================================
UICmd_RegisterUser
================================================
*/
class UICmd_RegisterUser : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( parms.Num() != 1 ) {
idLib::Warning( "No device specified when registering mouse user" );
return idSWFScriptVar();
}
const int device = parms[ 0 ].ToInteger();
session->GetSignInManager().RegisterLocalUser( device );
return idSWFScriptVar();
}
};
}
/*
========================
idMenuScreen_Shell_PressStart::Initialize
========================
*/
void idMenuScreen_Shell_PressStart::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuStart" );
itemList = new (TAG_SWF) idMenuWidget_Carousel();
itemList->SetSpritePath( GetSpritePath(), "info", "options" );
itemList->SetNumVisibleOptions( NUM_GAME_SELECTIONS_VISIBLE );
while ( itemList->GetChildren().Num() < NUM_GAME_SELECTIONS_VISIBLE ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, itemList->GetChildren().Num() );
buttonWidget->Initialize( data );
itemList->AddChild( buttonWidget );
}
itemList->Initialize( data );
AddChild( itemList );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER, WIDGET_EVENT_SCROLL_LEFT ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER, WIDGET_EVENT_SCROLL_RIGHT ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_LEFT_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER, WIDGET_EVENT_SCROLL_LEFT_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_LSTICK ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ) );
doomCover = declManager->FindMaterial( "guis/assets/mainmenu/doom_cover.tga" );
doom2Cover = declManager->FindMaterial( "guis/assets/mainmenu/doom2_cover.tga" );
doom3Cover = declManager->FindMaterial( "guis/assets/mainmenu/doom3_cover.tga" );
startButton = new idMenuWidget_Button();
startButton->SetSpritePath( GetSpritePath(), "info", "btnStart" );
AddChild( startButton );
}
/*
========================
idMenuScreen_Shell_Root::Update
========================
*/
void idMenuScreen_Shell_PressStart::Update() {
if ( !g_demoMode.GetBool() ) {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_PressStart::ShowScreen
========================
*/
void idMenuScreen_Shell_PressStart::ShowScreen( const mainMenuTransition_t transitionType ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
if ( g_demoMode.GetBool() ) {
idList<const idMaterial *> coverIcons;
if ( itemList != NULL ) {
itemList->SetListImages( coverIcons );
}
if ( startButton != NULL ) {
startButton->BindSprite( root );
startButton->SetLabel( idLocalization::GetString( "#str_swf_press_start" ) );
}
idSWFSpriteInstance * backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" );
if ( backing != NULL ) {
backing->SetVisible( false );
}
} else {
idList<const idMaterial *> coverIcons;
coverIcons.Append( doomCover );
coverIcons.Append( doom3Cover );
coverIcons.Append( doom2Cover );
if ( itemList != NULL ) {
itemList->SetListImages( coverIcons );
itemList->SetFocusIndex( 1, true );
itemList->SetViewIndex( 1 );
itemList->SetMoveToIndex( 1 );
}
if ( startButton != NULL ) {
startButton->BindSprite( root );
startButton->SetLabel( "" );
}
idSWFSpriteInstance * backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" );
if ( backing != NULL ) {
backing->SetVisible( true );
}
}
}
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_PressStart::HideScreen
========================
*/
void idMenuScreen_Shell_PressStart::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_PressStart::HandleAction
========================
*/
bool idMenuScreen_Shell_PressStart::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_START ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( itemList == NULL ) {
return true;
}
if ( event.parms.Num() != 1 ) {
return true;
}
if ( itemList->GetMoveToIndex() != itemList->GetViewIndex() ) {
return true;
}
if ( parms.Num() > 0 ) {
const int index = parms[0].ToInteger();
if ( index != 0 ) {
itemList->MoveToIndex( index );
Update();
}
}
if ( itemList->GetMoveToIndex() == 0 ) {
common->SwitchToGame( DOOM_CLASSIC );
} else if ( itemList->GetMoveToIndex() == 1 ) {
if ( session->GetSignInManager().GetMasterLocalUser() == NULL ) {
const int device = event.parms[ 0 ].ToInteger();
session->GetSignInManager().RegisterLocalUser( device );
} else {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
}
} else if ( itemList->GetMoveToIndex() == 2 ) {
common->SwitchToGame( DOOM2_CLASSIC );
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
idWidgetAction repeatAction;
widgetAction_t repeatActionType = static_cast< widgetAction_t >( parms[ 0 ].ToInteger() );
assert( parms.Num() == 2 );
repeatAction.Set( repeatActionType, parms[ 1 ] );
menuData->StartWidgetActionRepeater( widget, repeatAction, event );
return true;
}
case WIDGET_ACTION_STOP_REPEATER: {
menuData->ClearWidgetActionRepeater();
return true;
}
case WIDGET_ACTION_SCROLL_HORIZONTAL: {
if ( itemList == NULL ) {
return true;
}
if ( itemList->GetTotalNumberOfOptions() <= 1 ) {
return true;
}
idLib::Printf( "scroll \n" );
if ( itemList->GetMoveDiff() > 0 ) {
itemList->MoveToIndex( itemList->GetMoveToIndex(), true );
}
int direction = parms[0].ToInteger();
if ( direction == 1 ) {
if ( itemList->GetViewIndex() == itemList->GetTotalNumberOfOptions() - 1 ) {
return true;
} else {
itemList->MoveToIndex( 1 );
}
} else {
if ( itemList->GetViewIndex() == 0 ) {
return true;
} else {
itemList->MoveToIndex( ( itemList->GetNumVisibleOptions() / 2 ) + 1 );
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,295 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
#include "../../renderer/tr_local.h"
const static int NUM_SETTING_OPTIONS = 7;
enum settingMenuCmds_t {
SETTING_CMD_CONTROLS,
SETTING_CMD_GAMEPLAY,
SETTING_CMD_SYSTEM,
SETTING_CMD_3D,
};
/*
========================
idMenuScreen_Shell_Resolution::Initialize
========================
*/
void idMenuScreen_Shell_Resolution::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuResolution" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_00183" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Resolution::Update
========================
*/
void idMenuScreen_Shell_Resolution::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02154" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Resolution::ShowScreen
========================
*/
void idMenuScreen_Shell_Resolution::ShowScreen( const mainMenuTransition_t transitionType ) {
originalOption.fullscreen = r_fullscreen.GetInteger();
originalOption.vidmode = r_vidMode.GetInteger();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
menuOptions.Alloc().Alloc() = "#str_swf_disabled";
optionData.Append( optionData_t( 0, 0 ) );
int viewIndex = 0;
idList< idList<vidMode_t> > displays;
for ( int displayNum = 0 ; ; displayNum++ ) {
idList<vidMode_t> & modeList = displays.Alloc();
if ( !R_GetModeListForDisplay( displayNum, modeList ) ) {
displays.RemoveIndex( displays.Num() - 1 );
break;
}
}
for ( int displayNum = 0 ; displayNum < displays.Num(); displayNum++ ) {
idList<vidMode_t> & modeList = displays[displayNum];
for ( int i = 0; i < modeList.Num(); i++ ) {
const optionData_t thisOption( displayNum + 1, i );
if ( originalOption == thisOption ) {
viewIndex = menuOptions.Num();
}
idStr str;
if ( displays.Num() > 1 ) {
str.Append( va( "%s %i: ", idLocalization::GetString( "#str_swf_monitor" ), displayNum+1 ) );
}
str.Append( va( "%4i x %4i", modeList[i].width, modeList[i].height ) );
if ( modeList[i].displayHz != 60 ) {
str.Append( va( " @ %dhz", modeList[i].displayHz ) );
}
menuOptions.Alloc().Alloc() = str;
optionData.Append( thisOption );
}
}
options->SetListData( menuOptions );
options->SetViewIndex( viewIndex );
const int topOfLastPage = menuOptions.Num() - NUM_SETTING_OPTIONS;
if ( viewIndex < NUM_SETTING_OPTIONS ) {
options->SetViewOffset( 0 );
options->SetFocusIndex( viewIndex );
} else if ( viewIndex >= topOfLastPage ) {
options->SetViewOffset( topOfLastPage );
options->SetFocusIndex( viewIndex - topOfLastPage );
} else {
options->SetViewOffset( viewIndex );
options->SetFocusIndex( 0 );
}
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Resolution::HideScreen
========================
*/
void idMenuScreen_Shell_Resolution::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Resolution::HandleAction h
========================
*/
bool idMenuScreen_Shell_Resolution::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_RESOLUTION ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options != NULL ) {
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options->GetFocusIndex() != selectionIndex ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
const optionData_t & currentOption = optionData[options->GetViewIndex()];
if ( currentOption == originalOption ) {
// No change
menuData->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE );
} else if ( currentOption.fullscreen == 0 ) {
// Changing to windowed mode
r_fullscreen.SetInteger( 0 );
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "vid_restart\n" );
menuData->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE );
} else {
// Changing to fullscreen mode
r_fullscreen.SetInteger( currentOption.fullscreen );
r_vidMode.SetInteger( currentOption.vidmode );
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "vid_restart\n" );
class idSWFFuncAcceptVideoChanges : public idSWFScriptFunction_RefCounted {
public:
idSWFFuncAcceptVideoChanges( idMenuHandler * _menu, gameDialogMessages_t _msg, const optionData_t & _optionData, bool _accept ) {
menuHandler = _menu;
msg = _msg;
optionData = _optionData;
accept = _accept;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept ) {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
if ( menuHandler != NULL ) {
menuHandler->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE );
}
} else {
r_fullscreen.SetInteger( optionData.fullscreen );
r_vidMode.SetInteger( optionData.vidmode );
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "vid_restart\n" );
}
return idSWFScriptVar();
}
private:
idMenuHandler * menuHandler;
gameDialogMessages_t msg;
optionData_t optionData;
bool accept;
};
common->Dialog().AddDialog( GDM_CONFIRM_VIDEO_CHANGES, DIALOG_TIMER_ACCEPT_REVERT, new ( TAG_SWF ) idSWFFuncAcceptVideoChanges( menuData, GDM_CONFIRM_VIDEO_CHANGES, currentOption, true ), new ( TAG_SWF ) idSWFFuncAcceptVideoChanges( menuData, GDM_CONFIRM_VIDEO_CHANGES, originalOption, false ), false );
}
return true;
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,514 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
extern idCVar g_demoMode;
const static int NUM_MAIN_OPTIONS = 6;
/*
========================
idMenuScreen_Shell_Root::Initialize
========================
*/
void idMenuScreen_Shell_Root::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuMain" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_MAIN_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->Initialize( data );
options->SetWrappingAllowed( true );
AddChild( options );
helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( options->GetChildren().Num() < NUM_MAIN_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_RIGHT_START_REPEATER, WIDGET_EVENT_SCROLL_RIGHT ) );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_RIGHT_RELEASE ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_SCROLL_LEFT_START_REPEATER, WIDGET_EVENT_SCROLL_LEFT ) );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_LEFT_RELEASE ) );
AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, 0 );
}
/*
========================
idMenuScreen_Shell_Root::Update
========================
*/
void idMenuScreen_Shell_Root::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
if ( !g_demoMode.GetBool() ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
}
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idMenuScreen::Update();
}
enum rootMenuCmds_t {
ROOT_CMD_START_DEMO,
ROOT_CMD_START_DEMO2,
ROOT_CMD_SETTINGS,
ROOT_CMD_QUIT,
ROOT_CMD_DEV,
ROOT_CMD_CAMPAIGN,
ROOT_CMD_MULTIPLAYER,
ROOT_CMD_PLAYSTATION,
ROOT_CMD_CREDITS
};
/*
========================
idMenuScreen_Shell_Root::ShowScreen
========================
*/
void idMenuScreen_Shell_Root::ShowScreen( const mainMenuTransition_t transitionType ) {
if ( menuData != NULL && menuData->GetPlatform() != 2 ) {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
int index = 0;
if ( g_demoMode.GetBool() ) {
idMenuWidget_Button * buttonWidget = NULL;
option.Append( "START DEMO" ); // START DEMO
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_START_DEMO );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "Launch the demo" );
}
index++;
if ( g_demoMode.GetInteger() == 2 ) {
option.Clear();
option.Append( "START PRESS DEMO" ); // START DEMO
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_START_DEMO2 );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "Launch the press demo" );
}
index++;
}
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_SETTINGS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02206" );
}
index++;
option.Clear();
option.Append( "#str_swf_quit" ); // quit
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_QUIT );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_01976" );
}
index++;
} else {
idMenuWidget_Button * buttonWidget = NULL;
#if !defined ( ID_RETAIL )
option.Append( "DEV" ); // DEV
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_DEV );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "View a list of maps available for play" );
}
index++;
#endif
option.Clear();
option.Append( "#str_swf_campaign" ); // singleplayer
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_CAMPAIGN );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_campaign_desc" );
}
index++;
option.Clear();
option.Append( "#str_swf_multiplayer" ); // multiplayer
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_MULTIPLAYER );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02215" );
}
index++;
option.Clear();
option.Append( "#str_swf_settings" ); // settings
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_SETTINGS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02206" );
}
index++;
option.Clear();
option.Append( "#str_swf_credits" ); // credits
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_CREDITS );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02219" );
}
index++;
// only add quit option for PC
option.Clear();
option.Append( "#str_swf_quit" ); // quit
menuOptions.Append( option );
options->GetChildByIndex( index ).ClearEventActions();
options->GetChildByIndex( index ).AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, ROOT_CMD_QUIT );
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_01976" );
}
index++;
}
options->SetListData( menuOptions );
} else {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
options->SetListData( menuOptions );
}
idMenuScreen::ShowScreen( transitionType );
if ( menuData != NULL && menuData->GetPlatform() == 2 ) {
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( shell != NULL ) {
idMenuWidget_MenuBar * menuBar = shell->GetMenuBar();
if ( menuBar != NULL ) {
menuBar->SetFocusIndex( GetRootIndex() );
}
}
}
}
/*
========================
idMenuScreen_Shell_Root::HideScreen
========================
*/
void idMenuScreen_Shell_Root::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Root::HandleExitGameBtn
========================
*/
void idMenuScreen_Shell_Root::HandleExitGameBtn() {
class idSWFScriptFunction_QuitDialog : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_QuitDialog( gameDialogMessages_t _msg, int _accept ) {
msg = _msg;
accept = _accept;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept == 1 ) {
common->Quit();
} else if ( accept == -1 ) {
session->MoveToPressStart();
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
int accept;
};
idStaticList< idSWFScriptFunction *, 4 > callbacks;
idStaticList< idStrId, 4 > optionText;
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 1 ) );
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, 0 ) );
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_QuitDialog( GDM_QUIT_GAME, -1 ) );
optionText.Append( idStrId( "#STR_SWF_ACCEPT" ) );
optionText.Append( idStrId( "#STR_SWF_CANCEL" ) );
optionText.Append( idStrId( "#str_swf_change_game" ) );
common->Dialog().AddDynamicDialog( GDM_QUIT_GAME, callbacks, optionText, true, "" );
}
/*
========================
idMenuScreen_Shell_Root::GetRootIndex
========================
*/
int idMenuScreen_Shell_Root::GetRootIndex() {
if ( options != NULL ) {
return options->GetFocusIndex();
}
return 0;
}
/*
========================
idMenuScreen_Shell_Root::SetRootIndex
========================
*/
void idMenuScreen_Shell_Root::SetRootIndex( int index ) {
if ( options != NULL ) {
options->SetFocusIndex( index );
}
}
/*
========================
idMenuScreen_Shell_Root::HandleAction
========================
*/
bool idMenuScreen_Shell_Root::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_ROOT ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
session->MoveToPressStart();
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( menuData->GetPlatform() == 2 ) {
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( !shell ) {
return true;
}
idMenuWidget_MenuBar * menuBar = shell->GetMenuBar();
if ( !menuBar ) {
return true;
}
const idMenuWidget_MenuButton * buttonWidget = dynamic_cast< idMenuWidget_MenuButton * >( &menuBar->GetChildByIndex( menuBar->GetFocusIndex() ) );
if ( !buttonWidget ) {
return true;
}
idWidgetEvent pressEvent( WIDGET_EVENT_PRESS, 0, NULL, idSWFParmList() );
menuBar->ReceiveEvent( pressEvent );
return true;
}
break;
}
case WIDGET_ACTION_SCROLL_HORIZONTAL: {
if ( menuData->GetPlatform() != 2 ) {
return true;
}
idMenuHandler_Shell * shell = dynamic_cast< idMenuHandler_Shell * >( menuData );
if ( !shell ) {
return true;
}
idMenuWidget_MenuBar * menuBar = shell->GetMenuBar();
if ( !menuBar ) {
return true;
}
int index = menuBar->GetViewIndex();
const int dir = parms[0].ToInteger();
#ifdef ID_RETAIL
const int totalCount = menuBar->GetTotalNumberOfOptions() - 1;
#else
const int totalCount = menuBar->GetTotalNumberOfOptions();
#endif
index += dir;
if ( index < 0 ) {
index = totalCount - 1;
} else if ( index >= totalCount ) {
index = 0;
}
SetRootIndex( index );
menuBar->SetViewIndex( index );
menuBar->SetFocusIndex( index );
return true;
}
case WIDGET_ACTION_COMMAND: {
switch ( parms[0].ToInteger() ) {
case ROOT_CMD_START_DEMO: {
cmdSystem->AppendCommandText( va( "devmap %s %d\n", "demo/enpro_e3_2012", 1 ) );
break;
}
case ROOT_CMD_START_DEMO2: {
cmdSystem->AppendCommandText( va( "devmap %s %d\n", "game/le_hell", 2 ) );
break;
}
case ROOT_CMD_SETTINGS: {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
break;
}
case ROOT_CMD_QUIT: {
HandleExitGameBtn();
break;
}
case ROOT_CMD_DEV: {
menuData->SetNextScreen( SHELL_AREA_DEV, MENU_TRANSITION_SIMPLE );
break;
}
case ROOT_CMD_CAMPAIGN: {
menuData->SetNextScreen( SHELL_AREA_CAMPAIGN, MENU_TRANSITION_SIMPLE );
break;
}
case ROOT_CMD_MULTIPLAYER: {
const idLocalUser * masterUser = session->GetSignInManager().GetMasterLocalUser();
if ( masterUser == NULL ) {
break;
}
if ( masterUser->GetOnlineCaps() & CAP_BLOCKED_PERMISSION ) {
common->Dialog().AddDialog( GDM_ONLINE_INCORRECT_PERMISSIONS, DIALOG_CONTINUE, NULL, NULL, true, __FUNCTION__, __LINE__, false );
} else if ( !masterUser->CanPlayOnline() ) {
class idSWFScriptFunction_Accept : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Accept() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_PLAY_ONLINE_NO_PROFILE );
session->ShowOnlineSignin();
return idSWFScriptVar();
}
};
class idSWFScriptFunction_Cancel : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Cancel() { }
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_PLAY_ONLINE_NO_PROFILE );
return idSWFScriptVar();
}
};
common->Dialog().AddDialog( GDM_PLAY_ONLINE_NO_PROFILE, DIALOG_ACCEPT_CANCEL, new (TAG_SWF) idSWFScriptFunction_Accept(), new (TAG_SWF) idSWFScriptFunction_Cancel(), false );
} else {
idMatchParameters matchParameters;
matchParameters.matchFlags = DefaultPartyFlags;
session->CreatePartyLobby( matchParameters );
}
break;
}
case ROOT_CMD_PLAYSTATION: {
menuData->SetNextScreen( SHELL_AREA_PLAYSTATION, MENU_TRANSITION_SIMPLE );
break;
}
case ROOT_CMD_CREDITS: {
menuData->SetNextScreen( SHELL_AREA_CREDITS, MENU_TRANSITION_SIMPLE );
break;
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,494 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SAVE_OPTIONS = 10;
/*
========================
idMenuScreen_Shell_Save::Initialize
========================
*/
void idMenuScreen_Shell_Save::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuSave" );
saveInfo = new (TAG_SWF) idMenuWidget_Shell_SaveInfo();
saveInfo->SetSpritePath( GetSpritePath(), "info", "details" );
saveInfo->Initialize( data );
saveInfo->SetForSaveScreen( true );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SAVE_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
while ( options->GetChildren().Num() < NUM_SAVE_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->RegisterEventObserver( saveInfo );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
AddChild( options );
AddChild( saveInfo );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_pause_menu" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
btnDelete = new idMenuWidget_Button();
btnDelete->Initialize( data );
btnDelete->SetLabel( "" );
btnDelete->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_JOY3_ON_PRESS );
btnDelete->SetSpritePath( GetSpritePath(), "info", "btnDelete" );
AddChild( btnDelete );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Save::Update
========================
*/
void idMenuScreen_Shell_Save::Update() {
UpdateSaveEnumerations();
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_02179" ); // SAVE GAME
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Save::UpdateSaveEnumerations
========================
*/
void idMenuScreen_Shell_Save::UpdateSaveEnumerations() {
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
sortedSaves = saveGameInfo;
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > saveList;
int newSaveOffset = 1;
bool hasAutosave = false;
if ( session->GetSaveGameManager().IsWorking() ) {
idList< idStr > saveName;
saveName.Append( "#str_dlg_refreshing" );
saveList.Append( saveName );
if ( options != NULL ) {
options->SetListData( saveList );
options->Update();
}
} else {
for ( int i = 0; i < saveGameInfo.Num(); ++i ) {
if ( saveGameInfo[i].slotName.Icmp( "autosave" ) == 0 ) {
hasAutosave = true;
break;
}
}
if ( saveGameInfo.Num() == MAX_SAVEGAMES || ( !hasAutosave && saveGameInfo.Num() == MAX_SAVEGAMES - 1 ) ) {
newSaveOffset = 0;
}
if ( newSaveOffset != 0 ) {
idList< idStr > newSave;
newSave.Append( "#str_swf_new_save_game" );
saveList.Append( newSave );
}
if ( options != NULL ) {
sortedSaves.Sort( idSort_SavesByDate() );
for ( int slot = 0; slot < sortedSaves.Num(); ++slot ) {
const idSaveGameDetails & details = sortedSaves[slot];
if ( details.slotName.Icmp( "autosave" ) == 0 ) {
sortedSaves.RemoveIndex( slot );
slot--;
}
}
// +1 because the first item is "New Save"
saveList.SetNum( sortedSaves.Num() + newSaveOffset );
for ( int slot = 0; slot < sortedSaves.Num(); ++slot ) {
idStr & slotSaveName = saveList[ slot + newSaveOffset ].Alloc();
const idSaveGameDetails & details = sortedSaves[slot];
if ( details.damaged ) {
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_corrupt_file" ) );
} else if ( details.GetSaveVersion() > BUILD_NUMBER ) {
slotSaveName = va( S_COLOR_RED "%s", idLocalization::GetString( "#str_swf_wrong_version" ) );
} else {
if ( details.slotName.Icmp( "autosave" ) == 0 ) {
slotSaveName.Append( S_COLOR_YELLOW );
} else if ( details.slotName.Icmp( "quick" ) == 0 ) {
slotSaveName.Append( S_COLOR_ORANGE );
}
slotSaveName.Append( details.GetMapName() );
}
}
options->SetListData( saveList );
options->Update();
}
}
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395"; // BACK
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
if ( !session->GetSaveGameManager().IsWorking() ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_02179"; // SAVE GAME
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
if ( options != NULL ) {
if ( options->GetViewIndex() != 0 || ( options->GetViewIndex() == 0 && newSaveOffset == 0 ) ) {
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY3 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_02315"; // DELETE
}
buttonInfo->action.Set( WIDGET_ACTION_JOY3_ON_PRESS );
if ( btnDelete != NULL ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( btnDelete->BindSprite( root ) ) {
if ( menuData->GetPlatform() != 2 ) {
btnDelete->SetLabel( "" );
} else {
btnDelete->GetSprite()->SetVisible( true );
btnDelete->SetLabel( "#str_02315" );
}
}
btnDelete->Update();
}
} else {
if ( btnDelete != NULL ) {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( btnDelete->BindSprite( root ) ) {
btnDelete->SetLabel( "" );
btnDelete->Update();
}
}
}
}
}
cmdBar->Update();
}
}
if ( saveInfo != NULL ) {
saveInfo->Update();
}
if ( options != NULL && options->GetTotalNumberOfOptions() > 0 && options->GetViewIndex() >= options->GetTotalNumberOfOptions() ) {
options->SetViewIndex( options->GetTotalNumberOfOptions() - newSaveOffset );
if ( options->GetViewOffset() > options->GetViewIndex() ) {
options->SetViewOffset( options->GetViewIndex() );
}
options->SetFocusIndex( options->GetViewIndex() - options->GetViewOffset() );
}
}
/*
========================
idMenuScreen_Shell_Save::ShowScreen
========================
*/
void idMenuScreen_Shell_Save::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Save::HideScreen
========================
*/
void idMenuScreen_Shell_Save::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Save::SaveGame
========================
*/
void idMenuScreen_Shell_Save::SaveGame( int index ) {
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
int newSaveOffset = 1;
bool hasAutosave = false;
for ( int i = 0; i < saveGameInfo.Num(); ++i ) {
if ( saveGameInfo[i].slotName.Icmp( "autosave" ) == 0 ) {
hasAutosave = true;
break;
}
}
if ( saveGameInfo.Num() == MAX_SAVEGAMES || ( ( saveGameInfo.Num() == MAX_SAVEGAMES - 1 ) && !hasAutosave ) ) {
newSaveOffset = 0;
}
if ( index == 0 && newSaveOffset == 1 ) {
// New save...
// Scan all the savegames for the first doom3_xxx slot.
const idStr savePrefix = "doom3_";
uint64 slotMask = 0;
for ( int slot = 0; slot < saveGameInfo.Num(); ++slot ) {
const idSaveGameDetails & details = saveGameInfo[slot];
if ( details.slotName.Icmp( "autosave" ) == 0 ) {
continue;
}
idStr name = details.slotName;
name.ToLower(); // PS3 saves are uppercase ... we need to lower case-ify them for comparison here
name.StripLeading( savePrefix.c_str() );
if ( name.IsNumeric() ) {
int slotNumber = atoi( name.c_str() );
slotMask |= ( 1ULL << slotNumber );
}
}
int slotNumber = 0;
for ( slotNumber = 0; slotNumber < ( sizeof( slotMask ) * 8 ); slotNumber++ ) {
// If the slot isn't used, grab it
if ( !( slotMask & ( 1ULL << slotNumber ) ) ) {
break;
}
}
assert( slotNumber < ( sizeof( slotMask ) * 8 ) );
idStr name = va( "%s%d", savePrefix.c_str(), slotNumber );
cmdSystem->AppendCommandText( va( "savegame %s\n", name.c_str() ) );
// Throw up the saving message...
common->Dialog().ShowSaveIndicator( true );
} else {
class idSWFScriptFunction_OverwriteSave : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_OverwriteSave( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Save * _screen ) {
msg = _msg;
accept = _accept;
index = _index;
screen = _screen;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept && screen != NULL ) {
// Replace the save
if ( index < screen->GetSortedSaves().Num() ) {
idStr name = screen->GetSortedSaves()[ index ].slotName;
cmdSystem->AppendCommandText( va( "savegame %s\n", name.c_str() ) );
// Throw up the saving message...
common->Dialog().ShowSaveIndicator( true );
}
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
int index;
bool accept;
idMenuScreen_Shell_Save * screen;
};
if ( newSaveOffset == 1 ) {
index--;
}
common->Dialog().AddDialog( GDM_OVERWRITE_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_OverwriteSave( GDM_OVERWRITE_SAVE, true, index, this ), new idSWFScriptFunction_OverwriteSave( GDM_OVERWRITE_SAVE, false, index, this ), false );
}
}
/*
========================
idMenuScreen_Shell_Save::DeleteGame
========================
*/
void idMenuScreen_Shell_Save::DeleteGame( int index ) {
class idSWFScriptFunction_DeleteGame : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_DeleteGame( gameDialogMessages_t _msg, bool _accept, int _index, idMenuScreen_Shell_Save * _screen ) {
msg = _msg;
accept = _accept;
index = _index;
screen = _screen;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( accept && screen != NULL ) {
if ( index < screen->GetSortedSaves().Num() ) {
session->DeleteSaveGameSync( screen->GetSortedSaves()[ index ].slotName );
}
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
int index;
bool accept;
idMenuScreen_Shell_Save * screen;
};
bool hasAutosave = false;
const saveGameDetailsList_t & saveInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
for ( int i = 0; i < saveInfo.Num(); ++i ) {
if ( saveInfo[i].slotName.Icmp( "autosave" ) == 0 ) {
hasAutosave = true;
break;
}
}
if ( ( saveInfo.Num() < MAX_SAVEGAMES - 1 ) || ( ( saveInfo.Num() == MAX_SAVEGAMES - 1 ) && hasAutosave ) ) {
index--; // Subtract 1 from the index for 'New Game'
}
common->Dialog().AddDialog( GDM_DELETE_SAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, true, index, this ), new idSWFScriptFunction_DeleteGame( GDM_DELETE_SAVE, false, index, this ), false );
}
/*
========================
idMenuScreen_Shell_Save::HandleAction
========================
*/
bool idMenuScreen_Shell_Save::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_SAVE ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_JOY4_ON_PRESS: {
return true;
}
case WIDGET_ACTION_JOY3_ON_PRESS: {
if ( options == NULL ) {
return true;
}
DeleteGame( options->GetViewIndex() );
return true;
}
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
if ( session->GetSaveGameManager().IsWorking() ) {
return true;
}
if ( parms.Num() == 1 ) {
int selectionIndex = parms[0].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
return true;
}
}
SaveGame( options->GetViewIndex() );
return true;
}
case WIDGET_ACTION_SCROLL_VERTICAL: {
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,248 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SETTING_OPTIONS = 8;
enum settingMenuCmds_t {
SETTING_CMD_CONTROLS,
SETTING_CMD_GAMEPLAY,
SETTING_CMD_SYSTEM,
SETTING_CMD_3D,
};
/*
========================
idMenuScreen_Shell_Settings::Initialize
========================
*/
void idMenuScreen_Shell_Settings::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuSettings" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
option.Append( "#str_04158" ); // controls
menuOptions.Append( option );
option.Clear();
option.Append( "#str_02401" ); // game options
menuOptions.Append( option );
option.Clear();
option.Append( "#str_04160" ); // system
menuOptions.Append( option );
option.Clear();
if ( renderSystem->IsStereoScopicRenderingSupported() ) {
option.Append( "#str_swf_stereoscopics" ); // Stereoscopic Rendering
menuOptions.Append( option );
}
options->SetListData( menuOptions );
options->SetNumVisibleOptions( NUM_SETTING_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
const char * tips[] = { "#str_02166", "#str_02168", "#str_02170", "#str_swf_customize_3d" };
while ( options->GetChildren().Num() < NUM_SETTING_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->Initialize( data );
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, options->GetChildren().Num() );
if ( options->GetChildren().Num() < menuOptions.Num() ) {
buttonWidget->SetDescription( tips[options->GetChildren().Num()] );
}
buttonWidget->RegisterEventObserver( helpWidget );
options->AddChild( buttonWidget );
}
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
idMenuHandler_Shell * handler = dynamic_cast< idMenuHandler_Shell * >( data );
if ( handler != NULL && handler->GetInGame() ) {
btnBack->SetLabel( "#str_swf_pause_menu" );
} else {
btnBack->SetLabel( "#str_02305" );
}
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Settings::Update
========================
*/
void idMenuScreen_Shell_Settings::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_settings" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Settings::ShowScreen
========================
*/
void idMenuScreen_Shell_Settings::ShowScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Settings::HideScreen
========================
*/
void idMenuScreen_Shell_Settings::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Settings::HandleAction h
========================
*/
bool idMenuScreen_Shell_Settings::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_SETTINGS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_COMMAND: {
switch ( parms[0].ToInteger() ) {
case SETTING_CMD_CONTROLS: {
menuData->SetNextScreen( SHELL_AREA_CONTROLS, MENU_TRANSITION_SIMPLE );
break;
}
case SETTING_CMD_GAMEPLAY: {
menuData->SetNextScreen( SHELL_AREA_GAME_OPTIONS, MENU_TRANSITION_SIMPLE );
break;
}
case SETTING_CMD_SYSTEM: {
menuData->SetNextScreen( SHELL_AREA_SYSTEM_OPTIONS, MENU_TRANSITION_SIMPLE );
break;
}
case SETTING_CMD_3D: {
menuData->SetNextScreen( SHELL_AREA_STEREOSCOPICS, MENU_TRANSITION_SIMPLE );
break;
}
}
if ( options != NULL ) {
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options->GetFocusIndex() != selectionIndex ) {
options->SetFocusIndex( selectionIndex );
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,314 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SINGLEPLAYER_OPTIONS = 8;
/*
========================
idMenuScreen_Shell_Singleplayer::Initialize
========================
*/
void idMenuScreen_Shell_Singleplayer::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuCampaign" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SINGLEPLAYER_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
AddChild( options );
idMenuWidget_Help * const helpWidget = new ( TAG_SWF ) idMenuWidget_Help();
helpWidget->SetSpritePath( GetSpritePath(), "info", "helpTooltip" );
AddChild( helpWidget );
while ( options->GetChildren().Num() < NUM_SINGLEPLAYER_OPTIONS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
buttonWidget->RegisterEventObserver( helpWidget );
buttonWidget->Initialize( data );
options->AddChild( buttonWidget );
}
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_02305" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_Singleplayer::Update
========================
*/
void idMenuScreen_Shell_Singleplayer::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_SWF_SELECT";
}
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_campaign" );
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Singleplayer::ShowScreen
========================
*/
void idMenuScreen_Shell_Singleplayer::ShowScreen( const mainMenuTransition_t transitionType ) {
idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > menuOptions;
idList< idStr > option;
canContinue = false;
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
canContinue = ( saveGameInfo.Num() > 0 );
if ( canContinue ) {
option.Append( "#str_swf_continue_game" ); // continue game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_01866" ); // new game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_01867" ); // load game
menuOptions.Append( option );
int index = 0;
idMenuWidget_Button * buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_swf_continue_desc" );
}
index++;
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02209" );
}
index++;
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02213" );
}
index++;
} else {
option.Append( "#str_01866" ); // new game
menuOptions.Append( option );
option.Clear();
option.Append( "#str_01867" ); // load game
menuOptions.Append( option );
if ( options != NULL ) {
int index = 0;
idMenuWidget_Button * buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02209" );
}
index++;
buttonWidget = dynamic_cast< idMenuWidget_Button * >( &options->GetChildByIndex( index ) );
if ( buttonWidget != NULL ) {
buttonWidget->SetDescription( "#str_02213" );
}
}
}
if ( options != NULL ) {
options->SetListData( menuOptions );
}
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Singleplayer::HideScreen
========================
*/
void idMenuScreen_Shell_Singleplayer::HideScreen( const mainMenuTransition_t transitionType ) {
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Singleplayer::ContinueGame
========================
*/
void idMenuScreen_Shell_Singleplayer::ContinueGame() {
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
saveGameDetailsList_t sortedSaves = saveGameInfo;
sortedSaves.Sort( idSort_SavesByDate() );
if ( sortedSaves.Num() > 0 ) {
if ( sortedSaves[0].damaged ) {
class idSWFScriptFunction_ContinueDamaged : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_CORRUPT_CONTINUE );
return idSWFScriptVar();
}
};
idStaticList< idSWFScriptFunction *, 4 > callbacks;
callbacks.Append( new (TAG_SWF) idSWFScriptFunction_ContinueDamaged() );
idStaticList< idStrId, 4 > optionText;
optionText.Append( idStrId( "#str_04339" ) ); // OK
common->Dialog().AddDynamicDialog( GDM_CORRUPT_CONTINUE, callbacks, optionText, false, "" );
} else {
const idStr & name = sortedSaves[ 0 ].slotName;
cmdSystem->AppendCommandText( va( "loadgame %s\n", name.c_str() ) );
}
}
}
/*
========================
idMenuScreen_Shell_Singleplayer::HandleAction
========================
*/
bool idMenuScreen_Shell_Singleplayer::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_CAMPAIGN ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
menuData->SetNextScreen( SHELL_AREA_ROOT, MENU_TRANSITION_SIMPLE );
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetViewIndex();
if ( parms.Num() == 1 ) {
selectionIndex = parms[0].ToInteger();
}
canContinue = false;
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
canContinue = ( saveGameInfo.Num() > 0 );
if ( canContinue ) {
if ( selectionIndex == 0 ) {
ContinueGame();
} else if ( selectionIndex == 1 ) {
class idSWFScriptFunction_NewGame : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_NewGame( idMenuHandler * _menuData, bool _accept ) {
menuData = _menuData;
accept = _accept;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( GDM_DELETE_AUTOSAVE );
if ( accept ) {
menuData->SetNextScreen( SHELL_AREA_NEW_GAME, MENU_TRANSITION_SIMPLE );
}
return idSWFScriptVar();
}
private:
idMenuHandler * menuData;
bool accept;
};
common->Dialog().AddDialog( GDM_DELETE_AUTOSAVE, DIALOG_ACCEPT_CANCEL, new idSWFScriptFunction_NewGame( menuData, true ), new idSWFScriptFunction_NewGame( menuData, false ), true );
} else if ( selectionIndex == 2 ) {
menuData->SetNextScreen( SHELL_AREA_LOAD, MENU_TRANSITION_SIMPLE );
}
} else {
if ( selectionIndex == 0 ) {
menuData->SetNextScreen( SHELL_AREA_NEW_GAME, MENU_TRANSITION_SIMPLE );
} else if ( selectionIndex == 1 ) {
menuData->SetNextScreen( SHELL_AREA_LOAD, MENU_TRANSITION_SIMPLE );
}
}
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}

View File

@@ -0,0 +1,422 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SYSTEM_OPTIONS_OPTIONS = 4;
// TRC requires a maximum interoccular distance of 6.5cm even though human adults can easily have an interoccular distance of over 7.5cm
const static float MAX_INTEROCCULAR_DISTANCE = 6.5f;
// This should line up with stereo3DMode_t
static const char * stereoRender_enable_text[] = {
"#str_00641",
"#str_swf_stereo_side_by_side",
"#str_swf_stereo_top_and_bottom",
"#str_swf_stereo_side_by_side_full",
"#str_swf_stereo_interlaced",
"#str_swf_stereo_quad"
};
static const int NUM_STEREO_ENABLE = sizeof( stereoRender_enable_text ) / sizeof( stereoRender_enable_text[0] );
/*
========================
idMenuScreen_Shell_Stereoscopics::Initialize
========================
*/
void idMenuScreen_Shell_Stereoscopics::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuStereoscopics" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SYSTEM_OPTIONS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
AddChild( options );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_settings" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_swf_stereoscopic_rendering" ); // Stereoscopics
control->SetDataSource( &stereoData, idMenuDataSource_StereoSettings::STEREO_FIELD_ENABLE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_stereo_seperation" ); // View Offset
control->SetDataSource( &stereoData, idMenuDataSource_StereoSettings::STEREO_FIELD_SEPERATION );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TOGGLE );
control->SetLabel( "#str_swf_stereo_eye_swap" ); // Swap Eyes
control->SetDataSource( &stereoData, idMenuDataSource_StereoSettings::STEREO_FIELD_SWAP_EYES );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PRESS_FOCUSED, options->GetChildren().Num() );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
leftEyeMat = declManager->FindMaterial( "doomLeftEye" );
rightEyeMat = declManager->FindMaterial( "doomRightEye" );
}
/*
========================
idMenuScreen_Shell_Stereoscopics::Update
========================
*/
void idMenuScreen_Shell_Stereoscopics::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_swf_stereoscopics_heading" ); // STEREOSCOPIC RENDERING
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_Stereoscopics::ShowScreen
========================
*/
void idMenuScreen_Shell_Stereoscopics::ShowScreen( const mainMenuTransition_t transitionType ) {
stereoData.LoadData();
idMenuScreen::ShowScreen( transitionType );
if ( GetSprite() != NULL ) {
idSWFSpriteInstance * leftEye = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "leftEye" );
idSWFSpriteInstance * rightEye = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "rightEye" );
if ( leftEye != NULL && leftEyeMat != NULL ) {
leftEye->SetMaterial( leftEyeMat );
}
if ( rightEye != NULL && rightEyeMat != NULL ) {
rightEye->SetMaterial( rightEyeMat );
}
}
}
/*
========================
idMenuScreen_Shell_Stereoscopics::HideScreen
========================
*/
void idMenuScreen_Shell_Stereoscopics::HideScreen( const mainMenuTransition_t transitionType ) {
if ( stereoData.IsRestartRequired() ) {
class idSWFScriptFunction_Restart : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Restart( gameDialogMessages_t _msg, bool _restart ) {
msg = _msg;
restart = _restart;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( restart ) {
idStr cmdLine = Sys_GetCmdLine();
if ( cmdLine.Find( "com_skipIntroVideos" ) < 0 ) {
cmdLine.Append( " +set com_skipIntroVideos 1" );
}
Sys_ReLaunch( (void*)cmdLine.c_str(), cmdLine.Length() );
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
bool restart;
};
idStaticList<idSWFScriptFunction *, 4> callbacks;
idStaticList<idStrId, 4> optionText;
callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, false ) );
callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, true ) );
optionText.Append( idStrId( "#str_00100113" ) ); // Continue
optionText.Append( idStrId( "#str_02487" ) ); // Restart Now
common->Dialog().AddDynamicDialog( GDM_GAME_RESTART_REQUIRED, callbacks, optionText, true, idStr() );
}
if ( stereoData.IsDataChanged() ) {
stereoData.CommitData();
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_Stereoscopics::HandleAction h
========================
*/
bool idMenuScreen_Shell_Stereoscopics::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData != NULL ) {
if ( menuData->ActiveScreen() != SHELL_AREA_STEREOSCOPICS ) {
return false;
}
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
if ( menuData != NULL ) {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
}
return true;
}
case WIDGET_ACTION_PRESS_FOCUSED: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
stereoData.AdjustField( selectionIndex, 1 );
options->Update();
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
extern idCVar stereoRender_interOccularCentimeters;
extern idCVar stereoRender_swapEyes;
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::idMenuDataSource_StereoSettings
========================
*/
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::idMenuDataSource_StereoSettings() {
fields.SetNum( MAX_STEREO_FIELDS );
originalFields.SetNum( MAX_STEREO_FIELDS );
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData
========================
*/
void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::LoadData() {
fields[ STEREO_FIELD_ENABLE ].SetInteger( renderSystem->GetStereoScopicRenderingMode() );
fields[ STEREO_FIELD_SEPERATION ].SetFloat( 100.0f * ( stereoRender_interOccularCentimeters.GetFloat() / MAX_INTEROCCULAR_DISTANCE ) );
fields[ STEREO_FIELD_SWAP_EYES ].SetBool( stereoRender_swapEyes.GetBool() );
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::CommitData
========================
*/
void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::CommitData() {
if ( IsDataChanged() ) {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
}
// make the committed fields into the backup fields
originalFields = fields;
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::AdjustField
========================
*/
void idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
if ( fieldIndex == STEREO_FIELD_ENABLE ) {
int numOptions = NUM_STEREO_ENABLE;
if ( !renderSystem->HasQuadBufferSupport() ) {
numOptions--;
}
int adjusted = fields[ fieldIndex ].ToInteger() + adjustAmount;
adjusted += numOptions;
adjusted %= numOptions;
fields[fieldIndex].SetInteger( adjusted );
renderSystem->EnableStereoScopicRendering( (stereo3DMode_t)adjusted );
gameLocal.Shell_ClearRepeater();
} else if ( fieldIndex == STEREO_FIELD_SWAP_EYES ) {
fields[ fieldIndex ].SetBool( !fields[ fieldIndex ].ToBool() );
stereoRender_swapEyes.SetBool( fields[ fieldIndex ].ToBool() );
} else if ( fieldIndex == STEREO_FIELD_SEPERATION ) {
float newValue = idMath::ClampFloat( 0.0f, 100.0f, fields[ fieldIndex ].ToFloat() + adjustAmount );
fields[ fieldIndex ].SetFloat( newValue );
stereoRender_interOccularCentimeters.SetFloat( ( fields[ STEREO_FIELD_SEPERATION ].ToFloat() / 100.0f ) * MAX_INTEROCCULAR_DISTANCE );
}
// do this so we don't save every time we modify a setting. Only save once when we leave the screen
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsDataChanged
========================
*/
idSWFScriptVar idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::GetField( const int fieldIndex ) const {
if ( fieldIndex == STEREO_FIELD_ENABLE ) {
return idSWFScriptVar( stereoRender_enable_text[fields[fieldIndex].ToInteger()] );
}
return fields[ fieldIndex ];
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsDataChanged() const {
if ( fields[ STEREO_FIELD_SWAP_EYES ].ToBool() != originalFields[ STEREO_FIELD_SWAP_EYES ].ToBool() ) {
return true;
}
if ( fields[ STEREO_FIELD_ENABLE ].ToInteger() != originalFields[ STEREO_FIELD_ENABLE ].ToInteger() ) {
return true;
}
if ( fields[ STEREO_FIELD_SEPERATION ].ToFloat() != originalFields[ STEREO_FIELD_SEPERATION ].ToFloat() ) {
return true;
}
return false;
}
/*
========================
idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestartRequired
========================
*/
bool idMenuScreen_Shell_Stereoscopics::idMenuDataSource_StereoSettings::IsRestartRequired() const {
if ( fields[ STEREO_FIELD_ENABLE ].ToInteger() != originalFields[ STEREO_FIELD_ENABLE ].ToInteger() ) {
if ( fields[ STEREO_FIELD_ENABLE ].ToInteger() == STEREO3D_QUAD_BUFFER || originalFields[ STEREO_FIELD_ENABLE ].ToInteger() == STEREO3D_QUAD_BUFFER ) {
return true;
}
}
return false;
}

View File

@@ -0,0 +1,549 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
const static int NUM_SYSTEM_OPTIONS_OPTIONS = 8;
extern idCVar r_multiSamples;
extern idCVar r_motionBlur;
extern idCVar r_swapInterval;
extern idCVar s_volume_dB;
extern idCVar r_lightScale;
/*
========================
idMenuScreen_Shell_SystemOptions::Initialize
========================
*/
void idMenuScreen_Shell_SystemOptions::Initialize( idMenuHandler * data ) {
idMenuScreen::Initialize( data );
if ( data != NULL ) {
menuGUI = data->GetGUI();
}
SetSpritePath( "menuSystemOptions" );
options = new (TAG_SWF) idMenuWidget_DynamicList();
options->SetNumVisibleOptions( NUM_SYSTEM_OPTIONS_OPTIONS );
options->SetSpritePath( GetSpritePath(), "info", "options" );
options->SetWrappingAllowed( true );
options->SetControlList( true );
options->Initialize( data );
btnBack = new (TAG_SWF) idMenuWidget_Button();
btnBack->Initialize( data );
btnBack->SetLabel( "#str_swf_settings" );
btnBack->SetSpritePath( GetSpritePath(), "info", "btnBack" );
btnBack->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_GO_BACK );
AddChild( options );
AddChild( btnBack );
idMenuWidget_ControlButton * control;
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_02154" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_FULLSCREEN );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_FULLSCREEN );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_swf_framerate" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_FRAMERATE );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_FRAMERATE );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_04126" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_VSYNC );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_VSYNC );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_04128" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_ANTIALIASING );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_ANTIALIASING );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_TEXT );
control->SetLabel( "#str_swf_motionblur" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_MOTIONBLUR );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_MOTIONBLUR );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_swf_lodbias" );
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_LODBIAS );
control->SetupEvents( DEFAULT_REPEAT_TIME, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_LODBIAS );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_02155" ); // Brightness
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_BRIGHTNESS );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_BRIGHTNESS );
options->AddChild( control );
control = new (TAG_SWF) idMenuWidget_ControlButton();
control->SetOptionType( OPTION_SLIDER_BAR );
control->SetLabel( "#str_02163" ); // Volume
control->SetDataSource( &systemData, idMenuDataSource_SystemSettings::SYSTEM_FIELD_VOLUME );
control->SetupEvents( 2, options->GetChildren().Num() );
control->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_COMMAND, idMenuDataSource_SystemSettings::SYSTEM_FIELD_VOLUME );
options->AddChild( control );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_DOWN_START_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_SCROLL_UP_START_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_DOWN_LSTICK_RELEASE ) );
options->AddEventAction( WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ).Set( new (TAG_SWF) idWidgetActionHandler( options, WIDGET_ACTION_EVENT_STOP_REPEATER, WIDGET_EVENT_SCROLL_UP_LSTICK_RELEASE ) );
}
/*
========================
idMenuScreen_Shell_SystemOptions::Update
========================
*/
void idMenuScreen_Shell_SystemOptions::Update() {
if ( menuData != NULL ) {
idMenuWidget_CommandBar * cmdBar = menuData->GetCmdBar();
if ( cmdBar != NULL ) {
cmdBar->ClearAllButtons();
idMenuWidget_CommandBar::buttonInfo_t * buttonInfo;
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY2 );
if ( menuData->GetPlatform() != 2 ) {
buttonInfo->label = "#str_00395";
}
buttonInfo->action.Set( WIDGET_ACTION_GO_BACK );
buttonInfo = cmdBar->GetButton( idMenuWidget_CommandBar::BUTTON_JOY1 );
buttonInfo->action.Set( WIDGET_ACTION_PRESS_FOCUSED );
}
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
idSWFTextInstance * heading = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtHeading" );
if ( heading != NULL ) {
heading->SetText( "#str_00183" ); // FULLSCREEN
heading->SetStrokeInfo( true, 0.75f, 1.75f );
}
idSWFSpriteInstance * gradient = GetSprite()->GetScriptObject()->GetNestedSprite( "info", "gradient" );
if ( gradient != NULL && heading != NULL ) {
gradient->SetXPos( heading->GetTextLength() );
}
}
if ( btnBack != NULL ) {
btnBack->BindSprite( root );
}
idMenuScreen::Update();
}
/*
========================
idMenuScreen_Shell_SystemOptions::ShowScreen
========================
*/
void idMenuScreen_Shell_SystemOptions::ShowScreen( const mainMenuTransition_t transitionType ) {
systemData.LoadData();
idMenuScreen::ShowScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_SystemOptions::HideScreen
========================
*/
void idMenuScreen_Shell_SystemOptions::HideScreen( const mainMenuTransition_t transitionType ) {
if ( systemData.IsRestartRequired() ) {
class idSWFScriptFunction_Restart : public idSWFScriptFunction_RefCounted {
public:
idSWFScriptFunction_Restart( gameDialogMessages_t _msg, bool _restart ) {
msg = _msg;
restart = _restart;
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
common->Dialog().ClearDialog( msg );
if ( restart ) {
idStr cmdLine = Sys_GetCmdLine();
if ( cmdLine.Find( "com_skipIntroVideos" ) < 0 ) {
cmdLine.Append( " +set com_skipIntroVideos 1" );
}
Sys_ReLaunch( (void*)cmdLine.c_str(), cmdLine.Length() );
}
return idSWFScriptVar();
}
private:
gameDialogMessages_t msg;
bool restart;
};
idStaticList<idSWFScriptFunction *, 4> callbacks;
idStaticList<idStrId, 4> optionText;
callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, false ) );
callbacks.Append( new idSWFScriptFunction_Restart( GDM_GAME_RESTART_REQUIRED, true ) );
optionText.Append( idStrId( "#str_00100113" ) ); // Continue
optionText.Append( idStrId( "#str_02487" ) ); // Restart Now
common->Dialog().AddDynamicDialog( GDM_GAME_RESTART_REQUIRED, callbacks, optionText, true, idStr() );
}
if ( systemData.IsDataChanged() ) {
systemData.CommitData();
}
idMenuScreen::HideScreen( transitionType );
}
/*
========================
idMenuScreen_Shell_SystemOptions::HandleAction h
========================
*/
bool idMenuScreen_Shell_SystemOptions::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
if ( menuData == NULL ) {
return true;
}
if ( menuData->ActiveScreen() != SHELL_AREA_SYSTEM_OPTIONS ) {
return false;
}
widgetAction_t actionType = action.GetType();
const idSWFParmList & parms = action.GetParms();
switch ( actionType ) {
case WIDGET_ACTION_GO_BACK: {
if ( menuData != NULL ) {
menuData->SetNextScreen( SHELL_AREA_SETTINGS, MENU_TRANSITION_SIMPLE );
}
return true;
}
case WIDGET_ACTION_ADJUST_FIELD:
if ( widget->GetDataSourceFieldIndex() == idMenuDataSource_SystemSettings::SYSTEM_FIELD_FULLSCREEN ) {
menuData->SetNextScreen( SHELL_AREA_RESOLUTION, MENU_TRANSITION_SIMPLE );
return true;
}
break;
case WIDGET_ACTION_COMMAND: {
if ( options == NULL ) {
return true;
}
int selectionIndex = options->GetFocusIndex();
if ( parms.Num() > 0 ) {
selectionIndex = parms[0].ToInteger();
}
if ( options && selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
switch ( parms[0].ToInteger() ) {
case idMenuDataSource_SystemSettings::SYSTEM_FIELD_FULLSCREEN: {
menuData->SetNextScreen( SHELL_AREA_RESOLUTION, MENU_TRANSITION_SIMPLE );
return true;
}
default: {
systemData.AdjustField( parms[0].ToInteger(), 1 );
options->Update();
}
}
return true;
}
case WIDGET_ACTION_START_REPEATER: {
if ( options == NULL ) {
return true;
}
if ( parms.Num() == 4 ) {
int selectionIndex = parms[3].ToInteger();
if ( selectionIndex != options->GetFocusIndex() ) {
options->SetViewIndex( options->GetViewOffset() + selectionIndex );
options->SetFocusIndex( selectionIndex );
}
}
break;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/////////////////////////////////
// SCREEN SETTINGS
/////////////////////////////////
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::idMenuDataSource_SystemSettings
========================
*/
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::idMenuDataSource_SystemSettings() {
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData
========================
*/
void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::LoadData() {
originalFramerate = com_engineHz.GetInteger();
originalAntialias = r_multiSamples.GetInteger();
originalMotionBlur = r_motionBlur.GetInteger();
originalVsync = r_swapInterval.GetInteger();
originalBrightness = r_lightScale.GetFloat();
originalVolume = s_volume_dB.GetFloat();
const int fullscreen = r_fullscreen.GetInteger();
if ( fullscreen > 0 ) {
R_GetModeListForDisplay( fullscreen - 1, modeList );
} else {
modeList.Clear();
}
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsRestartRequired
========================
*/
bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsRestartRequired() const {
if ( originalAntialias != r_multiSamples.GetInteger() ) {
return true;
}
if ( originalFramerate != com_engineHz.GetInteger() ) {
return true;
}
return false;
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::CommitData
========================
*/
void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::CommitData() {
cvarSystem->SetModifiedFlags( CVAR_ARCHIVE );
}
/*
========================
AdjustOption
Given a current value in an array of possible values, returns the next n value
========================
*/
int AdjustOption( int currentValue, const int values[], int numValues, int adjustment ) {
int index = 0;
for ( int i = 0; i < numValues; i++ ) {
if ( currentValue == values[i] ) {
index = i;
break;
}
}
index += adjustment;
while ( index < 0 ) {
index += numValues;
}
index %= numValues;
return values[index];
}
/*
========================
LinearAdjust
Linearly converts a float from one scale to another
========================
*/
float LinearAdjust( float input, float currentMin, float currentMax, float desiredMin, float desiredMax ) {
return ( ( input - currentMin ) / ( currentMax - currentMin ) ) * ( desiredMax - desiredMin ) + desiredMin;
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField
========================
*/
void idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::AdjustField( const int fieldIndex, const int adjustAmount ) {
switch ( fieldIndex ) {
case SYSTEM_FIELD_FRAMERATE: {
static const int numValues = 2;
static const int values[numValues] = { 60, 120 };
com_engineHz.SetInteger( AdjustOption( com_engineHz.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_VSYNC: {
static const int numValues = 3;
static const int values[numValues] = { 0, 1, 2 };
r_swapInterval.SetInteger( AdjustOption( r_swapInterval.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_ANTIALIASING: {
static const int numValues = 5;
static const int values[numValues] = { 0, 2, 4, 8, 16 };
r_multiSamples.SetInteger( AdjustOption( r_multiSamples.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_MOTIONBLUR: {
static const int numValues = 5;
static const int values[numValues] = { 0, 2, 3, 4, 5 };
r_motionBlur.SetInteger( AdjustOption( r_motionBlur.GetInteger(), values, numValues, adjustAmount ) );
break;
}
case SYSTEM_FIELD_LODBIAS: {
const float percent = LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
const float adjusted = percent + (float)adjustAmount * 5.0f;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
r_lodBias.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, -1.0f, 1.0f ) );
break;
}
case SYSTEM_FIELD_BRIGHTNESS: {
const float percent = LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f );
const float adjusted = percent + (float)adjustAmount;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
r_lightScale.SetFloat( LinearAdjust( clamped, 0.0f, 100.0f, 2.0f, 4.0f ) );
break;
}
case SYSTEM_FIELD_VOLUME: {
const float percent = 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) );
const float adjusted = percent + (float)adjustAmount;
const float clamped = idMath::ClampFloat( 0.0f, 100.0f, adjusted );
s_volume_dB.SetFloat( DB_SILENCE - ( idMath::Sqrt( clamped / 100.0f ) * DB_SILENCE ) );
break;
}
}
cvarSystem->ClearModifiedFlags( CVAR_ARCHIVE );
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField
========================
*/
idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField( const int fieldIndex ) const {
switch ( fieldIndex ) {
case SYSTEM_FIELD_FULLSCREEN: {
const int fullscreen = r_fullscreen.GetInteger();
const int vidmode = r_vidMode.GetInteger();
if ( fullscreen == 0 ) {
return "#str_swf_disabled";
}
if ( fullscreen < 0 || vidmode < 0 || vidmode >= modeList.Num() ) {
return "???";
}
if ( modeList[vidmode].displayHz == 60 ) {
return va( "%4i x %4i", modeList[vidmode].width, modeList[vidmode].height );
} else {
return va( "%4i x %4i @ %dhz", modeList[vidmode].width, modeList[vidmode].height, modeList[vidmode].displayHz );
}
}
case SYSTEM_FIELD_FRAMERATE:
return va( "%d FPS", com_engineHz.GetInteger() );
case SYSTEM_FIELD_VSYNC:
if ( r_swapInterval.GetInteger() == 1 ) {
return "#str_swf_smart";
} else if ( r_swapInterval.GetInteger() == 2 ) {
return "#str_swf_enabled";
} else {
return "#str_swf_disabled";
}
case SYSTEM_FIELD_ANTIALIASING:
if ( r_multiSamples.GetInteger() == 0 ) {
return "#str_swf_disabled";
}
return va( "%dx", r_multiSamples.GetInteger() );
case SYSTEM_FIELD_MOTIONBLUR:
if ( r_motionBlur.GetInteger() == 0 ) {
return "#str_swf_disabled";
}
return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) );
case SYSTEM_FIELD_LODBIAS:
return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f );
case SYSTEM_FIELD_BRIGHTNESS:
return LinearAdjust( r_lightScale.GetFloat(), 2.0f, 4.0f, 0.0f, 100.0f );
case SYSTEM_FIELD_VOLUME: {
return 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) );
}
}
return false;
}
/*
========================
idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataChanged
========================
*/
bool idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::IsDataChanged() const {
if ( originalFramerate != com_engineHz.GetInteger() ) {
return true;
}
if ( originalAntialias != r_multiSamples.GetInteger() ) {
return true;
}
if ( originalMotionBlur != r_motionBlur.GetInteger() ) {
return true;
}
if ( originalVsync != r_swapInterval.GetInteger() ) {
return true;
}
if ( originalBrightness != r_lightScale.GetFloat() ) {
return true;
}
if ( originalVolume != s_volume_dB.GetFloat() ) {
return true;
}
return false;
}

View File

@@ -0,0 +1,545 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget::idMenuWidget
========================
*/
idMenuWidget::idMenuWidget() :
boundSprite( NULL ),
parent( NULL ),
dataSource( NULL ),
dataSourceFieldIndex( 0 ),
focusIndex( 0 ),
widgetState( WIDGET_STATE_NORMAL ),
menuData( NULL ),
swfObj( NULL ),
handlerIsParent( false ),
refCount( 0 ),
noAutoFree( false ) {
eventActionLookup.SetNum( eventActionLookup.Max() );
for ( int i = 0; i < eventActionLookup.Num(); ++i ) {
eventActionLookup[ i ] = INVALID_ACTION_INDEX;
}
}
/*
========================
idMenuWidget::~idMenuWidget
========================
*/
idMenuWidget::~idMenuWidget() {
Cleanup();
}
void idMenuWidget::Cleanup() {
for ( int j = 0; j < observers.Num(); ++j ) {
assert( observers[j]->refCount > 0 );
observers[ j ]->Release();
}
observers.Clear();
// free all children
for ( int i = 0; i < children.Num(); ++i ) {
assert( children[i]->refCount > 0 );
children[ i ]->Release();
}
children.Clear();
}
/*
========================
idMenuWidget::AddChild
========================
*/
void idMenuWidget::AddChild( idMenuWidget * widget ) {
if ( !verify( children.Find( widget ) == NULL ) ) {
return; // attempt to add a widget that was already in the list
}
if ( widget->GetParent() != NULL ) {
// take out of previous parent
widget->GetParent()->RemoveChild( widget );
}
widget->AddRef();
widget->SetParent( this );
children.Append( widget );
}
/*
========================
idMenuWidget::RemoveAllChildren
========================
*/
void idMenuWidget::RemoveAllChildren() {
for ( int i = 0; i < children.Num(); ++ i ) {
assert( children[ i ]->GetParent() == this );
children[ i ]->SetParent( NULL );
children[ i ]->Release();
}
children.Clear();
}
/*
========================
idMenuWidget::RemoveChild
========================
*/
void idMenuWidget::RemoveChild( idMenuWidget * widget ) {
assert( widget->GetParent() == this );
children.Remove( widget );
widget->SetParent( NULL );
widget->Release();
}
/*
========================
idMenuWidget::RemoveChild
========================
*/
bool idMenuWidget::HasChild( idMenuWidget * widget ) {
for ( int i = 0; i < children.Num(); ++ i ) {
if ( children[ i ] == widget ) {
return true;
}
}
return false;
}
/*
========================
idMenuWidget::ReceiveEvent
Events received through this function are passed to the innermost focused widget first, and then
propagates back through each widget within the focus chain. The first widget that handles the
event will stop propagation.
Each widget along the way will fire off an event to its observers, whether or not it actually
handles the event.
Note: How the focus chain is calculated:
Descend through GetFocus() calls until you reach a NULL focus. The terminating widget is the
innermost widget, while *this* widget is the outermost widget.
========================
*/
void idMenuWidget::ReceiveEvent( const idWidgetEvent & event ) {
idStaticList< idMenuWidget *, 16 > focusChain;
int focusRunawayCounter = focusChain.Max();
idMenuWidget * focusedWidget = this;
while ( focusedWidget != NULL && --focusRunawayCounter != 0 ) {
focusChain.Append( focusedWidget );
focusedWidget = focusedWidget->GetFocus();
}
// If hitting this then more than likely you have a self-referential chain. If that's not
// the case, then you may need to increase the size of the focusChain list.
assert( focusRunawayCounter != 0 );
for ( int focusIndex = focusChain.Num() - 1; focusIndex >= 0; --focusIndex ) {
idMenuWidget * const focusedWidget = focusChain[ focusIndex ];
if ( focusedWidget->ExecuteEvent( event ) ) {
break; // this widget has handled the event, so stop propagation
}
}
}
/*
========================
idMenuWidget::ExecuteEvent
Handles the event directly, and doesn't pass it through the focus chain.
This should only be used in very specific circumstances! Most events should go to the focus.
========================
*/
bool idMenuWidget::ExecuteEvent( const idWidgetEvent & event ) {
idList< idWidgetAction, TAG_IDLIB_LIST_MENU > * const actions = GetEventActions( event.type );
if ( actions != NULL ) {
for ( int actionIndex = 0; actionIndex < actions->Num(); ++actionIndex ) {
HandleAction( ( *actions )[ actionIndex ], event, this );
}
}
SendEventToObservers( event );
return actions != NULL && actions->Num() > 0;
}
/*
========================
idMenuWidget::SendEventToObservers
Sends an event to all the observers
========================
*/
void idMenuWidget::SendEventToObservers( const idWidgetEvent & event ) {
for ( int i = 0; i < observers.Num(); ++i ) {
observers[ i ]->ObserveEvent( *this, event );
}
}
/*
========================
idMenuWidget::RegisterEventObserver
Adds an observer to our observers list
========================
*/
void idMenuWidget::RegisterEventObserver( idMenuWidget * observer ) {
if ( !verify( observers.Find( observer ) == NULL ) ) {
return;
}
observer->AddRef();
observers.Append( observer );
}
/*
========================
idMenuWidget::SetSpritePath
========================
*/
void idMenuWidget::SetSpritePath( const char * arg1, const char * arg2, const char * arg3, const char * arg4, const char * arg5 ) {
const char * args[] = { arg1, arg2, arg3, arg4, arg5 };
const int numArgs = sizeof( args ) / sizeof( args[ 0 ] );
spritePath.Clear();
for ( int i = 0; i < numArgs; ++i ) {
if ( args[ i ] == NULL ) {
break;
}
spritePath.Append( args[ i ] );
}
}
/*
========================
idMenuWidget::SetSpritePath
========================
*/
void idMenuWidget::SetSpritePath( const idList< idStr > & spritePath_, const char * arg1, const char * arg2, const char * arg3, const char * arg4, const char * arg5 ) {
const char * args[] = { arg1, arg2, arg3, arg4, arg5 };
const int numArgs = sizeof( args ) / sizeof( args[ 0 ] );
spritePath = spritePath_;
for ( int i = 0; i < numArgs; ++i ) {
if ( args[ i ] == NULL ) {
break;
}
spritePath.Append( args[ i ] );
}
}
/*
========================
idMenuWidget::ClearSprite
========================
*/
void idMenuWidget::ClearSprite() {
if ( GetSprite() == NULL ) {
return;
}
GetSprite()->SetVisible( false );
boundSprite = NULL;
}
/*
========================
idMenuWidget::GetSWFObject
========================
*/
idSWF * idMenuWidget::GetSWFObject() {
if ( swfObj != NULL ) {
return swfObj;
}
if ( parent != NULL ) {
return parent->GetSWFObject();
}
if ( menuData != NULL ) {
return menuData->GetGUI();
}
return NULL;
}
/*
========================
idMenuWidget::GetMenuData
========================
*/
idMenuHandler * idMenuWidget::GetMenuData() {
if ( parent != NULL ) {
return parent->GetMenuData();
}
return menuData;
}
/*
========================
idMenuWidget::BindSprite
Takes the sprite path strings and resolves it to an actual sprite relative to a given root.
This is setup in this manner, because we can't resolve from path -> sprite immediately since
SWFs aren't necessarily loaded at the time widgets are instantiated.
========================
*/
bool idMenuWidget::BindSprite( idSWFScriptObject & root ) {
const char * args[ 6 ] = { NULL };
assert( GetSpritePath().Num() > 0 );
for ( int i = 0; i < GetSpritePath().Num(); ++i ) {
args[ i ] = GetSpritePath()[ i ].c_str();
}
boundSprite = root.GetNestedSprite( args[ 0 ], args[ 1 ], args[ 2 ], args[ 3 ], args[ 4 ], args[ 5 ] );
return boundSprite != NULL;
}
/*
========================
idMenuWidget::Show
========================
*/
void idMenuWidget::Show() {
if ( GetSWFObject() == NULL ) {
return;
}
if ( !BindSprite( GetSWFObject()->GetRootObject() ) ) {
return;
}
GetSprite()->SetVisible( true );
int currentFrame = GetSprite()->GetCurrentFrame();
int findFrame = GetSprite()->FindFrame( "rollOn" );
int idleFrame = GetSprite()->FindFrame( "idle" );
if ( currentFrame == findFrame || ( currentFrame > 1 && currentFrame <= idleFrame ) ) {
return;
}
GetSprite()->PlayFrame( findFrame );
}
/*
========================
idMenuWidget::Hide
========================
*/
void idMenuWidget::Hide() {
if ( GetSWFObject() == NULL ) {
return;
}
if ( !BindSprite( GetSWFObject()->GetRootObject() ) ) {
return;
}
int currentFrame = GetSprite()->GetCurrentFrame();
int findFrame = GetSprite()->FindFrame( "rollOff" );
if ( currentFrame >= findFrame || currentFrame == 1 ) {
return;
}
GetSprite()->PlayFrame( findFrame );
}
/*
========================
idMenuWidget::SetDataSource
========================
*/
void idMenuWidget::SetDataSource( idMenuDataSource * dataSource_, const int fieldIndex ) {
dataSource = dataSource_;
dataSourceFieldIndex = fieldIndex;
}
/*
========================
idMenuWidget::SetFocusIndex
========================
*/
void idMenuWidget::SetFocusIndex( const int index, bool skipSound ) {
if ( GetChildren().Num() == 0 ) {
return;
}
const int oldIndex = focusIndex;
assert( index >= 0 && index < GetChildren().Num() ); //&& oldIndex >= 0 && oldIndex < GetChildren().Num() );
focusIndex = index;
if ( oldIndex != focusIndex && !skipSound ) {
if ( menuData != NULL ) {
menuData->PlaySound( GUI_SOUND_FOCUS );
}
}
idSWFParmList parms;
parms.Append( oldIndex );
parms.Append( index );
// need to mark the widget as having lost focus
if ( oldIndex != index && oldIndex >= 0 && oldIndex < GetChildren().Num() && GetChildByIndex( oldIndex ).GetState() != WIDGET_STATE_HIDDEN ) {
GetChildByIndex( oldIndex ).ReceiveEvent( idWidgetEvent( WIDGET_EVENT_FOCUS_OFF, 0, NULL, parms ) );
}
//assert( GetChildByIndex( index ).GetState() != WIDGET_STATE_HIDDEN );
GetChildByIndex( index ).ReceiveEvent( idWidgetEvent( WIDGET_EVENT_FOCUS_ON, 0, NULL, parms ) );
}
/*
========================
idMenuWidget_Button::SetState
Transitioning from the current button state to the new button state
========================
*/
void idMenuWidget::SetState( const widgetState_t state ) {
if ( GetSprite() != NULL ) {
// FIXME: will need some more intelligence in the transitions to go from, say,
// selected_up -> up ... but this should work fine for now.
if ( state == WIDGET_STATE_HIDDEN ) {
GetSprite()->SetVisible( false );
} else {
GetSprite()->SetVisible( true );
if ( state == WIDGET_STATE_DISABLED ) {
GetSprite()->PlayFrame( "disabled" );
} else if ( state == WIDGET_STATE_SELECTING ) {
if ( widgetState == WIDGET_STATE_NORMAL ) {
GetSprite()->PlayFrame( "selecting" ); // transition from unselected to selected
} else {
GetSprite()->PlayFrame( "sel_up" );
}
} else if ( state == WIDGET_STATE_SELECTED ) {
GetSprite()->PlayFrame( "sel_up" );
} else if ( state == WIDGET_STATE_NORMAL ) {
if ( widgetState == WIDGET_STATE_SELECTING ) {
GetSprite()->PlayFrame( "unselecting" ); // transition from selected to unselected
} else if ( widgetState != WIDGET_STATE_HIDDEN && widgetState != WIDGET_STATE_NORMAL ) {
GetSprite()->PlayFrame( "out" );
} else {
GetSprite()->PlayFrame( "up" );
}
}
}
Update();
}
widgetState = state;
}
/*
========================
idMenuWidget::HandleAction
========================
*/
bool idMenuWidget::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
bool handled = false;
if ( GetParent() != NULL ) {
handled = GetParent()->HandleAction( action, event, widget );
} else {
if ( forceHandled ) {
return false;
}
idMenuHandler * data = GetMenuData();
if ( data != NULL ) {
return data->HandleAction( action, event, widget, false );
}
}
return handled;
}
/*
========================
idMenuWidget::GetEventActions
========================
*/
idList< idWidgetAction, TAG_IDLIB_LIST_MENU > * idMenuWidget::GetEventActions( const widgetEvent_t eventType ) {
if ( eventActionLookup[ eventType ] == INVALID_ACTION_INDEX ) {
return NULL;
}
return &eventActions[ eventActionLookup[ eventType ] ];
}
/*
========================
idMenuWidget::AddEventAction
========================
*/
idWidgetAction & idMenuWidget::AddEventAction( const widgetEvent_t eventType ) {
if ( eventActionLookup[ eventType ] == INVALID_ACTION_INDEX ) {
eventActionLookup[ eventType ] = eventActions.Num();
eventActions.Alloc();
}
return eventActions[ eventActionLookup[ eventType ] ].Alloc();
}
/*
========================
idMenuWidget::ClearEventActions
========================
*/
void idMenuWidget::ClearEventActions() {
eventActions.Clear();
eventActionLookup.Clear();
eventActionLookup.SetNum( eventActionLookup.Max() );
for ( int i = 0; i < eventActionLookup.Num(); ++i ) {
eventActionLookup[ i ] = INVALID_ACTION_INDEX;
}
}

1341
neo/d3xp/menus/MenuWidget.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,600 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
================================================================================================
idMenuWidget_Button
SWF object structure
--------------------
BUTTON (Frames: up, over, out, down, release, disabled, sel_up, sel_over, sel_out, sel_down, sel_release, selecting, unselecting)
txtOption
txtValue (Text)
optionType (Frames: One per mainMenuOption_t enum)
sliderBar
bar (Frames: 1-100 for percentage filled)
btnLess
btnMore
sliderText
txtVal (Text)
btnLess
btnMore
Future work:
- Perhaps this should be called "MultiButton", since it merges additional controls with a standard button?
================================================================================================
*/
//---------------------------------
// Animation State Transitions
//
// Maps animations that should be called when transitioning states:
//
// X-axis = state transitioning FROM
// Y-axis = state transitioning TO
//
// An empty string indicates remain at current animation.
//---------------------------------
static const char * ANIM_STATE_TRANSITIONS[ idMenuWidget_Button::ANIM_STATE_MAX * idMenuWidget_Button::ANIM_STATE_MAX ] = {
// UP DOWN OVER
"", "release", "out", // UP
"down", "", "down", // DOWN
"over", "over", "", // OVER
};
// script name for the control object for a given type of button
static const char * const CONTROL_SPRITE_NAMES[ MAX_MENU_OPTION_TYPES ] = {
NULL,
"sliderBar",
"sliderText",
"sliderText",
NULL,
"sliderText",
};
compile_time_assert( sizeof( CONTROL_SPRITE_NAMES ) / sizeof( CONTROL_SPRITE_NAMES[ 0 ] ) == MAX_MENU_OPTION_TYPES );
/*
========================
idMenuWidget_Button::Update
========================
*/
void idMenuWidget_Button::Update() {
if ( menuData != NULL && menuData->GetGUI() != NULL ) {
BindSprite( menuData->GetGUI()->GetRootObject() );
}
if ( GetSprite() == NULL ) {
return;
}
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
if ( btnLabel.IsEmpty() ) {
if ( values.Num() > 0 ) {
for ( int val = 0; val < values.Num(); ++val ) {
idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
if ( textObject != NULL ) {
idSWFTextInstance * const text = textObject->GetText();
text->SetIgnoreColor( ignoreColor );
text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
text->SetText( values[ val ].c_str() );
text->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
} else if ( img != NULL ) {
idSWFSpriteInstance * btnImg = spriteObject->GetNestedSprite( "img" );
if ( btnImg != NULL ) {
btnImg->SetMaterial( img );
}
btnImg = spriteObject->GetNestedSprite( "imgTop" );
if ( btnImg != NULL ) {
btnImg->SetMaterial( img );
}
} else {
ClearSprite();
}
} else {
idSWFScriptObject * const textObject = spriteObject->GetNestedObj( "label0", "txtVal" );
if ( textObject != NULL ) {
idSWFTextInstance * const text = textObject->GetText();
text->SetIgnoreColor( ignoreColor );
text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
text->SetText( btnLabel.c_str() );
text->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
// events
spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = spriteObject;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
/*
========================
idMenuWidget_Button::ExecuteEvent
========================
*/
bool idMenuWidget_Button::ExecuteEvent( const idWidgetEvent & event ) {
bool handled = false;
// do nothing at all if it's disabled
if ( GetState() != WIDGET_STATE_DISABLED ) {
switch ( event.type ) {
case WIDGET_EVENT_PRESS: {
if ( GetMenuData() != NULL ) {
GetMenuData()->PlaySound( GUI_SOUND_ADVANCE );
}
AnimateToState( ANIM_STATE_DOWN );
handled = true;
break;
}
case WIDGET_EVENT_RELEASE: {
AnimateToState( ANIM_STATE_UP );
GetMenuData()->ClearWidgetActionRepeater();
handled = true;
break;
}
case WIDGET_EVENT_ROLL_OVER: {
if ( GetMenuData() != NULL ) {
GetMenuData()->PlaySound( GUI_SOUND_ROLL_OVER );
}
AnimateToState( ANIM_STATE_OVER );
handled = true;
break;
}
case WIDGET_EVENT_ROLL_OUT: {
AnimateToState( ANIM_STATE_UP );
GetMenuData()->ClearWidgetActionRepeater();
handled = true;
break;
}
case WIDGET_EVENT_FOCUS_OFF: {
SetState( WIDGET_STATE_NORMAL );
handled = true;
break;
}
case WIDGET_EVENT_FOCUS_ON: {
SetState( WIDGET_STATE_SELECTING );
handled = true;
break;
}
case WIDGET_EVENT_SCROLL_LEFT_RELEASE: {
GetMenuData()->ClearWidgetActionRepeater();
break;
}
case WIDGET_EVENT_SCROLL_RIGHT_RELEASE: {
GetMenuData()->ClearWidgetActionRepeater();
break;
}
}
}
idMenuWidget::ExecuteEvent( event );
return handled;
}
/*
========================
idMenuWidget_Button::AddValue
========================
*/
void idMenuWidget_Button::SetValues( idList< idStr > & list ) {
values.Clear();
for ( int i = 0; i < list.Num(); ++ i ) {
values.Append( list[ i ] );
}
}
/*
========================
idMenuWidget_Button::GetValue
========================
*/
const idStr & idMenuWidget_Button::GetValue( int index ) const {
return values[ index ];
}
/*
========================
idMenuWidget_Button::SetupTransitionInfo
========================
*/
void idMenuWidget_Button::SetupTransitionInfo( widgetTransition_t & trans, const widgetState_t buttonState, const animState_t sourceAnimState, const animState_t destAnimState ) const {
trans.prefixes.Clear();
if ( buttonState == WIDGET_STATE_DISABLED ) {
trans.animationName = "disabled";
} else {
const int animIndex = (int)destAnimState * ANIM_STATE_MAX + (int)sourceAnimState;
trans.animationName = ANIM_STATE_TRANSITIONS[ animIndex ];
if ( buttonState == WIDGET_STATE_SELECTING ) {
trans.prefixes.Append( "sel_" );
}
}
trans.prefixes.Append( "" );
}
/*
========================
idMenuWidget_Button::AnimateToState
Plays an animation from the current state to the target state.
========================
*/
void idMenuWidget_Button::AnimateToState( const animState_t targetAnimState, const bool force ) {
if ( !force && targetAnimState == GetAnimState() ) {
return;
}
if ( GetSprite() != NULL ) {
widgetTransition_t trans;
SetupTransitionInfo( trans, GetState(), GetAnimState(), targetAnimState );
if ( trans.animationName[0] != '\0' ) {
for ( int i = 0; i < trans.prefixes.Num(); ++i ) {
const char * const frameLabel = va( "%s%s", trans.prefixes[ i ], trans.animationName );
if ( GetSprite()->FrameExists( frameLabel ) ) {
GetSprite()->PlayFrame( frameLabel );
Update();
break;
}
}
}
idSWFSpriteInstance * const focusSprite = GetSprite()->GetScriptObject()->GetSprite( "focusIndicator" );
if ( focusSprite != NULL ) {
if ( targetAnimState == ANIM_STATE_OVER ) {
focusSprite->PlayFrame( "show" );
} else {
focusSprite->PlayFrame( "hide" );
}
}
}
SetAnimState( targetAnimState );
}
//*****************************************************************************************************************
// CONTROL BUTTON
/*
========================
idMenuWidget_ControlButton::Update
========================
*/
void idMenuWidget_ControlButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject()->GetNestedObj( "type" );
if ( spriteObject == NULL ) {
return;
}
idSWFSpriteInstance * type = spriteObject->GetSprite();
if ( type == NULL ) {
return;
}
if ( GetOptionType() != OPTION_BUTTON_FULL_TEXT_SLIDER ) {
type->StopFrame( GetOptionType() + 1 );
}
idSWFTextInstance * text = spriteObject->GetNestedText( "label0", "txtVal" );
if ( text != NULL ) {
text->SetText( btnLabel );
text->SetStrokeInfo( true, 0.75f, 2.0f );
}
if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
idSWFSpriteInstance * controlSprite = NULL;
if ( CONTROL_SPRITE_NAMES[ GetOptionType() ] != NULL ) {
controlSprite = type->GetScriptObject()->GetSprite( CONTROL_SPRITE_NAMES[ GetOptionType() ] );
if ( verify( controlSprite != NULL ) ) {
if ( verify( GetDataSource() != NULL ) ) {
idSWFScriptVar fieldValue = GetDataSource()->GetField( GetDataSourceFieldIndex() );
if ( GetOptionType() == OPTION_SLIDER_BAR ) {
controlSprite->StopFrame( 1 + fieldValue.ToInteger() );
} else if ( GetOptionType() == OPTION_SLIDER_TOGGLE ) {
idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
if ( verify( txtInfo != NULL ) ) {
txtInfo->SetText( fieldValue.ToBool() ? "#str_swf_enabled" : "#str_swf_disabled" );
txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
}
} else if ( GetOptionType() == OPTION_SLIDER_TEXT || GetOptionType() == OPTION_BUTTON_FULL_TEXT_SLIDER ) {
idSWFTextInstance * const txtInfo = controlSprite->GetScriptObject()->GetNestedText( "txtVal" );
if ( verify( txtInfo != NULL ) ) {
txtInfo->SetText( fieldValue.ToString() );
txtInfo->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
}
idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
if ( btnLess != NULL && btnMore != NULL ) {
if ( disabled ) {
btnLess->GetSprite()->SetVisible( false );
btnMore->GetSprite()->SetVisible( false );
} else {
btnLess->GetSprite()->SetVisible( true );
btnMore->GetSprite()->SetVisible( true );
btnLess->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT, 0 ) );
btnLess->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_LEFT_RELEASE, 0 ) );
btnMore->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT, 0 ) );
btnMore->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_SCROLL_RIGHT_RELEASE, 0 ) );
btnLess->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
btnLess->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
btnMore->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
btnMore->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
}
}
}
} else {
idSWFScriptObject * const btnLess = GetSprite()->GetScriptObject()->GetObject( "btnLess" );
idSWFScriptObject * const btnMore = GetSprite()->GetScriptObject()->GetObject( "btnMore" );
if ( btnLess != NULL && btnMore != NULL ) {
btnLess->GetSprite()->SetVisible( false );
btnMore->GetSprite()->SetVisible( false );
}
}
// events
GetSprite()->GetScriptObject()->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
GetSprite()->GetScriptObject()->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = GetSprite()->GetScriptObject()->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = GetSprite()->GetScriptObject();
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
/*
========================
idMenuWidget_ControlButton::Update
========================
*/
void idMenuWidget_ControlButton::SetupEvents( int delay, int index ) {
AddEventAction( WIDGET_EVENT_SCROLL_LEFT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, -1, delay, index );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_ADJUST_FIELD, 1, delay, index );
AddEventAction( WIDGET_EVENT_SCROLL_LEFT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
AddEventAction( WIDGET_EVENT_SCROLL_RIGHT_LSTICK_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
}
//****************************************************************
// SERVER BUTTON
//****************************************************************
/*
========================
idMenuWidget_ServerButton::Update
========================
*/
void idMenuWidget_ServerButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
idSWFTextInstance * const txtName = spriteObject->GetNestedText( "label0", "txtVal" );
if ( txtName != NULL ) {
txtName->SetText( serverName );
txtName->SetStrokeInfo( true, 0.75f, 1.75f );
}
// events
spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = spriteObject;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
/*
========================
idMenuWidget_ServerButton::SetButtonInfo
========================
*/
void idMenuWidget_ServerButton::SetButtonInfo( idStr name_, idStrId mapName_, idStr modeName_, int index_, int players_, int maxPlayers_, bool joinable_, bool validMap_ ) {
serverName = name_;
index = index_;
players = players_;
maxPlayers = maxPlayers_;
joinable = joinable_;
validMap = validMap_;
mapName = mapName_;
modeName = modeName_;
idStr desc;
if ( index >= 0 ) {
idStr playerVal = va( "%s %d/%d", idLocalization::GetString( "#str_02396" ), players, maxPlayers );
idStr lobbyMapName = va( "%s %s", idLocalization::GetString( "#str_02045" ), mapName.GetLocalizedString() );
idStr lobbyMode;
if ( !modeName.IsEmpty() ) {
lobbyMode = va( "%s %s", idLocalization::GetString( "#str_02044" ), modeName.c_str() );
}
desc = va( "%s %s %s", playerVal.c_str(), lobbyMapName.c_str(), lobbyMode.c_str() );
}
SetDescription( desc );
}
//****************************************************************
// LOBBY BUTTON
//****************************************************************
/*
========================
idMenuWidget_LobbyButton::Update
========================
*/
void idMenuWidget_LobbyButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
idSWFTextInstance * const txtName = spriteObject->GetNestedText( "itemName", "txtVal" );
idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
if ( txtName != NULL ) {
txtName->SetText( name );
}
if ( talkIcon != NULL ) {
talkIcon->StopFrame( voiceState + 1 );
talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
}
// events
spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = spriteObject;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
/*
========================
idMenuWidget_LobbyButton::SetButtonInfo
========================
*/
void idMenuWidget_LobbyButton::SetButtonInfo( idStr name_, voiceStateDisplay_t voiceState_ ) {
name = name_;
voiceState = voiceState_;
}
//****************************************************************
// SCOREBOARD BUTTON
//****************************************************************
/*
========================
idMenuWidget_ScoreboardButton::Update
========================
*/
void idMenuWidget_ScoreboardButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
if ( index == -1 ) {
GetSprite()->SetVisible( false );
return;
}
GetSprite()->SetVisible( true );
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
for ( int val = 0; val < values.Num(); ++val ) {
idSWFScriptObject * const textObject = spriteObject->GetNestedObj( va( "label%d", val ), "txtVal" );
if ( textObject != NULL ) {
idSWFTextInstance * const text = textObject->GetText();
text->SetIgnoreColor( ignoreColor );
text->tooltip = ignoreColor; // ignoreColor does double duty as "allow tooltips"
text->SetText( values[ val ].c_str() );
text->SetStrokeInfo( true, 0.75f, 2.0f );
}
}
idSWFSpriteInstance * talkIcon = spriteObject->GetNestedSprite( "chaticon" );
if ( talkIcon != NULL ) {
talkIcon->StopFrame( voiceState + 1 );
talkIcon->GetScriptObject()->Set( "onPress", new (TAG_SWF) WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, WIDGET_ACTION_MUTE_PLAYER ) );
}
// events
spriteObject->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
spriteObject->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = spriteObject;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
/*
========================
idMenuWidget_ScoreboardButton::SetButtonInfo
========================
*/
void idMenuWidget_ScoreboardButton::SetButtonInfo( int index_, idList< idStr > & list, voiceStateDisplay_t voiceState_ ) {
index = index_;
voiceState = voiceState_;
SetValues( list );
}

View File

@@ -0,0 +1,265 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
void idMenuWidget_Carousel::Initialize( idMenuHandler * data ) {
idMenuWidget::Initialize( data );
class idCarouselRefresh : public idSWFScriptFunction_RefCounted {
public:
idCarouselRefresh( idMenuWidget_Carousel * _widget ) :
widget( _widget ) {
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
if ( widget == NULL ) {
return idSWFScriptVar();
}
if ( widget->GetMoveDiff() != 0 ) {
int diff = widget->GetMoveDiff();
diff--;
if ( widget->GetScrollLeft() ) {
widget->SetViewIndex( widget->GetViewIndex() - 1 );
} else {
widget->SetViewIndex( widget->GetViewIndex() + 1 );
}
if ( diff > 0 ) {
if ( widget->GetScrollLeft() ) {
widget->MoveToIndex( ( widget->GetNumVisibleOptions() / 2 ) + diff );
} else {
widget->MoveToIndex( diff );
}
} else {
widget->SetMoveDiff( 0 );
}
}
widget->Update();
return idSWFScriptVar();
}
private:
idMenuWidget_Carousel * widget;
};
if ( GetSWFObject() != NULL ) {
GetSWFObject()->SetGlobal( "refreshCarousel", new idCarouselRefresh( this ) );
}
}
/*
========================
idMenuWidget_Carousel::Update
========================
*/
void idMenuWidget_Carousel::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
int midPoint = GetNumVisibleOptions() / 2 + 1;
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
int listIndex = viewIndex + optionIndex;
if ( optionIndex >= midPoint ) {
listIndex = viewIndex - ( optionIndex - ( midPoint - 1 ) );
}
idMenuWidget & child = GetChildByIndex( optionIndex );
child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
if ( child.BindSprite( root ) ) {
if ( listIndex < 0 || listIndex >= GetTotalNumberOfOptions() ) {
child.SetState( WIDGET_STATE_HIDDEN );
} else {
idMenuWidget_Button * const button = dynamic_cast< idMenuWidget_Button * >( &child );
button->SetImg( imgList[ listIndex ] );
child.Update();
if ( optionIndex == focusIndex ) {
child.SetState( WIDGET_STATE_SELECTING );
} else {
child.SetState( WIDGET_STATE_NORMAL );
}
}
}
}
}
/*
========================
idMenuWidget_Carousel::SetListImages
========================
*/
void idMenuWidget_Carousel::SetListImages( idList<const idMaterial *> & list ) {
imgList.Clear();
for ( int i = 0; i < list.Num(); ++i ) {
imgList.Append( list[ i ] );
}
}
/*
========================
idMenuWidget_Carousel::Update
========================
*/
bool idMenuWidget_Carousel::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuWidget_Carousel::MoveToFirstItem
========================
*/
void idMenuWidget_Carousel::MoveToFirstItem( bool instant ) {
if ( instant ) {
moveDiff = 0;
viewIndex = 0;
moveToIndex = 0;
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
GetSprite()->StopFrame( 1 );
}
Update();
}
}
/*
========================
idMenuWidget_Carousel::MoveToLastItem
========================
*/
void idMenuWidget_Carousel::MoveToLastItem( bool instant ) {
if ( instant ) {
moveDiff = 0;
viewIndex = GetTotalNumberOfOptions() - 1;
moveToIndex = GetTotalNumberOfOptions() - 1;
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
GetSprite()->StopFrame( 1 );
}
Update();
}
}
/*
========================
idMenuWidget_Carousel::Update
========================
*/
void idMenuWidget_Carousel::MoveToIndex( int index, bool instant ) {
idLib::Printf( "moveToIndex %i\n", index );
if ( instant ) {
viewIndex = index;
moveDiff = 0;
moveToIndex = viewIndex;
idLib::Printf( "moveDiff = %i\n", moveDiff );
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( BindSprite( root ) ) {
GetSprite()->StopFrame( 1 );
}
Update();
return;
}
if ( index == 0 ) {
fastScroll = false;
moveDiff = 0;
idLib::Printf( "moveDiff = %i\n", moveDiff );
viewIndex = moveToIndex;
return;
}
int midPoint = GetNumVisibleOptions() / 2;
scrollLeft = false;
if ( index > midPoint ) {
moveDiff = index - midPoint;
scrollLeft = true;
} else {
moveDiff = index;
}
idLib::Printf( "moveDiff = %i\n", moveDiff );
if ( scrollLeft ) {
moveToIndex = viewIndex - moveDiff;
if ( moveToIndex < 0 ) {
moveToIndex = 0;
int diff = 0 - moveToIndex;
moveDiff -= diff;
}
} else {
moveToIndex = viewIndex + moveDiff;
if ( moveToIndex >= GetTotalNumberOfOptions() ) {
moveDiff = GetTotalNumberOfOptions() - GetViewIndex() - 1;
moveToIndex = GetTotalNumberOfOptions() - 1;
}
}
idLib::Printf( "moveDiff = %i\n", moveDiff );
if ( moveDiff != 0 ) {
if ( moveDiff > 1 ) {
if ( scrollLeft ) {
GetSprite()->PlayFrame( "leftFast" );
} else {
GetSprite()->PlayFrame( "rightFast" );
}
} else {
if ( scrollLeft ) {
GetSprite()->PlayFrame( "left" );
} else {
GetSprite()->PlayFrame( "right" );
}
}
}
idLib::Printf( "moveDiff = %i\n", moveDiff );
}

View File

@@ -0,0 +1,198 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
================================================================================================
idMenuWidget_CommandBar
Provides a paged view of this widgets children. Each child is expected to take on the following
naming scheme. Children outside of the given window size (NumVisibleOptions) are not rendered,
and will affect which type of arrow indicators are shown.
This transparently supports the "UseCircleForAccept" behavior that we need for Japanese PS3 SKU.
SWF object structure
--------------------
COMMANDBAR
joy#
img (Frames: platform)
txt_info (Text)
================================================================================================
*/
static const char * const BUTTON_NAMES[] = {
"joy1",
"joy2",
"joy3",
"joy4",
"joy10",
"tab"
};
compile_time_assert( sizeof( BUTTON_NAMES ) / sizeof( BUTTON_NAMES[ 0 ] ) == idMenuWidget_CommandBar::MAX_BUTTONS );
/*
========================
idMenuWidget_CommandBar::ClearAllButtons
========================
*/
void idMenuWidget_CommandBar::ClearAllButtons() {
for ( int index = 0; index < MAX_BUTTONS; ++index ) {
buttons[index].label.Clear();
buttons[index].action.Set( WIDGET_ACTION_NONE );
}
}
/*
========================
idMenuWidget_CommandBar::Update
========================
*/
void idMenuWidget_CommandBar::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
const int BASE_PADDING = 35;
const int PER_BUTTON_PADDING = 65;
const int ALIGNMENT_SCALE = ( GetAlignment() == LEFT ) ? 1 : -1;
int xPos = ALIGNMENT_SCALE * BASE_PADDING;
// Setup the button order.
idStaticList< button_t, MAX_BUTTONS > buttonOrder;
for ( int i = 0; i < buttonOrder.Max(); ++i ) {
buttonOrder.Append( static_cast< button_t >( i ) );
}
// NOTE: Special consideration is done for JPN PS3 where the standard accept button is
// swapped with the standard back button. i.e. In US: X = Accept, O = Back, but in JPN
// X = Back, O = Accept.
if ( GetSWFObject()->UseCircleForAccept() ) {
buttonOrder[ BUTTON_JOY2 ] = BUTTON_JOY1;
buttonOrder[ BUTTON_JOY1 ] = BUTTON_JOY2;
}
// FIXME: handle animating in of the button bar?
GetSprite()->SetVisible( true );
idStr shortcutName;
for ( int i = 0; i < buttonOrder.Num(); ++i ) {
const char * const buttonName = BUTTON_NAMES[ buttonOrder[ i ] ];
idSWFSpriteInstance * const buttonSprite = GetSprite()->GetScriptObject()->GetSprite( buttonName );
if ( buttonSprite == NULL ) {
continue;
}
idSWFTextInstance * const buttonText = buttonSprite->GetScriptObject()->GetText( "txt_info" );
if ( buttonText == NULL ) {
continue;
}
idSWFSpriteInstance * const imageSprite = buttonSprite->GetScriptObject()->GetSprite( "img" );
if ( imageSprite == NULL ) {
continue;
}
if ( buttons[ i ].action.GetType() != WIDGET_ACTION_NONE ) {
idSWFScriptObject * const shortcutKeys = GetSWFObject()->GetGlobal( "shortcutKeys" ).GetObject();
if ( verify( shortcutKeys != NULL ) ) {
buttonSprite->GetScriptObject()->Set( "onPress", new WrapWidgetSWFEvent( this, WIDGET_EVENT_COMMAND, i ) );
// bind the main action - need to use all caps here because shortcuts are stored that way
shortcutName = buttonName;
shortcutName.ToUpper();
shortcutKeys->Set( shortcutName, buttonSprite->GetScriptObject() );
// Some other keys have additional bindings. Remember that the button here is
// actually the virtual button, and the physical button could be swapped based
// on the UseCircleForAccept business on JPN PS3.
switch ( i ) {
case BUTTON_JOY1: {
shortcutKeys->Set( "ENTER", buttonSprite->GetScriptObject() );
break;
}
case BUTTON_JOY2: {
shortcutKeys->Set( "ESCAPE", buttonSprite->GetScriptObject() );
shortcutKeys->Set( "BACKSPACE", buttonSprite->GetScriptObject() );
break;
}
case BUTTON_TAB: {
shortcutKeys->Set( "K_TAB", buttonSprite->GetScriptObject() );
break;
}
}
}
if ( buttons[ i ].label.IsEmpty() ) {
buttonSprite->SetVisible( false );
} else {
imageSprite->SetVisible( true );
imageSprite->StopFrame( menuData->GetPlatform() + 1 );
buttonSprite->SetVisible( true );
buttonSprite->SetXPos( xPos );
buttonText->SetText( buttons[ i ].label );
xPos += ALIGNMENT_SCALE * ( buttonText->GetTextLength() + PER_BUTTON_PADDING );
}
} else {
buttonSprite->SetVisible( false );
idSWFScriptObject * const shortcutKeys = GetSWFObject()->GetGlobal( "shortcutKeys" ).GetObject();
if ( verify( shortcutKeys != NULL ) ) {
buttonSprite->GetScriptObject()->Set( "onPress", NULL );
// bind the main action - need to use all caps here because shortcuts are stored that way
shortcutName = buttonName;
shortcutName.ToUpper();
shortcutKeys->Set( shortcutName, buttonSprite->GetScriptObject() );
}
}
}
}
/*
========================
idMenuWidget_CommandBar::ReceiveEvent
========================
*/
bool idMenuWidget_CommandBar::ExecuteEvent( const idWidgetEvent & event ) {
if ( event.type == WIDGET_EVENT_COMMAND ) {
if ( verify( event.arg >= 0 && event.arg < buttons.Num() ) ) {
HandleAction( buttons[ event.arg ].action, event, this );
}
return true;
} else {
return idMenuWidget::ExecuteEvent( event );
}
}

View File

@@ -0,0 +1,219 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 "../precompiled.h"
#include "../MainMenuLocal.h"
/*
================================================================================================
idMenuWidget_DevList
Extends the standard list widget to support the developer menu.
================================================================================================
*/
namespace {
/*
================================================
DevList_NavigateForward
================================================
*/
class DevList_NavigateForward : public idSWFScriptFunction_RefCounted {
public:
DevList_NavigateForward( idMenuWidget_DevList * devList_, const int optionIndex_ ) :
devList( devList_ ),
optionIndex( optionIndex_ ) {
}
idSWFScriptVar Call( idSWFScriptObject * thisObject, const idSWFParmList & parms ) {
devList->NavigateForward( optionIndex );
return idSWFScriptVar();
}
private:
idMenuWidget_DevList * devList;
int optionIndex;
};
}
/*
========================
idMenuWidget_DevList::Initialize
========================
*/
void idMenuWidget_DevList::Initialize() {
AddEventAction( WIDGET_EVENT_SCROLL_DOWN ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, 1 );
AddEventAction( WIDGET_EVENT_SCROLL_UP ).Set( WIDGET_ACTION_START_REPEATER, WIDGET_ACTION_SCROLL_VERTICAL, -1 );
AddEventAction( WIDGET_EVENT_SCROLL_DOWN_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
AddEventAction( WIDGET_EVENT_SCROLL_UP_RELEASE ).Set( WIDGET_ACTION_STOP_REPEATER );
int optionIndex = 0;
while ( GetChildren().Num() < GetNumVisibleOptions() ) {
idMenuWidget_Button * const buttonWidget = new ( TAG_MENU ) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( new ( TAG_SWF ) DevList_NavigateForward( this, optionIndex++ ) );
AddChild( buttonWidget );
}
}
/*
========================
idMenuWidget_DevList::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_DevList::GetTotalNumberOfOptions() const {
if ( devMenuList == NULL ) {
return 0;
}
return devMenuList->devMenuList.Num();
}
/*
========================
idMenuWidget_DevList::GoToFirstMenu
========================
*/
void idMenuWidget_DevList::GoToFirstMenu() {
devMapListInfos.Clear();
indexInfo_t & info = devMapListInfos.Alloc();
info.name = "devmenuoption/main";
devMenuList = NULL;
RecalculateDevMenu();
}
/*
========================
idMenuWidget_DevList::NavigateForward
========================
*/
void idMenuWidget_DevList::NavigateForward( const int optionIndex ) {
if ( devMenuList == NULL ) {
return;
}
const int focusedIndex = GetViewOffset() + optionIndex;
const idDeclDevMenuList::idDevMenuOption & devOption = devMenuList->devMenuList[ focusedIndex ];
if ( ( devOption.devMenuDisplayName.Length() == 0 ) || ( devOption.devMenuDisplayName.Cmp( "..." ) == 0 ) ) {
return;
}
if ( devOption.devMenuSubList != NULL ) {
indexInfo_t & indexes = devMapListInfos.Alloc();
indexes.name = devOption.devMenuSubList->GetName();
indexes.focusIndex = GetFocusIndex();
indexes.viewIndex = GetViewIndex();
indexes.viewOffset = GetViewOffset();
RecalculateDevMenu();
SetViewIndex( 0 );
SetViewOffset( 0 );
Update();
// NOTE: This must be done after the Update() because it MAY change the sprites that
// children refer to
GetChildByIndex( 0 ).SetState( WIDGET_STATE_SELECTED );
ForceFocusIndex( 0 );
SetFocusIndex( 0 );
gameLocal->GetMainMenu()->ClearWidgetActionRepeater();
} else {
cmdSystem->AppendCommandText( va( "loadDevMenuOption %s %d\n", devMapListInfos[ devMapListInfos.Num() - 1 ].name, focusedIndex ) );
}
}
/*
========================
idMenuWidget_DevList::NavigateBack
========================
*/
void idMenuWidget_DevList::NavigateBack() {
assert( devMapListInfos.Num() != 0 );
if ( devMapListInfos.Num() == 1 ) {
// Important that this goes through as a DIRECT event, since more than likely the list
// widget will have the parent's focus, so a standard ReceiveEvent() here would turn
// into an infinite recursion.
idWidgetEvent event( WIDGET_EVENT_BACK, 0, NULL, idSWFParmList() );
idWidgetAction action;
action.Set( WIDGET_ACTION_GO_BACK, MENU_ROOT );
HandleAction( action, event );
return;
}
// NOTE: we need a copy here, since it's about to be removed from the list
const indexInfo_t indexes = devMapListInfos[ devMapListInfos.Num() - 1 ];
assert( indexes.focusIndex < GetChildren().Num() );
assert( ( indexes.viewIndex - indexes.viewOffset ) < GetNumVisibleOptions() );
devMapListInfos.RemoveIndex( devMapListInfos.Num() - 1 );
RecalculateDevMenu();
SetViewIndex( indexes.viewIndex );
SetViewOffset( indexes.viewOffset );
Update();
// NOTE: This must be done AFTER Update() because so that it is sure to refer to the proper sprite
GetChildByIndex( indexes.focusIndex ).SetState( WIDGET_STATE_SELECTED );
ForceFocusIndex( indexes.focusIndex );
SetFocusIndex( indexes.focusIndex );
gameLocal->GetMainMenu()->ClearWidgetActionRepeater();
}
/*
========================
idMenuWidget_DevList::RecalculateDevMenu
========================
*/
void idMenuWidget_DevList::RecalculateDevMenu() {
if ( devMapListInfos.Num() > 0 ) {
const idDeclDevMenuList * const devMenuListDecl = idDeclDevMenuList::resourceList.Load( devMapListInfos[ devMapListInfos.Num() - 1 ].name, false );
if ( devMenuListDecl != NULL ) {
devMenuList = devMenuListDecl;
}
}
idSWFScriptObject & root = gameLocal->GetMainMenu()->GetSWF()->GetRootObject();
for ( int i = 0; i < GetChildren().Num(); ++i ) {
idMenuWidget & child = GetChildByIndex( i );
child.SetSpritePath( GetSpritePath(), va( "option%d", i ) );
if ( child.BindSprite( root ) ) {
child.SetState( WIDGET_STATE_NORMAL );
child.GetSprite()->StopFrame( 1 );
}
}
}

View File

@@ -0,0 +1,236 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_DynamicList::Initialize
========================
*/
void idMenuWidget_DynamicList::Initialize( idMenuHandler * data ) {
idMenuWidget::Initialize( data );
}
/*
========================
idMenuWidget_DynamicList::Update
========================
*/
void idMenuWidget_DynamicList::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
if ( optionIndex >= children.Num() ) {
idSWFSpriteInstance * item = GetSprite()->GetScriptObject()->GetNestedSprite( va( "item%d", optionIndex ) );
if ( item != NULL ) {
item->SetVisible( false );
continue;
}
}
idMenuWidget & child = GetChildByIndex( optionIndex );
const int childIndex = GetViewOffset() + optionIndex;
bool shown = false;
child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
if ( child.BindSprite( root ) ) {
if ( optionIndex >= GetTotalNumberOfOptions() ) {
child.ClearSprite();
continue;
} else {
//const int controlIndex = GetNumVisibleOptions() - Min( GetNumVisibleOptions(), GetTotalNumberOfOptions() ) + optionIndex;
shown = PrepareListElement( child, childIndex );
child.Update();
}
if ( !shown ) {
child.SetState( WIDGET_STATE_HIDDEN );
} else {
if ( optionIndex == focusIndex ) {
child.SetState( WIDGET_STATE_SELECTING );
} else {
child.SetState( WIDGET_STATE_NORMAL );
}
}
}
}
idSWFSpriteInstance * const upSprite = GetSprite()->GetScriptObject()->GetSprite( "upIndicator" );
if ( upSprite != NULL ) {
upSprite->SetVisible( GetViewOffset() > 0 );
}
idSWFSpriteInstance * const downSprite = GetSprite()->GetScriptObject()->GetSprite( "downIndicator" );
if ( downSprite != NULL ) {
downSprite->SetVisible( GetViewOffset() + GetNumVisibleOptions() < GetTotalNumberOfOptions() );
}
}
/*
========================
idMenuWidget_DynamicList::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_DynamicList::GetTotalNumberOfOptions() const {
if ( controlList ) {
return GetChildren().Num();
}
return listItemInfo.Num();
}
/*
========================
idMenuWidget_DynamicList::PrepareListElement
========================
*/
bool idMenuWidget_DynamicList::PrepareListElement( idMenuWidget & widget, const int childIndex ) {
idMenuWidget_ScoreboardButton * const sbButton = dynamic_cast< idMenuWidget_ScoreboardButton * >( &widget );
if ( sbButton != NULL ) {
return true;
}
if ( listItemInfo.Num() == 0 ) {
return true;
}
if ( childIndex > listItemInfo.Num() ) {
return false;
}
idMenuWidget_Button * const button = dynamic_cast< idMenuWidget_Button * >( &widget );
if ( button != NULL ) {
button->SetIgnoreColor( ignoreColor );
button->SetValues( listItemInfo[ childIndex ] );
if ( listItemInfo[ childIndex ].Num() > 0 ) {
return true;
}
}
return false;
}
/*
========================
idMenuWidget_DynamicList::SetListData
========================
*/
void idMenuWidget_DynamicList::SetListData( idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > & list ) {
listItemInfo.Clear();
for ( int i = 0; i < list.Num(); ++i ) {
idList< idStr > values;
for ( int j = 0; j < list[i].Num(); ++j ) {
values.Append( list[i][j] );
}
listItemInfo.Append( values );
}
}
/*
========================
idMenuWidget_DynamicList::Recalculate
========================
*/
void idMenuWidget_DynamicList::Recalculate() {
idSWF * swf = GetSWFObject();
if ( swf == NULL ) {
return;
}
idSWFScriptObject & root = swf->GetRootObject();
for ( int i = 0; i < GetChildren().Num(); ++i ) {
idMenuWidget & child = GetChildByIndex( i );
child.SetSpritePath( GetSpritePath(), "info", "list", va( "item%d", i ) );
if ( child.BindSprite( root ) ) {
child.SetState( WIDGET_STATE_NORMAL );
child.GetSprite()->StopFrame( 1 );
}
}
}
/*
========================
idMenuWidget_ScoreboardList::Update
========================
*/
void idMenuWidget_ScoreboardList::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
idMenuWidget & child = GetChildByIndex( optionIndex );
const int childIndex = GetViewOffset() + optionIndex;
bool shown = false;
child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
if ( child.BindSprite( root ) ) {
shown = PrepareListElement( child, childIndex );
if ( optionIndex == focusIndex && child.GetState() != WIDGET_STATE_SELECTED && child.GetState() != WIDGET_STATE_SELECTING ) {
child.SetState( WIDGET_STATE_SELECTING );
} else if ( optionIndex != focusIndex && child.GetState() != WIDGET_STATE_NORMAL ) {
child.SetState( WIDGET_STATE_NORMAL );
}
child.Update();
}
}
}
/*
========================
idMenuWidget_ScoreboardList::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_ScoreboardList::GetTotalNumberOfOptions() const {
return GetChildren().Num();
}

View File

@@ -0,0 +1,139 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
================================================================================================
idMenuWidget_Help
Shows a help tooltip message based on observed events. It's expected that the widgets being
observed are all buttons, and therefore have a GetDescription() call to get the help message.
SWF object structure
--------------------
HELPTOOLTIP (Frames: shown, shown, hide, hidden)
txtOption
txtValue (Text)
Note: Frame 1 should, effectively, be a "hidden" state.
Future work:
- Make this act more like a help tooltip when on PC?
================================================================================================
*/
/*
========================
idMenuWidget_Help::Update
========================
*/
void idMenuWidget_Help::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
const idStr & msg = ( lastHoveredMessage.Length() > 0 ) ? lastHoveredMessage : lastFocusedMessage;
if ( msg.Length() > 0 && !hideMessage ) {
// try to show it if...
// - we are on the first frame
// - we aren't still animating while being between the "show" and "shown" frames
//
if ( GetSprite()->GetCurrentFrame() != GetSprite()->FindFrame( "shown" )
&& ( GetSprite()->GetCurrentFrame() == 1 || !( GetSprite()->IsPlaying() && GetSprite()->IsBetweenFrames( "show", "shown" ) ) ) ) {
GetSprite()->PlayFrame( "show" );
}
idSWFScriptObject * const textObject = GetSprite()->GetScriptObject()->GetNestedObj( "txtOption", "txtValue" );
if ( textObject != NULL ) {
idSWFTextInstance * const text = textObject->GetText();
text->SetText( msg );
text->SetStrokeInfo( true, 0.75f, 2.0f );
}
} else {
// try to hide it
if ( GetSprite()->GetCurrentFrame() != 1
&& GetSprite()->GetCurrentFrame() != GetSprite()->FindFrame( "hidden" )
&& !GetSprite()->IsBetweenFrames( "hide", "hidden" ) ) {
GetSprite()->PlayFrame( "hide" );
}
}
}
/*
========================
idMenuWidget_Help::ObserveEvent
========================
*/
void idMenuWidget_Help::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
hideMessage = false;
lastFocusedMessage = button->GetDescription();
lastHoveredMessage.Clear();
Update();
break;
}
case WIDGET_EVENT_FOCUS_OFF: {
// Don't do anything when losing focus. Focus updates come in pairs, so we can
// skip doing anything on the "lost focus" event, and instead do updates on the
// "got focus" event.
break;
}
case WIDGET_EVENT_ROLL_OVER: {
idStr desc = button->GetDescription();
if ( desc.IsEmpty() ) {
hideMessage = true;
} else {
hideMessage = false;
lastHoveredMessage = button->GetDescription();
}
Update();
break;
}
case WIDGET_EVENT_ROLL_OUT: {
hideMessage = false;
lastHoveredMessage.Clear();
Update();
break;
}
}
}

View File

@@ -0,0 +1,208 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_InfoBox::Update
========================
*/
void idMenuWidget_InfoBox::Initialize( idMenuHandler * data) {
idMenuWidget::Initialize( data );
}
/*
========================
idMenuWidget_InfoBox::Update
========================
*/
void idMenuWidget_InfoBox::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idSWFTextInstance * txtHeading = GetSprite()->GetScriptObject()->GetNestedText( "info", "heading", "txtVal" );
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtHeading != NULL ) {
txtHeading->SetText( heading );
}
if ( txtBody != NULL ) {
txtBody->SetText( info );
}
if ( scrollbar != NULL && txtBody != NULL ) {
txtBody->CalcMaxScroll();
scrollbar->Update();
}
idSWFScriptObject * info = GetSprite()->GetScriptObject()->GetNestedObj( "info" );
if ( info != NULL ) {
info->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
info->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
}
/*
========================
idMenuWidget_InfoBox::ObserveEvent
========================
*/
void idMenuWidget_InfoBox::ResetInfoScroll() {
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ){
return;
}
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtBody != NULL ) {
txtBody->scroll = 0;
}
if ( scrollbar != NULL ) {
scrollbar->Update();
}
}
/*
========================
idMenuWidget_InfoBox::Scroll
========================
*/
void idMenuWidget_InfoBox::Scroll( int d ) {
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtBody != NULL && txtBody->scroll + d >= 0 && txtBody->scroll + d <= txtBody->maxscroll ) {
txtBody->scroll += d;
}
if ( scrollbar != NULL ) {
scrollbar->Update();
}
}
/*
========================
idMenuWidget_InfoBox::GetScroll
========================
*/
int idMenuWidget_InfoBox::GetScroll() {
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtBody != NULL ) {
return txtBody->scroll;
}
return 0;
}
/*
========================
idMenuWidget_InfoBox::GetMaxScroll
========================
*/
int idMenuWidget_InfoBox::GetMaxScroll() {
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtBody != NULL ) {
return txtBody->maxscroll;
}
return 0;
}
/*
========================
idMenuWidget_InfoBox::SetScroll
========================
*/
void idMenuWidget_InfoBox::SetScroll( int scroll ) {
idSWFTextInstance * txtBody = GetSprite()->GetScriptObject()->GetNestedText( "info", "txtBody" );
if ( txtBody != NULL && scroll <= txtBody->maxscroll ) {
txtBody->scroll = scroll;
}
}
/*
========================
idMenuWidget_InfoBox::SetScrollbar
========================
*/
void idMenuWidget_InfoBox::SetScrollbar( idMenuWidget_ScrollBar * bar ) {
scrollbar = bar;
}
/*
========================
idMenuWidget_InfoBox::ObserveEvent
========================
*/
bool idMenuWidget_InfoBox::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
const idSWFParmList & parms = action.GetParms();
if ( action.GetType() == WIDGET_ACTION_SCROLL_VERTICAL ) {
const scrollType_t scrollType = static_cast< scrollType_t >( event.arg );
if ( scrollType == SCROLL_SINGLE ) {
Scroll( parms[ 0 ].ToInteger() );
}
return true;
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuWidget_InfoBox::ObserveEvent
========================
*/
void idMenuWidget_InfoBox::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
ResetInfoScroll();
break;
}
}
}

View File

@@ -0,0 +1,104 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
void idMenuWidget_ItemAssignment::SetIcon( int index, const idMaterial * icon ) {
if ( index < 0 || index >= NUM_QUICK_SLOTS ) {
return;
}
images[ index ] = icon;
}
void idMenuWidget_ItemAssignment::FindFreeSpot() {
slotIndex = 0;
for ( int i = 0; i < NUM_QUICK_SLOTS; ++i ) {
if ( images[ i ] == NULL ) {
slotIndex = i;
break;
}
}
}
/*
========================
idMenuWidget_ItemAssignment::Update
========================
*/
void idMenuWidget_ItemAssignment::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
idSWFSpriteInstance * dpad = GetSprite()->GetScriptObject()->GetNestedSprite( "dpad" );
if ( dpad != NULL ) {
dpad->StopFrame( slotIndex + 2 );
}
for ( int i = 0; i < NUM_QUICK_SLOTS; ++i ) {
idSWFSpriteInstance * item = GetSprite()->GetScriptObject()->GetNestedSprite( va( "item%d", i ) );
if ( item != NULL ) {
if ( i == slotIndex ) {
item->StopFrame( 2 );
} else {
item->StopFrame( 1 );
}
}
idSWFSpriteInstance * itemIcon = GetSprite()->GetScriptObject()->GetNestedSprite( va( "item%d", i ), "img" );
if ( itemIcon != NULL ) {
if ( images[ i ] != NULL ) {
itemIcon->SetVisible( true );
itemIcon->SetMaterial( images[ i ] );
} else {
itemIcon->SetVisible( false );
}
}
itemIcon = GetSprite()->GetScriptObject()->GetNestedSprite( va( "item%d", i ), "imgTop" );
if ( itemIcon != NULL ) {
if ( images[ i ] != NULL ) {
itemIcon->SetVisible( true );
itemIcon->SetMaterial( images[ i ] );
} else {
itemIcon->SetVisible( false );
}
}
}
}

View File

@@ -0,0 +1,408 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
================================================================================================
idMenuWidget_List
Provides a paged view of this widgets children. Each child is expected to take on the following
naming scheme. Children outside of the given window size (NumVisibleOptions) are not rendered,
and will affect which type of arrow indicators are shown.
Future work:
- Make upIndicator another kind of widget (Image widget?)
================================================================================================
*/
/*
========================
idMenuWidget_List::Update
========================
*/
void idMenuWidget_List::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
const int childIndex = GetViewOffset() + optionIndex;
bool shown = false;
if ( optionIndex < GetChildren().Num() ) {
idMenuWidget & child = GetChildByIndex( optionIndex );
const int controlIndex = GetNumVisibleOptions() - Min( GetNumVisibleOptions(), GetTotalNumberOfOptions() ) + optionIndex;
child.SetSpritePath( GetSpritePath(), va( "item%d", controlIndex ) );
if ( child.BindSprite( root ) ) {
PrepareListElement( child, childIndex );
child.Update();
shown = true;
}
}
if ( !shown ) {
// hide the item
idSWFSpriteInstance * const sprite = GetSprite()->GetScriptObject()->GetSprite( va( "item%d", optionIndex - GetTotalNumberOfOptions() ) );
if ( sprite != NULL ) {
sprite->SetVisible( false );
}
}
}
idSWFSpriteInstance * const upSprite = GetSprite()->GetScriptObject()->GetSprite( "upIndicator" );
if ( upSprite != NULL ) {
upSprite->SetVisible( GetViewOffset() > 0 );
}
idSWFSpriteInstance * const downSprite = GetSprite()->GetScriptObject()->GetSprite( "downIndicator" );
if ( downSprite != NULL ) {
downSprite->SetVisible( GetViewOffset() + GetNumVisibleOptions() < GetTotalNumberOfOptions() );
}
}
/*
========================
idMenuWidget_List::HandleAction
========================
*/
bool idMenuWidget_List::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
const idSWFParmList & parms = action.GetParms();
if ( action.GetType() == WIDGET_ACTION_SCROLL_VERTICAL ) {
const scrollType_t scrollType = static_cast< scrollType_t >( event.arg );
if ( scrollType == SCROLL_SINGLE ) {
Scroll( parms[ 0 ].ToInteger() );
} else if ( scrollType == SCROLL_PAGE ) {
ScrollOffset( parms[ 0 ].ToInteger() * ( GetNumVisibleOptions() - 1 ) );
} else if ( scrollType == SCROLL_FULL ) {
ScrollOffset( parms[ 0 ].ToInteger() * 999 );
}
return true;
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuWidget_List::ObserveEvent
========================
*/
void idMenuWidget_List::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
ExecuteEvent( event );
}
/*
========================
idMenuWidget_List::CalculatePositionFromIndexDelta
Pure functional encapsulation of how to calculate a new index and offset based on how the user
chose to move through the list.
========================
*/
void idMenuWidget_List::CalculatePositionFromIndexDelta( int & outIndex, int & outOffset, const int currentIndex, const int currentOffset, const int windowSize, const int maxSize, const int indexDelta, const bool allowWrapping, const bool wrapAround ) const {
assert( indexDelta != 0 );
int newIndex = currentIndex + indexDelta;
bool wrapped = false;
if ( indexDelta > 0 ) {
// moving down the list
if ( newIndex > maxSize - 1 ) {
if ( allowWrapping ) {
if ( wrapAround ) {
wrapped = true;
newIndex = 0 + ( newIndex - maxSize );
} else {
newIndex = 0;
}
} else {
newIndex = maxSize - 1;
}
}
} else {
// moving up the list
if ( newIndex < 0 ) {
if ( allowWrapping ) {
if ( wrapAround ) {
newIndex = maxSize + newIndex;
} else {
newIndex = maxSize - 1;
}
} else {
newIndex = 0;
}
}
}
// calculate the offset
if ( newIndex - currentOffset >= windowSize ) {
outOffset = newIndex - windowSize + 1;
} else if ( currentOffset > newIndex ) {
if ( wrapped ) {
outOffset = 0;
} else {
outOffset = newIndex;
}
} else {
outOffset = currentOffset;
}
outIndex = newIndex;
// the intended behavior is that outOffset and outIndex are always within maxSize of each
// other, as they are meant to model a window of items that should be visible in the list.
assert( outIndex - outOffset < windowSize );
assert( outIndex >= outOffset && outIndex >= 0 && outOffset >= 0 );
}
/*
========================
idMenuWidget_List::CalculatePositionFromOffsetDelta
========================
*/
void idMenuWidget_List::CalculatePositionFromOffsetDelta( int & outIndex, int & outOffset, const int currentIndex, const int currentOffset, const int windowSize, const int maxSize, const int offsetDelta ) const {
// shouldn't be setting both indexDelta AND offsetDelta
// FIXME: make this simpler code - just pass a boolean to control it?
assert( offsetDelta != 0 );
const int newOffset = Max( currentIndex + offsetDelta, 0 );
if ( newOffset >= maxSize ) {
// scrolling past the end - just scroll all the way to the end
outIndex = maxSize - 1;
outOffset = Max( maxSize - windowSize, 0 );
} else if ( newOffset >= maxSize - windowSize ) {
// scrolled to the last window
outIndex = newOffset;
outOffset = Max( maxSize - windowSize, 0 );
} else {
outIndex = outOffset = newOffset;
}
// the intended behavior is that outOffset and outIndex are always within maxSize of each
// other, as they are meant to model a window of items that should be visible in the list.
assert( outIndex - outOffset < windowSize );
assert( outIndex >= outOffset && outIndex >= 0 && outOffset >= 0 );
}
/*
========================
idMenuWidget_List::Scroll
========================
*/
void idMenuWidget_List::Scroll( const int scrollAmount, const bool wrapAround ) {
if ( GetTotalNumberOfOptions() == 0 ) {
return;
}
int newIndex, newOffset;
CalculatePositionFromIndexDelta( newIndex, newOffset, GetViewIndex(), GetViewOffset(), GetNumVisibleOptions(), GetTotalNumberOfOptions(), scrollAmount, IsWrappingAllowed(), wrapAround );
if ( newOffset != GetViewOffset() ) {
SetViewOffset( newOffset );
if ( menuData != NULL ) {
menuData->PlaySound( GUI_SOUND_FOCUS );
}
Update();
}
if ( newIndex != GetViewIndex() ) {
SetViewIndex( newIndex );
SetFocusIndex( newIndex - newOffset );
}
}
/*
========================
idMenuWidget_List::ScrollOffset
========================
*/
void idMenuWidget_List::ScrollOffset( const int scrollAmount ) {
if ( GetTotalNumberOfOptions() == 0 ) {
return;
}
int newIndex, newOffset;
CalculatePositionFromOffsetDelta( newIndex, newOffset, GetViewIndex(), GetViewOffset(), GetNumVisibleOptions(), GetTotalNumberOfOptions(), scrollAmount );
if ( newOffset != GetViewOffset() ) {
SetViewOffset( newOffset );
Update();
}
if ( newIndex != GetViewIndex() ) {
SetViewIndex( newIndex );
SetFocusIndex( newIndex - newOffset );
}
}
//*********************************************************************************
// GAME BROWSER LIST
//********************************************************************************
/*
========================
idMenuWidget_GameBrowserList::Update
========================
*/
void idMenuWidget_GameBrowserList::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
const int childIndex = GetViewOffset() + optionIndex;
bool shown = false;
if ( optionIndex < GetChildren().Num() ) {
idMenuWidget & child = GetChildByIndex( optionIndex );
child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
if ( child.BindSprite( root ) ) {
shown = PrepareListElement( child, childIndex );
if ( shown ) {
child.SetState( WIDGET_STATE_NORMAL );
child.GetSprite()->SetVisible( true );
child.Update();
} else {
child.GetSprite()->SetVisible( false );
}
}
}
}
idSWFSpriteInstance * const upSprite = GetSprite()->GetScriptObject()->GetSprite( "upIndicator" );
if ( upSprite != NULL ) {
upSprite->SetVisible( GetViewOffset() > 0 );
}
idSWFSpriteInstance * const downSprite = GetSprite()->GetScriptObject()->GetSprite( "downIndicator" );
if ( downSprite != NULL ) {
downSprite->SetVisible( GetViewOffset() + GetNumVisibleOptions() < GetTotalNumberOfOptions() );
}
}
/*
========================
idMenuWidget_GameBrowserList::PrepareListElement
========================
*/
bool idMenuWidget_GameBrowserList::PrepareListElement( idMenuWidget & widget, const int childIndex ) {
if ( childIndex >= games.Num() ) {
return false;
}
idMenuWidget_ServerButton * const button = dynamic_cast< idMenuWidget_ServerButton * >( &widget );
if ( button == NULL ) {
return false;
}
if ( games[childIndex].serverName.IsEmpty() ) {
return false;
}
const idBrowserEntry_t entry = games[childIndex];
button->SetButtonInfo( entry.serverName, entry.mapName, entry.modeName, entry.index, entry.players, entry.maxPlayers, entry.joinable, entry.validMap );
return true;
}
/*
========================
idMenuWidget_GameBrowserList::PrepareListElement
========================
*/
void idMenuWidget_GameBrowserList::ClearGames() {
games.Clear();
}
/*
========================
idMenuWidget_GameBrowserList::PrepareListElement
========================
*/
void idMenuWidget_GameBrowserList::AddGame( idStr name_, idStrId mapName_, idStr modeName_, int index_, int players_, int maxPlayers_, bool joinable_, bool validMap_ ) {
idBrowserEntry_t entry;
entry.serverName = name_;
entry.index = index_;
entry.players = players_;
entry.maxPlayers = maxPlayers_;
entry.joinable = joinable_;
entry.validMap = validMap_;
entry.mapName = mapName_;
entry.modeName = modeName_;
games.Append( entry );
}
/*
========================
idMenuWidget_GameBrowserList::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_GameBrowserList::GetTotalNumberOfOptions() const {
return games.Num();
}
/*
========================
idMenuWidget_GameBrowserList::PrepareListElement
========================
*/
int idMenuWidget_GameBrowserList::GetServerIndex() {
if ( GetViewIndex() < games.Num() ) {
return games[ GetViewIndex() ].index;
}
return -1;
}

View File

@@ -0,0 +1,126 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_LobbyList::Update
========================
*/
void idMenuWidget_LobbyList::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
for ( int i = 0; i < headings.Num(); ++i ) {
idSWFTextInstance * txtHeading = GetSprite()->GetScriptObject()->GetNestedText( va( "heading%d", i ) );
if ( txtHeading != NULL ) {
txtHeading->SetText( headings[i] );
txtHeading->SetStrokeInfo( true, 0.75f, 1.75f );
}
}
for ( int optionIndex = 0; optionIndex < GetNumVisibleOptions(); ++optionIndex ) {
bool shown = false;
if ( optionIndex < GetChildren().Num() ) {
idMenuWidget & child = GetChildByIndex( optionIndex );
child.SetSpritePath( GetSpritePath(), va( "item%d", optionIndex ) );
if ( child.BindSprite( root ) ) {
shown = PrepareListElement( child, optionIndex );
if ( shown ) {
child.GetSprite()->SetVisible( true );
child.Update();
} else {
child.GetSprite()->SetVisible( false );
}
}
}
}
}
/*
========================
idMenuWidget_LobbyList::PrepareListElement
========================
*/
bool idMenuWidget_LobbyList::PrepareListElement( idMenuWidget & widget, const int childIndex ) {
idMenuWidget_LobbyButton * const button = dynamic_cast< idMenuWidget_LobbyButton * >( &widget );
if ( button == NULL ) {
return false;
}
if ( !button->IsValid() ) {
return false;
}
return true;
}
/*
========================
idMenuWidget_LobbyList::SetHeadingInfo
========================
*/
void idMenuWidget_LobbyList::SetHeadingInfo( idList< idStr > & list ) {
headings.Clear();
for ( int index = 0; index < list.Num(); ++index ) {
headings.Append( list[ index ] );
}
}
/*
========================
idMenuWidget_LobbyList::SetEntryData
========================
*/
void idMenuWidget_LobbyList::SetEntryData( int index, idStr name, voiceStateDisplay_t voiceState ) {
if ( GetChildren().Num() == 0 || index >= GetChildren().Num() ) {
return;
}
idMenuWidget & child = GetChildByIndex( index );
idMenuWidget_LobbyButton * const button = dynamic_cast< idMenuWidget_LobbyButton * >( &child );
if ( button == NULL ) {
return;
}
button->SetButtonInfo( name, voiceState );
}

View File

@@ -0,0 +1,147 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_MenuBar::Initialize
========================
*/
void idMenuWidget_MenuBar::Initialize( idMenuHandler * data ) {
idMenuWidget::Initialize( data );
}
/*
========================
idMenuWidget_MenuBar::Update
========================
*/
void idMenuWidget_MenuBar::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
totalWidth = 0.0f;
buttonPos = 0.0f;
for ( int index = 0; index < GetNumVisibleOptions(); ++index ) {
if ( index >= children.Num() ) {
break;
}
if ( index != 0 ) {
totalWidth += rightSpacer;
}
idMenuWidget & child = GetChildByIndex( index );
child.SetSpritePath( GetSpritePath(), va( "btn%d", index ) );
if ( child.BindSprite( root ) ) {
PrepareListElement( child, index );
child.Update();
}
}
// 640 is half the size of our flash files width
float xPos = 640.0f - ( totalWidth / 2.0f );
GetSprite()->SetXPos( xPos );
idSWFSpriteInstance * backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" );
if ( backing != NULL ) {
if ( menuData != NULL && menuData->GetPlatform() != 2 ) {
backing->SetVisible( false );
} else {
backing->SetVisible( true );
backing->SetXPos( totalWidth / 2.0f );
}
}
}
/*
========================
idMenuWidget_MenuBar::SetListHeadings
========================
*/
void idMenuWidget_MenuBar::SetListHeadings( idList< idStr > & list ) {
headings.Clear();
for ( int index = 0; index < list.Num(); ++index ) {
headings.Append( list[ index ] );
}
}
/*
========================
idMenuWidget_MenuBar::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_MenuBar::GetTotalNumberOfOptions() const {
return GetChildren().Num();
}
/*
========================
idMenuWidget_MenuBar::PrepareListElement
========================
*/
bool idMenuWidget_MenuBar::PrepareListElement( idMenuWidget & widget, const int navIndex ) {
if ( navIndex >= GetNumVisibleOptions() ) {
return false;
}
idMenuWidget_MenuButton * const button = dynamic_cast< idMenuWidget_MenuButton * >( &widget );
if ( button == NULL || button->GetSprite() == NULL ) {
return false;
}
if ( navIndex >= headings.Num() ) {
button->SetLabel( "" );
} else {
button->SetLabel( headings[navIndex] );
idSWFTextInstance * ti = button->GetSprite()->GetScriptObject()->GetNestedText( "txtVal" );
if ( ti != NULL ) {
ti->SetStrokeInfo( true, 0.7f, 1.25f );
ti->SetText( headings[ navIndex ] );
button->SetPosition( buttonPos );
totalWidth += ti->GetTextLength();
buttonPos += rightSpacer + ti->GetTextLength();
}
}
return true;
}

View File

@@ -0,0 +1,175 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_NavBar::Initialize
========================
*/
void idMenuWidget_NavBar::Initialize( idMenuHandler * data ) {
idMenuWidget::Initialize( data );
}
/*
========================
idMenuWidget_NavBar::PrepareListElement
========================
*/
void idMenuWidget_NavBar::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) ) {
return;
}
int rightIndex = 0;
buttonPos = initialPos;
for ( int index = 0; index < GetNumVisibleOptions() - 1; ++index ) {
idSWFSpriteInstance * const rightOption = GetSprite()->GetScriptObject()->GetSprite( va( "optionRight%d", index ) );
rightOption->SetVisible( false );
idSWFSpriteInstance * const leftOption = GetSprite()->GetScriptObject()->GetSprite( va( "optionLeft%d", index ) );
leftOption->SetVisible( false );
}
for ( int index = 0; index < GetTotalNumberOfOptions(); ++index ) {
idMenuWidget & child = GetChildByIndex( index );
idMenuWidget_NavButton * const button = dynamic_cast< idMenuWidget_NavButton * >( &child );
button->SetLabel( "" );
}
for ( int index = 0; index < GetNumVisibleOptions(); ++index ) {
if ( index < GetFocusIndex() ) {
idMenuWidget & child = GetChildByIndex( index );
child.SetSpritePath( GetSpritePath(), va( "optionLeft%d", index ) );
if ( child.BindSprite( root ) ) {
PrepareListElement( child, index );
child.Update();
}
} else if ( index > GetFocusIndex() ) {
int rightChildIndex = ( GetNumVisibleOptions() - 1 ) + ( index - 1 );
idMenuWidget & child = GetChildByIndex( rightChildIndex );
child.SetSpritePath( GetSpritePath(), va( "optionRight%d", rightIndex ) );
rightIndex++;
if ( child.BindSprite( root ) ) {
PrepareListElement( child, index );
child.Update();
}
} else {
int mainIndex = GetTotalNumberOfOptions() - 1;
idMenuWidget & child = GetChildByIndex( mainIndex );
child.SetSpritePath( GetSpritePath(), va( "option" ) );
if ( child.BindSprite( root ) ) {
PrepareListElement( child, index );
child.Update();
}
}
}
}
/*
========================
idMenuWidget_NavBar::SetListHeadings
========================
*/
void idMenuWidget_NavBar::SetListHeadings( idList< idStr > & list ) {
headings.Clear();
for ( int index = 0; index < list.Num(); ++index ) {
headings.Append( list[ index ] );
}
}
/*
========================
idMenuWidget_NavBar::GetTotalNumberOfOptions
========================
*/
int idMenuWidget_NavBar::GetTotalNumberOfOptions() const {
return GetChildren().Num();
}
/*
========================
idMenuWidget_NavBar::PrepareListElement
========================
*/
bool idMenuWidget_NavBar::PrepareListElement( idMenuWidget & widget, const int navIndex ) {
if ( navIndex >= GetNumVisibleOptions() || navIndex >= headings.Num() ) {
return false;
}
idMenuWidget_NavButton * const button = dynamic_cast< idMenuWidget_NavButton * >( &widget );
if ( button == NULL || button->GetSprite() == NULL ) {
return false;
}
button->SetLabel( headings[navIndex] );
idSWFTextInstance * ti = button->GetSprite()->GetScriptObject()->GetNestedText( "txtVal" );
if ( ti != NULL ) {
ti->SetStrokeInfo( true, 0.7f, 1.25f );
if ( navIndex < GetFocusIndex() ) {
ti->SetText( headings[ navIndex ] );
buttonPos = buttonPos + ti->GetTextLength();
button->SetPosition( buttonPos );
button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_LEFT );
buttonPos += leftSpacer;
} else if ( navIndex > GetFocusIndex() ) {
ti->SetText( headings[ navIndex ] );
ti->SetStrokeInfo( true, 0.7f, 1.25f );
button->GetSprite()->SetXPos( buttonPos );
button->SetPosition( buttonPos );
button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_RIGHT );
buttonPos = buttonPos + ti->GetTextLength() + rightSpacer;
} else {
ti->SetText( headings[ navIndex ] );
ti->SetStrokeInfo( true, 0.7f, 1.25f );
button->GetSprite()->SetXPos( buttonPos );
button->SetPosition( buttonPos );
button->SetNavIndex( navIndex, idMenuWidget_NavButton::NAV_WIDGET_SELECTED );
buttonPos = buttonPos + ti->GetTextLength() + selectedSpacer;
}
}
return true;
}

View File

@@ -0,0 +1,183 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_NavButton::Update
========================
*/
void idMenuWidget_NavButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
if ( btnLabel.IsEmpty() ) {
GetSprite()->SetVisible( false );
return;
}
GetSprite()->SetVisible( true );
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
idSWFTextInstance * const text = spriteObject->GetNestedText( "txtVal" );
if ( text != NULL ) {
text->SetText( btnLabel.c_str() );
text->SetStrokeInfo( true, 0.7f, 1.25f );
}
GetSprite()->SetXPos( xPos );
if ( navState == NAV_WIDGET_SELECTED ) {
idSWFSpriteInstance * backing = GetSprite()->GetScriptObject()->GetNestedSprite( "backing" );
if ( backing != NULL && text != NULL ) {
backing->SetXPos( text->GetTextLength() + 53.0f );
}
}
//
// events
//
idSWFScriptObject * textObj = spriteObject->GetNestedObj( "txtVal" );
if ( textObj != NULL ) {
textObj->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
textObj->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = textObj;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
}
/*
========================
idMenuWidget_NavButton::ExecuteEvent
========================
*/
bool idMenuWidget_NavButton::ExecuteEvent( const idWidgetEvent & event ) {
bool handled = false;
//// do nothing at all if it's disabled
if ( GetState() != WIDGET_STATE_DISABLED ) {
switch ( event.type ) {
case WIDGET_EVENT_PRESS: {
//AnimateToState( ANIM_STATE_DOWN );
handled = true;
break;
}
case WIDGET_EVENT_ROLL_OVER: {
if ( GetMenuData() ) {
GetMenuData()->PlaySound( GUI_SOUND_ROLL_OVER );
}
handled = true;
break;
}
}
}
idMenuWidget::ExecuteEvent( event );
return handled;
}
//*********************************************************************************************************
// idMenuWidget_MenuButton
/*
========================
idMenuWidget_NavButton::Update
========================
*/
void idMenuWidget_MenuButton::Update() {
if ( GetSprite() == NULL ) {
return;
}
if ( btnLabel.IsEmpty() ) {
GetSprite()->SetVisible( false );
return;
}
GetSprite()->SetVisible( true );
idSWFScriptObject * const spriteObject = GetSprite()->GetScriptObject();
idSWFTextInstance * const text = spriteObject->GetNestedText( "txtVal" );
if ( text != NULL ) {
text->SetText( btnLabel.c_str() );
text->SetStrokeInfo( true, 0.7f, 1.25f );
idSWFSpriteInstance * selBar = spriteObject->GetNestedSprite( "sel", "bar" );
idSWFSpriteInstance * hoverBar =spriteObject->GetNestedSprite( "hover", "bar" );
if ( selBar != NULL ) {
selBar->SetXPos( text->GetTextLength() / 2.0f );
selBar->SetScale( 100.0f * ( text->GetTextLength() / 300.0f ), 100.0f );
}
if ( hoverBar != NULL ) {
hoverBar->SetXPos( text->GetTextLength() / 2.0f );
hoverBar->SetScale( 100.0f * ( text->GetTextLength() / 352.0f ), 100.0f );
}
idSWFSpriteInstance * hitBox =spriteObject->GetNestedSprite( "hitBox" );
if ( hitBox != NULL ) {
hitBox->SetScale( 100.0f * ( text->GetTextLength() / 235 ), 100.0f );
}
}
GetSprite()->SetXPos( xPos );
idSWFScriptObject * textObj = spriteObject->GetNestedObj( "txtVal" );
if ( textObj != NULL ) {
textObj->Set( "onPress", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_PRESS, 0 ) );
textObj->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_RELEASE, 0 ) );
idSWFScriptObject * hitBox = spriteObject->GetObject( "hitBox" );
if ( hitBox == NULL ) {
hitBox = textObj;
}
hitBox->Set( "onRollOver", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OVER, 0 ) );
hitBox->Set( "onRollOut", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_ROLL_OUT, 0 ) );
}
}

View File

@@ -0,0 +1,188 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 MAX_AUDIO_ITEMS = 3;
/*
========================
idMenuWidget_PDA_AudioFiles::~idMenuWidget_PDA_AudioFiles
========================
*/
idMenuWidget_PDA_AudioFiles::~idMenuWidget_PDA_AudioFiles() {
}
/*
========================
idMenuWidget_PDA_AudioFiles::Initialize
========================
*/
void idMenuWidget_PDA_AudioFiles::Initialize( idMenuHandler * data ) {
idMenuWidget_DynamicList * pdaAudioList = new (TAG_SWF) idMenuWidget_DynamicList();
pdaAudioList->SetSpritePath( GetSpritePath(), "info", "options" );
pdaAudioList->SetNumVisibleOptions( MAX_AUDIO_ITEMS );
pdaAudioList->SetWrappingAllowed( true );
while ( pdaAudioList->GetChildren().Num() < MAX_AUDIO_ITEMS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_SELECT_PDA_AUDIO, pdaAudioList->GetChildren().Num() );
buttonWidget->Initialize( data );
pdaAudioList->AddChild( buttonWidget );
}
pdaAudioList->Initialize( data );
AddChild( pdaAudioList );
}
/*
========================
idMenuWidget_PDA_AudioFiles::Update
========================
*/
void idMenuWidget_PDA_AudioFiles::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( pdaIndex > player->GetInventory().pdas.Num() ) {
return;
}
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
idSWFScriptObject * dataObj = GetSprite()->GetScriptObject()->GetNestedObj( "info" );
if ( dataObj != NULL && pda != NULL ) {
idSWFTextInstance * txtOwner = dataObj->GetNestedText( "txtOwner" );
if ( txtOwner != NULL ) {
idStr ownerText = idLocalization::GetString( "#str_04203" );
ownerText.Append( ": ");
ownerText.Append( pda->GetFullName() );
txtOwner->SetText( ownerText.c_str() );
}
idMenuWidget_DynamicList * const audioList = dynamic_cast< idMenuWidget_DynamicList * >( &GetChildByIndex( 0 ) );
if ( audioList != NULL ) {
audioFileNames.Clear();
if ( pda->GetNumAudios() == 0 ) {
idList< idStr > audioName;
audioName.Append( idLocalization::GetString( "#str_04168" ) );
audioList->GetChildByIndex( 0 ).SetState( WIDGET_STATE_DISABLED );
audioFileNames.Append( audioName );
} else {
audioList->GetChildByIndex( 0 ).SetState( WIDGET_STATE_NORMAL );
const idDeclAudio *aud = NULL;
for ( int index = 0; index < pda->GetNumAudios(); ++index ) {
idList< idStr > audioName;
aud = pda->GetAudioByIndex( index );
if ( aud != NULL ) {
audioName.Append( aud->GetAudioName() );
} else {
audioName.Append( "" );
}
audioFileNames.Append( audioName );
}
}
audioList->SetListData( audioFileNames );
if ( audioList->BindSprite( root ) ) {
audioList->Update();
}
}
}
//idSWFSpriteInstance * dataSprite = dataObj->GetSprite();
}
/*
========================
idMenuWidget_PDA_AudioFiles::ObserveEvent
========================
*/
void idMenuWidget_PDA_AudioFiles::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
if ( GetSprite() != NULL ) {
if ( list->GetViewIndex() == 0 ) {
GetSprite()->PlayFrame( "rollOff" );
} else if ( ( pdaIndex == 0 || GetSprite()->GetCurrentFrame() <= 2 || GetSprite()->GetCurrentFrame() > GetSprite()->FindFrame( "idle" ) ) && list->GetViewIndex() != 0 ) {
GetSprite()->PlayFrame( "rollOn" );
}
}
pdaIndex = list->GetViewIndex();
if ( GetParent() != NULL && menuData != NULL && menuData->ActiveScreen() == PDA_AREA_USER_DATA ) {
GetParent()->Update();
} else {
Update();
}
idMenuWidget_DynamicList * const audioList = dynamic_cast< idMenuWidget_DynamicList * >( &GetChildByIndex( 0 ) );
if ( audioList != NULL ) {
audioList->SetFocusIndex( 0 );
audioList->SetViewIndex( 0 );
}
break;
}
case WIDGET_EVENT_FOCUS_OFF: {
idMenuWidget_DynamicList * const audioList = dynamic_cast< idMenuWidget_DynamicList * >( &GetChildByIndex( 0 ) );
if ( audioList != NULL ) {
audioList->SetFocusIndex( 0 );
audioList->SetViewIndex( 0 );
}
Update();
break;
}
}
}

View File

@@ -0,0 +1,178 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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 MAX_EMAIL_ITEMS = 7;
/*
========================
idMenuWidget_PDA_EmailInbox::Initialize
========================
*/
void idMenuWidget_PDA_EmailInbox::Initialize( idMenuHandler * data ) {
idMenuWidget_ScrollBar * scrollbar = new (TAG_SWF) idMenuWidget_ScrollBar();
scrollbar->SetSpritePath( GetSpritePath(), "info", "scrollbar" );
scrollbar->Initialize( data );
emailList = new (TAG_SWF) idMenuWidget_DynamicList();
emailList->SetSpritePath( GetSpritePath(), "info", "options" );
emailList->SetNumVisibleOptions( MAX_EMAIL_ITEMS );
emailList->SetWrappingAllowed( true );
while ( emailList->GetChildren().Num() < MAX_EMAIL_ITEMS ) {
idMenuWidget_Button * const buttonWidget = new (TAG_SWF) idMenuWidget_Button();
buttonWidget->AddEventAction( WIDGET_EVENT_PRESS ).Set( WIDGET_ACTION_PDA_SELECT_EMAIL, emailList->GetChildren().Num() );
buttonWidget->AddEventAction( WIDGET_EVENT_FOCUS_ON ).Set( WIDGET_ACTION_REFRESH );
buttonWidget->Initialize( data );
buttonWidget->RegisterEventObserver( scrollbar );
emailList->AddChild( buttonWidget );
}
emailList->Initialize( data );
emailList->AddChild( scrollbar );
AddChild( emailList );
}
/*
========================
idMenuWidget_PDA_EmailInbox::Update
========================
*/
void idMenuWidget_PDA_EmailInbox::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( pdaIndex > player->GetInventory().pdas.Num() ) {
return;
}
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
idSWFScriptObject * dataObj = GetSprite()->GetScriptObject()->GetNestedObj( "info" );
if ( dataObj != NULL && pda != NULL ) {
idSWFTextInstance * txtOwner = dataObj->GetNestedText( "heading", "txtOwner" );
if ( txtOwner != NULL ) {
idStr ownerText = idLocalization::GetString( "#str_01474" );
ownerText.Append( ": ");
if ( pdaIndex == 0 ) {
ownerText.Append( session->GetLocalUserName(0) );
} else {
ownerText.Append( pda->GetFullName() );
}
txtOwner->SetText( ownerText.c_str() );
if ( pdaIndex == 0 ) {
txtOwner->SetIgnoreColor( false );
} else {
txtOwner->SetIgnoreColor( false );
txtOwner->SetText( pda->GetFullName() );
}
}
if ( emailList != NULL ) {
const idDeclEmail *email = NULL;
emailInfo.Clear();
for ( int index = 0; index < pda->GetNumEmails(); ++index ) {
idList< idStr > emailData;
email = pda->GetEmailByIndex( index );
if ( email != NULL ) {
emailData.Append( email->GetFrom() );
emailData.Append( email->GetSubject() );
emailData.Append( email->GetDate() );
}
emailInfo.Append( emailData );
}
emailList->SetListData( emailInfo );
if ( emailList->BindSprite( root ) ) {
emailList->Update();
}
}
}
}
/*
========================
idMenuWidget_PDA_EmailInbox::ObserveEvent
========================
*/
void idMenuWidget_PDA_EmailInbox::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
int oldIndex = pdaIndex;
if ( list != NULL ) {
pdaIndex = list->GetViewIndex();
Update();
}
if ( emailList != NULL && oldIndex != pdaIndex ) {
emailList->SetFocusIndex( 0 );
emailList->SetViewIndex( 0 );
emailList->SetViewOffset( 0 );
}
break;
}
case WIDGET_EVENT_FOCUS_OFF: {
Update();
if ( emailList != NULL ) {
emailList->SetFocusIndex( 0 );
emailList->SetViewIndex( 0 );
emailList->SetViewOffset( 0 );
}
break;
}
}
}

View File

@@ -0,0 +1,156 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_PDA_Objective::Update
========================
*/
void idMenuWidget_PDA_Objective::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
idSWFScriptObject * dataObj = GetSprite()->GetScriptObject()->GetNestedObj( "info" );
idSWFSpriteInstance * dataSprite = dataObj->GetSprite();
if ( dataObj != NULL && dataSprite != NULL ) {
idSWFSpriteInstance * img = dataObj->GetNestedSprite( "objImg", "img" );
if ( player->GetInventory().objectiveNames.Num() == 0 ) {
dataSprite->StopFrame( 1 );
} else {
int numObjectives = player->GetInventory().objectiveNames.Num();
int objStartIndex = 0;
if ( numObjectives == 1 ) {
dataSprite->StopFrame( 2 );
objStartIndex = 0;
} else {
dataSprite->StopFrame( 3 );
objStartIndex = 1;
}
idSWFTextInstance * txtDesc = dataObj->GetNestedText( "txtDesc" );
int displayCount = 0;
for ( int index = numObjectives - 1; displayCount < 2 && index >= 0; --index ) {
if ( img != NULL ) {
if ( player->GetInventory().objectiveNames[index].screenshot == NULL ) {
img->SetVisible( false );
} else {
img->SetVisible( true );
img->SetMaterial( player->GetInventory().objectiveNames[index].screenshot );
}
}
idSWFSpriteInstance * objSel = dataObj->GetNestedSprite( va( "obj%d", objStartIndex - displayCount ), "sel" );
idSWFTextInstance * txtNote = dataObj->GetNestedText( va( "obj%d", objStartIndex - displayCount ), "txtVal" );
if ( objSel != NULL ) {
if ( displayCount == 0 ) {
objSel->SetVisible( true );
} else {
objSel->SetVisible( false );
}
}
if ( txtNote != NULL ) {
txtNote->SetText( player->GetInventory().objectiveNames[index].title.c_str() );
}
if ( displayCount == 0 ) {
txtDesc->SetText( player->GetInventory().objectiveNames[index].text.c_str() );
}
displayCount++;
}
}
// Set the main objective text
idTarget_SetPrimaryObjective * mainObj = player->GetPrimaryObjective();
idSWFTextInstance * txtMainObj = dataObj->GetNestedText( "txtObj" );
if ( txtMainObj != NULL ) {
if ( mainObj != NULL ) {
txtMainObj->SetText( mainObj->spawnArgs.GetString( "text", idLocalization::GetString( "#str_04253" ) ) );
} else {
txtMainObj->SetText( idLocalization::GetString( "#str_02526" ) );
}
}
}
}
/*
========================
idMenuWidget_Help::ObserveEvent
========================
*/
void idMenuWidget_PDA_Objective::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
if ( GetSprite() != NULL ) {
if ( list->GetViewIndex() == 0 ) {
GetSprite()->PlayFrame( "rollOn" );
} else if ( pdaIndex == 0 && list->GetViewIndex() != 0 ) {
GetSprite()->PlayFrame( "rollOff" );
}
}
pdaIndex = list->GetViewIndex();
Update();
break;
}
}
}

View File

@@ -0,0 +1,168 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_PDA_UserData::Update
========================
*/
void idMenuWidget_PDA_UserData::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
if ( pdaIndex > player->GetInventory().pdas.Num() ) {
return;
}
const idDeclPDA * pda = player->GetInventory().pdas[ pdaIndex ];
idSWFScriptObject * dataObj = GetSprite()->GetScriptObject();
if ( dataObj != NULL && pda != NULL ) {
idSWFTextInstance * txtName = dataObj->GetNestedText( "txtName" );
idSWFTextInstance * txtId = dataObj->GetNestedText( "txtId" );
idSWFTextInstance * txtLocation = dataObj->GetNestedText( "txtLocation" );
idSWFTextInstance * txtRank = dataObj->GetNestedText( "txtRank" );
idSWFTextInstance * txtClearance = dataObj->GetNestedText( "txtClearance" );
idSWFTextInstance * txtLocHeading = dataObj->GetNestedText( "txtLocHeading" );
if ( txtName != NULL ) {
if ( pdaIndex == 0 ) {
txtName->SetIgnoreColor( false );
txtName->SetText( session->GetLocalUserName(0) );
} else {
txtName->SetIgnoreColor( false );
txtName->SetText( pda->GetFullName() );
}
}
if ( txtLocHeading != NULL ) {
if ( pdaIndex == 0 ) {
txtLocHeading->SetText( idLocalization::GetString( "#str_02516" ) ); // location
} else {
txtLocHeading->SetText( idLocalization::GetString( "#str_02515" ) ); // post
}
}
if ( txtId != NULL ) {
txtId->SetText( pda->GetID() );
}
if ( txtLocation != NULL ) {
if ( pdaIndex == 0 ) {
idLocationEntity *locationEntity = gameLocal.LocationForPoint( player->GetEyePosition() );
if ( locationEntity ) {
txtLocation->SetText( locationEntity->GetLocation() );
} else {
txtLocation->SetText( idLocalization::GetString( "#str_02911" ) );
}
} else {
txtLocation->SetText( pda->GetPost() );
}
}
if ( txtRank != NULL ) {
txtRank->SetText( pda->GetTitle() );
}
if ( txtClearance != NULL ) {
const char *security = pda->GetSecurity();
if ( *security == NULL ) {
txtClearance->SetText( idLocalization::GetString( "#str_00066" ) );
} else {
txtClearance->SetText( security );
}
}
}
}
/*
========================
idMenuWidget_Help::ObserveEvent
========================
*/
void idMenuWidget_PDA_UserData::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
pdaIndex = list->GetViewIndex();
if ( GetParent() != NULL && menuData != NULL && menuData->ActiveScreen() == PDA_AREA_USER_DATA ) {
GetParent()->Update();
} else {
Update();
}
break;
}
case WIDGET_EVENT_FOCUS_OFF: {
// Don't do anything when losing focus. Focus updates come in pairs, so we can
// skip doing anything on the "lost focus" event, and instead do updates on the
// "got focus" event.
break;
}
case WIDGET_EVENT_ROLL_OVER: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
pdaIndex = list->GetViewIndex();
Update();
break;
}
case WIDGET_EVENT_ROLL_OUT: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
pdaIndex = list->GetViewIndex();
Update();
break;
}
}
}

View File

@@ -0,0 +1,116 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
void idMenuWidget_PDA_VideoInfo::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player == NULL ) {
return;
}
idSWFTextInstance * txtHeading = GetSprite()->GetScriptObject()->GetNestedText( "txtName" );
idSWFTextInstance * txtInfo = GetSprite()->GetScriptObject()->GetNestedText( "txtInfo" );
int numVideos = player->GetInventory().videos.Num();
if ( numVideos != 0 ) {
const idDeclVideo * video = player->GetVideo( videoIndex );
if( video != NULL ) {
if ( txtHeading != NULL ) {
txtHeading->SetText( video->GetVideoName() );
}
if ( txtInfo != NULL ) {
txtInfo->SetText( video->GetInfo() );
}
}
} else {
if ( txtHeading != NULL ) {
txtHeading->SetText( "" );
}
if ( txtInfo != NULL ) {
txtInfo->SetText( "" );
}
}
}
void idMenuWidget_PDA_VideoInfo::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
videoIndex = list->GetViewIndex();
idPlayer * player = gameLocal.GetLocalPlayer();
if ( player != NULL ) {
player->EndVideoDisk();
const idDeclVideo * video = player->GetVideo( videoIndex );
if ( video != NULL ) {
idSWFSpriteInstance * videoSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "video", "img" );
if ( videoSprite != NULL ) {
videoSprite->SetMaterial( video->GetPreview() );
}
}
}
if ( GetParent() != NULL ) {
idMenuScreen_PDA_VideoDisks * screen = dynamic_cast< idMenuScreen_PDA_VideoDisks * const >( GetParent() );
if ( screen != NULL ) {
screen->Update();
}
}
break;
}
}
}

View File

@@ -0,0 +1,261 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
void idMenuWidget_ScrollBar::Initialize( idMenuHandler * data ) {
idMenuWidget::Initialize( data );
AddEventAction( WIDGET_EVENT_DRAG_START ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_DRAG_START, WIDGET_EVENT_DRAG_START ) );
AddEventAction( WIDGET_EVENT_DRAG_STOP ).Set( new (TAG_SWF) idWidgetActionHandler( this, WIDGET_ACTION_EVENT_DRAG_STOP, WIDGET_EVENT_DRAG_STOP ) );
}
/*
========================
idMenuWidget_ScrollBar::Update
========================
*/
void idMenuWidget_ScrollBar::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
if ( GetParent() == NULL ) {
return;
}
CalcTopAndBottom();
idSWFScriptObject * node = GetSprite()->GetScriptObject()->GetNestedObj( "node" );
idSWFSpriteInstance * nodeSprite = GetSprite()->GetScriptObject()->GetNestedSprite( "node" );
if ( node != NULL && nodeSprite != NULL ) {
node->Set( "onDrag", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_DRAG_START, 0 ) );
node->Set( "onRelease", new ( TAG_SWF ) WrapWidgetSWFEvent( this, WIDGET_EVENT_DRAG_STOP, 0 ) );
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( GetParent() );
if ( list != NULL ) {
float percent = 0.0f;
if ( ( list->GetTotalNumberOfOptions() - list->GetNumVisibleOptions() ) > 0 ) {
percent = (float)list->GetViewOffset() / ( (float)list->GetTotalNumberOfOptions() - list->GetNumVisibleOptions() );
float range = yBot - yTop;
nodeSprite->SetVisible( true );
nodeSprite->SetYPos( percent * range );
//GetSprite()->StopFrame( int( ( percent * 100.0f ) + 2.0f ) );
} else {
nodeSprite->SetVisible( 0 );
}
}
idMenuWidget_InfoBox * const infoBox = dynamic_cast< idMenuWidget_InfoBox * const >( GetParent() );
if ( infoBox != NULL ) {
float percent = 0.0f;
if ( infoBox->GetMaxScroll() == 0 ) {
nodeSprite->SetVisible( 0 );
} else {
percent = (float)infoBox->GetScroll() / (float)infoBox->GetMaxScroll();
float range = yBot - yTop;
nodeSprite->SetVisible( true );
nodeSprite->SetYPos( percent * range );
//GetSprite()->StopFrame( int( ( percent * 100.0f ) + 2.0f ) );
}
}
}
}
/*
========================
idMenuWidget_ScrollBar::CalcTopAndBottom
========================
*/
void idMenuWidget_ScrollBar::CalcTopAndBottom() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
int tempPos = 0.0f;
idSWFSpriteInstance * curMC = GetSprite()->GetScriptObject()->GetNestedSprite( "top" );
if ( curMC != NULL ) {
tempPos = curMC->GetYPos();
while ( curMC->parent != NULL ) {
curMC = curMC->parent;
tempPos += curMC->GetYPos();
}
}
yTop = tempPos;
tempPos = 0.0f;
curMC = GetSprite()->GetScriptObject()->GetNestedSprite( "bottom" );
if ( curMC != NULL ) {
tempPos = curMC->GetYPos();
while ( curMC->parent != NULL ) {
curMC = curMC->parent;
tempPos += curMC->GetYPos();
}
}
yBot = tempPos;
}
/*
========================
idMenuWidget_ScrollBar::CalculatePosition
========================
*/
void idMenuWidget_ScrollBar::CalculatePosition( float x, float y ) {
if ( GetSprite() == NULL ) {
return;
}
if ( y >= yTop && y <= yBot ) {
float range = yBot - yTop;
float val = y - yTop;
float percent = val / range;
idSWFSpriteInstance * node = GetSprite()->GetScriptObject()->GetNestedSprite( "node" );
if ( node != NULL ) {
node->SetYPos( percent * range );
}
idMenuWidget_DynamicList * const list = dynamic_cast< idMenuWidget_DynamicList * const >( GetParent() );
if ( list != NULL ) {
float maxScroll = list->GetTotalNumberOfOptions() - list->GetNumVisibleOptions();
int offset = list->GetViewOffset();
float segment = ( maxScroll + 0.5f ) / 100.0f;
int newOffset = ( int )( ( ( percent * segment ) * 100.0f ) );
if ( newOffset >= maxScroll ) {
int i = 1;
i = i;
}
if ( newOffset != offset ) {
int viewIndex = list->GetViewIndex();
list->SetViewOffset( newOffset );
idLib::Printf( "newOffset = %d\n", newOffset );
if ( viewIndex < newOffset ) {
viewIndex = newOffset;
list->SetViewIndex( viewIndex );
} else if ( viewIndex > ( newOffset + list->GetNumVisibleOptions() - 1 ) ) {
viewIndex = ( newOffset + list->GetNumVisibleOptions() - 1 );
list->SetViewIndex( viewIndex );
}
idLib::Printf( "newView = %d\n", list->GetViewIndex() );
int newFocus = viewIndex - newOffset;
if ( newFocus >= 0 ) {
list->SetFocusIndex( newFocus );
}
list->Update();
}
}
idMenuWidget_InfoBox * const infoBox = dynamic_cast< idMenuWidget_InfoBox * const >( GetParent() );
if ( infoBox != NULL ) {
float maxScroll = infoBox->GetMaxScroll();
int scroll = infoBox->GetScroll();
float segment = ( maxScroll + 1.0f ) / 100.0f;
int newScroll = (int)( ( ( percent * segment ) * 100.0f ) );
if ( newScroll != scroll ) {
infoBox->SetScroll( newScroll );
}
}
}
}
/*
========================
idMenuWidget_ScrollBar::HandleAction
========================
*/
bool idMenuWidget_ScrollBar::HandleAction( idWidgetAction & action, const idWidgetEvent & event, idMenuWidget * widget, bool forceHandled ) {
widgetAction_t actionType = action.GetType();
switch ( actionType ) {
case WIDGET_ACTION_SCROLL_DRAG: {
if ( event.parms.Num() != 3 ) {
return true;
}
dragging = true;
float x = event.parms[0].ToFloat();
float y = event.parms[1].ToFloat();
bool initial = event.parms[2].ToBool();
if ( initial ) {
CalcTopAndBottom();
}
CalculatePosition( x, y );
return true;
}
case WIDGET_ACTION_EVENT_DRAG_STOP: {
dragging = false;
return true;
}
}
return idMenuWidget::HandleAction( action, event, widget, forceHandled );
}
/*
========================
idMenuWidget_Help::ObserveEvent
========================
*/
void idMenuWidget_ScrollBar::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
switch ( event.type ) {
case WIDGET_EVENT_SCROLL_UP:
case WIDGET_EVENT_SCROLL_DOWN:
case WIDGET_EVENT_SCROLL_UP_LSTICK:
case WIDGET_EVENT_SCROLL_UP_RSTICK:
case WIDGET_EVENT_SCROLL_DOWN_LSTICK:
case WIDGET_EVENT_SCROLL_DOWN_RSTICK:
case WIDGET_EVENT_FOCUS_ON: {
if ( !dragging ) {
Update();
}
break;
}
}
}

View File

@@ -0,0 +1,161 @@
/*
===========================================================================
Doom 3 BFG Edition GPL Source Code
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
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"
/*
========================
idMenuWidget_Shell_SaveInfo::Update
========================
*/
void idMenuWidget_Shell_SaveInfo::Update() {
if ( GetSWFObject() == NULL ) {
return;
}
idSWFScriptObject & root = GetSWFObject()->GetRootObject();
if ( !BindSprite( root ) || GetSprite() == NULL ) {
return;
}
const saveGameDetailsList_t & saveGameInfo = session->GetSaveGameManager().GetEnumeratedSavegames();
saveGameDetailsList_t sortedSaves = saveGameInfo;
sortedSaves.Sort( idSort_SavesByDate() );
for ( int slot = 0; slot < sortedSaves.Num(); ++slot ) {
const idSaveGameDetails & details = sortedSaves[slot];
if ( forSaveScreen && details.slotName.Icmp( "autosave" ) == 0 ) {
sortedSaves.RemoveIndex( slot );
slot--;
}
}
idStr info;
if ( loadIndex >= 0 && sortedSaves.Num() != 0 && loadIndex < sortedSaves.Num() ) {
const idSaveGameDetails & details = sortedSaves[ loadIndex ];
info.Append( Sys_TimeStampToStr( details.date ) );
info.Append( "\n" );
// PS3 only strings that use the dict just set
const char * expansionStr = "";
switch ( details.GetExpansion() ) {
case GAME_D3XP: expansionStr = idLocalization::GetString( "#str_swf_resurrection" ); break;
case GAME_D3LE: expansionStr = idLocalization::GetString( "#str_swf_lost_episodes" ); break;
case GAME_BASE: expansionStr = idLocalization::GetString( "#str_swf_doom3" ); break;
default: expansionStr = idLocalization::GetString( "#str_savegame_title" ); break;
}
const char * difficultyStr = "";
switch ( details.GetDifficulty() ) {
case 0: difficultyStr = idLocalization::GetString( "#str_04089" ); break;
case 1: difficultyStr = idLocalization::GetString( "#str_04091" ); break;
case 2: difficultyStr = idLocalization::GetString( "#str_04093" ); break;
case 3: difficultyStr = idLocalization::GetString( "#str_02357" ); break;
}
idStr summary;
summary.Format( idLocalization::GetString( "#str_swf_save_info_format" ), difficultyStr, Sys_SecToStr( details.GetPlaytime() ), expansionStr );
info.Append( summary );
if ( details.damaged ) {
info.Append( "\n" );
info.Append( va( "^1%s^0", idLocalization::GetString( "#str_swf_damaged" ) ) );
} else if ( details.GetSaveVersion() > BUILD_NUMBER ) {
info.Append( "\n" );
info.Append( va( "^1%s^0", idLocalization::GetString( "#str_swf_wrong_version" ) ) );
}
}
idSWFTextInstance * infoSprite = GetSprite()->GetScriptObject()->GetNestedText( "txtDesc" );
if ( infoSprite != NULL ) {
infoSprite->SetText( info );
}
idSWFSpriteInstance * img = GetSprite()->GetScriptObject()->GetNestedSprite( "img" );
if ( img != NULL ) {
// TODO_SPARTY: until we have a thumbnail hide the image
img->SetVisible( false );
}
}
/*
========================
idMenuWidget_Help::ObserveEvent
========================
*/
void idMenuWidget_Shell_SaveInfo::ObserveEvent( const idMenuWidget & widget, const idWidgetEvent & event ) {
const idMenuWidget_Button * const button = dynamic_cast< const idMenuWidget_Button * >( &widget );
if ( button == NULL ) {
return;
}
const idMenuWidget * const listWidget = button->GetParent();
if ( listWidget == NULL ) {
return;
}
switch ( event.type ) {
case WIDGET_EVENT_FOCUS_ON: {
const idMenuWidget_DynamicList * const list = dynamic_cast< const idMenuWidget_DynamicList * const >( listWidget );
loadIndex = list->GetViewIndex();
const saveGameDetailsList_t & detailList = session->GetSaveGameManager().GetEnumeratedSavegames();
bool hasAutoSave = false;
for ( int i = 0; i < detailList.Num(); ++i ) {
if ( detailList[i].slotName.Icmp( "autosave" ) == 0 ) {
hasAutoSave = true;
}
}
if ( forSaveScreen && ( ( detailList.Num() < MAX_SAVEGAMES - 1 ) || ( ( detailList.Num() == MAX_SAVEGAMES - 1 ) && hasAutoSave ) ) ) {
loadIndex -= 1;
}
Update();
idMenuScreen_Shell_Load * loadScreen = dynamic_cast< idMenuScreen_Shell_Load * >( GetParent() );
if ( loadScreen ) {
loadScreen->UpdateSaveEnumerations();
}
idMenuScreen_Shell_Save * saveScreen = dynamic_cast< idMenuScreen_Shell_Save * >( GetParent() );
if ( saveScreen ) {
saveScreen->UpdateSaveEnumerations();
}
break;
}
}
}