Changeset 248
- Timestamp:
- 04/12/08 18:01:39 (1 month ago)
- Files:
-
- GtkRadiant/branches/ZeroRadiant/install/games/q2w (deleted)
- GtkRadiant/branches/ZeroRadiant/install/games/q3ut4 (deleted)
- GtkRadiant/branches/ZeroRadiant/install/games/quake3 (deleted)
- GtkRadiant/branches/ZeroRadiant/install/games/ufoai (deleted)
- GtkRadiant/branches/ZeroRadiant/libs/str.h (modified) (3 diffs)
- GtkRadiant/branches/ZeroRadiant/radiant/dialog.cpp (modified) (3 diffs)
- GtkRadiant/branches/ZeroRadiant/radiant/dialog.h (modified) (1 diff)
- GtkRadiant/branches/ZeroRadiant/radiant/preferences.cpp (modified) (18 diffs)
- GtkRadiant/branches/ZeroRadiant/radiant/preferences.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
GtkRadiant/branches/ZeroRadiant/libs/str.h
r183 r248 59 59 #define __StrDup Q_StrDup 60 60 61 inline char* Q_StrDup(char* pStr) 62 { 63 if (pStr == NULL) 64 pStr = ""; 65 66 return strcpy(new char[strlen(pStr)+1], pStr); 61 inline char* Q_StrDup( char* _pStr ) { 62 const char* pStr = _pStr; 63 if ( pStr == NULL ) { 64 pStr = ""; 65 } 66 67 return strcpy( new char[ strlen( pStr ) + 1 ], pStr ); 67 68 } 68 69 69 inline char* Q_StrDup( const char* pStr)70 { 71 if (pStr == NULL) 72 pStr = ""; 73 74 return strcpy(new char[strlen(pStr)+1], pStr); 70 inline char* Q_StrDup( const char* pStr ) { 71 if ( pStr == NULL ) { 72 pStr = ""; 73 } 74 75 return strcpy( new char[strlen(pStr)+1], pStr ); 75 76 } 76 77 … … 287 288 else 288 289 { 289 g_pStrWork = "";290 290 g_pStrWork = new char[1]; 291 291 g_pStrWork[0] = '\0'; … … 328 328 else 329 329 { 330 g_pStrWork = "";331 330 g_pStrWork = new char[1]; 332 331 g_pStrWork[0] = '\0'; GtkRadiant/branches/ZeroRadiant/radiant/dialog.cpp
r197 r248 197 197 i++; 198 198 } 199 } break; 199 } 200 break; 201 case DLG_COMBO_BOX_INT: { 202 *(int*)data->buffer = gtk_combo_box_get_active( GTK_COMBO_BOX( data->object ) ); 203 } 204 break; 205 200 206 } 201 207 } … … 242 248 gtk_adjustment_set_value (GTK_ADJUSTMENT (data->object), (*(int*)data->buffer)); 243 249 break; 244 case DLG_COMBO_INT: 245 { 250 case DLG_COMBO_INT: { 246 251 GList *lst = GTK_LIST (GTK_COMBO (data->object)->list)->children; 247 252 char *entry = ""; … … 255 260 256 261 gtk_entry_set_text (GTK_ENTRY (GTK_COMBO (data->object)->entry), entry); 257 } break; 262 } 263 break; 264 case DLG_COMBO_BOX_INT: { 265 gtk_combo_box_set_active( GTK_COMBO_BOX( data->object ), *(int*)data->buffer ); 266 } 267 break; 258 268 } 259 269 } GtkRadiant/branches/ZeroRadiant/radiant/dialog.h
r192 r248 37 37 DLG_SPIN_INT, 38 38 DLG_ADJ_INT, 39 DLG_COMBO_INT 39 DLG_COMBO_INT, 40 DLG_COMBO_BOX_INT, 40 41 } DLG_DATA_TYPE; 41 42 GtkRadiant/branches/ZeroRadiant/radiant/preferences.cpp
r240 r248 967 967 strGlobalPref += "global.pref"; 968 968 969 if ( !mGlobalPrefs.WriteXMLFile(strGlobalPref.GetBuffer()))969 if ( !mGlobalPrefs.WriteXMLFile( strGlobalPref.GetBuffer() ) ) { 970 970 Sys_FPrintf(SYS_ERR, "Error occured while saving global prefs file '%s'\n", strGlobalPref.GetBuffer()); 971 } 971 972 } 972 973 973 974 void CGameDialog::DoGameInstall() { 975 // make sure console logging is on whenever we enter the installation loop 976 g_PrefsDlg.mGamesDialog.m_bLogConsole = true; 977 Sys_LogFile(); 974 978 mGameInstall.Run(); 975 979 } … … 981 985 m_bDoGameInstall = false; 982 986 983 DoModal(); 987 if ( DoModal() == IDCANCEL ) { 988 Error( "game selection dialog canceled, cannot continue" ); 989 return; 990 } 984 991 985 992 if ( m_bDoGameInstall ) { … … 1019 1026 gtk_box_pack_start( GTK_BOX( vbox ), text, FALSE, FALSE, 0 ); 1020 1027 1021 combo = gtk_combo_ new();1028 combo = gtk_combo_box_new_text(); 1022 1029 gtk_widget_show( combo ); 1023 1030 gtk_box_pack_start( GTK_BOX( vbox ), combo, FALSE, FALSE, 0 ); 1024 1025 // fill in with the game descriptions 1026 GList *combo_list = (GList*)NULL; 1027 list<CGameDescription *>::iterator iGame; 1028 for( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) { 1029 combo_list = g_list_append( combo_list, (void *)(*iGame)->mGameName.GetBuffer() ); 1030 } 1031 gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list ); 1032 g_list_free( combo_list ); 1033 1034 AddDialogData( combo, &m_nComboSelect, DLG_COMBO_INT ); 1031 AddDialogData( combo, &m_nComboSelect, DLG_COMBO_BOX_INT ); 1032 mGameCombo = GTK_COMBO_BOX( combo ); 1033 1034 UpdateGameCombo(); 1035 1035 1036 1036 check = gtk_check_button_new_with_label( "Auto load selected game on startup" ); … … 1126 1126 gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 ); 1127 1127 AddModalButton( button, IDOK ); 1128 1129 button = gtk_button_new_with_label( "Cancel" ); 1130 gtk_widget_show( button ); 1131 gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 ); 1132 AddModalButton( button, IDCANCEL ); 1128 1133 1129 1134 gtk_widget_set_usize( button, 60, -2 ); 1135 } 1136 1137 void CGameDialog::UpdateGameCombo() { 1138 // fill in with the game descriptions 1139 list<CGameDescription *>::iterator iGame; 1140 1141 if ( mGameCombo == NULL ) { 1142 Sys_Printf( "mGameCombo == NULL\n" ); 1143 return; 1144 } 1145 1146 // clear whatever is in - wtf no way to know how many text entries? 1147 // use set/get active to track 1148 gtk_combo_box_set_active( mGameCombo, 0 ); 1149 while ( gtk_combo_box_get_active( mGameCombo ) == 0 ) { 1150 gtk_combo_box_remove_text( mGameCombo, 0 ); 1151 gtk_combo_box_set_active( mGameCombo, 0 ); 1152 } 1153 1154 for ( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) { 1155 gtk_combo_box_append_text( mGameCombo, (*iGame)->mGameName.GetBuffer() ); 1156 } 1157 gtk_combo_box_set_active( mGameCombo, 0 ); 1130 1158 } 1131 1159 … … 1191 1219 } 1192 1220 1193 g_free( dirlist);1221 g_free( dirlist ); 1194 1222 } 1195 g_dir_close (dir); 1196 } 1223 g_dir_close( dir ); 1224 } 1225 1226 // entries in the combo need to be updated 1227 UpdateGameCombo(); 1197 1228 } 1198 1229 … … 1201 1232 list<CGameDescription *>::iterator iGame; 1202 1233 int i=0; 1203 for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++,i++) 1204 { 1205 if (i == m_nComboSelect) 1206 { 1234 for( iGame = mGames.begin(); iGame != mGames.end(); iGame++,i++ ) { 1235 if ( i == m_nComboSelect ) { 1207 1236 return (*iGame); 1208 1237 } … … 3139 3168 } 3140 3169 3170 static void CGameInstall::OnBtnBrowseEngine( GtkWidget *widget, gpointer data ) { 3171 Sys_Printf( "OnBtnBrowseEngine\n" ); 3172 3173 CGameInstall* i = static_cast<CGameInstall*>( data ); 3174 char *dir = dir_dialog( widget, "Select game directory", NULL ); 3175 3176 i->UpdateData( TRUE ); 3177 3178 if ( dir != NULL ) { 3179 i->m_strEngine = dir; 3180 i->UpdateData( FALSE ); 3181 free( dir ); 3182 } 3183 } 3184 3185 static void CGameInstall::OnGameSelectChanged( GtkWidget *widget, gpointer data ) { 3186 Sys_Printf( "OnGameSelectChanged\n" ); 3187 3188 CGameInstall* i = static_cast<CGameInstall*>( data ); 3189 i->UpdateData( TRUE ); 3190 i->m_strName = gtk_combo_box_get_active_text( GTK_COMBO_BOX( widget ) ); 3191 i->UpdateData( FALSE ); 3192 } 3193 3141 3194 void CGameInstall::BuildDialog() { 3142 GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry ;3195 GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry, *hbox; 3143 3196 3144 3197 dlg = m_pWidget; … … 3153 3206 gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 3154 3207 3155 combo = gtk_combo_ new();3208 combo = gtk_combo_box_new_text(); 3156 3209 gtk_widget_show( combo ); 3157 3210 gtk_box_pack_start( GTK_BOX( vbox1 ), combo, FALSE, FALSE, 0 ); 3158 3211 3159 GList *combo_list = NULL;3212 // GList *combo_list = NULL; 3160 3213 int iGame = 0; 3161 3214 while ( m_availGames[ iGame ] != GAME_NONE ) { 3162 3215 switch ( m_availGames[ iGame ] ) { 3163 3216 case GAME_Q2: 3164 combo_list = g_list_append( combo_list, "Quake II" );3217 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Quake II" ); 3165 3218 break; 3166 3219 case GAME_Q3: 3167 combo_list = g_list_append( combo_list, "Quake III Arena (including mods)" );3220 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Quake III Arena and mods" ); 3168 3221 break; 3169 3222 case GAME_URT: 3170 combo_list = g_list_append( combo_list, "Urban Terror (standalone)" );3223 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Urban Terror (standalone)" ); 3171 3224 break; 3172 3225 case GAME_UFOAI: 3173 combo_list = g_list_append( combo_list, "UFO: Alien Invasion" );3226 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "UFO: Alien Invasion" ); 3174 3227 break; 3175 3228 case GAME_Q2W: 3176 combo_list = g_list_append( combo_list, "Quake2World" );3229 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Quake2World" ); 3177 3230 break; 3178 3231 case GAME_WARSOW: 3179 combo_list = g_list_append( combo_list, "Warsow" );3232 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Warsow" ); 3180 3233 break; 3181 3234 case GAME_NEXUIZ: 3182 combo_list = g_list_append( combo_list, "Nexuiz" );3235 gtk_combo_box_append_text( GTK_COMBO_BOX( combo ), "Nexuiz" ); 3183 3236 break; 3184 3237 } 3185 3238 iGame++; 3186 3239 } 3187 gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list);3188 g _list_free( combo_list);3189 AddDialogData( combo, &m_nComboSelect, DLG_COMBO_INT );3240 AddDialogData( combo, &m_nComboSelect, DLG_COMBO_BOX_INT ); 3241 gtk_signal_connect( GTK_OBJECT( combo ), "changed", G_CALLBACK( OnGameSelectChanged ), this ); 3242 gtk_combo_box_set_active( GTK_COMBO_BOX( combo ), 0 ); // NOTE: will trigger signal 3190 3243 3191 3244 text = gtk_label_new( "Name:" ); … … 3201 3254 gtk_widget_show( text ); 3202 3255 gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 3256 3257 hbox = gtk_hbox_new( FALSE, 0 ); 3258 gtk_widget_show( hbox ); 3259 gtk_box_pack_start( GTK_BOX( vbox1 ), hbox, FALSE, FALSE, 0 ); 3203 3260 3204 3261 entry = gtk_entry_new(); 3205 3262 gtk_widget_show( entry ); 3206 gtk_box_pack_start( GTK_BOX( vbox1), entry, FALSE, FALSE, 0 );3263 gtk_box_pack_start( GTK_BOX( hbox ), entry, FALSE, FALSE, 0 ); 3207 3264 AddDialogData( entry, &m_strEngine, DLG_ENTRY_TEXT ); 3265 3266 button = gtk_button_new_with_label ("..."); 3267 gtk_widget_show( button ); 3268 gtk_signal_connect( GTK_OBJECT( button ), "clicked", GTK_SIGNAL_FUNC( OnBtnBrowseEngine ), this ); 3269 gtk_box_pack_start( GTK_BOX( hbox ), button, FALSE, FALSE, 0 ); 3208 3270 3209 3271 // this gets done in the project stuff atm … … 3224 3286 AddModalButton( button, IDOK ); 3225 3287 3288 button = gtk_button_new_with_label( "Cancel" ); 3289 gtk_widget_show( button ); 3290 gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 ); 3291 AddModalButton( button, IDCANCEL ); 3292 3226 3293 gtk_widget_set_usize( button, 60, -2 ); 3227 3294 } … … 3229 3296 void CGameInstall::Run() { 3230 3297 ScanGames(); 3231 DoModal(); 3298 if ( DoModal() == IDCANCEL ) { 3299 Sys_Printf( "game dialog cancelled\n" ); 3300 return; 3301 } 3232 3302 Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() ); 3233 3303 … … 3248 3318 switch ( m_availGames[ m_nComboSelect ] ) { 3249 3319 case GAME_Q2: { 3250 fprintf( fg, " gametools=\"%s games/quake2\"\n", g_strAppPath.GetBuffer() );3320 fprintf( fg, " gametools=\"%sinstalls/Quake2Pack/game\"\n", g_strAppPath.GetBuffer() ); 3251 3321 fprintf( fg, " prefix=\".quake2\"\n" ); 3252 3322 Str source = g_strAppPath.GetBuffer(); 3253 3323 source += "installs/"; 3254 3324 source += Q2_PACK; 3325 source += "/install/"; 3255 3326 Str dest = m_strEngine.GetBuffer(); 3256 3327 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3259 3330 } 3260 3331 case GAME_Q3: { 3261 fprintf( fg, " gametools=\"%s games/quake3\"\n", g_strAppPath.GetBuffer() );3332 fprintf( fg, " gametools=\"%sinstalls/Q3Pack/game\"\n", g_strAppPath.GetBuffer() ); 3262 3333 fprintf( fg, " prefix=\".q3a\"\n" ); 3263 3334 Str source = g_strAppPath.GetBuffer(); 3264 3335 source += "installs/"; 3265 3336 source += Q3_PACK; 3337 source += "/install/"; 3266 3338 Str dest = m_strEngine.GetBuffer(); 3267 3339 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3270 3342 } 3271 3343 case GAME_URT: { 3272 fprintf( fg, " gametools=\"%s games/q3ut4\"\n", g_strAppPath.GetBuffer() );3344 fprintf( fg, " gametools=\"%sinstalls/UrTPack/game\"\n", g_strAppPath.GetBuffer() ); 3273 3345 fprintf( fg, " prefix=\".q3a\"\n" ); 3274 3346 Str source = g_strAppPath.GetBuffer(); 3275 3347 source += "installs/"; 3276 3348 source += URT_PACK; 3349 source += "/install/"; 3277 3350 Str dest = m_strEngine.GetBuffer(); 3278 3351 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3281 3354 } 3282 3355 case GAME_UFOAI: { 3283 fprintf( fg, " gametools=\"%s games/ufoai\"\n", g_strAppPath.GetBuffer() );3356 fprintf( fg, " gametools=\"%sinstalls/UFOAIPack/game\"\n", g_strAppPath.GetBuffer() ); 3284 3357 fprintf( fg, " prefix=\".ufoai\"\n" ); 3285 3358 Str source = g_strAppPath.GetBuffer(); 3286 3359 source += "installs/"; 3287 3360 source += UFOAI_PACK; 3361 source += "/install/"; 3288 3362 Str dest = m_strEngine.GetBuffer(); 3289 3363 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3292 3366 } 3293 3367 case GAME_Q2W: { 3294 fprintf( fg, " gametools=\"%s games/q2w\"\n", g_strAppPath.GetBuffer() );3368 fprintf( fg, " gametools=\"%sinstalls/Q2WPack/game\"\n", g_strAppPath.GetBuffer() ); 3295 3369 fprintf( fg, " prefix=\".quake2world\"\n" ); 3296 3370 Str source = g_strAppPath.GetBuffer(); 3297 3371 source += "installs/"; 3298 3372 source += Q2W_PACK; 3373 source += "/install/"; 3299 3374 Str dest = m_strEngine.GetBuffer(); 3300 3375 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3303 3378 } 3304 3379 case GAME_WARSOW: { 3305 fprintf( fg, " gametools=\"% sgames/warsow\"\n", g_strAppPath.GetBuffer() );3380 fprintf( fg, " gametools=\"%installs/WarsowPack/game\"\n", g_strAppPath.GetBuffer() ); 3306 3381 fprintf( fg, " prefix=\".warsow\"\n" ); 3307 3382 Str source = g_strAppPath.GetBuffer(); 3308 3383 source += "installs/"; 3309 3384 source += WARSOW_PACK; 3385 source += "/install/"; 3310 3386 Str dest = m_strEngine.GetBuffer(); 3311 3387 CopyTree( source.GetBuffer(), dest.GetBuffer() ); … … 3314 3390 } 3315 3391 case GAME_NEXUIZ: { 3316 fprintf( fg, " gametools=\"%s games/nexuiz\"\n", g_strAppPath.GetBuffer() );3392 fprintf( fg, " gametools=\"%sinstalls/NexuizPack/game\"\n", g_strAppPath.GetBuffer() ); 3317 3393 fprintf( fg, " prefix=\".nexuiz\"\n" ); 3318 3394 Str source = g_strAppPath.GetBuffer(); 3319 3395 source += "installs/"; 3320 3396 source += NEXUIZ_PACK; 3397 source += "/install/"; 3321 3398 Str dest = m_strEngine.GetBuffer(); 3322 3399 CopyTree( source.GetBuffer(), dest.GetBuffer() ); GtkRadiant/branches/ZeroRadiant/radiant/preferences.h
r237 r248 214 214 void BuildDialog(); 215 215 216 static void OnBtnBrowseEngine( GtkWidget *widget, gpointer data ); 217 static void OnGameSelectChanged( GtkWidget *widget, gpointer data ); 218 216 219 enum gameType_e { 217 220 GAME_NONE = 0, … … 244 247 GtkWidget *mTopBox; ///< top level box used to store the dialog frame, must unhook after modal use 245 248 249 GtkComboBox *mGameCombo; // combo box holds the selection of available game 246 250 247 251 /*! … … 311 315 m_bForceLogConsole = false; 312 316 m_bDoGameInstall = true; // go through DoModal at least once 317 mGameCombo = NULL; 313 318 } 314 319 virtual ~CGameDialog(); … … 398 403 */ 399 404 static void SInstallCallback( GtkWidget *widget, gpointer data ); 405 406 void UpdateGameCombo(); 400 407 }; 401 408
