Skip to content

Commit

Permalink
Updated images, fallacy taxonomy, introduced cross links
Browse files Browse the repository at this point in the history
  • Loading branch information
jsboige committed Jan 21, 2024
1 parent 2749dc1 commit 0391bf2
Show file tree
Hide file tree
Showing 11 changed files with 1,340 additions and 1,119 deletions.
2,232 changes: 1,169 additions & 1,063 deletions Cards/Fallacies/Argumentum Fallacies - Taxonomy.csv

Large diffs are not rendered by default.

Binary file modified Cards/Fallacies/Assets/Fallacy-front/2.2.1.2.1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Cards/Fallacies/Assets/Fallacy-front/6.2.3.4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class AssetConverterConfig

public bool SkipConfigFile { get; set; } = true;

public ConverterMode Mode { get; set; } = ConverterMode.Mindmapper | ConverterMode.WebBasedImageGeneration;
public ConverterMode Mode { get; set; } = ConverterMode.Mindmapper;// | ConverterMode.WebBasedImageGeneration;

public bool ForceDebugParams { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace Argumentum.AssetConverter.Entities
public class Fallacy : CsvBase<Fallacy, FallacyClassMap>
{

public string GetId()
{
return Path;
}

public string LinkFrFallback => string.IsNullOrEmpty(LinkFr) ? LinkEn : LinkFr;

public string LinkEnFallback => string.IsNullOrEmpty(LinkEn) ? LinkFr : LinkEn;
Expand Down Expand Up @@ -100,7 +105,13 @@ public class Fallacy : CsvBase<Fallacy, FallacyClassMap>
public string Image { get; set; }
public string SvgColor { get; set; }
public string SvgIllustration { get; set; }
}

public int? PrintAndPlay { get; set; }

public string DécimalPathPadded { get; set; }

public string DepthMax4 { get; set; }
}

public sealed class FallacyClassMap : ClassMap<Fallacy>
{
Expand Down Expand Up @@ -165,8 +176,11 @@ public FallacyClassMap()
Map(m => m.Image).Name("image");
Map(m => m.SvgColor).Name("svg_color");
Map(m => m.SvgIllustration).Name("svg_illustration");
}
}
Map(m => m.PrintAndPlay).Name("print_and_play");
Map(m => m.DécimalPathPadded).Name("decimal_path_padded");
Map(m => m.DepthMax4).Name("depth_max4");
}
}



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;

namespace Argumentum.AssetConverter.Mindmapper;

[Flags]
public enum CrossLink
{
None = 0,
Identity = 1 << 0, // 1
Opposite = 1 << 1, // 2
AppealTo = 1 << 2, // 4
Symmetric = 1 << 3, // 8
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,35 @@ public class Icon
public string BUILTIN { get; set; }
}


[XmlRoot(ElementName = "arrowlink")]
public class Arrowlink
{
[XmlAttribute(AttributeName = "COLOR")]
public string Color { get; set; }

[XmlAttribute(AttributeName = "DESTINATION")]
public string Destination { get; set; }

[XmlAttribute(AttributeName = "ENDARROW")]
public string EndArrow { get; set; }

[XmlAttribute(AttributeName = "ENDINCLINATION")]
public string EndInclination { get; set; }

[XmlAttribute(AttributeName = "ID")]
public string ID { get; set; }

[XmlAttribute(AttributeName = "STARTARROW")]
public string StartArrow { get; set; }

[XmlAttribute(AttributeName = "STARTINCLINATION")]
public string StartInclination { get; set; }

// Add other attributes as needed
}


[XmlRoot(ElementName = "node")]
public class Node
{
Expand Down Expand Up @@ -110,6 +139,10 @@ static int GetUnixTime(DateTime utcTime)
[XmlElement(ElementName = "font")]
public Font Font { get; set; }

[XmlElement(ElementName = "arrowlink")]
public List<Arrowlink> Arrowlinks { get; set; } = new List<Arrowlink>();


[XmlElement(ElementName = "node")]
public List<Node> Nodes { get; set; } = new List<Node>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static MindMapCreatorConfig()

//}

public int MaxDegreeOfParallelismMindMaps { get; set; } = 6;
public int MaxDegreeOfParallelismMindMaps { get; set; } = 1;



Expand All @@ -97,47 +97,48 @@ await Task.WhenAll(MindMapDocuments
private async Task ProcessMindMapDocumentAsync(MindMapDocumentConfig mindMap,
AssetConverterConfig assetConverterConfig, ParallelOptions parallelOptions)
{
IList<Fallacy> fallacies;
var dataSet = assetConverterConfig.DataSets.FirstOrDefault(ds => ds.Name == mindMap.DataSet);
if (dataSet == null)
{
fallacies = Fallacy.Load(mindMap.DataSet);
}
else
{
if (dataSet.CsvType != null && dataSet.CsvType != typeof(Fallacy))

IList<Fallacy> fallacies;
var dataSet = assetConverterConfig.DataSets.FirstOrDefault(ds => ds.Name == mindMap.DataSet);
if (dataSet == null)
{

if (IsSubclassOfRawGeneric(typeof(CsvBase<,>), dataSet.CsvType))
fallacies = Fallacy.Load(mindMap.DataSet);
}
else
{
if (dataSet.CsvType != null && dataSet.CsvType != typeof(Fallacy))
{

var config = new MapperConfiguration(cfg =>
if (IsSubclassOfRawGeneric(typeof(CsvBase<,>), dataSet.CsvType))
{
cfg.AddProfile<MappingProfile>();

});
var mapper = config.CreateMapper();
var config = new MapperConfiguration(cfg =>
{
cfg.AddProfile<MappingProfile>();

// Trouver la m�thode LoadAsync sur le type sp�cifique
var loadAsyncMethod = dataSet.CsvType.GetMethod("LoadAsync", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
});
var mapper = config.CreateMapper();

// Trouver la m�thode LoadAsync sur le type sp�cifique
var loadAsyncMethod = dataSet.CsvType.GetMethod("LoadAsync", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);

// Invoquer la m�thode
var task = (Task)loadAsyncMethod.Invoke(null, new object[] { dataSet, assetConverterConfig.UseDebugParams });

// Attendre la fin de la t�che et obtenir le r�sultat
await task.ConfigureAwait(false);
var result = (IEnumerable)task.GetType().GetProperty("Result")?.GetValue(task, null);
// Invoquer la m�thode
var task = (Task)loadAsyncMethod.Invoke(null, new object[] { dataSet, assetConverterConfig.UseDebugParams });

// Mapper les objets � Fallacy
fallacies = (from object baseObject in result select mapper.Map<Fallacy>(baseObject)).ToList();
// Attendre la fin de la t�che et obtenir le r�sultat
await task.ConfigureAwait(false);
var result = (IEnumerable)task.GetType().GetProperty("Result")?.GetValue(task, null);

}
else
{
throw new InvalidOperationException(
$"Dataset type {dataSet.CsvType.AssemblyQualifiedName} is incompatible with mindmap generation");
}
// Mapper les objets � Fallacy
fallacies = (from object baseObject in result select mapper.Map<Fallacy>(baseObject)).ToList();

}
else
{
throw new InvalidOperationException(
$"Dataset type {dataSet.CsvType.AssemblyQualifiedName} is incompatible with mindmap generation");
}

}
else
Expand All @@ -150,19 +151,30 @@ private async Task ProcessMindMapDocumentAsync(MindMapDocumentConfig mindMap,
var targetLanguages = assetConverterConfig.LocalizationConfig.BuildLanguageList(mindMap.Translations);
await Parallel.ForEachAsync(targetLanguages, parallelOptions, async (targetLanguage, token) =>
{
var currentTranslatedMap = mindMap.CloneMindMap();
foreach (var documentLocalization in assetConverterConfig.LocalizationConfig.MindMapLocalization)
try
{
documentLocalization.DoReflectionTranslate(currentTranslatedMap, targetLanguage);
}
var currentTranslatedMap = mindMap.CloneMindMap();
foreach (var documentLocalization in assetConverterConfig.LocalizationConfig.MindMapLocalization)
{
documentLocalization.DoReflectionTranslate(currentTranslatedMap, targetLanguage);
}

var documentDirectory = assetConverterConfig.GetDocumentDirectory(targetLanguage);
var documentDirectory = assetConverterConfig.GetDocumentDirectory(targetLanguage);

await currentTranslatedMap.GenerateMindMapFile(fallacies, assetConverterConfig, documentDirectory, targetLanguage);
await currentTranslatedMap.GenerateMindMapFile(fallacies, assetConverterConfig, documentDirectory, targetLanguage);
}
catch (Exception e)
{
Logger.LogException(e);
}
});
}




public static bool IsSubclassOfRawGeneric(Type generic, Type toCheck)
}

public static bool IsSubclassOfRawGeneric(Type generic, Type toCheck)
{
while (toCheck != null && toCheck != typeof(object))
{
Expand Down Expand Up @@ -231,7 +243,7 @@ public static bool IsSubclassOfRawGeneric(Type generic, Type toCheck)
},
new MindMapDocumentConfig()
{
Enabled = true,
Enabled = false,
DocumentName = "Argumentum_Fallacies_MindMap_cards_fr.mm",
DataSet = KnownDataSets.FallaciesTaxonomy,
InsertCardsThumbnails = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ public Func<Fallacy, string> ThumbnailsPathFunc

public bool KeepOriginalSVG { get; set; }

public CrossLink CrossLinks { get; set; } = CrossLink.None;

public string MatchThumbnailsName(string targetDirectory, Fallacy fallacy)
{
var fileNames = Directory.GetFiles(targetDirectory);
Expand Down Expand Up @@ -283,12 +285,24 @@ private void CreateFreemindmap(IList<Fallacy> fallacies, AssetConverterConfig co
private void CreateFallacyNodes(FreemindMap freemindMap, IList<Fallacy> fallacies, Dictionary<string, Node> nodesByPath,
AssetConverterConfig config, string language)
{
var linkedFallacies = new HashSet<Fallacy>();

foreach (var fallacy in fallacies)
{
linkedFallacies.Add(fallacy);
if (string.IsNullOrEmpty(fallacy.PK)) continue;

var localPath = fallacy.Path;
var fallacyNode = CreateNode(fallacy, config, language);

List<(CrossLink crossLinkType, List<Fallacy> targets)> crossLinks = new();

if (this.CrossLinks.HasFlag(CrossLink.Identity))
{
var identityFallacies = fallacies.Where(f => f.TextFr == fallacy.TextFr && !linkedFallacies.Contains(f)).ToList();
crossLinks.Add((CrossLink.Identity, identityFallacies));
}

var fallacyNode = CreateNode(fallacy, config, language, crossLinks.ToArray());
nodesByPath[localPath] = fallacyNode;

var lastDotIndex = localPath.LastIndexOf('.');
Expand All @@ -310,9 +324,14 @@ private void CreateFallacyNodes(FreemindMap freemindMap, IList<Fallacy> fallacie
}
}

private Node CreateNode(Fallacy fallacy, AssetConverterConfig config, string language)




private Node CreateNode(Fallacy fallacy, AssetConverterConfig config, string language, params (CrossLink crossLinkType, List<Fallacy> targets)[] crossLinks)
{
var fallacyNode = new Node { TEXT = TitleFunc(fallacy) };
fallacyNode.ID = fallacy.GetId();
var link = LinkFunc(fallacy);
if (!string.IsNullOrEmpty(link))
{
Expand All @@ -327,6 +346,37 @@ private Node CreateNode(Fallacy fallacy, AssetConverterConfig config, string lan
AddCardIcon(fallacy, fallacyNode, config, language);
}

foreach (var crossLink in crossLinks)
{
foreach (var target in crossLink.targets)
{
var crossLinkNode = new Arrowlink();
crossLinkNode.StartArrow = "Default";
crossLinkNode.EndArrow = "Default";
crossLinkNode.StartInclination = "892;0;";
crossLinkNode.EndInclination = "892;0;";
crossLinkNode.Destination = target.GetId();

switch (crossLink.crossLinkType)
{
case CrossLink.Identity:
crossLinkNode.Color = "#dbffd6 ";
break;
case CrossLink.AppealTo:
crossLinkNode.Color = "#ccffff";
break;
case CrossLink.Opposite:
crossLinkNode.Color = "#ffcfcc";
break;
default:
throw new ArgumentOutOfRangeException($"cross link type {crossLink.crossLinkType} unsupported");
}
fallacyNode.Arrowlinks.Add(crossLinkNode);

}
}


return fallacyNode;
}

Expand Down Expand Up @@ -802,12 +852,4 @@ protected override DocumentConfig GetClone()
return CloneMindMap();
}
}








}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public class WebBasedGeneratorConfig
}),
JsonFilePathRelease = "https://raw.githubusercontent.com/ArgumentumGames/Argumentum/master/Cards/Memo/Argumentum_Memo_Back_fr.json",
JsonFilePathDebug = @"..\..\..\..\..\..\Cards\Memo\Argumentum_Memo_Back_fr.json",

}
},
new CardSetConfig(){
Expand All @@ -124,8 +125,8 @@ public class WebBasedGeneratorConfig
"2"
}),
JsonFilePathRelease = "https://raw.githubusercontent.com/ArgumentumGames/Argumentum/master/Cards/Fallacies/Argumentum_Fallacies_Face_fr.json",
JsonFilePathDebug = @"..\..\..\..\..\..\Cards\Fallacies\Argumentum_Fallacies_Face_fr.json"

JsonFilePathDebug = @"..\..\..\..\..\..\Cards\Fallacies\Argumentum_Fallacies_Face_fr.json",
PauseForEdits = true
},
BackCardSetInfo = new CardSetInfo()
{
Expand Down

0 comments on commit 0391bf2

Please sign in to comment.