Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

WIN_DLG.CPP

Go to the documentation of this file.
00001 /*
00002 ===========================================================================
00003 Copyright (C) 1999-2005 Id Software, Inc.
00004 
00005 This file is part of Quake III Arena source code.
00006 
00007 Quake III Arena source code is free software; you can redistribute it
00008 and/or modify it under the terms of the GNU General Public License as
00009 published by the Free Software Foundation; either version 2 of the License,
00010 or (at your option) any later version.
00011 
00012 Quake III Arena source code is distributed in the hope that it will be
00013 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Foobar; if not, write to the Free Software
00019 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020 ===========================================================================
00021 */
00022 #include "stdafx.h"
00023 #include "qe3.h"
00024 #include "PrefsDlg.h"
00025 
00026 BOOL CALLBACK EditCommandDlgProc (
00027     HWND hwndDlg,   // handle to dialog box
00028     UINT uMsg,  // message
00029     WPARAM wParam,  // first message parameter
00030     LPARAM lParam   // second message parameter
00031    )
00032 {
00033     char    key[1024];
00034     char    value[1024];
00035     char    *temp;
00036     int     index;
00037     HWND    hOwner;
00038     
00039     hOwner = GetParent (hwndDlg);
00040 
00041     switch (uMsg)
00042     {
00043     case WM_INITDIALOG:
00044         index = SendDlgItemMessage (hOwner, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);
00045     if (index >= 0)
00046     {
00047           SendDlgItemMessage(hOwner, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);
00048           temp = ValueForKey (g_qeglobals.d_project_entity, key);
00049           strcpy (value, temp);
00050           SetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key);
00051           SetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value);
00052     }
00053         return FALSE;
00054         break;
00055 
00056     case WM_COMMAND: 
00057         switch (LOWORD(wParam)) 
00058         { 
00059             case IDOK:
00060                 if (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))
00061                 {
00062                     Sys_Printf ("Command not added\n");
00063                     return FALSE;
00064                 }
00065 
00066                 if (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))
00067                 {
00068                     Sys_Printf ("Command not added\n");
00069                     return FALSE;
00070                 }
00071 
00072                 //if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')
00073                 //{
00074                     SetKeyValue (g_qeglobals.d_project_entity, key, value);
00075                     FillBSPMenu ();
00076                 //}
00077                 //else
00078                 //  Sys_Printf ("BSP commands must be preceded by \"bsp\"");
00079 
00080                 EndDialog(hwndDlg, 1);
00081                 return TRUE;
00082 
00083             case IDCANCEL:
00084                 EndDialog(hwndDlg, 0);
00085                 return TRUE;
00086         }
00087     }
00088     return FALSE;
00089 }
00090 
00091 BOOL CALLBACK AddCommandDlgProc (
00092     HWND hwndDlg,   // handle to dialog box
00093     UINT uMsg,  // message
00094     WPARAM wParam,  // first message parameter
00095     LPARAM lParam   // second message parameter
00096    )
00097 {
00098     char    key[64];
00099     char    value[128];
00100 
00101     switch (uMsg)
00102     {
00103     case WM_COMMAND: 
00104         switch (LOWORD(wParam)) 
00105         { 
00106             case IDOK:
00107                 if (!GetDlgItemText(hwndDlg, IDC_CMDMENUTEXT, key, 64))
00108                 {
00109                     Sys_Printf ("Command not added\n");
00110                     return FALSE;
00111                 }
00112 
00113                 if (!GetDlgItemText(hwndDlg, IDC_CMDCOMMAND, value, 64))
00114                 {
00115                     Sys_Printf ("Command not added\n");
00116                     return FALSE;
00117                 }
00118 
00119                 if (key[0] == 'b' && key[1] == 's' && key[2] == 'p')
00120                 {
00121                     SetKeyValue (g_qeglobals.d_project_entity, key, value);
00122                     FillBSPMenu ();
00123                 }
00124                 else
00125                     Sys_Printf ("BSP commands must be preceded by \"bsp\"");
00126 
00127                 EndDialog(hwndDlg, 1);
00128                 return TRUE;
00129 
00130             case IDCANCEL:
00131                 EndDialog(hwndDlg, 0);
00132                 return TRUE;
00133         }
00134     }
00135     return FALSE;
00136 }
00137 
00138 void UpdateBSPCommandList (HWND hwndDlg)
00139 {
00140     int         i;
00141     epair_t     *ep;
00142 
00143     SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_RESETCONTENT, 0 , 0);
00144 
00145     i = 0;
00146     for (ep = g_qeglobals.d_project_entity->epairs ; ep ; ep=ep->next)
00147     {
00148         if (ep->key[0] == 'b' && ep->key[1] == 's' && ep->key[2] == 'p')
00149         {
00150             SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_ADDSTRING, i , (LPARAM) ep->key);
00151             i++;
00152         }
00153     }
00154 }
00155 
00156 
00157 // FIXME: turn this into an MFC dialog
00158 BOOL CALLBACK ProjectDlgProc (
00159     HWND hwndDlg,   // handle to dialog box
00160     UINT uMsg,  // message
00161     WPARAM wParam,  // first message parameter
00162     LPARAM lParam   // second message parameter
00163    )
00164 {
00165     char        key[1024];
00166     char        value[1024];
00167     int         index;
00168 
00169     switch (uMsg)
00170     {
00171     case WM_INITDIALOG:
00172         SetDlgItemText(hwndDlg, IDC_PRJBASEPATH, ValueForKey (g_qeglobals.d_project_entity, "basepath"));
00173         SetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, ValueForKey (g_qeglobals.d_project_entity, "mapspath"));
00174         SetDlgItemText(hwndDlg, IDC_PRJRSHCMD, ValueForKey (g_qeglobals.d_project_entity, "rshcmd"));
00175         SetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, ValueForKey (g_qeglobals.d_project_entity, "remotebasepath"));
00176         SetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, ValueForKey (g_qeglobals.d_project_entity, "entitypath"));
00177         SetDlgItemText(hwndDlg, IDC_PRJTEXPATH, ValueForKey (g_qeglobals.d_project_entity, "texturepath"));
00178         UpdateBSPCommandList (hwndDlg);
00179         // Timo
00180         // additional fields
00181         CheckDlgButton( hwndDlg, IDC_CHECK_BPRIMIT, (g_qeglobals.m_bBrushPrimitMode) ? BST_CHECKED : BST_UNCHECKED );
00182 //      SendMessage( ::GetDlgItem( hwndDlg, IDC_CHECK_BPRIMIT ), BM_SETCHECK, (WPARAM) g_qeglobals.m_bBrushPrimitMode, 0 );
00183         return TRUE;
00184 
00185     case WM_COMMAND: 
00186         switch (LOWORD(wParam)) 
00187         { 
00188             case IDC_ADDCMD:
00189 //              DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, AddCommandDlgProc);
00190                 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, AddCommandDlgProc);
00191                 UpdateBSPCommandList (hwndDlg);
00192                 break;
00193 
00194             case IDC_EDITCMD:
00195 //              DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, g_qeglobals.d_hwndMain, EditCommandDlgProc);
00196                 DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ADDCMD, hwndDlg, EditCommandDlgProc);
00197                 UpdateBSPCommandList (hwndDlg);
00198                 break;
00199 
00200             case IDC_REMCMD:
00201                 index = SendDlgItemMessage (hwndDlg, IDC_CMD_LIST, LB_GETCURSEL, 0, 0);
00202                 SendDlgItemMessage(hwndDlg, IDC_CMD_LIST, LB_GETTEXT, index, (LPARAM) (LPCTSTR) key);
00203                 DeleteKey (g_qeglobals.d_project_entity, key);
00204                 Sys_Printf ("Selected %d\n", index);
00205                 UpdateBSPCommandList (hwndDlg);
00206                 break;
00207 
00208             case IDOK:
00209                 GetDlgItemText(hwndDlg, IDC_PRJBASEPATH, value, 1024);
00210                 SetKeyValue (g_qeglobals.d_project_entity, "basepath", value);
00211                 GetDlgItemText(hwndDlg, IDC_PRJMAPSPATH, value, 1024);
00212                 SetKeyValue (g_qeglobals.d_project_entity, "mapspath", value);
00213                 GetDlgItemText(hwndDlg, IDC_PRJRSHCMD, value, 1024);
00214                 SetKeyValue (g_qeglobals.d_project_entity, "rshcmd", value);
00215                 GetDlgItemText(hwndDlg, IDC_PRJREMOTEBASE, value, 1024);
00216                 SetKeyValue (g_qeglobals.d_project_entity, "remotebasepath", value);
00217                 GetDlgItemText(hwndDlg, IDC_PRJENTITYPATH, value, 1024);
00218                 SetKeyValue (g_qeglobals.d_project_entity, "entitypath", value);
00219                 GetDlgItemText(hwndDlg, IDC_PRJTEXPATH, value, 1024);
00220                 SetKeyValue (g_qeglobals.d_project_entity, "texturepath", value);
00221                 // Timo
00222                 // read additional fields
00223                 if ( IsDlgButtonChecked( hwndDlg, IDC_CHECK_BPRIMIT ) )
00224                 {
00225                     g_qeglobals.m_bBrushPrimitMode = TRUE;
00226                 }
00227                 else
00228                 {
00229                     g_qeglobals.m_bBrushPrimitMode = FALSE;
00230                 }
00231                 SetKeyValue ( g_qeglobals.d_project_entity, "brush_primit", ( g_qeglobals.m_bBrushPrimitMode ? "1" : "0" ) );
00232 
00233                 EndDialog(hwndDlg, 1);
00234                 QE_SaveProject(g_strProject);
00235                 return TRUE;
00236 
00237             case IDCANCEL:
00238                 EndDialog(hwndDlg, 0);
00239                 return TRUE;
00240         }
00241     }
00242     return FALSE;
00243 }
00244 
00245 void DoProjectSettings()
00246 {
00247     DialogBox(g_qeglobals.d_hInstance, (char *)IDD_PROJECT, g_qeglobals.d_hwndMain, ProjectDlgProc);
00248 }
00249 
00250 
00251 
00252 BOOL CALLBACK GammaDlgProc (
00253     HWND hwndDlg,   // handle to dialog box
00254     UINT uMsg,  // message
00255     WPARAM wParam,  // first message parameter
00256     LPARAM lParam   // second message parameter
00257    )
00258 {
00259     char sz[256];
00260 
00261     switch (uMsg)
00262     {
00263     case WM_INITDIALOG:
00264         sprintf(sz, "%1.1f", g_qeglobals.d_savedinfo.fGamma);       
00265         SetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz);
00266         return TRUE;
00267     case WM_COMMAND: 
00268         switch (LOWORD(wParam)) 
00269         { 
00270         
00271         case IDOK:
00272             GetWindowText(GetDlgItem(hwndDlg, IDC_G_EDIT), sz, 255);
00273             g_qeglobals.d_savedinfo.fGamma = atof(sz);
00274             EndDialog(hwndDlg, 1);
00275             return TRUE;
00276 
00277         case IDCANCEL:
00278             EndDialog(hwndDlg, 0);
00279             return TRUE;
00280         }
00281     }
00282     return FALSE;
00283 }
00284 
00285 
00286 
00287 void DoGamma(void)
00288 {
00289     if ( DialogBox(g_qeglobals.d_hInstance, (char *)IDD_GAMMA, g_qeglobals.d_hwndMain, GammaDlgProc))
00290     {
00291     }
00292 }       
00293 
00294 //================================================
00295 
00296 
00297 void SelectBrush (int entitynum, int brushnum)
00298 {
00299     entity_t    *e;
00300     brush_t     *b;
00301     int         i;
00302 
00303     if (entitynum == 0)
00304         e = world_entity;
00305     else
00306     {
00307         e = entities.next;
00308         while (--entitynum)
00309         {
00310             e=e->next;
00311             if (e == &entities)
00312             {
00313                 Sys_Status ("No such entity.", 0);
00314                 return;
00315             }
00316         }
00317     }
00318 
00319     b = e->brushes.onext;
00320     if (b == &e->brushes)
00321     {
00322         Sys_Status ("No such brush.", 0);
00323         return;
00324     }
00325     while (brushnum--)
00326     {
00327         b=b->onext;
00328         if (b == &e->brushes)
00329         {
00330             Sys_Status ("No such brush.", 0);
00331             return;
00332         }
00333     }
00334 
00335     Brush_RemoveFromList (b);
00336     Brush_AddToList (b, &selected_brushes);
00337 
00338 
00339     Sys_UpdateWindows (W_ALL);
00340     for (i=0 ; i<3 ; i++)
00341   {
00342     if (g_pParentWnd->GetXYWnd())
00343       g_pParentWnd->GetXYWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
00344 
00345     if (g_pParentWnd->GetXZWnd())
00346       g_pParentWnd->GetXZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
00347     
00348     if (g_pParentWnd->GetYZWnd())
00349       g_pParentWnd->GetYZWnd()->GetOrigin()[i] = (b->mins[i] + b->maxs[i])/2;
00350   }
00351 
00352     Sys_Status ("Selected.", 0);
00353 }
00354 
00355 /*
00356 =================
00357 GetSelectionIndex
00358 =================
00359 */
00360 void GetSelectionIndex (int *ent, int *brush)
00361 {
00362     brush_t     *b, *b2;
00363     entity_t    *entity;
00364 
00365     *ent = *brush = 0;
00366 
00367     b = selected_brushes.next;
00368     if (b == &selected_brushes)
00369         return;
00370 
00371     // find entity
00372     if (b->owner != world_entity)
00373     {
00374         (*ent)++;
00375         for (entity = entities.next ; entity != &entities 
00376             ; entity=entity->next, (*ent)++)
00377         ;
00378     }
00379 
00380     // find brush
00381     for (b2=b->owner->brushes.onext 
00382         ; b2 != b && b2 != &b->owner->brushes
00383         ; b2=b2->onext, (*brush)++)
00384     ;
00385 }
00386 
00387 BOOL CALLBACK FindBrushDlgProc (
00388     HWND hwndDlg,   // handle to dialog box
00389     UINT uMsg,  // message
00390     WPARAM wParam,  // first message parameter
00391     LPARAM lParam   // second message parameter
00392    )
00393 {
00394     char entstr[256];
00395     char brushstr[256];
00396     HWND    h;
00397     int     ent, brush;
00398 
00399     switch (uMsg)
00400     {
00401     case WM_INITDIALOG:
00402         // set entity and brush number
00403         GetSelectionIndex (&ent, &brush);
00404         sprintf (entstr, "%i", ent);
00405         sprintf (brushstr, "%i", brush);
00406         SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);
00407         SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);
00408 
00409         h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
00410         SetFocus (h);
00411         return FALSE;
00412 
00413     case WM_COMMAND: 
00414         switch (LOWORD(wParam)) 
00415         { 
00416             case IDOK:
00417                 GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);
00418                 GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);
00419                 SelectBrush (atoi(entstr), atoi(brushstr));
00420                 EndDialog(hwndDlg, 1);
00421                 return TRUE;
00422 
00423             case IDCANCEL:
00424                 EndDialog(hwndDlg, 0);
00425                 return TRUE;
00426         }   
00427     }
00428     return FALSE;
00429 }
00430 
00431 
00432 
00433 void DoFind(void)
00434 {
00435     DialogBox(g_qeglobals.d_hInstance, (char *)IDD_FINDBRUSH, g_qeglobals.d_hwndMain, FindBrushDlgProc);
00436 }   
00437     
00438 /*
00439 ===================================================
00440 
00441   ARBITRARY ROTATE
00442 
00443 ===================================================
00444 */
00445 
00446 
00447 BOOL CALLBACK RotateDlgProc (
00448     HWND hwndDlg,   // handle to dialog box
00449     UINT uMsg,  // message
00450     WPARAM wParam,  // first message parameter
00451     LPARAM lParam   // second message parameter
00452    )
00453 {
00454     char    str[256];
00455     HWND    h;
00456     float   v;
00457 
00458     switch (uMsg)
00459     {
00460     case WM_INITDIALOG:
00461         h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
00462         SetFocus (h);
00463         return FALSE;
00464 
00465     case WM_COMMAND: 
00466         switch (LOWORD(wParam)) 
00467         { 
00468         
00469         case IDOK:
00470             GetWindowText(GetDlgItem(hwndDlg, IDC_ROTX), str, 255);
00471             v = atof(str);
00472             if (v)
00473                 Select_RotateAxis (0, v);
00474 
00475             GetWindowText(GetDlgItem(hwndDlg, IDC_ROTY), str, 255);
00476             v = atof(str);
00477             if (v)
00478                 Select_RotateAxis (1, v);
00479 
00480             GetWindowText(GetDlgItem(hwndDlg, IDC_ROTZ), str, 255);
00481             v = atof(str);
00482             if (v)
00483                 Select_RotateAxis (2, v);
00484 
00485             EndDialog(hwndDlg, 1);
00486             return TRUE;
00487 
00488         case IDCANCEL:
00489             EndDialog(hwndDlg, 0);
00490             return TRUE;
00491         }   
00492     }
00493 
00494     return FALSE;
00495 }
00496 
00497 
00498 
00499 void DoRotate(void)
00500 {
00501     DialogBox(g_qeglobals.d_hInstance, (char *)IDD_ROTATE, g_qeglobals.d_hwndMain, RotateDlgProc);
00502 }
00503         
00504 /*
00505 ===================================================
00506 
00507   ARBITRARY SIDES
00508 
00509 ===================================================
00510 */
00511 
00512 bool g_bDoCone = false;
00513 bool g_bDoSphere = false;
00514 BOOL CALLBACK SidesDlgProc (
00515     HWND hwndDlg,   // handle to dialog box
00516     UINT uMsg,  // message
00517     WPARAM wParam,  // first message parameter
00518     LPARAM lParam   // second message parameter
00519    )
00520 {
00521     char str[256];
00522     HWND    h;
00523 
00524     switch (uMsg)
00525     {
00526     case WM_INITDIALOG:
00527         h = GetDlgItem(hwndDlg, IDC_SIDES);
00528         SetFocus (h);
00529         return FALSE;
00530 
00531     case WM_COMMAND: 
00532         switch (LOWORD(wParam)) { 
00533         
00534         case IDOK:
00535             GetWindowText(GetDlgItem(hwndDlg, IDC_SIDES), str, 255);
00536       if (g_bDoCone)
00537               Brush_MakeSidedCone(atoi(str));
00538       else if (g_bDoSphere)
00539               Brush_MakeSidedSphere(atoi(str));
00540       else
00541               Brush_MakeSided (atoi(str));
00542 
00543             EndDialog(hwndDlg, 1);
00544         break;
00545 
00546         case IDCANCEL:
00547             EndDialog(hwndDlg, 0);
00548         break;
00549     }   
00550     default:
00551         return FALSE;
00552     }
00553 }
00554 
00555 
00556 void DoSides(bool bCone, bool bSphere, bool bTorus)
00557 {
00558   g_bDoCone = bCone;
00559   g_bDoSphere = bSphere;
00560   //g_bDoTorus = bTorus;
00561     DialogBox(g_qeglobals.d_hInstance, (char *)IDD_SIDES, g_qeglobals.d_hwndMain, SidesDlgProc);
00562 }       
00563 
00564 
00565 //======================================================================
00566 
00567 /*
00568 ===================
00569 DoAbout
00570 ===================
00571 */
00572 BOOL CALLBACK AboutDlgProc( HWND hwndDlg,
00573                             UINT uMsg,
00574                             WPARAM wParam,
00575                             LPARAM lParam )
00576 {
00577     switch (uMsg)
00578     {
00579     case WM_INITDIALOG:
00580         {
00581             char renderer[1024];
00582             char version[1024];
00583             char vendor[1024];
00584             char extensions[4096];
00585 
00586             sprintf( renderer, "Renderer:\t%s", qglGetString( GL_RENDERER ) );
00587             sprintf( version, "Version:\t\t%s", qglGetString( GL_VERSION ) );
00588             sprintf( vendor, "Vendor:\t\t%s", qglGetString( GL_VENDOR ) );
00589             sprintf( extensions, "%s", qglGetString( GL_EXTENSIONS ) );
00590 
00591             SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLRENDERER ),   renderer );
00592             SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVERSION ),    version );
00593             SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLVENDOR ),     vendor );
00594             SetWindowText( GetDlgItem( hwndDlg, IDC_ABOUT_GLEXTENSIONS ), extensions );
00595 
00596         }
00597         return TRUE;
00598 
00599     case WM_CLOSE:
00600         EndDialog( hwndDlg, 1 );
00601         return TRUE;
00602 
00603     case WM_COMMAND:
00604         if ( LOWORD( wParam ) == IDOK )
00605             EndDialog(hwndDlg, 1);
00606         return TRUE;
00607     }
00608     return FALSE;
00609 }
00610 
00611 void DoAbout(void)
00612 {
00613     DialogBox( g_qeglobals.d_hInstance, ( char * ) IDD_ABOUT, g_qeglobals.d_hwndMain, AboutDlgProc );
00614 }
00615 
00616 

Generated on Thu Aug 25 12:38:42 2005 for Quake III Arena by  doxygen 1.3.9.1