ApplicationOptions.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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() {}
  21. /// <summary>
  22. /// Desktop only
  23. /// </summary>
  24. public int Width { get; set; } = 0;
  25. /// <summary>
  26. /// Desktop only
  27. /// </summary>
  28. public int Height { get; set; } = 0;
  29. /// <summary>
  30. /// Desktop only
  31. /// </summary>
  32. public bool WindowedMode { get; set; } = true;
  33. /// <summary>
  34. /// Desktop only
  35. /// </summary>
  36. public bool ResizableWindow { get; set; } = false;
  37. /// <summary>
  38. /// With limit enabled: 200 fps for Desktop (and always 60 fps for mobile despite of the flag)
  39. /// </summary>
  40. public bool LimitFps { get; set; } = true;
  41. #if XFORMS
  42. /// <summary>
  43. /// iOS only
  44. /// </summary>
  45. public OrientationType Orientation { get; set; } = OrientationType.LandscapeAndPortrait;
  46. #else
  47. /// <summary>
  48. /// iOS only
  49. /// </summary>
  50. public OrientationType Orientation { get; set; } = OrientationType.Landscape;
  51. #endif
  52. /// <summary>
  53. /// Resource path(s) to use (default: Data, CoreData)
  54. /// </summary>
  55. public string[] ResourcePaths { get; set; } = null;
  56. /// <summary>
  57. /// Resource package files to use (default: empty)
  58. /// </summary>
  59. public string[] ResourcePackagesPaths { get; set; } = null;
  60. #if WINDOWS_UWP
  61. public bool TouchEmulation { get { return true; } set {} }
  62. #else
  63. /// <summary>
  64. /// Touch emulation on desktop platform
  65. /// </summary>
  66. public bool TouchEmulation { get; set; } = false;
  67. #endif
  68. /// <summary>
  69. /// Enable high DPI, only supported by Apple platforms (OSX, iOS, and tvOS)
  70. /// </summary>
  71. public bool HighDpi { get; set; } = true;
  72. /// <summary>
  73. /// Add any flag listed here: http://urho3d.github.io/documentation/1.5/_running.html
  74. /// </summary>
  75. public string AdditionalFlags { get; set; } = string.Empty;
  76. /// <summary>
  77. /// Windows: external window handle (WinForms Panel.Handle) to use in order to display Urho game
  78. /// You can use it in WPF via WindowsFormsHost (and a WF panel inside it)
  79. /// </summary>
  80. public IntPtr ExternalWindow { get; set; }
  81. public bool DelayedStart { get; set; } = false;
  82. public bool AutoloadCoreData { get; set; } = true;
  83. public string[] ResourcePrefixPaths { get; set; }
  84. public enum OrientationType
  85. {
  86. Landscape,
  87. Portrait,
  88. LandscapeAndPortrait
  89. }
  90. public override string ToString()
  91. {
  92. StringBuilder builder = new StringBuilder();
  93. builder.Append("args");//it will be skipped by Urho;
  94. #if !IOS //always use -w on iOS
  95. if (WindowedMode)
  96. #endif
  97. builder.Append(" -w");
  98. if (!LimitFps)
  99. builder.Append(" -nolimit");
  100. if (DelayedStart)
  101. builder.Append(" -delayedstart");
  102. if (Width > 0)
  103. builder.AppendFormat(" -x {0}", Width);
  104. if (Height > 0)
  105. builder.AppendFormat(" -y {0}", Height);
  106. #if !IOS //always use -s on iOS and UWP
  107. if (ResizableWindow)
  108. #endif
  109. builder.Append(" -s");
  110. string[] resourcePathes = new[] { "CoreData" }.Concat(ResourcePaths ?? new string[0]).ToArray();
  111. if (!AutoloadCoreData)
  112. resourcePathes = ResourcePaths ?? new string[0];
  113. builder.AppendFormat(" -p \"{0}\"", string.Join(";", resourcePathes.Distinct()));
  114. if (ResourcePackagesPaths?.Length > 0)
  115. builder.AppendFormat(" -pf \"{0}\"", string.Join(";", ResourcePackagesPaths));
  116. if (ResourcePrefixPaths?.Length > 0)
  117. builder.AppendFormat(" -pp \"{0}\"", string.Join(";", ResourcePrefixPaths));
  118. #if !WINDOWS_UWP
  119. if (TouchEmulation)
  120. #endif
  121. builder.Append(" -touch");
  122. if (HighDpi)
  123. builder.Append(" -hd");
  124. switch (Orientation)
  125. {
  126. case OrientationType.Landscape:
  127. builder.Append(" -landscape");
  128. break;
  129. case OrientationType.Portrait:
  130. builder.Append(" -portrait");
  131. break;
  132. case OrientationType.LandscapeAndPortrait:
  133. builder.Append(" -landscape -portrait");
  134. break;
  135. }
  136. return builder + " " + AdditionalFlags;
  137. }
  138. }
  139. }