-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dr.Abc
committed
Aug 16, 2024
1 parent
999c18e
commit 1ffe6cc
Showing
12 changed files
with
199 additions
and
145 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
using CliFx; | ||
namespace SPRView.Net.Cli; | ||
|
||
namespace SPRView.Net.CLI.Cli; | ||
public class CLICommandManager | ||
{ | ||
public async void Run(string[] args) => await new CliApplicationBuilder() | ||
.AddCommand<ThumbnailCommand>() | ||
.AddCommand<SaveImageCommand>() | ||
.AddCommand<InformationCommand>() | ||
.AddCommand<PreviewCommand>() | ||
.AddCommand<CreateCommand>() | ||
.Build() | ||
.RunAsync(args); | ||
} |
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,46 @@ | ||
using CliFx; | ||
using CliFx.Attributes; | ||
using CliFx.Infrastructure; | ||
using SPRView.Net.Lib.Class; | ||
using SPRView.Net.Lib.Interface; | ||
|
||
namespace SPRView.Net.CLI.Cli; | ||
|
||
[Command("create", Description = "create a spr from files")] | ||
public class CreateCommand : ICommand | ||
{ | ||
[CommandParameter(0, Description = "Images path, Use \",\" connect multiple paths")] | ||
public required string Paths { get; set; } | ||
|
||
[CommandParameter(1, Description = "Spr width")] | ||
public required int Width { get; set; } | ||
|
||
[CommandParameter(2, Description = "Spr Height")] | ||
public required int Height { get; set; } | ||
|
||
[CommandParameter(3, Description = "Path to save spr file")] | ||
public required string SavePath { get; set; } | ||
|
||
[CommandOption("type", 't', Description = "Spr type")] | ||
public int Type { get; set; } = (int)ISprite.SpriteType.Parallel; | ||
|
||
[CommandOption("format", 'f', Description = "Spr format")] | ||
public int Format { get; set; } = (int)ISprite.SpriteFormat.Normal; | ||
|
||
[CommandOption("sync", 's', Description = "Spr sync")] | ||
public bool Sync { get; set; } = true; | ||
|
||
[CommandOption("beam length", 'b', Description = "Spr beam lenght")] | ||
public float BeamLenght { get; set; } = 0.0f; | ||
|
||
[CommandOption("unpack", 'u', Description = "Unpack multiple frames of images")] | ||
public bool Unpack { get; set; } = false; | ||
|
||
public ValueTask ExecuteAsync(IConsole console) | ||
{ | ||
using FileStream fs = File.OpenWrite(SavePath); | ||
string[] paths = Array.ConvertAll(Paths.Split(','), s => s.Trim()); | ||
CSprite.Save(paths, fs, Width, Height, (ISprite.SpriteFormat)Format, (ISprite.SpriteType)Type, (ISprite.SpriteSynchron)(Sync ? 0 : 1), BeamLenght, Unpack); | ||
return default; | ||
} | ||
} |
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
using SPRView.Net.Cli; | ||
using SPRView.Net.CLI.Cli; | ||
CLICommandManager cli = new(); | ||
cli.Run(args); |
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
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
Oops, something went wrong.