Implement save directory
This commit is contained in:
parent
82e787984f
commit
0e3557f596
4 changed files with 78 additions and 19 deletions
15
.vscode/launch.json
vendored
15
.vscode/launch.json
vendored
|
@ -9,12 +9,17 @@
|
||||||
"type": "coreclr",
|
"type": "coreclr",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/bin/Debug/netcoreapp3.1/GraalGmapGenerator.dll",
|
"program": "${workspaceFolder}/GraalGmapGenerator/bin/Debug/netcoreapp3.1/GraalGmapGenerator.dll",
|
||||||
"args": [],
|
"args": [],
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}/GraalGmapGenerator",
|
||||||
"stopAtEntry": false,
|
"console": "externalTerminal",
|
||||||
"console": "internalConsole"
|
"stopAtEntry": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach",
|
||||||
|
"processId": "${command:pickProcess}"
|
||||||
}
|
}
|
||||||
|
|
||||||
]
|
]
|
||||||
}
|
}
|
36
.vscode/tasks.json
vendored
36
.vscode/tasks.json
vendored
|
@ -1,23 +1,41 @@
|
||||||
{
|
{
|
||||||
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
|
||||||
// for the documentation about the tasks.json format
|
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "build",
|
"label": "build",
|
||||||
"command": "dotnet",
|
"command": "dotnet",
|
||||||
"type": "shell",
|
"type": "process",
|
||||||
"args": [
|
"args": [
|
||||||
"build",
|
"build",
|
||||||
// Ask dotnet build to generate full paths for file names.
|
"${workspaceFolder}/GraalGmapGenerator/GraalGmapGenerator.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "publish",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"publish",
|
||||||
|
"${workspaceFolder}/GraalGmapGenerator/GraalGmapGenerator.csproj",
|
||||||
|
"/property:GenerateFullPaths=true",
|
||||||
|
"/consoleloggerparameters:NoSummary"
|
||||||
|
],
|
||||||
|
"problemMatcher": "$msCompile"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "watch",
|
||||||
|
"command": "dotnet",
|
||||||
|
"type": "process",
|
||||||
|
"args": [
|
||||||
|
"watch",
|
||||||
|
"run",
|
||||||
|
"${workspaceFolder}/GraalGmapGenerator/GraalGmapGenerator.csproj",
|
||||||
"/property:GenerateFullPaths=true",
|
"/property:GenerateFullPaths=true",
|
||||||
// Do not generate summary otherwise it leads to duplicate errors in Problems panel
|
|
||||||
"/consoleloggerparameters:NoSummary"
|
"/consoleloggerparameters:NoSummary"
|
||||||
],
|
],
|
||||||
"group": "build",
|
|
||||||
"presentation": {
|
|
||||||
"reveal": "silent"
|
|
||||||
},
|
|
||||||
"problemMatcher": "$msCompile"
|
"problemMatcher": "$msCompile"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using GraalGmapGenerator.Validators;
|
using GraalGmapGenerator.Validators;
|
||||||
|
|
||||||
namespace GraalGmapGenerator
|
namespace GraalGmapGenerator
|
||||||
{
|
{
|
||||||
class Program
|
class Programfg
|
||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +66,7 @@ namespace GraalGmapGenerator
|
||||||
Console.WriteLine("Load full map? (y/n)...");
|
Console.WriteLine("Load full map? (y/n)...");
|
||||||
Console.WriteLine("INFO: Loads all map parts into memory on startup.");
|
Console.WriteLine("INFO: Loads all map parts into memory on startup.");
|
||||||
|
|
||||||
var loadFullMapStr = GetInput(
|
string loadFullMapStr = GetInput(
|
||||||
inputFunc: () => Console.ReadLine(),
|
inputFunc: () => Console.ReadLine(),
|
||||||
validator: (input) =>
|
validator: (input) =>
|
||||||
{
|
{
|
||||||
|
@ -84,7 +85,7 @@ namespace GraalGmapGenerator
|
||||||
Console.WriteLine("No automapping? (y/n)...");
|
Console.WriteLine("No automapping? (y/n)...");
|
||||||
Console.WriteLine("INFO: Disables the assembly of automagical screenshots into a map that is drawn over the MAPIMG image.");
|
Console.WriteLine("INFO: Disables the assembly of automagical screenshots into a map that is drawn over the MAPIMG image.");
|
||||||
|
|
||||||
var noAutoMappingStr = GetInput(
|
string noAutoMappingStr = GetInput(
|
||||||
inputFunc: () => Console.ReadLine(),
|
inputFunc: () => Console.ReadLine(),
|
||||||
validator: (input) =>
|
validator: (input) =>
|
||||||
{
|
{
|
||||||
|
@ -103,12 +104,30 @@ namespace GraalGmapGenerator
|
||||||
Console.WriteLine("Save directory...");
|
Console.WriteLine("Save directory...");
|
||||||
Console.WriteLine($"INFO: If you do not wish to provide a save directory, you can leave this setting blank (hit ENTER) and the GMAP will be created under \"gmaps/\" in the application directory ({AppDomain.CurrentDomain.BaseDirectory}/gmaps/{gmapName}/)");
|
Console.WriteLine($"INFO: If you do not wish to provide a save directory, you can leave this setting blank (hit ENTER) and the GMAP will be created under \"gmaps/\" in the application directory ({AppDomain.CurrentDomain.BaseDirectory}/gmaps/{gmapName}/)");
|
||||||
|
|
||||||
// string saveDirectory =
|
string saveDirectory = GetInput(
|
||||||
|
() => Console.ReadLine(),
|
||||||
|
(input) =>
|
||||||
|
{
|
||||||
|
if (input != "" && !GmapPropertyValidators.IsValidDirectory(input))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Please provide a valid directory path.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (saveDirectory == "")
|
||||||
|
{
|
||||||
|
saveDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "gmaps", gmapName);
|
||||||
|
}
|
||||||
|
|
||||||
Console.WriteLine("Generating gmap...");
|
Console.WriteLine("Generating gmap...");
|
||||||
var gmap = mapBuilder.Build();
|
var gmap = mapBuilder.Build();
|
||||||
|
|
||||||
Console.WriteLine("Saving gmap...");
|
Console.WriteLine("Saving gmap...");
|
||||||
GmapWriter.SaveGmap(gmap);
|
GmapWriter.SaveGmap(saveDirectory, gmap);
|
||||||
|
|
||||||
Console.WriteLine("Done!");
|
Console.WriteLine("Done!");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace GraalGmapGenerator.Validators
|
namespace GraalGmapGenerator.Validators
|
||||||
{
|
{
|
||||||
|
@ -18,5 +20,20 @@ namespace GraalGmapGenerator.Validators
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool IsValidDirectory(string input)
|
||||||
|
{
|
||||||
|
char[] inputChars = input.ToCharArray();
|
||||||
|
char[] fsInvalidPathChars = Path.GetInvalidPathChars();
|
||||||
|
foreach (char inputChar in inputChars)
|
||||||
|
{
|
||||||
|
if (fsInvalidPathChars.Contains(inputChar))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue