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

## 2025.1.13
* Updates support for XML Only mods to work with both 1.6 and 1.7
* Update support for XML Only mods to allow launching directly through Rider
* Update support for XML Only mods to work with both 1.6 and 1.7

## 2025.1.12
* Update the Rimworld Run Configuration to support both 1.6 and 1.7 at the same time
Expand Down
2 changes: 0 additions & 2 deletions example-mods/XmlOnlyMod/XmlOnlyMod.sln

This file was deleted.

2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DotnetPluginId=ReSharperPlugin.RimworldDev
DotnetSolution=ReSharperPlugin.RimworldDev.sln
RiderPluginId=com.jetbrains.rider.plugins.rimworlddev
PluginVersion=2025.1.12
PluginVersion=2025.1.13

BuildConfiguration=Release

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Linq;
using JetBrains.Application;
using JetBrains.ProjectModel.ProjectsHost;
using JetBrains.RdBackend.Common.Features.ProjectModel;
using JetBrains.Rider.Model;
using JetBrains.Util;
using ReSharperPlugin.RimworldDev.Settings;

namespace ReSharperPlugin.RimworldDev.RimworldXmlProject.Solution;

[ShellComponent]
public sealed class RimworldSolutionMarkProvider : ISolutionMarkProvider
{
public RimworldSolutionMarkProvider(SettingsAccessor settingsAccessor)
{
settingsAccessor.GetSettings();
}

public ISolutionMark TryCreate(RdSolutionDescription solutionDescription)
{
// This check is here to make sure we're only trying to adopt projects that opened up in Folder View, IE: they
// don't have a .sln file. If they do have a .sln file, we'll use the RimworldProjectMarkProvider instead.
if (solutionDescription is not RdVirtualSolution virtualSolution) return null;

var directory = VirtualFileSystemPath.TryParse(virtualSolution.SolutionDirectory.Value, InteractionContext.SolutionContext);
if (directory.IsEmpty) return null;

var projectDirectory = directory;
var aboutFile = projectDirectory.TryCombine("About/About.xml");
var parentAttempts = 0;
while (!aboutFile.ExistsFile)
{
parentAttempts++;
projectDirectory = projectDirectory.Parent;
if (projectDirectory.Exists == FileSystemPath.Existence.Missing || parentAttempts >= 5) break;

aboutFile = projectDirectory.TryCombine("About/About.xml");
}

if (!aboutFile.ExistsFile) return null;

// When we come in as a folder project we may have other "projects" that we do or don't want to load. De default
// Rider will pass us a list where it's basically a file for ever folder, since it assumes each folder is its own
// project. We don't just want to throw them away (maybe someone has a .csproj or an obscure F# project without
// using a .sln file because reasons) (If you are using F# for your mods, respect), we want to load the ones that
// are legitimate projects. So we'll filter files down by ending in .*proj and let them get added to our custom
// virtual solution.
var projectFiles = virtualSolution.ProjectFilePaths
.Where(path => path.Value.EndsWith("proj", StringComparison.OrdinalIgnoreCase))
.Select(path => VirtualFileSystemPath.TryParse(path.Value, InteractionContext.SolutionContext))
.Where(path => !path.IsEmpty)
.ToList();

return new RimworldVirtualSolutionMark(directory.Name, aboutFile, projectFiles);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using JetBrains.ProjectModel.Impl;
using JetBrains.ProjectModel.ProjectsHost;
using JetBrains.ProjectModel.ProjectsHost.Diagnostic;
using JetBrains.ProjectModel.ProjectsHost.Impl;
using JetBrains.ProjectModel.SolutionStructure.SolutionConfigurations;
using JetBrains.ProjectModel.SolutionStructure.SolutionDefinitions;
using JetBrains.Util;

namespace ReSharperPlugin.RimworldDev.RimworldXmlProject.Solution;

public class RimworldVirtualSolutionMark : ISolutionMark
{
private readonly IReadOnlyCollection<VirtualFileSystemPath> myProjectFiles;

public RimworldVirtualSolutionMark([NotNull] string name, [NotNull] VirtualFileSystemPath location,
[NotNull] IReadOnlyCollection<VirtualFileSystemPath> projectFiles)
{
Name = name;
Location = location;
myProjectFiles = projectFiles;
ConfigurationAndPlatformStore = SolutionConfigurationAndPlatformStore.Empty;
}

public string Name { get; }

public VirtualFileSystemPath Location { get; }

public SolutionFormatVersion GetPlatformVersion() => SolutionFormatVersion.Unknown;

public IReadOnlyCollection<VirtualFileSystemPath> GetProjectLocations() => myProjectFiles;

public IReadOnlyCollection<VirtualFileSystemPath> GetSolutionRelatedLocations() =>
EmptyList<VirtualFileSystemPath>.Instance;

public ISolutionConfigurationAndPlatform ActiveConfigurationAndPlatform =>
MissingSolutionConfigurationAndPlatform.Instance;

public ISolutionConfigurationAndPlatformStore ConfigurationAndPlatformStore { get; }

public SolutionStructureChange Update(SolutionMarkUpdateRequest request)
{
var projectMarks = request.StructureContainer.ProjectMarks;
var addedProjects = new List<IProjectMark>();
var updatedProjects = new List<IProjectMark>();

// See our comment in `RimworldSolutionMarkProvider`, we may be picking up other actual projects that we want
// to add.
var existingVirtualMarks = projectMarks.OfType<VirtualProjectMark>().ToList<IProjectMark>();
foreach (var projectFile in myProjectFiles)
{
var existingMark = existingVirtualMarks.FirstOrDefault(mark => mark.Location == projectFile);
if (existingMark == null)
{
addedProjects.Add(new VirtualProjectMark(this, projectFile));
continue;
}

updatedProjects.Add(existingMark);
existingVirtualMarks.Remove(existingMark);
}

var rimworldMarks = projectMarks.OfType<RimworldProjectMark>().ToList();
if (rimworldMarks.Count == 0)
{
var rootProject = new RimworldProjectMark(this, Location, this);
addedProjects.Add(rootProject);
addedProjects.AddRange(rootProject.Dependencies);
}
else
updatedProjects.AddRange(rimworldMarks);

return new SolutionStructureChange(this, addedProjects, existingVirtualMarks, updatedProjects,
EmptyList<IProjectMark>.InstanceList, EmptyList<SolutionLoadDiagnostic>.InstanceList);
}

public IProjectMark AddProject(ProjectDefinitionDescriptor descriptor, IProjectMark parent) =>
throw new NotImplementedException();

public IProjectMark RenameProject(IProjectMark project, string name, string path) =>
throw new NotImplementedException();

public void RemoveProject(IProjectMark project) => throw new NotImplementedException();

public void MoveProject(IProjectMark project, IProjectMark parent) => throw new NotImplementedException();
}
Loading