00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include <stdlib.h>
00027 #include <stdio.h>
00028 #include <float.h>
00029 #include <math.h>
00030 #include <windows.h>
00031 #include <commctrl.h>
00032 #include "struct.h"
00033 #include "..\common\postprocess\ximage.h"
00034 #include "local.h"
00035
00036 #include "starfld.h"
00037
00038 #if __X__MIPS__
00039 BOOL WINAPI _CRT_INIT(HINSTANCE ,DWORD , LPVOID );
00040 #endif
00041
00042 static HINSTANCE hDLLinstance=NULL;
00043 static long version=1;
00044
00045 #include "utils.h"
00046
00047 #include "paint.c"
00048
00049 #if 0
00050 static double GetYint(double x, double y, double dx, double dy, double xe){
00051 double grad;
00052 grad=dy/dx;
00053 return grad*(xe-x)+y;
00054 }
00055
00056 static double GetXint(double x, double y, double dx, double dy, double ye){
00057 double grad;
00058 grad=dx/dy;
00059 return grad*(ye-y)+x;
00060 }
00061
00062 static void GetStarPosition(double mr, long xc, long yc,
00063 long Xmax, long Ymax,
00064 long *x, long *y){
00065 long dx,dy;
00066 double ddx,ddy,dxc,dyc,ye,xe,ds,de,fr;
00067 dx = *x - xc;
00068 dy = *y - yc;
00069 if(dx == 0 && dy == 0)dx=1;
00070 ddx=(double)dx; ddy=(double)dy;
00071 dxc=(double)xc; dyc=(double)yc;
00072 if(dx == 0){
00073 xe=xc;
00074 if(dy > 0)ye=(double)Ymax;
00075 else ye=0.0;
00076 }
00077 else if(dy == 0){
00078 ye=yc;
00079 if(dx < 0)xe=0.0;
00080 else xe=(double)Xmax;
00081 }
00082 else {
00083 if(dx > 0)xe=(double)Xmax;
00084 else xe=0.0;
00085 ye=GetYint(dxc,dyc,ddx,ddy,xe);
00086 if(ye < 0){
00087 xe=GetXint(dxc,dyc,ddx,ddy,0);
00088 ye=0.0;
00089 }
00090 else if(ye > Ymax){
00091 xe=GetXint(dxc,dyc,ddx,ddy,(double)Ymax);
00092 ye=(double)Ymax;
00093 }
00094 }
00095 ds=DIST(ddx,ddy);
00096 de=DIST(xe-dxc,ye-dyc);
00097 fr=frac(mr+ds/de);
00098 *x = xc+(long)((xe-dxc)*fr);
00099 *y = yc+(long)((ye-dyc)*fr);
00100 return;
00101 }
00102
00103 dmax=DIST(xc,yc);
00104 if((dc=DIST(Xmax-xc,yc)) > dmax)dmax=dc;
00105 if((dc=DIST(Xmax-xc,Ymax-yc)) > dmax)dmax=dc;
00106 if((dc=DIST(xc,Ymax-yc)) > dmax)dmax=dc;
00107 if(nstar > 0)for(i=0;i<nstar;i++){
00108 x=(long)((double)rand()*(double)Xmax/32767.0);
00109 y=(long)((double)rand()*(double)Ymax/32767.0);
00110 C=((double)rand()*(double)63/32767.0);
00111 GetStarPosition(mr,xc,yc,Xmax,Ymax,&x,&y);
00112 if((lpXimage->Screen+(long)y*Xmax+(long)x)->A == 0){
00113 dc=DIST(x-xc,y-yc);
00114 w=0.1+wmax*dc/dmax;
00115 DrawAApixel((double)x,(double)y,
00116 w,w,192+C,lpXimage->Screen,Xmax,Ymax,1.0,1.0,1.0);
00117 }
00118 }
00119 #endif
00120
00121 #if __WATCOMC__
00122 int APIENTRY LibMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00123 #elif __BC__
00124 BOOL WINAPI DllEntryPoint(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00125 #else
00126 BOOL WINAPI DllMain(HANDLE hDLL, DWORD dwReason, LPVOID lpReserved){
00127 #endif
00128 switch (dwReason) {
00129 case DLL_PROCESS_ATTACH:
00130 #if __X__MIPS__
00131 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00132 #endif
00133 hDLLinstance = hDLL;
00134 break;
00135 case DLL_PROCESS_DETACH:
00136 #if __X__MIPS__
00137 if(!_CRT_INIT(hDLL,dwReason,lpReserved))return(int)FALSE;
00138 #endif
00139 break;
00140 }
00141 return (int)TRUE;
00142 }
00143
00144 #if __SC__
00145 #pragma startaddress(DllMain)
00146 #endif
00147
00148
00149 void Hsv2Rgb(double h, double s, double v,
00150 double *r, double *g, double *b){
00151 double rr,gg,bb,hh,ss,vv,maxcol,mincol;
00152 hh=(double)h; ss=(double)s; vv=(double)v;
00153 mincol=vv*(1.0-ss);
00154 if(hh <= 120.0){bb=mincol;
00155 if(hh <= 60){rr=vv; gg=mincol+hh*(vv-mincol)/(120.0-hh);}
00156 else {gg=vv; rr=mincol+(120.0-hh)*(vv-mincol)/hh;}
00157 }
00158 else if( hh <= 240){rr=mincol;
00159 if(hh <= 180){gg=vv; bb=mincol+(hh-120.0)*(vv-mincol)/(240.0-hh);}
00160 else {bb=vv; gg=mincol+(240.0-hh)*(vv-mincol)/(hh-120.0);}
00161 }
00162 else {gg=mincol;
00163 if(hh <= 300){bb=vv; rr=mincol+(hh-240.0)*(vv-mincol)/(360.0-hh);}
00164 else {rr=vv; bb=mincol+(360.0-hh)*(vv-mincol)/(hh-240.0);}
00165 }
00166 *r = rr;
00167 *g = gg;
00168 *b = bb;
00169 }
00170
00171 static void DrawInBuffer1(long x, long y, fullscreenbuffer *Screen,
00172 long X, long Y, long radius,
00173 double r, double g, double b){
00174
00175 long i,j;
00176 double d;
00177 fullscreenbuffer *S;
00178 for(i=x-radius;i<=x+radius;i++)for(j=y-radius;j<=y+radius;j++){
00179 if(i < 0 || i >= X || j < 0 || j >= Y)continue;
00180 S=(Screen + j*X + i);
00181 if(radius < 1)d=1.0;
00182 else{
00183 d=sqrt((double)(i-x)*(double)(i-x) + (double)(j-y)*(double)(j-y));
00184 d=255.0*((double)radius-d)/(double)radius;
00185 d=max(0.0,d);
00186 }
00187 S->R = (unsigned char)min(255.0,(double)S->R+d*r);
00188 S->G = (unsigned char)min(255.0,(double)S->G+d*g);
00189 S->B = (unsigned char)min(255.0,(double)S->B+d*b);
00190 }
00191 return;
00192 }
00193
00194 void DrawInBuffer(fullscreenbuffer *Screen, int Xmax, int Ymax,
00195 int x, int y, double v,
00196 double rr, double gg, double bb){
00197 int r,g,b;
00198 fullscreenbuffer *S;
00199 if(x < 0 || y < 0 || x >= Xmax || y >= Ymax)return;
00200 S=(Screen+y*Xmax+x);
00201 r=(int)S->R+(int)((double)v*rr);
00202 g=(int)S->G+(int)((double)v*gg);
00203 b=(int)S->B+(int)((double)v*bb);
00204 S->R=(r>255) ? 255:r;
00205 S->G=(g>255) ? 255:g;
00206 S->B=(b>255) ? 255:b;
00207 }
00208
00209 #define DIST(i,j) sqrt((double)(i) * (double)(i) + (double)(j) * (double)(j))
00210
00211 #define frac(z) fmod(z,1.0)
00212
00213 void DrawAApixel(double x, double y, double w, double h, double C,
00214 fullscreenbuffer *S, int X, int Y,
00215 double r, double g, double b){
00216 int xa,xb,ya,yb,i,j,brite;
00217 double x2,y2,lfrac,rfrac,tfrac,bfrac,xfrac,yfrac;
00218
00219 if(w > 4 || h > 4){
00220 DrawInBuffer1((long)x,(long)y,S,X,Y,(long)w,r,g,b);
00221 return;
00222 }
00223 brite=(int)C;
00224 if(x < 0 || y < 0)return;
00225 x -= w*0.5; y -= h*0.5;
00226 x2 = x + w;
00227 y2 = y + w;
00228 xa = (int)x;
00229 xb = (int)x2;
00230 ya = (int)y;
00231 yb = (int)y2;
00232 lfrac = 1.0-frac(x);
00233 rfrac = frac(x2);
00234 tfrac = 1.0-frac(y);
00235 bfrac = frac(y2);
00236 if (xa==xb) {
00237 xfrac = lfrac+rfrac-1.0;
00238 if (ya==yb) {
00239 DrawInBuffer(S,X,Y,xa,ya,xfrac*(tfrac+bfrac-1.0)*brite,r,g,b);
00240 }
00241 else {
00242 DrawInBuffer(S,X,Y,xa,ya,xfrac*tfrac*brite,r,g,b);
00243 for (j=ya+1; j<yb; j++) DrawInBuffer(S,X,Y,xa,j,xfrac*brite,r,g,b);
00244 DrawInBuffer(S,X,Y,xa,yb,xfrac*bfrac*brite,r,g,b);
00245 }
00246 }
00247 else {
00248 if (ya==yb) {
00249 yfrac = tfrac+bfrac-1.0;
00250 DrawInBuffer(S,X,Y,xa,ya,yfrac*lfrac*brite,r,g,b);
00251 for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,ya,yfrac*brite,r,g,b);
00252 DrawInBuffer(S,X,Y,xb,ya,yfrac*rfrac*brite,r,g,b);
00253 }
00254 else {
00255 DrawInBuffer(S,X,Y,xa,ya,tfrac*lfrac*brite,r,g,b);
00256 for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,ya,tfrac*brite,r,g,b);
00257 DrawInBuffer(S,X,Y,xb,ya,tfrac*rfrac*brite,r,g,b);
00258 for (j=ya+1; j<yb; j++) {
00259 DrawInBuffer(S,X,Y,xa,j,lfrac*brite,r,g,b);
00260 for (i=xa+1; i<xb; i++)DrawInBuffer(S,X,Y,i,j,brite,r,g,b);
00261 DrawInBuffer(S,X,Y,xb,j,rfrac*brite,r,g,b);
00262 }
00263 DrawInBuffer(S,X,Y,xa,yb,bfrac*lfrac*brite,r,g,b);
00264 for (i=xa+1; i<xb; i++) DrawInBuffer(S,X,Y,i,yb,bfrac*brite,r,g,b);
00265 DrawInBuffer(S,X,Y,xb,yb,bfrac*rfrac*brite,r,g,b);
00266 }
00267 }
00268 }
00269
00270 static double GetW(double l, double dx, double dy,
00271 double Wmin, double Wmax,
00272 BOOL linear){
00273 double d,f;
00274 d=DIST(dx,dy);
00275 f=d/l;
00276 return (Wmax-(Wmax-Wmin)*f);
00277 }
00278
00279 static double GetC(double l, double dx, double dy,
00280 double Wmin, double Wmax,
00281 BOOL linear){
00282 double d,f;
00283 d=DIST(dx,dy);
00284 f=d/l;
00285 if(f < 0.5)return Wmax;
00286 return (Wmin+(Wmax-Wmin)*2.0*(1.0-f));
00287 }
00288
00289 static void DrawFlareInBuffer(long x, long y, long idx, long idy,
00290 fullscreenbuffer *Screen,
00291 long X, long Y,
00292 double Cin,
00293 double r, double g, double b,
00294 double Wmin, double Wmax,
00295 BOOL linear){
00296 long i,j;
00297 double grad,error,W,l,C;
00298 C=Cin;
00299 l=DIST(idx,idy);
00300 if(abs(idx) >= abs(idy)){
00301 grad=(double)idy/(double)idx; j=y;
00302 if(idy >= 0)error = -0.5; else error = 0.5;
00303 if(idx >= 0){
00304 for(i=x;i<x+idx;i++){
00305 error += grad;
00306 if(idy >= 0){
00307 if(error > 0.0){j++; error -= 1.0;}
00308 }
00309 else{
00310 if(error < 0.0){j--; error += 1.0;}
00311 }
00312 W=GetW(l,(double)(i-x),(double)(j-y),Wmin,Wmax,linear);
00313 if(!linear)C=GetC(l,(double)(i-x),(double)(j-y),Cin*0.25,Cin,TRUE);
00314 DrawAApixel((double)i,(double)j,W,W,C,Screen,X,Y,r,g,b);
00315 }
00316 }
00317 else{
00318 for(i=x;i>x+idx;i--){
00319 error -= grad;
00320 if(idy >= 0){
00321 if(error > 0.0){j++; error -= 1.0;}
00322 }
00323 else{
00324 if(error < 0.0){j--; error += 1.0;}
00325 }
00326 W=GetW(l,(double)(i-x),(double)(j-y),Wmin,Wmax,linear);
00327 if(!linear)C=GetC(l,(double)(i-x),(double)(j-y),Cin*0.25,Cin,TRUE);
00328 DrawAApixel((double)i,(double)j,W,W,C,Screen,X,Y,r,g,b);
00329 }
00330 }
00331 }
00332 else{
00333 grad=(double)idx/(double)idy; j=x;
00334 if(idx >= 0)error = -0.5; else error = 0.5;
00335 if(idy >= 0){
00336 for(i=y;i<y+idy;i++){
00337 error += grad;
00338 if(idx >= 0){
00339 if(error > 0.0){j++; error -= 1.0;}
00340 }
00341 else{
00342 if(error < 0.0){j--; error += 1.0;}
00343 }
00344 W=GetW(l,(double)(j-x),(double)(i-y),Wmin,Wmax,linear);
00345 if(!linear)C=GetC(l,(double)(j-x),(double)(i-y),Cin*0.25,Cin,TRUE);
00346 DrawAApixel((double)j,(double)i,W,W,C,Screen,X,Y,r,g,b);
00347 }
00348 }
00349 else{
00350 for(i=y;i>y+idy;i--){
00351 error -= grad;
00352 if(idx >= 0){
00353 if(error > 0.0){j++; error -= 1.0;}
00354 }
00355 else{
00356 if(error < 0.0){j--; error += 1.0;}
00357 }
00358 W=GetW(l,(double)(j-x),(double)(i-y),Wmin,Wmax,linear);
00359 if(!linear)C=GetC(l,(double)(j-x),(double)(i-y),Cin*0.25,Cin,TRUE);
00360 DrawAApixel((double)j,(double)i,W,W,C,Screen,X,Y,r,g,b);
00361 }
00362 }
00363 }
00364 return;
00365 }
00366
00367 long _RenderImageProcess(char *PrmList, XIMAGE *lpXimage){
00368 int i,j,nstar,nback,type,multic,xc,yc,Xmax,Ymax,accel,trails,cycles,scale;
00369 char dummy[255];
00370 double x,y,z,zt,xt,yt,Zmax;
00371 double mr,C,w,wmax=2.5;
00372 double r=1.0,g=1.0,b=1.0,h,s;
00373 #include "pro_key.c"
00374 sscanf(PrmList,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",dummy,&version,
00375 &nstar,&nback,&type,&multic,&xc,&scale,&accel,&trails,&cycles);
00376 mr=(double)(lpXimage->last_frame - lpXimage->first_frame)+1.0;
00377 mr /= (double)cycles;
00378 if(mr < 1.0)return 0;
00379 mr=(double)(lpXimage->this_frame - lpXimage->first_frame)/mr;
00380 mr=frac(mr);
00381 if(type == 1 || type == 4)mr=1.0-mr;
00382 wmax=wmax*(double)scale*0.01;
00383 Xmax=lpXimage->Xmax;
00384 Ymax=lpXimage->Ymax;
00385 xc=Xmax/2; yc=Ymax/2;
00386 if(nback > 0)for(i=0;i<nback;i++){
00387 x=(long)((double)rand()*(double)Xmax/32767.0);
00388 y=(long)((double)rand()*(double)Ymax/32767.0);
00389 C=((double)rand()*(double)63/32767.0);
00390 if((lpXimage->Screen+(long)y*Xmax+(long)x)->A == 0)
00391 DrawAApixel((double)x,(double)y,
00392 1.5,1.5,128+C,lpXimage->Screen,Xmax,Ymax,1.0,1.0,1.0);
00393 }
00394 if((type == 1 || type == 2) && nstar > 0){
00395 Zmax=10.0*(double)Xmax;
00396 for(i=0;i<nstar;i++){
00397 if(multic == 1){
00398 h=360.0*(double)rand()/32767.0;
00399 s=0.5+0.5*(double)rand()/32767.0;
00400 Hsv2Rgb(h,s,1.0,&r,&g,&b);
00401 }
00402 x=((double)rand()*4.0*(double)Xmax/32767.0)-2*(double)Xmax;
00403 y=((double)rand()*4.0*(double)Ymax/32767.0)-2*(double)Ymax;
00404 if(fabs(x) < Xmax/2 && fabs(y) < Ymax/2){
00405 nstar++;
00406 continue;
00407 }
00408 z=((double)rand()*Zmax/32767.0);
00409 z=fmod(z+mr*Zmax,Zmax);
00410 z+=Xmax;
00411 if(trails == 1){
00412 if(type == 1)zt=z+Xmax;
00413 if(type == 2)zt=z-Xmax;
00414 xt=x*(double)Xmax/zt+(double)Xmax/2;
00415 yt=y*(double)Xmax/zt+(double)Ymax/2;
00416 }
00417 C=((double)rand()*(double)63/32767.0);
00418 x=x*(double)Xmax/z+(double)Xmax/2;
00419 y=y*(double)Xmax/z+(double)Ymax/2;
00420 if(x >= 0 && x < Xmax && y >= 0 && y < Ymax &&
00421 (lpXimage->Screen+(long)y*Xmax+(long)x)->A == 0){
00422 w=0.2+wmax*(Zmax-z+Xmax)/Zmax;
00423 if(w < 3.0)DrawAApixel((double)x,(double)y,
00424 w,w,192+C,lpXimage->Screen,
00425 Xmax,Ymax,
00426 r,g,b);
00427 else DrawInBuffer1((long)x,(long)y,lpXimage->Screen,
00428 Xmax,Ymax,(long)w,
00429 r,g,b);
00430 if(trails == 1){
00431 DrawFlareInBuffer((long)x,(long)y,
00432 (long)(xt-x),(long)(yt-y),
00433 lpXimage->Screen,
00434 Xmax,Ymax,
00435 192+C,
00436 r,g,b,
00437 0.1,w,
00438 TRUE);
00439 }
00440 }
00441 }
00442 }
00443 if((type == 3 || type == 4) && nstar > 0){
00444 Zmax=4.0*(double)Xmax;
00445 wmax /= 2.0;
00446 for(i=0;i<nstar;i++){
00447 if(multic == 1){
00448 h=360.0*(double)rand()/32767.0;
00449 s=0.5+0.5*(double)rand()/32767.0;
00450 Hsv2Rgb(h,s,1.0,&r,&g,&b);
00451 }
00452 x=((double)rand()*4.0*(double)Xmax/32767.0);
00453 x=fmod(x+mr*4.0*(double)Xmax,4.0*(double)Xmax);
00454 x -= 2.0*(double)Xmax;
00455 y=((double)rand()*4.0*(double)Ymax/32767.0);
00456 y -= 2.0*(double)Ymax;
00457 z=((double)rand()*Zmax/32767.0);
00458 C=((double)rand()*(double)63/32767.0);
00459 x=x*(double)Xmax/z+(double)Xmax/2;
00460 y=y*(double)Xmax/z+(double)Ymax/2;
00461 if(x >= 0 && x < Xmax && y >= 0 && y < Ymax &&
00462 (lpXimage->Screen+(long)y*Xmax+(long)x)->A == 0){
00463 w=1.0+wmax*(Zmax-z)/Zmax;
00464 if(w < 3.0)DrawAApixel((double)x,(double)y,w,w,192+C,
00465 lpXimage->Screen,
00466 Xmax,Ymax,
00467 r,g,b);
00468 else DrawInBuffer1((long)x,(long)y,lpXimage->Screen,
00469 Xmax,Ymax,(long)w,
00470 r,g,b);
00471 if(trails == 1){
00472 if(type == 3)xt= -(double)Xmax*0.1;
00473 if(type == 4)xt= (double)Xmax*0.1;
00474 DrawFlareInBuffer((long)x,(long)y,
00475 (long)xt,0,
00476 lpXimage->Screen,
00477 Xmax,Ymax,
00478 192+C,
00479 r,g,b,
00480 0.1,w,
00481 TRUE);
00482
00483 }
00484 }
00485 }
00486 }
00487 return 1;
00488 }
00489
00490
00491
00492 long _RenderGLexternal(char *PrmList, XIMAGE *lpXimage){
00493 MessageBox(NULL,"OpenGL function called","OK",MB_OK);
00494 return 1;
00495 }
00496
00497
00498
00499 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00500
00501 static long nstar=100,nback=0,type=1,multic=0,xc=160,scale=100,accel=0,
00502 trails=0,cycles=1;
00503
00504 static X__MEMORY_MANAGER *lpLocalEVI;
00505
00506 char * _SetExternalParameters(
00507 char *Op,
00508 HWND hWnd,
00509 long ruler,
00510 char *name,
00511 X__MEMORY_MANAGER *lpEVI
00512 ){
00513 char buffer[256];
00514 if(Op != NULL){
00515 sscanf(Op,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",buffer,&version,
00516 &nstar,&nback,&type,&multic,&xc,&scale,&accel,&trails,&cycles);
00517 }
00518 lpLocalEVI=lpEVI;
00519 if(DialogBox(hDLLinstance,MAKEINTRESOURCE(DLG_STARFIELD),hWnd,
00520 (DLGPROC)DlgProc) == FALSE)return Op;
00521 if(Op != NULL)CALL_FREE(Op);
00522 sprintf(buffer,"%s %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld",name,version,
00523 nstar,nback,type,multic,xc,scale,accel,trails,cycles);
00524 if((Op=(char *)CALL_MALLOC(strlen(buffer)+1)) == NULL){
00525 MessageBox (GetFocus(),"Memory",NULL,MB_OK|MB_TASKMODAL|MB_ICONSTOP);
00526 return NULL;
00527 }
00528 strcpy(Op,buffer);
00529 return Op;
00530 }
00531
00532 static void LoadAnimatedClip(HWND hDlg){
00533 char *c,modname[256];
00534 GetModuleFileName(hDLLinstance,modname,255);
00535 if((c=strrchr(modname,'.')) != NULL){
00536 strcpy(c,".avi");
00537 Animate_Open(GetDlgItem(hDlg,DLG_IMAGE),modname);
00538 Animate_Play(GetDlgItem(hDlg,DLG_IMAGE),0, -1, -1);
00539 }
00540 }
00541
00542 BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam){
00543 BOOL err;
00544 char str[32];
00545 switch( msg ) {
00546 case WM_INITDIALOG:
00547 SetDlgItemInt(hwnd,DLG_STARFIELD_NSTAR,nstar,FALSE);
00548 SetDlgItemInt(hwnd,DLG_STARFIELD_NBACK,nback,FALSE);
00549 SetDlgItemInt(hwnd,DLG_STARFIELD_CYCLES,cycles,FALSE);
00550 if(type == 1)SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE1,BM_SETCHECK,TRUE,0);
00551 if(type == 2)SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE2,BM_SETCHECK,TRUE,0);
00552 if(type == 3)SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE3,BM_SETCHECK,TRUE,0);
00553 if(type == 4)SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE4,BM_SETCHECK,TRUE,0);
00554 if(multic == 1)SendDlgItemMessage(hwnd,DLG_STARFIELD_MULTICOLOUR,BM_SETCHECK,TRUE,0);
00555 if(trails == 1)SendDlgItemMessage(hwnd,DLG_STARFIELD_TRAILS,BM_SETCHECK,TRUE,0);
00556 SetDlgItemInt(hwnd,DLG_STARFIELD_SIZE,scale,FALSE);
00557 LoadAnimatedClip(hwnd);
00558 CentreDialogOnScreen(hwnd);
00559 return TRUE;
00560 case WM_PAINT:
00561 PaintBackground(hwnd);
00562 break;
00563 case WM_COMMAND:
00564 switch(LOWORD(wparam)){
00565 case IDCANCEL:
00566 EndDialog(hwnd,FALSE);
00567 return(TRUE);
00568 case IDOK:
00569 nstar=GetDlgItemInt(hwnd,DLG_STARFIELD_NSTAR,&err,FALSE);
00570 nback=GetDlgItemInt(hwnd,DLG_STARFIELD_NBACK,&err,FALSE);
00571 cycles=GetDlgItemInt(hwnd,DLG_STARFIELD_CYCLES,&err,FALSE);
00572 scale=GetDlgItemInt(hwnd,DLG_STARFIELD_SIZE,&err,FALSE);
00573 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE1,BM_GETCHECK,0,0))
00574 type=1;
00575 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE2,BM_GETCHECK,0,0))
00576 type=2;
00577 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE3,BM_GETCHECK,0,0))
00578 type=3;
00579 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_TYPE4,BM_GETCHECK,0,0))
00580 type=4;
00581 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_TRAILS,BM_GETCHECK,0,0))
00582 trails=1;
00583 else trails=0;
00584 if(SendDlgItemMessage(hwnd,DLG_STARFIELD_MULTICOLOUR,BM_GETCHECK,0,0))
00585 multic=1;
00586 else multic=0;
00587 EndDialog(hwnd,TRUE);
00588 return(TRUE);
00589 default:
00590 break;
00591 }
00592 break;
00593 default: break;
00594 }
00595 return FALSE;
00596 }
00597