| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- using System;
- using System.Linq;
- using System.Text;
- namespace Urho
- {
- /// <summary>
- /// Application options, see full description at:
- /// http://urho3d.github.io/documentation/1.5/_running.html
- /// </summary>
- public class ApplicationOptions
- {
- /// <param name="assetsFolder">usually it's "Data". Can be null if built-in assets are enough for you</param>
- public ApplicationOptions(string assetsFolder)
- {
- if (assetsFolder != null)
- {
- ResourcePaths = new[] { assetsFolder };
- }
- }
- public ApplicationOptions(string[] assetsFolders)
- {
- ResourcePaths = assetsFolders;
- }
- /// <summary>
- /// Desktop only
- /// </summary>
- public int Width { get; set; } = 0;
- /// <summary>
- /// Desktop only
- /// </summary>
- public int Height { get; set; } = 0;
-
- /// <summary>
- /// Desktop only
- /// </summary>
- public bool WindowedMode { get; set; } = true;
- /// <summary>
- /// Desktop only
- /// </summary>
- public bool ResizableWindow { get; set; } = false;
- /// <summary>
- /// With limit enabled: 200 fps for Desktop (and always 60 fps for mobile despite of the flag)
- /// </summary>
- public bool LimitFps { get; set; } = true;
- #if XFORMS
- /// <summary>
- /// iOS only
- /// </summary>
- public OrientationType Orientation { get; set; } = OrientationType.Portrait;
- #else
- /// <summary>
- /// iOS only
- /// </summary>
- public OrientationType Orientation { get; set; } = OrientationType.Landscape;
- #endif
- /// <summary>
- /// Resource path(s) to use (default: Data, CoreData)
- /// </summary>
- public string[] ResourcePaths { get; set; } = null;
- /// <summary>
- /// Resource package files to use (default: empty)
- /// </summary>
- public string[] ResourcePackagesPaths { get; set; } = null;
- #if WINDOWS_UWP
- public bool TouchEmulation { get { return true; } set {} }
- #else
- /// <summary>
- /// Touch emulation on desktop platform
- /// </summary>
- public bool TouchEmulation { get; set; } = false;
- #endif
- /// <summary>
- /// Add any flag listed here: http://urho3d.github.io/documentation/1.5/_running.html
- /// </summary>
- public string AdditionalFlags { get; set; } = string.Empty;
- /// <summary>
- /// Windows: external window handle (WinForms Panel.Handle) to use in order to display Urho game
- /// You can use it in WPF via WindowsFormsHost (and a WF panel inside it)
- /// </summary>
- public IntPtr ExternalWindow { get; set; }
- public enum OrientationType
- {
- Landscape,
- Portrait,
- LandscapeAndPortrait
- }
- public override string ToString()
- {
- StringBuilder builder = new StringBuilder();
- builder.Append("args");//it will be skipped by Urho;
- #if !IOS //always use -w on iOS
- if (WindowedMode)
- #endif
- builder.Append(" -w");
- if (!LimitFps)
- builder.Append(" -nolimit");
- if (Width > 0)
- builder.AppendFormat(" -x {0}", Width);
- if (Height > 0)
- builder.AppendFormat(" -y {0}", Height);
- #if !IOS //always use -s on iOS and UWP
- if (ResizableWindow)
- #endif
- builder.Append(" -s");
- var resourcePathes = new[] {"CoreData"}.Concat(ResourcePaths ?? new string[0]);
- builder.AppendFormat(" -p \"{0}\"", string.Join(";", resourcePathes.Distinct()));
- if (ResourcePackagesPaths?.Length > 0)
- builder.AppendFormat(" -pf \"{0}\"", string.Join(";", ResourcePackagesPaths));
- #if !WINDOWS_UWP
- if (TouchEmulation)
- #endif
- builder.Append(" -touch");
- switch (Orientation)
- {
- case OrientationType.Landscape:
- builder.Append(" -landscape");
- break;
- case OrientationType.Portrait:
- builder.Append(" -portrait");
- break;
- case OrientationType.LandscapeAndPortrait:
- builder.Append(" -landscape -portrait");
- break;
- }
- return builder + " " + AdditionalFlags;
- }
- }
- }
|