2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 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 Source Code. If not, please request a copy in writing from id Software at the address below.
24 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.
26 ===========================================================================
29 #include "../idlib/precompiled.h"
37 size_t idDeclPDA::Size( void ) const {
38 return sizeof( idDeclPDA );
46 void idDeclPDA::Print( void ) const {
47 common->Printf( "Implement me\n" );
55 void idDeclPDA::List( void ) const {
56 common->Printf( "Implement me\n" );
64 bool idDeclPDA::Parse( const char *text, const int textLength ) {
68 src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
69 src.SetFlags( DECL_LEXER_FLAGS );
70 src.SkipUntilString( "{" );
72 // scan through, identifying each individual parameter
75 if ( !src.ReadToken( &token ) ) {
83 if ( !token.Icmp( "name") ) {
84 src.ReadToken( &token );
89 if ( !token.Icmp( "fullname") ) {
90 src.ReadToken( &token );
95 if ( !token.Icmp( "icon") ) {
96 src.ReadToken( &token );
101 if ( !token.Icmp( "id") ) {
102 src.ReadToken( &token );
107 if ( !token.Icmp( "post") ) {
108 src.ReadToken( &token );
113 if ( !token.Icmp( "title") ) {
114 src.ReadToken( &token );
119 if ( !token.Icmp( "security") ) {
120 src.ReadToken( &token );
125 if ( !token.Icmp( "pda_email") ) {
126 src.ReadToken( &token );
127 emails.Append( token );
128 declManager->FindType(DECL_EMAIL, token);
132 if ( !token.Icmp( "pda_audio") ) {
133 src.ReadToken( &token );
134 audios.Append( token );
135 declManager->FindType(DECL_AUDIO, token);
139 if ( !token.Icmp( "pda_video") ) {
140 src.ReadToken( &token );
141 videos.Append( token );
142 declManager->FindType(DECL_VIDEO, token);
148 if ( src.HadError() ) {
149 src.Warning( "PDA decl '%s' had a parse error", GetName() );
153 originalVideos = videos.Num();
154 originalEmails = emails.Num();
160 idDeclPDA::DefaultDefinition
163 const char *idDeclPDA::DefaultDefinition( void ) const {
166 "\t" "name \"default pda\"\n"
175 void idDeclPDA::FreeData( void ) {
188 void idDeclPDA::AddVideo( const char *name, bool unique ) const {
189 if ( unique && ( videos.Find( name ) != NULL ) ) {
192 if ( declManager->FindType( DECL_VIDEO, name, false ) == NULL ) {
193 common->Printf( "Video %s not found\n", name );
196 videos.Append( name );
204 void idDeclPDA::AddAudio( const char *name, bool unique ) const {
205 if ( unique && ( audios.Find( name ) != NULL ) ) {
208 if ( declManager->FindType( DECL_AUDIO, name, false ) == NULL ) {
209 common->Printf( "Audio log %s not found\n", name );
212 audios.Append( name );
220 void idDeclPDA::AddEmail( const char *name, bool unique ) const {
221 if ( unique && ( emails.Find( name ) != NULL ) ) {
224 if ( declManager->FindType( DECL_EMAIL, name, false ) == NULL ) {
225 common->Printf( "Email %s not found\n", name );
228 emails.Append( name );
233 idDeclPDA::RemoveAddedEmailsAndVideos
236 void idDeclPDA::RemoveAddedEmailsAndVideos() const {
237 int num = emails.Num();
238 if ( originalEmails < num ) {
239 while ( num && num > originalEmails ) {
240 emails.RemoveIndex( --num );
244 if ( originalVideos < num ) {
245 while ( num && num > originalVideos ) {
246 videos.RemoveIndex( --num );
253 idDeclPDA::SetSecurity
256 void idDeclPDA::SetSecurity( const char *sec ) const {
262 idDeclPDA::GetNumVideos
265 const int idDeclPDA::GetNumVideos() const {
271 idDeclPDA::GetNumAudios
274 const int idDeclPDA::GetNumAudios() const {
280 idDeclPDA::GetNumEmails
283 const int idDeclPDA::GetNumEmails() const {
289 idDeclPDA::GetVideoByIndex
292 const idDeclVideo* idDeclPDA::GetVideoByIndex( int index ) const {
293 if ( index >= 0 && index < videos.Num() ) {
294 return static_cast< const idDeclVideo* >( declManager->FindType( DECL_VIDEO, videos[index], false ) );
301 idDeclPDA::GetAudioByIndex
304 const idDeclAudio* idDeclPDA::GetAudioByIndex( int index ) const {
305 if ( index >= 0 && index < audios.Num() ) {
306 return static_cast< const idDeclAudio* >( declManager->FindType( DECL_AUDIO, audios[index], false ) );
313 idDeclPDA::GetEmailByIndex
316 const idDeclEmail* idDeclPDA::GetEmailByIndex( int index ) const {
317 if ( index >= 0 && index < emails.Num() ) {
318 return static_cast< const idDeclEmail* >( declManager->FindType( DECL_EMAIL, emails[index], false ) );
328 size_t idDeclEmail::Size( void ) const {
329 return sizeof( idDeclEmail );
337 void idDeclEmail::Print( void ) const {
338 common->Printf( "Implement me\n" );
346 void idDeclEmail::List( void ) const {
347 common->Printf( "Implement me\n" );
355 bool idDeclEmail::Parse( const char *_text, const int textLength ) {
359 src.LoadMemory( _text, textLength, GetFileName(), GetLineNum() );
360 src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
361 src.SkipUntilString( "{" );
364 // scan through, identifying each individual parameter
367 if ( !src.ReadToken( &token ) ) {
371 if ( token == "}" ) {
375 if ( !token.Icmp( "subject") ) {
376 src.ReadToken( &token );
381 if ( !token.Icmp( "to") ) {
382 src.ReadToken( &token );
387 if ( !token.Icmp( "from") ) {
388 src.ReadToken( &token );
393 if ( !token.Icmp( "date") ) {
394 src.ReadToken( &token );
399 if ( !token.Icmp( "text") ) {
400 src.ReadToken( &token );
401 if ( token != "{" ) {
402 src.Warning( "Email decl '%s' had a parse error", GetName() );
405 while ( src.ReadToken( &token ) && token != "}" ) {
411 if ( !token.Icmp( "image") ) {
412 src.ReadToken( &token );
418 if ( src.HadError() ) {
419 src.Warning( "Email decl '%s' had a parse error", GetName() );
427 idDeclEmail::DefaultDefinition
430 const char *idDeclEmail::DefaultDefinition( void ) const {
434 "\t\t" "to\t5Mail recipient\n"
435 "\t\t" "subject\t5Nothing\n"
436 "\t\t" "from\t5No one\n"
443 idDeclEmail::FreeData
446 void idDeclEmail::FreeData( void ) {
454 size_t idDeclVideo::Size( void ) const {
455 return sizeof( idDeclVideo );
463 void idDeclVideo::Print( void ) const {
464 common->Printf( "Implement me\n" );
472 void idDeclVideo::List( void ) const {
473 common->Printf( "Implement me\n" );
481 bool idDeclVideo::Parse( const char *text, const int textLength ) {
485 src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
486 src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
487 src.SkipUntilString( "{" );
489 // scan through, identifying each individual parameter
492 if ( !src.ReadToken( &token ) ) {
496 if ( token == "}" ) {
500 if ( !token.Icmp( "name") ) {
501 src.ReadToken( &token );
506 if ( !token.Icmp( "preview") ) {
507 src.ReadToken( &token );
512 if ( !token.Icmp( "video") ) {
513 src.ReadToken( &token );
515 declManager->FindMaterial( video );
519 if ( !token.Icmp( "info") ) {
520 src.ReadToken( &token );
525 if ( !token.Icmp( "audio") ) {
526 src.ReadToken( &token );
528 declManager->FindSound(audio);
534 if ( src.HadError() ) {
535 src.Warning( "Video decl '%s' had a parse error", GetName() );
543 idDeclVideo::DefaultDefinition
546 const char *idDeclVideo::DefaultDefinition( void ) const {
550 "\t\t" "name\t5Default Video\n"
557 idDeclVideo::FreeData
560 void idDeclVideo::FreeData( void ) {
568 size_t idDeclAudio::Size( void ) const {
569 return sizeof( idDeclAudio );
577 void idDeclAudio::Print( void ) const {
578 common->Printf( "Implement me\n" );
586 void idDeclAudio::List( void ) const {
587 common->Printf( "Implement me\n" );
595 bool idDeclAudio::Parse( const char *text, const int textLength ) {
599 src.LoadMemory( text, textLength, GetFileName(), GetLineNum() );
600 src.SetFlags( LEXFL_NOSTRINGCONCAT | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT | LEXFL_NOFATALERRORS );
601 src.SkipUntilString( "{" );
603 // scan through, identifying each individual parameter
606 if ( !src.ReadToken( &token ) ) {
610 if ( token == "}" ) {
614 if ( !token.Icmp( "name") ) {
615 src.ReadToken( &token );
620 if ( !token.Icmp( "audio") ) {
621 src.ReadToken( &token );
623 declManager->FindSound(audio);
627 if ( !token.Icmp( "info") ) {
628 src.ReadToken( &token );
633 if ( !token.Icmp( "preview") ) {
634 src.ReadToken( &token );
641 if ( src.HadError() ) {
642 src.Warning( "Audio decl '%s' had a parse error", GetName() );
650 idDeclAudio::DefaultDefinition
653 const char *idDeclAudio::DefaultDefinition( void ) const {
657 "\t\t" "name\t5Default Audio\n"
664 idDeclAudio::FreeData
667 void idDeclAudio::FreeData( void ) {