- Timestamp:
- Jan 21, 2006, 3:13:27 AM (19 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/lib/lang/base_object.cc
r6634 r6640 13 13 ### File Specific: 14 14 main-programmer: Patrick Boenzli 15 co-programmer: ...15 co-programmer: Benjamin Grauer 16 16 */ 17 17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_BASE -
trunk/src/util/loading/resource_manager.cc
r6467 r6640 78 78 // deleting the Directorie Lists 79 79 while (!this->imageDirs.empty()) 80 81 82 83 80 { 81 delete[] this->imageDirs.front(); 82 this->imageDirs.pop_front(); 83 } 84 84 85 85 delete[] this->dataDir; … … 162 162 bool retVal; 163 163 if (!isDir(this->dataDir)) 164 165 166 167 164 { 165 PRINTF(1)("%s is not a directory\n", this->dataDir); 166 return false; 167 } 168 168 169 169 char* testFile = new char[strlen(this->dataDir)+strlen(fileInside)+1]; … … 201 201 // check if the param is a Directory 202 202 if (isDir(newDir)) 203 { 204 // check if the Directory has been added before 205 std::list<char*>::const_iterator imageDir; 206 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 203 { 204 // check if the Directory has been added before 205 std::list<char*>::const_iterator imageDir; 206 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 207 { 208 if (!strcmp(*imageDir, newDir)) 207 209 { 208 if (!strcmp(*imageDir, newDir)) 209 { 210 PRINTF(3)("Path %s already loaded\n", newDir); 211 delete[] newDir; 212 return true; 213 } 210 PRINTF(3)("Path %s already loaded\n", newDir); 211 delete[] newDir; 212 return true; 214 213 } 215 // adding the directory to the List 216 this->imageDirs.push_back(newDir); 217 return true; 218 } 219 else 220 { 221 PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir); 222 delete[] newDir; 223 return false; 224 } 214 } 215 // adding the directory to the List 216 this->imageDirs.push_back(newDir); 217 return true; 218 } 219 else 220 { 221 PRINTF(1)("%s is not a Directory, and can not be added to the Paths of Images\n", newDir); 222 delete[] newDir; 223 return false; 224 } 225 225 } 226 226 #endif /* NO_TEXTURES */ … … 258 258 #endif 259 259 #define __IF_OK 260 if (!strncasecmp(fileName+(strlen(fileName)-4), ".wav", 4))261 tmpType = WAV;262 else if (!strncasecmp(fileName+(strlen(fileName)-4), ".mp3", 4))263 tmpType = MP3;264 else if (!strncasecmp(fileName+(strlen(fileName)-4), ".ogg", 4))265 tmpType = OGG;260 if (!strncasecmp(fileName+(strlen(fileName)-4), ".wav", 4)) 261 tmpType = WAV; 262 else if (!strncasecmp(fileName+(strlen(fileName)-4), ".mp3", 4)) 263 tmpType = MP3; 264 else if (!strncasecmp(fileName+(strlen(fileName)-4), ".ogg", 4)) 265 tmpType = OGG; 266 266 #endif /* NO_AUDIO */ 267 267 #ifndef NO_TEXT 268 268 #ifdef __IF_OK 269 else269 else 270 270 #endif 271 271 #define __IF_OK 272 if (!strncasecmp(fileName+(strlen(fileName)-4), ".ttf", 4))273 tmpType = TTF;272 if (!strncasecmp(fileName+(strlen(fileName)-4), ".ttf", 4)) 273 tmpType = TTF; 274 274 #endif /* NO_TEXT */ 275 275 #ifndef NO_SHADERS 276 276 #ifdef __IF_OK 277 else277 else 278 278 #endif 279 279 #define __IF_OK 280 if (!strncasecmp(fileName+(strlen(fileName)-5), ".vert", 5))281 tmpType = SHADER;280 if (!strncasecmp(fileName+(strlen(fileName)-5), ".vert", 5)) 281 tmpType = SHADER; 282 282 #endif /* NO_SHADERS */ 283 283 #ifndef NO_TEXTURES 284 284 #ifdef __IF_OK 285 else285 else 286 286 #else 287 287 if 288 288 #endif 289 tmpType = IMAGE;289 tmpType = IMAGE; 290 290 #endif /* NO_TEXTURES */ 291 291 #undef __IF_OK … … 304 304 */ 305 305 BaseObject* ResourceManager::load(const char* fileName, ResourceType type, ResourcePriority prio, 306 void* param1, void* param2, void* param3) 307 { 308 if (fileName == NULL) 306 void* param1, void* param2, void* param3) 307 { 308 assert(fileName != NULL); 309 310 // searching if the resource was loaded before. 311 Resource* tmpResource; 312 // check if we already loaded this Resource 313 tmpResource = this->locateResourceByInfo(fileName, type, param1, param2, param3); 314 // otherwise load it 315 if (tmpResource == NULL) 316 tmpResource = this->loadResource(fileName, type, prio, param1, param2, param3); 317 // return cached pointer. 318 if (tmpResource != NULL) // if the resource was loaded before. 319 { 320 tmpResource->count++; 321 if(tmpResource->prio < prio) 322 tmpResource->prio = prio; 323 return tmpResource->pointer; 324 } 325 else 309 326 return NULL; 310 311 // searching if the resource was loaded before. 312 Resource* tmpResource = this->locateResourceByInfo(fileName, type, param1, param2, param3); 313 if (tmpResource != NULL) // if the resource was loaded before. 314 { 315 PRINTF(4)("not loading cached resource %s\n", tmpResource->name); 316 tmpResource->count++; 317 if(tmpResource->prio < prio) 318 tmpResource->prio = prio; 319 } 320 else 321 { 322 // Setting up the new Resource 323 tmpResource = new Resource; 324 tmpResource->count = 1; 325 tmpResource->type = type; 326 tmpResource->prio = prio; 327 tmpResource->pointer = NULL; 328 tmpResource->name = new char[strlen(fileName)+1]; 329 strcpy(tmpResource->name, fileName); 330 331 // creating the full name. (directoryName + FileName) 332 char* fullName = ResourceManager::getFullName(fileName); 333 // Checking for the type of resource \see ResourceType 334 switch(type) 335 { 327 } 328 329 330 /** 331 * loads resources for internal purposes 332 * @param fileName: The fileName of the resource to load 333 * @param type: The Type of Resource to load. 334 * @param prio: The ResourcePriority of this resource (will only be increased) 335 * @param param1: an additional option to parse (see the constuctors for more help) 336 * @param param2: an additional option to parse (see the constuctors for more help) 337 * @param param3: an additional option to parse (see the constuctors for more help) 338 * @returns a pointer to a desired Resource. 339 */ 340 Resource* ResourceManager::loadResource(const char* fileName, ResourceType type, ResourcePriority prio, 341 void* param1, void* param2, void* param3) 342 { 343 // Setting up the new Resource 344 Resource* tmpResource = new Resource; 345 tmpResource->count = 0; 346 tmpResource->type = type; 347 tmpResource->prio = prio; 348 tmpResource->pointer = NULL; 349 tmpResource->name = new char[strlen(fileName)+1]; 350 strcpy(tmpResource->name, fileName); 351 352 // creating the full name. (directoryName + FileName) 353 char* fullName = ResourceManager::getFullName(fileName); 354 // Checking for the type of resource \see ResourceType 355 switch(type) 356 { 336 357 #ifndef NO_MODEL 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 // tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName);380 381 382 358 case OBJ: 359 if (param1) 360 tmpResource->modelSize = *(float*)param1; 361 else 362 tmpResource->modelSize = 1.0; 363 364 if(ResourceManager::isFile(fullName)) 365 tmpResource->pointer = new OBJModel(fullName, tmpResource->modelSize); 366 else 367 { 368 PRINTF(2)("File %s in %s does not exist. Loading a cube-Model instead\n", fileName, dataDir); 369 tmpResource->pointer = ResourceManager::load("cube", PRIM, prio, &tmpResource->modelSize); 370 } 371 break; 372 case PRIM: 373 if (param1) 374 tmpResource->modelSize = *(float*)param1; 375 else 376 tmpResource->modelSize = 1.0; 377 378 if (!strcmp(tmpResource->name, "cube")) 379 tmpResource->pointer = new PrimitiveModel(PRIM_CUBE, tmpResource->modelSize); 380 else if (!strcmp(tmpResource->name, "sphere")) 381 tmpResource->pointer = new PrimitiveModel(PRIM_SPHERE, tmpResource->modelSize); 382 else if (!strcmp(tmpResource->name, "plane")) 383 tmpResource->pointer = new PrimitiveModel(PRIM_PLANE, tmpResource->modelSize); 384 else if (!strcmp(tmpResource->name, "cylinder")) 385 tmpResource->pointer = new PrimitiveModel(PRIM_CYLINDER, tmpResource->modelSize); 386 else if (!strcmp(tmpResource->name, "cone")) 387 tmpResource->pointer = new PrimitiveModel(PRIM_CONE, tmpResource->modelSize); 388 break; 389 case MD2: 390 if(ResourceManager::isFile(fullName)) 391 { 392 if (param1 != NULL) 393 { 394 tmpResource->secFileName = new char[strlen((const char*)param1)+1]; 395 strcpy(tmpResource->secFileName, (const char*) param1); 396 } 397 else 398 tmpResource->secFileName = NULL; 399 tmpResource->pointer = new MD2Data(fullName, tmpResource->secFileName); 400 // tmpResource->pointer = new MD2Model(fullName, tmpResource->secFileName); 401 402 } 403 break; 383 404 #endif /* NO_MODEL */ 384 405 #ifndef NO_TEXT 385 386 387 388 389 390 391 392 393 394 395 406 case TTF: 407 if (param1 != NULL) 408 tmpResource->ttfSize = *(unsigned int*)param1; 409 else 410 tmpResource->ttfSize = FONT_DEFAULT_RENDER_SIZE; 411 412 if(isFile(fullName)) 413 tmpResource->pointer = new Font(fullName, tmpResource->ttfSize); 414 else 415 PRINTF(2)("%s does not exist in %s. Not loading Font\n", fileName, this->dataDir); 416 break; 396 417 #endif /* NO_TEXT */ 397 418 #ifndef NO_AUDIO 398 399 400 401 402 403 404 405 419 case WAV: 420 if(isFile(fullName)) 421 tmpResource->pointer = new SoundBuffer(fullName); 422 break; 423 case OGG: 424 if (isFile(fullName)) 425 tmpResource->pointer = new OggPlayer(fullName); 426 break; 406 427 #endif /* NO_AUDIO */ 407 428 #ifndef NO_TEXTURES 408 case IMAGE: 409 if (param1 != NULL) 410 tmpResource->texTarget = *(GLenum*)param1; 411 else 412 tmpResource->texTarget = GL_TEXTURE_2D; 413 if(isFile(fullName)) 414 { 415 PRINTF(4)("Image %s resides to %s\n", fileName, fullName); 416 tmpResource->pointer = new Texture(fullName); 417 } 418 else 419 { 420 std::list<char*>::iterator imageDir; 421 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 422 { 423 char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1]; 424 sprintf(imgName, "%s%s", *imageDir, fileName); 425 if(isFile(imgName)) 426 { 427 PRINTF(4)("Image %s resides to %s\n", fileName, imgName); 428 tmpResource->pointer = new Texture(imgName, tmpResource->texTarget); 429 delete[] imgName; 430 break; 431 } 432 delete[] imgName; 433 } 434 } 435 if(!tmpResource) 436 PRINTF(2)("!!Image %s not Found!!\n", fileName); 429 case IMAGE: 430 if (param1 != NULL) 431 tmpResource->texTarget = *(GLenum*)param1; 432 else 433 tmpResource->texTarget = GL_TEXTURE_2D; 434 if(isFile(fullName)) 435 { 436 PRINTF(4)("Image %s resides to %s\n", fileName, fullName); 437 tmpResource->pointer = new Texture(fullName); 438 } 439 else 440 { 441 std::list<char*>::iterator imageDir; 442 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 443 { 444 char* imgName = new char[strlen(*imageDir)+strlen(fileName)+1]; 445 sprintf(imgName, "%s%s", *imageDir, fileName); 446 if(isFile(imgName)) 447 { 448 PRINTF(4)("Image %s resides to %s\n", fileName, imgName); 449 tmpResource->pointer = new Texture(imgName, tmpResource->texTarget); 450 delete[] imgName; 437 451 break; 452 } 453 delete[] imgName; 454 } 455 } 456 if(!tmpResource) 457 PRINTF(2)("!!Image %s not Found!!\n", fileName); 458 break; 438 459 #endif /* NO_TEXTURES */ 439 460 #ifndef NO_SHADERS 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 case SHADER: 462 if(ResourceManager::isFile(fullName)) 463 { 464 if (param1 != NULL) 465 { 466 char* secFullName = ResourceManager::getFullName((const char*)param1); 467 if (ResourceManager::isFile(secFullName)) 468 { 469 tmpResource->secFileName = new char[strlen((const char*)param1)+1]; 470 strcpy(tmpResource->secFileName, (const char*) param1); 471 tmpResource->pointer = new Shader(fullName, secFullName); 472 } 473 delete[] secFullName; 474 } 475 else 476 { 477 tmpResource->secFileName = NULL; 478 tmpResource->pointer = new Shader(fullName, NULL); 479 } 480 } 481 break; 461 482 #endif /* NO_SHADERS */ 462 default: 463 tmpResource->pointer = NULL; 464 PRINTF(1)("No type found for %s.\n !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name); 465 break; 466 } 467 if (tmpResource->pointer != NULL) 468 this->resourceList.push_back(tmpResource); 469 delete[] fullName; 470 } 483 default: 484 tmpResource->pointer = NULL; 485 PRINTF(1)("No type found for %s.\n !!This should not happen unless the Type is not supported yet. JUST DO IT!!\n", tmpResource->name); 486 break; 487 } 471 488 if (tmpResource->pointer != NULL) 472 return tmpResource->pointer; 473 else 474 { 475 PRINTF(2)("Resource %s could not be loaded\n", fileName); 476 delete[] tmpResource->name; 477 delete tmpResource; 478 return NULL; 479 } 489 this->resourceList.push_back(tmpResource); 490 delete[] fullName; 491 492 493 if (tmpResource->pointer != NULL) 494 return tmpResource; 495 else 496 { 497 PRINTF(2)("Resource %s could not be loaded\n", fileName); 498 delete[] tmpResource->name; 499 delete tmpResource; 500 return NULL; 501 } 480 502 } 481 503 … … 515 537 516 538 if (resource->prio <= prio) 517 518 519 520 521 522 539 { 540 if (resource->count == 0) 541 { 542 // deleting the Resource 543 switch(resource->type) 544 { 523 545 #ifndef NO_MODEL 524 525 526 527 528 529 530 546 case OBJ: 547 case PRIM: 548 delete (Model*)resource->pointer; 549 break; 550 case MD2: 551 delete (MD2Data*)resource->pointer; 552 break; 531 553 #endif /* NO_MODEL */ 532 554 #ifndef NO_AUDIO 533 534 535 536 537 538 555 case WAV: 556 delete (SoundBuffer*)resource->pointer; 557 break; 558 case OGG: 559 delete (OggPlayer*)resource->pointer; 560 break; 539 561 #endif /* NO_AUDIO */ 540 562 #ifndef NO_TEXT 541 542 543 563 case TTF: 564 delete (Font*)resource->pointer; 565 break; 544 566 #endif /* NO_TEXT */ 545 567 #ifndef NO_TEXTURES 546 547 548 568 case IMAGE: 569 delete (Texture*)resource->pointer; 570 break; 549 571 #endif /* NO_TEXTURES */ 550 572 #ifndef NO_SHADERS 551 552 553 573 case SHADER: 574 delete (Shader*)resource->pointer; 575 break; 554 576 #endif /* NO_SHADERS */ 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 577 default: 578 PRINTF(2)("NOT YET IMPLEMENTED !!FIX FIX!!\n"); 579 return false; 580 break; 581 } 582 // deleting the List Entry: 583 PRINTF(4)("Resource %s safely removed.\n", resource->name); 584 delete[] resource->name; 585 std::list<Resource*>::iterator resourceIT = std::find(this->resourceList.begin(), this->resourceList.end(), resource); 586 this->resourceList.erase(resourceIT); 587 delete resource; 588 } 589 else 590 PRINTF(4)("Resource %s not removed, because there are still %d References to it.\n", resource->name, resource->count); 591 } 570 592 else 571 593 PRINTF(4)("not deleting resource %s because DeleteLevel to high\n", resource->name); … … 590 612 resource = pre; 591 613 pre--; 592 if ((*resource)->prio <= prio) 614 if ((*resource)->prio <= prio) 615 { 616 if ((*resource)->count == 0) 617 unload((*resource), prio); 618 else 593 619 { 594 if ((*resource)->count == 0) 595 unload((*resource), prio); 596 else 597 { 598 PRINTF(2)("unable to unload %s because there are still %d references to it\n", 599 (*resource)->name, (*resource)->count); 600 removeCount++; 601 } 620 PRINTF(2)("unable to unload %s because there are still %d references to it\n", 621 (*resource)->name, (*resource)->count); 622 removeCount++; 602 623 } 603 } 604 if (removeCount == 0) break; 624 } 625 } 626 if (removeCount == 0) break; 605 627 } 606 628 } … … 617 639 */ 618 640 Resource* ResourceManager::locateResourceByInfo(const char* fileName, ResourceType type, 619 641 void* param1, void* param2, void* param3) const 620 642 { 621 643 std::list<Resource*>::const_iterator resource; … … 623 645 { 624 646 if ((*resource)->type == type && !strcmp(fileName, (*resource)->name)) 647 { 648 bool match = false; 649 650 switch (type) 651 { 652 #ifndef NO_MODEL 653 case PRIM: 654 case OBJ: 655 if (!param1) 625 656 { 626 bool match = false; 627 628 switch (type) 629 { 630 #ifndef NO_MODEL 631 case PRIM: 632 case OBJ: 633 if (!param1) 634 { 635 if ((*resource)->modelSize == 1.0) 636 match = true; 637 } 638 else if ((*resource)->modelSize == *(float*)param1) 639 match = true; 640 break; 641 case MD2: 642 if (!param1) 643 { 644 if ((*resource)->secFileName == NULL) 645 match = true; 646 } 647 else if (!strcmp((*resource)->secFileName, (const char*)param1)) 648 match = true; 649 break; 657 if ((*resource)->modelSize == 1.0) 658 match = true; 659 } 660 else if ((*resource)->modelSize == *(float*)param1) 661 match = true; 662 break; 663 case MD2: 664 if (!param1) 665 { 666 if ((*resource)->secFileName == NULL) 667 match = true; 668 } 669 else if (!strcmp((*resource)->secFileName, (const char*)param1)) 670 match = true; 671 break; 650 672 #endif /* NO_MODEL */ 651 673 #ifndef NO_TEXT 652 653 654 655 656 657 658 659 660 674 case TTF: 675 if (param1 == NULL) 676 { 677 if ((*resource)->ttfSize == FONT_DEFAULT_RENDER_SIZE) 678 match = true; 679 } 680 else if ((*resource)->ttfSize == *(unsigned int*)param1) 681 match = true; 682 break; 661 683 #endif /* NO_TEXT */ 662 684 #ifndef NO_SHADERS 663 664 665 666 667 668 669 670 685 case SHADER: 686 if (!param1) 687 { 688 if ((*resource)->secFileName == NULL) 689 match = true; 690 } 691 else if (!strcmp((*resource)->secFileName, (const char*)param1)) 692 match = true; 671 693 #endif /* NO_SHADERS */ 672 694 #ifndef NO_TEXTURES 673 674 675 676 677 678 679 680 695 case IMAGE: 696 if (!param1) 697 { 698 if ((*resource)->texTarget == GL_TEXTURE_2D) 699 match = true; 700 } 701 else if ((*resource)->texTarget == *(GLenum*)param1) 702 match = true; 681 703 #endif /* NO_TEXTURES */ 682 683 684 685 686 687 688 689 690 691 704 default: 705 match = true; 706 break; 707 } 708 if (match) 709 { 710 return (*resource); 711 } 712 } 713 } 692 714 return NULL; 693 715 } … … 704 726 for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++) 705 727 if (pointer == (*resource)->pointer) 706 728 return (*resource); 707 729 return NULL; 708 730 } … … 724 746 if (directoryName[strlen(directoryName)-1] == '/' || 725 747 directoryName[strlen(directoryName)-1] == '\\') 726 727 728 729 730 731 else 732 733 734 735 748 { 749 tmpDirName = new char[strlen(directoryName)]; 750 strncpy(tmpDirName, directoryName, strlen(directoryName)-1); 751 tmpDirName[strlen(directoryName)-1] = '\0'; 752 } 753 else 754 { 755 tmpDirName = new char[strlen(directoryName)+1]; 756 strcpy(tmpDirName, directoryName); 757 } 736 758 737 759 if(!stat(tmpDirName, &status)) 738 739 760 { 761 if (status.st_mode & (S_IFDIR 740 762 #ifndef __WIN32__ 741 742 #endif 743 744 745 746 747 748 749 750 751 752 753 763 | S_IFLNK 764 #endif 765 )) 766 { 767 delete[] tmpDirName; 768 return true; 769 } 770 else 771 { 772 delete[] tmpDirName; 773 return false; 774 } 775 } 754 776 else 755 777 { … … 772 794 struct stat status; 773 795 if (!stat(tmpFileName, &status)) 774 775 796 { 797 if (status.st_mode & (S_IFREG 776 798 #ifndef __WIN32__ 777 | S_IFLNK 778 #endif 779 )) 780 { 781 delete[] tmpFileName; 782 return true; 783 } 784 else 785 { 786 delete[] tmpFileName; 787 return false; 788 } 789 } 790 else 799 | S_IFLNK 800 #endif 801 )) 802 { 803 delete[] tmpFileName; 804 return true; 805 } 806 else 791 807 { 792 808 delete[] tmpFileName; 793 809 return false; 794 810 } 811 } 812 else 813 { 814 delete[] tmpFileName; 815 return false; 816 } 795 817 } 796 818 … … 806 828 FILE* stream; 807 829 if( (stream = fopen (tmpName, "w")) == NULL) 808 809 810 811 812 830 { 831 PRINTF(1)("could not open %s fro writing\n", fileName); 832 delete[] tmpName; 833 return false; 834 } 813 835 fclose(stream); 814 836 … … 840 862 char* retName; 841 863 if (!strncmp(name, "~/", 2)) 842 843 864 { 865 char tmpFileName[500]; 844 866 #ifdef __WIN32__ 845 867 strcpy(tmpFileName, getenv("USERPROFILE")); 846 868 #else 847 848 #endif 849 850 851 852 else 853 854 855 856 869 strcpy(tmpFileName, getenv("HOME")); 870 #endif 871 retName = new char[strlen(tmpFileName)+strlen(name)]; 872 sprintf(retName, "%s%s", tmpFileName, name+1); 873 } 874 else 875 { 876 retName = new char[strlen(name)+1]; 877 strcpy(retName, name); 878 } 857 879 return retName; 858 880 } … … 874 896 return retName; 875 897 else 876 877 878 879 898 { 899 delete[] retName; 900 return NULL; 901 } 880 902 } 881 903 … … 893 915 bool retVal = false; 894 916 char* checkFile = new char[strlen(ResourceManager::getInstance()->getDataDir()) 895 + strlen(fileName) + 1];917 + strlen(fileName) + 1]; 896 918 sprintf(checkFile, "%s%s", ResourceManager::getInstance()->getDataDir(), fileName); 897 919 … … 919 941 std::list<char*>::const_iterator imageDir; 920 942 for (imageDir = this->imageDirs.begin(); imageDir != this->imageDirs.end(); imageDir++) 921 943 PRINT(0)("%s ", (*imageDir)); 922 944 PRINT(0)("\n"); 923 945 … … 926 948 for (resource = this->resourceList.begin(); resource != this->resourceList.end(); resource++) 927 949 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 { 951 PRINT(0)("-----------------------------------------\n"); 952 PRINT(0)("Name: %s; References: %d; Type: %s ", (*resource)->name, (*resource)->count, ResourceManager::ResourceTypeToChar((*resource)->type)); 953 954 PRINT(0)("gets deleted at "); 955 switch((*resource)->prio) 956 { 957 default: 958 case RP_NO: 959 PRINT(0)("first posibility (0)\n"); 960 break; 961 case RP_LEVEL: 962 PRINT(0)("the end of the Level (1)\n"); 963 break; 964 case RP_CAMPAIGN: 965 PRINT(0)("the end of the campaign (2)\n"); 966 break; 967 case RP_GAME: 968 PRINT(0)("when leaving the game (3)\n"); 969 break; 970 } 971 } 950 972 951 973 … … 965 987 { 966 988 #ifndef NO_MODEL 967 968 969 970 971 972 973 974 975 989 case OBJ: 990 return "ObjectModel"; 991 break; 992 case PRIM: 993 return "PrimitiveModel"; 994 break; 995 case MD2: 996 return "MD2-Data"; 997 break; 976 998 #endif 977 999 #ifndef NO_TEXTURES 978 979 980 1000 case IMAGE: 1001 return "ImageFile (Texture)"; 1002 break; 981 1003 #endif 982 1004 #ifndef NO_AUDIO 983 984 985 986 987 988 1005 case WAV: 1006 return "SoundFile"; 1007 break; 1008 case OGG: 1009 return "MusicFile"; 1010 break; 989 1011 #endif 990 1012 #ifndef NO_TEXT 991 992 993 1013 case TTF: 1014 return "Font (TTF)"; 1015 break; 994 1016 #endif 995 1017 #ifndef NO_SHADERS 996 997 998 999 #endif 1000 1001 1002 1003 } 1004 } 1018 case SHADER: 1019 return "Shader"; 1020 break; 1021 #endif 1022 default: 1023 return "unknown Format"; 1024 break; 1025 } 1026 } -
trunk/src/util/loading/resource_manager.h
r6633 r6640 14 14 (NO_TEXT) 15 15 (NO_TEXTURES) 16 (NO_SHADERS) 16 17 */ 17 18 … … 114 115 bool verifyDataDir(const char* fileInside); 115 116 bool addImageDir(const char* imageDir); 117 118 void cache(const char* fileName, ResourceType type, ResourcePriority prio = RP_NO, 119 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); 120 116 121 BaseObject* load(const char* fileName, ResourcePriority prio = RP_NO, 117 122 void* param1 = NULL, void* param2 = NULL, void* param3 = NULL); … … 142 147 private: 143 148 ResourceManager(); 149 Resource* loadResource(const char* fileName, ResourceType type, ResourcePriority prio, 150 void* param1, void* param2, void* param3); 144 151 145 152 private:
Note: See TracChangeset
for help on using the changeset viewer.