Changeset 192

Show
Ignore:
Timestamp:
12/24/07 18:10:45 (6 months ago)
Author:
timo
Message:

basic architecture for game configuration at runtime. writes out a .game, no sanity checks, does not copy any game pak data

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • GtkRadiant/branches/ZeroRadiant/config.py

    r190 r192  
    153153                if ( config == 'debug' ): 
    154154                        env.Append( CFLAGS = [ '-g' ] ) 
     155                        env.Append( CXXFLAGS = [ '-g' ] ) 
    155156                        env.Append( CPPDEFINES = [ '_DEBUG' ] )                          
    156157                else: 
    157158                        env.Append( CFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] ) 
     159                        env.Append( CXXFLAGS = [ '-O3', '-Winline', '-ffast-math', '-fno-unsafe-math-optimizations' ] ) 
    158160                        #env.Append( CFLAGS = [ '-march=pentium3' ] ) 
    159161 
  • GtkRadiant/branches/ZeroRadiant/radiant/dialog.cpp

    r185 r192  
    109109} 
    110110 
    111 void Dialog::AddDialogData (GtkObject *object, void *buf, DLG_DATA_TYPE type
     111void Dialog::AddDialogData( GtkObject *object, void *buf, DLG_DATA_TYPE type
    112112{ 
    113113  DLG_DATA *data; 
     
    121121} 
    122122 
    123 void Dialog::AddModalButton (GtkWidget *widget, int ret) 
    124 
    125   gtk_signal_connect (GTK_OBJECT (widget), "clicked", 
    126                       GTK_SIGNAL_FUNC (dialog_button_callback), GINT_TO_POINTER (ret)); 
     123void Dialog::AddModalButton( GtkWidget *widget, int ret ) { 
     124  gtk_signal_connect( GTK_OBJECT( widget ), "clicked", 
     125                      GTK_SIGNAL_FUNC( dialog_button_callback ), GINT_TO_POINTER( ret ) ); 
    127126} 
    128127 
     
    262261} 
    263262 
    264 void Dialog::EndModal (int code) 
    265 
     263void Dialog::EndModal( int code ) { 
    266264  m_nLoop = 0; 
    267265  m_nReturn = code; 
    268266} 
    269267 
    270 int Dialog::DoModal () 
    271 { 
    272   Create (); 
    273   UpdateData (FALSE); 
     268int Dialog::DoModal() 
     269{ 
     270  Create(); 
     271  UpdateData( FALSE ); 
    274272 
    275273  PreModal(); 
    276274 
    277   gtk_grab_add (m_pWidget); 
    278   gtk_widget_show (m_pWidget); 
     275  gtk_grab_add( m_pWidget ); 
     276  gtk_widget_show( m_pWidget ); 
    279277 
    280278  m_nLoop = 1; 
    281   while (m_nLoop) 
    282     gtk_main_iteration (); 
    283  
    284   if (m_pWidget != NULL) 
    285  
    286     UpdateData (TRUE); 
    287  
    288     gtk_grab_remove (m_pWidget); 
    289     gtk_widget_hide (m_pWidget); 
    290   } 
    291   PostModal (m_nReturn); 
     279  while ( m_nLoop ) { 
     280    gtk_main_iteration(); 
     281  } 
     282 
     283  if ( m_pWidget != NULL )
     284    UpdateData( TRUE ); 
     285 
     286    gtk_grab_remove( m_pWidget ); 
     287    gtk_widget_hide( m_pWidget ); 
     288  } 
     289  PostModal( m_nReturn ); 
    292290 
    293291  return m_nReturn; 
    294292} 
    295  
  • GtkRadiant/branches/ZeroRadiant/radiant/dialog.h

    r183 r192  
    7676  used in overloaded BuildDialog implementations to configure modal behaviour easily 
    7777  */ 
    78   void AddModalButton (GtkWidget *widget, int ret); 
     78  void AddModalButton( GtkWidget *widget, int ret ); 
    7979 
    8080 private: 
  • GtkRadiant/branches/ZeroRadiant/radiant/gtkmisc.cpp

    r185 r192  
    852852// Message Boxes 
    853853 
    854 void dialog_button_callback (GtkWidget *widget, gpointer data) 
    855 
     854void dialog_button_callback( GtkWidget *widget, gpointer data ) { 
    856855  GtkWidget *parent; 
    857856  int *loop, *ret; 
    858857 
    859   parent = gtk_widget_get_toplevel (widget); 
    860   loop = (int*)g_object_get_data (G_OBJECT (parent), "loop"); 
    861   ret = (int*)g_object_get_data (G_OBJECT (parent), "ret"); 
     858  parent = gtk_widget_get_toplevel( widget ); 
     859  loop = (int*)g_object_get_data( G_OBJECT( parent ), "loop" ); 
     860  ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); 
    862861 
    863862  *loop = 0; 
  • GtkRadiant/branches/ZeroRadiant/radiant/main.cpp

    r185 r192  
    420420} 
    421421 
    422 int main (int argc, char* argv[]) 
    423 
    424   char *libgl, *ptr; 
    425   int i, j, k; 
     422int main( int argc, char* argv[] ) { 
     423        char *libgl, *ptr; 
     424        int i, j, k; 
    426425 
    427426#ifdef _WIN32 
     
    443442  struct passwd *pw; 
    444443  seteuid(getuid()); 
    445   if (geteuid() == 0 && (loginname = getlogin()) != NULL && 
    446       (pw = getpwnam(loginname)) != NULL) 
    447     setuid(pw->pw_uid); 
     444  if ( geteuid() == 0 && ( loginname = getlogin() ) != NULL && ( pw = getpwnam(loginname) ) != NULL ) { 
     445          setuid(pw->pw_uid); 
     446  } 
    448447#endif 
    449448 
     
    508507  g_strBitmapsPath += "bitmaps/"; 
    509508 
    510 #if 0 
    511   // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=639 
    512   // now check if we are running from a network installation 
    513   // use a dummy file as the flag 
    514   FILE *f_netrun; 
    515   CString strNetrun; 
    516   strNetrun = g_strAppPath; strNetrun += NETRUN_FILENAME; 
    517   f_netrun = fopen(strNetrun.GetBuffer(), "r"); 
    518   if (f_netrun) 
    519   { 
    520     fclose(f_netrun); 
    521     g_PrefsDlg.m_bUseHomePath = true; 
    522   } 
    523 #endif 
    524509  CGameDialog::UpdateNetrun(false); // read the netrun configuration 
    525510 
    526   if (CGameDialog::GetNetrun()) 
    527   { 
     511  if ( CGameDialog::GetNetrun() ) { 
    528512    // we have to find a per-user g_strTempPath 
    529513    // this behaves the same as on Linux 
     
    574558  g_strAppPath = real; 
    575559 
    576 #if 0 
    577   printf("g_strAppPath: %s\n", g_strAppPath.GetBuffer()); 
    578 #endif 
    579  
    580560  // radiant is installed in the parent dir of "tools/" 
    581561  // NOTE: this is not very easy for debugging 
     
    584564  g_strBitmapsPath = g_strAppPath; 
    585565  g_strBitmapsPath += "bitmaps/"; 
    586 #if 0 
    587   printf("g_strBitmapsPath: %s\n", g_strBitmapsPath.GetBuffer()); 
    588 #endif 
    589566   
    590567  // we will set this right after the game selection is done 
     
    608585 
    609586  FILE *pid; 
    610   pid = fopen (g_pidFile.GetBuffer(), "r"); 
    611   if (pid != NULL) 
    612   { 
     587  pid = fopen( g_pidFile.GetBuffer(), "r" ); 
     588  if ( pid != NULL ) { 
    613589    fclose (pid); 
    614590    CString msg; 
     
    652628 
    653629  // create a primary .pid for global init run 
    654   pid = fopen (g_pidFile.GetBuffer(), "w"); 
    655   if (pid) 
    656     fclose (pid); 
     630  pid = fopen( g_pidFile.GetBuffer(), "w" ); 
     631  if ( pid ) { 
     632          fclose( pid ); 
     633  } 
    657634   
    658635  // a safe check to avoid people running broken installations 
     
    662639  // http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=431 
    663640#ifndef _DEBUG 
    664 #define CHECK_VERSION 
     641  //#define CHECK_VERSION 
    665642#endif 
    666643#ifdef CHECK_VERSION   
     
    729706   
    730707  g_qeglobals.disable_ini = false; 
    731   g_PrefsDlg.Init (); 
     708  g_PrefsDlg.Init(); 
    732709 
    733710  // close the primary 
    734   if (remove (g_pidFile.GetBuffer ()) == -1) 
    735   { 
     711  if ( remove( g_pidFile.GetBuffer () ) == -1 ) { 
    736712    CString msg; 
    737713    msg = "WARNING: Could not delete "; msg += g_pidGameFile; 
     
    846822 
    847823#ifndef SKIP_SPLASH 
    848   create_splash (); 
     824  create_splash(); 
    849825#endif 
    850826 
     
    866842 
    867843  // redirect Gtk warnings to the console 
    868   g_log_set_handler ("Gdk", (GLogLevelFlags)(G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING| 
     844  g_log_set_handler( "Gdk", (GLogLevelFlags)(G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING| 
    869845                                             G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG), error_redirect, NULL); 
    870   g_log_set_handler ("Gtk", (GLogLevelFlags)(G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING| 
     846  g_log_set_handler( "Gtk", (GLogLevelFlags)(G_LOG_LEVEL_ERROR|G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_WARNING| 
    871847                                             G_LOG_LEVEL_MESSAGE|G_LOG_LEVEL_INFO|G_LOG_LEVEL_DEBUG), error_redirect, NULL); 
    872848 
    873849  // spog - creates new filters list for the first time 
    874   g_qeglobals.d_savedinfo.filters = NULL; //initialise to NULL 
     850  g_qeglobals.d_savedinfo.filters = NULL; 
    875851  g_qeglobals.d_savedinfo.filters = FilterUpdate(g_qeglobals.d_savedinfo.filters); 
    876852 
    877   g_pParentWnd = new MainFrame (); 
    878  
    879   if (g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0) 
    880     Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer()); 
    881   else 
    882     Map_New(); 
     853  g_pParentWnd = new MainFrame(); 
     854 
     855  if ( g_PrefsDlg.m_bLoadLastMap && g_PrefsDlg.m_strLastMap.GetLength() > 0 ) { 
     856          Map_LoadFile(g_PrefsDlg.m_strLastMap.GetBuffer()); 
     857  } else { 
     858          Map_New(); 
     859  } 
    883860 
    884861  // load up shaders now that we have the map loaded 
    885862  // eviltypeguy 
    886   Texture_ShowStartupShaders (); 
     863  Texture_ShowStartupShaders(); 
    887864 
    888865#ifndef SKIP_SPLASH 
    889   gdk_window_raise (splash_screen->window); 
    890   gtk_window_set_transient_for (GTK_WINDOW (splash_screen), GTK_WINDOW (g_pParentWnd->m_pWidget)); 
    891   gtk_timeout_add (1000, try_destroy_splash, NULL); 
     866  gdk_window_raise(splash_screen->window); 
     867  gtk_window_set_transient_for( GTK_WINDOW( splash_screen ), GTK_WINDOW( g_pParentWnd->m_pWidget ) ); 
     868  gtk_timeout_add( 1000, try_destroy_splash, NULL ); 
    892869#endif 
    893870   
     
    897874  g_pParentWnd->DoWatchBSP(); 
    898875 
    899   gtk_main (); 
     876  gtk_main(); 
    900877 
    901878  // close the log file if any 
     
    909886  //   restricting it to linux build 
    910887#ifdef __linux__ 
    911   _exit (0); 
     888  _exit( 0 ); 
    912889#endif 
    913890  return 0; 
  • GtkRadiant/branches/ZeroRadiant/radiant/preferences.cpp

    r185 r192  
    2828#include "stdafx.h" 
    2929#include <glib.h> 
     30#include <assert.h> 
    3031#if defined (__linux__) || defined (__APPLE__) 
    3132#include <sys/stat.h> 
     
    958959} 
    959960 
    960 void CGameDialog::DoGameDialog() 
    961 
    962   // show the UI 
    963   DoModal(); 
    964  
    965   // unhook so we can use in other places 
    966   // we manually incref'ed it when creating, it won't be freed (destructor) 
    967   gtk_container_remove (GTK_CONTAINER (mTopBox), GetGlobalFrame()); 
    968  
    969   // we save the prefs file 
    970   SavePrefs(); 
     961void CGameDialog::DoGameInstall() { 
     962        mGameInstall.Run(); 
     963
     964 
     965void CGameDialog::DoGameDialog() { 
     966        // allow looping the game selection dialog with calls to the game configure dialog in between 
     967        while ( m_bDoGameInstall ) { 
     968                 
     969                m_bDoGameInstall = false; 
     970 
     971                DoModal(); 
     972                 
     973                if ( m_bDoGameInstall ) { 
     974                        DoGameInstall(); 
     975                        ScanForGames(); 
     976                        // and we will loop to do another DoModal dialog 
     977                } 
     978        } 
     979 
     980        // unhook so we can use in other places 
     981        // we manually incref'ed it when creating, it won't be freed (destructor) 
     982        gtk_container_remove( GTK_CONTAINER( mTopBox ), GetGlobalFrame() ); 
     983 
     984        // we save the prefs file 
     985        SavePrefs(); 
    971986} 
    972987 
     
    975990  GtkWidget *vbox, *text, *combo, *check; 
    976991 
    977   if (mFrame) 
    978     return mFrame; 
    979  
    980   mFrame = gtk_frame_new(NULL); 
    981   gtk_container_set_border_width(GTK_CONTAINER(mFrame), 5); 
    982   gtk_widget_show(mFrame); 
    983  
    984   vbox = gtk_vbox_new (FALSE, 6); 
    985   gtk_widget_show (vbox); 
    986   gtk_container_add (GTK_CONTAINER (mFrame), vbox); 
    987   gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); 
    988  
    989   text = gtk_label_new("Select the game:"); 
    990   gtk_widget_show(text); 
    991   gtk_box_pack_start (GTK_BOX(vbox), text, FALSE, FALSE, 0); 
     992  if ( mFrame != NULL ) { 
     993          return mFrame; 
     994  } 
     995 
     996  mFrame = gtk_frame_new( NULL ); 
     997  gtk_container_set_border_width( GTK_CONTAINER( mFrame ), 5 ); 
     998  gtk_widget_show( mFrame ); 
     999 
     1000  vbox = gtk_vbox_new( FALSE, 6 ); 
     1001  gtk_widget_show( vbox ); 
     1002  gtk_container_add( GTK_CONTAINER( mFrame ), vbox ); 
     1003  gtk_container_set_border_width( GTK_CONTAINER( vbox ), 5 ); 
     1004 
     1005  text = gtk_label_new( "Select the game:" ); 
     1006  gtk_widget_show( text ); 
     1007  gtk_box_pack_start( GTK_BOX( vbox ), text, FALSE, FALSE, 0 ); 
    9921008 
    9931009  combo = gtk_combo_new(); 
    994   gtk_widget_show(combo); 
    995   gtk_box_pack_start (GTK_BOX (vbox), combo, FALSE, FALSE, 0); 
     1010  gtk_widget_show( combo ); 
     1011  gtk_box_pack_start( GTK_BOX( vbox ), combo, FALSE, FALSE, 0 ); 
    9961012 
    9971013  // fill in with the game descriptions 
    9981014  GList *combo_list = (GList*)NULL; 
    9991015  list<CGameDescription *>::iterator iGame; 
    1000   for(iGame=mGames.begin(); iGame!=mGames.end(); iGame++) 
    1001   { 
    1002     combo_list = g_list_append (combo_list, (void *)(*iGame)->mGameName.GetBuffer()); 
    1003   } 
    1004   gtk_combo_set_popdown_strings (GTK_COMBO (combo), combo_list); 
    1005   g_list_free (combo_list); 
    1006  
    1007   AddDialogData (combo, &m_nComboSelect, DLG_COMBO_INT); 
    1008  
    1009   check = gtk_check_button_new_with_label("Auto load selected game on startup"); 
     1016  for( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) { 
     1017          combo_list = g_list_append( combo_list, (void *)(*iGame)->mGameName.GetBuffer() ); 
     1018  } 
     1019  gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list ); 
     1020  g_list_free( combo_list ); 
     1021 
     1022  AddDialogData( combo, &m_nComboSelect, DLG_COMBO_INT ); 
     1023 
     1024  check = gtk_check_button_new_with_label( "Auto load selected game on startup" ); 
    10101025  gtk_widget_show(check); 
    10111026  gtk_box_pack_start (GTK_BOX(vbox), check, FALSE, FALSE, 0); 
     
    10171032 
    10181033#ifdef _WIN32 
    1019   check = gtk_check_button_new_with_label("Networked install - per-user settings"); 
    1020   gtk_widget_show(check); 
    1021   gtk_box_pack_start (GTK_BOX(vbox), check, FALSE, FALSE, 0); 
    1022   AddDialogData (check, &m_bNetRun, DLG_CHECK_BOOL); 
     1034  check = gtk_check_button_new_with_label( "Networked install - per-user settings" ); 
     1035  gtk_widget_show( check ); 
     1036  gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); 
     1037  AddDialogData( check, &m_bNetRun, DLG_CHECK_BOOL ); 
    10231038#endif 
    10241039 
    1025   check = gtk_check_button_new_with_label("Log the console to radiant.log"); 
    1026   gtk_widget_show(check); 
    1027   gtk_box_pack_start (GTK_BOX(vbox), check, FALSE, FALSE, 0); 
    1028   AddDialogData (check, &m_bLogConsole, DLG_CHECK_BOOL); 
     1040  check = gtk_check_button_new_with_label( "Log the console to radiant.log" ); 
     1041  gtk_widget_show( check ); 
     1042  gtk_box_pack_start( GTK_BOX( vbox ), check, FALSE, FALSE, 0 ); 
     1043  AddDialogData( check, &m_bLogConsole, DLG_CHECK_BOOL ); 
    10291044 
    10301045  // incref it so we can pass it around 
    1031   gtk_widget_ref (GTK_WIDGET(mFrame)); 
     1046  gtk_widget_ref( GTK_WIDGET( mFrame ) ); 
    10321047 
    10331048  return mFrame; 
    10341049} 
    10351050 
    1036 void CGameDialog::UpdateData (bool retrieve) 
    1037 
     1051void CGameDialog::UpdateData( bool retrieve ) { 
    10381052  if (!retrieve) 
    10391053  { 
     
    10711085} 
    10721086 
    1073 void CGameDialog::BuildDialog() 
    1074 
    1075   GtkWidget *dlg, *vbox1, *button; 
    1076  
    1077   dlg = m_pWidget; 
    1078   gtk_window_set_title (GTK_WINDOW (dlg), "Select Game"); 
    1079  
    1080   vbox1 = gtk_vbox_new (FALSE, 0); 
    1081   gtk_widget_show(vbox1); 
    1082   gtk_container_add (GTK_CONTAINER (dlg), vbox1); 
    1083  
    1084   gtk_container_add (GTK_CONTAINER (vbox1), GetGlobalFrame()); 
    1085   mTopBox = vbox1; 
    1086  
    1087   button = gtk_button_new_with_label ("OK"); 
    1088   gtk_widget_show (button); 
    1089   gtk_box_pack_start (GTK_BOX (vbox1), button, FALSE, FALSE, 0); 
    1090   AddModalButton(button, IDOK); 
    1091   gtk_widget_set_usize (button, 60, -2); 
     1087void CGameDialog::SInstallCallback( GtkWidget *widget, gpointer data ) { 
     1088        CGameDialog *d = static_cast< CGameDialog* >( data ); 
     1089        d->m_bDoGameInstall = true; 
     1090        d->EndModal( 0 ); 
     1091
     1092 
     1093void CGameDialog::BuildDialog() { 
     1094        GtkWidget *dlg, *vbox1, *button, *setup_button; 
     1095         
     1096        dlg = m_pWidget; 
     1097        gtk_window_set_title( GTK_WINDOW( dlg ), "Select Game" ); 
     1098 
     1099        vbox1 = gtk_vbox_new( FALSE, 0 ); 
     1100        gtk_widget_show( vbox1 ); 
     1101        gtk_container_add( GTK_CONTAINER( dlg ), vbox1 ); 
     1102 
     1103        gtk_container_add( GTK_CONTAINER( vbox1 ), GetGlobalFrame() ); 
     1104        mTopBox = vbox1; 
     1105 
     1106        setup_button = gtk_button_new_with_label( "Configure more games" ); 
     1107        gtk_widget_show( setup_button ); 
     1108        gtk_box_pack_start( GTK_BOX( vbox1 ), setup_button, FALSE, FALSE, 0 ); 
     1109        gtk_signal_connect( GTK_OBJECT( setup_button ), "clicked", 
     1110                                                GTK_SIGNAL_FUNC( SInstallCallback ), this ); 
     1111 
     1112        button = gtk_button_new_with_label( "OK" ); 
     1113        gtk_widget_show( button ); 
     1114        gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 ); 
     1115        AddModalButton( button, IDOK ); 
     1116         
     1117        gtk_widget_set_usize( button, 60, -2 ); 
    10921118} 
    10931119 
     
    11011127  const char *path = strGamesPath.GetBuffer(); 
    11021128 
    1103   Sys_Printf("Scanning for game description files: %s\n", path); 
     1129  if ( !mGames.empty() ) { 
     1130          Sys_Printf( "Clearing game list\n" ); 
     1131          list<CGameDescription*>::iterator iGame; 
     1132          for ( iGame = mGames.begin(); iGame != mGames.end(); iGame++ ) { 
     1133                  delete (*iGame); 
     1134          } 
     1135          mGames.clear(); 
     1136  } 
     1137 
     1138  Sys_Printf( "Scanning for game description files: %s\n", path ); 
    11041139 
    11051140  /*! 
     
    11371172      if (pDoc) 
    11381173      { 
    1139         mGames.push_front(new CGameDescription(pDoc, dirlist)); 
     1174        mGames.push_front( new CGameDescription( pDoc, dirlist ) ); 
    11401175      } 
    11411176      else 
     
    11641199} 
    11651200 
    1166 /*GString* CGameDialog::InitGlobalPrefPath() 
    1167 { 
    1168   GString* global_rc_path; 
    1169   // configure m_global_rc_path 
    1170 #if defined (__linux__) || defined (__APPLE__) 
    1171   global_rc_path = g_string_new (g_get_home_dir ()); 
    1172  
    1173   if (global_rc_path->str[global_rc_path->len-1] != '/') 
    1174     g_string_append (global_rc_path, "/"); 
    1175  
    1176   g_string_append (global_rc_path, ".radiant/"); 
    1177   mkdir (global_rc_path->str, 0775); 
    1178   g_string_append (global_rc_path, RADIANT_VERSION); 
    1179   g_string_append (global_rc_path, "/"); 
    1180   mkdir (global_rc_path->str, 0775); 
    1181 #elif WIN32 
    1182   global_rc_path = g_string_new (g_strAppPath.GetBuffer() ); 
    1183 #else 
    1184 #error "WTF are you compiling under" 
    1185 #endif 
    1186   return global_rc_path; 
    1187 }*/ 
    1188  
    11891201void CGameDialog::InitGlobalPrefPath() 
    11901202{ 
     
    12091221  InitGlobalPrefPath(); 
    12101222  ScanForGames(); 
    1211   if (mGames.empty()) 
    1212   { 
    1213     Error("Didn't find any valid game file descriptions, aborting\n"); 
     1223  if ( mGames.empty() ) { 
     1224          DoGameInstall(); 
     1225          ScanForGames(); 
     1226          if ( mGames.empty() ) { 
     1227                  Error( "No games setup, aborting\n" ); 
     1228          } 
    12141229  } 
    12151230  LoadPrefs(); 
    1216   if (m_bAutoLoadGame) 
    1217   { 
     1231  if ( m_bAutoLoadGame ) { 
    12181232    // search by .game name 
    12191233    list<CGameDescription *>::iterator iGame; 
     
    12271241    } 
    12281242  } 
    1229   if (!m_bAutoLoadGame || !m_pCurrentGameDescription) 
    1230   { 
     1243  if ( !m_bAutoLoadGame || !m_pCurrentGameDescription ) { 
    12311244    DoGameDialog(); 
    12321245    // use m_nComboSelect to identify the game to run as and set the globals 
    12331246    m_pCurrentGameDescription = GameDescriptionForComboItem(); 
    1234     if (!m_pCurrentGameDescription) 
    1235       Error("Lookup of game description object failed, can't continue\n"); 
     1247    if ( !m_pCurrentGameDescription ) { 
     1248                Error("Lookup of game description object failed, can't continue\n"); 
     1249        } 
    12361250  } 
    12371251  g_pGameDescription = m_pCurrentGameDescription; 
     
    14951509  gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); 
    14961510  gtk_widget_set_usize(button, 60, -2); 
    1497   AddModalButton (button, IDCANCEL); 
     1511  AddModalButton(button, IDCANCEL); 
    14981512 
    14991513  button = gtk_button_new_with_label ("Clean"); 
     
    30163030    Sys_FPrintf(SYS_ERR, "Error occured while saving local prefs file '%s'\n", m_inipath->str); 
    30173031 
    3018   if (m_nMouse == 0) 
    3019     m_nMouseButtons = 2; 
    3020   else 
    3021     m_nMouseButtons = 3; 
     3032  if ( m_nMouse == 0 ) { 
     3033          m_nMouseButtons = 2; 
     3034  } else { 
     3035          m_nMouseButtons = 3; 
     3036  } 
    30223037 
    30233038} 
     
    31013116    } 
    31023117} 
     3118 
     3119/* 
     3120============================================================ 
     3121CGameInstall 
     3122============================================================ 
     3123*/ 
     3124 
     3125void CGameInstall::BuildDialog() { 
     3126        GtkWidget *dlg, *vbox1, *button, *text, *combo, *entry; 
     3127         
     3128        dlg = m_pWidget; 
     3129        gtk_window_set_title( GTK_WINDOW( dlg ), "Configure games" ); 
     3130 
     3131        vbox1 = gtk_vbox_new( FALSE, 0 ); 
     3132        gtk_widget_show( vbox1 ); 
     3133        gtk_container_add( GTK_CONTAINER( dlg ), vbox1 ); 
     3134 
     3135        text = gtk_label_new( "Select the game to configure" ); 
     3136        gtk_widget_show( text ); 
     3137        gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 
     3138 
     3139        combo = gtk_combo_new(); 
     3140        gtk_widget_show( combo ); 
     3141        gtk_box_pack_start( GTK_BOX( vbox1 ), combo, FALSE, FALSE, 0 ); 
     3142 
     3143        GList *combo_list = NULL; 
     3144        combo_list = g_list_append( combo_list, "Quake III Arena and mods" ); 
     3145        combo_list = g_list_append( combo_list, "Urban Terror standalone" ); 
     3146        combo_list = g_list_append( combo_list, "Warsaw" ); 
     3147        gtk_combo_set_popdown_strings( GTK_COMBO( combo ), combo_list ); 
     3148        g_list_free( combo_list ); 
     3149        AddDialogData( combo, &m_nComboSelect, DLG_COMBO_INT ); 
     3150 
     3151        text = gtk_label_new( "Name:" ); 
     3152        gtk_widget_show( text ); 
     3153        gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 
     3154         
     3155        entry = gtk_entry_new(); 
     3156        gtk_widget_show( entry ); 
     3157        gtk_box_pack_start( GTK_BOX( vbox1 ), entry, FALSE, FALSE, 0 ); 
     3158        AddDialogData( entry, &m_strName, DLG_ENTRY_TEXT ); 
     3159 
     3160        text = gtk_label_new( "Engine directory:" ); 
     3161        gtk_widget_show( text ); 
     3162        gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 
     3163         
     3164        entry = gtk_entry_new(); 
     3165        gtk_widget_show( entry ); 
     3166        gtk_box_pack_start( GTK_BOX( vbox1 ), entry, FALSE, FALSE, 0 ); 
     3167        AddDialogData( entry, &m_strEngine, DLG_ENTRY_TEXT ); 
     3168 
     3169        // this gets done in the project stuff atm 
     3170#if 0 
     3171        text = gtk_label_new( "Mod subdirectory:" ); 
     3172        gtk_widget_show( text ); 
     3173        gtk_box_pack_start( GTK_BOX( vbox1 ), text, FALSE, FALSE, 0 ); 
     3174 
     3175        entry = gtk_entry_new(); 
     3176        gtk_widget_show( entry ); 
     3177        gtk_box_pack_start( GTK_BOX( vbox1 ), entry, FALSE, FALSE, 0 ); 
     3178        AddDialogData( entry, &m_strMod, DLG_ENTRY_TEXT ); 
     3179#endif 
     3180 
     3181        button = gtk_button_new_with_label( "OK" ); 
     3182        gtk_widget_show( button ); 
     3183        gtk_box_pack_start( GTK_BOX( vbox1 ), button, FALSE, FALSE, 0 ); 
     3184        AddModalButton( button, IDOK ); 
     3185 
     3186        gtk_widget_set_usize( button, 60, -2 ); 
     3187} 
     3188 
     3189void CGameInstall::Run() { 
     3190        DoModal(); 
     3191        Sys_Printf( "combo: %d name: %s engine: %s mod: %s\n", m_nComboSelect, m_strName.GetBuffer(), m_strEngine.GetBuffer(), m_strMod.GetBuffer() ); 
     3192 
     3193        // write out the game file 
     3194        Str gameFilePath = g_strAppPath.GetBuffer(); 
     3195        gameFilePath += "games/"; 
     3196        gameFilePath += m_strName.GetBuffer(); 
     3197        gameFilePath += ".game"; 
     3198        Sys_Printf( "game file: %s\n", gameFilePath.GetBuffer() ); 
     3199 
     3200        FILE *fg = fopen( gameFilePath.GetBuffer(), "w" ); 
     3201        if ( fg == NULL ) { 
     3202                Error( "Failed to open %s for writing\n", gameFilePath.GetBuffer() ); 
     3203        } 
     3204        fprintf( fg, "<?xml version=\"1.0\" encoding=\"iso-8859-1\" standalone=\"yes\"?>\n<game\n" ); 
     3205        fprintf( fg, "  name=\"%s\"\n", m_strName.GetBuffer() ); 
     3206        fprintf( fg, "  gametools=\"%sgames\"\n", g_strAppPath.GetBuffer() ); 
     3207        fprintf( fg, "  enginepath=\"%s\"\n", m_strEngine.GetBuffer() ); 
     3208        switch ( m_nComboSelect ) { 
     3209        case GAME_Q3: 
     3210                fprintf( fg, "  basegame=\"baseq3\"\n" ); 
     3211                break; 
     3212        case GAME_URT: 
     3213                fprintf( fg, "  basegame=\"q3ut4\"\n" ); 
     3214                break; 
     3215        case GAME_WARSOW: 
     3216                fprintf( fg, "  basegame=\"basewsw\"\n" ); 
     3217                break; 
     3218        } 
     3219        fprintf( fg, "/>\n" ); 
     3220        fclose( fg ); 
     3221} 
  • GtkRadiant/branches/ZeroRadiant/radiant/preferences.h

    r183 r192  
    195195 
    196196/*! 
     197select games, copy editing assets and write out configuration files 
     198 */ 
     199class CGameInstall : public Dialog { 
     200public: 
     201        void Run(); 
     202        void BuildDialog(); 
     203 
     204        enum gameType_e { 
     205                GAME_Q3, 
     206                GAME_URT, 
     207                GAME_WARSOW 
     208        }; 
     209 
     210protected: 
     211        Str m_strName; 
     212        Str     m_strMod; 
     213        Str m_strEngine; 
     214        int m_nComboSelect; 
     215}; 
     216 
     217/*! 
    197218standalone dialog for games selection, and more generally global settings 
    198219*/ 
     
    218239#endif 
    219240 
     241  bool m_bDoGameInstall; 
     242 
     243  CGameInstall mGameInstall; 
     244 
    220245protected: 
    221246   
     
    259284  list<CGameDescription *> mGames; 
    260285 
    261   CGameDialog() { mFrame = NULL; m_pCurrentGameDescription = NULL; m_bLogConsole = false; m_bForceLogConsole = false; } 
     286  CGameDialog() { 
     287          mFrame = NULL; 
     288          m_pCurrentGameDescription = NULL; 
     289          m_bLogConsole = false; 
     290          m_bForceLogConsole = false; 
     291          m_bDoGameInstall = true;      // go through DoModal at least once 
     292  } 
    262293  virtual ~CGameDialog();  
    263294 
    264   void AddPacksURL(Str &s);   
     295  void AddPacksURL( Str &s ); 
    265296     
    266297  /*! 
     
    281312 
    282313  /*! 
     314        call out to the game installation dialog 
     315  */ 
     316  void DoGameInstall(); 
     317 
     318  /*! 
    283319  Dialog API 
    284320  this is only called when the dialog is built at startup for main engine select 
    285321  */ 
    286   void BuildDialog (); 
    287   void UpdateData (bool retrieve); 
     322  void BuildDialog(); 
     323  void UpdateData( bool retrieve ); 
    288324 
    289325  /*! 
     
    336372  */ 
    337373  CGameDescription *GameDescriptionForComboItem(); 
     374 
     375  /*! 
     376        callback for the game install button 
     377  */ 
     378  static void SInstallCallback( GtkWidget *widget, gpointer data ); 
    338379}; 
    339380 
  • GtkRadiant/branches/ZeroRadiant/radiant/qe3.cpp

    r185 r192  
    17001700#define BUFFER_SIZE 4096 
    17011701 
    1702 extern "C" void Sys_FPrintf_VA (int level, const char *text, va_list args) 
    1703 
     1702extern "C" void Sys_FPrintf_VA( int level, const char *text, va_list args ) { 
    17041703  char buf[BUFFER_SIZE]; 
    17051704   
    17061705  buf[0] = 0; 
    1707   vsnprintf(buf, BUFFER_SIZE, text, args); 
     1706  vsnprintf( buf, BUFFER_SIZE, text, args ); 
    17081707  buf[BUFFER_SIZE-1] = 0; 
    17091708  const unsigned int length = strlen(buf); 
    17101709 
    1711   if (g_qeglobals.hLogFile) 
    1712   { 
     1710  if ( g_qeglobals.hLogFile ) { 
    17131711#ifdef _WIN32 
    1714     _write(g_qeglobals.hLogFile, buf,length); 
    1715     _commit(g_qeglobals.hLogFile); 
     1712    _write( g_qeglobals.hLogFile, buf, length ); 
     1713    _commit( g_qeglobals.hLogFile ); 
    17161714#endif 
    17171715#if defined (__linux__) || defined (__APPLE__) 
    1718     write(g_qeglobals.hLogFile, buf, length); 
    1719 #endif 
    1720   } 
    1721  
    1722   if (level != SYS_NOCON) 
    1723   { 
     1716    write( g_qeglobals.hLogFile, buf, length ); 
     1717#endif 
     1718  } 
     1719 
     1720  if ( level != SYS_NOCON ) { 
    17241721    // TTimo: FIXME: killed the console to avoid GDI leak fuckup 
    1725     if (g_qeglobals_gui.d_edit != NULL) 
    1726     { 
     1722    if ( g_qeglobals_gui.d_edit != NULL ) { 
    17271723      GtkTextBuffer* buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(g_qeglobals_gui.d_edit)); 
    17281724       
     
    17791775} 
    17801776 
    1781 extern "C" void Sys_Printf (const char *text, ...) 
    1782 
     1777extern "C" void Sys_Printf( const char *text, ... ) { 
    17831778  va_list args; 
    17841779 
    1785   va_start (args, text); 
    1786   Sys_FPrintf_VA (SYS_STD, text, args); 
    1787   va_end (args); 
     1780  va_start( args, text ); 
     1781  Sys_FPrintf_VA( SYS_STD, text, args ); 
     1782  va_end( args ); 
    17881783} 
    17891784