LuxBasePersonal.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright © 2011-2020 Frictional Games
  3. *
  4. * This file is part of Amnesia: A Machine For Pigs.
  5. *
  6. * Amnesia: A Machine For Pigs is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. * Amnesia: A Machine For Pigs is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Amnesia: A Machine For Pigs. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. * LusBasePersonal.h
  20. * Lux
  21. *
  22. * Created by Edward Rudd on 8/27/10.
  23. * Copyright 2010 Frictional Games All rights reserved.
  24. *
  25. */
  26. /////////////////////////
  27. // Multi platform personal directory specifics.
  28. #if defined(WIN32)
  29. #define PERSONAL_RELATIVEROOT _W("")
  30. #define PERSONAL_RELATIVEPIECES
  31. #define PERSONAL_RELATIVEPIECES_COUNT 0
  32. #elif defined(__linux__)
  33. #define PERSONAL_RELATIVEROOT _W(".frictionalgames/")
  34. #define PERSONAL_RELATIVEPIECES _W(".frictionalgames"),
  35. #define PERSONAL_RELATIVEPIECES_COUNT 1
  36. #else
  37. #define PERSONAL_RELATIVEROOT _W("Frictional Games/")
  38. #define PERSONAL_RELATIVEPIECES _W("Frictional Games"),
  39. #define PERSONAL_RELATIVEPIECES_COUNT 1
  40. #endif
  41. #define PERSONAL_RELATIVEGAME_PARENT _W("Amnesia/")
  42. #define PERSONAL_RESOURCES _W("local_resources/")
  43. namespace hpl {
  44. inline void SetupBaseDirs(tWStringVec& vDirs, const tWString& asRelativeParent = _W(""), const tWString& asMainFolder = _W(""),
  45. bool userDir = false, const tWString& asCustomStoryPath = _W(""))
  46. {
  47. vDirs.clear();
  48. #if PERSONAL_RELATIVEPIECES_COUNT > 0
  49. tWString aDirs[] = { PERSONAL_RELATIVEPIECES };
  50. for (int i = 0; i < PERSONAL_RELATIVEPIECES_COUNT; ++i) {
  51. vDirs.push_back(aDirs[i]);
  52. }
  53. #endif
  54. if (asRelativeParent.length()) {
  55. vDirs.push_back(PERSONAL_RELATIVEROOT + asRelativeParent);
  56. if (asMainFolder.length()) {
  57. vDirs.push_back(PERSONAL_RELATIVEROOT + asRelativeParent + asMainFolder + _W("/"));
  58. }
  59. }
  60. vDirs.push_back(PERSONAL_RELATIVEROOT PERSONAL_RELATIVEGAME_PARENT);
  61. #ifndef HPL_MINIMAL
  62. iFileBrowser::msGameDir = cPlatform::GetWorkingDir();
  63. iFileBrowser::msPersonalDir = PERSONAL_RELATIVEROOT PERSONAL_RELATIVEGAME_PARENT;
  64. #endif
  65. if (userDir) {
  66. vDirs.push_back(PERSONAL_RELATIVEROOT PERSONAL_RELATIVEGAME_PARENT PERSONAL_RESOURCES);
  67. if (asCustomStoryPath.length()) {
  68. vDirs.push_back(PERSONAL_RELATIVEROOT PERSONAL_RELATIVEGAME_PARENT PERSONAL_RESOURCES
  69. + asCustomStoryPath + _W("/"));
  70. }
  71. }
  72. }
  73. inline void CreateBaseDirs(const tWStringVec& vDirs, const tWString& asRoot)
  74. {
  75. //Check if directories exist and if not create
  76. for(tWStringVec::const_iterator it = vDirs.begin(); it != vDirs.end(); ++it)
  77. {
  78. tWString sDir = asRoot + (*it);
  79. if(cPlatform::FolderExists(sDir)) continue;
  80. cPlatform::CreateFolder(sDir);
  81. }
  82. }
  83. }