00001
00002
00003 #define MODULE_SETUP 1
00004
00005 #include "animate.h"
00006 #include "callall.h"
00007
00008 extern UINT AnimationTimer;
00009
00010 #include "memory.c"
00011
00012 static long palette256[16]={
00013 0x00c0c0c0,
00014 0x00808080,
00015 0x0000ffff,
00016 0x00ffff00,
00017 0x00ffffff,
00018 0x0000ffff,
00019 0x00ffff00,
00020 0x0000ff00,
00021 0x00ffffff,
00022 0x00808080,
00023 0x00808080,
00024 0x007c3c00,
00025 0x00c0c0c0,
00026
00027
00028 0x00b0b0b0,
00029 0x0,0x0};
00030
00031 static long palette24b[16]={
00032 0x00c0c0c0,
00033
00034 0x00606060,
00035 0x0000ffff,
00036 0x00ffff00,
00037 0x00ffffff,
00038 0x0000ffff,
00039 0x00ffff00,
00040 0x0000ff00,
00041 0x00f0f0f0,
00042 0x0000ff00,
00043 0x0000ffff,
00044 0x007c3c00,
00045 0x00767676,
00046 0x00979797,
00047 0x0,0x0};
00048
00049 #define PALVERSION 0x300
00050
00051 #define X__C(p,i) RGB(p->palPalEntry[i].peRed, \
00052 p->palPalEntry[i].peGreen, \
00053 p->palPalEntry[i].peBlue)
00054
00055
00056
00057 HPALETTE CreateAppPalette(int *ScreenX, int *ScreenY){
00058 char *cstr[16]={
00059 "screen",
00060 "window",
00061 "selected",
00062 "deselected",
00063 "invert",
00064 "selected",
00065 "deselected",
00066 "edit",
00067 "wireframe",
00068 "cursor",
00069 "invert",
00070 "robot",
00071 "grid1",
00072 "grid2",
00073 "un",
00074 "un"
00075 };
00076 char strng[64];
00077 LOGPALETTE *pPal;
00078 HPALETTE hpal = NULL;
00079 WORD nNumColors;
00080 BYTE red,green,blue;
00081 HWND hDesktopWnd;
00082 HDC hDCcaps;
00083 int i,Dbits;
00084 long c,*palette;
00085 nNumColors = 256;
00086 pPal = (LOGPALETTE*)LocalAlloc(LPTR,sizeof(LOGPALETTE) +
00087 nNumColors * sizeof(PALETTEENTRY));
00088 if(pPal == NULL)return NULL;
00089 pPal->palNumEntries = nNumColors;
00090 pPal->palVersion = PALVERSION;
00091 red = green = blue = 0;
00092 for(i=0;i<256;i++){
00093 pPal->palPalEntry[i].peRed = red;
00094 pPal->palPalEntry[i].peGreen = green;
00095 pPal->palPalEntry[i].peBlue = blue;
00096 pPal->palPalEntry[i].peFlags = (BYTE)0;
00097 if (!(red += 32))if (!(green += 32)) blue += 64;
00098 }
00099 hDesktopWnd = GetDesktopWindow();
00100 hDCcaps = GetDC(hDesktopWnd);
00101 Dbits = GetDeviceCaps(hDCcaps,BITSPIXEL);
00102 *ScreenX = GetDeviceCaps(hDCcaps,HORZRES);
00103 *ScreenY = GetDeviceCaps(hDCcaps,VERTRES);
00104 ReleaseDC(hDesktopWnd,hDCcaps);
00105 if(Dbits <= 8)palette=palette256;
00106 else palette=palette24b;
00107 for(i = 0; i < 16; i++){
00108 GetPrivateProfileString("ACOLOURS",cstr[i],"$$$",
00109 strng,sizeof(strng),IniFilename);
00110
00111 if(1){
00112 pPal->palPalEntry[i].peRed = (unsigned char)( palette[i] & 0xff);
00113 pPal->palPalEntry[i].peGreen = (unsigned char)((palette[i] >> 8) & 0xff);
00114 pPal->palPalEntry[i].peBlue = (unsigned char)((palette[i] >> 16) & 0xff);
00115 pPal->palPalEntry[i].peFlags = (BYTE)0;
00116 }
00117 else{
00118 int r,g,b;
00119 sscanf(strng,"%ld %ld %ld",&r,&g,&b);
00120 pPal->palPalEntry[i].peRed = (unsigned char)(r&0xff);
00121 pPal->palPalEntry[i].peGreen = (unsigned char)(g&0xff);
00122 pPal->palPalEntry[i].peBlue = (unsigned char)(b&0xff);
00123 pPal->palPalEntry[i].peFlags = (BYTE)0;
00124 }
00125 }
00126 for(c=0,i=16;i<32;i++,c+=16){
00127 pPal->palPalEntry[i].peRed = c;
00128 pPal->palPalEntry[i].peGreen = c;
00129 pPal->palPalEntry[i].peBlue = c;
00130 pPal->palPalEntry[i].peFlags = (BYTE)0;
00131 }
00132 hpal = CreatePalette(pPal);
00133 ghbrushScreen = CreateSolidBrush(RGB(pPal->palPalEntry[0].peRed,pPal->palPalEntry[0].peGreen,pPal->palPalEntry[0].peBlue));
00134 ghbrushWindow = CreateSolidBrush(RGB(pPal->palPalEntry[1].peRed,pPal->palPalEntry[1].peGreen,pPal->palPalEntry[1].peBlue));
00135 ghSelectedBrush = CreateSolidBrush(RGB(pPal->palPalEntry[2].peRed,pPal->palPalEntry[2].peGreen,pPal->palPalEntry[2].peBlue));
00136 ghDeselectedBrush = CreateSolidBrush(RGB(pPal->palPalEntry[3].peRed,pPal->palPalEntry[3].peGreen,pPal->palPalEntry[3].peBlue));
00137 ghInvertBrush = CreateSolidBrush(RGB(pPal->palPalEntry[4].peRed,pPal->palPalEntry[4].peGreen,pPal->palPalEntry[4].peBlue));
00138 ghRobotBrush = CreateSolidBrush(RGB(pPal->palPalEntry[11].peRed,pPal->palPalEntry[11].peGreen,pPal->palPalEntry[11].peBlue));
00139 ghSelectedPen = CreatePen(PS_SOLID,0,X__C(pPal, 5));
00140 ghDeselectedPen = CreatePen(PS_SOLID,0,RGB(pPal->palPalEntry[6].peRed,pPal->palPalEntry[6].peGreen,pPal->palPalEntry[6].peBlue));
00141 ghEditPen = CreatePen(PS_SOLID,0,RGB(pPal->palPalEntry[7].peRed,pPal->palPalEntry[7].peGreen,pPal->palPalEntry[7].peBlue));
00142 ghWireframePen = CreatePen(PS_SOLID,0,RGB(pPal->palPalEntry[8].peRed,pPal->palPalEntry[8].peGreen,pPal->palPalEntry[8].peBlue));
00143 ghCursorPen = CreatePen(PS_SOLID,0,RGB(pPal->palPalEntry[9].peRed,pPal->palPalEntry[9].peGreen,pPal->palPalEntry[9].peBlue));
00144 ghInvertPen = CreatePen(PS_SOLID,0,RGB(pPal->palPalEntry[10].peRed,pPal->palPalEntry[10].peGreen,pPal->palPalEntry[10].peBlue));
00145 ghDotSelectedPen = CreatePen(PS_DOT,0,RGB(pPal->palPalEntry[5].peRed,pPal->palPalEntry[5].peGreen,pPal->palPalEntry[5].peBlue));
00146 ghDotDeselectedPen= CreatePen(PS_DOT,0,RGB(pPal->palPalEntry[6].peRed,pPal->palPalEntry[6].peGreen,pPal->palPalEntry[6].peBlue));
00147 ghDotInvertPen = CreatePen(PS_DOT,0,RGB(pPal->palPalEntry[10].peRed,pPal->palPalEntry[10].peGreen,pPal->palPalEntry[10].peBlue));
00148 gScreenColourRef=(COLORREF)palette[1];
00149 gGridColourRef1=X__C(pPal,12);
00150 gGridColourRef2=X__C(pPal,13);
00151
00152
00153 LocalFree((HANDLE)pPal);
00154 return hpal;
00155 }
00156
00157 void SetupStructures(void){
00158 ANI_STRUCTURE *lpEVI;
00159 X__MEMORY_MANAGER *lpEVIMM;
00160 lpEVI=&AniStructure;
00161 lpEVI->gszHomeDir=gszHomeDir;
00162 lpEVI->Nnodes = &Nnodes;
00163 lpEVI->Nground = &Nground;
00164 lpEVI->Nrobots = &Nrobots;
00165 lpEVI->Nskys = &Nskys;
00166 lpEVI->Ncameras = &Ncameras;
00167 lpEVI->Ndirectors = &Ndirectors;
00168 lpEVI->MainNp = &MainNp;
00169 lpEVI->FirstNp = &FirstNp;
00170 lpEVI->SelectedNode=&SelectedNode;
00171 lpEVI->SelectedCamera=&SelectedCamera;
00172 lpEVI->Nframes = &Nframes;
00173 lpEVI->CurrentFrame = &CurrentFrame;
00174 lpEVI->NpointerX=&NpointerX;
00175 lpEVI->NpointerY=&NpointerY;
00176 lpEVI->NpointerZ=&NpointerZ;
00177 lpEVI->TVpointX=&TVpointX;
00178 lpEVI->TVpointY=&TVpointY;
00179 lpEVI->TVpointZ=&TVpointZ;
00180 lpEVI->TVsizeX=&TVsizeX;
00181 lpEVI->TVsizeY=&TVsizeY;
00182 lpEVI->TVsizeZ=&TVsizeZ;
00183 lpEVI->ruler=&ruler;
00184 lpEVI->rulerx=&rulerx; lpEVI->rulery=&rulery; lpEVI->rulerz=&rulerz;
00185 lpEVI->orulerx=&lrulerx; lpEVI->orulery=&lrulery; lpEVI->orulerz=&lrulerz;
00186 #if __LITE__
00187 lpEVI->version=0;
00188 #else
00189 lpEVI->version=1;
00190 #endif
00191
00192 lpEVI->fpGetTransform=GetTransform;
00193 lpEVI->fp_scal=scal;
00194 lpEVI->fp_rotz=rotz;
00195 lpEVI->fp_roty=roty;
00196 lpEVI->fp_rotx=rotx;
00197 lpEVI->fp_tram=tram;
00198 lpEVI->fp_m4by4=m4by4;
00199 lpEVI->fp_m4by1=m4by1;
00200 lpEVI->fp_null_transform=null_transform;
00201 lpEVI->fp_c4to4=c4to4;
00202 lpEVI->fp_arbitrary_rotate=arbitrary_rotate;
00203 lpEVI->fp_L_cross=L_cross;
00204 lpEVI->fpDrawPerspectiveView=DrawPerspectiveView;
00205 lpEVI->fpDeleteCostume=DeleteCostume;
00206 lpEVI->fpCreateCostume=CreateCostume;
00207 lpEVI->fpDeleteSize=DeleteSize;
00208 lpEVI->fpCreateSize=CreateSize;
00209 lpEVI->fpDeleteAlign=DeleteAlign;
00210 lpEVI->fpCreateAlign=CreateAlign;
00211 lpEVI->fpDeletePosition=DeletePosition;
00212 lpEVI->fpCreatePosition=CreatePosition;
00213 lpEVI->fpDeleteSky=DeleteSky;
00214 lpEVI->fpCreateSky=CreateSky;
00215 lpEVI->fpDeleteNode=DeleteNode;
00216 lpEVI->fpCreateNode=CreateNode;
00217 lpEVI->fpCreatePathEditControlPoint=CreatePathEditControlPoint;
00218 lpEVI->fpDeletePathEditControlPoint=DeletePathEditControlPoint;
00219 lpEVI->fpAppendPathPoint=AppendPathPoint;
00220 lpEVI->fpCreatePathPoint=CreatePathPoint;
00221 lpEVI->fpDeletePathPoint=DeletePathPoint;
00222 lpEVI->fpCreateIPointPath=CreateIPointPath;
00223 lpEVI->fpSetNumberOfFrames=SetNumberOfFrames;
00224 lpEVI->fpChooseFile=SelectFileName;
00225 lpEVI->fpLoadMeshObject=LoadMeshObject;
00226 lpEVI->fpChooseColour=SetColour;
00227 lpEVI->fpRequestNumEntry=RequestNumEntry;
00228 lpEVI->fpSelectNodeID=SelectNodeID;
00229
00230 lpEVI->fpAppendFileExtension=AppendFileExtension;
00231 lpEVI->fpCentreDlgOnC=CentreDialogOnCursor;
00232 lpEVI->fpCentreDlgOnS=CentreDialogOnScreen;
00233
00234
00235 lpEVIMM=&EviMemoryManager;
00236 lpEVIMM->lpAni=(void *)lpEVI;
00237 lpEVIMM->lpMod=NULL;
00238 lpEVIMM->fpMalloc=X__AllocateRam;
00239 lpEVIMM->fpFree=X__FreeRam;
00240 }
00241
00242 void UpdateGLview(BOOL full){
00243 #if 0
00244 static BOOL in_use=FALSE;
00245 if(ghwndOpenGLview == NULL)return;
00246 if(!IsWindow(ghwndOpenGLview))return;
00247 UpdateFrameBox();
00248 if(!in_use){
00249 in_use=TRUE;
00250 if(!full){
00251
00252
00253
00254 if(AnimationTimer > 1)PostMessage(ghwndOpenGLview,(WM_USER+4),0,0);
00255 else PostMessage(ghwndOpenGLview,(WM_USER+2),0,0);
00256 }
00257 else{
00258 MakeScript(5,1);
00259 PostMessage(ghwndOpenGLview,(WM_USER+1),0,0);
00260 }
00261 in_use=FALSE;
00262 }
00263 #endif
00264 }
00265
00266 BOOL EnableGLview(void){
00267 DWORD version;
00268 version=GetVersion();
00269 return FALSE;
00270 #if 0
00271 if((version & 0x80000000) == 0x80000000){
00272 if(LOBYTE(LOWORD(version)) < 4)return FALSE;
00273 }
00274 else if(LOBYTE(LOWORD(version)) < 4 &&
00275 HIBYTE(LOWORD(version)) < 11)return FALSE;
00276 {char sysdir[256];
00277 HANDLE hfbm;
00278 strcpy(sysdir,"opengl32.dll");
00279 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00280 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00281 if(hfbm == INVALID_HANDLE_VALUE){
00282 GetSystemDirectory(sysdir,256); strcat(sysdir,"\\opengl32.dll");
00283 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00284 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00285 if(hfbm == INVALID_HANDLE_VALUE)return FALSE;
00286 CloseHandle(hfbm);
00287 }
00288 else CloseHandle(hfbm);
00289 }
00290 EnableMenuItem(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,MF_ENABLED);
00291 EnableMenuItem(GetMenu(ghwnd_main),IDM_FILE_EXP_OPENGL,MF_ENABLED);
00292
00293
00294 return TRUE;
00295 #endif
00296 }
00297
00298 void StartGLview(BOOL first_time){
00299 #if 0
00300 char lname[256],str[64],text[128];
00301 char oldname[256],newname[256];
00302 RECT rc;
00303 HWND hwnd=NULL;
00304 static HMODULE hLib=NULL;
00305 FARPROC fpFun;
00306 ANI_STRUCTURE *Evs;
00307 HWND (*fpFun1)(HWND, LPRECT, ANI_STRUCTURE *);
00308 DWORD version;
00309 version=GetVersion();
00310 if((version & 0x80000000) == 0x80000000){
00311 if(LOBYTE(LOWORD(version)) < 4)return;
00312 }
00313 else{
00314 if(LOBYTE(LOWORD(version)) < 4 &&
00315 HIBYTE(LOWORD(version)) < 11)return;
00316 }
00317 GetCurrentDirectory(255,oldname);
00318 strcpy(newname,gszHomeDir);
00319 if(SetCurrentDirectory(newname) == FALSE)
00320 MessageBox(ghwnd_main,newname,NULL,MB_OK);
00321 {char sysdir[256];
00322 HANDLE hfbm;
00323 strcpy(sysdir,"opengl32.dll");
00324 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00325 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00326 if(hfbm == INVALID_HANDLE_VALUE){
00327 GetSystemDirectory(sysdir,256); strcat(sysdir,"\\opengl32.dll");
00328 hfbm=CreateFile(sysdir,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,
00329 FILE_ATTRIBUTE_READONLY,(HANDLE)NULL);
00330 if(hfbm == INVALID_HANDLE_VALUE){
00331 SetCurrentDirectory(oldname);
00332 return;
00333 }
00334 CloseHandle(hfbm);
00335 }
00336 else CloseHandle(hfbm);
00337 }
00338 if(hLib != NULL){
00339 if(ghwndOpenGLview != NULL)DestroyWindow(ghwndOpenGLview);
00340 ShowWindow(ghwnd_view,SW_SHOWNA);
00341 LoadString(ghinst_main,IDX_MISC_SHOWOPENGL,text,128);
00342 ModifyMenu(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,
00343 MF_BYCOMMAND|MF_STRING,IDM_WINDOW_SHOWOPENGL,
00344 text);
00345 FreeLibrary(hLib); hLib=NULL;
00346 ghwndOpenGLview=NULL;
00347 InvalidateRect(ghwnd_main,NULL,TRUE);
00348 PerspectiveView(0,1);
00349 opengl_visible=0;
00350 SetCurrentDirectory(oldname);
00351 return;
00352 }
00353 Evs=&AniStructure;
00354 rc.left=WindowViewXmin;
00355 rc.top=WindowViewYmin;
00356 rc.right=WindowViewXsize;
00357 rc.bottom=WindowViewYsize;
00358 strcpy(lname,gszHomeDir); strcat(lname,"animategl.dll");
00359 if((hLib=LoadLibrary(lname)) != NULL){
00360 if((fpFun=GetProcAddress(hLib,"_AttachViewOpenGL")) != NULL){
00361 ShowWindow(ghwnd_view,SW_HIDE);
00362 fpFun1 = (void *)fpFun;
00363 hwnd=(*fpFun1)(ghwnd_main,&rc,Evs);
00364 }
00365 else{
00366 SendPrgmQuery(IDQ_FAILEDFUNCTION,3);
00367 FreeLibrary(hLib); hLib=NULL;
00368 }
00369 }
00370 else SendPrgmQuery(IDQ_FAILEDLIBRARY,3);
00371 ghwndOpenGLview=hwnd;
00372 UpdateGLview(TRUE);
00373 if(hwnd != NULL){
00374 LoadString(ghinst_main,IDX_MISC_HIDEOPENGL,text,128);
00375 ModifyMenu(GetMenu(ghwnd_main),IDM_WINDOW_SHOWOPENGL,
00376 MF_BYCOMMAND|MF_STRING,IDM_WINDOW_SHOWOPENGL,
00377 text);
00378 opengl_visible=1;
00379 }
00380 SetCurrentDirectory(oldname);
00381 #endif
00382 return;
00383 }
00384
00385
00386
00387
00388 BOOL SetupMainWindow(HANDLE inst, int cmdshow){
00389 long i;
00390 RECT rc;
00391 HDC hdc;
00392 TEXTMETRIC tm;
00393
00394 int StatusPartsList[2]={160,-1};
00395 Yres=GetSystemMetrics(SM_CYSCREEN);
00396 Xres=GetSystemMetrics(SM_CXSCREEN);
00397 if(Xres < 800 )SelectPointSize=2;
00398 else if(Xres < 1024)SelectPointSize=3;
00399 else SelectPointSize=4;
00400 if(Xres < 800)WindowGap /= 2;
00401 View=TRIVIEW; BigCameraView=0;
00402 ghwndTools=NULL; ghwndCoord1=NULL;
00403 ghwndDlgTools=NULL; ghwndQuicktime=NULL;
00404 ghwnd_current=NULL; ghwndRobotView=NULL;
00405 ghwndTimeline=NULL; ghwndTimelineChild=NULL;
00406 ghwndTooltip=NULL; ghwndSkEdit=NULL;
00407 ghwnd_main = CreateWindow(
00408 szMainClass,
00409 " ",
00410 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
00411 WS_MAXIMIZE | !WS_VISIBLE | WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
00412 0,
00413 0,
00414 Xres,
00415 Yres,
00416 NULL,
00417 NULL,
00418 inst,
00419 NULL
00420 );
00421 if( !ghwnd_main ) return( FALSE );
00422 ghwnd_info=CreateWindowEx(0L,STATUSCLASSNAME,"",
00423 WS_CHILD | !WS_BORDER | WS_VISIBLE,
00424 0,0,0,0,
00425 ghwnd_main,
00426 (HMENU)NULL,
00427 inst,
00428 NULL);
00429 if(!ghwnd_info)return(FALSE);
00430 SendMessage(ghwnd_info,SB_SETPARTS,(WPARAM)2,(LPARAM)StatusPartsList);
00431 GetClientRect(ghwnd_info,&rc);
00432 InfoWindowSize=rc.bottom-rc.top;
00433 LoadMenuHelpTable(ghwnd_main);
00434 GetClientRect(ghwnd_main,&rc);
00435 SetWindowSize(rc.right,rc.bottom,View,TRUE);
00436 GetTriview(TRUE);
00437 for(i=0;i<3;i++){
00438 ghwnd_triview[i] = CreateWindow(
00439 szTriViewClass,
00440 NULL,
00441 WS_CHILD | WS_BORDER | WS_VISIBLE,
00442 WindowsXmin[i],WindowsYmin[i],WindowSizeX[i],WindowSizeY[i],
00443 ghwnd_main,
00444 (HMENU)i,
00445 inst,
00446 NULL
00447 );
00448 if(!ghwnd_triview[i])return(FALSE);
00449 }
00450 ghwnd_view = CreateWindow(
00451 szViewClass,
00452 NULL,
00453 WS_CHILD | WS_BORDER | WS_VISIBLE,
00454 WindowViewXmin,WindowViewYmin,WindowViewXsize,WindowViewYsize,
00455 ghwnd_main,
00456 NULL,
00457 inst,
00458 NULL
00459 );
00460 if(!ghwnd_view)return(FALSE);
00461 cmdshow=SW_SHOWMAXIMIZED;
00462 ghwnd_current=ghwnd_triview[ActiveView];
00463 ghFont1=CreateFont(-12,0,0,0,FW_DONTCARE,FALSE,FALSE,FALSE,
00464 ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
00465 FIXED_PITCH,"MS Sans Serif");
00466 ghFont2=CreateFont(-12, 0, 0, 0, FW_LIGHT, FALSE, FALSE, FALSE,
00467 ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
00468 PROOF_QUALITY, VARIABLE_PITCH | FF_SWISS,
00469 "Arial");
00470 if(ghFont1 == NULL || ghFont2 == NULL)return(FALSE);
00471 ToolboxShow(TRUE);
00472
00473
00474 SendMessage(ghwnd_xscl,TBM_SETPOS,FALSE,(LPARAM)1);
00475 SendMessage(ghwnd_xscl,TBM_SETRANGE,(WPARAM)TRUE,(LPARAM)MAKELONG(1,1));
00476 if(!ghwndTools)return(FALSE);
00477 hdc=GetDC(ghwnd_main);
00478 GetTextMetrics(hdc,&tm);
00479 ReleaseDC(ghwnd_main,hdc);
00480 Textwidth = tm.tmAveCharWidth;
00481 Textheight = tm.tmHeight;
00482 ShowWindow( ghwnd_main, cmdshow);
00483 return TRUE;
00484 }
00485
00486 static PSTR apstr_StringTable[CSTRINGS];
00487 static PSTR apstr_QueryTable[QSTRINGS];
00488 static PSTR apstr_IconHelpTable[ISTRINGS];
00489
00490 void SendPrgmText(PSTR p){
00491 SendMessage(ghwnd_info,SB_SETTEXT,(WPARAM)1,(LPARAM)p);
00492 }
00493
00494 void SendPrgmMessage(int idString, int where){
00495 PSTR pstr,p;
00496 INT cch,string_id;
00497 idString -= FIRST_IDS_STRING;
00498 if(apstr_StringTable[idString] != NULL)p=apstr_StringTable[idString];
00499 else{
00500 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return;
00501 string_id=idString+FIRST_IDS_STRING;
00502 #if __LITE__
00503 if(idString == IDS_DEFAULT)string_id=IDS_DEFAULT_LITE;
00504 if(idString == IDS_CURRENT)string_id=IDS_CURRENT_LITE;
00505 #endif
00506 if((cch = LoadString(ghinst_main,string_id,pstr,CCHTEXTMAX)) == 0){
00507 X__Free(pstr);
00508 return;
00509 }
00510 p = apstr_StringTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00511 if(p == NULL)return;
00512 }
00513 if(where == 0)SendMessage(ghwnd_main,WM_SETTEXT,0,(LPARAM)p);
00514 else SendPrgmText(p);
00515 }
00516
00517 int SendPrgmQuery(int idString, int response){
00518 int a;
00519 PSTR pstr,p;
00520 INT cch;
00521 char title[128];
00522 idString -= FIRST_IDQ_STRING;
00523 if(apstr_QueryTable[idString] != NULL)p=apstr_QueryTable[idString];
00524 else{
00525 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return 0;
00526 if((cch = LoadString(ghinst_main,idString+FIRST_IDQ_STRING,pstr,CCHTEXTMAX)) == 0){
00527 X__Free(pstr);
00528 return 0;
00529 }
00530 p = apstr_QueryTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00531 if(p == NULL)return 0;
00532 }
00533 #if __LITE__
00534 LoadString(ghinst_main,IDS_DEFAULT_LITE,title,127);
00535 #else
00536 LoadString(ghinst_main,IDS_DEFAULT,title,127);
00537 #endif
00538 if(response > 0)MessageBeep(MB_ICONQUESTION);
00539 else MessageBeep(MB_OK);
00540 if (response == 3)a=MessageBox (GetFocus(),p,NULL,
00541 MB_OK | MB_ICONEXCLAMATION | MB_TASKMODAL);
00542 else if(response == 2)a=MessageBox (GetFocus(),p,title,
00543 MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL);
00544 else if(response == 1)a=MessageBox (GetFocus(),p,title,
00545 MB_YESNO | MB_ICONQUESTION | MB_TASKMODAL);
00546 else a=MessageBox (GetFocus(),p,title,
00547 MB_OK | MB_ICONINFORMATION | MB_TASKMODAL);
00548 return a;
00549 }
00550
00551 void SetPrgmMessage(int idString, PSTR pstr){
00552 int l;
00553 PSTR p;
00554 idString -= FIRST_IDS_STRING;
00555 l=strlen(pstr)+1;
00556 if(apstr_StringTable[idString] == NULL){
00557 if((p=(PSTR)X__Malloc(l)) == NULL)return;
00558 }
00559 else{
00560 if((p=(PSTR)X__Realloc(apstr_StringTable[idString],l)) == NULL)return;
00561 }
00562 strcpy(p,pstr);
00563 apstr_StringTable[idString]=p;
00564 }
00565
00566 void SendIconHelpMessage(int idString){
00567 PSTR pstr,p;
00568 INT cch;
00569 RECT rc;
00570 HDC hdc;
00571 DWORD syscolour;
00572 HFONT hfont;
00573 idString -= FIRST_IDI_STRING;
00574 if(apstr_IconHelpTable[idString] != NULL)p=apstr_IconHelpTable[idString];
00575 else{
00576 if((pstr = (PSTR)X__Malloc(CCHTEXTMAX)) == NULL)return;
00577 if((cch = LoadString(ghinst_main, idString+FIRST_IDI_STRING,pstr, CCHTEXTMAX)) == 0){
00578 X__Free(pstr);
00579 return;
00580 }
00581 p = apstr_IconHelpTable[idString] = pstr = (PSTR)X__Realloc(pstr, cch + 1);
00582 if(p == NULL)return;
00583 }
00584 SendMessage(ghwnd_info,SB_SETTEXT,(WPARAM)1,(LPARAM)p);
00585 }
00586
00587 BOOL AnimatorStartup(UINT *screen_ready){
00588 int i;
00589 object *Op;
00590
00591 for(i=0;i<CSTRINGS;i++)apstr_StringTable[i]=NULL;
00592 for(i=0;i<QSTRINGS;i++)apstr_QueryTable[i]=NULL;
00593 for(i=0;i<ISTRINGS;i++)apstr_IconHelpTable[i]=NULL;
00594 ghcurWait=LoadCursor(NULL,IDC_WAIT);
00595 ghcurArrow=LoadCursor(NULL,IDC_ARROW);
00596 ghcurCross=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_NONE));
00597 ghcurX=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_XCROSS));
00598 ghcurPan=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PAN));
00599 ghcurZout=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOMOUT));
00600 ghcurZin=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOMIN));
00601 ghcurZoom=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ZOOM));
00602 ghcurArrow1=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_OPENARROW));
00603 ghcurMove=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_GRABBER));
00604 ghcurRotate=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_ROTATOR));
00605 ghcurScale=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SIZER));
00606 ghcurTracker=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_TRACKER));
00607 ghcurDirector=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_DIRECTOR));
00608 ghcurPathed=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_PATHED));
00609 ghcurSkeletor=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_SKELETOR));
00610 ghcurInsert=LoadCursor(ghinst_main,MAKEINTRESOURCE(IDC_INSERT));
00611 ghcurTools[0]=ghcurArrow;
00612 ghcurTools[1]=ghcurArrow1;
00613 ghcurTools[2]=ghcurPan;
00614 ghcurTools[3]=ghcurZoom;
00615 ghcurTools[4]=ghcurMove;
00616 ghcurTools[5]=ghcurRotate;
00617 ghcurTools[6]=ghcurScale;
00618 ghcurTools[7]=ghcurArrow;
00619
00620 bAbortedDrawing=FALSE;
00621 if(FindWindow("OFX:ModelerClass",NULL) == NULL)StartedInAnimator=TRUE;
00622 else StartedInAnimator=FALSE;
00623 GetModuleFileName(ghinst_main,gszHomeDir,MAX_DIR);
00624 *FileInPath(gszHomeDir) = '\0';
00625 gszSTGfile[0]='\0';strcpy(gszSTGdir,gszHomeDir);strcat(gszSTGdir,"animations");
00626 gszPAKfile[0]='\0';strcpy(gszPAKdir,gszHomeDir);strcat(gszPAKdir,"animations");
00627 gszSCEfile[0]='\0';strcpy(gszSCEdir,gszHomeDir);strcat(gszSCEdir,"models");
00628 gszPTHfile[0]='\0';strcpy(gszPTHdir,gszHomeDir);strcat(gszPTHdir,"models");
00629 gszSCRfile[0]='\0';strcpy(gszSCRdir,gszHomeDir);strcat(gszSCRdir,"scripts");
00630 gszIMGfile[0]='\0';strcpy(gszIMGdir,gszHomeDir);strcat(gszIMGdir,"images");
00631 gszMAPfile[0]='\0';strcpy(gszMAPdir,gszHomeDir);strcat(gszMAPdir,"maps");
00632 gszDLLfile[0]='\0';strcpy(gszDLLdir,gszHomeDir);strcat(gszDLLdir,"effects");
00633 gszXIPfile[0]='\0';strcpy(gszXIPdir,gszHomeDir);strcat(gszXIPdir,"postprocess");
00634 gszANIfile[0]='\0';strcpy(gszANIdir,gszHomeDir);strcat(gszANIdir,"animations");
00635 gszPSTfile[0]='\0';strcpy(gszPSTdir,gszHomeDir);strcat(gszPSTdir,"presets");
00636 gszPZEfile[0]='\0';strcpy(gszPZEdir,gszHomeDir);strcat(gszPZEdir,"animations");
00637 gszRSQfile[0]='\0';strcpy(gszRSQdir,gszHomeDir);strcat(gszRSQdir,"animations");
00638 for(i=0;i<N_OBJECTTYPELIST;i++){
00639 LoadString(ghinst_main,ObjectTypeListID[i],res_str,256);
00640 ObjectTypeList[i]=(char *)X__Malloc(strlen(res_str)+1);
00641 if(ObjectTypeList[i] != NULL)strcpy(ObjectTypeList[i],res_str);
00642 }
00643 for(i=0;i<NoGroundTexts;i++){
00644 LoadString(ghinst_main,GroundTextureListID[i],res_str,256);
00645 GroundTextList[i]=(char *)X__Malloc(strlen(res_str)+1);
00646 if(GroundTextList[i] != NULL)strcpy(GroundTextList[i],res_str);
00647 }
00648 strcpy(gszUndoFile,TempPath);
00649 strcat(gszUndoFile,"undo_$.ofx");
00650 PIo180=PI/180.0;
00651 SetUpWindowBoxView(0);
00652 gCurTool=gCurCommand=gCurSelect= -1;
00653 SendPrgmMessage(IDS_DEFAULT,0);
00654 ScrapEverything();
00655 SetupStructures();
00656 if(CreateNode() != NULL){
00657 strcpy(MainNp->actorname,"Camera ");
00658 MainNp->type=CAMERA;
00659 SelectedCamera=MainNp;
00660 if((Op=CreateCostume(MainNp,1,(short)Nframes)) == NULL)return FALSE;
00661 Op->type=MainNp->type;
00662 MainNp->fobj->morph=NO;
00663 Ncameras=1;
00664 CreatePosition(MainNp,1,(short)Nframes);
00665 MainNp->fpos->finish[0]=0;
00666 MainNp->fpos->finish[1]=-TVsizeY/3;
00667 MainNp->fpos->finish[2]=0;
00668 MainNp->fpos->type=SPLINE;
00669 CreateAlign(FirstNp,1,(short)Nframes);
00670 CreateSize(FirstNp,1,(short)Nframes);
00671 CreateNode();
00672 strcpy(MainNp->actorname,"Target");
00673 MainNp->type=TARGET;
00674 Op=CreateCostume(MainNp,1,(short)Nframes);
00675 Op->type=MainNp->type;
00676 FirstNp->fali->type=TRACK;
00677 FirstNp->fali->topath=MainNp;
00678 CreatePosition(MainNp,1,Nframes);
00679 }
00680 else return FALSE;
00681 EDIT_ACTION=NO;
00682 InitializeLastFilesList();
00683 DeleteMemoryWindows();
00684 if(!CreateMemoryWindows()){
00685 SendPrgmQuery(IDQ_FATALERROR,3);
00686 return FALSE;
00687 }
00688 gToolFlags.flagX=TRUE; gToolFlags.flagY=TRUE; gToolFlags.flagZ=TRUE;
00689 gToolFlags.flagA=0; gToolFlags.flagT=0; gToolFlags.flagR=0;
00690 gToolFlags.flagP=0; gToolFlags.flagK=0;
00691 *screen_ready=1;
00692 ReDrawStageDisplay(TRUE);
00693 PerspectiveView(0,0);
00694 UpdateSelectedActor(FALSE);
00695 return TRUE;
00696 }
00697
00698
00699
00700
00701 void AnimatorShutdown(void){
00702 char ss[32];
00703 int i;
00704 if(UNDO_ACTIVE)DeleteFile(gszUndoFile);
00705 DeleteArrowIcons();
00706 ScrapEverything();
00707 DeleteMemoryWindows();
00708 ToolboxDestroy();
00709 for(i=0;i<CSTRINGS;i++)
00710 if(apstr_StringTable[i] != NULL)X__Free(apstr_StringTable[i]);
00711 for(i=0;i<QSTRINGS;i++)
00712 if(apstr_QueryTable[i] != NULL)X__Free(apstr_QueryTable[i]);
00713 for(i=0;i<ISTRINGS;i++)
00714 if(apstr_IconHelpTable[i] != NULL)X__Free(apstr_IconHelpTable[i]);
00715 FreeMenuHelpData();
00716 DeleteObject(ghbrushScreen);
00717 DeleteObject(ghbrushWindow);
00718 DeleteObject(ghSelectedBrush);
00719 DeleteObject(ghDeselectedBrush);
00720 DeleteObject(ghInvertBrush);
00721 DeleteObject(ghRobotBrush);
00722 DeleteObject(ghSelectedPen);
00723 DeleteObject(ghDeselectedPen);
00724 DeleteObject(ghEditPen);
00725 DeleteObject(ghWireframePen);
00726 DeleteObject(ghCursorPen);
00727 DeleteObject(ghInvertPen);
00728 DeleteObject(ghDotSelectedPen);
00729 DeleteObject(ghDotDeselectedPen);
00730 DeleteObject(ghDotInvertPen);
00731
00732 DeleteObject(ghcurCross);
00733 DeleteObject(ghcurX);
00734 DeleteObject(ghcurPan);
00735 DeleteObject(ghcurZout);
00736 DeleteObject(ghcurZin);
00737 DeleteObject(ghcurZoom);
00738 DeleteObject(ghcurArrow1);
00739 DeleteObject(ghcurMove);
00740 DeleteObject(ghcurRotate);
00741 DeleteObject(ghcurScale);
00742 DeleteObject(ghcurTracker);
00743 DeleteObject(ghcurDirector);
00744 DeleteObject(ghcurPathed);
00745 DeleteObject(ghcurSkeletor);
00746 DeleteObject(ghcurInsert);
00747
00748 if(ghFont1 != NULL)DeleteObject(ghFont1);
00749 if(ghFont2 != NULL)DeleteObject(ghFont2);
00750 CloseUtilities(0);
00751 sprintf(ss,"%ld",View);
00752 WritePrivateProfileString(IniSection,"VIEW",ss,IniFilename);
00753 sprintf(ss,"%ld",ActiveView);
00754 WritePrivateProfileString(IniSection,"ACTIVEVIEW",ss,IniFilename);
00755 if(BigCameraView)
00756 WritePrivateProfileString(IniSection,"BIGCAMERA","YES",IniFilename);
00757 else
00758 WritePrivateProfileString(IniSection,"BIGCAMERA","NO",IniFilename);
00759 sprintf(ss,"%ld",FramesPerSec);
00760 WritePrivateProfileString(IniSection,"FPS",ss,IniFilename);
00761 if(global_quickdraw)
00762 WritePrivateProfileString(IniSection,"QUICKDRAW","YES",IniFilename);
00763 else
00764 WritePrivateProfileString(IniSection,"QUICKDRAW","NO",IniFilename);
00765 if(DrawStatus == 0)
00766 WritePrivateProfileString(IniSection,"DRAWFULL","NO",IniFilename);
00767 else
00768 WritePrivateProfileString(IniSection,"DRAWFULL","YES",IniFilename);
00769 sprintf(ss,"%ld",AllDrawStatus);
00770 WritePrivateProfileString(IniSection,"DRAWFULLTYPE",ss,IniFilename);
00771 if(show_light_cones)
00772 WritePrivateProfileString(IniSection,"LIGHTCONES","YES",IniFilename);
00773 else
00774 WritePrivateProfileString(IniSection,"LIGHTCONES","NO",IniFilename);
00775 if(show_camera_fov)
00776 WritePrivateProfileString(IniSection,"CAMERAFOV","YES",IniFilename);
00777 else
00778 WritePrivateProfileString(IniSection,"CAMERAFOV","NO",IniFilename);
00779 if(opengl_visible)
00780 WritePrivateProfileString(IniSection,"OPENGL1","YES",IniFilename);
00781 else
00782 WritePrivateProfileString(IniSection,"OPENGL1","NO",IniFilename);
00783 if(keyframer_docked)
00784 WritePrivateProfileString(IniSection,"KEYDOCK","YES",IniFilename);
00785 else
00786 WritePrivateProfileString(IniSection,"KEYDOCK","NO",IniFilename);
00787 sprintf(ss,"%ld",coords_visible);
00788 WritePrivateProfileString(IniSection,"COORDSVISIBLE",ss,IniFilename);
00789 sprintf(ss,"%ld",draw_grid_on);
00790 WritePrivateProfileString(IniSection,"DRAWGRIDON",ss,IniFilename);
00791 sprintf(ss,"%ld",grid_on);
00792 WritePrivateProfileString(IniSection,"GRIDON",ss,IniFilename);
00793 return;
00794 }
00795
00796
00797
00798
00799
00800
00801
00802 void CloseUtilities(int what){
00803 HWND hWndPrev;
00804 if(IsWindow(ghwndTimeline)){
00805 if(IsWindowVisible(ghwndTimeline)){
00806 SendMessage(ghwndTimeline,WM_COMMAND,IDM_TIMELINE_HIDE,0);
00807 }
00808 DestroyTimelineEditor();
00809 if(keyframer_docked)FormatScreen();
00810 }
00811
00812 UnloadRenderer();
00813 hWndPrev = FindWindow("OFX:ModelerClass",NULL);
00814 if (hWndPrev != NULL){
00815 SetForegroundWindow(hWndPrev);
00816 BringWindowToTop(hWndPrev);
00817 ShowWindow (hWndPrev,SW_SHOW);
00818 if(StartedInAnimator)PostMessage(hWndPrev,WM_COMMAND,IDM_CALLBACK_SHUTDOWN,0);
00819 }
00820 hWndPrev = FindWindow("OFX:FLCPlayer",NULL);
00821 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,100,0);
00822 hWndPrev = FindWindow("OFX:ViewClass",NULL);
00823 if(StartedInAnimator && hWndPrev != NULL)
00824 PostMessage(hWndPrev,WM_COMMAND,106,0);
00825 hWndPrev = FindWindow("OFX:AVIPlay",NULL);
00826 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00827 hWndPrev = FindWindow("OFX:Viewer",NULL);
00828 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00829 hWndPrev = FindWindow("OFX:AVIConvertClass",NULL);
00830 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00831 hWndPrev = FindWindow("OFX:GIFConvertClass",NULL);
00832 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00833 hWndPrev = FindWindow("OFX:BuildClass",NULL);
00834 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00835 hWndPrev = FindWindow("OFX:EditSoundClass",NULL);
00836 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00837 hWndPrev = FindWindow("OFX:STV",NULL);
00838 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00839 hWndPrev = FindWindow("OFX:MediaPlayerClass",NULL);
00840 if(hWndPrev != NULL)PostMessage(hWndPrev,WM_COMMAND,1001,0);
00841 return;
00842 }