Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

winfuncs.cpp

Go to the documentation of this file.
00001 #include <windows.h>
00002 #include <math.h>
00003 #include "shared.h"
00004 #include "mmgr.h"
00005 #include "resource.rh"
00006 
00007 extern int DialogInUse;
00008 extern float lightColor[3];
00009 extern HWND hWnd;
00010 extern HWND hWndStartDlg;
00011 extern char szText[BUFFER_SIZE];
00012 extern char Directory[MAX_PATH];
00013 extern char AppDirectory[MAX_PATH];  // This application's directory
00014 extern char HaloTypeName[MAX_PATH];         // filename and path to the tga images
00015 extern char FireTypeName[MAX_PATH];
00016 extern char SplineFileName[MAX_PATH];  // filename and path to the spline data
00017 
00018 HWND hWndOfDlg;
00019 OPENFILENAME ofn;
00020 char CurrentDirectory[MAX_PATH];
00021 
00022 // Initialization dialog process
00023 BOOL CALLBACK StartProc(HWND hwnd,UINT Message, WPARAM wParam, LPARAM /*lParam*/)
00024 {
00025     switch(Message)
00026     {
00027         case WM_INITDIALOG:
00028             hWndStartDlg = hwnd;
00029 
00030             SendDlgItemMessage(hwnd, IDC_DLG_TEXT1, EM_SETLIMITTEXT, (WPARAM)BUFFER_SIZE - 1, (LPARAM)0);
00031 
00032             sprintf(SplineFileName, "%s", AppDirectory);
00033             strcat(SplineFileName, "\\default.spn");
00034             SetDlgItemText(hWndStartDlg, IDC_DLG_TEXT1, SplineFileName);
00035         return TRUE;
00036 
00037         case WM_COMMAND:
00038             switch(LOWORD(wParam))
00039             {
00040                 case IDCANCEL:
00041                     EndDialog(hwnd, IDCANCEL);
00042                 return TRUE;
00043 
00044                 case IDOK:
00045                     if (GetDlgItemText(hwnd, IDC_DLG_TEXT1, szText, BUFFER_SIZE))
00046                         sprintf(SplineFileName, "%s", szText);
00047                     else
00048                         return FALSE;
00049                     EndDialog(hwnd, IDOK);
00050                 return TRUE;
00051 
00052                 case IDC_DLG_SETPATH1:
00053                     sprintf(szText, "%s", SplineFileName);
00054                     ZeroMemory(&ofn, sizeof(ofn));
00055                     ofn.lStructSize = sizeof(ofn);
00056                     ofn.hwndOwner = hWndStartDlg;
00057                     ofn.lpstrFilter = "Spline Files (*.spn)\0*.spn\0\0";
00058                     ofn.lpstrFile = szText;
00059                     ofn.nMaxFile = MAX_PATH;
00060                     ofn.lpstrInitialDir = AppDirectory;
00061                     ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
00062                     ofn.lpstrDefExt = "spn";
00063                     if(GetOpenFileName(&ofn))
00064                         SetDlgItemText(hWndStartDlg, IDC_DLG_TEXT1, szText);
00065                     sprintf(SplineFileName, "%s", szText);
00066                 return TRUE;
00067             }
00068         break;
00069     }
00070     return FALSE;
00071 }
00072 
00073 // Hook function for color common dialog window
00074 UINT APIENTRY ColorDialogHook(HWND hdlg, UINT msg, WPARAM, LPARAM)
00075 {
00076     switch (msg)
00077     {
00078         case WM_INITDIALOG:
00079         {
00080             if(DialogInUse == 1)  // Ambient
00081                 SetWindowText(hdlg, "Choose Ambient Color");
00082             if(DialogInUse == 2)  // Diffuse
00083                 SetWindowText(hdlg, "Choose Diffuse Color");
00084             if(DialogInUse == 3)  // Specular
00085                 SetWindowText(hdlg, "Choose Specular Color");
00086             return TRUE;
00087         }
00088 
00089         default:
00090             return FALSE;
00091     }
00092 }
00093 
00094 void GetLightColor()
00095 {
00096     COLORREF colors[16];
00097     COLORREF colorRGB = RGB(lightColor[0]*255, lightColor[1]*255, lightColor[2]*255);
00098     CHOOSECOLOR colorDialog;
00099     memset(&colorDialog,0,sizeof(colorDialog));
00100     memset(colors,255,sizeof(colors));
00101     colorDialog.lStructSize = sizeof(CHOOSECOLOR);
00102     colorDialog.hwndOwner = hWnd;
00103     colorDialog.rgbResult = colorRGB;
00104     colorDialog.lpCustColors = colors;
00105     colorDialog.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ENABLEHOOK;
00106     colorDialog.lpfnHook = (LPCCHOOKPROC)ColorDialogHook;
00107     ChooseColor(&colorDialog);
00108     lightColor[0] = (float)GetRValue(colorDialog.rgbResult)/255;
00109     lightColor[1] = (float)GetGValue(colorDialog.rgbResult)/255;
00110     lightColor[2] = (float)GetBValue(colorDialog.rgbResult)/255;
00111 }

Generated on Fri Dec 23 05:20:18 2005 for Portals by doxygen1.2.15