00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include <stdlib.h>
00012 #include <stdio.h>
00013 #include <time.h>
00014 #include <windows.h>
00015 #include <commctrl.h>
00016 #include <gl\gl.h>
00017 #include <gl\glu.h>
00018 #include <vfw.h>
00019
00020 #include "update.h"
00021 #include "rmessage.h"
00022 #include "settings.h"
00023 #include "preview.h"
00024 #include "..\common\animate\callall.h"
00025 #include "..\common\animate\spin_dll.h"
00026 #include "..\common\animate\about.h"
00027 #include "..\common\mem.h"
00028 #include "..\animate\memory.h"
00029 #include "..\animate\memory.c"
00030
00031 void UpdateNTFrame(long, long);
00032
00033 static void CentreDialogOnCursor(HWND);
00034 static int SelectFileName(int save, char *szfile, char *szdir,
00035 char *szTitle, char *szfilter, HWND parent);
00036 static int SelectDirectoryName(char *szfile, char *szdir,
00037 char *szTitle, char *szfilter, HWND parent);
00038 static PSTR FileInPath(PSTR pstrPath);
00039 static BOOL FirstInstance(HANDLE inst);
00040 static long GetCharListID(char *item, char **list, long n);
00041 static void PlayAnimation(char *, long);
00042 static int BuildAnimation(char *, long, long, long);
00043 static void DisplayOutputFile(void);
00044 static int RendererMainLoop(HINSTANCE hInstance, int wait);
00045
00046 static BOOL InitiateRendererUpdateView(HWND);
00047 static void TerminateRendererUpdateView(void);
00048 static void ExecuteQuickInlineRenderer(HWND,HWND);
00049 static void GetNumberOfScriptFrames(void);
00050 static void UpdateControlDlg(HWND hdlg,BOOL ini);
00051 static void PaintDialogBackground(HWND hDlg, HINSTANCE hInst);
00052 static BOOL CALLBACK TabbedDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
00053 LPARAM lparam );
00054 static BOOL CALLBACK UpdateDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
00055 LPARAM lparam );
00056 static BOOL CALLBACK UpdateXDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
00057 LPARAM lparam );
00058 static BOOL CALLBACK PreferencesDlgProc(HWND hdlg,UINT msg,
00059 WPARAM wparam,LPARAM lparam);
00060 static void LoadPreferences(void);
00061
00062 #define MAX_DIR 255
00063 #define MAX_FILE 255
00064 #define NOCOLOUR 32768L
00065
00066
00067 typedef struct SCREENBUFFER {
00068 unsigned char R,G,B,A;
00069 } fullscreenbuffer;
00070
00071
00080 typedef struct tagPARAMLIST {
00081 long ot,di,re,
00082 aa,ae,
00083 swgp,
00084 ns,
00085 ef,
00086 bUseOpenGLrender,
00087 bDrawDirectly,
00088 nv_not_used,
00089 sc,
00090 al,
00091 sd,
00092 sb,
00093 bCopyGLdepth,
00094 xres,yres,
00095 zbuffer,
00096 colour0,speed,
00097 last_ot;
00098 char pic_dir[256],pic_file[256];
00099 char fli_dir[256],fli_file[256];
00100 char scr_dir[256],scr_file[256];
00101 char tmp_dir[256],tmp_file[256];
00102 long u3,logfile;
00103 long avi_fli;
00104 long ntsc_colours;
00105 long personal;
00106 long blur;
00107 long full_mirror;
00108 long bUseFBO ;
00109 long ob;
00110 long callback;
00111 long trace_shadows,
00112 trace_reflections,
00113 trace_refractions,
00114 trace_partition,
00115 trace_depth,
00116 trace_face_count_target,
00117 trace_voxel_min_size,
00118 trace_unused;
00119 long jpeg_quality;
00120 long tzeros;
00121 long Nthreads;
00122 long interlace_gif;
00123 long tzero_still;
00124 long beep_after;
00125 long autoshow;
00126 long autoplay;
00127 long constrain;
00128 long avi_low;
00129 long avi_compress;
00130 long bRenderStereo;
00131 } PARAMLIST;
00132
00133
00134 static PARAMLIST ParamList={
00135 0,1,1,
00136 2,1,0,
00137 0,
00138 0,
00139 0,0,
00140 15,
00141 60,10,
00142 50,300,
00143 0,
00144 800,600,
00145 1,
00146 0,5,
00147 0,
00148 " "," ",
00149 " "," ",
00150 " "," ",
00151 " "," ",
00152 1,0,
00153 1,
00154 0,0,0,
00155 0,
00156 0,
00157 0,
00158 1,
00159 0,0,0,1,
00160 8,25,4,0,
00161 75,
00162 4,
00163 0,
00164 0,
00165 0,
00166 0,
00167 1,1,
00168 0,
00169 0,
00170 0,
00171 0
00172 },*plp;
00173
00174 FILE *debug=NULL;
00175 unsigned long *colorstats0;
00176 unsigned short *colorstats1;
00177 char gszHomeDir[MAX_DIR];
00178 HINSTANCE hThisInstance=NULL;
00179 HWND hWndOpenGL=NULL;
00180 char TempPath[MAX_DIR];
00181
00182
00183 static FILE *logfile=NULL;
00184 static X__MEMORY_MANAGER EviMemoryManager;
00185 static time_t last_frame_start,start_time;
00186 static HMODULE hLibSpin=NULL;
00187 static HMODULE hLibMeter=NULL;
00188 static HMODULE hLibSetup=NULL;
00189
00190 static char *szRenderClass="OFX:RenderClass";
00191 static HWND hwndMain=NULL,hwndcontrol=NULL,
00192 hwndupdate=NULL,hwndupdateX=NULL,
00193 hwndmeter1=NULL,hwndmeterframes1=NULL,hwndframe1=NULL,
00194 hwndframeof1=NULL,hwndstatus1=NULL,hwndinfo1=NULL,
00195 hwndframetime1=NULL,hwndestimate1=NULL,
00196 hwndmeter2=NULL,hwndmeterframes2=NULL,hwndframe2=NULL,
00197 hwndframeof2=NULL,hwndstatus2=NULL,hwndinfo2=NULL,
00198 hwndframetime2=NULL,hwndestimate2=NULL,
00199 hwndmeter,hwndmeterframes,hwndframe,
00200 hwndframeof,hwndstatus,hwndinfo,
00201 hwndframetime,hwndestimate,
00202 hwndimage=NULL;
00203 static HINSTANCE hResourceInstance=NULL;
00204 static char *gszWorkDrive=NULL;
00205 static long InModeller=0,RendererInUse=0,
00206 RendererStandAlone=0,RendererAborted=0,
00207 RendererFirstTime=1,RendererRange=0,
00208 RendererNotCancelled=0,
00209 frames=9999,frame_counter=0,current_frame=1,
00210 first_frame=1,last_frame=9999;
00211 static BOOL LoggingFlag=TRUE;
00212 static BOOL ImmediateFlag=FALSE;
00213 static BOOL update_title=FALSE;
00214
00215 static long Nrlist=9,Nplist=6,Naalist=8,Ndilist=3,Ncolist=3,Nthreadlist=17;
00216 static char *rlist[]={
00217 "640 x 480",
00218 "800 x 600",
00219 "1024 x 768",
00220 "1280 x 1024",
00221 "Hi Def TV",
00222 "NSTC Video",
00223 "PAL Video",
00224 "2000 x 1500",
00225 " "
00226 };
00227
00228 static long rxlist[]={640,800,1024,1280,1920,720,720,2000};
00229 static long rylist[]={480,600, 768,1024,1080,480,576,1500};
00230
00231 static char *output_switch[]={
00232 "-b24",
00233 "-ani",
00234 "-j24",
00235 "-p24",
00236 "-t24",
00237 "-b24"
00238 };
00239
00240
00241 static char *aalist[8]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
00242 static char *dilist[3]={NULL,NULL,NULL};
00243
00244
00245 static char *plist[13]={NULL,NULL,NULL,NULL,NULL,NULL,NULL,
00246 NULL,NULL,NULL,NULL,NULL,NULL};
00247
00248 static char *colist[]={
00249 "First in Palette",
00250 "Black",
00251 "White"
00252 };
00253
00254 static char *threadlist[]={
00255 " ",
00256 "1", "2", "3", "4", "5", "6", "7", "8",
00257 "9","10","11","12","13","14","15","16"
00258 };
00259
00260 LRESULT CALLBACK RendererMainWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00261 LPARAM lparam);
00262 void RenderYield(void);
00263 void WindowedRenderMessage(int message);
00264 void WindowedRenderString(char *str);
00265 void WindowedRenderInfo(char *str);
00266 int ConfirmNTabort(void);
00267 int GetRenderNTnewfile(char *name, char *rep_name);
00268
00269 extern HINSTANCE __cdecl ResourceX(void);
00270 extern int render(int argc, char ** argv);
00271 extern HWND SetUpGlWindow(HANDLE, HWND, long, long, BOOL, BOOL, BOOL, long);
00272 extern void LoadParticleImages(void);
00273 extern void UnloadParticleImages(void);
00274 extern void CloseGlWindow(void);
00275
00276 extern long renderer_NT_abort_flag;
00277 extern int Nprocessors,Nthreads;
00278
00279 int ConfirmNTabort(void){
00280 char text_string[512];
00281 char title[64];
00282 if(ImmediateFlag)return 1;
00283 LoadString(hThisInstance,IDX_MISC_CONFIRMSTOP,text_string,sizeof(text_string));
00284 LoadString(hThisInstance,IDX_MISC_CONFIRMSTOP1,title,sizeof(title));
00285 if(MessageBox(hwndMain,text_string,title,
00286 MB_OKCANCEL | MB_ICONSTOP) == IDOK)return 1;
00287 else return 0;
00288 }
00289
00290 void SetTitleBarMessage(long percent, BOOL update){
00291 char text_string[512];
00292 static BOOL restore=FALSE;
00293 if(!update_title)return;
00294 if(percent < 0){
00295 LoadString(hThisInstance,IDX_MISC_WINDOWTITLE,text_string,
00296 sizeof(text_string));
00297 SendMessage(hwndMain,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text_string);
00298 restore=FALSE;
00299 }
00300 else{
00301 if(!IsIconic(hwndMain)){
00302 if(restore){
00303 LoadString(hThisInstance,IDX_MISC_WINDOWTITLE,text_string,
00304 sizeof(text_string));
00305 SendMessage(hwndMain,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text_string);
00306 }
00307 restore=FALSE;
00308 }
00309 else if(update || percent%5 == 0){
00310 sprintf(text_string,"%ld%% Complete",percent);
00311 SendMessage(hwndMain,WM_SETTEXT,0,(LPARAM)(LPCTSTR)text_string);
00312 restore=TRUE;
00313 }
00314 }
00315 return;
00316 }
00317
00318 void WindowedRenderMessage(int message){
00319 char szTitle[256];
00320 if(LoadString(hThisInstance,(UINT)message,szTitle,sizeof(szTitle))
00321 <= 0)return;
00322 SendMessage(hwndstatus,WM_SETTEXT,0,(LPARAM)(LPCTSTR)szTitle);
00323 if(logfile != NULL)fprintf(logfile,"%s\n",szTitle);
00324 }
00325
00326 void WindowedRenderString(char *str){
00327 SendMessage(hwndstatus,WM_SETTEXT,0,(LPARAM)(LPCTSTR)str);
00328 if(logfile != NULL)fprintf(logfile,"%s\n",str);
00329 RenderYield();
00330 }
00331
00332 void WindowedRenderInfo(char *str){
00333 SendMessage(hwndinfo,WM_SETTEXT,0,(LPARAM)(LPCTSTR)str);
00334 if(logfile != NULL)fprintf(logfile,"%s\n",str);
00335 RenderYield();
00336 }
00337
00338 static BOOL CheckRendererStatus(void){
00339 char text_string[512];
00340 if(RendererInUse || RendererStandAlone){
00341 SetForegroundWindow(hwndMain);
00342 BringWindowToTop(hwndMain);
00343 ShowWindow(hwndMain,SW_SHOW);
00344 LoadString(hThisInstance,IDX_MISC_BUSY,text_string,sizeof(text_string));
00345 MessageBox(hwndMain,text_string,NULL,MB_OK|MB_SYSTEMMODAL);
00346 return FALSE;
00347 }
00348 return TRUE;
00349 }
00350
00351 void UpdateNTTrace(long line){
00352 HDC hdc;
00353 RECT rect;
00354 POINT pt[4];
00355 long d;
00356 PostMessage(hwndmeter,MM_SETPARTSCOMPLETE,(WPARAM)line,0);
00357 if(RendererRange == 0)SetTitleBarMessage((line*100)/plp->yres,FALSE);
00358 RenderYield();
00359 return;
00360 }
00361
00362 static void UpdateNTFrameM(long f,long s){
00363 char str[32];
00364 time_t t;
00365 double te;
00366 long tm,ts;
00367 SendMessage(hwndmeterframes,MM_SETPARTSCOMPLETE,(WPARAM)(frame_counter),0);
00368 if(RendererRange == 1){
00369 sprintf(str,"%ld",min(f,last_frame));
00370 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM)str);
00371 f=min(f,last_frame)-first_frame+1;
00372 sprintf(str,"(%ld of %ld)",f,last_frame-first_frame+1);
00373 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)str);
00374 SetTitleBarMessage(((f-first_frame+1)*100)/(last_frame-first_frame),TRUE);
00375 }
00376 else{
00377 sprintf(str,"%ld",current_frame);
00378 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM)str);
00379 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)" ");
00380 }
00381 if(frame_counter > 0 && s == 0){
00382 t=time(NULL);
00383 te=difftime(t,last_frame_start);
00384 if(te < 61.0)sprintf(str,"%lds",(long)te);
00385 else {
00386 tm=(long)te/60; ts=(long)(te-(double)tm*60);
00387 sprintf(str,"%ldm %lds",tm,ts);
00388 }
00389 SendMessage(hwndframetime,WM_SETTEXT,0,(LPARAM)str);
00390 te=difftime(t,start_time);
00391 last_frame_start=t;
00392 te=difftime(t,start_time)*
00393 ((double)(last_frame-first_frame-frame_counter))/
00394 (double)(frame_counter);
00395 t=t+(time_t)te;
00396 SendMessage(hwndestimate,WM_SETTEXT,0,(LPARAM)ctime(&t));
00397 }
00398 if(s == 0)frame_counter++;
00399 RenderYield();
00400 return;
00401 }
00402 static void UpdateNTFrameS(long f,long s){
00403 char str[32];
00404 time_t t;
00405 double te;
00406 long tm,ts;
00407 f=f/2;
00408 SendMessage(hwndmeterframes,MM_SETPARTSCOMPLETE,(WPARAM)(frame_counter/2),0);
00409 if(RendererRange == 1){
00410 sprintf(str,"%ld",min(f,last_frame));
00411 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM)str);
00412 f=min(f,last_frame)-first_frame+1;
00413 sprintf(str,"(%ld of %ld)",f,last_frame-first_frame+1);
00414 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)str);
00415 SetTitleBarMessage(((f-first_frame+1)*100)/(last_frame-first_frame),TRUE);
00416 }
00417 else{
00418 sprintf(str,"%ld",current_frame);
00419 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM)str);
00420 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)" ");
00421 }
00422 if(frame_counter > 0 && s == 0){
00423 t=time(NULL);
00424 te=difftime(t,last_frame_start);
00425 if(te < 61.0)sprintf(str,"%lds",(long)te);
00426 else {
00427 tm=(long)te/60; ts=(long)(te-(double)tm*60);
00428 sprintf(str,"%ldm %lds",tm,ts);
00429 }
00430 SendMessage(hwndframetime,WM_SETTEXT,0,(LPARAM)str);
00431 te=difftime(t,start_time);
00432 last_frame_start=t;
00433 te=difftime(t,start_time)*
00434 ((double)(last_frame-first_frame-frame_counter/2))/
00435 (double)(frame_counter/2);
00436 t=t+(time_t)te;
00437 SendMessage(hwndestimate,WM_SETTEXT,0,(LPARAM)ctime(&t));
00438 }
00439 if(s == 0)frame_counter++;
00440 RenderYield();
00441 return;
00442 }
00443
00444 void UpdateNTFrame(long f,long s){
00445 if(plp->bRenderStereo)UpdateNTFrameS(f,s);
00446 else UpdateNTFrameM(f,s);
00447 }
00448
00449 static PSTR FileInPath(PSTR pstrPath){
00450 PSTR pstr;
00451 pstr = pstrPath + strlen(pstrPath);
00452 while (pstr > pstrPath) {
00453 pstr = (AnsiPrev(pstrPath, pstr));
00454 if (*pstr == '\\' || *pstr == ':' || *pstr == '/') {
00455 pstr = (AnsiNext(pstr));
00456 break;
00457 }
00458 }
00459 return pstr;
00460 }
00461
00462 static void ShrinkWindowTo(HWND hwndf,HWND hwndto){
00463 RECT rc,rcto;
00464 GetWindowRect(hwndf,&rc);
00465 GetWindowRect(hwndto,&rcto);
00466 MoveWindow(hwndf,rc.left,rc.top,
00467 rcto.right-rcto.left,
00468 rcto.bottom-rcto.top+GetSystemMetrics(SM_CYCAPTION),
00469 FALSE);
00470 }
00471
00472 static void WrapWindowTo(HWND hwndf,HWND hwndto){
00473 RECT rc,rcto;
00474 GetWindowRect(hwndf,&rc);
00475 GetWindowRect(hwndto,&rcto);
00476 SetWindowPos(hwndf,NULL,0,0,
00477 rcto.right-rcto.left,
00478 rcto.bottom-rcto.top+GetSystemMetrics(SM_CYCAPTION),
00479 SWP_NOMOVE|SWP_DRAWFRAME|SWP_FRAMECHANGED);
00480 }
00481
00482
00483
00484
00485 static BOOL FirstInstance(HANDLE inst){
00486 WNDCLASS wc;
00487 BOOL rc;
00488 X__MEMORY_MANAGER *lpEVIMM;
00489
00490 lpEVIMM=&EviMemoryManager;
00491 lpEVIMM->lpAni=NULL;
00492 lpEVIMM->lpMod=NULL;
00493 lpEVIMM->fpMalloc=X__AllocateRam;
00494 lpEVIMM->fpFree=X__FreeRam;
00495 wc.style = CS_HREDRAW | CS_VREDRAW | CS_SAVEBITS;
00496 wc.lpfnWndProc = (WNDPROC)RendererMainWndProc;
00497 wc.cbClsExtra = 0;
00498 wc.cbWndExtra = 0;
00499 wc.hInstance = inst;
00500 wc.hIcon = LoadIcon( inst, "SHOWICON");
00501 wc.hCursor = LoadCursor( NULL, IDC_ARROW );
00502 wc.hbrBackground = GetStockObject( WHITE_BRUSH );
00503
00504 wc.lpszMenuName = NULL;
00505 wc.lpszClassName = szRenderClass;
00506 rc = RegisterClass( &wc );
00507 if((hLibSpin=LoadLibrary("spin.dll")) == NULL){
00508 MessageBox (NULL,"Can't find SPIN.DLL","Error",
00509 MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00510 }
00511 if((hLibMeter=LoadLibrary("update.dll")) == NULL){
00512 MessageBox (NULL,"Can't find UPDATE.DLL","Error",
00513 MB_OK|MB_ICONEXCLAMATION|MB_APPLMODAL);
00514 return FALSE;
00515 }
00516 hResourceInstance=inst;
00517 return( rc );
00518 }
00519
00520 static void LoadTextLists(void){
00521 char text_string[512];
00522 long i,ilist[]={
00523 IDX_MISC_GIFStills,
00524 IDX_MISC_Animation,
00525 IDX_MISC_JPEGcompressed,
00526 IDX_MISC_PNGcompressed,
00527 IDX_MISC_TIFFRGB,
00528 IDX_MISC_WindowsBMP
00529 };
00530 LoadString(hThisInstance,IDX_MISC_None,
00531 text_string,sizeof(text_string));
00532 aalist[0]=(char *)X__Malloc(strlen(text_string)*2+1);
00533 if(aalist[0] != NULL)strcpy(aalist[0],text_string);
00534 LoadString(hThisInstance,IDX_MISC_Low,
00535 text_string,sizeof(text_string));
00536 aalist[1]=(char *)X__Malloc(strlen(text_string)*2+1);
00537 if(aalist[1] != NULL)strcpy(aalist[1],text_string);
00538 LoadString(hThisInstance,IDX_MISC_Medium,
00539 text_string,sizeof(text_string));
00540 aalist[2]=(char *)X__Malloc(strlen(text_string)*2+1);
00541 if(aalist[2] != NULL)strcpy(aalist[2],text_string);
00542 LoadString(hThisInstance,IDX_MISC_High,
00543 text_string,sizeof(text_string));
00544 aalist[3]=(char *)X__Malloc(strlen(text_string)*2+1);
00545 if(aalist[3] != NULL)strcpy(aalist[3],text_string);
00546 LoadString(hThisInstance,IDX_MISC_Best,
00547 text_string,sizeof(text_string));
00548 aalist[4]=(char *)X__Malloc(strlen(text_string)*2+1);
00549 if(aalist[4] != NULL)strcpy(aalist[4],text_string);
00550 LoadString(hThisInstance,IDX_MISC_AA_9,
00551 text_string,sizeof(text_string));
00552 aalist[5]=(char *)X__Malloc(strlen(text_string)*2+1);
00553 if(aalist[5] != NULL)strcpy(aalist[5],text_string);
00554 LoadString(hThisInstance,IDX_MISC_AA_12,
00555 text_string,sizeof(text_string));
00556 aalist[6]=(char *)X__Malloc(strlen(text_string)*2+1);
00557 if(aalist[6] != NULL)strcpy(aalist[6],text_string);
00558 LoadString(hThisInstance,IDX_MISC_AA_16,
00559 text_string,sizeof(text_string));
00560 aalist[7]=(char *)X__Malloc(strlen(text_string)*2+1);
00561 if(aalist[7] != NULL)strcpy(aalist[7],text_string);
00562
00563 LoadString(hThisInstance,IDX_MISC_NoneD,
00564 text_string,sizeof(text_string));
00565 dilist[0]=(char *)X__Malloc(strlen(text_string)*2+1);
00566 if(dilist[0] != NULL)strcpy(dilist[0],text_string);
00567 LoadString(hThisInstance,IDX_MISC_FloydSteinberg,
00568 text_string,sizeof(text_string));
00569 dilist[1]=(char *)X__Malloc(strlen(text_string)*2+1);
00570 if(dilist[1] != NULL)strcpy(dilist[1],text_string);
00571 LoadString(hThisInstance,IDX_MISC_Noise,
00572 text_string,sizeof(text_string));
00573 dilist[2]=(char *)X__Malloc(strlen(text_string)*2+1);
00574 if(dilist[2] != NULL)strcpy(dilist[2],text_string);
00575 LoadString(hThisInstance,IDX_MISC_TH_Automatic,
00576 text_string,sizeof(text_string));
00577 strcpy(threadlist[0],text_string);
00578 LoadString(hThisInstance,IDX_MISC_Specified,
00579 text_string,sizeof(text_string));
00580 strcpy(rlist[Nrlist-1],text_string);
00581 for(i=0;i<Nplist;i++){
00582 LoadString(hThisInstance,ilist[i],text_string,sizeof(text_string));
00583 plist[i]=(char *)X__Malloc(strlen(text_string)*2+1);
00584 if(plist[i] != NULL)strcpy(plist[i],text_string);
00585 }
00586 }
00587
00588 static int RendererMainLoop(HINSTANCE hInstance, int wait){
00589 char text_string[512];
00590 MSG msg;
00591 HMENU hmenu;
00592 hThisInstance=hInstance;
00593 plp=&ParamList;
00594 LoadPreferences();
00595
00596 if(plp->u3 == 1){
00597 if(LOBYTE(LOWORD(GetVersion())) < 4){
00598 if(LoadLibrary("dlg3d.dll") == NULL)
00599 MessageBox(NULL,"Dlg3d DLL missing",NULL,MB_OK);
00600 }
00601 }
00602 LoadTextLists();
00603 LoadString(hThisInstance,IDX_MISC_WINDOWTITLE,text_string,sizeof(text_string));
00604 hwndMain=CreateWindow(szRenderClass,
00605 text_string,
00606 WS_OVERLAPPED | WS_VISIBLE | WS_CLIPCHILDREN | WS_CAPTION |
00607 WS_MINIMIZEBOX |
00608 WS_SYSMENU,
00609 0,0,0,0,
00610 NULL,NULL,hInstance,NULL);
00611 if(!hwndMain) return FALSE;
00612 hmenu = GetSystemMenu(hwndMain, FALSE);
00613 RemoveMenu(hmenu, 7, MF_BYPOSITION);
00614 RemoveMenu(hmenu, 5, MF_BYPOSITION);
00615 RemoveMenu(hmenu, SC_RESTORE, MF_BYCOMMAND);
00616 RemoveMenu(hmenu, SC_SIZE, MF_BYCOMMAND);
00617 RemoveMenu(hmenu, SC_MAXIMIZE, MF_BYCOMMAND);
00618 RemoveMenu(hmenu, SC_TASKLIST, MF_BYCOMMAND);
00619 if(RendererStandAlone){
00620 AppendMenu(hmenu,MF_SEPARATOR,0,0);
00621 LoadString(hThisInstance,IDX_MISC_OPENSCRIPT,text_string,sizeof(text_string));
00622 AppendMenu(hmenu,MF_ENABLED | MF_STRING,SYSMENU_SCRIPT,text_string);
00623 }
00624 LoadString(hThisInstance,IDX_MISC_ABOUT,text_string,sizeof(text_string));
00625 AppendMenu(hmenu,MF_ENABLED | MF_STRING,SYSMENU_ABOUT,text_string);
00626 ShowWindow(hwndMain,SW_SHOW);
00627 UpdateWindow(hwndMain);
00628 InitialiseLibraryHandleList();
00629 colorstats0=NULL; colorstats1=NULL;
00630 if((colorstats0 = (unsigned long *)
00631 X__Malloc(NOCOLOUR*(long)sizeof(unsigned long))) == NULL)return FALSE;
00632 if((colorstats1 = (unsigned short *)
00633 X__Malloc(NOCOLOUR*(long)sizeof(unsigned short))) == NULL)return FALSE;
00634 SetFocus(hwndcontrol);
00635 if(RendererStandAlone)PostMessage(hwndMain,WM_COMMAND,MENU_FILE_SCRIPT,0);
00636 while (GetMessage(&msg,NULL,0,0)){
00637 if(!IsWindow(hwndupdate) || !IsDialogMessage(hwndupdate,&msg)){
00638 if(!IsWindow(hwndupdateX) || !IsDialogMessage(hwndupdateX,&msg)){
00639 if(!IsWindow(hwndcontrol) || !IsDialogMessage(hwndcontrol,&msg)){
00640 TranslateMessage(&msg);
00641 DispatchMessage(&msg);
00642 }
00643 }
00644 }
00645 }
00646 if(hWndOpenGL)CloseGlWindow(); hWndOpenGL=NULL;
00647 UnloadParticleImages();
00648 if(colorstats0 != NULL)X__Free(colorstats0); colorstats0=NULL;
00649 if(colorstats1 != NULL)X__Free(colorstats1); colorstats1=NULL;
00650 FreeLibraryHandleList();
00651 DestroyWindow(hwndMain);
00652
00653 UnregisterClass(szRenderClass,hInstance);
00654
00655 if(hLibMeter != NULL)FreeLibrary(hLibMeter);
00656 if(hLibSetup != NULL)FreeLibrary(hLibSetup);
00657 if(hLibSpin != NULL)FreeLibrary(hLibSpin);
00658 if(debug != NULL)fclose(debug); debug=NULL;
00659
00660
00661 return (msg.wParam);
00662 }
00663
00664 LRESULT CALLBACK RendererMainWndProc(HWND hwnd, UINT msg, WPARAM wparam,
00665 LPARAM lparam ){
00666 HWND hwndCaller,hwndTemp;
00667
00668 RECT rc;
00669 char szTitle[60],szTemp[32];
00670 char text_string[512];
00671 switch( msg ){
00672 case WM_ACTIVATE:
00673 if(LOWORD(wparam) != WA_INACTIVE){
00674 if(IsWindowVisible(hwndcontrol))SetFocus(hwndcontrol);
00675 else if(IsWindowVisible(hwndupdate))SetFocus(hwndupdate);
00676 else if(IsWindowVisible(hwndupdateX))SetFocus(hwndupdateX);
00677 }
00678 break;
00679 case WM_CREATE:
00680
00681 hwndcontrol=CreateDialog(hResourceInstance,MAKEINTRESOURCE(DLG_TAB),
00682 hwnd,(DLGPROC)TabbedDlgProc);
00683 hwndupdate=CreateDialog(hResourceInstance,MAKEINTRESOURCE(RD_UPDATE),
00684 hwnd,(DLGPROC)UpdateDlgProc);
00685 hwndupdateX=CreateDialog(hResourceInstance,MAKEINTRESOURCE(RD_UPDATEX),
00686 hwnd,(DLGPROC)UpdateXDlgProc);
00687 if(hwndcontrol == NULL || hwndupdate == NULL || hwndupdateX == NULL)
00688 return -1;
00689 ShrinkWindowTo(hwnd,hwndcontrol);
00690 GetWindowRect(hwnd, &rc);
00691 SetWindowPos(hwnd, NULL,
00692 (GetSystemMetrics(SM_CXSCREEN) - (rc.right - rc.left)) / 2,
00693 (GetSystemMetrics(SM_CYSCREEN) - (rc.bottom - rc.top)) / 2,
00694 0, 0, SWP_NOSIZE | SWP_NOZORDER);
00695
00696 if(!CheckGPUhardware(hwnd))EnableWindow(GetDlgItem(hwndcontrol,RD_CONTROL_RENDERGL),FALSE);
00697 break;
00698 case WM_DESTROY:
00699 if(hwndcontrol != NULL)DestroyWindow(hwndcontrol);
00700 if(hwndupdate != NULL)DestroyWindow(hwndupdate);
00701 if(hwndupdateX != NULL)DestroyWindow(hwndupdateX);
00702 break;
00703 case WM_PAINT: {
00704 HDC hdc;
00705 PAINTSTRUCT ps;
00706 hdc=BeginPaint(hwnd,&ps);
00707 EndPaint(hwnd,&ps);
00708 }
00709 break;
00710 case WM_SYSCOMMAND:
00711 switch(LOWORD(wparam & 0xfff0)){
00712 case SYSMENU_ABOUT:
00713 PostMessage(hwnd,WM_COMMAND,MENU_FILE_ABOUT,0);
00714 break;
00715 case SYSMENU_SCRIPT:
00716 PostMessage(hwnd,WM_COMMAND,MENU_FILE_SCRIPT,0);
00717 break;
00718 case SYSMENU_PREFS:{
00719 DialogBox(hResourceInstance,MAKEINTRESOURCE(DLG_PREFERENCES),hwnd,
00720 (DLGPROC)PreferencesDlgProc);
00721 }
00722 break;
00723 case SYSMENU_PPREFS_LOAD:
00724 if(IsWindow(hwndcontrol))UpdateControlDlg(hwndcontrol,FALSE);
00725 break;
00726 case SYSMENU_PPREFS_SAVE:
00727 break;
00728 case SC_CLOSE:
00729 if(RendererInUse)PostMessage(hwnd,WM_COMMAND,MENU_FILE_ABORT,0);
00730 else PostMessage(hwnd,WM_COMMAND,MENU_FILE_EXIT,0);
00731 break;
00732 default:
00733 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
00734 }
00735 break;
00736 case IDM_CALLBACK_SETUP_ANIMATOR:
00737 if(!CheckRendererStatus())break;
00738 InModeller=0;
00739 frames=HIWORD(lparam); current_frame=LOWORD(lparam);
00740 first_frame=1; last_frame=frames;
00741 SendMessage(hwndcontrol,WM_COMMAND,IDC_FRAMESET,0);
00742 break;
00743 case IDM_CALLBACK_SETUP_MODELLER:
00744 if(!CheckRendererStatus())break;
00745 InModeller=1;
00746 frames=1; current_frame=1; first_frame=1; last_frame=frames;
00747 SendMessage(hwndcontrol,WM_COMMAND,IDC_FRAMESET,0);
00748 break;
00749 case IDM_CALLBACK_HIDDENLINE:
00750 break;
00751 case WM_CALLBACK_MATERIAL:
00752 if(!CheckRendererStatus())break;
00753 ShowWindow(hwnd,SW_HIDE);
00754 ExecuteQuickInlineRenderer(hwnd,(HWND)lparam);
00755 break;
00756 case WM_CALLBACK_ABANDON:
00757 if(RendererInUse && ImmediateFlag){
00758 renderer_NT_abort_flag=1;
00759 }
00760 break;
00761 case WM_COMMAND:
00762 switch( LOWORD(wparam) ) {
00763 case MENU_FILE_SCRIPT: {
00764 char szTitle[80],tempfile[255];
00765 LoadString(hThisInstance,WRM_OPENSCRIPT,szTitle,sizeof(szTitle));
00766 strcpy(tempfile,plp->scr_file);
00767 if(SelectFileName(0,tempfile,plp->scr_dir,szTitle,
00768 "(*.SCR)|*.scr|",hwnd) == TRUE){
00769 strcpy(plp->scr_file,FileInPath(tempfile));
00770 sprintf(tempfile,"Renderer (%s)",plp->scr_file);
00771 SendMessage(hwnd,WM_SETTEXT,0,(LPARAM)tempfile);
00772 GetNumberOfScriptFrames();
00773 RendererFirstTime=0;
00774 SendMessage(hwndcontrol,WM_COMMAND,IDC_FRAMESET,0);
00775 }
00776 if(RendererFirstTime)PostMessage(hwnd,WM_COMMAND,MENU_FILE_EXIT,0);
00777 }
00778 break;
00779 case IDM_CALLBACK_RUN:
00780 if(!CheckRendererStatus())break;
00781 if(lparam < 1 || lparam > frames || plp->ot == 1){
00782 MessageBox(hwnd,"Renderer settings must be adjusted",
00783 "Warning",MB_ICONSTOP);
00784 break;
00785 }
00786 RendererRange=0;
00787 current_frame=lparam;
00788 case MENU_FILE_START:
00789 LoadParticleImages();
00790 if(plp->bUseOpenGLrender==TRUE){
00791 long aa_samples[8]={0,2,4,6,8,9,12,16};
00792 hWndOpenGL=SetUpGlWindow(hThisInstance,hwndMain,plp->xres,plp->yres,
00793 (BOOL)plp->bDrawDirectly,(BOOL)plp->bUseFBO,
00794 (BOOL)plp->bCopyGLdepth,aa_samples[plp->aa]);
00795 }
00796 EnableWindow(hwndcontrol,FALSE);
00797 ShowWindow(hwndcontrol,SW_HIDE);
00798 if(plp->callback == 1 && hWndOpenGL == NULL){
00799 if(!InitiateRendererUpdateView(hwndupdateX))plp->callback=0;
00800 }
00801 if(plp->callback == 1 && hWndOpenGL == NULL){
00802 hwndTemp=hwndupdateX;
00803 hwndmeter=hwndmeter2;
00804 hwndmeterframes=hwndmeterframes2;
00805 hwndframe=hwndframe2;
00806 hwndframeof=hwndframeof2;
00807 hwndstatus=hwndstatus2;
00808 hwndframetime=hwndframetime2;
00809 hwndestimate=hwndestimate2;
00810 hwndinfo=hwndinfo2;
00811 }
00812 else{
00813 hwndTemp=hwndupdate;
00814 hwndmeter=hwndmeter1;
00815 hwndmeterframes=hwndmeterframes1;
00816 hwndframe=hwndframe1;
00817 hwndframeof=hwndframeof1;
00818 hwndstatus=hwndstatus1;
00819 hwndframetime=hwndframetime1;
00820 hwndestimate=hwndestimate1;
00821 hwndinfo=hwndinfo1;
00822 }
00823 WrapWindowTo(hwnd,hwndTemp);
00824 LoadString(hThisInstance,IDX_MISC_STOP,
00825 text_string,sizeof(text_string));
00826 SendMessage(GetDlgItem(hwndTemp,RD_UPDATE_STOP),
00827 WM_SETTEXT,0,(LPARAM)text_string);
00828 ShowWindow(hwndTemp,SW_SHOW);
00829 EnableWindow(hwndTemp,TRUE);
00830 SetFocus(hwndTemp);
00831 SendMessage(hwndmeter,MM_SETPARTSCOMPLETE,0,0);
00832 SendMessage(hwndmeterframes,MM_SETPARTSCOMPLETE,0,0);
00833 SendMessage(hwndframetime,WM_SETTEXT,0,(LPARAM)"<NA>");
00834 SendMessage(hwndestimate,WM_SETTEXT,0,(LPARAM)"<NA>");
00835 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM) " ");
00836 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)" ");
00837 if(RendererStandAlone){
00838 PostMessage(hwnd,WM_COMMAND,MENU_FILE_RENDER,0);
00839 }
00840 else{
00841 if(RendererRange){
00842 WindowedRenderMessage(WRM_WRITINGSCRIPT);
00843 PostMessage(hwnd,WM_COMMAND,MENU_FILE_RENDERN,0);
00844 }
00845 else PostMessage(hwnd,WM_COMMAND,MENU_FILE_RENDER1,0);
00846 }
00847 break;
00848 case MENU_FILE_STOP:
00849 RendererNotCancelled=0;
00850 if(plp->callback == 1 && !plp->bUseOpenGLrender)hwndTemp=hwndupdateX;
00851 else hwndTemp=hwndupdate;
00852 EnableWindow(hwndTemp,FALSE);
00853 ShowWindow(hwndTemp,SW_HIDE);
00854 if(plp->callback && !plp->bUseOpenGLrender)TerminateRendererUpdateView();
00855 plp->bUseOpenGLrender=FALSE;
00856 WrapWindowTo(hwnd,hwndcontrol);
00857 ShowWindow(hwndcontrol,SW_SHOW);
00858 EnableWindow(hwndcontrol,TRUE);
00859 SetFocus(hwndcontrol);
00860 if(!RendererStandAlone && !RendererAborted)
00861 SendMessage(hwnd,WM_COMMAND,MENU_FILE_EXIT,0);
00862 RendererAborted=0;
00863 break;
00864 case MENU_FILE_RENDER: {
00865 char *args[50],*filter;
00866 int i,argc=3,ff,lf,failed;
00867 if(RendererInUse)break;
00868 RendererInUse=1;
00869 logfile=NULL;
00870 if(plp->logfile){
00871 char lgg[256];
00872 strcpy(lgg,gszHomeDir);
00873 strcat(lgg,"render.log");
00874 logfile=fopen(lgg,"w");
00875 }
00876 frame_counter=0;
00877 SendMessage(hwndmeter,MM_SETPARTSCOMPLETE,0,0);
00878 SendMessage(hwndmeter,MM_SETPARTSINJOB,(WPARAM)plp->yres,0);
00879 for(i=0;i<3;i++)args[i]=(char *)X__Malloc(256);
00880 for(i=3;i<50;i++)args[i]=(char *)X__Malloc(10);
00881 strcpy(args[1],plp->scr_dir);
00882 strcat(args[1],"\\");
00883 strcat(args[1],plp->scr_file);
00884 *strrchr(args[1],'.')='\0';
00885 strcpy(args[2],plp->pic_dir);
00886 i=strlen(plp->pic_dir);
00887 if(*(plp->pic_dir+i-1) != '\\')strcat(args[2],"\\");
00888 strcat(args[2],plp->pic_file);
00889 strcpy(args[argc++],"-x");
00890 sprintf(args[argc++],"%ld",plp->xres);
00891 strcpy(args[argc++],"-y");
00892 sprintf(args[argc++],"%ld",plp->yres);
00893 ff=first_frame; lf=last_frame;
00894 if(ff > 1){
00895 strcpy(args[argc++],"-ff");
00896 sprintf(args[argc++],"%ld",ff);
00897 }
00898 if(lf > 0 && lf < frames){
00899 strcpy(args[argc++],"-lf");
00900 sprintf(args[argc++],"%ld",lf);
00901 }
00902 SendMessage(hwndmeterframes,MM_SETPARTSCOMPLETE,0,0);
00903 SendMessage(hwndmeterframes,MM_SETPARTSINJOB,(WPARAM)(lf-ff+1),0);
00904 if(plp->ot == 1){
00905 strcpy(args[argc++],"-an2");
00906 }
00907 else if(plp->ot > 1){
00908 strcpy(args[argc++],output_switch[plp->ot]);
00909 if(plp->ot == 2){
00910 sprintf(args[argc++],"%ld",plp->jpeg_quality);
00911 }
00912 }
00913 if(plp->aa == 1)strcpy(args[argc++],"-a");
00914 if(plp->aa == 2)strcpy(args[argc++],"-aa");
00915 if(plp->aa == 3)strcpy(args[argc++],"-aaa");
00916 if(plp->aa >= 4)strcpy(args[argc++],"-aaaa");
00917 if(plp->bRenderStereo > 0)strcpy(args[argc++],"-sto");
00918 if(plp->ae && plp->aa < 5)strcpy(args[argc++],"-ae");
00919
00920 if(plp->swgp) strcpy(args[argc++],"-h");
00921 if(plp->sd != 50){
00922 strcpy(args[argc++],"-sd");
00923 sprintf(args[argc++],"%ld",plp->sd);
00924 }
00925 if(plp->al != 10){
00926 strcpy(args[argc++],"-al");
00927 sprintf(args[argc++],"%ld",plp->al);
00928 }
00929 if(plp->sb != 300){
00930 strcpy(args[argc++],"-sb");
00931 sprintf(args[argc++],"%ld",plp->sb);
00932 }
00933 if(plp->sc != 89){
00934 strcpy(args[argc++],"-sc");
00935 sprintf(args[argc++],"%ld",plp->sc);
00936 }
00937 if(plp->ntsc_colours)strcpy(args[argc++],"-ntsc");
00938 if(plp->full_mirror)strcpy(args[argc++],"-fm");
00939 if(plp->blur > 0){
00940 strcpy(args[argc++],"-blr");
00941 sprintf(args[argc++],"%ld",plp->blur);
00942 }
00943 if(plp->ob > 0)strcpy(args[argc++],"-ob");
00944 if(plp->callback && hWndOpenGL == NULL)strcpy(args[argc++],"-cbk");
00945 if(plp->tzeros != 4){
00946 strcpy(args[argc++],"-tz");
00947 sprintf(args[argc++],"%ld",plp->tzeros);
00948 }
00949 if(plp->interlace_gif != 0)strcpy(args[argc++],"-lce");
00950 #if TRACER
00951 if(plp->trace_shadows)strcpy(args[argc++],"-trs");
00952 if(plp->trace_reflections)strcpy(args[argc++],"-trr");
00953 if(plp->trace_refractions)strcpy(args[argc++],"-trg");
00954 if(!plp->trace_partition)strcpy(args[argc++],"-to");
00955 if(plp->trace_depth != 0){
00956 strcpy(args[argc++],"-tod");
00957 sprintf(args[argc++],"%ld",plp->trace_depth);
00958 }
00959 if(plp->trace_face_count_target != 0){
00960 strcpy(args[argc++],"-tot");
00961 sprintf(args[argc++],"%ld",plp->trace_face_count_target);
00962 }
00963 if(plp->trace_voxel_min_size != 0){
00964 strcpy(args[argc++],"-tos");
00965 sprintf(args[argc++],"%ld",plp->trace_voxel_min_size);
00966 }
00967 #endif
00968 renderer_NT_abort_flag=0; RendererAborted=0;
00969 update_title=TRUE;
00970 SetTitleBarMessage(0,TRUE);
00971 WindowedRenderMessage(WRM_LOADING);
00972 start_time=last_frame_start=time(NULL);
00973 failed=render(argc,args);
00974 SetTitleBarMessage(-1,TRUE);
00975 update_title=FALSE;
00976 if(hWndOpenGL != NULL){
00977 DestroyWindow(hWndOpenGL);
00978 CloseGlWindow(); hWndOpenGL=NULL;
00979 }
00980 UnloadParticleImages();
00981 if(!renderer_NT_abort_flag){
00982 if(plp->beep_after){
00983 for(i=0;i<1;i++){
00984 MessageBeep(MB_ICONEXCLAMATION);
00985 if(i<2)Sleep(200);
00986 }
00987 }
00988 SendMessage(hwndmeter,MM_SETPARTSCOMPLETE,plp->yres,0);
00989 SendMessage(hwndmeterframes,MM_SETPARTSCOMPLETE,(WPARAM)(lf-ff+1),0);
00990 SendMessage(hwndframe,WM_SETTEXT,0,(LPARAM) " ");
00991 SendMessage(hwndframeof,WM_SETTEXT,0,(LPARAM)" ");
00992 if(failed != -1){
00993 if(plp->ot == 1){
00994 int rval;
00995 rval=BuildAnimation(args[2],plp->avi_fli,plp->avi_low, plp->avi_compress);
00996 LoadString(hThisInstance,IDX_MISC_BUILDFINISHED,
00997 text_string,sizeof(text_string));
00998 WindowedRenderString(text_string);
00999 if(rval == 1 && plp->autoplay)PlayAnimation(args[2],plp->avi_fli);
01000 }
01001 if((!plp->callback || plp->autoshow) &&
01002 RendererRange == 0 && (plp->ot == 0 ||
01003 plp->ot == 2 ||
01004 plp->ot == 3 ||
01005 plp->ot == 4 ||
01006 plp->ot == 5)){
01007 if(hWndOpenGL == NULL)DisplayOutputFile();
01008 }
01009 }
01010 }
01011 else{
01012 LoadString(hThisInstance,IDX_MISC_PRETERMINATED,
01013 text_string,sizeof(text_string));
01014 WindowedRenderString(text_string);
01015 }
01016 renderer_NT_abort_flag=0;
01017 for(i=0;i<50;i++)X__Free(args[i]);
01018 RendererInUse=0;
01019 if(logfile != NULL){
01020 fclose(logfile);
01021 logfile=NULL;
01022 }
01023 if(plp->callback == 1 && hWndOpenGL == NULL)hwndTemp=hwndupdateX;
01024 else hwndTemp=hwndupdate;
01025 LoadString(hThisInstance,IDX_MISC_CLOSE,
01026 text_string,sizeof(text_string));
01027 SendMessage(GetDlgItem(hwndTemp,RD_UPDATE_STOP),
01028 WM_SETTEXT,0,(LPARAM)text_string);
01029 RendererNotCancelled=1;
01030 }
01031 break;
01032 case MENU_FILE_ABORT:
01033 renderer_NT_abort_flag=1; RendererAborted=1;
01034 break;
01035 case IDM_CALLBACK_SETUP_PREVIEW:
01036 break;
01037 case MENU_FILE_EXIT:
01038 if(RendererStandAlone){
01039 HWND hWndPrev;
01040 hWndPrev = FindWindow("OFX:ViewClass",NULL);
01041 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,106,0);
01042 PostQuitMessage(0L);
01043 }
01044 else{
01045 HWND lastW;
01046 ShowWindow(hwnd,SW_HIDE);
01047 if(InModeller)lastW = FindWindow("OFX:ModelerClass",NULL);
01048 else lastW = FindWindow("OFX:AnimatorClass",NULL);
01049 if(IsWindow(lastW)){
01050 SetForegroundWindow(lastW);
01051 BringWindowToTop(lastW);
01052 ShowWindow(lastW,SW_SHOW);
01053 }
01054 }
01055 break;
01056 case MENU_FILE_ABOUT:
01057 LoadString(hThisInstance,IDX_MISC_ABOUTRENDERERBIG,
01058 text_string,sizeof(text_string));
01059 MessageBox(hwnd,ABOUT_VERSION,text_string,MB_OK);
01060 break;
01061 case IDM_CALLBACK_SHUTDOWN:
01062
01063
01064
01065
01066 PostQuitMessage(0L);
01067 break;
01068 case MENU_FILE_RENDER1:
01069 if(!CheckRendererStatus())break;
01070 if(InModeller){
01071 strcpy(plp->scr_dir,gszWorkDrive);
01072 if(strrchr(plp->scr_dir,'\\') != NULL)
01073 *strrchr(plp->scr_dir,'\\')='\0';
01074 strcpy(plp->scr_file,"w_$.scr");
01075 SendMessage(hwnd,WM_COMMAND,MENU_FILE_RENDER,0);
01076 }
01077 else{
01078 hwndCaller=FindWindow("OFX:AnimatorClass",NULL);
01079 if(IsWindow(hwndCaller))SendMessage(hwndCaller,WM_COMMAND,
01080 IDM_CALLBACK_FSCRIPT,(LPARAM)current_frame);
01081 }
01082 break;
01083 case MENU_FILE_RENDERN:
01084 if(!CheckRendererStatus())break;
01085 if(InModeller)break;
01086 hwndCaller=FindWindow("OFX:AnimatorClass",NULL);
01087 if(IsWindow(hwndCaller))SendMessage(hwndCaller,WM_COMMAND,
01088 IDM_CALLBACK_ASCRIPT,0);
01089 break;
01090 case IDM_CALLBACK_SETUP:
01091 if(gszWorkDrive != NULL){
01092 strcpy(plp->scr_dir,gszWorkDrive);
01093 if(strrchr(plp->scr_dir,'\\') != NULL)
01094 *strrchr(plp->scr_dir,'\\')='\0';
01095 strcpy(plp->scr_file,"w_$.scr");
01096 PostMessage(hwnd,WM_COMMAND,MENU_FILE_RENDER,0);
01097 }
01098 break;
01099 case IDM_CALLBACK_CANCEL:
01100 LoadString(hThisInstance,IDX_MISC_SETUPERROR,
01101 text_string,sizeof(text_string));
01102 MessageBox(hwnd,text_string,NULL,MB_OK);
01103 break;
01104 default: break;
01105 }
01106 break;
01107 default:
01108 return( DefWindowProc( hwnd, msg, wparam, lparam ) );
01109 }
01110 return( 0L );
01111 }
01112
01113 void RenderYield(void){
01114 MSG msg;
01115 while (PeekMessage(&msg, NULL, 0, 0,PM_REMOVE)){
01116 TranslateMessage(&msg);
01117 DispatchMessage(&msg);
01118 }
01119 }
01120
01121 CRITICAL_SECTION g_CriticalSection;
01122
01123 extern char IniFilename[];
01124
01125
01126 #define FAIL 0
01127 #define OK 1
01128 #ifdef RENDERER_DLL
01129 #define BITMAPSIZE 320
01130 #else
01131 #define BITMAPSIZE 320
01132 #endif
01133 #define PALVERSION 0x300
01134
01135 static void PaintRendererUpdateView(HDC, RECT);
01136
01137 static int RendererUpdateCount=0;
01138 static HDRAWDIB hDrawDib = NULL;
01139 static long BitmapSizeX,BitmapSizeY;
01140 static LPSTR lpBitmapBits=NULL,lpBitmapHeader=NULL,lpBits;
01141 static char gszDLLfile[MAX_FILE],gszDLLdir[MAX_DIR];
01142 static BOOL StretchImage=FALSE;
01143
01144
01145 static void CentreDialogOnCursor(HWND hwnd){
01146 RECT rcDlg;
01147 POINT p;
01148 int xres,yres;
01149 yres=GetSystemMetrics(SM_CYSCREEN);
01150 xres=GetSystemMetrics(SM_CXSCREEN);
01151 GetCursorPos(&p);
01152 GetWindowRect(hwnd,&rcDlg);
01153 OffsetRect(&rcDlg,-rcDlg.left,-rcDlg.top);
01154 OffsetRect(&rcDlg,p.x-rcDlg.right/2,p.y-rcDlg.bottom/2);
01155 if(rcDlg.left < 0)OffsetRect(&rcDlg,-rcDlg.left,0);
01156 if(rcDlg.top < 0)OffsetRect(&rcDlg,0,-rcDlg.top);
01157 if(rcDlg.right > xres)OffsetRect(&rcDlg,xres-rcDlg.right,0);
01158 if(rcDlg.bottom > yres)OffsetRect(&rcDlg,0,yres-rcDlg.bottom);
01159 SetWindowPos(hwnd,HWND_TOP,rcDlg.left,rcDlg.top,0,0,SWP_NOSIZE);
01160 return;
01161 }
01162
01163
01164 static HWND hwndAnimatorViewWindow=NULL;
01165
01166 static void ExecuteQuickInlineRenderer(HWND hwnd, HWND hwndView){
01167 if(IsWindow(hwndView)){
01168 HDC hDC;
01169 HCURSOR hSave;
01170 char *argu[10];
01171 int i,narg=10;
01172 RECT rc;
01173 HWND hwndimageSave;
01174 BOOL LoggingFlagSave;
01175 long xresSave,yresSave;
01176 hwndimageSave=hwndimage;
01177 hwndimage=hwndView;
01178 LoggingFlagSave=LoggingFlag;
01179 LoggingFlag=FALSE;
01180 xresSave=plp->xres;
01181 yresSave=plp->yres;
01182 GetClientRect(hwndView,&rc);
01183 plp->xres=rc.right;
01184 plp->yres=rc.bottom;
01185 if(InitiateRendererUpdateView(hwnd)){
01186 RendererInUse=1;
01187 ImmediateFlag=TRUE;
01188 hwndAnimatorViewWindow=hwndView;
01189 for(i=0;i<3;i++)argu[i]=(char *)X__Malloc(128);
01190 for(i=3;i<narg;i++)argu[i]=(char *)X__Malloc(8);
01191 sprintf(argu[0],"??");
01192 sprintf(argu[1],"%sw_$",gszWorkDrive);
01193 sprintf(argu[2],"%sw_$",gszWorkDrive);
01194 strcpy(argu[3],"-x"); sprintf(argu[4],"%ld",rc.right);
01195 strcpy(argu[5],"-y"); sprintf(argu[6],"%ld",rc.bottom);
01196 strcpy(argu[7],"-cbk");
01197 strcpy(argu[8],"-q");
01198 strcpy(argu[9],"-ac");
01199 hSave=SetCursor(LoadCursor(NULL,IDC_WAIT));
01200 renderer_NT_abort_flag=0;
01201 render(narg,argu);
01202 renderer_NT_abort_flag=0;
01203 hDC=GetDC(hwndAnimatorViewWindow);
01204 PaintRendererUpdateView(hDC,rc);
01205 ReleaseDC(hwndAnimatorViewWindow,hDC);
01206 SetCursor(hSave);
01207 for(i=0;i<narg;i++)X__Free(argu[i]);
01208 ImmediateFlag=FALSE;
01209 RendererInUse=0;
01210 TerminateRendererUpdateView();
01211 }
01212 hwndimage=hwndimageSave;
01213 LoggingFlag=LoggingFlagSave;
01214 plp->xres=xresSave;
01215 plp->yres=yresSave;
01216 hwndAnimatorViewWindow=NULL;
01217 }
01218 return;
01219 }
01220
01221
01222
01223
01224 static void LoadPreferences(void){
01225 char pref_id[32];
01226 char defd[256];
01227
01228
01229
01230 GetPrivateProfileString("RPREFERENCES","ACCELAA","$$$",
01231 pref_id,sizeof(pref_id),IniFilename);
01232 if(strncmp(pref_id,"NO",2) == 0){
01233 ParamList.ae=0;
01234 }
01235 GetPrivateProfileString("RPREFERENCES","DIALOGS3D","$$$",
01236 pref_id,sizeof(pref_id),IniFilename);
01237 if(strncmp(pref_id,"NO",2) == 0){
01238 ParamList.u3=0;
01239 }
01240 GetPrivateProfileString("RPREFERENCES","LOGFILE","$$$",
01241 pref_id,sizeof(pref_id),IniFilename);
01242 if(strncmp(pref_id,"YES",3) == 0){
01243 ParamList.logfile=1;
01244 }
01245 GetPrivateProfileString("RPREFERENCES","PREVIEW","$$$",
01246 pref_id,sizeof(pref_id),IniFilename);
01247 if(strncmp(pref_id,"NO",2) == 0){
01248 ParamList.callback=0;
01249 }
01250 GetPrivateProfileString("RPREFERENCES","AUTOSHOW","$$$",
01251 pref_id,sizeof(pref_id),IniFilename);
01252 if(strncmp(pref_id,"NO",2) == 0){
01253 ParamList.autoshow=0;
01254 }
01255 GetPrivateProfileString("RPREFERENCES","AUTOPLAY","$$$",
01256 pref_id,sizeof(pref_id),IniFilename);
01257 if(strncmp(pref_id,"NO",2) == 0){
01258 ParamList.autoplay=0;
01259 }
01260
01261 GetModuleFileName(hThisInstance,gszHomeDir,MAX_DIR);
01262 *FileInPath(gszHomeDir) = '\0';
01263 strcpy(plp->pic_file,"temp");
01264 GetPrivateProfileString("RPREFERENCES","PICDIR","$$$",
01265 defd,sizeof(defd),IniFilename);
01266 if(strncmp(defd,"$$$",3) == 0){
01267
01268 strcpy(plp->pic_dir,TempPath); plp->pic_dir[strlen(plp->pic_dir)-1] = '\0';
01269 }
01270 else strcpy(plp->pic_dir,defd);
01271 strcpy(plp->fli_file,"unnamed");
01272 GetPrivateProfileString("RPREFERENCES","FLIDIR","$$$",
01273 defd,sizeof(defd),IniFilename);
01274 if(strncmp(defd,"$$$",3) == 0){
01275 strcpy(plp->fli_dir,TempPath); plp->fli_dir[strlen(plp->fli_dir)-1] = '\0';
01276 }
01277 else strcpy(plp->fli_dir,defd);
01278 strcpy(plp->scr_file,"*.scr");
01279 strcpy(plp->scr_dir,gszHomeDir); strcat(plp->scr_dir,"scripts");
01280 plp->tmp_file[0]='\0';
01281 strcpy(plp->tmp_dir,gszHomeDir); strcat(plp->tmp_dir,"objects");
01282 gszWorkDrive=&TempPath[0];
01283 GetPrivateProfileString("RPREFERENCES","PERSONAL","$$$",
01284 pref_id,sizeof(pref_id),IniFilename);
01285 if(strncmp(pref_id,"YES",3) == 0){; }
01286 else plp->personal=FALSE;
01287 Nthreads=GetPrivateProfileInt("RPREFERENCES","THREADS",0,IniFilename);
01288 plp->Nthreads=Nthreads;
01289 GetPrivateProfileString("RPREFERENCES","TZERO_STILL","$$$",
01290 pref_id,sizeof(pref_id),IniFilename);
01291 if(strncmp(pref_id,"YES",3) == 0)plp->tzero_still=1;
01292 else plp->tzero_still=0;
01293 GetPrivateProfileString("RPREFERENCES","BEEP_AFTER","$$$",
01294 pref_id,sizeof(pref_id),IniFilename);
01295 if(strncmp(pref_id,"YES",3) == 0)plp->beep_after=1;
01296 else plp->beep_after=0;
01297 return;
01298 }
01299
01300 static long GetCharListID(char *item, char **list, long n){
01301 long i;
01302 for(i=0;i<n;i++){
01303 if(strcmp(item,list[i]) == 0)return i;
01304 }
01305 return -1;
01306 }
01307
01308 static BOOL ValidFileName(char *name){
01309 int i,l;
01310 char c;
01311
01312 if((l=strlen(name)) > 256 || l < 1)return FALSE;
01313 for(i=0;i<l;i++){
01314 c = *(name+i);
01315 if(c == '.' || c == '\\' || c == ':')return FALSE;
01316 else if(c == '-' || c == '_'){;}
01317 else if( c < 48 || (c > 57 && c < 65) || (c > 90 && c < 97) || c > 123)
01318 return FALSE;
01319 }
01320 return TRUE;
01321 }
01322
01323 static char compressed_path[256];
01324
01325 static char *CompressPath(char *name, int n){
01326 char *lp;
01327 int i,l;
01328 if((l=strlen(name)) == 0)return name;
01329 if(strlen(name) > n){
01330 strnset(compressed_path,'\0',255);
01331 strncpy(compressed_path,name,3);
01332 strcat(compressed_path,"...");
01333 lp=strrchr(name,'\\');
01334 if(lp != NULL)strcat(compressed_path,lp);
01335 }
01336 else strcpy(compressed_path,name);
01337 AnsiLower(compressed_path);
01338 return compressed_path;
01339 }
01340
01341 static void EnableAnimSettings(HWND hdlg, BOOL f, int h, BOOL ff, int hh){
01342 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_LAST),f);
01343 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FIRST),f);
01344 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME),f);
01345 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME),f);
01346 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME_SPIN),f);
01347 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME_SPIN),f);
01348 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME_SPIN),h);
01349 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME_SPIN),h);
01350 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME),ff);
01351 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME_SPIN),ff);
01352 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME_SPIN),hh);
01353 }
01354
01355 static void UpdateControlDlg(HWND hdlg,BOOL ini){
01356 int i,v;
01357 HWND hctl;
01358 SetDlgItemInt(hdlg,RD_X_SIZE,(UINT)plp->xres,FALSE);
01359 SetDlgItemInt(hdlg,RD_Y_SIZE,(UINT)plp->yres,FALSE);
01360 SendDlgItemMessage(hdlg,RD_X_SIZE_SPIN,
01361 SPNM_SETRANGE,0,MAKELPARAM(1,10000));
01362 SendDlgItemMessage(hdlg,RD_X_SIZE_SPIN,
01363 SPNM_SETCRNTVALUE,(WPARAM)plp->xres,0);
01364 SendDlgItemMessage(hdlg,RD_X_SIZE_SPIN,SPNM_SETEDITCTRL,0,
01365 (LPARAM)GetDlgItem(hdlg,RD_X_SIZE));
01366 SendDlgItemMessage(hdlg,RD_Y_SIZE_SPIN,
01367 SPNM_SETRANGE,0,MAKELPARAM(1,10000));
01368 SendDlgItemMessage(hdlg,RD_Y_SIZE_SPIN,
01369 SPNM_SETCRNTVALUE,(WPARAM)plp->yres,0);
01370 SendDlgItemMessage(hdlg,RD_Y_SIZE_SPIN,SPNM_SETEDITCTRL,0,
01371 (LPARAM)GetDlgItem(hdlg,RD_Y_SIZE));
01372 hctl=GetDlgItem(hdlg,RD_FILE);
01373 SendMessage(hctl,CB_RESETCONTENT,0,0);
01374 for(i=0;i<Nplist;i++)
01375 SendMessage(hctl,CB_ADDSTRING,0,(LPARAM)plist[i]);
01376 SendMessage(hctl,CB_SELECTSTRING,0,(LPARAM)plist[plp->ot]);
01377 hctl=GetDlgItem(hdlg,RD_RESOLUTION);
01378 SendMessage(hctl,CB_RESETCONTENT,0,0);
01379 for(i=0;i<Nrlist;i++)
01380 SendMessage(hctl,CB_ADDSTRING,0,(LPARAM)rlist[i]);
01381 SendMessage(hctl,CB_SELECTSTRING,0,(LPARAM)rlist[plp->re]);
01382 hctl=GetDlgItem(hdlg,RD_AA);
01383 SendMessage(hctl,CB_RESETCONTENT,0,0);
01384 for(i=0;i<Naalist;i++)
01385 SendMessage(hctl,CB_ADDSTRING,0,(LPARAM)aalist[i]);
01386 SendMessage(hctl,CB_SELECTSTRING,0,(LPARAM)aalist[plp->aa]);
01387 SendDlgItemMessage(hdlg,RD_CONTROL_ONEFRAME,BM_SETCHECK,TRUE,0);
01388 SetDlgItemText(hdlg,RD_CONTROL_STILLFILEDIR,
01389 CompressPath(plp->pic_dir,18));
01390 SetDlgItemText(hdlg,RD_CONTROL_STILLFILENAME,plp->pic_file);
01391 SetDlgItemText(hdlg,RD_CONTROL_ANIMFILEDIR,
01392 CompressPath(plp->fli_dir,18));
01393 SetDlgItemText(hdlg,RD_CONTROL_ANIMFILENAME, plp->fli_file);
01394 if(!ini)return;
01395 if(plp->avi_fli == 1)
01396 SendDlgItemMessage(hdlg,RD_CONTROL_AVI,BM_SETCHECK,TRUE,0);
01397 else SendDlgItemMessage(hdlg,RD_CONTROL_FLI,BM_SETCHECK,TRUE,0);
01398 if(plp->avi_compress == 1)
01399 SendDlgItemMessage(hdlg,RD_CONTROL_COMPRESS,BM_SETCHECK,TRUE,0);
01400 if((GetVersion() & 0x80000000) == 0x80000000){
01401 if(LOBYTE(LOWORD(GetVersion())) < 4){
01402 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_AVI),FALSE);
01403 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_AVI),SW_HIDE);
01404 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FLI),FALSE);
01405 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_FLI),SW_HIDE);
01406 }
01407 }
01408 if(plp->ae)v=1; else v=0;
01409 SendDlgItemMessage(hdlg,RD_ACCELERATED_AA,BM_SETCHECK,v,0);
01410 if(plp->bRenderStereo > 0)v=1; else v=0;
01411 SendDlgItemMessage(hdlg,RD_CONTROL_STEREO,BM_SETCHECK,0,0);
01412 if(plp->constrain)v=1; else v=0;
01413 SendDlgItemMessage(hdlg,RD_CONTROL_CONSTRAIN,BM_SETCHECK,v,0);
01414 return;
01415 }
01416
01417 static BOOL CALLBACK UpdateDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
01418 LPARAM lparam ){
01419 switch( msg ){
01420 case WM_INITDIALOG:
01421 hwndmeter1=GetDlgItem(hdlg,RD_UPDATE_FRAME);
01422 hwndmeterframes1=GetDlgItem(hdlg,RD_UPDATE_FRAMES);
01423 hwndframe1=GetDlgItem(hdlg,RD_UPDATE_FF);
01424 hwndframeof1=GetDlgItem(hdlg,RD_UPDATE_LF);
01425 hwndstatus1=GetDlgItem(hdlg,RD_UPDATE_STATUS);
01426 hwndframetime1=GetDlgItem(hdlg,RD_UPDATE_LFT);
01427 hwndestimate1=GetDlgItem(hdlg,RD_UPDATE_ETA);
01428 hwndinfo1=GetDlgItem(hdlg,RD_UPDATE_INFO);
01429 SendMessage(hwndmeter1,MM_SETPARTSINJOB, 0, 0);
01430 SendMessage(hwndmeter1,MM_SETPARTSCOMPLETE, 0, 0);
01431 SendMessage(hwndmeterframes1,MM_SETPARTSINJOB, 0, 0);
01432 SendMessage(hwndmeterframes1,MM_SETPARTSCOMPLETE, 0, 0);
01433 return( TRUE );
01434 case WM_COMMAND:
01435 switch( LOWORD(wparam) ){
01436 case IDCANCEL:
01437 case RD_UPDATE_STOP:
01438 if(RendererInUse)PostMessage(hwndMain,WM_COMMAND,MENU_FILE_ABORT,0);
01439 else PostMessage(hwndMain,WM_COMMAND,MENU_FILE_STOP,0);
01440 break;
01441 default:
01442 break;
01443 }
01444 break;
01445 default: break;
01446 }
01447 return( FALSE );
01448 }
01449
01450 static BOOL InitiateRendererUpdateView(HWND hwnd){
01451 long imagesize;
01452 int i;
01453 RECT rc;
01454 LPBITMAPINFOHEADER lpbi;
01455 ImmediateFlag=FALSE;
01456 lpBitmapHeader = (LPSTR)X__Malloc((long)sizeof(BITMAPINFOHEADER));
01457 if(lpBitmapHeader == NULL){
01458 return FALSE;
01459 }
01460 RendererUpdateCount=0;
01461 GetClientRect(hwndimage,&rc);
01462 BitmapSizeX=min(plp->xres,rc.right);
01463 BitmapSizeX=((BitmapSizeX+3)/4*4);
01464 BitmapSizeY=min(plp->yres,rc.bottom);
01465 lpbi=(LPBITMAPINFOHEADER)lpBitmapHeader;
01466 lpbi->biSize=sizeof(BITMAPINFOHEADER);
01467 lpbi->biWidth=(DWORD)BitmapSizeX;
01468 lpbi->biHeight=(DWORD)BitmapSizeY;
01469 lpbi->biPlanes=1;
01470 lpbi->biBitCount=24;
01471 lpbi->biCompression=BI_RGB;
01472 imagesize = lpbi->biSizeImage = BitmapSizeX*BitmapSizeY*3L;
01473 lpbi->biXPelsPerMeter=0;
01474 lpbi->biYPelsPerMeter=0;
01475 lpbi->biClrUsed=0;
01476 lpbi->biClrImportant=0;
01477 lpBitmapBits=(LPSTR)X__Malloc(imagesize);
01478 if(lpBitmapBits == NULL){
01479
01480 if(lpBitmapHeader != NULL)X__Free((char *)lpBitmapHeader);
01481 lpBitmapHeader = NULL;
01482
01483 return FALSE;
01484 }
01485 memset(lpBitmapBits,0,imagesize);
01486 if((hDrawDib=DrawDibOpen()) == NULL)MessageBox(NULL,"No Dib",NULL,MB_OK);
01487 return TRUE;
01488 }
01489
01490 static void TerminateRendererUpdateView(void){
01491 if(hDrawDib != NULL)DrawDibClose(hDrawDib);
01492 if(lpBitmapBits != NULL)X__Free((char *)lpBitmapBits);
01493 if(lpBitmapHeader != NULL)X__Free((char *)lpBitmapHeader);
01494 hDrawDib = NULL;
01495 lpBitmapHeader = NULL;
01496 lpBitmapBits = NULL;
01497 }
01498
01499 static void PaintRendererUpdateView(HDC hDC,RECT rc){
01500 HPALETTE hpalT;
01501 if(hDrawDib != NULL && lpBitmapHeader != NULL && lpBitmapBits != NULL){
01502 DrawDibRealize(hDrawDib,hDC,TRUE);
01503 DrawDibDraw(hDrawDib,hDC,
01504 0,
01505 0,
01506 rc.right,
01507 rc.bottom,
01508 (LPBITMAPINFOHEADER)lpBitmapHeader,lpBitmapBits,
01509 0,0,
01510 (int)((LPBITMAPINFOHEADER)lpBitmapHeader)->biWidth,
01511 (int)((LPBITMAPINFOHEADER)lpBitmapHeader)->biHeight,
01512 0);
01513 }
01514 }
01515
01516 void AddToRenderImagePreview(long index,
01517 long xmax, long ymax,
01518 fullscreenbuffer *F,
01519 unsigned char *R,
01520 unsigned char *G,
01521 unsigned char *B){
01522 long i,j,id;
01523 LPSTR p;
01524 fullscreenbuffer *f;
01525 if(lpBitmapBits == NULL)return;
01526 if(F != NULL){
01527 if(!LoggingFlag && !ImmediateFlag)return;
01528 for(j=0;j<BitmapSizeY;j++){
01529 index = BitmapSizeY - 1 - j;
01530 p=(lpBitmapBits+index*BitmapSizeX*3);
01531 id=(j*ymax)/BitmapSizeY;
01532 id *= xmax;
01533 for(i=0;i<BitmapSizeX;i++){
01534 f = (F + id + (i*xmax)/BitmapSizeX);
01535 *p++ = f->B;
01536 *p++ = f->G;
01537 *p++ = f->R;
01538 }
01539 }
01540 if(LoggingFlag){
01541 InvalidateRect(hwndimage,NULL,FALSE);
01542 UpdateWindow(hwndimage);
01543 }
01544 }
01545 else {
01546 index = BitmapSizeY - 1 - (index*BitmapSizeY)/ymax;
01547 p=(lpBitmapBits+index*BitmapSizeX*3);
01548 for(i=0;i<BitmapSizeX;i++){
01549 id = (i*xmax)/BitmapSizeX;
01550 *p++ = B[id];
01551 *p++ = G[id];
01552 *p++ = R[id];
01553 }
01554 if(RendererUpdateCount++ == 8){
01555 if(LoggingFlag)InvalidateRect(hwndimage,NULL,FALSE);
01556 else if(ImmediateFlag){
01557 if(hwndAnimatorViewWindow != NULL){
01558 HDC hDC;
01559 RECT rc;
01560 hDC=GetDC(hwndAnimatorViewWindow);
01561 GetClientRect(hwndAnimatorViewWindow,&rc);
01562 PaintRendererUpdateView(hDC,rc);
01563 ReleaseDC(hwndAnimatorViewWindow,hDC);
01564 }
01565 }
01566 RendererUpdateCount=0;
01567 }
01568 }
01569 return;
01570 }
01571
01572 static BOOL CALLBACK UpdateXDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
01573 LPARAM lparam ){
01574 char text_string[512];
01575 switch( msg ){
01576 case WM_INITDIALOG:
01577 LoggingFlag=TRUE;
01578 hwndmeter2=GetDlgItem(hdlg,RD_UPDATE_FRAME);
01579 hwndmeterframes2=GetDlgItem(hdlg,RD_UPDATE_FRAMES);
01580 hwndframe2=GetDlgItem(hdlg,RD_UPDATE_FF);
01581 hwndframeof2=GetDlgItem(hdlg,RD_UPDATE_LF);
01582 hwndstatus2=GetDlgItem(hdlg,RD_UPDATE_STATUS);
01583 hwndframetime2=GetDlgItem(hdlg,RD_UPDATE_LFT);
01584 hwndestimate2=GetDlgItem(hdlg,RD_UPDATE_ETA);
01585 hwndinfo2=GetDlgItem(hdlg,RD_UPDATE_INFO);
01586 hwndimage=GetDlgItem(hdlg,RD_UPDATEX_VIEW);
01587 SendMessage(hwndmeter2,MM_SETPARTSINJOB, 0, 0);
01588 SendMessage(hwndmeter2,MM_SETPARTSCOMPLETE, 0, 0);
01589 SendMessage(hwndmeterframes2,MM_SETPARTSINJOB, 0, 0);
01590 SendMessage(hwndmeterframes2,MM_SETPARTSCOMPLETE, 0, 0);
01591 InitializeCriticalSection(&g_CriticalSection);
01592 return( TRUE );
01593 case WM_DESTROY:
01594 DeleteCriticalSection(&g_CriticalSection);
01595 break;
01596 case WM_DRAWITEM:{
01597 LPDRAWITEMSTRUCT lpdis;
01598 HBRUSH hbr,hbrold;
01599 BYTE r,g,b;
01600 RECT rc;
01601 lpdis=(LPDRAWITEMSTRUCT)lparam;
01602 if(lpdis->CtlID == RD_UPDATEX_VIEW){
01603 if(lpdis->itemAction == ODA_DRAWENTIRE){
01604 EnterCriticalSection(&g_CriticalSection);
01605 PaintRendererUpdateView(lpdis->hDC,lpdis->rcItem);
01606 LeaveCriticalSection(&g_CriticalSection);
01607 }
01608 }
01609 }
01610 return TRUE;
01611 case WM_COMMAND:
01612 switch( LOWORD(wparam) ){
01613 case RD_UPDATEX_SHOWFINAL:
01614 DisplayOutputFile();
01615 break;
01616 case RD_UPDATEX_LOGGING:
01617 LoggingFlag ^= 1;
01618 if(LoggingFlag)
01619 LoadString(hThisInstance,IDX_MISC_PREVIEWOFF,
01620 text_string,sizeof(text_string));
01621 else
01622 LoadString(hThisInstance,IDX_MISC_PREVIEWON,
01623 text_string,sizeof(text_string));
01624 if(LoggingFlag)SetDlgItemText(hdlg,RD_UPDATEX_LOGGING,text_string);
01625 else SetDlgItemText(hdlg,RD_UPDATEX_LOGGING,text_string);
01626 break;
01627 case IDCANCEL:
01628 case RD_UPDATE_STOP:
01629 if(RendererInUse)PostMessage(hwndMain,WM_COMMAND,MENU_FILE_ABORT,0);
01630 else PostMessage(hwndMain,WM_COMMAND,MENU_FILE_STOP,0);
01631 break;
01632 default:
01633 break;
01634 }
01635 break;
01636 default: break;
01637 }
01638 return( FALSE );
01639 }
01640
01641 static BOOL CALLBACK PreferencesDlgProc(HWND hdlg,UINT msg,
01642 WPARAM wparam,LPARAM lparam){
01643 BOOL state;
01644 char *w, yesyes[]="YES", nono[]="NO";
01645 switch( msg ) {
01646 case WM_PAINT:
01647 PaintDialogBackground(hdlg,hResourceInstance);
01648 break;
01649 case WM_INITDIALOG:
01650 CentreDialogOnCursor(hdlg);
01651 if(ParamList.ae)state=TRUE; else state=FALSE;
01652 SendDlgItemMessage(hdlg,DLG_PREFERENCES_ACCELAA,BM_SETCHECK,state,0);
01653 if(ParamList.logfile)state=TRUE; else state=FALSE;
01654 SendDlgItemMessage(hdlg,DLG_PREFERENCES_LOGFILE,BM_SETCHECK,state,0);
01655 if(ParamList.personal)state=TRUE; else state=FALSE;
01656 SendDlgItemMessage(hdlg,DLG_PREFERENCES_PERSONAL,BM_SETCHECK,state,0);
01657 if(ParamList.callback)state=TRUE; else state=FALSE;
01658 SendDlgItemMessage(hdlg,DLG_PREFERENCES_PREVIEW,BM_SETCHECK,state,0);
01659 if(ParamList.tzero_still)state=TRUE; else state=FALSE;
01660 SendDlgItemMessage(hdlg,DLG_PREFERENCES_TZERO_STILL,BM_SETCHECK,state,0);
01661 if(ParamList.beep_after)state=TRUE; else state=FALSE;
01662 SendDlgItemMessage(hdlg,DLG_PREFERENCES_BEEP_AFTER,BM_SETCHECK,state,0);
01663 if(ParamList.autoshow)state=TRUE; else state=FALSE;
01664 SendDlgItemMessage(hdlg,DLG_PREFERENCES_AUTOSHOW,BM_SETCHECK,state,0);
01665 if(ParamList.autoplay)state=TRUE; else state=FALSE;
01666 SendDlgItemMessage(hdlg,DLG_PREFERENCES_AUTOPLAY,BM_SETCHECK,state,0);
01667 return (TRUE);
01668 case WM_COMMAND:
01669 switch(LOWORD(wparam)){
01670 case IDOK:
01671 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_ACCELAA,BM_GETCHECK,0,0))
01672 ParamList.ae=1; else ParamList.ae=0;
01673 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_LOGFILE,BM_GETCHECK,0,0))
01674 ParamList.logfile=TRUE; else ParamList.logfile=FALSE;
01675 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_PERSONAL,BM_GETCHECK,0,0))
01676 ParamList.personal=TRUE; else ParamList.personal=FALSE;
01677 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_PREVIEW,BM_GETCHECK,0,0))
01678 ParamList.callback=TRUE; else ParamList.callback=FALSE;
01679 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_TZERO_STILL,BM_GETCHECK,0,0))
01680 ParamList.tzero_still=TRUE; else ParamList.tzero_still=FALSE;
01681 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_BEEP_AFTER,BM_GETCHECK,0,0))
01682 ParamList.beep_after=TRUE; else ParamList.beep_after=FALSE;
01683 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_AUTOSHOW,BM_GETCHECK,0,0))
01684 ParamList.autoshow=TRUE; else ParamList.autoshow=FALSE;
01685 if(SendDlgItemMessage(hdlg,DLG_PREFERENCES_AUTOPLAY,BM_GETCHECK,0,0))
01686 ParamList.autoplay=TRUE; else ParamList.autoplay=FALSE;
01687
01688 if(ParamList.ae == 1)w=yesyes; else w=nono;
01689 WritePrivateProfileString("RPREFERENCES","ACCELAA",w,IniFilename);
01690 if(ParamList.u3 == 1)w=yesyes; else w=nono;
01691 WritePrivateProfileString("RPREFERENCES","DIALOGS3D",w,IniFilename);
01692 if(ParamList.logfile == 1)w=yesyes; else w=nono;
01693 WritePrivateProfileString("RPREFERENCES","LOGFILE",w,IniFilename);
01694 if(ParamList.personal == 1)w=yesyes; else w=nono;
01695 WritePrivateProfileString("RPREFERENCES","PERSONAL",w,IniFilename);
01696 if(ParamList.callback == 1)w=yesyes; else w=nono;
01697 WritePrivateProfileString("RPREFERENCES","PREVIEW",w,IniFilename);
01698 if(ParamList.tzero_still == 1)w=yesyes; else w=nono;
01699 WritePrivateProfileString("RPREFERENCES","TZERO_STILL",w,IniFilename);
01700 if(ParamList.beep_after == 1)w=yesyes; else w=nono;
01701 WritePrivateProfileString("RPREFERENCES","BEEP_AFTER",w,IniFilename);
01702 if(ParamList.autoshow == 1)w=yesyes; else w=nono;
01703 WritePrivateProfileString("RPREFERENCES","AUTOSHOW",w,IniFilename);
01704 if(ParamList.autoplay == 1)w=yesyes; else w=nono;
01705 WritePrivateProfileString("RPREFERENCES","AUTOPLAY",w,IniFilename);
01706 EndDialog(hdlg,TRUE);
01707 return(TRUE);
01708 break;
01709 case IDCANCEL:
01710 EndDialog(hdlg,FALSE);
01711 return(TRUE);
01712 break;
01713 default: break;
01714 }
01715 break;
01716 default: break;
01717 }
01718 return(FALSE);
01719 }
01720
01721
01722
01723
01724
01725 #define D_BORDER 4
01726 #define WM_RSF_GETSTATUS (WM_USER + 100)
01727
01728 typedef struct tag_dlghdr {
01729 HWND hwndDlgControl;
01730 HWND hwndDlgOptions;
01731 HWND hwndDlgSettings;
01732 HWND hwndDlgTracing;
01733 RECT rcTab;
01734 } DLGHDR;
01735
01736 static DLGHDR DlgHdr,*lpDlgHdr;
01737 static HWND hwndTab;
01738 static BOOL TabCheckOk;
01739
01740 static BOOL CALLBACK TabbedDlgProcControl(HWND hdlg, UINT msg,
01741 WPARAM wparam, LPARAM lparam ){
01742 char text_string[512];
01743 static BOOL bEflag=FALSE;
01744 int i,istatus;
01745 char tempstr[64],tempdir[256],mss1[20];
01746 HWND hctl;
01747 BOOL status;
01748 switch( msg ){
01749 case WM_PAINT:
01750 PaintDialogBackground(hdlg,hResourceInstance);
01751 break;
01752 case WM_INITDIALOG:
01753 UpdateControlDlg(hdlg,TRUE);
01754 return( TRUE );
01755 case WM_COMMAND:
01756 switch( HIWORD(wparam) ){
01757 case EN_CHANGE:
01758 if(plp->constrain){
01759 if(!bEflag && LOWORD(wparam) == RD_X_SIZE){
01760 i=GetDlgItemInt(hdlg,RD_X_SIZE,&status,FALSE);
01761 i=(3*i)/4;
01762 bEflag=TRUE;
01763 SetDlgItemInt(hdlg,RD_Y_SIZE,(UINT)i,FALSE);
01764 SendDlgItemMessage(hdlg,RD_Y_SIZE_SPIN,
01765 SPNM_SETCRNTVALUE,(WPARAM)i,0);
01766 bEflag=FALSE;
01767 }
01768 else if(!bEflag && LOWORD(wparam) == RD_Y_SIZE){
01769 i=GetDlgItemInt(hdlg,RD_Y_SIZE,&status,FALSE);
01770 i=(4*i)/3;
01771 bEflag=TRUE;
01772 SetDlgItemInt(hdlg,RD_X_SIZE,(UINT)i,FALSE);
01773 SendDlgItemMessage(hdlg,RD_X_SIZE_SPIN,
01774 SPNM_SETCRNTVALUE,(WPARAM)i,0);
01775 bEflag=FALSE;
01776 }
01777 }
01778 break;
01779 case CBN_SELENDOK:
01780 if(LOWORD(wparam) == RD_RESOLUTION){
01781 SendDlgItemMessage(hdlg,RD_RESOLUTION,WM_GETTEXT,
01782 (WPARAM)18,(LPARAM)mss1);
01783 i=GetCharListID(mss1,rlist,Nrlist);
01784 if(i >= 0 && i < Nrlist - 1){
01785 plp->re=i; plp->xres=rxlist[i]; plp->yres=rylist[i];
01786 SetDlgItemInt(hdlg,RD_X_SIZE,(UINT)plp->xres,FALSE);
01787 SetDlgItemInt(hdlg,RD_Y_SIZE,(UINT)plp->yres,FALSE);
01788 SendDlgItemMessage(hdlg,RD_X_SIZE_SPIN,
01789 SPNM_SETCRNTVALUE,(WPARAM)plp->xres,0);
01790 SendDlgItemMessage(hdlg,RD_Y_SIZE_SPIN,
01791 SPNM_SETCRNTVALUE,(WPARAM)plp->yres,0);
01792 }
01793 }
01794 else if(LOWORD(wparam) == RD_FILE){
01795 SendDlgItemMessage(hdlg,RD_FILE,WM_GETTEXT,
01796 (WPARAM)18,(LPARAM)mss1);
01797 i=GetCharListID(mss1,plist,Nplist);
01798 if(i >= 0)plp->ot=i;
01799 if(i != 1)plp->last_ot=i;
01800 }
01801 else if(LOWORD(wparam) == RD_AA){
01802 SendDlgItemMessage(hdlg,RD_AA,WM_GETTEXT,
01803 (WPARAM)18,(LPARAM)mss1);
01804 i=GetCharListID(mss1,aalist,Naalist);
01805 if(i >= 0)plp->aa=i;
01806 }
01807 break;
01808 default:
01809 break;
01810 }
01811 switch( LOWORD(wparam) ){
01812 case RD_CONTROL_CONSTRAIN:
01813 if(SendDlgItemMessage(hdlg,RD_CONTROL_CONSTRAIN,BM_GETCHECK,0,0))
01814 plp->constrain=1;
01815 else plp->constrain=0;
01816 break;
01817 case IDC_FRAMESET:
01818 SetDlgItemInt(hdlg,RD_CONTROL_CURRENTFRAME,current_frame,FALSE);
01819 SendDlgItemMessage(hdlg,RD_CONTROL_CURRENTFRAME,EM_LIMITTEXT,(WPARAM)6,0);
01820 SendDlgItemMessage(hdlg,RD_CONTROL_CURRENTFRAME_SPIN,
01821 SPNM_SETRANGE,0,MAKELPARAM(1,frames));
01822 SendDlgItemMessage(hdlg,RD_CONTROL_CURRENTFRAME_SPIN,
01823 SPNM_SETCRNTVALUE,(WPARAM)current_frame,0);
01824 SendDlgItemMessage(hdlg,RD_CONTROL_CURRENTFRAME_SPIN,
01825 SPNM_SETEDITCTRL,0,
01826 (LPARAM)GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME));
01827 SetDlgItemInt(hdlg,RD_CONTROL_FIRSTFRAME,first_frame,FALSE);
01828 SendDlgItemMessage(hdlg,RD_CONTROL_FIRSTFRAME,EM_LIMITTEXT,(WPARAM)6,0);
01829 SendDlgItemMessage(hdlg,RD_CONTROL_FIRSTFRAME_SPIN,
01830 SPNM_SETRANGE,0,MAKELPARAM(1,frames));
01831 SendDlgItemMessage(hdlg,RD_CONTROL_FIRSTFRAME_SPIN,
01832 SPNM_SETCRNTVALUE,(WPARAM)first_frame,0);
01833 SendDlgItemMessage(hdlg,RD_CONTROL_FIRSTFRAME_SPIN,
01834 SPNM_SETEDITCTRL,0,
01835 (LPARAM)GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME));
01836 SetDlgItemInt(hdlg,RD_CONTROL_LASTFRAME,last_frame,FALSE);
01837 SendDlgItemMessage(hdlg,RD_CONTROL_LASTFRAME,EM_LIMITTEXT,(WPARAM)6,0);
01838 SendDlgItemMessage(hdlg,RD_CONTROL_LASTFRAME_SPIN,
01839 SPNM_SETRANGE,0,MAKELPARAM(1,frames));
01840 SendDlgItemMessage(hdlg,RD_CONTROL_LASTFRAME_SPIN,
01841 SPNM_SETCRNTVALUE,(WPARAM)last_frame,0);
01842 SendDlgItemMessage(hdlg,RD_CONTROL_LASTFRAME_SPIN,
01843 SPNM_SETEDITCTRL,0,
01844 (LPARAM)GetDlgItem(hdlg,RD_CONTROL_LASTFRAME));
01845 if(RendererStandAlone){
01846 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME),FALSE);
01847 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME_SPIN),FALSE);
01848 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_CURRENTFRAME_SPIN),SW_HIDE);
01849 if(frames == 1){
01850 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_ONEFRAME),TRUE);
01851 SendDlgItemMessage(hdlg,RD_CONTROL_ONEFRAME,BM_SETCHECK,TRUE,0);
01852 SendDlgItemMessage(hdlg,RD_CONTROL_MANYFRAMES,BM_SETCHECK,FALSE,0);
01853 status=FALSE;
01854 }
01855 else{
01856 status=TRUE;
01857 SendDlgItemMessage(hdlg,RD_CONTROL_ONEFRAME,BM_SETCHECK,FALSE,0);
01858 SendDlgItemMessage(hdlg,RD_CONTROL_MANYFRAMES,BM_SETCHECK,TRUE,0);
01859 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_ONEFRAME),FALSE);
01860 }
01861 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_MANYFRAMES),status);
01862 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME),status);
01863 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME),status);
01864 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME_SPIN),status);
01865 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME_SPIN),status);
01866 if(status)istatus=SW_SHOW; else istatus=SW_HIDE;
01867 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_FIRSTFRAME_SPIN),istatus);
01868 ShowWindow(GetDlgItem(hdlg,RD_CONTROL_LASTFRAME_SPIN),istatus);
01869 }
01870 else {
01871 if(plp->ot == 1)plp->ot=plp->last_ot;
01872 SendMessage(GetDlgItem(hdlg,RD_FILE),CB_SELECTSTRING,0,
01873 (LPARAM)plist[plp->ot]);
01874 SendDlgItemMessage(hdlg,RD_CONTROL_ONEFRAME,BM_SETCHECK,TRUE,0);
01875 SendDlgItemMessage(hdlg,RD_CONTROL_MANYFRAMES,BM_SETCHECK,FALSE,0);
01876 if(frames == 1)
01877 EnableWindow(GetDlgItem(hdlg,RD_CONTROL_MANYFRAMES),FALSE);
01878 else EnableWindow(GetDlgItem(hdlg,RD_CONTROL_MANYFRAMES),TRUE);
01879 EnableAnimSettings(hdlg,FALSE,SW_HIDE,TRUE,SW_SHOW);
01880 }
01881 break;
01882 case RD_CONTROL_COMPRESS:
01883 if(HIWORD(wparam) != BN_CLICKED)break;
01884 if(SendDlgItemMessage(hdlg,RD_CONTROL_COMPRESS,BM_GETCHECK,0,0))
01885 plp->avi_compress=1;
01886 else plp->avi_compress=0;
01887 break;
01888 case RD_CONTROL_AVI:
01889 if(HIWORD(wparam) != BN_CLICKED)break;
01890 plp->avi_fli=1;
01891 plp->avi_low=0;
01892 break;
01893 case RD_CONTROL_FLI:
01894 if(HIWORD(wparam) != BN_CLICKED)break;
01895 plp->avi_fli=0;
01896 plp->avi_low=1;
01897 break;
01898 case RD_CONTROL_GIF:
01899 if(HIWORD(wparam) != BN_CLICKED)break;
01900 plp->avi_fli=2;
01901 plp->avi_low=1;
01902 break;
01903 case RD_CONTROL_ONEFRAME:
01904 if(HIWORD(wparam) != BN_CLICKED)break;
01905 EnableAnimSettings(hdlg,FALSE,SW_HIDE,TRUE,SW_SHOW);
01906 break;
01907 case RD_CONTROL_MANYFRAMES:
01908 if(HIWORD(wparam) != BN_CLICKED)break;
01909 EnableAnimSettings(hdlg,TRUE,SW_SHOW,FALSE,SW_HIDE);
01910 break;
01911 case RD_CONTROL_CDSTILL:
01912 strcpy(tempstr,"temp.scr"); strcpy(tempdir,plp->pic_dir);
01913 LoadString(hThisInstance,IDX_MISC_IMAGEFILEDIR,
01914 text_string,sizeof(text_string));
01915 if(SelectDirectoryName(tempstr,tempdir,text_string,
01916 "(*.SCR)|*.scr|",hwndMain) == TRUE){
01917 if(strlen(tempdir) == 2)strcat(tempdir,"\\");
01918 strcpy(plp->pic_dir,tempdir);
01919 WritePrivateProfileString("RPREFERENCES","PICDIR",tempdir,
01920 IniFilename);
01921 SetDlgItemText(hdlg,RD_CONTROL_STILLFILEDIR,
01922 CompressPath(plp->pic_dir,18));
01923 }
01924 break;
01925 case RD_CONTROL_CDANIM:
01926 strcpy(tempstr,"temp.scr"); strcpy(tempdir,plp->fli_dir);
01927 LoadString(hThisInstance,IDX_MISC_FLICFILEDIR,
01928 text_string,sizeof(text_string));
01929 if(SelectDirectoryName(tempstr,tempdir,text_string,
01930 "(*.SCR)|*.scr|",hwndMain) == TRUE){
01931 if(strlen(tempdir) == 2)strcat(tempdir,"\\");
01932 strcpy(plp->fli_dir,tempdir);
01933 WritePrivateProfileString("RPREFERENCES","FLIDIR",tempdir,
01934 IniFilename);
01935 SetDlgItemText(hdlg,RD_CONTROL_ANIMFILEDIR,
01936 CompressPath(plp->fli_dir,18));
01937 }
01938 break;
01939 default:
01940 break;
01941 }
01942 break;
01943 case WM_RSF_GETSTATUS:
01944 case WM_DESTROY:{
01945 BOOL err,err1;
01946 UINT result;
01947 int i1,i2,i3;
01948 if(SendDlgItemMessage(hdlg,RD_ACCELERATED_AA,BM_GETCHECK,0,0))
01949 plp->ae=1;else plp->ae=0;
01950 if(SendDlgItemMessage(hdlg,RD_CONTROL_STEREO,BM_GETCHECK,0,0))
01951 plp->bRenderStereo=1;else plp->bRenderStereo=0;
01952 result=GetDlgItemInt(hdlg,RD_X_SIZE,&err,FALSE);
01953 if(err)plp->xres=result;
01954 result=GetDlgItemInt(hdlg,RD_Y_SIZE,&err,FALSE);
01955 if(err)plp->yres=result;
01956 if(plp->yres < 10 || plp->xres < 20 ||
01957 plp->yres > 16348 || plp->xres > 16348){
01958 LoadString(hThisInstance,IDX_MISC_IMAGENOTSUPPORT,
01959 text_string,sizeof(text_string));
01960 MessageBox(hdlg,text_string,NULL,MB_ICONSTOP);
01961 break;
01962 }
01963 err1=FALSE;
01964 i1=GetDlgItemInt(hdlg,RD_CONTROL_CURRENTFRAME,&err,FALSE);
01965 if(!err)err1=TRUE;
01966 i2=GetDlgItemInt(hdlg,RD_CONTROL_FIRSTFRAME,&err,FALSE);
01967 if(!err)err1=TRUE;
01968 i3=GetDlgItemInt(hdlg,RD_CONTROL_LASTFRAME,&err,FALSE);
01969 if(!err)err1=TRUE;
01970 if(i2 < 1 || i2 > i3)err1=TRUE;
01971 if(i3 < 1 || i3 > frames)err1=TRUE;
01972 if(i1 > frames)err1=TRUE;
01973 if(err1){
01974 LoadString(hThisInstance,IDX_MISC_INVALIDANIMATION,
01975 text_string,sizeof(text_string));
01976 MessageBox(hdlg,text_string,NULL,MB_ICONSTOP);
01977 SendMessage(hdlg,WM_COMMAND,IDC_FRAMESET,0);
01978 break;
01979 }
01980 current_frame=i1; first_frame=i2; last_frame=i3;
01981 if(GetDlgItemText(hdlg,RD_CONTROL_STILLFILENAME,tempstr,64) == 0
01982 || strlen(tempstr) == 0 || !ValidFileName(tempstr)){
01983 LoadString(hThisInstance,IDX_MISC_INVALIDNAME1,
01984 text_string,sizeof(text_string));
01985 MessageBox(hdlg,text_string,NULL,MB_ICONSTOP);
01986 break;
01987 }
01988 strcpy(plp->pic_file,tempstr);
01989 if(GetDlgItemText(hdlg,RD_CONTROL_ANIMFILENAME,tempstr,64) == 0
01990 || strlen(tempstr) == 0 || !ValidFileName(tempstr)){
01991 LoadString(hThisInstance,IDX_MISC_INVALIDNAME2,
01992 text_string,sizeof(text_string));
01993 MessageBox(hdlg,text_string,NULL,MB_ICONSTOP);
01994 break;
01995 }
01996 strcpy(plp->fli_file,tempstr);
01997 if(SendDlgItemMessage(hdlg,RD_CONTROL_MANYFRAMES,BM_GETCHECK,0,0)){
01998 RendererRange=1;
01999 if(plp->ot != 1){
02000 char warnt[32];
02001 LoadString(hThisInstance,IDX_MISC_INVALIDRANGE,
02002 text_string,sizeof(text_string));
02003 LoadString(hThisInstance,IDX_MISC_WARNING,
02004 warnt,sizeof(warnt));
02005 i=MessageBox(hdlg,text_string,warnt,MB_ICONQUESTION|MB_YESNOCANCEL);
02006 if(i == IDCANCEL)break;
02007 else if(i == IDYES){
02008 plp->ot=1;
02009 SendMessage(GetDlgItem(hdlg,RD_FILE),CB_SELECTSTRING,0,
02010 (LPARAM)plist[plp->ot]);
02011 }
02012 }
02013 }
02014 else{
02015 RendererRange=0;
02016 if(plp->ot == 1){
02017 LoadString(hThisInstance,IDX_MISC_NOANIMFORMAT,
02018 text_string,sizeof(text_string));
02019 MessageBox(hdlg,text_string,NULL,MB_ICONSTOP);
02020 break;
02021 }
02022 }
02023 }
02024 TabCheckOk=TRUE;
02025 break;
02026 default: break;
02027 }
02028 return( FALSE );
02029 }
02030
02031 static void UpdateSettingsDlg(HWND hdlg){
02032 int i;
02033 SetDlgItemInt(hdlg,RD_SMOOTHING,(UINT)plp->sc,FALSE);
02034 SendDlgItemMessage(hdlg,RD_SMOOTHING_SPIN,
02035 SPNM_SETRANGE,0,MAKELPARAM(0,89));
02036 SendDlgItemMessage(hdlg,RD_SMOOTHING_SPIN,
02037 SPNM_SETCRNTVALUE,(WPARAM)plp->sc,0);
02038 SendDlgItemMessage(hdlg,RD_SMOOTHING_SPIN,SPNM_SETEDITCTRL,0,
02039 (LPARAM)GetDlgItem(hdlg,RD_SMOOTHING));
02040 SetDlgItemInt(hdlg,RD_AMBIENT,(UINT)plp->al,FALSE);
02041 SendDlgItemMessage(hdlg,RD_AMBIENT_SPIN,
02042 SPNM_SETRANGE,0,MAKELPARAM(0,75));
02043 SendDlgItemMessage(hdlg,RD_AMBIENT_SPIN,
02044 SPNM_SETCRNTVALUE,(WPARAM)plp->al,0);
02045 SendDlgItemMessage(hdlg,RD_AMBIENT_SPIN,SPNM_SETEDITCTRL,0,
02046 (LPARAM)GetDlgItem(hdlg,RD_AMBIENT));
02047 SetDlgItemInt(hdlg,RD_SHADOW_DENSITY,(UINT)plp->sd,FALSE);
02048 SendDlgItemMessage(hdlg,RD_SHADOW_DENSITY_SPIN,
02049 SPNM_SETRANGE,0,MAKELPARAM(0,100));
02050 SendDlgItemMessage(hdlg,RD_SHADOW_DENSITY_SPIN,
02051 SPNM_SETCRNTVALUE,(WPARAM)plp->sd,0);
02052 SendDlgItemMessage(hdlg,RD_SHADOW_DENSITY_SPIN,SPNM_SETEDITCTRL,0,
02053 (LPARAM)GetDlgItem(hdlg,RD_SHADOW_DENSITY));
02054 SetDlgItemInt(hdlg,RD_SPOTLIGHT_SIZE,plp->sb,FALSE);
02055 SendDlgItemMessage(hdlg,RD_SPOTLIGHT_SIZE_SPIN,
02056 SPNM_SETRANGE,0,MAKELPARAM(10,9999));
02057 SendDlgItemMessage(hdlg,RD_SPOTLIGHT_SIZE_SPIN,
02058 SPNM_SETCRNTVALUE,(WPARAM)plp->sb,0);
02059 SendDlgItemMessage(hdlg,RD_SPOTLIGHT_SIZE_SPIN,SPNM_SETEDITCTRL,0,
02060 (LPARAM)GetDlgItem(hdlg,RD_SPOTLIGHT_SIZE));
02061
02062 SetDlgItemInt(hdlg,RD_ANIM_SPEED,(UINT)plp->speed,FALSE);
02063 SendDlgItemMessage(hdlg,RD_ANIM_SPEED_SPIN,
02064 SPNM_SETRANGE,0,MAKELPARAM(0,9999));
02065 SendDlgItemMessage(hdlg,RD_ANIM_SPEED_SPIN,
02066 SPNM_SETCRNTVALUE,(WPARAM)plp->speed,0);
02067 SendDlgItemMessage(hdlg,RD_ANIM_SPEED_SPIN,SPNM_SETEDITCTRL,0,
02068 (LPARAM)GetDlgItem(hdlg,RD_ANIM_SPEED));
02069 SetDlgItemInt(hdlg,RD_MOTION_BLUR,(UINT)plp->blur,FALSE);
02070 SendDlgItemMessage(hdlg,RD_MOTION_BLUR_SPIN,
02071 SPNM_SETRANGE,0,MAKELPARAM(0,10));
02072 SendDlgItemMessage(hdlg,RD_MOTION_BLUR_SPIN,
02073 SPNM_SETCRNTVALUE,(WPARAM)plp->blur,0);
02074 SendDlgItemMessage(hdlg,RD_MOTION_BLUR_SPIN,SPNM_SETEDITCTRL,0,
02075 (LPARAM)GetDlgItem(hdlg,RD_MOTION_BLUR));
02076 SetDlgItemInt(hdlg,RD_TZEROS,plp->tzeros,FALSE);
02077 SendDlgItemMessage(hdlg,RD_TZEROS_SPIN,
02078 SPNM_SETRANGE,0,MAKELPARAM(2,10));
02079 SendDlgItemMessage(hdlg,RD_TZEROS_SPIN,
02080 SPNM_SETCRNTVALUE,(WPARAM)plp->tzeros,0);
02081 SendDlgItemMessage(hdlg,RD_TZEROS_SPIN,SPNM_SETEDITCTRL,0,
02082 (LPARAM)GetDlgItem(hdlg,RD_TZEROS));
02083 SendDlgItemMessage(hdlg,RD_JPEG,TBM_SETPOS,(WPARAM)TRUE,
02084 plp->jpeg_quality);
02085 SendDlgItemMessage(hdlg,RD_THREADS,CB_RESETCONTENT,0,0);
02086 for(i=0;i<Nthreadlist;i++)
02087 SendDlgItemMessage(hdlg,RD_THREADS,CB_ADDSTRING,
02088 0,(LPARAM)threadlist[i]);
02089 SendDlgItemMessage(hdlg,RD_THREADS,CB_SELECTSTRING,
02090 0,(LPARAM)threadlist[plp->Nthreads]);
02091 #if __LITE__
02092 EnableWindow(GetDlgItem(hdlg,RD_THREADS),FALSE);
02093 EnableWindow(GetDlgItem(hdlg,RD_MOTION_BLUR),FALSE);
02094 EnableWindow(GetDlgItem(hdlg,RD_MOTION_BLUR_SPIN),FALSE);
02095 #endif
02096 }
02097
02098 static BOOL CALLBACK TabbedDlgProcSettings(HWND hdlg, UINT msg,
02099 WPARAM wparam, LPARAM lparam){
02100 BOOL err;
02101 UINT result;
02102 int i;
02103 switch( msg ){
02104 case WM_PAINT:
02105 PaintDialogBackground(hdlg,hResourceInstance);
02106 break;
02107 case WM_INITDIALOG:
02108 SendDlgItemMessage(hdlg,RD_JPEG,TBM_SETRANGE,(WPARAM)FALSE,
02109 MAKELONG(10,100));
02110 SendDlgItemMessage(hdlg,RD_JPEG,TBM_SETTIC,0,(LPARAM)55);
02111 UpdateSettingsDlg(hdlg);
02112 return( TRUE );
02113 case WM_HSCROLL:
02114 switch(LOWORD(wparam)){
02115 case TB_ENDTRACK:
02116 plp->jpeg_quality=SendDlgItemMessage(hdlg,RD_JPEG,TBM_GETPOS,0,0);
02117 break;
02118 default:
02119 break;
02120 }
02121 break;
02122 case WM_COMMAND:
02123 switch( LOWORD(wparam) ){
02124 case RD_LOADOWNPREFS:
02125 UpdateSettingsDlg(hdlg);
02126 break;
02127 case RD_SAVEOWNPREFS:
02128 SendMessage(hdlg,WM_RSF_GETSTATUS,0,0);
02129 break;
02130 default:
02131 break;
02132 }
02133 break;
02134 case WM_RSF_GETSTATUS:
02135 case WM_DESTROY:
02136 i=SendDlgItemMessage(hdlg,RD_THREADS,CB_GETCURSEL,0,0);
02137 if(i != CB_ERR){
02138 char str[16];
02139 plp->Nthreads=i;
02140 Nthreads=i;
02141 sprintf(str,"%ld",Nthreads);
02142 WritePrivateProfileString("RPREFERENCES","THREADS",str,IniFilename);
02143 }
02144 else MessageBox(NULL,"CB",NULL,MB_OK);
02145 result=GetDlgItemInt(hdlg,RD_SMOOTHING,&err,FALSE);
02146 if(err)plp->sc=result;
02147 result=GetDlgItemInt(hdlg,RD_AMBIENT,&err,FALSE);
02148 if(err)plp->al=result;
02149 result=GetDlgItemInt(hdlg,RD_SHADOW_DENSITY,&err,FALSE);
02150 if(err)plp->sd=result;
02151 result=GetDlgItemInt(hdlg,RD_SPOTLIGHT_SIZE,&err,FALSE);
02152 if(err)plp->sb=result;
02153 result=GetDlgItemInt(hdlg,RD_ANIM_SPEED,&err,FALSE);
02154 if(err)plp->speed=result;
02155 result=GetDlgItemInt(hdlg,RD_MOTION_BLUR,&err,FALSE);
02156 if(err)plp->blur=result;
02157 result=GetDlgItemInt(hdlg,RD_TZEROS,&err,FALSE);
02158 if(err){
02159 result=max(result,2);
02160 result=min(result,10);
02161 plp->tzeros=result;
02162 }
02163 plp->jpeg_quality=SendDlgItemMessage(hdlg,RD_JPEG,TBM_GETPOS,0,0);
02164 break;
02165 default: break;
02166 }
02167 return( FALSE );
02168 }
02169
02170 static void UpdateOptionsDlg(HWND hdlg){
02171 int v;
02172 if(plp->bDrawDirectly)SendDlgItemMessage(hdlg,RD_RENDER_SCREEN,BM_SETCHECK,1,0);
02173 else if(plp->bUseFBO) SendDlgItemMessage(hdlg,RD_RENDER_FBO,BM_SETCHECK,1,0);
02174 else SendDlgItemMessage(hdlg,RD_RENDER_PBUFFER,BM_SETCHECK,1,0);
02175 if(plp->callback)v=1; else v=0;
02176 SendDlgItemMessage(hdlg,RD_CALLBACK,BM_SETCHECK,v,0);
02177 if(plp->swgp)v=1; else v=0;
02178 SendDlgItemMessage(hdlg,RD_SW_POSTPRO,BM_SETCHECK,v,0);
02179 if(plp->bCopyGLdepth)v=1; else v=0;
02180 SendDlgItemMessage(hdlg,RD_COPY_TO_DEPTH_BUFFER,BM_SETCHECK,v,0);
02181 }
02182
02183 static BOOL CALLBACK TabbedDlgProcOptions(HWND hdlg, UINT msg,
02184 WPARAM wparam, LPARAM lparam ){
02185 int i;
02186 HWND hctl;
02187 switch( msg ){
02188 case WM_PAINT:
02189 PaintDialogBackground(hdlg,hResourceInstance);
02190 break;
02191 case WM_INITDIALOG:
02192 UpdateOptionsDlg(hdlg);
02193 return( TRUE );
02194 case WM_COMMAND:
02195 switch( LOWORD(wparam) ){
02196 case RD_EDITPRESET:
02197 if(DialogBox(hResourceInstance,MAKEINTRESOURCE(DLG_PREFERENCES),hdlg,
02198 (DLGPROC)PreferencesDlgProc))UpdateOptionsDlg(hdlg);
02199 break;
02200 default:
02201 break;
02202 }
02203 break;
02204 case WM_RSF_GETSTATUS:
02205 case WM_DESTROY:
02206 plp->ob=1;
02207 plp->interlace_gif=0;
02208 if(SendDlgItemMessage(hdlg,RD_RENDER_FBO,BM_GETCHECK,0,0)){
02209 plp->bDrawDirectly=FALSE; plp->bUseFBO=TRUE;
02210 }
02211 else if(SendDlgItemMessage(hdlg,RD_RENDER_SCREEN,BM_GETCHECK,0,0)){
02212 plp->bDrawDirectly=TRUE; plp->bUseFBO=FALSE;
02213 }
02214 else {
02215 plp->bDrawDirectly=FALSE; plp->bUseFBO=FALSE;
02216 }
02217
02218 if(SendDlgItemMessage(hdlg,RD_NTSC_COLOURS,BM_GETCHECK,0,0))
02219 plp->ntsc_colours=1;else plp->ntsc_colours=0;
02220 if(SendDlgItemMessage(hdlg,RD_FULL_MIRROR,BM_GETCHECK,0,0))
02221 plp->full_mirror=1;else plp->full_mirror=0;
02222 if(SendDlgItemMessage(hdlg,RD_CALLBACK,BM_GETCHECK,0,0))
02223 plp->callback=1;else plp->callback=0;
02224 if(SendDlgItemMessage(hdlg,RD_SW_POSTPRO,BM_GETCHECK,0,0))
02225 plp->swgp=1;else plp->swgp=0;
02226 if(SendDlgItemMessage(hdlg,RD_COPY_TO_DEPTH_BUFFER,BM_GETCHECK,0,0))
02227 plp->bCopyGLdepth=1;else plp->bCopyGLdepth=0;
02228 break;
02229 default: break;
02230 }
02231 return( FALSE );
02232 }
02233
02234 static void UpdateTracingDlg(HWND hdlg){
02235 int v;
02236 if(plp->trace_shadows)v=1; else v=0;
02237 SendDlgItemMessage(hdlg,RD_TRACE_SHADOWS,BM_SETCHECK,v,0);
02238 if(plp->trace_reflections)v=1; else v=0;
02239 SendDlgItemMessage(hdlg,RD_TRACE_REFLECTIONS,BM_SETCHECK,v,0);
02240 if(plp->trace_refractions)v=1; else v=0;
02241 SendDlgItemMessage(hdlg,RD_TRACE_REFRACTIONS,BM_SETCHECK,v,0);
02242
02243
02244 if(plp->trace_partition)
02245 SendDlgItemMessage(hdlg,RD_TRACE_OPT_PARTITION,BM_SETCHECK,TRUE,0);
02246 else SendDlgItemMessage(hdlg,RD_TRACE_OPT_SPLIT,BM_SETCHECK,TRUE,0);
02247
02248 SetDlgItemInt(hdlg,RD_TRACE_OPT_DEPTH,plp->trace_depth,FALSE);
02249 SendDlgItemMessage(hdlg,RD_TRACE_OPT_DEPTH_SPIN,
02250 SPNM_SETRANGE,0,MAKELPARAM(4,20));
02251 SendDlgItemMessage(hdlg,RD_TRACE_OPT_DEPTH_SPIN,
02252 SPNM_SETCRNTVALUE,(WPARAM)plp->trace_depth,0);
02253 SendDlgItemMessage(hdlg,RD_TRACE_OPT_DEPTH_SPIN,SPNM_SETEDITCTRL,0,
02254 (LPARAM)GetDlgItem(hdlg,RD_TRACE_OPT_DEPTH));
02255 SetDlgItemInt(hdlg,RD_TRACE_OPT_THRESHOLD,plp->trace_face_count_target,FALSE);
02256 SendDlgItemMessage(hdlg,RD_TRACE_OPT_THRESHOLD_SPIN,
02257 SPNM_SETRANGE,0,MAKELPARAM(2,100));
02258 SendDlgItemMessage(hdlg,RD_TRACE_OPT_THRESHOLD_SPIN,
02259 SPNM_SETCRNTVALUE,(WPARAM)plp->trace_face_count_target,0);
02260 SendDlgItemMessage(hdlg,RD_TRACE_OPT_THRESHOLD_SPIN,SPNM_SETEDITCTRL,0,
02261 (LPARAM)GetDlgItem(hdlg,RD_TRACE_OPT_THRESHOLD));
02262 SetDlgItemInt(hdlg,RD_TRACE_OPT_SIZE,plp->trace_voxel_min_size,FALSE);
02263 SendDlgItemMessage(hdlg,RD_TRACE_OPT_SIZE_SPIN,
02264 SPNM_SETRANGE,0,MAKELPARAM(1,128));
02265 SendDlgItemMessage(hdlg,RD_TRACE_OPT_SIZE_SPIN,
02266 SPNM_SETCRNTVALUE,(WPARAM)plp->trace_voxel_min_size,0);
02267 SendDlgItemMessage(hdlg,RD_TRACE_OPT_SIZE_SPIN,SPNM_SETEDITCTRL,0,
02268 (LPARAM)GetDlgItem(hdlg,RD_TRACE_OPT_SIZE));
02269 return;
02270 }
02271
02272 static BOOL CALLBACK TabbedDlgProcTracing(HWND hdlg, UINT msg,
02273 WPARAM wparam, LPARAM lparam){
02274 BOOL err;
02275 UINT result;
02276 switch( msg ){
02277 case WM_PAINT:
02278 PaintDialogBackground(hdlg,hResourceInstance);
02279 break;
02280 case WM_INITDIALOG:
02281 UpdateTracingDlg(hdlg);
02282 return( TRUE );
02283 case WM_COMMAND:
02284 switch( LOWORD(wparam) ){
02285 default:
02286 break;
02287 }
02288 break;
02289 case WM_RSF_GETSTATUS:
02290 case WM_DESTROY:
02291 if(SendDlgItemMessage(hdlg,RD_TRACE_SHADOWS,BM_GETCHECK,0,0))
02292 plp->trace_shadows=1;else plp->trace_shadows=0;
02293 if(SendDlgItemMessage(hdlg,RD_TRACE_REFLECTIONS,BM_GETCHECK,0,0))
02294 plp->trace_reflections=1;else plp->trace_reflections=0;
02295 if(SendDlgItemMessage(hdlg,RD_TRACE_REFRACTIONS,BM_GETCHECK,0,0))
02296 plp->trace_refractions=1;else plp->trace_refractions=0;
02297 if(SendDlgItemMessage(hdlg,RD_TRACE_OPT_PARTITION,BM_GETCHECK,0,0))
02298 plp->trace_partition=1; else plp->trace_partition=0;
02299 result=GetDlgItemInt(hdlg,RD_TRACE_OPT_DEPTH,&err,FALSE);
02300 if(err)plp->trace_depth=result;
02301 result=GetDlgItemInt(hdlg,RD_TRACE_OPT_THRESHOLD,&err,FALSE);
02302 if(err)plp->trace_face_count_target=result;
02303 result=GetDlgItemInt(hdlg,RD_TRACE_OPT_SIZE,&err,FALSE);
02304 if(err)plp->trace_voxel_min_size=result;
02305 plp->trace_depth=max(3,min(20,plp->trace_depth));
02306 plp->trace_face_count_target=max(2,min(1000,plp->trace_face_count_target));
02307 plp->trace_voxel_min_size=max(1,min(128,plp->trace_voxel_min_size));
02308 break;
02309 default: break;
02310 }
02311 return( FALSE );
02312 }
02313
02314 static BOOL CALLBACK TabbedDlgProc(HWND hdlg, UINT msg, WPARAM wparam,
02315 LPARAM lparam ){
02316 char text_string[512];
02317 switch( msg ){
02318 case WM_INITDIALOG:{
02319 TC_ITEM tie;
02320 RECT rc,rd;
02321 int h,w;
02322 DWORD dwDlgBase=GetDialogBaseUnits();
02323 lpDlgHdr=&DlgHdr;
02324 GetWindowRect(hdlg,&rc);
02325
02326 GetWindowRect(GetDlgItem(hdlg,IDOK),&rd);
02327
02328 h=rd.bottom-rc.top;
02329 w=rd.left-rc.left;
02330 GetClientRect(hdlg,&rc);
02331 hwndTab=CreateWindow(WC_TABCONTROL," ",
02332 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
02333 (D_BORDER*LOWORD(dwDlgBase))/4,
02334 (D_BORDER*HIWORD(dwDlgBase))/8,
02335
02336 w-(2*D_BORDER*LOWORD(dwDlgBase))/4,
02337
02338 h+(2*D_BORDER*HIWORD(dwDlgBase))/8,
02339 hdlg,NULL,hThisInstance,NULL);
02340 LoadString(hThisInstance,IDX_MISC_LANGUAGE,
02341 text_string,sizeof(text_string));
02342 if(strcmp(text_string,"ENGLISH") == 0)
02343 SendMessage(hwndTab,WM_SETFONT,
02344 (WPARAM)GetStockObject(ANSI_VAR_FONT),0);
02345 memset(&tie,0,sizeof(TC_ITEM));
02346 tie.mask = TCIF_TEXT | TCIF_IMAGE;
02347 tie.iImage = -1;
02348 tie.pszText=text_string;
02349 LoadString(hThisInstance,IDX_MISC_TAB_CONTROL,
02350 text_string,sizeof(text_string));
02351 TabCtrl_InsertItem(hwndTab,0,&tie);
02352 LoadString(hThisInstance,IDX_MISC_TAB_OPTIONS,
02353 text_string,sizeof(text_string));
02354 TabCtrl_InsertItem(hwndTab,1,&tie);
02355 LoadString(hThisInstance,IDX_MISC_TAB_SETTINGS,
02356 text_string,sizeof(text_string));
02357 TabCtrl_InsertItem(hwndTab,2,&tie);
02358 #ifdef TRACER
02359 LoadString(hThisInstance,IDX_MISC_TAB_TRACING,
02360 text_string,sizeof(text_string));
02361 TabCtrl_InsertItem(hwndTab,3,&tie);
02362 #endif
02363 SetRectEmpty(&rc);
02364 TabCtrl_AdjustRect(hwndTab,FALSE,&rc);
02365 rc.left += (D_BORDER*LOWORD(dwDlgBase))/4;
02366 rc.top += (D_BORDER*HIWORD(dwDlgBase))/8;
02367 CopyRect(&(lpDlgHdr->rcTab),&rc);
02368 lpDlgHdr->hwndDlgControl=NULL;
02369 lpDlgHdr->hwndDlgOptions=NULL;
02370 lpDlgHdr->hwndDlgSettings=NULL;
02371 lpDlgHdr->hwndDlgTracing=NULL;
02372 lpDlgHdr->hwndDlgControl=CreateDialog(hResourceInstance,
02373 MAKEINTRESOURCE(DLG_TAB_CONTROL),
02374 hdlg,(DLGPROC)TabbedDlgProcControl);
02375 SetWindowPos(lpDlgHdr->hwndDlgControl,NULL,
02376 lpDlgHdr->rcTab.left,lpDlgHdr->rcTab.top,0,0,
02377 SWP_NOSIZE | SWP_NOZORDER);
02378 SendMessage(lpDlgHdr->hwndDlgControl,WM_COMMAND,IDC_FRAMESET,0);
02379 ShowWindow(lpDlgHdr->hwndDlgControl,SW_SHOW);
02380 }
02381 return TRUE;
02382 case WM_NOTIFY:
02383 if( ((LPNMHDR)lparam)->code == TCN_SELCHANGING){
02384 int id=TabCtrl_GetCurSel(hwndTab);
02385 }
02386 if( ((LPNMHDR)lparam)->code == TCN_SELCHANGE){
02387 int id=TabCtrl_GetCurSel(hwndTab);
02388 if(lpDlgHdr->hwndDlgControl != NULL){
02389 TabCheckOk=FALSE;
02390 DestroyWindow(lpDlgHdr->hwndDlgControl);
02391 lpDlgHdr->hwndDlgControl=NULL;
02392 if(!TabCheckOk){
02393 TabCtrl_SetCurSel(hwndTab,0);
02394 id=0;
02395 }
02396 }
02397 if(lpDlgHdr->hwndDlgOptions != NULL){
02398 DestroyWindow(lpDlgHdr->hwndDlgOptions);
02399 lpDlgHdr->hwndDlgOptions=NULL;
02400 }
02401 if(lpDlgHdr->hwndDlgSettings != NULL){
02402 DestroyWindow(lpDlgHdr->hwndDlgSettings);
02403 lpDlgHdr->hwndDlgSettings=NULL;
02404 }
02405 if(lpDlgHdr->hwndDlgTracing != NULL){
02406 DestroyWindow(lpDlgHdr->hwndDlgTracing);
02407 lpDlgHdr->hwndDlgTracing=NULL;
02408 }
02409 if(id == 0){
02410 lpDlgHdr->hwndDlgControl=CreateDialog(hResourceInstance,
02411 MAKEINTRESOURCE(DLG_TAB_CONTROL),
02412 hdlg,(DLGPROC)TabbedDlgProcControl);
02413 SetWindowPos(lpDlgHdr->hwndDlgControl,NULL,
02414 lpDlgHdr->rcTab.left,lpDlgHdr->rcTab.top,0,0,
02415 SWP_NOSIZE | SWP_NOZORDER);
02416 SendMessage(lpDlgHdr->hwndDlgControl,WM_COMMAND,IDC_FRAMESET,0);
02417 ShowWindow(lpDlgHdr->hwndDlgControl,SW_SHOW);
02418 }
02419 else if(id == 1){
02420 lpDlgHdr->hwndDlgOptions=CreateDialog(hResourceInstance,
02421 MAKEINTRESOURCE(DLG_TAB_OPTIONS),
02422 hdlg,(DLGPROC)TabbedDlgProcOptions);
02423 SetWindowPos(lpDlgHdr->hwndDlgOptions,NULL,
02424 lpDlgHdr->rcTab.left,lpDlgHdr->rcTab.top,0,0,
02425 SWP_NOSIZE | SWP_NOZORDER);
02426 ShowWindow(lpDlgHdr->hwndDlgOptions,SW_SHOW);
02427 }
02428 else if(id == 2){
02429 lpDlgHdr->hwndDlgSettings=CreateDialog(hResourceInstance,
02430 MAKEINTRESOURCE(DLG_TAB_SETTINGS),
02431 hdlg,(DLGPROC)TabbedDlgProcSettings);
02432 SetWindowPos(lpDlgHdr->hwndDlgSettings,NULL,
02433 lpDlgHdr->rcTab.left,lpDlgHdr->rcTab.top,0,0,
02434 SWP_NOSIZE | SWP_NOZORDER);
02435 ShowWindow(lpDlgHdr->hwndDlgSettings,SW_SHOW);
02436 }
02437 #ifdef TRACER
02438 else if(id == 3){
02439 lpDlgHdr->hwndDlgTracing=CreateDialog(hResourceInstance,
02440 MAKEINTRESOURCE(DLG_TAB_TRACING),
02441 hdlg,(DLGPROC)TabbedDlgProcTracing);
02442 SetWindowPos(lpDlgHdr->hwndDlgTracing,NULL,
02443 lpDlgHdr->rcTab.left,lpDlgHdr->rcTab.top,0,0,
02444 SWP_NOSIZE | SWP_NOZORDER);
02445 ShowWindow(lpDlgHdr->hwndDlgTracing,SW_SHOW);
02446 }
02447 #endif
02448 }
02449 break;
02450 case WM_COMMAND:
02451 switch( LOWORD(wparam) ){
02452 case RD_CONTROL_HELP:{
02453 char lname[256],res_str1[256],res_str2[256];
02454 LoadString(hThisInstance,IDX_MISC_HELPFILENAME,
02455 text_string,sizeof(text_string));
02456 strcpy(lname,gszHomeDir); strcat(lname,"help\\");
02457 strcpy(res_str1,lname);
02458 #if !__HELP_WS__
02459 strcat(res_str1,text_string);
02460 ShellExecute(hdlg,NULL,res_str1,
02461 NULL,lname,SW_SHOW);
02462 #else
02463 {
02464 HH_WINTYPE hhwin;
02465 memset(&hhwin,0,sizeof(HH_WINTYPE));
02466 hhwin.cbStruct=sizeof(HH_WINTYPE);
02467 LoadString(hThisInstance,IDX_MISC_HELPTITLE1,text_string,256);
02468 hhwin.pszCaption=text_string;
02469 hhwin.nShowState=SW_SHOW;
02470 hhwin.pszType="MyHelp";
02471 hhwin.fsValidMembers = HHWIN_PARAM_SHOWSTATE |
02472 HHWIN_PARAM_PROPERTIES|
02473 HHWIN_PARAM_CUR_TAB|
02474 HHWIN_PARAM_EXPANSION|
02475 HHWIN_PARAM_RECT;
02476 hhwin.rcWindowPos.top=0;
02477 hhwin.rcWindowPos.left=0;
02478 hhwin.rcWindowPos.right=750;
02479 hhwin.rcWindowPos.bottom=500;
02480 hhwin.nShowState=SW_SHOW;
02481 strcat(res_str1,"rnd_help.chm");
02482 hhwin.fNotExpanded = FALSE;
02483 hhwin.fsWinProperties = HHWIN_PROP_TRI_PANE|
02484 !HHWIN_PROP_POST_QUIT|
02485 HHWIN_PROP_TAB_SEARCH;
02486 hhwin.curNavType=HHWIN_NAVTYPE_TOC;
02487 strcpy(res_str2,res_str1);
02488 strcat(res_str2,"::toc.hhc");
02489 hhwin.pszToc=res_str2;
02490 strcat(res_str1,"::/render_overview.htm");
02491 HtmlHelp(hdlg,NULL,HH_SET_WIN_TYPE,(DWORD)&hhwin);
02492 HtmlHelp(hdlg,">MyHelp",HH_DISPLAY_TOPIC,(DWORD)res_str1);
02493 }
02494 #endif
02495 }
02496 break;
02497 case IDC_FRAMESET:
02498 if(lpDlgHdr->hwndDlgControl != NULL)
02499 SendMessage(lpDlgHdr->hwndDlgControl,WM_COMMAND,IDC_FRAMESET,0);
02500 break;
02501 case IDCANCEL:
02502 SendMessage(hwndMain,WM_COMMAND,MENU_FILE_EXIT,0);
02503 break;
02504 case RD_CONTROL_RENDERGL:
02505 plp->bUseOpenGLrender=TRUE;
02506 case IDOK:
02507 TabCheckOk=FALSE;
02508 if(lpDlgHdr->hwndDlgControl != NULL)
02509 SendMessage(lpDlgHdr->hwndDlgControl,WM_RSF_GETSTATUS,0,0);
02510 else TabCheckOk=TRUE;
02511 if(lpDlgHdr->hwndDlgOptions != NULL)
02512 SendMessage(lpDlgHdr->hwndDlgOptions,WM_RSF_GETSTATUS,0,0);
02513 if(lpDlgHdr->hwndDlgSettings != NULL)
02514 SendMessage(lpDlgHdr->hwndDlgSettings,WM_RSF_GETSTATUS,0,0);
02515 if(lpDlgHdr->hwndDlgTracing != NULL)
02516 SendMessage(lpDlgHdr->hwndDlgTracing,WM_RSF_GETSTATUS,0,0);
02517 if(TabCheckOk)PostMessage(hwndMain,WM_COMMAND,MENU_FILE_START,0);
02518 break;
02519 default:
02520 break;
02521 }
02522 break;
02523 case WM_DESTROY:
02524 break;
02525 default: break;
02526 }
02527 return( FALSE );
02528 }
02529
02530 static void PaintDialogBackground(HWND hDlg, HINSTANCE hInst){
02531 int x;
02532 int y;
02533 HDC hDC;
02534 HPALETTE hpalT;
02535 HBRUSH hOldBrush;
02536 RECT rc1,rc2;
02537 HDC hMemDC;
02538 HBITMAP hBmBackground,hbmOld;
02539 BITMAP bm;
02540 PAINTSTRUCT ps;
02541
02542 return;
02543
02544 hDC = BeginPaint(hDlg,&ps);
02545 hBmBackground=LoadBitmap(hInst,MAKEINTRESOURCE(IDBM_BACKGROUND));
02546 if(hBmBackground != NULL){
02547 GetObject(hBmBackground,sizeof(BITMAP),&bm);
02548 hMemDC = CreateCompatibleDC(hDC);
02549 hbmOld = SelectObject(hMemDC,hBmBackground);
02550 GetClientRect(hDlg,&rc2);
02551 for(x=0;x<(rc2.right/bm.bmWidth)+1;x++)
02552 for(y=0;y<(rc2.bottom/bm.bmHeight)+1;y++)
02553 BitBlt(hDC,
02554 x*bm.bmWidth,y*bm.bmHeight,
02555 bm.bmWidth,
02556 bm.bmHeight,
02557 hMemDC,
02558 0,0,
02559 SRCCOPY);
02560 SelectObject(hMemDC,hbmOld);
02561 DeleteDC(hMemDC);
02562 DeleteObject(hBmBackground);
02563 }
02564 EndPaint(hDlg,&ps);
02565 }
02566
02567
02568
02569 int GetRenderNTnewfile(char *name, char *rep_name){
02570 long i,l;
02571 OPENFILENAME ofn;
02572 char szDir[256],szFileTitle[256],szFilter[256];
02573 char szTitle[256],szFile[256];
02574 szFile[0]='\0';
02575 GetCurrentDirectory(sizeof(szDir),szDir);
02576 l=strlen(name);
02577 if(l > 3 && strnicmp((name+l-3),"mfx",3) == 0)strcpy(szFilter,"Model Files|*.mfx|");
02578 else strcpy(szFilter,"All file formats|*.bmp;*.gif;*.tga;*.cel;*.jpg;*.tif;*.png|");
02579 for(i=0;szFilter[i] != '\0';i++)if(szFilter[i] == '|')szFilter[i]='\0';
02580 memset(&ofn,0,sizeof(OPENFILENAME));
02581 ofn.lStructSize=sizeof(OPENFILENAME);
02582 ofn.hwndOwner=hwndMain;
02583 ofn.lpstrFilter=szFilter;
02584 ofn.nFilterIndex=1;
02585 ofn.lpstrFile=szFile;
02586 ofn.nMaxFile=sizeof(szFile);
02587 ofn.lpstrFileTitle=szFileTitle;
02588 ofn.nMaxFileTitle=sizeof(szFileTitle);
02589 ofn.lpstrInitialDir=szDir;
02590 sprintf(szTitle,"Replace %s",name);
02591 ofn.lpstrTitle=szTitle;
02592 ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
02593 if(GetOpenFileName(&ofn)){
02594 strcpy(rep_name,szFile);
02595 return 1;
02596 }
02597 return 0;
02598 }
02599
02600 static void GetNumberOfScriptFrames(void){
02601 char temp_str[80],tempfile[256];
02602 FILE *CF;
02603 strcpy(tempfile,plp->scr_dir);
02604 strcat(tempfile,"\\");
02605 strcat(tempfile,plp->scr_file);
02606 frames=9999; current_frame=1;
02607 first_frame=1; last_frame=frames;
02608 if((CF=fopen((char *)strlwr(tempfile),"r")) == NULL)return;
02609 fscanf(CF,"%s",temp_str);
02610 if(temp_str[0] == 'R')fscanf(CF,"%ld",&frames);
02611 else fscanf(CF,"%s",temp_str);
02612 first_frame=1; last_frame=frames;
02613 fclose(CF);
02614 }
02615
02616 static int SelectFileName(int save, char *szfile, char *szdir,
02617 char *szTitle, char *szfilter, HWND parent){
02618 int i;
02619 OPENFILENAME ofn;
02620 char szFilter[80],szdummy[MAX_FILE];
02621 szdummy[0]='\0';
02622 strcpy(szFilter,szfilter);
02623 i=0; while(szFilter[i] != '\0'){
02624 if(szFilter[i] == '|')szFilter[i]='\0'; i++;
02625 }
02626 memset(&ofn,0,sizeof(OPENFILENAME));
02627 ofn.lStructSize=sizeof(OPENFILENAME);
02628 ofn.hwndOwner=parent;
02629 ofn.lpstrFilter=szFilter;
02630 ofn.nFilterIndex=1;
02631 ofn.lpstrFile=szfile;
02632 ofn.nMaxFile=MAX_FILE;
02633 ofn.lpstrFileTitle=szdummy;
02634 ofn.nMaxFileTitle=MAX_FILE;
02635 ofn.lpstrInitialDir=szdir;
02636 ofn.lpstrTitle=szTitle;
02637 if(save){
02638 ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST;
02639 i=(int)(GetSaveFileName(&ofn));
02640 }
02641 else{
02642 ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
02643 i=(int)(GetOpenFileName(&ofn));
02644 }
02645 if(i){
02646 strcpy(szdummy,szfile);
02647 *AnsiPrev(szdummy,FileInPath(szdummy)) = '\0';
02648 strcpy(szdir,szdummy);
02649 }
02650 return i;
02651 }
02652
02653 static int SelectDirectoryName(char *szfile, char *szdir,
02654 char *szTitle, char *szfilter,
02655 HWND parent){
02656 int i;
02657 OPENFILENAME ofn;
02658 char szFilter[80],szdummy[MAX_FILE];
02659 szdummy[0]='\0';
02660 strcpy(szFilter,szfilter);
02661 i=0; while(szFilter[i] != '\0'){
02662 if(szFilter[i] == '|')szFilter[i]='\0'; i++;
02663 }
02664 memset(&ofn,0,sizeof(OPENFILENAME));
02665 ofn.lStructSize=sizeof(OPENFILENAME);
02666 ofn.hwndOwner=parent;
02667 ofn.lpstrFilter=szFilter;
02668 ofn.nFilterIndex=1;
02669 ofn.lpstrFile=szfile;
02670 ofn.nMaxFile=MAX_FILE;
02671 ofn.lpstrFileTitle=szdummy;
02672 ofn.nMaxFileTitle=MAX_FILE;
02673 ofn.lpstrInitialDir=szdir;
02674 ofn.lpstrTitle=szTitle;
02675 ofn.hInstance=hResourceInstance;
02676 ofn.lpfnHook=NULL;
02677 ofn.lpTemplateName="DIRECTORYOPEN";
02678 ofn.Flags=OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|
02679 OFN_ENABLETEMPLATE|OFN_NONETWORKBUTTON|
02680 OFN_NOTESTFILECREATE;
02681 i=(int)(GetSaveFileName(&ofn));
02682 if(i){
02683 strcpy(szdummy,szfile);
02684 *AnsiPrev(szdummy,FileInPath(szdummy)) = '\0';
02685 strcpy(szdir,szdummy);
02686 }
02687 return i;
02688 }
02689
02690 static char WIN32_environment[512];
02691
02692 char *R_GetEnv(char const *aa){
02693 if(GetEnvironmentVariable((LPTSTR)aa,(LPTSTR)WIN32_environment,256) == 0)
02694 return NULL;
02695 return WIN32_environment;
02696 }
02697
02698 static int BuildAnimation(char *root, long avi_fli, long avi_low, long avi_compress){
02699 char lname[256],fname[256],function[32];
02700 HMODULE hLibFlx=NULL;
02701 FARPROC fpFun;
02702 long l,result=0;
02703 int rval=0;
02704 int nCOLOUR;
02705 int (*fpBuildFli)(
02706 HWND parent_window,HWND status_window,
02707 int range_f, int range_l,
02708 char *flic_file,
02709 char *stem_file,
02710 int ResolutionX,int ResolutionY,
02711 int nCOLOUR, long speed, long tzeros,
02712 unsigned long *cstats0,unsigned short *cstats1
02713 );
02714 WindowedRenderMessage(WRM_BUILDANIM);
02715 nCOLOUR=NOCOLOUR;
02716 fpBuildFli=NULL;
02717 strcpy(lname,gszHomeDir);
02718 if(avi_fli == 1){
02719 if(avi_low == 1)strcat(lname,"avi_dll.dll");
02720 else{
02721 strcat(lname,"avi24_dll.dll");
02722 if(avi_compress)nCOLOUR=1;
02723 else nCOLOUR=0;
02724 }
02725 strcpy(function,"_BuildAvi");
02726 }
02727 else if(avi_fli == 2){
02728 strcat(lname,"gif_dll.dll");
02729 strcpy(function,"_BuildGif");
02730 }
02731 else{
02732 strcat(lname,"flic_dll.dll");
02733 strcpy(function,"_BuildFli");
02734 }
02735 strcpy(fname,plp->fli_dir);
02736 l=strlen(plp->fli_dir);
02737 if(*(plp->fli_dir+l-1) != '\\')strcat(fname,"\\");
02738 strcat(fname,plp->fli_file);
02739 if(strrchr(fname,'.') != NULL)*strrchr(fname,'.')='\0';
02740 if(avi_fli == 1)strcat(fname,".avi");
02741 else if(avi_fli == 2)strcat(fname,".gif");
02742 else {
02743 if(plp->xres <= 320 && plp->yres <= 200)strcat(fname,".fli");
02744 else strcat(fname,".flc");
02745 }
02746 if(avi_fli == 1){
02747 hLibFlx=LoadLibrary(lname);
02748 }
02749 else{
02750 hLibFlx=LoadLibrary(lname);
02751 }
02752 if(hLibFlx != NULL){
02753 if((fpFun=GetProcAddress(hLibFlx,function)) != NULL){
02754 fpBuildFli = (int ( *)(
02755 HWND, HWND,
02756 int, int,
02757 char *,
02758 char *,
02759 int, int,
02760 int, long, long,
02761 unsigned long *,unsigned short *))fpFun;
02762
02763 if(plp->bRenderStereo)
02764 rval=(*fpBuildFli)(hwndMain,hwndstatus,
02765 (int)first_frame,(int)(first_frame+frame_counter/2),
02766 fname,
02767 root,
02768 (int)plp->xres,(int)plp->yres*2,
02769 nCOLOUR,(long)plp->speed,(long)plp->tzeros,
02770 colorstats0,colorstats1);
02771 else
02772 rval=(*fpBuildFli)(hwndMain,hwndstatus,
02773 (int)first_frame,(int)(first_frame+frame_counter-1),
02774 fname,
02775 root,
02776 (int)plp->xres,(int)plp->yres,
02777 nCOLOUR,(long)plp->speed,(long)plp->tzeros,
02778 colorstats0,colorstats1);
02779 }
02780 else{
02781 MessageBox(GetFocus(),
02782 (LPCTSTR) "Failed to get Animation Function",
02783 (LPCTSTR) "",
02784 MB_OK | MB_SYSTEMMODAL );
02785 FreeLibrary(hLibFlx);
02786 return 0;
02787 }
02788
02789 FreeLibrary(hLibFlx);
02790 }
02791 else {
02792 MessageBox(GetFocus(),
02793 (LPCTSTR) lname,
02794 (LPCTSTR) "Failed to load the Flics Library",
02795 MB_OK | MB_SYSTEMMODAL );
02796 return 0;
02797 }
02798 return rval;
02799 }
02800
02801 static void PlayAnimation(char *root, long avi_fli){
02802 HWND hWndPlayer;
02803 char modulename[256],fname[256],classname[256];
02804 long l;
02805 strcpy(fname,plp->fli_dir);
02806 l=strlen(plp->fli_dir);
02807 if(*(plp->fli_dir+l-1) != '\\')strcat(fname,"\\");
02808 strcat(fname,plp->fli_file);
02809 if(strrchr(fname,'.') != NULL)*strrchr(fname,'.')='\0';
02810 if(avi_fli == 0){
02811 sprintf(modulename,"%swinplay",gszHomeDir);
02812 if(plp->xres <= 320 && plp->yres <= 200)strcat(fname,".fli");
02813 else strcat(fname,".flc");
02814 strcpy(classname,"OFX:FLCPlayer");
02815 }
02816 else if(avi_fli == 1){
02817 strcat(fname,".avi");
02818
02819
02820 sprintf(modulename,"%sofxmediaplayer %s",gszHomeDir,fname);
02821 strcpy(classname,"OFX:MediaPlayerClass");
02822 WinExec(modulename,SW_SHOW);
02823 return;
02824
02825 }
02826 else return;
02827 WritePrivateProfileString("PLAYER","FILE",fname,IniFilename);
02828 if((hWndPlayer = FindWindow(classname,NULL)) == NULL){
02829 WinExec(modulename,SW_SHOW);
02830 }
02831 if((hWndPlayer = FindWindow(classname,NULL)) == NULL)return;
02832
02833 PostMessage(hWndPlayer,(WM_USER+1),0,0);
02834 return;
02835 }
02836
02837 static void DisplayOutputFile(void){
02838 HWND hWndViewer;
02839 char modulename[256],filename[256],pathname[256];
02840 long l;
02841 if(plp->bRenderStereo > 0)return;
02842 sprintf(modulename,"%swinview",gszHomeDir);
02843 if (plp->ot == 0)sprintf(filename,"%s.bmp",plp->pic_file);
02844 else if(plp->ot == 2)sprintf(filename,"%s.jpg",plp->pic_file);
02845 else if(plp->ot == 3)sprintf(filename,"%s.png",plp->pic_file);
02846 else if(plp->ot == 4)sprintf(filename,"%s.tif",plp->pic_file);
02847 else if(plp->ot == 5)sprintf(filename,"%s.bmp",plp->pic_file);
02848 l=strlen(plp->pic_dir);
02849 if(*(plp->pic_dir+l-1) == '\\')sprintf(pathname,"%s",plp->pic_dir);
02850 else sprintf(pathname,"%s\\",plp->pic_dir);
02851 WritePrivateProfileString("VIEWER","FILE",filename,IniFilename);
02852 WritePrivateProfileString("VIEWER","PATH",pathname,IniFilename);
02853 WinExec(modulename,SW_SHOW);
02854 if((hWndViewer = FindWindow("OFX:ViewClass",NULL)) == NULL)return;
02855 PostMessage(hWndViewer,WM_COMMAND,107,1);
02856 }
02857
02858
02859 int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
02860 LPSTR lpCmdLine, int nCmdShow){
02861 int rv;
02862 HWND hWndPrev;
02863 SYSTEM_INFO siSysInfo;
02864 hWndPrev = FindWindow(szRenderClass,NULL);
02865 if(hWndPrev != NULL){
02866 if(FindWindow("OFX:AnimatorClass",NULL) != NULL ||
02867 FindWindow("OFX:ModelerClass",NULL) != NULL){
02868 SetForegroundWindow(hWndPrev);
02869 BringWindowToTop(hWndPrev);
02870 ShowWindow (hWndPrev,SW_SHOW);
02871 return FALSE;
02872 }
02873 }
02874
02875 {
02876 FILE *fini=NULL; int ix;
02877 GetModuleFileName(hInstance,IniFilename,256);
02878 *FileInPath(IniFilename) = '\0';
02879 strcpy(TempPath,IniFilename);
02880 strcat(IniFilename,"OPENFX_.CFG");
02881 if((fini=fopen(IniFilename,"r")) != NULL){
02882 fscanf(fini,"%ld",&ix);
02883 strcpy(TempPath,"X");
02884 fscanf(fini," %[^\n]",TempPath);
02885 if(ix > 1){
02886 fscanf(fini," %[^\n]",IniFilename);
02887 }
02888 else *FileInPath(IniFilename) = '\0';
02889 fclose(fini);
02890 }
02891 else {
02892 char *pE;
02893 pE=R_GetEnv("TEMP");
02894 if(pE != NULL){
02895
02896 strcpy(TempPath,pE); strcat(TempPath,"\\");
02897 strcpy(IniFilename,TempPath);
02898 *FileInPath(TempPath) = '\0';
02899 }
02900 *FileInPath(IniFilename) = '\0';
02901 }
02902 strcat(IniFilename,"OPENFX_.INI");
02903 }
02904
02905
02906
02907 hInstance=ResourceX();
02908 InitCommonControls();
02909 AVIFileInit();
02910 GetSystemInfo(&siSysInfo); Nprocessors=siSysInfo.dwNumberOfProcessors;
02911 if(!FirstInstance(hInstance)) return FALSE;
02912 if(lpCmdLine == NULL)RendererStandAlone=1;
02913 else{
02914 if(strstr(lpCmdLine,"$SAL$") == NULL)RendererStandAlone=1;
02915 else RendererStandAlone=0;
02916 }
02917 RendererInUse=0;
02918 rv=RendererMainLoop(hInstance,1);
02919 AVIFileExit();
02920 return rv;
02921 }