ApplicationOptions.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. namespace Urho
  5. {
  6. /// <summary>
  7. /// Application options, see full description at:
  8. /// http://urho3d.github.io/documentation/1.5/_running.html
  9. /// </summary>
  10. public class ApplicationOptions
  11. {
  12. /// <param name="assetsFolder">usually it's "Data". Can be null if built-in assets are enough for you</param>
  13. public ApplicationOptions(string assetsFolder)
  14. {
  15. if (assetsFolder != null)
  16. {
  17. ResourcePaths = new[] { assetsFolder };
  18. }
  19. }
  20. public ApplicationOptions(string[] assetsFolders)
  21. {
  22. ResourcePaths = assetsFolders;
  23. }
  24. /// <summary>
  25. /// Desktop only
  26. /// </summary>
  27. public int Width { get; set; } = 0;
  28. /// <summary>
  29. /// Desktop only
  30. /// </summary>
  31. public int Height { get; set; } = 0;
  32. /// <summary>
  33. /// Desktop only
  34. /// </summary>
  35. public bool WindowedMode { get; set; } = true;
  36. /// <summary>
  37. /// Desktop only
  38. /// </summary>
  39. public bool ResizableWindow { get; set; } = false;
  40. /// <summary>
  41. /// With limit enabled: 200 fps for Desktop (and always 60 fps for mobile despite of the flag)
  42. /// </summary>
  43. public bool LimitFps { get; set; } = true;
  44. #if XFORMS
  45. /// <summary>
  46. /// iOS only
  47. /// </summary>
  48. public OrientationType Orientation { get; set; } = OrientationType.Portrait;
  49. #else
  50. /// <summary>
  51. /// iOS only
  52. /// </summary>
  53. public OrientationType Orientation { get; set; } = OrientationType.Landscape;
  54. #endif
  55. /// <summary>
  56. /// Resource path(s) to use (default: Data, CoreData)
  57. /// </summary>
  58. public string[] ResourcePaths { get; set; } = null;
  59. /// <summary>
  60. /// Resource package files to use (default: empty)
  61. /// </summary>
  62. public string[] ResourcePackagesPaths { get; set; } = null;
  63. /// <summary>
  64. /// Touch emulation on desktop platform
  65. /// </summary>
  66. public bool TouchEmulation { get; set; } = false;
  67. /// <summary>
  68. /// Add any flag listed here: http://urho3d.github.io/documentation/1.5/_running.html
  69. /// </summary>
  70. public string AdditionalFlags { get; set; } = string.Empty;
  71. /// <summary>
  72. /// Windows: external window handle (WinForms Panel.Handle) to use in order to display Urho game
  73. /// You can use it in WPF via WindowsFormsHost (and a WF panel inside it)
  74. /// </summary>
  75. public IntPtr ExternalWindow { get; set; }
  76. public enum OrientationType
  77. {
  78. Landscape,
  79. Portrait,
  80. LandscapeAndPortrait
  81. }
  82. public override string ToString()
  83. {
  84. StringBuilder builder = new StringBuilder();
  85. builder.Append("args");//it will be skipped by Urho;
  86. #if !IOS //always use -w on iOS
  87. if (WindowedMode)
  88. #endif
  89. builder.Append(" -w");
  90. if (!LimitFps)
  91. builder.Append(" -nolimit");
  92. if (Width > 0)
  93. builder.AppendFormat(" -x {0}", Width);
  94. if (Height > 0)
  95. builder.AppendFormat(" -y {0}", Height);
  96. #if !IOS //always use -s on iOS
  97. if (ResizableWindow)
  98. #endif
  99. builder.Append(" -s");
  100. var resourcePathes = new[] {"CoreData"}.Concat(ResourcePaths ?? new string[0]);
  101. builder.AppendFormat(" -p \"{0}\"", string.Join(";", resourcePathes.Distinct()));
  102. if (ResourcePackagesPaths?.Length > 0)
  103. builder.AppendFormat(" -pf \"{0}\"", string.Join(";", ResourcePackagesPaths));
  104. if (TouchEmulation)
  105. builder.Append(" -touch");
  106. switch (Orientation)
  107. {
  108. case OrientationType.Landscape:
  109. builder.Append(" -landscape");
  110. break;
  111. case OrientationType.Portrait:
  112. builder.Append(" -portrait");
  113. break;
  114. case OrientationType.LandscapeAndPortrait:
  115. builder.Append(" -landscape -portrait");
  116. break;
  117. }
  118. return builder + " " + AdditionalFlags;
  119. }
  120. }
  121. }