SWF_Dictionary.cpp (4789B)
1 /* 2 =========================================================================== 3 4 Doom 3 BFG Edition GPL Source Code 5 Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company. 6 7 This file is part of the Doom 3 BFG Edition GPL Source Code ("Doom 3 BFG Edition Source Code"). 8 9 Doom 3 BFG Edition 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. 13 14 Doom 3 BFG Edition 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. 18 19 You should have received a copy of the GNU General Public License 20 along with Doom 3 BFG Edition Source Code. If not, see <http://www.gnu.org/licenses/>. 21 22 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. 23 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. 25 26 =========================================================================== 27 */ 28 #pragma hdrstop 29 #include "../idlib/precompiled.h" 30 31 /* 32 ======================== 33 idSWF::idSWFDictionaryEntry::idSWFDictionaryEntry 34 ======================== 35 */ 36 idSWFDictionaryEntry::idSWFDictionaryEntry() : 37 type( SWF_DICT_NULL ), 38 material( NULL ), 39 shape( NULL ), 40 sprite( NULL ), 41 font( NULL ), 42 text( NULL ), 43 edittext( NULL ), 44 imageSize( 0, 0 ), 45 imageAtlasOffset( 0, 0 ), 46 channelScale( 1.0f, 1.0f, 1.0f, 1.0f ) { 47 } 48 49 /* 50 ======================== 51 idSWF::idSWFDictionaryEntry::idSWFDictionaryEntry 52 ======================== 53 */ 54 idSWFDictionaryEntry::~idSWFDictionaryEntry() { 55 delete shape; 56 delete sprite; 57 delete font; 58 delete text; 59 delete edittext; 60 } 61 62 /* 63 ======================== 64 idSWF::idSWFDictionaryEntry::operator= 65 This exists mostly so idList works right 66 ======================== 67 */ 68 idSWFDictionaryEntry & idSWFDictionaryEntry::operator=( idSWFDictionaryEntry & other ) { 69 type = other.type; 70 material = other.material; 71 shape = other.shape; 72 sprite = other.sprite; 73 font = other.font; 74 text = other.text; 75 edittext = other.edittext; 76 imageSize = other.imageSize; 77 imageAtlasOffset = other.imageAtlasOffset; 78 other.type = SWF_DICT_NULL; 79 other.material = NULL; 80 other.shape = NULL; 81 other.sprite = NULL; 82 other.font = NULL; 83 other.text = NULL; 84 other.edittext = NULL; 85 return *this; 86 } 87 88 /* 89 ======================== 90 idSWF::AddDictionaryEntry 91 ======================== 92 */ 93 idSWFDictionaryEntry * idSWF::AddDictionaryEntry( int characterID, swfDictType_t type ) { 94 95 if ( dictionary.Num() < characterID + 1 ) { 96 dictionary.SetNum( characterID + 1 ); 97 } 98 99 if ( dictionary[ characterID ].type != SWF_DICT_NULL ) { 100 idLib::Warning( "%s: Duplicate character %d", filename.c_str(), characterID ); 101 return NULL; 102 } 103 104 dictionary[ characterID ].type = type; 105 106 if ( ( type == SWF_DICT_SHAPE ) || ( type == SWF_DICT_MORPH ) ) { 107 dictionary[ characterID ].shape = new (TAG_SWF) idSWFShape; 108 } else if ( type == SWF_DICT_SPRITE ) { 109 dictionary[ characterID ].sprite = new (TAG_SWF) idSWFSprite( this ); 110 } else if ( type == SWF_DICT_FONT ) { 111 dictionary[ characterID ].font = new (TAG_SWF) idSWFFont; 112 } else if ( type == SWF_DICT_TEXT ) { 113 dictionary[ characterID ].text = new (TAG_SWF) idSWFText; 114 } else if ( type == SWF_DICT_EDITTEXT ) { 115 dictionary[ characterID ].edittext = new (TAG_SWF) idSWFEditText; 116 } 117 118 return &dictionary[ characterID ]; 119 } 120 121 /* 122 ======================== 123 FindDictionaryEntry 124 ======================== 125 */ 126 idSWFDictionaryEntry * idSWF::FindDictionaryEntry( int characterID, swfDictType_t type ) { 127 128 if ( dictionary.Num() < characterID + 1 ) { 129 idLib::Warning( "%s: Could not find character %d", filename.c_str(), characterID ); 130 return NULL; 131 } 132 133 if ( dictionary[ characterID ].type != type ) { 134 idLib::Warning( "%s: Character %d is the wrong type", filename.c_str(), characterID ); 135 return NULL; 136 } 137 138 return &dictionary[ characterID ]; 139 } 140 141 142 /* 143 ======================== 144 FindDictionaryEntry 145 ======================== 146 */ 147 idSWFDictionaryEntry * idSWF::FindDictionaryEntry( int characterID ) { 148 149 if ( dictionary.Num() < characterID + 1 ) { 150 idLib::Warning( "%s: Could not find character %d", filename.c_str(), characterID ); 151 return NULL; 152 } 153 154 return &dictionary[ characterID ]; 155 }