00001
00002
00003
00004
00005
00006 #define MODULE_SETUP 1
00007
00008 #define SIZESTATUS1 195 // 130 //This must also be defined in DESIGN.C
00009
00010 #include "design.h"
00011 #include "..\animate\callall.h"
00012
00013 static void UnloadRenderer(void);
00014
00015 static long palette256[16]={
00016 0x00c0c0c0,
00017 0x00808080,
00018 0x0000ffff,
00019 0x000000ff,
00020 0x00ffffff,
00021 0x0000ffff,
00022 0x000000ff,
00023 0x0000ff00,
00024 0x00f0f0f0,
00025 0x00808080,
00026 0x0000ff00,
00027 0x00000000,
00028 0x0000ffff,
00029 0x000000ff,
00030 0x00767676,
00031 0x00979797};
00032
00033 static long palette24b[16]={
00034 0x00c0c0c0,
00035 0x00606060,
00036 0x00ff0000,
00037 0x00ffff00,
00038 0x00ffffff,
00039 0x0000ffff,
00040 0x000000ff,
00041 0x0000ff00,
00042 0x00f0f0f0,
00043 0x00ffff00,
00044 0x00ffff00,
00045 0x00000000,
00046 0x0000ffff,
00047 0x000000ff,
00048 0x00767676,
00049 0x00979797};
00050
00051 #define PALVERSION 0x300
00052
00053 #define X__C(p,i) RGB(p->palPalEntry[i].peRed,p->palPalEntry[i].peGreen,p->palPalEntry[i].peBlue)
00054
00055 HPALETTE CreateAppPalette(int *ScreenX, int *ScreenY){
00056 char *cstr[16]={
00057 "screen",
00058 "window",
00059 "selected",
00060 "deselected",
00061 "invert",
00062 "selected",
00063 "deselected",
00064 "edit",
00065 "wireframe",
00066 "cursor",
00067 "invert",
00068 "edge",
00069 "selector",
00070 "deselector",
00071 "grid1",
00072 "grid2"
00073 };
00074 char strng[64];
00075 LOGPALETTE *pPal;
00076 HPALETTE hpal = NULL;
00077 WORD nNumColors;
00078 BYTE red,green,blue;
00079 HWND hDesktopWnd;
00080 HDC hDCcaps;
00081 int i,Dbits;
00082 long c,*palette;
00083 nNumColors = 256;
00084 pPal = (LOGPALETTE*)LocalAlloc(LPTR,sizeof(LOGPALETTE) +
00085 nNumColors * sizeof(PALETTEENTRY));
00086 if(pPal == NULL)return NULL;
00087 pPal->palNumEntries = nNumColors;
00088 pPal->palVersion = PALVERSION;
00089 red = green = blue = 0;
00090 for(i=0;i<256;i++){
00091 pPal->palPalEntry[i].peRed = red;
00092 pPal->palPalEntry[i].peGreen = green;
00093 pPal->palPalEntry[i].peBlue = blue;
00094 pPal->palPalEntry[i].peFlags = (BYTE)0;
00095 if (!(red += 32))if (!(green += 32)) blue += 64;
00096 }
00097 hDesktopWnd = GetDesktopWindow();
00098 hDCcaps = GetDC(hDesktopWnd);
00099 Dbits = GetDeviceCaps(hDCcaps,BITSPIXEL);
00100 *ScreenX = GetDeviceCaps(hDCcaps,HORZRES);
00101 *ScreenY = GetDeviceCaps(hDCcaps,VERTRES);
00102 ReleaseDC(hDesktopWnd,hDCcaps);
00103 if(Dbits <= 8)palette=palette256;
00104 else palette=palette24b;
00105 for(i = 0; i < 16; i++){
00106 GetPrivateProfileString("MCOLOURS",cstr[i],"$$$",
00107 strng,sizeof(strng),IniFilename);
00108 if(strncmp(strng,"$$$",3) == 0){
00109 pPal->palPalEntry[i].peRed = (unsigned char)( palette[i] & 0xff);
00110 pPal->palPalEntry[i].peGreen = (unsigned char)((palette[i] >> 8) & 0xff);
00111 pPal->palPalEntry[i].peBlue = (unsigned char)((palette[i] >> 16) & 0xff);
00112 pPal->palPalEntry[i].peFlags = (BYTE)0;
00113 }
00114 else{
00115 int r,g,b;
00116 sscanf(strng,"%ld %ld %ld",&r,&g,&b);
00117 pPal->palPalEntry[i].peRed = (unsigned char)(r&0xff);
00118 pPal->palPalEntry[i].peGreen = (unsigned char)(g&0xff);
00119 pPal->palPalEntry[i].peBlue = (unsigned char)(b&0xff);
00120 pPal->palPalEntry[i].peFlags = (BYTE)0;
00121 }
00122 }
00123 hpal = CreatePalette(pPal);
00124 ghbrushScreen = CreateSolidBrush(PALETTEINDEX(0));
00125 ghbrushWindow = CreateSolidBrush(PALETTEINDEX(1));
00126 ghSelectedBrush = CreateSolidBrush(PALETTEINDEX(2));
00127 ghDeselectedBrush = CreateSolidBrush(PALETTEINDEX(3));
00128 ghInvertBrush = CreateSolidBrush(PALETTEINDEX(4));
00129 ghSelectedPen = CreatePen(PS_SOLID,0,X__C(pPal, 5));
00130 ghDotSelectedPen = CreatePen(PS_DOT,0,X__C(pPal, 11));
00131 ghDeselectedPen = CreatePen(PS_SOLID,0,X__C(pPal, 6));
00132 ghEditPen = CreatePen(PS_SOLID,0,X__C(pPal, 7));
00133 ghWireframePen = CreatePen(PS_SOLID,0,X__C(pPal, 8));
00134 ghCursorPen = CreatePen(PS_SOLID,0,X__C(pPal, 9));
00135 ghInvertPen = CreatePen(PS_SOLID,0,X__C(pPal,10));
00136 ghEdgePen = CreatePen(PS_SOLID,0,X__C(pPal,11));
00137 ghSelectorPen = CreatePen(PS_SOLID,0,X__C(pPal,12));
00138 ghDeselectorPen = CreatePen(PS_SOLID,0,X__C(pPal,13));
00139 gScreenColourRef=(COLORREF)palette[1];
00140 gGridColourRef1=X__C(pPal,14);
00141 gGridColourRef2=X__C(pPal,15);
00142 if(ghbrushScreen == NULL ||
00143 ghbrushWindow == NULL ||
00144 ghSelectedBrush == NULL ||
00145 ghDeselectedBrush == NULL ||
00146 ghInvertBrush == NULL ||
00147 ghSelectedPen == NULL ||
00148 ghDotSelectedPen == NULL ||
00149 ghDeselectedPen == NULL ||
00150 ghEditPen == NULL ||
00151 ghWireframePen == NULL ||
00152 ghCursorPen == NULL ||
00153 ghInvertPen == NULL ||
00154 ghEdgePen == NULL ||
00155 ghSelectorPen == NULL ||
00156 ghDeselectorPen == NULL)SendPrgmQuery(IDQ_BADPENS,3);
00157 LocalFree((HANDLE)pPal);
00158 return hpal;
00159 }
00160
00161 void LoadPreferences(void){
00162 char pref_id[32];
00163 Preferences.embedimages=TRUE;
00164 Preferences.buttons=TRUE;
00165 Preferences.quick_trick=TRUE;
00166 Preferences.show_select=FALSE;
00167 Preferences.undo=TRUE;
00168 Preferences.use_3d_dialogs=TRUE;
00169 Preferences.use_OpenGL=FALSE;
00170 Preferences.Vcolour[0]=0;
00171 Preferences.Vcolour[1]=0;
00172 Preferences.Vcolour[2]=0;
00173 Preferences.tooltips=TRUE;
00174 Preferences.attribs_sheet=TRUE;
00175 Preferences.bigv=FALSE;
00176 Preferences.use_positions=TRUE;
00177 Preferences.toolsmall=FALSE;
00178 Preferences.toolleft=FALSE;
00179 Preferences.background=TRUE;
00180 select_visible=0;
00181 ActiveView=TRITOP;
00182 GetPrivateProfileString(IniSection,"BUTTONS","$$$",
00183 pref_id,sizeof(pref_id),IniFilename);
00184 if(strncmp(pref_id,"NO",2) == 0){
00185 Preferences.buttons=FALSE;
00186 }
00187 GetPrivateProfileString(IniSection,"SELECTPANNEL","$$$",
00188 pref_id,sizeof(pref_id),IniFilename);
00189 if(strncmp(pref_id,"YES",3) == 0){
00190 Preferences.show_select=TRUE;
00191 select_visible=1;
00192 }
00193 GetPrivateProfileString(IniSection,"QUICKTRICK","$$$",
00194 pref_id,sizeof(pref_id),IniFilename);
00195 if(strncmp(pref_id,"NO",2) == 0){
00196 Preferences.quick_trick=FALSE;
00197 }
00198 GetPrivateProfileString(IniSection,"UNDO","$$$",
00199 pref_id,sizeof(pref_id),IniFilename);
00200 if(strncmp(pref_id,"NO",2) == 0){
00201 Preferences.undo=FALSE;
00202 UNDO_ON=0;
00203 }
00204 GetPrivateProfileString(IniSection,"DIALOGS3D","$$$",
00205 pref_id,sizeof(pref_id),IniFilename);
00206 if(strncmp(pref_id,"NO",2) == 0){
00207 Preferences.use_3d_dialogs=FALSE;
00208 }
00209 GetPrivateProfileString(IniSection,"USEOPENGL","$$$",
00210 pref_id,sizeof(pref_id),IniFilename);
00211 if(strncmp(pref_id,"YES",2) == 0){
00212 Preferences.use_OpenGL=TRUE;
00213 }
00214 GetPrivateProfileString(IniSection,"VIEWCOLOUR","$$$",
00215 pref_id,sizeof(pref_id),IniFilename);
00216 if(strncmp(pref_id,"$$$",3) != 0){
00217 long i1,i2,i3;
00218 sscanf(pref_id,"%ld %ld %ld",&i1,&i2,&i3);
00219 Preferences.Vcolour[0]=(unsigned char)i1;
00220 Preferences.Vcolour[1]=(unsigned char)i2;
00221 Preferences.Vcolour[2]=(unsigned char)i3;
00222 }
00223 GetPrivateProfileString(IniSection,"TOOLTIPS","$$$",
00224 pref_id,sizeof(pref_id),IniFilename);
00225 if(strncmp(pref_id,"NO",2) == 0){
00226 Preferences.tooltips=FALSE;
00227 }
00228 GetPrivateProfileString(IniSection,"DLG95","$$$",
00229 pref_id,sizeof(pref_id),IniFilename);
00230 if(strncmp(pref_id,"NO",2) == 0){
00231 Preferences.attribs_sheet=FALSE;
00232 }
00233 GetPrivateProfileString(IniSection,"BIGV","$$$",
00234 pref_id,sizeof(pref_id),IniFilename);
00235 if(strncmp(pref_id,"YES",3) == 0){
00236 Preferences.bigv=TRUE;
00237 }
00238 GetPrivateProfileString(IniSection,"TOOLLEFT","$$$",
00239 pref_id,sizeof(pref_id),IniFilename);
00240 if(strncmp(pref_id,"YES",3) == 0)Preferences.toolleft=TRUE;
00241 if(strncmp(pref_id,"NO",2) == 0)Preferences.toolleft=FALSE;
00242 GetPrivateProfileString(IniSection,"TOOLSMALL","$$$",
00243 pref_id,sizeof(pref_id),IniFilename);
00244 if(strncmp(pref_id,"YES",3) == 0)Preferences.toolsmall=TRUE;
00245 if(strncmp(pref_id,"NO",2) == 0)Preferences.toolsmall=FALSE;
00246 GetPrivateProfileString(IniSection,"BACKIMAGE","$$$",
00247 pref_id,sizeof(pref_id),IniFilename);
00248 if(strncmp(pref_id,"YES",3) == 0)Preferences.background=TRUE;
00249 if(strncmp(pref_id,"NO",2) == 0)Preferences.background=FALSE;
00250 ActiveView=GetPrivateProfileInt(IniSection,"ACTIVEVIEW",TRITOP,
00251 IniFilename);
00252 GetPrivateProfileString(IniSection,"POSITIONS","$$$",
00253 pref_id,sizeof(pref_id),IniFilename);
00254 if(strncmp(pref_id,"NO",2) == 0){
00255 Preferences.use_positions=FALSE;
00256 }
00257 bBackgroundImage=Preferences.background;
00258 bToolpannelLeft=Preferences.toolleft;
00259 bToolpannelSmall=Preferences.toolsmall;
00260 bEmbedImageMaps=Preferences.embedimages;
00261
00262 GetPrivateProfileString(IniSection,"QUICKDRAW","$$$",
00263 pref_id,sizeof(pref_id),IniFilename);
00264 if(strncmp(pref_id,"YES",3) == 0)global_quickdraw=1;
00265 if(strncmp(pref_id,"NO",2) == 0)global_quickdraw=0;
00266 DefaultBrilliance=GetPrivateProfileInt(IniSection,
00267 "DefaultBrilliance",DefaultBrilliance,IniFilename);
00268 DefaultParameter=GetPrivateProfileInt(IniSection,
00269 "DefaultParameter",DefaultParameter,IniFilename);
00270 DefaultReflectivity=GetPrivateProfileInt(IniSection,
00271 "DefaultReflectivity",DefaultReflectivity,IniFilename);
00272 DefaultTransp=GetPrivateProfileInt(IniSection,
00273 "DefaultReflectivity",DefaultReflectivity,IniFilename);
00274 DefaultTexture=GetPrivateProfileInt(IniSection,
00275 "DefaultTexture",DefaultTexture,IniFilename);
00276 DefaultShiny=GetPrivateProfileInt(IniSection,
00277 "DefaultShiny",DefaultShiny,IniFilename);
00278 DefaultSmoothing=GetPrivateProfileInt(IniSection,
00279 "DefaultSmoothing",DefaultSmoothing,IniFilename);
00280 FaceColour[0]=GetPrivateProfileInt(IniSection,
00281 "FaceColour0",FaceColour[0],IniFilename);
00282 FaceColour[1]=GetPrivateProfileInt(IniSection,
00283 "FaceColour1",FaceColour[1],IniFilename);
00284 FaceColour[2]=GetPrivateProfileInt(IniSection,
00285 "FaceColour2",FaceColour[2],IniFilename);
00286 ShaderColour[0]=GetPrivateProfileInt(IniSection,
00287 "ShaderColour0",ShaderColour[0],IniFilename);
00288 ShaderColour[1]=GetPrivateProfileInt(IniSection,
00289 "ShaderColour1",ShaderColour[1],IniFilename);
00290 ShaderColour[2]=GetPrivateProfileInt(IniSection,
00291 "ShaderColour2",ShaderColour[2],IniFilename);
00292 LastColour[0]=FaceColour[0];
00293 LastColour[1]=FaceColour[1];
00294 LastColour[2]=FaceColour[2];
00295 coords_visible=GetPrivateProfileInt(IniSection,"COORDSVISIBLE",
00296 coords_visible,IniFilename);
00297 draw_grid_on=GetPrivateProfileInt(IniSection,"DRAWGRIDON",
00298 draw_grid_on,IniFilename);
00299 grid_on=GetPrivateProfileInt(IniSection,"GRIDON",
00300 grid_on,IniFilename);
00301 rubberbone_model=GetPrivateProfileInt(IniSection,"RUBBERBONEMODEL",
00302 rubberbone_model,IniFilename);
00303 return;
00304 }
00305
00306 void ActivatePreferences(void){
00307 HMENU hmenu;
00308 hmenu=GetMenu(ghwnd_main);
00309 if(global_quickdraw)CheckMenuItem(hmenu,
00310 IDM_VIEW_DRAWING_HIDEEDGES,MF_CHECKED);
00311 else CheckMenuItem(hmenu,
00312 IDM_VIEW_DRAWING_HIDEEDGES,MF_UNCHECKED);
00313 if(coords_visible){
00314 if(IsWindow(ghwndCoord1))ShowWindow(ghwndCoord1,SW_SHOWNA);
00315 CheckMenuItem(hmenu,IDM_WINDOW_COORDS,MF_CHECKED);
00316 }
00317 if(draw_grid_on)CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_DRAW_GRID,MF_CHECKED);
00318 if(grid_on)CheckMenuItem(GetMenu(ghwnd_main),IDM_VIEW_GRID,MF_CHECKED);
00319 if(GetPrivateProfileInt(IniSection,"VIEW",View,IniFilename)
00320 == ONEVIEW)PostMessage(ghwnd_main,WM_COMMAND,
00321 (WPARAM)IDM_WINDOW_SWITCHWINDOWS,(LPARAM)0);
00322 if(rubberbone_model == 1){
00323 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_CHECKED);
00324 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_UNCHECKED);
00325 }
00326 else {
00327 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELCONST,MF_UNCHECKED);
00328 CheckMenuItem(hmenu,IDM_HIERARCHY_RUBBERMODELVARI,MF_CHECKED);
00329 }
00330 }
00331
00332 BOOL DesignStartup(UINT *screen_r){
00333 int id,i;
00334 HMENU hmenu,hmenu1;
00335 HANDLE h;
00336 FILE *ff;
00337 WIN32_FIND_DATA ffd,*lpffd;
00338 char str[255],title[64];
00339 InitialiseStringVectors();
00340 ghcurWait = LoadCursor(NULL,IDC_WAIT);
00341 ghcurArrow = LoadCursor(NULL,IDC_ARROW);
00342 ghcurArrowD = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_OPENARROW));
00343 ghcurPan = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PAN));
00344 ghcurZout = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOMOUT));
00345 ghcurZin = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOMIN));
00346 ghcurZoom = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOM));
00347 ghcurCross = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_NONE));
00348 ghcurSelect = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SELECTOR));
00349 ghcurDeselect= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_DESELECTOR));
00350 ghcurPlotter = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PLOTTER));
00351 ghcurPlot3d = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PLOT3D));
00352 ghcurGrabber = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_GRABBER));
00353 ghcurBuilder = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_BUILDER));
00354 ghcurExpander= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_EXPANDER));
00355 ghcurRotator = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ROTATOR));
00356 ghcurPrims = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PRIMS));
00357 ghcurShaper = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SHAPER));
00358 ghcurMagnetTo= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_MAGNETTO));
00359 ghcurMagnetFr= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_MAGNETFROM));
00360 ghcurMagnetTw= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_MAGNETTWIST));
00361 ghcurMagnetCu= LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_MAGNETCURL));
00362 ghcurSel_a = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_A));
00363 ghcurSel_s = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_S));
00364 ghcurSel_l_a = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_L_A));
00365 ghcurSel_l_s = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_L_S));
00366 ghcurSel_c_a = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_C_A));
00367 ghcurSel_c_s = LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SEL_C_S));
00368 ghcurTools[ 0]= ghcurArrow;
00369 ghcurTools[ 1]= ghcurArrowD;
00370 ghcurTools[ 2]= ghcurPan;
00371 ghcurTools[ 3]= ghcurZoom;
00372 ghcurTools[ 4]= ghcurGrabber;
00373 ghcurTools[ 5]= ghcurRotator;
00374 ghcurTools[ 6]= ghcurExpander;
00375 ghcurTools[ 7]= ghcurPlotter;
00376 ghcurTools[ 8]= ghcurShaper;
00377 ghcurTools[ 9]= ghcurMagnetTo;
00378 ghcurTools[10]= ghcurBuilder;
00379 ghcurTools[11]= ghcurPlot3d;
00380 if(FindWindow("OFX:AnimatorClass",NULL) == NULL)StartedInModeler=TRUE;
00381 else StartedInModeler=FALSE;
00382 GetModuleFileName(ghinst_main,gszHomeDir,MAX_DIR);
00383 *FileInPath(gszHomeDir) = '\0';
00384 gszSCEfile[0]='\0';strcpy(gszSCEdir,gszHomeDir);strcat(gszSCEdir,"models");
00385 gszSCFfile[0]='\0';strcpy(gszSCFdir,gszHomeDir);strcat(gszSCFdir,"models");
00386 gszSCNfile[0]='\0';strcpy(gszSCNdir,gszHomeDir);strcat(gszSCNdir,"models");
00387 gszPTHfile[0]='\0';strcpy(gszPTHdir,gszHomeDir);strcat(gszPTHdir,"models");
00388 gszIMGfile[0]='\0';strcpy(gszIMGdir,gszHomeDir);strcat(gszIMGdir,"maps");
00389 gszGIFfile[0]='\0';strcpy(gszGIFdir,gszHomeDir);strcat(gszGIFdir,"maps");
00390 gszDLLfile[0]='\0';strcpy(gszDLLdir,gszHomeDir);strcat(gszDLLdir,"textures");
00391 gszDLMfile[0]='\0';strcpy(gszDLMdir,gszHomeDir);strcat(gszDLMdir,"plugins");
00392 gszDXFfile[0]='\0';strcpy(gszDXFdir,gszHomeDir);strcat(gszDXFdir,"models");
00393 gsz3DSfile[0]='\0';strcpy(gsz3DSdir,gszHomeDir);strcat(gsz3DSdir,"models");
00394 gszTDDfile[0]='\0';strcpy(gszTDDdir,gszHomeDir);strcat(gszTDDdir,"models");
00395 gszAVIfile[0]='\0';strcpy(gszAVIdir,gszHomeDir);strcat(gszAVIdir,"movies");
00396 gszBRDfile[0]='\0';strcpy(gszBRDdir,gszHomeDir);strcat(gszBRDdir,"renderx");
00397 gszMTLfile[0]='\0';strcpy(gszMTLdir,gszHomeDir);strcat(gszMTLdir,"maps");
00398 SetUpWindowBoxView(0);
00399 nImaps=0; nLockediMaps=0; nMats=0;
00400
00401 tool=NOTOOL; sktool=NO;
00402
00403 sprintf(str,"%s\\*.afx",gszDLMdir);
00404 lpffd=&ffd;
00405 nActionsList=0;
00406 if((h=FindFirstFile(str,lpffd)) != INVALID_HANDLE_VALUE){
00407 sprintf(str,"%s\\%s",gszDLMdir,lpffd->cFileName);
00408 ActionsList[nActionsList]=(char *)X__Malloc(256*sizeof(char));
00409 if(ActionsList[nActionsList] != NULL)strcpy(ActionsList[nActionsList],str);
00410 nActionsList++;
00411 while(FindNextFile(h,lpffd)){
00412 sprintf(str,"%s\\%s",gszDLMdir,lpffd->cFileName);
00413 ActionsList[nActionsList]=(char *)X__Malloc(256*sizeof(char));
00414 strcpy(ActionsList[nActionsList],str);
00415 nActionsList++;
00416 }
00417 if(GetLastError() != ERROR_NO_MORE_FILES){
00418 SendPrgmQuery(IDQ_BADNEXTFILE,3);
00419 }
00420 if(!FindClose(h))SendPrgmQuery(IDQ_FILEERROR,3);
00421 hmenu=GetSubMenu(GetMenu(ghwnd_main),4);
00422 AppendMenu(hmenu,MF_SEPARATOR,0,0);
00423
00424 hmenu1=CreatePopupMenu();
00425 LoadString(ghinst_main,IDX_MISC_PLUGINACTIONS,title,64);
00426 AppendMenu(hmenu,MF_POPUP,(UINT)hmenu1,title);
00427
00428 if(nActionsList > 0)for(i=0;i<nActionsList;i++){
00429 if((ff=fopen(ActionsList[i],"r")) != NULL){
00430 fscanf(ff,"%[^\n]",title);
00431 AppendMenu(hmenu1,MF_ENABLED | MF_STRING,i+30000,title);
00432 fclose(ff);
00433 }
00434 }
00435 }
00436 InitializeLastFilesList();
00437 SendPrgmMessage(IDS_DEFAULT,0);
00438 EDIT_ACTION=NO;
00439 DeleteMemoryWindows();
00440 if(!CreateMemoryWindows()){
00441 MessageBox (NULL,"Fatal ERROR", NULL, MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00442 return FALSE;
00443 }
00444 EraseAll(1);
00445 SetupStructures();
00446 *screen_r=1;
00447 update_timer=0;
00448 DrawModel();
00449 if(ghwndOpenGLview == NULL)Draw3dView(0,0);
00450 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
00451 return TRUE;
00452 }
00453
00454 BOOL SetupMainWindow(HANDLE inst, int cmdshow){
00455 long i;
00456 RECT rc;
00457 HDC hdc;
00458 TEXTMETRIC tm;
00459 int StatusPartsList[2]={0,-1};
00460 Yres=GetSystemMetrics(SM_CYSCREEN);
00461 Xres=GetSystemMetrics(SM_CXSCREEN);
00462 View=TRIVIEW;
00463 ghwndTools=NULL;
00464 ghwndCoord1=NULL; ghwndData=NULL;
00465 ghwnd_current=NULL; ghwndDlgAttribs=NULL;
00466 ghwndLock=NULL; ghwndDlgTools=NULL;
00467 ghwndDlgExpand=NULL; ghwndTooltip=NULL;
00468 ghwndSkEdit=NULL; ghwndSkToolbar=NULL;
00469 ghwndDlgPrimitives=NULL;
00470 ghwnd_main = CreateWindow(
00471 szMainClass,
00472 " ",
00473 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
00474 WS_MAXIMIZE | !WS_VISIBLE | WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
00475 0,
00476 0,
00477 Xres,
00478 Yres,
00479 NULL,
00480 NULL,
00481 inst,
00482 NULL
00483 );
00484 if( !ghwnd_main ) return( FALSE );
00485 ghwnd_info=CreateWindowEx(0L,STATUSCLASSNAME,"",
00486 WS_CHILD | !WS_BORDER | WS_VISIBLE,
00487 0,0,0,0,
00488 ghwnd_main,
00489 (HMENU)NULL,
00490 inst,
00491 NULL);
00492 if(!ghwnd_info)return(FALSE);
00493 StatusPartsList[0]=Xres-SIZESTATUS1;
00494 SendMessage(ghwnd_info,SB_SETPARTS,(WPARAM)2,(LPARAM)StatusPartsList);
00495 GetClientRect(ghwnd_info,&rc);
00496 InfoWindowSize=rc.bottom-rc.top;
00497 LoadMenuHelpTable(ghwnd_main);
00498 GetClientRect(ghwnd_main,&rc);
00499 SetWindowSize(rc.right,rc.bottom,View,TRUE);
00500 GetTriview(TRUE);
00501 for(i=0;i<3;i++){
00502 ghwnd_triview[i] = CreateWindow(
00503 szTriViewClass,
00504 NULL,
00505 WS_CHILD | WS_BORDER | WS_VISIBLE,
00506 WindowsXmin[i],WindowsYmin[i],WindowSizeX[i],WindowSizeY[i],
00507 ghwnd_main,
00508 (HMENU)i,
00509 inst,
00510 NULL
00511 );
00512 if(!ghwnd_triview[i])return(FALSE);
00513 }
00514 ghwnd_view = CreateWindow(
00515 szViewClass,
00516 NULL,
00517 WS_CHILD | WS_BORDER | WS_VISIBLE |
00518 WS_HSCROLL | WS_VSCROLL,
00519 WindowViewXmin,WindowViewYmin,WindowViewXsize,WindowViewYsize,
00520 ghwnd_main,
00521 NULL,
00522 inst,
00523 NULL
00524 );
00525 if(!ghwnd_view)return(FALSE);
00526 cmdshow=SW_SHOWMAXIMIZED;
00527 SetScrollRange(ghwnd_view,SB_HORZ,0,359,FALSE);
00528 SetScrollRange(ghwnd_view,SB_VERT,0,179,FALSE);
00529 SetScrollPos(ghwnd_view,SB_HORZ,(int)PerspFi+180,FALSE);
00530 SetScrollPos(ghwnd_view,SB_VERT,(int)PerspTheta+90,FALSE);
00531 ghwnd_current=ghwnd_triview[ActiveView];
00532 ToolboxShow(TRUE);
00533 if(!ghwndTools){
00534 MessageBox (NULL,"Can't find icon bitmaps","Error",
00535 MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00536 return (FALSE);
00537 }
00538 hdc=GetDC(ghwnd_main);
00539 GetTextMetrics(hdc,&tm);
00540 ReleaseDC(ghwnd_main,hdc);
00541 Textwidth = tm.tmAveCharWidth;
00542 Textheight = tm.tmHeight;
00543 ghFont1=CreateFont(-12,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,
00544 ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
00545 FIXED_PITCH,"MS Sans Serif");
00546 ghFont2=CreateFont(-12, 0, 0, 0, FW_LIGHT, FALSE, FALSE, FALSE,
00547 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
00548 PROOF_QUALITY, VARIABLE_PITCH | FF_SWISS,
00549 "Arial");
00550 ShowWindow( ghwnd_main, cmdshow);
00551 return TRUE;
00552 }
00553
00554 static void UnloadRenderer(void){
00555 HWND hWnd;
00556 if((hWnd=FindWindow("OFX:RenderClass",NULL)) != NULL){
00557 SendMessage(hWnd,WM_COMMAND,IDM_CALLBACK_SHUTDOWN,0);
00558 return;
00559 }
00560 }
00561
00562 void DesignShutdown(void){
00563 int i;
00564 HWND hWndPrev;
00565 char ss[32];
00566 if(ghwndOpenGLview != NULL)StartOpenGL(FALSE);
00567 DeleteArrowIcons();
00568 Empty_Undo();
00569 EraseTempImageFiles();
00570 EraseAll(1);
00571 DeleteMemoryWindows();
00572 ToolboxDestroy();
00573 UnloadRenderer();
00574 hWndPrev = FindWindow("OFX:AnimatorClass",NULL);
00575 if (hWndPrev != NULL){
00576 SetForegroundWindow(hWndPrev);
00577 BringWindowToTop(hWndPrev);
00578 ShowWindow (hWndPrev,SW_SHOW);
00579 if(StartedInModeler)PostMessage(hWndPrev,WM_COMMAND,IDM_CALLBACK_SHUTDOWN,0);
00580 }
00581 hWndPrev = FindWindow("OFX:BezierClass",NULL);
00582 if(hWndPrev != NULL){
00583 PostMessage(hWndPrev,WM_COMMAND,106,0);
00584 }
00585 hWndPrev = FindWindow("OFX:ViewClass",NULL);
00586 if(StartedInModeler && hWndPrev != NULL)
00587 PostMessage(hWndPrev,WM_COMMAND,106,0);
00588 hWndPrev = FindWindow("MDI:Viewer",NULL);
00589 if(StartedInModeler &&hWndPrev != NULL)
00590 PostMessage(hWndPrev,WM_COMMAND,1001,0);
00591 if(nActionsList > 0){
00592 for(i=0;i<nActionsList;i++){
00593 if(ActionsList[i] != NULL)X__Free(ActionsList[i]);
00594 }
00595 nActionsList=0;
00596 }
00597 FreeStringVectors();
00598 FreeMenuHelpData();
00599
00600
00601 DeleteObject(ghbrushScreen);
00602 DeleteObject(ghbrushWindow);
00603 DeleteObject(ghSelectedBrush);
00604 DeleteObject(ghDeselectedBrush);
00605 DeleteObject(ghInvertBrush);
00606 DeleteObject(ghSelectedPen);
00607 DeleteObject(ghDotSelectedPen);
00608 DeleteObject(ghDeselectedPen);
00609 DeleteObject(ghEditPen);
00610 DeleteObject(ghWireframePen);
00611 DeleteObject(ghCursorPen);
00612 DeleteObject(ghInvertPen);
00613 DeleteObject(ghEdgePen);
00614 DeleteObject(ghSelectorPen);
00615 DeleteObject(ghDeselectorPen);
00616 DeleteObject(ghcurArrowD);
00617 DeleteObject(ghcurCross);
00618 DeleteObject(ghcurSelect);
00619 DeleteObject(ghcurDeselect);
00620 DeleteObject(ghcurPan);
00621 DeleteObject(ghcurZout);
00622 DeleteObject(ghcurZin);
00623 DeleteObject(ghcurZoom);
00624 DeleteObject(ghcurPlotter);
00625 DeleteObject(ghcurPlot3d);
00626 DeleteObject(ghcurGrabber);
00627 DeleteObject(ghcurBuilder);
00628 DeleteObject(ghcurExpander);
00629 DeleteObject(ghcurRotator);
00630 DeleteObject(ghcurPrims);
00631 DeleteObject(ghcurShaper);
00632 DeleteObject(ghcurMagnetTo);
00633 DeleteObject(ghcurMagnetFr);
00634 DeleteObject(ghcurMagnetTw);
00635 DeleteObject(ghcurMagnetCu);
00636 DeleteObject(ghcurSel_a);
00637 DeleteObject(ghcurSel_s);
00638 DeleteObject(ghcurSel_l_a);
00639 DeleteObject(ghcurSel_l_s);
00640 DeleteObject(ghcurSel_c_a);
00641 DeleteObject(ghcurSel_c_s);
00642 if(ghFont1 != NULL)DeleteObject(ghFont1);
00643 if(ghFont2 != NULL)DeleteObject(ghFont2);
00644 sprintf(ss,"%ld",View);
00645 WritePrivateProfileString(IniSection,"VIEW",ss,IniFilename);
00646 sprintf(ss,"%ld",ActiveView);
00647 WritePrivateProfileString(IniSection,"ACTIVEVIEW",ss,IniFilename);
00648 if(global_quickdraw)
00649 WritePrivateProfileString(IniSection,"QUICKDRAW","YES",IniFilename);
00650 else
00651 WritePrivateProfileString(IniSection,"QUICKDRAW","NO",IniFilename);
00652 sprintf(ss,"%ld",DefaultBrilliance);
00653 WritePrivateProfileString(IniSection,"DefaultBrilliance",ss,IniFilename);
00654 sprintf(ss,"%ld",DefaultParameter);
00655 WritePrivateProfileString(IniSection,"DefaultParameter",ss,IniFilename);
00656 sprintf(ss,"%ld",DefaultReflectivity);
00657 WritePrivateProfileString(IniSection,"DefaultReflectivity",ss,IniFilename);
00658 sprintf(ss,"%ld",DefaultReflectivity);
00659 WritePrivateProfileString(IniSection,"DefaultReflectivity",ss,IniFilename);
00660 sprintf(ss,"%ld",DefaultTexture);
00661 WritePrivateProfileString(IniSection,"DefaultTexture",ss,IniFilename);
00662 sprintf(ss,"%ld",DefaultShiny);
00663 WritePrivateProfileString(IniSection,"DefaultShiny",ss,IniFilename);
00664 sprintf(ss,"%ld",DefaultSmoothing);
00665 WritePrivateProfileString(IniSection,"DefaultSmoothing",ss,IniFilename);
00666 sprintf(ss,"%ld",FaceColour[0]);
00667 WritePrivateProfileString(IniSection,"FaceColour0",ss,IniFilename);
00668 sprintf(ss,"%ld",FaceColour[1]);
00669 WritePrivateProfileString(IniSection,"FaceColour1",ss,IniFilename);
00670 sprintf(ss,"%ld",FaceColour[2]);
00671 WritePrivateProfileString(IniSection,"FaceColour2",ss,IniFilename);
00672 sprintf(ss,"%ld",ShaderColour[0]);
00673 WritePrivateProfileString(IniSection,"ShaderColour0",ss,IniFilename);
00674 sprintf(ss,"%ld",ShaderColour[1]);
00675 WritePrivateProfileString(IniSection,"ShaderColour1",ss,IniFilename);
00676 sprintf(ss,"%ld",ShaderColour[2]);
00677 WritePrivateProfileString(IniSection,"ShaderColour2",ss,IniFilename);
00678 sprintf(ss,"%ld",coords_visible);
00679 WritePrivateProfileString(IniSection,"COORDSVISIBLE",ss,IniFilename);
00680 sprintf(ss,"%ld",draw_grid_on);
00681 WritePrivateProfileString(IniSection,"DRAWGRIDON",ss,IniFilename);
00682 sprintf(ss,"%ld",grid_on);
00683 WritePrivateProfileString(IniSection,"GRIDON",ss,IniFilename);
00684 sprintf(ss,"%ld",rubberbone_model);
00685 WritePrivateProfileString(IniSection,"RUBBERBONEMODEL",ss,IniFilename);
00686 return;
00687 }
00688
00689 void StartOpenGL(BOOL first_time){
00690 char oldname[256],newname[256];
00691 char lname[255],text[128];
00692 RECT rc;
00693 HWND hwnd=NULL;
00694 static HMODULE hLib=NULL;
00695 FARPROC fpFun;
00696 X__STRUCTURE *Evs;
00697 HWND (*fpFun1)(HWND, char *, LPRECT, double *, double *, int *, X__STRUCTURE *);
00698 GetCurrentDirectory(255,oldname);
00699 strcpy(newname,gszHomeDir);
00700 if(SetCurrentDirectory(newname) == FALSE)
00701 MessageBox(ghwnd_main,newname,NULL,MB_OK);
00702 {char sysdir[256];
00703 HANDLE hfbm;
00704 strcpy(sysdir,"opengl32.dll");
00705 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00706 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00707 if(hfbm == INVALID_HANDLE_VALUE){
00708 GetSystemDirectory(sysdir,256); strcat(sysdir,"\\opengl32.dll");
00709 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00710 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00711 if(hfbm == INVALID_HANDLE_VALUE){
00712 SetCurrentDirectory(oldname);
00713 return;
00714 }
00715 CloseHandle(hfbm);
00716 }
00717 else CloseHandle(hfbm);
00718 }
00719 EnableMenuItem(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,MF_ENABLED);
00720 if(first_time && !Preferences.use_OpenGL)return;
00721 if(hLib != NULL){
00722 if(ghwndOpenGLview != NULL)DestroyWindow(ghwndOpenGLview);
00723 SetScrollPos(ghwnd_view,SB_HORZ,(int)PerspFi+180,TRUE);
00724 SetScrollPos(ghwnd_view,SB_VERT,(int)PerspTheta+90,TRUE);
00725 ShowWindow(ghwnd_view,SW_SHOWNA);
00726 LoadString(ghinst_main,IDX_MISC_SHOWGL,text,128);
00727 ModifyMenu(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,
00728 MF_BYCOMMAND|MF_STRING,IDM_WINDOW_SHOWOPENGL,text);
00729 FreeLibrary(hLib); hLib=NULL;
00730 ghwndOpenGLview=NULL;
00731 SetCurrentDirectory(oldname);
00732 return;
00733 }
00734 Evs=&EviStructure;
00735 rc.left=WindowViewXmin;
00736 rc.top=WindowViewYmin;
00737 rc.right=WindowViewXsize;
00738 rc.bottom=WindowViewYsize;
00739 strcpy(lname,gszHomeDir); strcat(lname,"gldesign.dll");
00740 if((hLib=LoadLibrary(lname)) != NULL){
00741 if((fpFun=GetProcAddress(hLib,"_AttachViewOpenGL")) != NULL){
00742 ShowWindow(ghwnd_view,SW_HIDE);
00743 fpFun1 = (void *)fpFun;
00744 hwnd=(*fpFun1)(ghwnd_main,NULL,&rc,&PerspTheta,&PerspFi,&tool,Evs);
00745 }
00746 else{
00747 SendPrgmQuery(IDQ_FAILEDFUNCTION,3);
00748 FreeLibrary(hLib); hLib=NULL;
00749 }
00750 }
00751 else SendPrgmQuery(IDQ_FAILEDLIBRARY,3);
00752 ghwndOpenGLview=hwnd;
00753 if(hwnd != NULL){
00754 LoadString(ghinst_main,IDX_MISC_HIDEGL,text,128);
00755 ModifyMenu(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,
00756 MF_BYCOMMAND|MF_STRING,IDM_WINDOW_SHOWOPENGL,text);
00757 }
00758 SetCurrentDirectory(oldname);
00759 return;
00760 }
00761
00762 void ExecuteAnimator(BOOL reload){
00763 int result;
00764 char modulename[255];
00765 HWND hWnd;
00766 if((hWnd=FindWindow("OFX:AnimatorClass",NULL)) != NULL){
00767 SetForegroundWindow(hWnd);
00768 BringWindowToTop(hWnd);
00769 if(reload)PostMessage(hWnd,WM_COMMAND,IDM_CALLBACK_RELOAD,0);
00770 }
00771 else{
00772 strcpy(modulename,gszHomeDir);strcat(modulename,"openfx.exe");
00773 result=WinExec(modulename,SW_SHOW);
00774 if(result < 32){
00775 if(result == ERROR_FILE_NOT_FOUND ||
00776 result == ERROR_PATH_NOT_FOUND)SendPrgmQuery(IDQ_NOSTART,3);
00777 }
00778 if((hWnd=FindWindow("OFX:AnimatorClass",NULL)) != NULL){
00779 SetForegroundWindow(hWnd);
00780 BringWindowToTop(hWnd);
00781 if(reload)PostMessage(hWnd,WM_COMMAND,IDM_CALLBACK_RELOAD,0);
00782 }
00783 else SendPrgmQuery(IDQ_NOSTART,3);
00784 }
00785 }
00786
00787 #include "..\animate\memory.c"
00788
00789 static unsigned long DUMMY_Long=0;
00790
00791 void SetupStructures(void){
00792
00793 X__STRUCTURE *lpEVI;
00794 X__MEMORY_MANAGER *lpEVIMM;
00795 lpEVI=&EviStructure;
00796 lpEVI->Nvert = &Nvert;
00797 lpEVI->NvertSelect = &NvertSelect;
00798 lpEVI->NvertDeselect = &NvertDeselect;
00799 lpEVI->NvertG = &DUMMY_Long;
00800 lpEVI->Nskel = &Nskel;
00801 lpEVI->Nedge = &Nedge;
00802 lpEVI->Nface = &Nface;
00803 lpEVI->Nnurbs = &Nnurbs;
00804 lpEVI->nImaps = &nImaps;
00805 lpEVI->nMats = &nMats;
00806 lpEVI->MainVp = &MainVp;
00807 lpEVI->MainEp = &MainEp;
00808 lpEVI->MainFp = &MainFp;
00809 lpEVI->MainSp = &MainSp;
00810 lpEVI->MainNp = &MainNp;
00811 lpEVI->FirstSp = &FirstSp;
00812 lpEVI->iMap=iMap;
00813 lpEVI->iMat=iMat;
00814 lpEVI->xShaders=NULL;
00815 lpEVI->NpointerX=&NpointerX;
00816 lpEVI->NpointerY=&NpointerY;
00817 lpEVI->NpointerZ=&NpointerZ;
00818 lpEVI->TVpointX=&TVpointX;
00819 lpEVI->TVpointY=&TVpointY;
00820 lpEVI->TVpointZ=&TVpointZ;
00821 lpEVI->TVsizeX=&TVsizeX;
00822 lpEVI->TVsizeY=&TVsizeY;
00823 lpEVI->TVsizeZ=&TVsizeZ;
00824 lpEVI->ruler=&ruler;
00825 lpEVI->rulerx=&rulerx; lpEVI->rulery=&rulery; lpEVI->rulerz=&rulerz;
00826 lpEVI->orulerx=&lrulerx; lpEVI->orulery=&lrulery; lpEVI->orulerz=&lrulerz;
00827 lpEVI->ActiveView=&ActiveView;
00828 lpEVI->w_frame=&w_frame;
00829 #if __LITE__
00830 lpEVI->version=0;
00831 #else
00832 lpEVI->version=1;
00833 #endif
00834
00835 lpEVI->fpDA=EraseAll;
00836 lpEVI->fpCV=CreateVertex;
00837 lpEVI->fpCE=CreateEdge;
00838 lpEVI->fpCF=CreateFace;
00839 lpEVI->fpCS=CreateSkeleton;
00840 lpEVI->fpUVH=UpdateVertexHeap;
00841 lpEVI->fpUEH=UpdateEdgeHeap;
00842 lpEVI->fpUFH=UpdateFaceHeap;
00843 lpEVI->fpTool_UP=UpdateCounters;
00844 lpEVI->fpTool_RD=DrawModel;
00845 lpEVI->fpTool_CP=AddCopy;
00846 lpEVI->fpTool_FC=AutoFacetCurveWithHoles;
00847 lpEVI->fpTool_AC=CreateAttachedCopy;
00848 lpEVI->fpChooseColour=SetColour;
00849 lpEVI->fpChooseFile=SelectFileName;
00850 lpEVI->fpCentreDlgOnC=CentreDialogOnCursor;
00851 lpEVI->fpCentreDlgOnS=CentreDialogOnScreen;
00852 lpEVI->fpCopyFaceProp=CopyFaceProp;
00853 lpEVI->fpZeroSkeletonBoundingBox=ZeroSkeletonBoundingBox;
00854 lpEVI->fpGetSkeletonBoundBox=GetSkeletonBoundBox;
00855 lpEVI->fpEraseVertex=EraseVertex;
00856 lpEVI->fpEraseVertexMapping=EraseVertexMapping;
00857 lpEVI->fpEraseSkeleton=EraseSkeleton;
00858 lpEVI->fpGetClosestVertex=get_closest_vertex;
00859 lpEVI->fpConnected=connected;
00860 lpEVI->fpNormalize=O_normalize;
00861 lpEVI->fpArbitraryRotate=arbitrary_rotate;
00862 lpEVI->fpOrientateFaceNormals=OrientateFaceNormals;
00863 lpEVI->fpReverseFaceOrientation=ReverseFaceOrientation;
00864 lpEVI->fpIsFOSame=IsFOSame;
00865 lpEVI->fpOrientateSelectedFaces=OrientateSelectedFaces;
00866 lpEVI->fpAppendFileExtension=AppendFileExtension;
00867 lpEVI->fpEraseAllNurbs=EraseAllNurbs;
00868 lpEVI->fpEraseNurbs=EraseNurbs;
00869 lpEVI->fpCreateNurbs=CreateNurbs;
00870 lpEVI->fpClearNurbsSkeleton=ClearNurbsSkeleton;
00871 lpEVI->fpAllocNurbs=AllocNurbs;
00872 lpEVI->fpCloneNurbs=CloneNurbs;
00873 lpEVI->fpReleaseNurbs=ReleaseNurbs;
00874
00875 lpEVI->fpCreateMaterial=CreateMaterial;
00876 lpEVI->fpCreateImageMap=CreateImageMap;
00877
00878
00879 lpEVIMM=&EviMemoryManager;
00880 lpEVIMM->fpMalloc=X__AllocateRam;
00881 lpEVIMM->fpFree=X__FreeRam;
00882 lpEVIMM->lpAni=NULL;
00883 lpEVIMM->lpMod=NULL;
00884 }
00885
00886 static PSTR apstr_StringTable[CSTRINGS];
00887 static PSTR apstr_QueryTable[QSTRINGS];
00888 static PSTR apstr_IconHelpTable[ISTRINGS];
00889
00890 void SendIconHelpMessage(int idString){
00891 PSTR pstr,p;
00892 INT cch;
00893 idString -= FIRST_IDI_STRING;
00894 if(apstr_IconHelpTable[idString] != NULL)p=apstr_IconHelpTable[idString];
00895 else{
00896 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return;
00897 if((cch = LoadString(ghinst_main, idString+FIRST_IDI_STRING,pstr, CCHTEXTMAX)) == 0){
00898 X__Free(pstr);
00899 return;
00900 }
00901 p = apstr_IconHelpTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00902 if(p == NULL)return;
00903 }
00904 SendMessage(ghwnd_info,SB_SETTEXT,(WPARAM)0,(LPARAM)p);
00905 }
00906
00907 void SendPrgmText(PSTR p){
00908 SendMessage(ghwnd_info,SB_SETTEXT,(WPARAM)0,(LPARAM)p);
00909 }
00910
00911 void SendPrgmMessage(int idString, int where){
00912 PSTR pstr,p;
00913 INT cch,string_id;
00914 idString -= FIRST_IDS_STRING;
00915 if(apstr_StringTable[idString] != NULL)p=apstr_StringTable[idString];
00916 else{
00917 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return;
00918 string_id=idString+FIRST_IDS_STRING;
00919 #if __LITE__
00920 if(idString == IDS_DEFAULT)string_id=IDS_DEFAULT_LITE;
00921 if(idString == IDS_CURRENT)string_id=IDS_CURRENT_LITE;
00922 #endif
00923 if((cch = LoadString(ghinst_main,string_id,pstr,CCHTEXTMAX)) == 0){
00924 X__Free(pstr);
00925 return;
00926 }
00927 p = apstr_StringTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00928 if(p == NULL)return;
00929 }
00930 if(where == 0)SendMessage(ghwnd_main,WM_SETTEXT,0,(LPARAM)p);
00931 else SendPrgmText(p);
00932 }
00933
00934 int SendPrgmQuery(int idString, int response){
00935 int a;
00936 PSTR pstr,p;
00937 INT cch;
00938 char title[128];
00939 idString -= FIRST_IDQ_STRING;
00940 if(apstr_QueryTable[idString] != NULL)p=apstr_QueryTable[idString];
00941 else{
00942 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return 0;
00943 if((cch = LoadString(ghinst_main,idString+FIRST_IDQ_STRING,pstr,CCHTEXTMAX)) == 0){
00944 X__Free(pstr);
00945 return 0;
00946 }
00947 p = apstr_QueryTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00948 if(p == NULL)return 0;
00949 }
00950 #if __LITE__
00951 LoadString(ghinst_main,IDS_DEFAULT_LITE,title,127);
00952 #else
00953 LoadString(ghinst_main,IDS_DEFAULT,title,127);
00954 #endif
00955 if(response > 0)MessageBeep(MB_ICONQUESTION);
00956 else MessageBeep(MB_OK);
00957 if (response == 3)a=MessageBox (GetFocus(),p,NULL,
00958 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
00959 else if(response == 2)a=MessageBox (GetFocus(),p,title,
00960 MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL);
00961 else if(response == 1)a=MessageBox (GetFocus(),p,title,
00962 MB_YESNO | MB_ICONQUESTION | MB_TASKMODAL);
00963 else a=MessageBox (GetFocus(),p,title,
00964 MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
00965 return a;
00966 }
00967
00968 void SetPrgmMessage(int idString, PSTR pstr){
00969 int l;
00970 PSTR p;
00971 idString -= FIRST_IDS_STRING;
00972 l=strlen(pstr)+1;
00973 if(apstr_StringTable[idString] == NULL){
00974 if((p=(PSTR)X__Malloc(l)) == NULL)return;
00975 }
00976 else{
00977 if((p=(PSTR)X__Realloc(apstr_StringTable[idString],l)) == NULL)return;
00978 }
00979 strcpy(p,pstr);
00980 apstr_StringTable[idString]=p;
00981 }
00982
00983 void InitialiseStringVectors(void){
00984 int i;
00985 for(i=0;i<CSTRINGS;i++)apstr_StringTable[i]=NULL;
00986 for(i=0;i<QSTRINGS;i++)apstr_QueryTable[i]=NULL;
00987 for(i=0;i<ISTRINGS;i++)apstr_IconHelpTable[i]=NULL;
00988 return;
00989 }
00990
00991 void FreeStringVectors(void){
00992 int i;
00993 for(i=0;i<CSTRINGS;i++)
00994 if(apstr_StringTable[i] != NULL)X__Free(apstr_StringTable[i]);
00995 for(i=0;i<QSTRINGS;i++)
00996 if(apstr_QueryTable[i] != NULL)X__Free(apstr_QueryTable[i]);
00997 for(i=0;i<ISTRINGS;i++)
00998 if(apstr_IconHelpTable[i] != NULL)X__Free(apstr_IconHelpTable[i]);
00999 return;
01000 }