2012-11-26 18:58:24 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
|
|
|
|
Doom 3 BFG Edition GPL Source Code
|
2012-11-28 15:47:07 +00:00
|
|
|
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
2012-11-26 18:58:24 +00:00
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code").
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Doom 3 BFG Edition Source Code is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
In addition, the Doom 3 BFG Edition Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 BFG Edition Source Code. If not, please request a copy in writing from id Software at the address below.
|
|
|
|
|
|
|
|
If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma hdrstop
|
2012-12-22 15:18:19 +00:00
|
|
|
#include "precompiled.h"
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
#include "DeviceContext.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "UserInterfaceLocal.h"
|
|
|
|
#include "ChoiceWindow.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
idChoiceWindow::InitVars
|
|
|
|
============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::InitVars( )
|
|
|
|
{
|
|
|
|
if( cvarStr.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvar = cvarSystem->Find( cvarStr );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !cvar )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
common->Warning( "idChoiceWindow::InitVars: gui '%s' window '%s' references undefined cvar '%s'", gui->GetSourceFile(), name.c_str(), cvarStr.c_str() );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
updateStr.Append( &cvarStr );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiStr.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
updateStr.Append( &guiStr );
|
|
|
|
}
|
|
|
|
updateStr.SetGuiInfo( gui->GetStateDict() );
|
|
|
|
updateStr.Update();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
============
|
|
|
|
idChoiceWindow::CommonInit
|
|
|
|
============
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::CommonInit()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = 0;
|
|
|
|
choiceType = 0;
|
|
|
|
cvar = NULL;
|
|
|
|
liveUpdate = true;
|
|
|
|
choices.Clear();
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idChoiceWindow::idChoiceWindow( idUserInterfaceLocal* g ) : idWindow( g )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
gui = g;
|
|
|
|
CommonInit();
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idChoiceWindow::~idChoiceWindow()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::RunNamedEvent( const char* eventName )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr event, group;
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !idStr::Cmpn( eventName, "cvar read ", 10 ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
event = eventName;
|
|
|
|
group = event.Mid( 10, event.Length() - 10 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !group.Cmp( updateGroup ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
UpdateVars( true, true );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( !idStr::Cmpn( eventName, "cvar write ", 11 ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
event = eventName;
|
|
|
|
group = event.Mid( 11, event.Length() - 11 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !group.Cmp( updateGroup ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
UpdateVars( false, true );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::UpdateVars( bool read, bool force )
|
|
|
|
{
|
|
|
|
if( force || liveUpdate )
|
|
|
|
{
|
|
|
|
if( cvar && cvarStr.NeedsUpdate() )
|
|
|
|
{
|
|
|
|
if( read )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvarStr.Set( cvar->GetString() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvar->SetString( cvarStr.c_str() );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !read && guiStr.NeedsUpdate() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
guiStr.Set( va( "%i", currentChoice ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
const char* idChoiceWindow::HandleEvent( const sysEvent_t* event, bool* updateVisuals )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int key;
|
|
|
|
bool runAction = false;
|
|
|
|
bool runAction2 = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( event->evType == SE_KEY )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
key = event->evValue;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( key == K_RIGHTARROW || key == K_KP_6 || key == K_MOUSE1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// never affects the state, but we want to execute script handlers anyway
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !event->evValue2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
RunScript( ON_ACTIONRELEASE );
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
currentChoice++;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( currentChoice >= choices.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = 0;
|
|
|
|
}
|
|
|
|
runAction = true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( key == K_LEFTARROW || key == K_KP_4 || key == K_MOUSE2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// never affects the state, but we want to execute script handlers anyway
|
2012-11-28 15:47:07 +00:00
|
|
|
if( !event->evValue2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
RunScript( ON_ACTIONRELEASE );
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
currentChoice--;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( currentChoice < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = choices.Num() - 1;
|
|
|
|
}
|
|
|
|
runAction = true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !event->evValue2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// is a key release with no action catch
|
|
|
|
return "";
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if( event->evType == SE_CHAR )
|
|
|
|
{
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
key = event->evValue;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int potentialChoice = -1;
|
2012-11-28 15:47:07 +00:00
|
|
|
for( int i = 0; i < choices.Num(); i++ )
|
|
|
|
{
|
|
|
|
if( toupper( key ) == toupper( choices[i][0] ) )
|
|
|
|
{
|
|
|
|
if( i < currentChoice && potentialChoice < 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
potentialChoice = i;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( i > currentChoice )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
potentialChoice = -1;
|
|
|
|
currentChoice = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( potentialChoice >= 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = potentialChoice;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
runAction = true;
|
|
|
|
runAction2 = true;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return "";
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( runAction )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
RunScript( ON_ACTION );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( choiceType == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvarStr.Set( va( "%i", currentChoice ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else if( values.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvarStr.Set( values[ currentChoice ] );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
cvarStr.Set( choices[ currentChoice ] );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
UpdateVars( false );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( runAction2 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
RunScript( ON_ACTIONRELEASE );
|
|
|
|
}
|
|
|
|
|
|
|
|
return cmd;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::ValidateChoice()
|
|
|
|
{
|
|
|
|
if( currentChoice < 0 || currentChoice >= choices.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( choices.Num() == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
choices.Append( "No Choices Defined" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::UpdateChoice()
|
|
|
|
{
|
|
|
|
if( !updateStr.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
UpdateVars( true );
|
2012-11-26 18:58:24 +00:00
|
|
|
updateStr.Update();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( choiceType == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// ChoiceType 0 stores current as an integer in either cvar or gui
|
|
|
|
// If both cvar and gui are defined then cvar wins, but they are both updated
|
2012-11-28 15:47:07 +00:00
|
|
|
if( updateStr[ 0 ]->NeedsUpdate() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = atoi( updateStr[ 0 ]->c_str() );
|
|
|
|
}
|
|
|
|
ValidateChoice();
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// ChoiceType 1 stores current as a cvar string
|
|
|
|
int c = ( values.Num() ) ? values.Num() : choices.Num();
|
|
|
|
int i;
|
2012-11-28 15:47:07 +00:00
|
|
|
for( i = 0; i < c; i++ )
|
|
|
|
{
|
|
|
|
if( idStr::Icmp( cvarStr.c_str(), ( values.Num() ) ? values[i] : choices[i] ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( i == c )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
i = 0;
|
|
|
|
}
|
|
|
|
currentChoice = i;
|
|
|
|
ValidateChoice();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idChoiceWindow::ParseInternalVar( const char* _name, idTokenParser* src )
|
|
|
|
{
|
|
|
|
if( idStr::Icmp( _name, "choicetype" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
choiceType = src->ParseInt();
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "currentchoice" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
currentChoice = src->ParseInt();
|
|
|
|
return true;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
return idWindow::ParseInternalVar( _name, src );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinVar* idChoiceWindow::GetWinVarByName( const char* _name, bool fixup, drawWin_t** owner )
|
|
|
|
{
|
|
|
|
if( idStr::Icmp( _name, "choices" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &choicesStr;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "values" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &choiceVals;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "cvar" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &cvarStr;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "gui" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &guiStr;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "liveUpdate" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &liveUpdate;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( idStr::Icmp( _name, "updateGroup" ) == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return &updateGroup;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
return idWindow::GetWinVarByName( _name, fixup, owner );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// update the lists whenever the WinVar have changed
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::UpdateChoicesAndVals()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idToken token;
|
|
|
|
idStr str2, str3;
|
|
|
|
idLexer src;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( latchedChoices.Icmp( choicesStr ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
choices.Clear();
|
|
|
|
src.FreeSource();
|
|
|
|
src.SetFlags( LEXFL_NOFATALERRORS | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
|
|
|
|
src.LoadMemory( choicesStr, choicesStr.Length(), "<ChoiceList>" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( src.IsLoaded() )
|
|
|
|
{
|
|
|
|
while( src.ReadToken( &token ) )
|
|
|
|
{
|
|
|
|
if( token == ";" )
|
|
|
|
{
|
|
|
|
if( str2.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
str2.StripTrailingWhitespace();
|
|
|
|
str2 = idLocalization::GetString( str2 );
|
2012-11-28 15:47:07 +00:00
|
|
|
choices.Append( str2 );
|
2012-11-26 18:58:24 +00:00
|
|
|
str2 = "";
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
str2 += token;
|
|
|
|
str2 += " ";
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( str2.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
str2.StripTrailingWhitespace();
|
|
|
|
choices.Append( str2 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
latchedChoices = choicesStr.c_str();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( choiceVals.Length() && latchedVals.Icmp( choiceVals ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
values.Clear();
|
|
|
|
src.FreeSource();
|
|
|
|
src.SetFlags( LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
|
|
|
|
src.LoadMemory( choiceVals, choiceVals.Length(), "<ChoiceVals>" );
|
|
|
|
str2 = "";
|
|
|
|
bool negNum = false;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( src.IsLoaded() )
|
|
|
|
{
|
|
|
|
while( src.ReadToken( &token ) )
|
|
|
|
{
|
|
|
|
if( token == "-" )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
negNum = true;
|
|
|
|
continue;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
if( token == ";" )
|
|
|
|
{
|
|
|
|
if( str2.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
str2.StripTrailingWhitespace();
|
|
|
|
values.Append( str2 );
|
|
|
|
str2 = "";
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( negNum )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
str2 += "-";
|
|
|
|
negNum = false;
|
|
|
|
}
|
|
|
|
str2 += token;
|
|
|
|
str2 += " ";
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( str2.Length() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
str2.StripTrailingWhitespace();
|
|
|
|
values.Append( str2 );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( choices.Num() != values.Num() )
|
|
|
|
{
|
|
|
|
common->Warning( "idChoiceWindow:: gui '%s' window '%s' has value count unequal to choices count", gui->GetSourceFile(), name.c_str() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
latchedVals = choiceVals.c_str();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::PostParse()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idWindow::PostParse();
|
|
|
|
UpdateChoicesAndVals();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
InitVars();
|
|
|
|
UpdateChoice();
|
2012-11-28 15:47:07 +00:00
|
|
|
UpdateVars( false );
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
flags |= WIN_CANFOCUS;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::Draw( int time, float x, float y )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idVec4 color = foreColor;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
UpdateChoicesAndVals();
|
|
|
|
UpdateChoice();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// FIXME: It'd be really cool if textAlign worked, but a lot of the guis have it set wrong because it used to not work
|
|
|
|
textAlign = 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( textShadow )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr shadowText = choices[currentChoice];
|
|
|
|
idRectangle shadowRect = textRect;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
shadowText.RemoveColors();
|
|
|
|
shadowRect.x += textShadow;
|
|
|
|
shadowRect.y += textShadow;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
dc->DrawText( shadowText, textScale, textAlign, colorBlack, shadowRect, false, -1 );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( hover && !noEvents && Contains( gui->CursorX(), gui->CursorY() ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
color = hoverColor;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
hover = false;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( flags & WIN_FOCUS )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
color = hoverColor;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
dc->DrawText( choices[currentChoice], textScale, textAlign, color, textRect, false, -1 );
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
void idChoiceWindow::Activate( bool activate, idStr& act )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idWindow::Activate( activate, act );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( activate )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// sets the gui state based on the current choice the window contains
|
|
|
|
UpdateChoice();
|
|
|
|
}
|
|
|
|
}
|