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.
|
|
|
|
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __WINVAR_H__
|
|
|
|
#define __WINVAR_H__
|
|
|
|
|
|
|
|
#include "Rectangle.h"
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
static const char* VAR_GUIPREFIX = "gui::";
|
|
|
|
static const int VAR_GUIPREFIX_LEN = strlen( VAR_GUIPREFIX );
|
2012-11-26 18:58:24 +00:00
|
|
|
|
|
|
|
class idWindow;
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinVar();
|
|
|
|
virtual ~idWinVar();
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void SetGuiInfo( idDict* gd, const char* _name );
|
|
|
|
const char* GetName() const
|
|
|
|
{
|
|
|
|
if( name )
|
|
|
|
{
|
|
|
|
if( guiDict && *name == '*' )
|
|
|
|
{
|
|
|
|
return guiDict->GetString( &name[1] );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
return "";
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
void SetName( const char* _name )
|
|
|
|
{
|
|
|
|
delete []name;
|
2012-11-26 18:58:24 +00:00
|
|
|
name = NULL;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( _name )
|
|
|
|
{
|
|
|
|
name = new( TAG_OLD_UI ) char[strlen( _name ) + 1];
|
|
|
|
strcpy( name, _name );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idWinVar& operator=( const idWinVar& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
guiDict = other.guiDict;
|
2012-11-28 15:47:07 +00:00
|
|
|
SetName( other.name );
|
2012-11-26 18:58:24 +00:00
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idDict* GetDict() const
|
|
|
|
{
|
|
|
|
return guiDict;
|
|
|
|
}
|
|
|
|
bool NeedsUpdate()
|
|
|
|
{
|
|
|
|
return ( guiDict != NULL );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Init( const char* _name, idWindow* win ) = 0;
|
|
|
|
virtual void Set( const char* val ) = 0;
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual void Update() = 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const = 0;
|
|
|
|
virtual size_t Size()
|
|
|
|
{
|
|
|
|
size_t sz = ( name ) ? strlen( name ) : 0;
|
|
|
|
return sz + sizeof( *this );
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile ) = 0;
|
|
|
|
virtual void ReadFromSaveGame( idFile* savefile ) = 0;
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
virtual float x() const = 0;
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void SetEval( bool b )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
eval = b;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
bool GetEval()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return eval;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2012-11-28 15:47:07 +00:00
|
|
|
idDict* guiDict;
|
|
|
|
char* name;
|
2012-11-26 18:58:24 +00:00
|
|
|
bool eval;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinBool : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinBool() : idWinVar() {};
|
|
|
|
~idWinBool() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetBool( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const bool& other )
|
|
|
|
{
|
|
|
|
return ( other == data );
|
|
|
|
}
|
|
|
|
bool& operator=( const bool& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetBool( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinBool& operator=( const idWinBool& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
operator bool() const
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = ( atoi( val ) != 0 );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetBool( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetBool( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
|
|
|
return va( "%i", data );
|
|
|
|
}
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// SaveGames
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual float x() const
|
|
|
|
{
|
|
|
|
return data ? 1.0f : 0.0f;
|
|
|
|
};
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
bool data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinStr : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinStr() : idWinVar() {};
|
|
|
|
~idWinStr() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
const char* name = GetName();
|
|
|
|
if( name[0] == 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = "";
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetString( name );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idStr& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const char* other ) const
|
|
|
|
{
|
|
|
|
return ( data == other );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idStr& operator=( const idStr& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->Set( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinStr& operator=( const idWinStr& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const char* () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.c_str();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idStr& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int LengthWithoutColors()
|
|
|
|
{
|
|
|
|
if( guiDict && name && *name )
|
|
|
|
{
|
|
|
|
data = guiDict->GetString( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data.LengthWithoutColors();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int Length()
|
|
|
|
{
|
|
|
|
if( guiDict && name && *name )
|
|
|
|
{
|
|
|
|
data = guiDict->GetString( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data.Length();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
void RemoveColors()
|
|
|
|
{
|
|
|
|
if( guiDict && name && *name )
|
|
|
|
{
|
|
|
|
data = guiDict->GetString( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
data.RemoveColors();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.c_str();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = val;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->Set( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetString( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual size_t Size()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
size_t sz = idWinVar::Size();
|
2012-11-28 15:47:07 +00:00
|
|
|
return sz + data.Allocated();
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// SaveGames
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int len = data.Length();
|
|
|
|
savefile->Write( &len, sizeof( len ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( len > 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( data.c_str(), len );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int len;
|
|
|
|
savefile->Read( &len, sizeof( len ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( len > 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data.Fill( ' ', len );
|
|
|
|
savefile->Read( &data[0], len );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// return wether string is emtpy
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual float x() const
|
|
|
|
{
|
|
|
|
return data[0] ? 1.0f : 0.0f;
|
|
|
|
};
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idStr data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinInt : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinInt() : idWinVar() {};
|
|
|
|
~idWinInt() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetInt( GetName() );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int& operator=( const int& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetInt( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinInt& operator=( const idWinInt& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator int () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
data = atoi( val );;
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetInt( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetInt( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
|
|
|
return va( "%i", data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// SaveGames
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
// no suitable conversion
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual float x() const
|
|
|
|
{
|
|
|
|
assert( false );
|
|
|
|
return 0.0f;
|
|
|
|
};
|
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
int data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinFloat : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinFloat() : idWinVar() {};
|
|
|
|
~idWinFloat() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetFloat( GetName() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
idWinFloat& operator=( const idWinFloat& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float& operator=( const float& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetFloat( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator float() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
data = atof( val );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetFloat( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetFloat( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
|
|
|
return va( "%f", data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual float x() const
|
|
|
|
{
|
|
|
|
return data;
|
|
|
|
};
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
float data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinRectangle : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinRectangle() : idWinVar() {};
|
|
|
|
~idWinRectangle() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
idVec4 v = guiDict->GetVec4( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
data.x = v.x;
|
|
|
|
data.y = v.y;
|
|
|
|
data.w = v.z;
|
|
|
|
data.h = v.w;
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idRectangle& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idWinRectangle& operator=( const idWinRectangle& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idRectangle& operator=( const idVec4& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVec4( GetName(), other );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
idRectangle& operator=( const idRectangle& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idVec4 v = data.ToVec4();
|
2012-11-28 15:47:07 +00:00
|
|
|
guiDict->SetVec4( GetName(), v );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idRectangle& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float x() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.x;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float y() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.y;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float w() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.w;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float h() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.h;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float Right() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.Right();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float Bottom() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.Bottom();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idVec4& ToVec4()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
static idVec4 ret;
|
|
|
|
ret = data.ToVec4();
|
|
|
|
return ret;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
if( strchr( val, ',' ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sscanf( val, "%f,%f,%f,%f", &data.x, &data.y, &data.w, &data.h );
|
2012-11-28 15:47:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sscanf( val, "%f %f %f %f", &data.x, &data.y, &data.w, &data.h );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idVec4 v = data.ToVec4();
|
2012-11-28 15:47:07 +00:00
|
|
|
guiDict->SetVec4( GetName(), v );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
idVec4 v = guiDict->GetVec4( s );
|
|
|
|
data.x = v.x;
|
|
|
|
data.y = v.y;
|
|
|
|
data.w = v.z;
|
|
|
|
data.h = v.w;
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.ToVec4().ToString();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idRectangle data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinVec2 : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinVec2() : idWinVar() {};
|
|
|
|
~idWinVec2() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetVec2( GetName() );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idVec2& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinVec2& operator=( const idWinVec2& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
idVec2& operator=( const idVec2& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVec2( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float x() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.x;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
float y() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.y;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
if( strchr( val, ',' ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sscanf( val, "%f,%f", &data.x, &data.y );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf( val, "%f %f", &data.x, &data.y );
|
|
|
|
}
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVec2( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idVec2& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetVec2( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.ToString();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
void Zero()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data.Zero();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idVec2 data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinVec4 : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinVec4() : idWinVar() {};
|
|
|
|
~idWinVec4() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetVec4( GetName() );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idVec4& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinVec4& operator=( const idWinVec4& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idVec4& operator=( const idVec4& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVec4( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idVec4& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float x() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.x;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float y() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.y;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float z() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.z;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float w() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.w;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
if( strchr( val, ',' ) )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
sscanf( val, "%f,%f,%f,%f", &data.x, &data.y, &data.z, &data.w );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sscanf( val, "%f %f %f %f", &data.x, &data.y, &data.z, &data.w );
|
|
|
|
}
|
|
|
|
if( guiDict )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
guiDict->SetVec4( GetName(), data );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetVec4( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.ToString();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void Zero()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data.Zero();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVec4( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
const idVec3& ToVec3() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.ToVec3();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idVec4 data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinVec3 : public idWinVar
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
|
|
|
idWinVec3() : idWinVar() {};
|
|
|
|
~idWinVec3() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinVar::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetVector( GetName() );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idVec3& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinVec3& operator=( const idWinVec3& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idVec3& operator=( const idVec3& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVector( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idVec3& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float x() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.x;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float y() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.y;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
float z() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.z;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
|
|
|
sscanf( val, "%f %f %f", &data.x, &data.y, &data.z );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVector( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetVector( s );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.ToString();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void Zero()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data.Zero();
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->SetVector( GetName(), data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
|
|
|
savefile->Write( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
|
|
|
savefile->Read( &data, sizeof( data ) );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idVec3 data;
|
|
|
|
};
|
|
|
|
|
2012-11-28 15:47:07 +00:00
|
|
|
class idWinBackground : public idWinStr
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinBackground() : idWinStr()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
mat = NULL;
|
|
|
|
};
|
|
|
|
~idWinBackground() {};
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void Init( const char* _name, idWindow* win )
|
|
|
|
{
|
|
|
|
idWinStr::Init( _name, win );
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetString( GetName() );
|
|
|
|
}
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const idStr& other ) const
|
|
|
|
{
|
|
|
|
return ( other == data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int operator==( const char* other ) const
|
|
|
|
{
|
|
|
|
return ( data == other );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idStr& operator=( const idStr& other )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->Set( GetName(), data );
|
|
|
|
}
|
|
|
|
if( mat )
|
|
|
|
{
|
|
|
|
if( data == "" )
|
|
|
|
{
|
|
|
|
( *mat ) = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *mat ) = declManager->FindMaterial( data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
idWinBackground& operator=( const idWinBackground& other )
|
|
|
|
{
|
|
|
|
idWinVar::operator=( other );
|
2012-11-26 18:58:24 +00:00
|
|
|
data = other.data;
|
|
|
|
mat = other.mat;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( mat )
|
|
|
|
{
|
|
|
|
if( data == "" )
|
|
|
|
{
|
|
|
|
( *mat ) = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *mat ) = declManager->FindMaterial( data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return *this;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const char* () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.c_str();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
operator const idStr& () const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
int Length()
|
|
|
|
{
|
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
data = guiDict->GetString( GetName() );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
return data.Length();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual const char* c_str() const
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
return data.c_str();
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Set( const char* val )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = val;
|
2012-11-28 15:47:07 +00:00
|
|
|
if( guiDict )
|
|
|
|
{
|
|
|
|
guiDict->Set( GetName(), data );
|
|
|
|
}
|
|
|
|
if( mat )
|
|
|
|
{
|
|
|
|
if( data == "" )
|
|
|
|
{
|
|
|
|
( *mat ) = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *mat ) = declManager->FindMaterial( data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void Update()
|
|
|
|
{
|
|
|
|
const char* s = GetName();
|
|
|
|
if( guiDict && s[0] != '\0' )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data = guiDict->GetString( s );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( mat )
|
|
|
|
{
|
|
|
|
if( data == "" )
|
|
|
|
{
|
|
|
|
( *mat ) = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *mat ) = declManager->FindMaterial( data );
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual size_t Size()
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
size_t sz = idWinVar::Size();
|
2012-11-28 15:47:07 +00:00
|
|
|
return sz + data.Allocated();
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
void SetMaterialPtr( const idMaterial** m )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
mat = m;
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
|
|
|
virtual void WriteToSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( &eval, sizeof( eval ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int len = data.Length();
|
|
|
|
savefile->Write( &len, sizeof( len ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( len > 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Write( data.c_str(), len );
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
virtual void ReadFromSaveGame( idFile* savefile )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
savefile->Read( &eval, sizeof( eval ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
int len;
|
|
|
|
savefile->Read( &len, sizeof( len ) );
|
2012-11-28 15:47:07 +00:00
|
|
|
if( len > 0 )
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
data.Fill( ' ', len );
|
|
|
|
savefile->Read( &data[0], len );
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
if( mat )
|
|
|
|
{
|
|
|
|
if( len > 0 )
|
|
|
|
{
|
|
|
|
( *mat ) = declManager->FindMaterial( data );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
( *mat ) = NULL;
|
2012-11-26 18:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-11-28 15:47:07 +00:00
|
|
|
|
2012-11-26 18:58:24 +00:00
|
|
|
protected:
|
|
|
|
idStr data;
|
2012-11-28 15:47:07 +00:00
|
|
|
const idMaterial** mat;
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
================
|
|
|
|
idMultiWinVar
|
|
|
|
multiplexes access to a list if idWinVar*
|
|
|
|
================
|
|
|
|
*/
|
2012-11-28 15:47:07 +00:00
|
|
|
class idMultiWinVar : public idList< idWinVar* >
|
|
|
|
{
|
2012-11-26 18:58:24 +00:00
|
|
|
public:
|
2012-11-28 15:47:07 +00:00
|
|
|
void Set( const char* val );
|
2012-11-26 18:58:24 +00:00
|
|
|
void Update();
|
2012-11-28 15:47:07 +00:00
|
|
|
void SetGuiInfo( idDict* dict );
|
2012-11-26 18:58:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* !__WINVAR_H__ */
|
|
|
|
|