ApplicationOptions.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. /// <summary>
  45. /// iOS only
  46. /// </summary>
  47. public OrientationType Orientation { get; set; } = OrientationType.Landscape;
  48. /// <summary>
  49. /// Resource path(s) to use (default: Data, CoreData)
  50. /// </summary>
  51. public string[] ResourcePaths { get; set; } = null;
  52. /// <summary>
  53. /// Resource prefix path, default to URHO3D_PREFIX_PATH env-var or executable path
  54. /// </summary>
  55. public string ResourcePrefixPath { get; set; } = null;
  56. /// <summary>
  57. /// Resource package files to use (default: empty)
  58. /// </summary>
  59. public string[] ResourcePackagesPaths { get; set; } = null;
  60. /// <summary>
  61. /// Touch emulation on desktop platform
  62. /// </summary>
  63. public bool TouchEmulation { get; set; } = false;
  64. /// <summary>
  65. /// Add any flag listed here: http://urho3d.github.io/documentation/1.5/_running.html
  66. /// </summary>
  67. public string AdditionalFlags { get; set; } = string.Empty;
  68. /// <summary>
  69. /// Windows: external window handle (WinForms Panel.Handle) to use in order to display Urho game
  70. /// You can use it in WPF via WindowsFormsHost (and a WF panel inside it)
  71. /// </summary>
  72. public IntPtr ExternalWindow { get; set; }
  73. public enum OrientationType
  74. {
  75. Landscape,
  76. Portrait
  77. }
  78. public override string ToString()
  79. {
  80. StringBuilder builder = new StringBuilder();
  81. builder.Append("args");//it will be skipped by Urho;
  82. if (WindowedMode)
  83. builder.Append(" -w");
  84. if (!LimitFps)
  85. builder.Append(" -nolimit");
  86. if (Width > 0)
  87. builder.AppendFormat(" -x {0}", Width);
  88. if (Height > 0)
  89. builder.AppendFormat(" -y {0}", Height);
  90. if (ResizableWindow)
  91. builder.Append(" -s");
  92. var resourcePathes = new[] {"CoreData"}.Concat(ResourcePaths ?? new string[0]);
  93. builder.AppendFormat(" -p \"{0}\"", string.Join(";", resourcePathes.Distinct()));
  94. if (ResourcePackagesPaths?.Length > 0)
  95. builder.AppendFormat(" -pf \"{0}\"", string.Join(";", ResourcePackagesPaths));
  96. if (ResourcePrefixPath != null)
  97. builder.AppendFormat(" -pp \"{0}\"", ResourcePrefixPath);
  98. if (TouchEmulation)
  99. builder.Append(" -touch");
  100. builder.AppendFormat(" -{0}", Orientation.ToString().ToLower());
  101. return builder + " " + AdditionalFlags;
  102. }
  103. }
  104. }