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
17 changes: 0 additions & 17 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ jobs:
distribution: 'corretto'
java-version: '21'
cache: 'gradle'
- uses: actions/cache@v4
with:
path: |
build/gradle-jvm
~/.nuget/packages
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-Build-${{ hashFiles('gradlew.bat', 'src/dotnet/*/*.csproj', './*.props', 'gradle-wrapper.properties') }}
- run: ./gradlew :buildPlugin --no-daemon
- run: ./gradlew :buildResharperPlugin --no-daemon
- uses: actions/upload-artifact@v4
Expand All @@ -46,13 +38,4 @@ jobs:
distribution: 'corretto'
java-version: '17'
cache: 'gradle'
- uses: actions/cache@v4
with:
path: |
build/gradle-jvm
packages
~/.nuget/packages
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-Test-${{ hashFiles('gradlew.bat', 'src/dotnet/*/*.csproj', './*.props', 'gradle-wrapper.properties') }}
- run: ./gradlew :testDotNet --no-daemon
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Adds support for [Parent=""] attributes
* Makes the New Mod template modular, allowing you to select the components you want included in your mod
* Bundled in Zetrith's Remodder code into this plugin
* Update the Rimworld template for 1.6
* Automatically detect and use the user-installed Harmony version for debugging, if available

## 2024.1.7
* Solved some incompatibilities for ReSharper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,21 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>

<ItemGroup>
<Reference Include="System"/>
<Reference Include="System.Core"/>
<Reference Include="System.Xml"/>
</ItemGroup>


<!--#if(assemblyExists)-->
<ItemGroup>
<Reference Include="System">
<HintPath>AssemblyDir\System.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Core">
<HintPath>AssemblyDir\System.Core.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml">
<HintPath>AssemblyDir\System.Xml.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Assembly-CSharp">
<HintPath>Assembly-CSharp.dll</HintPath>
<Private>False</Private>
Expand All @@ -52,7 +58,7 @@
If that reference does not exist, it will add Krafs Rimworld Ref to the project. If it does exist, Krafs won't be added
as a reference. This basically means that Krafs is treated as a fallback if Assembly-CSharp is not found -->
<ItemGroup Condition="'@(Reference->WithMetadataValue('Identity', 'Assembly-CSharp')->Metadata('HintPath')->Exists())' == ''">
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.4-*" />
<PackageReference Include="Krafs.Rimworld.Ref" Version="1.6.*" />
</ItemGroup>

<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Expand Down
125 changes: 125 additions & 0 deletions src/rider/main/kotlin/helpers/ScopeHelper.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package RimworldDev.Rider.helpers

import java.io.File
import java.nio.file.Files
import javax.xml.parsers.DocumentBuilderFactory

class ScopeHelper {
companion object {
fun getSteamLocations(): List<String> {
var home = System.getProperty("user.home")

var locations = mutableListOf<String>(
"C:\\Program Files (x86)\\Steam\\steamapps\\",
"C:\\Program Files\\Steam\\steamapps\\",
"${home}/steam/steam/steamapps/",
"${home}/snap/steam/common/.local/share/Steam/steamapps/",
"${home}/.local/share/Steam/steamapps/",
)

locations.addAll(File.listRoots().map {
"${it.path}/SteamLibrary/steamapps"
})

return locations.filter { location -> File(location).exists() }.map {
File(it).absoluteFile.toString()
}
}

fun findRimworldDirectory(): String? {
// @TODO: Check the user settings for the Rimworld location

var locations = mutableListOf<String>();
locations.addAll(getSteamLocations().filter {
File("${it}/common/Rimworld").exists()
}.map {
File("${it}/common/Rimworld").absolutePath.toString()
})

if (locations.isNotEmpty()) return locations.first()

// @TODO: Check from the current directory

return null
}

fun findModDirectories(): List<String> {
val locations = mutableListOf<String>()
val rimworldLocation = findRimworldDirectory()
if (rimworldLocation != null) {
var dataDirectory = File("$rimworldLocation/Data")
var modsDirectory = File("$rimworldLocation/Mods")

if (dataDirectory.exists()) locations.add(dataDirectory.absolutePath)
if (modsDirectory.exists()) locations.add(modsDirectory.absolutePath)
}

locations.addAll(getSteamLocations()
.map { "${it}/workshop/content/294100/" }
.filter { File(it).exists() }
.map { File(it).absolutePath }
)

return locations
}

fun findModLocation(id: String): String? {
val directoriesToCheck = findModDirectories()

val xmlReaderFactory = DocumentBuilderFactory.newInstance()
val builder = xmlReaderFactory.newDocumentBuilder()
for (directory in directoriesToCheck) {
for (child in File(directory).listFiles()) {
if (!child.isDirectory) continue

var aboutFile = File("${child.absolutePath}/About/About.xml")
if (!aboutFile.exists()) continue

val document = builder.parse(aboutFile)

var a = 1 + 1
}
}

return null
}

fun findInstalledHarmonyDll(): String? {
val version = findRimworldVersion()
if (version == null) return null

val directoriesToCheck = findModDirectories()

val xmlReaderFactory = DocumentBuilderFactory.newInstance()
val builder = xmlReaderFactory.newDocumentBuilder()
for (directory in directoriesToCheck) {
for (child in File(directory).listFiles()) {
if (!child.isDirectory) continue

var aboutFile = File("${child.absolutePath}/About/About.xml")
if (!aboutFile.exists()) continue

if (child.name != "2009463077") continue

if (File("${child.absolutePath}/${version}/Assemblies/0Harmony.dll").exists())
return File("${child.absolutePath}/${version}/Assemblies/0Harmony.dll").absolutePath

return File("${child.absolutePath}/Current/Assemblies/0Harmony.dll").absolutePath
}
}

return null
}

fun findRimworldVersion(): String? {
val directory = findRimworldDirectory()
if (directory == null) return null

if (!File("${directory}/Version.txt").exists()) return null

val contents = File("${directory}/Version.txt").readText()

return contents.substring(0, 3)
}
}
}
6 changes: 6 additions & 0 deletions src/rider/main/kotlin/run/RunState.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package RimworldDev.Rider.run

import RimworldDev.Rider.helpers.ScopeHelper
import com.intellij.execution.ExecutionResult
import com.intellij.execution.Executor
import com.intellij.execution.configurations.RunProfileState
Expand Down Expand Up @@ -108,6 +109,11 @@ class RunState(
currentResources.forEach {
copyResource("/UnityDoorstop/${OS.CURRENT}/", it)
}

val harmonyDll = ScopeHelper.findInstalledHarmonyDll()
if (harmonyDll != null) {
File(harmonyDll).copyTo(File("${rimworldDir}/Doorstop/0Harmony.dll"), true)
}
}

private fun removeDoorstep() {
Expand Down