(string outputPath, object arg)
| 29 | |
| 30 | /// <inheritdoc /> |
| 31 | public override void Create(string outputPath, object arg) |
| 32 | { |
| 33 | // Find the module that this script is being added (based on the path) |
| 34 | var module = string.Empty; |
| 35 | var project = TryGetProjectAtFolder(outputPath, out var moduleName); |
| 36 | if (project != null) |
| 37 | { |
| 38 | module = moduleName.ToUpperInvariant() + "_API "; |
| 39 | } |
| 40 | |
| 41 | var gameSettings = GameSettings.Load(); |
| 42 | var scriptName = ScriptItem.CreateScriptName(outputPath); |
| 43 | var filename = Path.GetFileNameWithoutExtension(outputPath); |
| 44 | var copyrightComment = string.IsNullOrEmpty(gameSettings.CopyrightNotice) ? string.Empty : string.Format("// {0}{1}{1}", gameSettings.CopyrightNotice, Environment.NewLine); |
| 45 | |
| 46 | GetTemplatePaths(out var headerTemplatePath, out var sourceTemplatePath); |
| 47 | if (headerTemplatePath != null) |
| 48 | { |
| 49 | var headerTemplate = File.ReadAllText(headerTemplatePath); |
| 50 | headerTemplate = headerTemplate.Replace("%copyright%", copyrightComment); |
| 51 | headerTemplate = headerTemplate.Replace("%class%", scriptName); |
| 52 | headerTemplate = headerTemplate.Replace("%module%", module); |
| 53 | headerTemplate = headerTemplate.Replace("%filename%", filename); |
| 54 | File.WriteAllText(Path.ChangeExtension(outputPath, ".h"), headerTemplate, Encoding.UTF8); |
| 55 | } |
| 56 | if (sourceTemplatePath != null) |
| 57 | { |
| 58 | var sourceTemplate = File.ReadAllText(sourceTemplatePath); |
| 59 | sourceTemplate = sourceTemplate.Replace("%copyright%", copyrightComment); |
| 60 | sourceTemplate = sourceTemplate.Replace("%class%", scriptName); |
| 61 | sourceTemplate = sourceTemplate.Replace("%module%", module); |
| 62 | sourceTemplate = sourceTemplate.Replace("%filename%", filename); |
| 63 | File.WriteAllText(outputPath, sourceTemplate, Encoding.UTF8); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | /// <inheritdoc /> |
| 68 | public override string FileExtension => "cpp"; |
no test coverage detected