Skip to content
This repository has been archived by the owner on Jan 6, 2022. It is now read-only.

Commit

Permalink
Shortened auto-generated file paths for import
Browse files Browse the repository at this point in the history
  • Loading branch information
REHERC committed Apr 23, 2021
1 parent 119aaf9 commit 9543eeb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
10 changes: 8 additions & 2 deletions App.AdventureMaker.Core/Forms/AddResourceWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ public class AddResourceWindow : Dialog<CampaignResource>
{
private readonly IEditor<CampaignFile> editor;

private readonly EnumDropDown<ResourceType> dropDown;
private readonly EnumRadioButtonList<ResourceType> dropDown;

public AddResourceWindow(IEditor<CampaignFile> editor)
{
this.editor = editor;

Title = "Add new resource";

Size = MinimumSize = new Size(400, 250);
Resizable = false;

Expand All @@ -32,7 +34,11 @@ public AddResourceWindow(IEditor<CampaignFile> editor)
new StackLayoutItem(new GroupBox()
{
Text = "Select a resource type to add",
Content = (dropDown = new EnumDropDown<ResourceType>())
Content = (dropDown = new EnumRadioButtonList<ResourceType>()
{
Orientation = Orientation.Vertical,
Spacing = new Size(8, 8)
})
}, true),
new StackLayoutItem(new StackLayout()
{
Expand Down
18 changes: 15 additions & 3 deletions App.AdventureMaker.Core/Global/ResourceImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Distance.AdventureMaker.Common.Models;
using System;
using System.IO;
using System.Text;

public static class ResourceImporter
{
Expand Down Expand Up @@ -49,10 +50,21 @@ public static DirectoryInfo GetPath(DirectoryInfo projectPath, FileInfo file, st

public static string GenerateDirectoryName(string path)
{
string guid = Guid.NewGuid().ToString("D");
string date = DateTime.Now.Ticks.ToString();
//string guid = Guid.NewGuid().ToString("D");
//string date = DateTime.Now.Ticks.ToString();
string root = !string.IsNullOrWhiteSpace(path) ? $"{path}/" : "";

return $"{root}imported/{guid}_{date}";
//return $"{root}imported/{guid}_{date}";

Random random = new Random((int)(DateTime.Now.Ticks % int.MaxValue));

StringBuilder sb = new StringBuilder();

while (sb.Length < 4)
{
sb.Append(random.Next(10));
}

return $"{root}imported/{sb}";
}
}

0 comments on commit 9543eeb

Please sign in to comment.