-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow setting download location from command line arguments
- Loading branch information
1 parent
f33c616
commit 99580a6
Showing
4 changed files
with
79 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
namespace YARG | ||
{ | ||
public struct CommandLineArgs | ||
{ | ||
// Yes, the arguments should probably be prefixed with "--", however, this is based upon | ||
// Unity's existing command line arguments to make them consistent in style. | ||
|
||
/// <summary> | ||
/// Whether or not the game should be launched in offline mode. Offline mode disables | ||
/// offline features such as fetching the OpenSource icons. | ||
/// </summary> | ||
private const string OFFLINE_ARG = "-offline"; | ||
|
||
/// <summary> | ||
/// Used to select the language the game will be launcher in. The argument after should be | ||
/// the language code. | ||
/// </summary> | ||
private const string LANGUAGE_ARG = "-lang"; | ||
|
||
/// <summary> | ||
/// Used to reference the download location of YARG and all of its setlists (by the launcher). | ||
/// The argument after should be the download location path. | ||
/// </summary> | ||
private const string DOWNLOAD_LOCATION_ARG = "-download-location"; | ||
|
||
public bool Offline { get; private set; } | ||
public string Language { get; private set; } | ||
public string DownloadLocation { get; private set; } | ||
|
||
public static CommandLineArgs Parse(string[] args) | ||
{ | ||
var output = new CommandLineArgs(); | ||
|
||
// Remember, the first argument is always the application itself | ||
for (int i = 1; i < args.Length; i++) | ||
{ | ||
switch (args[i]) | ||
{ | ||
case OFFLINE_ARG: | ||
output.Offline = true; | ||
break; | ||
case LANGUAGE_ARG: | ||
i++; | ||
if (i < args.Length) | ||
{ | ||
output.Language = args[i]; | ||
} | ||
break; | ||
case DOWNLOAD_LOCATION_ARG: | ||
i++; | ||
if (i < args.Length) | ||
{ | ||
output.DownloadLocation = args[i]; | ||
} | ||
break; | ||
} | ||
} | ||
|
||
return output; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters