diff --git a/src/NFT.net/Properties/Settings.Designer.cs b/src/NFT.net/Properties/Settings.Designer.cs
index 9c77c73..10b45ee 100644
--- a/src/NFT.net/Properties/Settings.Designer.cs
+++ b/src/NFT.net/Properties/Settings.Designer.cs
@@ -118,5 +118,29 @@ public string CollectionImageNamePrefix {
this["CollectionImageNamePrefix"] = value;
}
}
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("")]
+ public string MetadataExternalUrl {
+ get {
+ return ((string)(this["MetadataExternalUrl"]));
+ }
+ set {
+ this["MetadataExternalUrl"] = value;
+ }
+ }
+
+ [global::System.Configuration.UserScopedSettingAttribute()]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Configuration.DefaultSettingValueAttribute("False")]
+ public bool MetadataUseFileExtension {
+ get {
+ return ((bool)(this["MetadataUseFileExtension"]));
+ }
+ set {
+ this["MetadataUseFileExtension"] = value;
+ }
+ }
}
}
diff --git a/src/NFT.net/Properties/Settings.settings b/src/NFT.net/Properties/Settings.settings
index 10e2726..4bc5c7b 100644
--- a/src/NFT.net/Properties/Settings.settings
+++ b/src/NFT.net/Properties/Settings.settings
@@ -26,5 +26,11 @@
nft #
+
+
+
+
+ False
+
\ No newline at end of file
diff --git a/src/NFT.net/Services/Collection/CollectionService.cs b/src/NFT.net/Services/Collection/CollectionService.cs
index 074c096..9ec1201 100644
--- a/src/NFT.net/Services/Collection/CollectionService.cs
+++ b/src/NFT.net/Services/Collection/CollectionService.cs
@@ -35,7 +35,7 @@ public CollectionService(ILayerService layerService, IGeneratorService generator
public event EventHandler CollectionItemStatus;
- public void Create(string layersFolder, string outputFolder, int metadataType, string metadataDescription, string metadataImageBaseUri, int collectionSize, int collectionInitialNumber, string collectionImagePrefix)
+ public void Create(string layersFolder, string outputFolder, int metadataType, string metadataDescription, string metadataImageBaseUri, string metadataExternalUrl, bool metadataUseFileExtension, int collectionSize, int collectionInitialNumber, string collectionImagePrefix)
{
var layers = this.layerService.Load(layersFolder);
@@ -69,6 +69,7 @@ public void Create(string layersFolder, string outputFolder, int metadataType, s
Filename = Uri.EscapeDataString(filename),
Description = metadataDescription,
Image = $"{metadataImageBaseUri}/{Uri.EscapeDataString(filename)}",
+ ExternalUrl = metadataExternalUrl,
Attributes = item.Attributes.Select(i => new Model.Attribute { Layer = i.Layer, Value = i.Value }).ToList(),
};
@@ -89,7 +90,7 @@ public void Create(string layersFolder, string outputFolder, int metadataType, s
collectionNumber++;
}
- this.metadataService.Generate(outputFolder, metadataList, metadataType);
+ this.metadataService.Generate(outputFolder, metadataList, metadataType, metadataUseFileExtension);
this.rarityService.Generate(outputFolder, metadataList, metadataType);
}
diff --git a/src/NFT.net/Services/Collection/ICollectionService.cs b/src/NFT.net/Services/Collection/ICollectionService.cs
index d449b51..a281a0c 100644
--- a/src/NFT.net/Services/Collection/ICollectionService.cs
+++ b/src/NFT.net/Services/Collection/ICollectionService.cs
@@ -11,6 +11,6 @@ public interface ICollectionService
{
event EventHandler CollectionItemStatus;
- void Create(string layersFolder, string outputFolder, int metadataType, string metadataDescription, string metadataImageBaseUri, int collectionSize, int collectionInitialNumber, string collectionImagePrefix);
+ void Create(string layersFolder, string outputFolder, int metadataType, string metadataDescription, string metadataImageBaseUri, string metadataExternalUrl, bool metadataUseFileExtension, int collectionSize, int collectionInitialNumber, string collectionImagePrefix);
}
}
diff --git a/src/NFT.net/Services/Generator/GeneratorService.cs b/src/NFT.net/Services/Generator/GeneratorService.cs
index 7d8543a..e5aa6c6 100644
--- a/src/NFT.net/Services/Generator/GeneratorService.cs
+++ b/src/NFT.net/Services/Generator/GeneratorService.cs
@@ -22,7 +22,7 @@ public List Create(List layers, int collectionSize, stri
// Load predefined images (if available)
var presetDna = this.GetPresetDna(layersFolder);
- if (presetDna != null && presetDna.Preset != null && presetDna.Preset.Length > 0)
+ if (presetDna != null && presetDna.Preset != null && presetDna.Preset.Length > 0 && presetDna.Preset.Length < collectionSize)
{
foreach (var dna in presetDna.Preset)
{
diff --git a/src/NFT.net/Services/Metadata/IMetadataService.cs b/src/NFT.net/Services/Metadata/IMetadataService.cs
index 1dbd408..1980b5e 100644
--- a/src/NFT.net/Services/Metadata/IMetadataService.cs
+++ b/src/NFT.net/Services/Metadata/IMetadataService.cs
@@ -9,8 +9,8 @@ namespace Tedeschi.NFT.Services.Metadata
public interface IMetadataService
{
- void Generate(string outputFolder, List metadataList, int type);
+ void Generate(string outputFolder, List metadataList, int type, bool useFileExtension);
- void Update(string outputFolder, string newImageBaseUri, int type);
+ void Update(string outputFolder, string newImageBaseUri, int type, bool useFileExtension);
}
}
diff --git a/src/NFT.net/Services/Metadata/MetadataService.cs b/src/NFT.net/Services/Metadata/MetadataService.cs
index ead1dd8..fc7a2b6 100644
--- a/src/NFT.net/Services/Metadata/MetadataService.cs
+++ b/src/NFT.net/Services/Metadata/MetadataService.cs
@@ -11,9 +11,11 @@ namespace Tedeschi.NFT.Services.Metadata
internal class MetadataService : IMetadataService
{
- public void Generate(string outputFolder, List metadataList, int type)
+ public void Generate(string outputFolder, List metadataList, int type, bool useFileExtension)
{
var metadataLocation = $"{outputFolder}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.FolderName}";
+ var extension = useFileExtension == true ? Constants.FileExtension.Json : string.Empty;
+
var serializerSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
@@ -31,7 +33,7 @@ public void Generate(string outputFolder, List metadataList, int type)
}
var jsonMerged = JsonConvert.SerializeObject(metadataList, Formatting.Indented, serializerSettings);
- File.WriteAllText($"{metadataLocation}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.MergedFilename}{Constants.FileExtension.Json}", jsonMerged);
+ File.WriteAllText($"{metadataLocation}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.MergedFilename}{extension}", jsonMerged);
break;
case Constants.MetadataType.Individual:
@@ -43,16 +45,17 @@ public void Generate(string outputFolder, List metadataList, int type)
foreach (var metadata in metadataList)
{
var jsonIndividual = JsonConvert.SerializeObject(metadata, Formatting.Indented, serializerSettings);
- File.WriteAllText($"{metadataLocation}{Path.DirectorySeparatorChar}{metadata.Id}{Constants.FileExtension.Json}", jsonIndividual);
+ File.WriteAllText($"{metadataLocation}{Path.DirectorySeparatorChar}{metadata.Id}{extension}", jsonIndividual);
}
break;
}
}
- public void Update(string outputFolder, string newImageBaseUri, int type)
+ public void Update(string outputFolder, string newImageBaseUri, int type, bool useFileExtension)
{
var metadataLocation = $"{outputFolder}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.FolderName}";
+ var extension = useFileExtension == true ? Constants.FileExtension.Json : string.Empty;
switch (type)
{
@@ -61,7 +64,7 @@ public void Update(string outputFolder, string newImageBaseUri, int type)
case Constants.MetadataType.Merged:
{
- var filename = $"{metadataLocation}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.MergedFilename}{Constants.FileExtension.Json}";
+ var filename = $"{metadataLocation}{Path.DirectorySeparatorChar}{Constants.MetadataDefault.MergedFilename}{extension}";
var list = JsonConvert.DeserializeObject>(File.ReadAllText(filename));
foreach (var item in list)
@@ -69,7 +72,7 @@ public void Update(string outputFolder, string newImageBaseUri, int type)
item.Image = $"{newImageBaseUri}/{item.Filename}";
}
- this.Generate(outputFolder, list, type);
+ this.Generate(outputFolder, list, type, useFileExtension);
}
break;
@@ -78,7 +81,7 @@ public void Update(string outputFolder, string newImageBaseUri, int type)
{
var list = new List();
- foreach (string filename in Directory.GetFiles(metadataLocation, $"*{Constants.FileExtension.Json}"))
+ foreach (string filename in Directory.GetFiles(metadataLocation, $"*{extension}"))
{
var metadata = JsonConvert.DeserializeObject(File.ReadAllText(filename));
metadata.Image = $"{newImageBaseUri}/{metadata.Filename}";
@@ -86,7 +89,7 @@ public void Update(string outputFolder, string newImageBaseUri, int type)
list.Add(metadata);
}
- this.Generate(outputFolder, list, type);
+ this.Generate(outputFolder, list, type, useFileExtension);
}
break;
diff --git a/src/NFT.net/View/MainForm.Designer.cs b/src/NFT.net/View/MainForm.Designer.cs
index 6465175..84b177e 100644
--- a/src/NFT.net/View/MainForm.Designer.cs
+++ b/src/NFT.net/View/MainForm.Designer.cs
@@ -49,6 +49,9 @@ private void InitializeComponent()
this.buttonGenerate = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
+ this.checkBoxMetadataUseFileExtension = new System.Windows.Forms.CheckBox();
+ this.label7 = new System.Windows.Forms.Label();
+ this.textBoxMetadataExternalUrl = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.textBoxMetadataImageBaseURI = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
@@ -58,8 +61,8 @@ private void InitializeComponent()
this.toolStripStatus = new System.Windows.Forms.ToolStripStatusLabel();
this.menuStrip = new System.Windows.Forms.MenuStrip();
this.toolsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.updateMetadataImageBaseURIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.checkTraitWeightsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.updateMetadataImageBaseURIToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.helpToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox2.SuspendLayout();
@@ -126,7 +129,7 @@ private void InitializeComponent()
this.groupBox2.Controls.Add(this.label2);
this.groupBox2.Controls.Add(this.textBoxCollectionSize);
this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Location = new System.Drawing.Point(12, 317);
+ this.groupBox2.Location = new System.Drawing.Point(12, 351);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(465, 123);
this.groupBox2.TabIndex = 9;
@@ -199,7 +202,7 @@ private void InitializeComponent()
//
// buttonGenerate
//
- this.buttonGenerate.Location = new System.Drawing.Point(12, 446);
+ this.buttonGenerate.Location = new System.Drawing.Point(12, 480);
this.buttonGenerate.Name = "buttonGenerate";
this.buttonGenerate.Size = new System.Drawing.Size(465, 28);
this.buttonGenerate.TabIndex = 13;
@@ -217,6 +220,9 @@ private void InitializeComponent()
//
// groupBox3
//
+ this.groupBox3.Controls.Add(this.checkBoxMetadataUseFileExtension);
+ this.groupBox3.Controls.Add(this.label7);
+ this.groupBox3.Controls.Add(this.textBoxMetadataExternalUrl);
this.groupBox3.Controls.Add(this.label6);
this.groupBox3.Controls.Add(this.textBoxMetadataImageBaseURI);
this.groupBox3.Controls.Add(this.label5);
@@ -225,11 +231,37 @@ private void InitializeComponent()
this.groupBox3.Controls.Add(this.comboBoxMetadataType);
this.groupBox3.Location = new System.Drawing.Point(12, 190);
this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(465, 113);
+ this.groupBox3.Size = new System.Drawing.Size(465, 144);
this.groupBox3.TabIndex = 5;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Metadata";
//
+ // checkBoxMetadataUseExtension
+ //
+ this.checkBoxMetadataUseFileExtension.AutoSize = true;
+ this.checkBoxMetadataUseFileExtension.Location = new System.Drawing.Point(384, 21);
+ this.checkBoxMetadataUseFileExtension.Name = "checkBoxMetadataUseExtension";
+ this.checkBoxMetadataUseFileExtension.Size = new System.Drawing.Size(73, 19);
+ this.checkBoxMetadataUseFileExtension.TabIndex = 20;
+ this.checkBoxMetadataUseFileExtension.Text = "Use .json";
+ this.checkBoxMetadataUseFileExtension.UseVisualStyleBackColor = true;
+ //
+ // label7
+ //
+ this.label7.AutoSize = true;
+ this.label7.Location = new System.Drawing.Point(24, 112);
+ this.label7.Name = "label7";
+ this.label7.Size = new System.Drawing.Size(73, 15);
+ this.label7.TabIndex = 18;
+ this.label7.Text = "External URL";
+ //
+ // textBoxMetadataExternalUrl
+ //
+ this.textBoxMetadataExternalUrl.Location = new System.Drawing.Point(142, 108);
+ this.textBoxMetadataExternalUrl.Name = "textBoxMetadataExternalUrl";
+ this.textBoxMetadataExternalUrl.Size = new System.Drawing.Size(317, 23);
+ this.textBoxMetadataExternalUrl.TabIndex = 17;
+ //
// label6
//
this.label6.AutoSize = true;
@@ -267,7 +299,7 @@ private void InitializeComponent()
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripProgressBar,
this.toolStripStatus});
- this.statusStrip.Location = new System.Drawing.Point(0, 497);
+ this.statusStrip.Location = new System.Drawing.Point(0, 515);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(490, 22);
this.statusStrip.TabIndex = 10;
@@ -302,13 +334,6 @@ private void InitializeComponent()
this.toolsToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.toolsToolStripMenuItem.Text = "Tools";
//
- // updateMetadataImageBaseURIToolStripMenuItem
- //
- this.updateMetadataImageBaseURIToolStripMenuItem.Name = "updateMetadataImageBaseURIToolStripMenuItem";
- this.updateMetadataImageBaseURIToolStripMenuItem.Size = new System.Drawing.Size(249, 22);
- this.updateMetadataImageBaseURIToolStripMenuItem.Text = "Update Metadata Image Base URI";
- this.updateMetadataImageBaseURIToolStripMenuItem.Click += new System.EventHandler(this.UpdateMetadataImageBaseURIToolStripMenuItemOnClick);
- //
// checkTraitWeightsToolStripMenuItem
//
this.checkTraitWeightsToolStripMenuItem.Name = "checkTraitWeightsToolStripMenuItem";
@@ -316,6 +341,13 @@ private void InitializeComponent()
this.checkTraitWeightsToolStripMenuItem.Text = "Check Trait Weights";
this.checkTraitWeightsToolStripMenuItem.Click += new System.EventHandler(this.CheckTraitWeightsToolStripMenuItemOnClick);
//
+ // updateMetadataImageBaseURIToolStripMenuItem
+ //
+ this.updateMetadataImageBaseURIToolStripMenuItem.Name = "updateMetadataImageBaseURIToolStripMenuItem";
+ this.updateMetadataImageBaseURIToolStripMenuItem.Size = new System.Drawing.Size(249, 22);
+ this.updateMetadataImageBaseURIToolStripMenuItem.Text = "Update Metadata Image Base URI";
+ this.updateMetadataImageBaseURIToolStripMenuItem.Click += new System.EventHandler(this.UpdateMetadataImageBaseURIToolStripMenuItemOnClick);
+ //
// helpToolStripMenuItem
//
this.helpToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -327,7 +359,7 @@ private void InitializeComponent()
// aboutToolStripMenuItem
//
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
- this.aboutToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.aboutToolStripMenuItem.Size = new System.Drawing.Size(107, 22);
this.aboutToolStripMenuItem.Text = "About";
this.aboutToolStripMenuItem.Click += new System.EventHandler(this.AboutMenuItemOnClick);
//
@@ -335,7 +367,7 @@ private void InitializeComponent()
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(490, 519);
+ this.ClientSize = new System.Drawing.Size(490, 537);
this.Controls.Add(this.statusStrip);
this.Controls.Add(this.menuStrip);
this.Controls.Add(this.groupBox3);
@@ -349,8 +381,8 @@ private void InitializeComponent()
this.Controls.Add(this.groupBox2);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(506, 558);
- this.MinimumSize = new System.Drawing.Size(506, 558);
+ this.MaximumSize = new System.Drawing.Size(506, 576);
+ this.MinimumSize = new System.Drawing.Size(506, 576);
this.Name = "MainForm";
this.Text = "NFT.net";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.MainForm_OnFormClosed);
@@ -401,6 +433,9 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem updateMetadataImageBaseURIToolStripMenuItem;
private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;
private System.Windows.Forms.ToolStripMenuItem checkTraitWeightsToolStripMenuItem;
+ private System.Windows.Forms.Label label7;
+ private System.Windows.Forms.TextBox textBoxMetadataExternalUrl;
+ private System.Windows.Forms.CheckBox checkBoxMetadataUseFileExtension;
}
}
diff --git a/src/NFT.net/View/MainForm.cs b/src/NFT.net/View/MainForm.cs
index 07ad259..7809080 100644
--- a/src/NFT.net/View/MainForm.cs
+++ b/src/NFT.net/View/MainForm.cs
@@ -43,6 +43,8 @@ private void MainForm_OnLoad(object sender, EventArgs e)
this.comboBoxMetadataType.SelectedIndex = Properties.Settings.Default.MetadataType;
this.textBoxMetadataDescription.Text = Properties.Settings.Default.MetadataDescription;
this.textBoxMetadataImageBaseURI.Text = Properties.Settings.Default.MetadataImageBaseURI;
+ this.textBoxMetadataExternalUrl.Text = Properties.Settings.Default.MetadataExternalUrl;
+ this.checkBoxMetadataUseFileExtension.Checked = Properties.Settings.Default.MetadataUseFileExtension;
// Collection
this.textBoxCollectionSize.Text = Properties.Settings.Default.CollectionSize;
@@ -60,6 +62,8 @@ private void MainForm_OnFormClosed(object sender, FormClosedEventArgs e)
Properties.Settings.Default.MetadataType = this.comboBoxMetadataType.SelectedIndex;
Properties.Settings.Default.MetadataDescription = this.textBoxMetadataDescription.Text;
Properties.Settings.Default.MetadataImageBaseURI = this.textBoxMetadataImageBaseURI.Text;
+ Properties.Settings.Default.MetadataExternalUrl = this.textBoxMetadataExternalUrl.Text;
+ Properties.Settings.Default.MetadataUseFileExtension = this.checkBoxMetadataUseFileExtension.Checked;
// Collection
Properties.Settings.Default.CollectionSize = this.textBoxCollectionSize.Text;
@@ -84,11 +88,12 @@ private void UpdateMetadataImageBaseURIToolStripMenuItemOnClick(object sender, E
var outputFolder = this.textBoxOutputFolder.Text;
var metadataImageBaseUri = this.textBoxMetadataImageBaseURI.Text;
var metadataType = this.comboBoxMetadataType.SelectedIndex;
+ var metadataUseFileExtension = this.checkBoxMetadataUseFileExtension.Checked;
try
{
this.ValidateForUpdateMetadata(outputFolder, metadataImageBaseUri);
- this.metadataService.Update(outputFolder, metadataImageBaseUri, metadataType);
+ this.metadataService.Update(outputFolder, metadataImageBaseUri, metadataType, metadataUseFileExtension);
MessageBox.Show(Resource.METADATA_UPDATED_SUCCESSFULLY);
}
@@ -154,6 +159,8 @@ private void ButtonGenerateOnClick(object sender, EventArgs e)
var metadataType = this.comboBoxMetadataType.SelectedIndex;
var metadataDescription = this.textBoxMetadataDescription.Text;
var metadataImageBaseUri = this.textBoxMetadataImageBaseURI.Text;
+ var metadataExternalUrl = this.textBoxMetadataExternalUrl.Text;
+ var metadataUseFileExtension = this.checkBoxMetadataUseFileExtension.Checked;
var collectionSize = this.textBoxCollectionSize.Text;
var collectionInitialNumber = this.textBoxCollectionInitialNumber.Text;
@@ -166,7 +173,7 @@ private void ButtonGenerateOnClick(object sender, EventArgs e)
{
this.ValidateForGeneration(layersFolder, outputFolder, metadataImageBaseUri, collectionSize, collectionInitialNumber);
this.collectionService.CollectionItemStatus += new EventHandler(this.OnCollectionItemProcessed);
- this.collectionService.Create(layersFolder, outputFolder, metadataType, metadataDescription, metadataImageBaseUri, int.Parse(collectionSize), int.Parse(collectionInitialNumber), collectionImagePrefix);
+ this.collectionService.Create(layersFolder, outputFolder, metadataType, metadataDescription, metadataImageBaseUri, metadataExternalUrl, metadataUseFileExtension, int.Parse(collectionSize), int.Parse(collectionInitialNumber), collectionImagePrefix);
MessageBox.Show(Resource.COLLECTION_CREATED_SUCCESSFULLY);
}