From 4bd0b990b9fc8d35214cc7dadd25bdb00d915106 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 23 Sep 2024 20:32:54 +0200 Subject: [PATCH] Update source gen --- .../RoslynElements/PurchaseMenuExtensions.cs | 28 +++++++++++++++++++ QuestPathGenerator/RoslynShortcuts.cs | 1 + 2 files changed, 29 insertions(+) create mode 100644 QuestPathGenerator/RoslynElements/PurchaseMenuExtensions.cs diff --git a/QuestPathGenerator/RoslynElements/PurchaseMenuExtensions.cs b/QuestPathGenerator/RoslynElements/PurchaseMenuExtensions.cs new file mode 100644 index 000000000..251e64cec --- /dev/null +++ b/QuestPathGenerator/RoslynElements/PurchaseMenuExtensions.cs @@ -0,0 +1,28 @@ +using Microsoft.CodeAnalysis.CSharp; +using Microsoft.CodeAnalysis.CSharp.Syntax; +using Questionable.Model.Questing; +using static Microsoft.CodeAnalysis.CSharp.SyntaxFactory; +using static Questionable.QuestPathGenerator.RoslynShortcuts; + +namespace Questionable.QuestPathGenerator.RoslynElements; + +internal static class PurchaseMenuExtensions +{ + public static ExpressionSyntax ToExpressionSyntax(this PurchaseMenu purchaseMenu) + { + PurchaseMenu emptyMenu = new(); + return ObjectCreationExpression( + IdentifierName(nameof(PurchaseMenu))) + .WithInitializer( + InitializerExpression( + SyntaxKind.ObjectInitializerExpression, + SeparatedList( + SyntaxNodeList( + Assignment(nameof(PurchaseMenu.ExcelSheet), purchaseMenu.ExcelSheet, + emptyMenu.ExcelSheet) + .AsSyntaxNodeOrToken(), + Assignment(nameof(PurchaseMenu.Key), purchaseMenu.Key, + emptyMenu.Key) + .AsSyntaxNodeOrToken())))); + } +} diff --git a/QuestPathGenerator/RoslynShortcuts.cs b/QuestPathGenerator/RoslynShortcuts.cs index cc146a0b1..4147e47ba 100644 --- a/QuestPathGenerator/RoslynShortcuts.cs +++ b/QuestPathGenerator/RoslynShortcuts.cs @@ -57,6 +57,7 @@ public static class RoslynShortcuts DialogueChoice dialogueChoice => dialogueChoice.ToExpressionSyntax(), JumpDestination jumpDestination => jumpDestination.ToExpressionSyntax(), ExcelRef excelRef => excelRef.ToExpressionSyntax(), + PurchaseMenu purchaseMenu => purchaseMenu.ToExpressionSyntax(), ComplexCombatData complexCombatData => complexCombatData.ToExpressionSyntax(), QuestWorkValue questWorkValue => questWorkValue.ToExpressionSyntax(), List list => list.ToExpressionSyntax(), // TODO fix in AssignmentList