Simple game engine with complete export to scripting language
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

61 lines
1.0 KiB

  1. #include "Application.h"
  2. #include "Utilities/Log.h"
  3. #include "physfs.h"
  4. using namespace BlueCore;
  5. void initializePhysfs(char* program)
  6. {
  7. // setup physfs
  8. PHYSFS_init(program);
  9. std::string appdir = PHYSFS_getUserDir();
  10. appdir += ".bluecore";
  11. if ( !PHYSFS_setWriteDir(appdir.c_str()) )
  12. {
  13. if ( (PHYSFS_setWriteDir(PHYSFS_getUserDir()))
  14. && (PHYSFS_mkdir(".bluecore")))
  15. PHYSFS_setWriteDir(appdir.c_str() );
  16. }
  17. PHYSFS_addToSearchPath(appdir.c_str(), 0);
  18. PHYSFS_addToSearchPath("data", 1);
  19. char **rc = PHYSFS_enumerateFiles("");
  20. for (char **i = rc; *i != 0; i++)
  21. {
  22. std::string filename( *i);
  23. if (filename.substr(filename.size() - 4, 4) == ".zip")
  24. {
  25. PHYSFS_addToSearchPath(( "data/" + filename ).c_str(), 1);
  26. clog << ">>> Using addon: "<< filename << endlog;
  27. }
  28. }
  29. PHYSFS_freeList(rc);
  30. }
  31. void shutdownPhysfs()
  32. {
  33. PHYSFS_deinit();
  34. }
  35. int main(int argc, char **argv)
  36. {
  37. initializePhysfs(argv[0]);
  38. ref_ptr<Application> app = new Application();
  39. if (app->initialize())
  40. {
  41. app->run();
  42. }
  43. app->shutdown();
  44. shutdownPhysfs();
  45. }