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 "ListGUILocal.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::StateChanged
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::StateChanged()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int i;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
if( !m_stateUpdates )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
for( i = 0; i < Num(); i++ )
|
|
|
|
{
|
|
|
|
m_pGUI->SetStateString( va( "%s_item_%i", m_name.c_str(), i ), ( *this )[i].c_str() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
for( i = Num() ; i < m_water ; i++ )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
m_pGUI->SetStateString( va( "%s_item_%i", m_name.c_str(), i ), "" );
|
|
|
|
}
|
|
|
|
m_water = Num();
|
|
|
|
m_pGUI->StateChanged( Sys_Milliseconds() );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::GetNumSelections
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
int idListGUILocal::GetNumSelections()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return m_pGUI->State().GetInt( va( "%s_numsel", m_name.c_str() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::GetSelection
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
int idListGUILocal::GetSelection( char* s, int size, int _sel ) const
|
|
|
|
{
|
|
|
|
if( s )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
s[ 0 ] = '\0';
|
|
|
|
}
|
|
|
|
int sel = m_pGUI->State().GetInt( va( "%s_sel_%i", m_name.c_str(), _sel ), "-1" );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( sel == -1 || sel >= m_ids.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( s )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idStr::snPrintf( s, size, m_pGUI->State().GetString( va( "%s_item_%i", m_name.c_str(), sel ), "" ) );
|
|
|
|
}
|
|
|
|
// don't let overflow
|
2012-11-28 15:47:07 +00:00
|
|
|
if( sel >= m_ids.Num() )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sel = 0;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
m_pGUI->SetStateInt( va( "%s_selid_0", m_name.c_str() ), m_ids[ sel ] );
|
2012-11-26 18:58:24 +00:00
|
|
|
return m_ids[ sel ];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::SetSelection
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::SetSelection( int sel )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
m_pGUI->SetStateInt( va( "%s_sel_0", m_name.c_str() ), sel );
|
|
|
|
StateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::Add
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::Add( int id, const idStr& s )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
int i = m_ids.FindIndex( id );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( i == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
Append( s );
|
|
|
|
m_ids.Append( id );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *this )[ i ] = s;
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
StateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::Push
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::Push( const idStr& s )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
Append( s );
|
|
|
|
m_ids.Append( m_ids.Num() );
|
|
|
|
StateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::Del
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idListGUILocal::Del( int id )
|
|
|
|
{
|
|
|
|
int i = m_ids.FindIndex( id );
|
|
|
|
if( i == -1 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
m_ids.RemoveIndex( i );
|
|
|
|
this->RemoveIndex( i );
|
|
|
|
StateChanged();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::Clear
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::Clear()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
m_ids.Clear();
|
|
|
|
idList<idStr, TAG_OLD_UI>::Clear();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( m_pGUI )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
// will clear all the GUI variables and will set m_water back to 0
|
|
|
|
StateChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::IsConfigured
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
bool idListGUILocal::IsConfigured() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return m_pGUI != NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::SetStateChanges
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::SetStateChanges( bool enable )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
m_stateUpdates = enable;
|
|
|
|
StateChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
====================
|
|
|
|
idListGUILocal::Shutdown
|
|
|
|
====================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
void idListGUILocal::Shutdown()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
m_pGUI = NULL;
|
|
|
|
m_name.Clear();
|
|
|
|
Clear();
|
|
|
|
}
|