Skip to content

Commit

Permalink
2023.3.1 (#29)
Browse files Browse the repository at this point in the history
 * Fixed a rare crash when the plugin was completely unable to find Rimworld
 * Fixed automatic Rimworld detection when Rimworld is installed through Steam on the C: drive
 * Fixed some false positives on error checking in XML
 * Added more mod folders to the XML Project that gets added automatically
  • Loading branch information
Garethp authored Sep 20, 2023
1 parent 934c428 commit a1e31e5
Show file tree
Hide file tree
Showing 32 changed files with 566 additions and 32 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 2023.3.1
* Fixed a rare crash when the plugin was completely unable to find Rimworld
* Fixed automatic Rimworld detection when Rimworld is installed through Steam on the C: drive
* Fixed some false positives on error checking in XML
* Added more mod folders to the XML Project that gets added automatically

## 2023.3
* Rimworld XML will now exist as it's own project
* Added some new problem analyzers to catch simple typing errors in Rimworld XML
Expand Down
2 changes: 1 addition & 1 deletion buildPlugin.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Param(
$Version = "2023.3"
$Version = "2023.3.1"
)

Set-StrictMode -Version Latest
Expand Down
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=2023.3
PluginVersion=2023.3.1

BuildConfiguration=Release

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ void IRecursiveElementProcessor.ProcessAfterInterior(ITreeNode element)
case "System.Int32":
ProcessInt(fullText, range);
return;
case "System.Single":
ProcessFloat(fullText, range);
return;
case "Verse.IntRange":
ProcessIntRange(fullText, range);
return;
case "Verse.FloatRange":
ProcessFloatRange(fullText, range);
return;
case "System.String":
break;
case "UnityEngine.Vector2":
Expand All @@ -100,7 +106,15 @@ void IRecursiveElementProcessor.ProcessAfterInterior(ITreeNode element)
case "UnityEngine.Vector3":
ProcessVector3(fullText, range);
break;
case "UnityEngine.Rect":
case "UnityEngine.Color":
case "RimWorld.PsychicDroneLevel":
case "RimWorld.FoodTypeFlags":
case "Verse.DevelopmentalStage":
case "Verse.ColorInt":
case "Verse.IntVec3":
case "Verse.IntVec2":
case "Verse.WorkTags":
break;
default:
if (context.GetType().Name == "Enum")
Expand All @@ -124,23 +138,30 @@ private void ProcessBoolean(string textValue, DocumentRange range)
{
if (textValue.ToLower() is "true" or "false") return;

IHighlighting error = new XmlErrorHighlighting("Value must be \"true\" or \"false\"", range, Array.Empty<object>());

myConsumer.AddHighlighting(error, range);
AddError("Value must be \"true\" or \"false\"", range);
}

private void ProcessInt(string textValue, DocumentRange range)
{
if (int.TryParse(textValue, out _)) return;

IHighlighting error = new XmlErrorHighlighting("Value must be a whole number with no decimal points", range, Array.Empty<object>());

myConsumer.AddHighlighting(error, range);
AddError("Value must be a whole number with no decimal points", range);
}

private void ProcessFloat(string textValue, DocumentRange range)
{
if (float.TryParse(textValue, out _)) return;

AddError("Value must be a valid number", range);
}

private void ProcessIntRange(string textValue, DocumentRange range)
{
var strArray = textValue.Split('~');

// For some reason IntRange also just accepts a single number instead of a range
if (strArray.Length == 1 && int.TryParse(strArray[0], out _)) return;

if (strArray.Length != 2)
{
AddError("Your value must be two integers in a format similar to \"1~2\"", range);
Expand All @@ -159,12 +180,40 @@ private void ProcessIntRange(string textValue, DocumentRange range)
return;
}
}

private void ProcessFloatRange(string textValue, DocumentRange range)
{
var strArray = textValue.Split('~');
// For some reason FloatRange also just accepts a single number instead of a range
if (strArray.Length == 1 && float.TryParse(strArray[0], out _)) return;

if (strArray.Length != 2)
{
AddError("Your value must be two integers in a format similar to \"1~2\"", range);
return;
}

if (!float.TryParse(strArray[0], out _))
{
AddError($"\"{strArray[0]}\" is not a valid float", range);
return;
}

if (!float.TryParse(strArray[1], out _))
{
AddError($"\"{strArray[1]}\" is not a valid float", range);
return;
}
}

private void ProcessVector2(string textValue, DocumentRange range)
{
var match = Regex.Match(textValue.Trim(), @"^\((.*?),(.*?)\)$");
if (!match.Success)
{
// For some reason Vector2 allows us to pass in just a single number instead of a vector?
if (float.TryParse(textValue, out _)) return;

AddError("Your value must be in a format similar to (1,2)", range);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<DefineConstants>$(DefineConstants);RIDER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>false</Optimize>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="2023.2.0" />
<PackageReference Include="JetBrains.Lifetimes" Version="2023.3.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>false</Optimize>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="JetBrains.ReSharper.SDK" Version="$(SdkVersion)" PrivateAssets="all" />
<PackageReference Include="Wave" Version="$(WaveVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ public bool Filter(VirtualFileSystemPath path) =>
path.Name.Equals("bin", StringComparison.OrdinalIgnoreCase) ||
path.Name.EndsWith(".DotSettings.user", StringComparison.OrdinalIgnoreCase) ||
path.Name.Equals("node_modules", StringComparison.OrdinalIgnoreCase) ||
(!path.FullPath.Contains("About") && !path.FullPath.Contains("Defs"));
!new List<string> {"About", "Defs", "Patches", "Languages", "Sounds", "Textures", "News"}.Any(it => path.FullPath.Contains(it));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ public ISolutionMark TryCreate(RdSolutionDescription solutionDescription)
}

var directory = VirtualFileSystemPath.TryParse(solutionDirectory, InteractionContext.SolutionContext);
var aboutFile = directory.TryCombine("About/About.xml");
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;

Expand Down
10 changes: 7 additions & 3 deletions src/dotnet/ReSharperPlugin.RimworldDev/ScopeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ public static FileSystemPath FindRimworldDll(string currentPath)
{
var rimworldLocation = FindRimworldDirectory(currentPath);

if (rimworldLocation == null) return null;

var fileRelativePaths = new List<string>
{
"RimWorldWin64_Data/Managed/Assembly-CSharp.dll",
Expand All @@ -132,6 +134,8 @@ public static FileSystemPath FindRimworldDll(string currentPath)
var location = fileRelativePaths.FirstOrDefault(path =>
FileSystemPath.ParseRelativelyTo(path, rimworldLocation).ExistsFile);

if (location == null) return null;

var path = FileSystemPath.ParseRelativelyTo(location, rimworldLocation);

return path.ExistsFile ? path : null;
Expand Down Expand Up @@ -163,9 +167,9 @@ private static IEnumerable<string> GetSteamLocations()
{
var locations = new List<string>
{
@"C:\Program Files (x86)\Steam\",
@"C:\Program Files\Steam\",
"~/.steam/steam/"
@"C:\Program Files (x86)\Steam\steamapps\",
@"C:\Program Files\Steam\steamapps\",
"~/.steam/steam/steamapps/"
};

locations.AddRange(
Expand Down
49 changes: 33 additions & 16 deletions src/rider/main/kotlin/run/RunState.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.intellij.execution.configurations.RunProfileState
import com.intellij.execution.process.*
import com.intellij.execution.runners.ExecutionEnvironment
import com.intellij.execution.runners.ProgramRunner
import com.intellij.util.system.OS
import com.jetbrains.rider.debugger.DebuggerWorkerProcessHandler
import com.jetbrains.rider.plugins.unity.run.configurations.UnityAttachProfileState
import com.jetbrains.rider.run.configurations.remote.RemoteConfiguration
Expand All @@ -23,19 +24,32 @@ class RunState(
targetName: String
) :
UnityAttachProfileState(remoteConfiguration, executionEnvironment, targetName), RunProfileState {
private val resources = listOf(
".doorstop_version",
"doorstop_config.ini",
"winhttp.dll",

"Doorstop/0Harmony.dll",
"Doorstop/dnlib.dll",
"Doorstop/Doorstop.dll",
"Doorstop/Doorstop.pdb",
"Doorstop/HotReload.dll",
"Doorstop/Mono.Cecil.dll",
"Doorstop/Mono.CompilerServices.SymbolWriter.dll",
"Doorstop/pdb2mdb.exe",
private val resources = mapOf(
OS.Windows to listOf(
".doorstop_version",
"doorstop_config.ini",
"winhttp.dll",

"Doorstop/0Harmony.dll",
"Doorstop/dnlib.dll",
"Doorstop/Doorstop.dll",
"Doorstop/Doorstop.pdb",
"Doorstop/HotReload.dll",
"Doorstop/Mono.Cecil.dll",
"Doorstop/Mono.CompilerServices.SymbolWriter.dll",
"Doorstop/pdb2mdb.exe",
),
OS.macOS to listOf(
".doorstop_version",
".doorstop_config.ini",

"Doorstop/0Harmony.dll",
"Doorstop/Doorstop.dll",
"Doorstop/Doorstop.pdb",
"Doorstop/Mono.Cecil.dll",
"Doorstop/Mono.CompilerServices.SymbolWriter.dll",
"Doorstop/pdb2mdb.exe",
)
)

override fun execute(
Expand Down Expand Up @@ -67,6 +81,8 @@ class RunState(
}

private fun setupDoorstop() {
val currentResources = resources[OS.CURRENT] ?: return

val rimworldDir = Path(rimworldLocation).parent.toFile()

val copyResource = fun(basePath: String, name: String) {
Expand All @@ -84,12 +100,13 @@ class RunState(
fileWriteStream.close()
}

resources.forEach {
copyResource("/UnityDoorstop/Win64/", it)
currentResources.forEach {
copyResource("/UnityDoorstop/${OS.CURRENT}/", it)
}
}

private fun removeDoorstep() {
val currentResources = resources[OS.CURRENT] ?: return
Thread.sleep(50)

val rimworldDir = Path(rimworldLocation).parent.toFile()
Expand All @@ -99,7 +116,7 @@ class RunState(
file.delete()
}

resources.forEach {
currentResources.forEach {
removeResource(it)
}

Expand Down
7 changes: 7 additions & 0 deletions src/rider/main/kotlin/spellchecker/DictionaryProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package RimworldDev.Rider.spellchecker

import com.intellij.spellchecker.BundledDictionaryProvider

class DictionaryProvider: BundledDictionaryProvider {
override fun getBundledDictionaries(): Array<String> = arrayOf("/spellchecker/rimworld.dic")
}
10 changes: 7 additions & 3 deletions src/rider/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin require-restart="true">
<id>com.jetbrains.rider.plugins.rimworlddev</id>
<name>Rimworld Development Environment</name>
<version>2023.3</version>
<version>2023.3red.1</version>
<vendor url="https://github.com/Garethp/Rider-RimworldDevelopment">Garethp</vendor>
<idea-version since-build="231" />
<depends>com.intellij.modules.rider</depends>
Expand All @@ -18,8 +18,10 @@ in your mods!</p>
<change-notes>
<![CDATA[
<p><ul>
<li>Rimworld XML will now exist as it's own project</li>
<li>Added some new problem analyzers to catch simple typing errors in Rimworld XML</li>
<li>Fixed a rare crash when the plugin was completely unable to locate Rimworld</li>
<li>Fixed automatic Rimworld detection when Rimworld is installed through Steam on the C: drive</li>
<li>Fixed some false positives on error checking in XML</li>
<li>Added more mod folders to the XML Project that gets added automatically</li>
</ul></p>
]]>
</change-notes>
Expand All @@ -34,6 +36,8 @@ in your mods!</p>

<configurationType implementation="RimworldDev.Rider.run.ConfigurationType"/>
<backend.markup.adapterFactory language="XML" implementationClass="com.jetbrains.rider.daemon.RiderCacheAwareMarkupAdapterFactory" />

<spellchecker.bundledDictionaryProvider implementation="RimworldDev.Rider.spellchecker.DictionaryProvider" />
</extensions>

</idea-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4.0.0
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
45 changes: 45 additions & 0 deletions src/rider/main/resources/UnityDoorstop/macOS/doorstop_config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# General options for Unity Doorstop
[General]

# Enable Doorstop?
enabled=true

# Path to the assembly to load and execute
# NOTE: The entrypoint must be of format `static void Doorstop.Entrypoint.Start()`
target_assembly=Doorstop\Doorstop.dll

# If true, Unity's output log is redirected to <current folder>\output_log.txt
redirect_output_log=false

# If enabled, DOORSTOP_DISABLE env var value is ignored
# USE THIS ONLY WHEN ASKED TO OR YOU KNOW WHAT THIS MEANS
ignore_disable_switch=false


# Options specific to running under Unity Mono runtime
[UnityMono]

# Overrides default Mono DLL search path
# Sometimes it is needed to instruct Mono to seek its assemblies from a different path
# (e.g. mscorlib is stripped in original game)
# This option causes Mono to seek mscorlib and core libraries from a different folder before Managed
# Original Managed folder is added as a secondary folder in the search path
dll_search_path_override=

# If true, Mono debugger server will be enabled
debug_enabled=true

# When debug_enabled is true, specifies the address to use for the debugger server
debug_address=127.0.0.1:56000

# If true and debug_enabled is true, Mono debugger server will suspend the game execution until a debugger is attached
debug_suspend=false

# Options sepcific to running under Il2Cpp runtime
[Il2Cpp]

# Path to coreclr.dll that contains the CoreCLR runtime
coreclr_path=

# Path to the directory containing the managed core libraries for CoreCLR (mscorlib, System, etc.)
corlib_dir=
Loading

0 comments on commit a1e31e5

Please sign in to comment.