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"
38 void CreateResourceIDs_f( const idCmdArgs &args ) {
41 idStrList resourceFiles;
52 if ( args.Argc() > 1 ) {
55 path = SOURCE_CODE_BASE_FOLDER"/";
56 path.Append( __FILE__ );
58 path.BackSlashesToSlashes();
61 common->Printf( "%s\n", path.c_str() );
62 Sys_ListFiles( path, "_resource.h", resourceFiles );
64 for ( i = 0; i < resourceFiles.Num(); i++ ) {
66 fileName = path + "/" + resourceFiles[i];
68 common->Printf( "creating IDs for %s...\n", fileName.c_str() );
70 if ( !src.LoadFile( fileName, true ) ) {
71 common->Warning( "couldn't load %s", fileName.c_str() );
83 while( src.ReadToken( &token ) ) {
85 src.ExpectAnyToken( &token );
86 if ( token == "ifdef" || token == "ifndef" ) {
88 } else if ( token == "define" ) {
89 src.ExpectTokenType( TT_NAME, 0, &token );
91 if ( token.Icmpn( "_APS_", 5 ) == 0 ) {
95 if ( token.Icmpn( "IDD_", 4 ) == 0 ) {
96 dialogs.AddUnique( token );
97 } else if ( token.Icmpn( "IDR_", 4 ) == 0 ) {
98 resources.AddUnique( token );
99 } else if ( token.Icmpn( "IDB_", 4 ) == 0 ) {
100 bitmaps.AddUnique( token );
101 } else if ( token.Icmpn( "IDI_", 4 ) == 0 ) {
102 icons.AddUnique( token );
103 } else if ( token.Icmpn( "IDS_", 4 ) == 0 ||
104 token.Icmpn( "IDP_", 4 ) == 0 ) {
105 strings.AddUnique( token );
106 } else if ( token.Icmpn( "IDC_", 4 ) == 0 ) {
107 controls.AddUnique( token );
109 commands.AddUnique( token );
118 int curResource, curControl, curCommand;
120 curResource = i ? i * 1000 : 100;
121 curCommand = 20000 + i * 1000;
122 curControl = i * 1000 + 200;
124 f = fileSystem->OpenExplicitFileWrite( fileName );
126 common->Warning( "couldn't write %s", fileName.c_str() );
130 f->WriteFloatString( "//{{NO_DEPENDENCIES}}\n"
131 "// Microsoft Visual C++ generated include file.\n"
135 for ( j = 0; j < dialogs.Num(); j++ ) {
136 f->WriteFloatString( "#define %-40s %d\n", dialogs[j].c_str(), curResource++ );
138 for ( j = 0; j < resources.Num(); j++ ) {
139 f->WriteFloatString( "#define %-40s %d\n", resources[j].c_str(), curResource++ );
141 for ( j = 0; j < bitmaps.Num(); j++ ) {
142 f->WriteFloatString( "#define %-40s %d\n", bitmaps[j].c_str(), curResource++ );
144 for ( j = 0; j < icons.Num(); j++ ) {
145 f->WriteFloatString( "#define %-40s %d\n", icons[j].c_str(), curResource++ );
147 for ( j = 0; j < strings.Num(); j++ ) {
148 f->WriteFloatString( "#define %-40s %d\n", strings[j].c_str(), curResource++ );
151 f->WriteFloatString( "\n" );
153 for ( j = 0; j < controls.Num(); j++ ) {
154 f->WriteFloatString( "#define %-40s %d\n", controls[j].c_str(), curControl++ );
157 f->WriteFloatString( "\n" );
159 for ( j = 0; j < commands.Num(); j++ ) {
161 // NOTE: special hack for Radiant
162 if ( commands[j].Cmp( "ID_ENTITY_START" ) == 0 ) {
163 f->WriteFloatString( "#define %-40s %d\n", commands[j].c_str(), 40000 );
166 if ( commands[j].Cmp( "ID_ENTITY_END" ) == 0 ) {
167 f->WriteFloatString( "#define %-40s %d\n", commands[j].c_str(), 45000 );
171 f->WriteFloatString( "#define %-40s %d\n", commands[j].c_str(), curCommand++ );
175 f->WriteFloatString( "\n// Next default values for new objects\n"
177 "#ifdef APSTUDIO_INVOKED\n"
178 "#ifndef APSTUDIO_READONLY_SYMBOLS\n"
179 "#define _APS_3D_CONTROLS 1\n"
180 "#define _APS_NEXT_RESOURCE_VALUE %d\n"
181 "#define _APS_NEXT_COMMAND_VALUE %d\n"
182 "#define _APS_NEXT_CONTROL_VALUE %d\n"
183 "#define _APS_NEXT_SYMED_VALUE %d\n"
185 "#endif\n", curResource, curCommand, curControl, curResource );
187 fileSystem->CloseFile( f );