Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Changelog

## 2024.2
* Adds support for [Parent=""] attributes
* Adds support for [Parent=""] attributes
* Makes the New Mod template modular, allowing you to select the components you want included in your mod

## 2024.1.7
* Solved some incompatibilities for ReSharper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,38 @@
"isRequired": "false",
"defaultValue": ""
},
"PublisherPlus": {
"type": "parameter",
"datatype": "bool",
"displayName": "Include a PublisherPlus config",
"description": "If enabled, a PublisherPlus config file will be included in the mod",
"isRequired": "false",
"defaultValue": "true"
},
"CSharp": {
"type": "parameter",
"datatype": "bool",
"displayName": "Add a C# Project and Sources",
"description": "If enabled, this mod will be created with a .sln file, Sources folder and a csproj file",
"isRequired": "false",
"defaultValue": "true"
},
"XML": {
"type": "parameter",
"datatype": "bool",
"displayName": "Add a Defs folder with a starting XML file",
"description": "If enabled, this mod will be created with a Defs folder and a starting XML file",
"isRequired": "false",
"defaultValue": "true"
},
"Languages": {
"type": "parameter",
"datatype": "bool",
"displayName": "Add a Languages folder",
"description": "If enabled, this mod will be created with a Languages folder with a starting English.xml file",
"isRequired": "false",
"defaultValue": "true"
},
"AssemblyDir": {
"type": "derived",
"valueSource": "RimworldDLL",
Expand All @@ -64,11 +96,22 @@
{
"type": "conditional",
"configuration": {
"if": [ "<!--#if" ],
"else": [ "#else", "<!--#else" ],
"elseif": [ "#elseif", "<!--#elseif" ],
"endif": [ "#endif", "<!--#endif" ],
"trim" : "true",
"if": [
"<!--#if"
],
"else": [
"#else",
"<!--#else"
],
"elseif": [
"#elseif",
"<!--#elseif"
],
"endif": [
"#endif",
"<!--#endif"
],
"trim": "true",
"wholeLine": "true"
}
}
Expand All @@ -82,6 +125,28 @@
"replacement": "$1"
}
},
"sources": [
{
"modifiers": [
{
"condition": "PublisherPlus == false",
"exclude": ["_PublisherPlus.xml"]
},
{
"condition": "CSharp == false",
"exclude": ["Source/**/*"]
},
{
"condition": "XML == false",
"exclude": ["Defs/**/*"]
},
{
"condition": "Languages == false",
"exclude": ["Languages/**/*"]
}
]
}
],
"primaryOutputs": [
{
"path": "About/About.xml"
Expand Down Expand Up @@ -120,9 +185,11 @@
},
{
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [{
"text": "Run 'dotnet restore'"
}],
"manualInstructions": [
{
"text": "Run 'dotnet restore'"
}
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,93 +1,34 @@
// using System.Collections.Generic;
// using System.Linq;
// using JetBrains.Application;
// using JetBrains.Rider.Backend.Features.ProjectModel.ProjectTemplates.DotNetExtensions;
// using JetBrains.Rider.Backend.Features.ProjectModel.ProjectTemplates.DotNetTemplates;
// using JetBrains.Rider.Model;
// using JetBrains.Util;
// using Microsoft.TemplateEngine.Abstractions;
//
// namespace ReSharperPlugin.RimworldDev.TemplateParameters;
//
// public class RimworldDLLParameter : DotNetTemplateParameter
// {
// public RimworldDLLParameter() : base("RimworldDLL", "Rimworld DLL", "Path to Assembly-CSharp.dll")
// {
// }
//
// public override RdProjectTemplateOption CreateContent(ITemplateInfo templateInfo, ITemplateParameter templateParameter,
// Dictionary<string, object> context)
// {
// var locations = new List<string>
// {
// "C:\\Program Files (x86)\\Steam\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "C:\\Program Files\\Steam\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "~/.steam/steam/steamapps/common/RimWorld/RimWorldLinux_Data/Managed/Assembly-CSharp.dll"
// };
//
// var possiblePaths = locations
// .Select(location => FileSystemPath.TryParse(location)).Where(location => location.ExistsFile)
// .ToArray();
//
// var detectedPath = possiblePaths.FirstOrDefault()?.FullPath;
//
// return new RdProjectTemplateTextOption(detectedPath ?? "", Name, PresentableName, Tooltip);
// }
//
// public override RdProjectTemplateContent CreateContent(
// DotNetProjectTemplateExpander expander,
// IDotNetTemplateContentFactory factory,
// int index, IDictionary<string, string> context
// )
// {
// var locations = new List<string>
// {
// "C:\\Program Files (x86)\\Steam\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "C:\\Program Files\\Steam\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "D:\\SteamLibrary\\steamapps\\common\\RimWorld\\RimWorldWin64_Data\\Managed\\Assembly-CSharp.dll",
// "~/.steam/steam/steamapps/common/RimWorld/RimWorldLinux_Data/Managed/Assembly-CSharp.dll"
// };
//
// var content = factory.CreateNextParameters(new[] { expander }, index + 1, context);
// var parameter = expander.TemplateInfo.GetParameter(Name);
// if (parameter == null)
// {
// return content;
// }
//
// var possiblePaths = locations
// .Select(location => FileSystemPath.TryParse(location)).Where(location => location.ExistsFile)
// .ToArray();
//
// var options = new List<RdProjectTemplateGroupOption>();
//
// foreach (var path in possiblePaths)
// {
// var optionContext = new Dictionary<string, string>(context) { { Name, path.FullPath } };
// var content1 = factory.CreateNextParameters(new[] { expander }, index + 1, optionContext);
// options.Add(new RdProjectTemplateGroupOption(path.FullPath, path.FullPath, null, content1));
// }
//
// options.Add(new RdProjectTemplateGroupOption(
// "Custom",
// possiblePaths.Any() ? "Custom" : "Custom (Assembly-CSharp.dll not found)",
// null,
// new RdProjectTemplateTextParameter(Name, "Custom path", null, Tooltip, RdTextParameterStyle.FileChooser,
// content)));
//
// return new RdProjectTemplateGroupParameter(Name, PresentableName,
// possiblePaths.Any() ? possiblePaths.Last().FullPath : string.Empty, null, options);
// }
// }
//
// [ShellComponent]
// public class RimworldDLLParameterProvider : IDotNetTemplateParameterProvider
// {
// public int Priority => 50;
//
// public IReadOnlyCollection<DotNetTemplateParameter> Get()
// {
// return new[] { new RimworldDLLParameter() };
// }
// }
using System.Collections.Generic;
using System.IO;
using JetBrains.Application;
using JetBrains.Rider.Backend.Features.ProjectModel.ProjectTemplates.DotNetExtensions;
using JetBrains.Rider.Model;
using Microsoft.TemplateEngine.Abstractions;

namespace ReSharperPlugin.RimworldDev.TemplateParameters;

public class RimworldDLLParameter : DotNetTemplateParameter
{
public RimworldDLLParameter() : base("RimworldDLL", "Rimworld DLL", "Path to Assembly-CSharp.dll")
{
}

public override RdProjectTemplateOption CreateContent(ITemplateInfo templateInfo, ITemplateParameter templateParameter,
Dictionary<string, object> context)
{
var detectedPath = ScopeHelper.FindRimworldDll(Directory.GetCurrentDirectory())?.FullPath;

return new RdProjectTemplateTextOption(detectedPath ?? "", "string", Name, PresentableName, Tooltip);
}
}

[ShellComponent]
public class RimworldDLLParameterProvider : IDotNetTemplateParameterProvider
{
public int Priority => 50;

public IReadOnlyCollection<DotNetTemplateParameter> Get()
{
return new[] { new RimworldDLLParameter() };
}
}
Loading