Skip to content

Commit dc88f1b

Browse files
committed
Update for .net 9 / splittening
1 parent e5f82b0 commit dc88f1b

14 files changed

Lines changed: 255 additions & 77 deletions

.github/workflows/build.yml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Build
4+
5+
# Trigger the action on push to master
6+
on:
7+
workflow_call: {} # Allow reusing this workflow
8+
push:
9+
branches:
10+
- master # Run for pushes to master
11+
pull_request:
12+
branches:
13+
- '*' # Run the workflow for all pull requests
14+
15+
# Sets permissions of the GITHUB_TOKEN to allow reading packages
16+
permissions:
17+
packages: read
18+
19+
env:
20+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
21+
DOTNET_NOLOGO: true
22+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
NuGetDirectory: ${{ github.workspace}}/nuget
24+
25+
defaults:
26+
run:
27+
shell: pwsh
28+
29+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
30+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
31+
concurrency:
32+
group: "ci"
33+
cancel-in-progress: false
34+
35+
jobs:
36+
Build:
37+
runs-on: ubuntu-latest
38+
steps:
39+
# Setup environment
40+
- name: Checkout
41+
uses: actions/checkout@v4
42+
43+
- name: Setup Dotnet
44+
uses: actions/setup-dotnet@v4
45+
with:
46+
dotnet-version: 9.x
47+
source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json
48+
49+
- name: Add MonkeyLoader NuGet Source
50+
run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json
51+
52+
- name: Restore NuGet Package Cache
53+
uses: actions/cache/restore@v4
54+
with:
55+
path: ~/.nuget/packages
56+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
57+
restore-keys: |
58+
${{ runner.os }}-nuget
59+
60+
# Build and test projects
61+
- name: Restore
62+
run: dotnet restore
63+
64+
- name: Build
65+
run: dotnet build --no-restore --configuration Release
66+
67+
- name: Test
68+
run: dotnet test --no-restore --no-build
69+
70+
- name: Move NuGet Packages
71+
run: mv (Get-ChildItem -Recurse ./ -Include *.nupkg) ./
72+
73+
# Removes the version number from the package name
74+
- name: Rename NuGet Packages
75+
run: Get-ChildItem -Include *.nupkg -Path ./* | Rename-Item -NewName { $_.Name -Replace '\.\d+\.\d+\.\d+.*$','.nupkg' }
76+
77+
# Publish the NuGet package(s) as an artifact, so they can be used in the following jobs
78+
- name: Upload NuGet Packages Artifact
79+
uses: actions/upload-artifact@v4
80+
with:
81+
name: NuGet Packages
82+
if-no-files-found: error
83+
retention-days: 7
84+
path: ./*.nupkg
85+
86+
# Only when it's not from a PR to avoid any funny packages in the cache
87+
- name: Save NuGet Package Cache
88+
if: ${{ github.event_name != 'pull_request' }}
89+
uses: actions/cache/save@v4
90+
with:
91+
path: ~/.nuget/packages
92+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
93+
94+
Validate-NuGet:
95+
runs-on: ubuntu-latest
96+
needs: [ Build ]
97+
steps:
98+
- name: Setup Dotnet
99+
uses: actions/setup-dotnet@v4
100+
with:
101+
dotnet-version: 9.x
102+
source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json
103+
104+
- name: Add MonkeyLoader NuGet Source
105+
run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json
106+
107+
- name: Restore NuGet Package Cache
108+
uses: actions/cache/restore@v4
109+
with:
110+
path: ~/.nuget/packages
111+
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
112+
restore-keys: |
113+
${{ runner.os }}-nuget
114+
115+
- name: Install NuGet Validator
116+
run: dotnet tool update Meziantou.Framework.NuGetPackageValidation.Tool --global
117+
118+
- name: Download NuGet Packages Artifact
119+
uses: actions/download-artifact@v4
120+
with:
121+
name: NuGet Packages
122+
path: ${{ env.NuGetDirectory }}
123+
124+
# Validate metadata and content of the NuGet package
125+
# https://www.nuget.org/packages/Meziantou.Framework.NuGetPackageValidation.Tool#readme-body-tab
126+
# If some rules are not applicable, you can disable them
127+
# using the --excluded-rules or --excluded-rule-ids option
128+
- name: Validate Package(s)
129+
run: meziantou.validate-nuget-package (Get-ChildItem -Recurse "${{ env.NuGetDirectory }}" -Include *.nupkg) --excluded-rules IconMustBeSet

.github/workflows/publish.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Publish
4+
5+
on:
6+
push:
7+
tags:
8+
- v** # Only when a v... tag is pushed
9+
10+
# Sets permissions of the GITHUB_TOKEN to allow writing packages and push releases
11+
permissions:
12+
packages: write
13+
contents: write
14+
15+
env:
16+
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
17+
DOTNET_NOLOGO: true
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
20+
NuGetDirectory: ${{ github.workspace}}/nuget
21+
22+
defaults:
23+
run:
24+
shell: pwsh
25+
26+
jobs:
27+
Build:
28+
uses: ./.github/workflows/build.yml
29+
30+
Release:
31+
#if: startsWith(github.ref, 'refs/tags/')
32+
runs-on: ubuntu-latest
33+
needs: [ build ]
34+
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v4
37+
38+
- name: Download NuGet Packages Artifact
39+
uses: actions/download-artifact@v4
40+
with:
41+
name: NuGet Packages
42+
path: ${{ env.NuGetDirectory }}
43+
44+
- name: Build Changelog
45+
id: build_changelog
46+
uses: mikepenz/release-changelog-builder-action@v4
47+
48+
- name: Create Release
49+
uses: mikepenz/action-gh-release@v1 #softprops/action-gh-release
50+
with:
51+
body: ${{steps.build_changelog.outputs.changelog}}
52+
files: ${{ env.NuGetDirectory }}/*.nupkg
53+
fail_on_unmatched_files: true
54+
fail_on_asset_upload_issue: true
55+
prerelease: ${{ contains(github.ref, '-') }} # simple check for vX.Y.Z-something
56+
57+
Publish-GitHub:
58+
#if: startsWith(github.ref, 'refs/tags/')
59+
runs-on: ubuntu-latest
60+
needs: [ build ]
61+
steps:
62+
- name: Download NuGet Packages Artifact
63+
uses: actions/download-artifact@v4
64+
with:
65+
name: NuGet Packages
66+
path: ${{ env.NuGetDirectory }}
67+
68+
- name: Setup Dotnet
69+
uses: actions/setup-dotnet@v4
70+
with:
71+
dotnet-version: 9.x
72+
source-url: https://nuget.pkg.github.com/ResoniteModdingGroup/index.json
73+
74+
- name: Add MonkeyLoader NuGet Source
75+
run: dotnet nuget add source https://pkg.munally.com/MonkeyModdingTroop/index.json
76+
77+
# Publish all NuGet packages to the GitHub feed
78+
# Use --skip-duplicate to prevent errors if a package with the same version already exists.
79+
# If you retry a failed workflow, already published packages will be skipped without error.
80+
- name: Publish NuGet Packages
81+
run: |
82+
foreach($file in (Get-ChildItem "${{ env.NuGetDirectory }}" -Recurse -Include *.nupkg)) {
83+
dotnet nuget push $file --api-key "${{ secrets.GITHUB_TOKEN }}" --source https://nuget.pkg.github.com/ResoniteModdingGroup/index.json --skip-duplicate
84+
}

BoundedUIX.sln

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.31727.386
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36408.4 d17.14
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BoundedUIX", "BoundedUIX\BoundedUIX.csproj", "{0322B2EF-7452-479D-BAE2-FCAB75033337}"
77
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8EC462FD-D22E-90A8-E5CE-7E832BA40C5D}"
9+
ProjectSection(SolutionItems) = preProject
10+
.gitattributes = .gitattributes
11+
.gitignore = .gitignore
12+
Directory.Build.props = Directory.Build.props
13+
README.md = README.md
14+
EndProjectSection
15+
EndProject
816
Global
917
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1018
Debug|Any CPU = Debug|Any CPU

BoundedUIX/BoundedUIX.csproj

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>net462</TargetFramework>
43
<AssemblyName>BoundedUIX</AssemblyName>
54
<AssemblyFileName>$(AssemblyTitle).dll</AssemblyFileName>
65
<RootNamespace>BoundedUIX</RootNamespace>
@@ -11,11 +10,9 @@
1110
<PackageId>BoundedUIX</PackageId>
1211
<Title>Bounded UIX</Title>
1312
<Authors>Banane9</Authors>
14-
<Version>2.0.1-beta</Version>
15-
<Description>
16-
This MonkeyLoader mod for Resonite makes UIX elements selectable and editable with the usual Slot gizmos,
17-
as well as fixing UIX elements breaking when a parent is inserted.
18-
</Description>
13+
<Version>2.1.0-beta</Version>
14+
<Description>This MonkeyLoader mod for Resonite makes UIX elements selectable and editable with the usual Slot gizmos,
15+
as well as fixing UIX elements breaking when a parent is inserted.</Description>
1916
<PackageReadmeFile>README.md</PackageReadmeFile>
2017
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
2118
<PackageProjectUrl>https://github.com/ResoniteModdingGroup/BoundedUIX</PackageProjectUrl>
@@ -45,24 +42,19 @@
4542
</ItemGroup>
4643

4744
<ItemGroup>
48-
<PackageReference Include="MonkeyLoader" Version="0.17.2-beta" />
49-
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.16.0-beta" GeneratePathProperty="true" />
50-
<PackageReference Include="PolySharp" Version="1.14.1">
51-
<PrivateAssets>all</PrivateAssets>
52-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
53-
</PackageReference>
54-
<PackageReference Include="Resonite.Elements.Core" Version="1.0.2" />
55-
<PackageReference Include="Resonite.FrooxEngine" Version="2024.6.5.198" />
56-
<PackageReference Include="System.Text.Json" Version="8.0.2">
45+
<PackageReference Include="MonkeyLoader.GamePacks.Resonite" Version="0.24.1-beta" GeneratePathProperty="true" />
46+
<PackageReference Include="PolySharp" Version="1.15.0">
5747
<PrivateAssets>all</PrivateAssets>
5848
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5949
</PackageReference>
50+
<PackageReference Include="Resonite.Elements.Core" Version="1.4.9.4" />
51+
<PackageReference Include="Resonite.FrooxEngine" Version="2025.8.28.607" />
6052
</ItemGroup>
6153

6254
<ItemGroup>
6355
<!-- Reference the pre-patcher assembly from the Game Pack because PackageReference is stupid -->
6456
<Reference Include="MonkeyLoader.Resonite.Data">
65-
<HintPath>$(PkgMonkeyLoader_GamePacks_Resonite)\lib\net462\pre-patchers\MonkeyLoader.Resonite.Data.dll</HintPath>
57+
<HintPath>$(PkgMonkeyLoader_GamePacks_Resonite)\lib\net9.0\pre-patchers\MonkeyLoader.Resonite.Data.dll</HintPath>
6658
</Reference>
6759
</ItemGroup>
6860
</Project>

BoundedUIX/Gizmos/SlotGizmoPatches.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Elements.Core;
66
using FrooxEngine;
77
using HarmonyLib;
8+
using MonkeyLoader.Resonite.UI;
89

910
namespace BoundedUIX.Gizmos
1011
{
@@ -30,10 +31,11 @@ private static BoundingBox BoundUIX(BoundingBox bounds, Slot target, Slot space)
3031
[HarmonyPatch(nameof(SlotGizmo.OnCommonUpdate))]
3132
private static IEnumerable<CodeInstruction> OnCommonUpdateTranspiler(IEnumerable<CodeInstruction> codeInstructions)
3233
{
33-
var boundUIXMethod = typeof(SlotGizmoPatches).GetMethod(nameof(BoundUIX), AccessTools.allDeclared);
34-
var computeBoundingBoxMethod = typeof(BoundsHelper).GetMethod(nameof(BoundsHelper.ComputeBoundingBox), AccessTools.allDeclared);
35-
var getGlobalPositionMethod = typeof(Slot).GetProperty(nameof(Slot.GlobalPosition), AccessTools.allDeclared).GetMethod;
36-
var uixBoundCenterMethod = typeof(SlotGizmoPatches).GetMethod(nameof(UIXBoundCenter), AccessTools.allDeclared);
34+
var computeBoundingBoxMethod = AccessTools.Method(typeof(BoundsHelper), nameof(BoundsHelper.ComputeBoundingBox));
35+
var getGlobalPositionMethod = AccessTools.PropertyGetter(typeof(Slot), nameof(Slot.GlobalPosition));
36+
37+
var boundUIXMethod = AccessTools.Method(typeof(SlotGizmoPatches), nameof(BoundUIX));
38+
var uixBoundCenterMethod = AccessTools.Method(typeof(SlotGizmoPatches), nameof(UIXBoundCenter));
3739

3840
var instructions = codeInstructions.ToList();
3941

BoundedUIX/Gizmos/TranslationGizmoPatches.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private static void SetTargetPostfix(TranslationGizmo __instance, Slot slot)
1919
var moveableRect = slot.TryGetMovableRectTransform(out _);
2020

2121
foreach (var child in __instance.Slot.Children)
22-
child.ActiveSelf = !moveableRect || !child.Name.Contains("Z") || !UIXGizmos.Enabled;
22+
child.ActiveSelf = !moveableRect || !child.Name.Contains('Z') || !UIXGizmos.Enabled;
2323
}
2424
}
2525
}

BoundedUIX/Gizmos/UIXGizmos.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using HarmonyLib;
33
using MonkeyLoader.Patching;
44
using MonkeyLoader.Resonite;
5+
using MonkeyLoader.Resonite.UI;
56
using System;
67
using System.Collections.Generic;
78
using System.Linq;
@@ -17,8 +18,6 @@ internal sealed class UIXGizmos : ConfiguredResoniteMonkey<UIXGizmos, UIXGizmoCo
1718
public override bool CanBeDisabled => true;
1819
public override string Name => "UIX Gizmos";
1920

20-
protected override IEnumerable<IFeaturePatch> GetFeaturePatches() => Enumerable.Empty<IFeaturePatch>();
21-
2221
[HarmonyPrefix]
2322
private static bool PositionAtTargetPrefix(Gizmo __instance)
2423
{

BoundedUIX/Helpers.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,14 @@ namespace BoundedUIX
1313
{
1414
internal static class Helpers
1515
{
16-
private static readonly ConditionalWeakTable<RectTransform, OriginalRect> _originalRects = new();
16+
private static readonly ConditionalWeakTable<RectTransform, OriginalRect> _originalRects = [];
1717

1818
public static bool Contains(this BoundingBox2D boundingBox, float2 point)
1919
=> (point >= boundingBox.Min).All() && (point <= boundingBox.Max).All();
2020

21-
public static BoundingBox2D GetCanvasBounds(this RectTransform rectTransform)
22-
{
23-
var area = rectTransform.ComputeGlobalComputeRect();
24-
25-
var bounds = BoundingBox2D.Empty();
26-
bounds.Encapsulate(area.ExtentMin / rectTransform.Canvas.UnitScale);
27-
bounds.Encapsulate(area.ExtentMax / rectTransform.Canvas.UnitScale);
28-
29-
return bounds;
30-
}
31-
32-
public static BoundingBox GetGlobalBounds(this RectTransform rectTransform)
33-
{
34-
var area = rectTransform.ComputeGlobalComputeRect();
35-
36-
var bounds = BoundingBox.Empty();
37-
bounds.Encapsulate(rectTransform.Canvas.Slot.LocalPointToGlobal(area.ExtentMin / rectTransform.Canvas.UnitScale));
38-
bounds.Encapsulate(rectTransform.Canvas.Slot.LocalPointToGlobal(area.ExtentMax / rectTransform.Canvas.UnitScale));
39-
40-
return bounds;
41-
}
42-
4321
public static OriginalRect GetOriginal(this RectTransform rectTransform)
4422
=> _originalRects.GetOrCreateValue(rectTransform);
4523

46-
public static void ResetTransform(this RectTransform rectTransform)
47-
{
48-
rectTransform.AnchorMin.Value = float2.Zero;
49-
rectTransform.AnchorMax.Value = float2.One;
50-
rectTransform.OffsetMin.Value = float2.Zero;
51-
rectTransform.OffsetMax.Value = float2.Zero;
52-
rectTransform.Pivot.Value = new(.5f, .5f);
53-
}
54-
5524
public static bool TryGetMovableRectTransform(this Slot slot, [NotNullWhen(true)] out RectTransform? rectTransform)
5625
=> slot.TryGetRectTransform(out rectTransform) && rectTransform.Slot != rectTransform.Canvas.Slot;
5726

0 commit comments

Comments
 (0)