Skip to content

Commit

Permalink
v3.23.0
Browse files Browse the repository at this point in the history
support ToggleGrabMode
  • Loading branch information
LozenChen committed Dec 31, 2024
1 parent b2bf2d3 commit 670dde2
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 17 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,9 @@ ASALocalRun/

SpeedrunTool/lib-stripped/*
/SpeedrunTool.sln.DotSettings

SpeedrunTool.dll
Dialog
Graphics
everest.yaml
toZip.cmd
64 changes: 51 additions & 13 deletions SpeedrunTool/Source/SaveLoad/SaveLoadAction.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Concurrent;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
Expand Down Expand Up @@ -197,7 +197,8 @@ public static void InitActions() {
FixSaveLoadIcon();
BetterCasualPlay();
SupportExternalMember();
SupportCalcRandom();
SupportCalcRandom();
SupportSettings();
SupportMInput();
SupportInput();
SupportAudioMusic();
Expand All @@ -222,6 +223,15 @@ public static void InitActions() {
// 放最后,确保收集了所有克隆的 VirtualAssets 与 EventInstance
ReloadVirtualAssets();
ReleaseEventInstances();
}

internal static void LogSavedValues() {
foreach (SaveLoadAction slAction in All) {
Logger.Log("SRT", "=================");
foreach (KeyValuePair<Type, Dictionary<string, object>> pair in slAction.savedValues) {
Logger.Log("SRT", pair.Key.FullName);
}
}
}

private static void InitFields() {
Expand Down Expand Up @@ -454,6 +464,24 @@ private static void SupportCalcRandom() {
(savedValues, _) => SaveStaticMemberValues(savedValues, typeof(Calc),
nameof(Calc.Random), nameof(Calc.randomStack)),
(savedValues, _) => LoadStaticMemberValues(savedValues));
}

private static void SupportSettings() {
SafeAdd(
(savedValues, _) => {
if (Settings.Instance is { } settings) {
Dictionary<string, object> dict = new();
dict["GrabMode"] = settings.GrabMode;
savedValues[typeof(Settings)] = dict;
}
},
(savedValues, _) => {
if (Settings.Instance is { } settings && savedValues.TryGetValue(typeof(Settings), out Dictionary<string, object> dict)) {
settings.GrabMode = (GrabModes)dict["GrabMode"];

}
}
);
}

private static void SupportMInput() {
Expand All @@ -479,7 +507,10 @@ private static void SupportInput() {
foreach (FieldInfo fieldInfo in typeof(Input).GetFields(BindingFlags.Public | BindingFlags.Static).Where(info =>
info.FieldType.IsSameOrSubclassOf(typeof(VirtualInput)))) {
inputDict[fieldInfo.Name] = fieldInfo.GetValue(null);
}
}

inputDict["grabToggle"] = Input.grabToggle;
inputDict["LastAim"] = Input.LastAim;

savedValues[inputType] = inputDict.DeepCloneShared();

Expand Down Expand Up @@ -524,16 +555,23 @@ private static void SupportInput() {

if (StateManager.Instance.LoadByTas) {
inputType.SetFieldValue(fieldName, virtualInput);
} else {
object fieldValue = inputType.GetFieldValue(fieldName);

if (fieldValue is VirtualJoystick virtualJoystick &&
virtualInput is VirtualJoystick savedVirtualJoystick) {
virtualJoystick.InvertedX = savedVirtualJoystick.InvertedX;
virtualJoystick.InvertedY = savedVirtualJoystick.InvertedY;
} else if (fieldValue is VirtualIntegerAxis virtualIntegerAxis &&
virtualInput is VirtualIntegerAxis savedVirtualIntegerAxis) {
virtualIntegerAxis.Inverted = savedVirtualIntegerAxis.Inverted;
} else {
if (fieldName == "grabToggle") {
Input.grabToggle = (bool)virtualInput;
}
else if (fieldName == "LastAim") {
Input.LastAim = (Vector2)virtualInput;
}
else {
object fieldValue = inputType.GetFieldValue(fieldName);
if (fieldValue is VirtualJoystick virtualJoystick &&
virtualInput is VirtualJoystick savedVirtualJoystick) {
virtualJoystick.InvertedX = savedVirtualJoystick.InvertedX;
virtualJoystick.InvertedY = savedVirtualJoystick.InvertedY;
} else if (fieldValue is VirtualIntegerAxis virtualIntegerAxis &&
virtualInput is VirtualIntegerAxis savedVirtualIntegerAxis) {
virtualIntegerAxis.Inverted = savedVirtualIntegerAxis.Inverted;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions SpeedrunTool/Source/SaveLoad/StateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ private bool SaveState(bool tas) {
level.Add(new WaitingEntity());
}
}

// SaveLoadAction.LogSavedValues();

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion SpeedrunTool/Source/SpeedrunToolModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Celeste.Mod.SpeedrunTool.SaveLoad;
using Celeste.Mod.SpeedrunTool.SaveLoad;
using FMOD.Studio;

namespace Celeste.Mod.SpeedrunTool;
Expand Down
19 changes: 18 additions & 1 deletion SpeedrunTool/SpeedrunTool.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectGuid>{C7DFDD37-907C-4A75-96DA-1C5828C97F96}</ProjectGuid>
<RootNamespace>Celeste.Mod.SpeedrunTool</RootNamespace>
Expand Down Expand Up @@ -83,5 +83,22 @@
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<Delete Files="$(TargetDir)JetBrains.Profiler.Api.dll" />
</Target>

<Target Name="CopyAssemblies" AfterTargets="Build">
<Copy SourceFiles="$(OutputPath)$(AssemblyName).dll" DestinationFolder=".." />
<Copy SourceFiles="$(OutputPath)$(AssemblyName).pdb" DestinationFolder=".." />
</Target>

<Target Name="CopyAssets" AfterTargets="Build" Condition="'$(Configuration)' != 'Debug' or '$(OS)' != 'Unix' or $(UseSymlinks) == false">
<ItemGroup>
<CelesteAssets Include="everest.yaml" />
<CelesteAssets Include="Dialog\**\*" />
<CelesteAssets Include="Graphics\**\*" />
</ItemGroup>

<!-- Clean-up potential symlinks -->
<RemoveDir Directories="..\Dialog;..\Graphics"/>
<Copy SourceFiles="@(CelesteAssets)" DestinationFiles="..\%(Identity)"/>
</Target>
</Project>
4 changes: 2 additions & 2 deletions SpeedrunTool/everest.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
- Name: SpeedrunTool
Version: 3.22.11
Version: 3.23.0
DLL: SpeedrunTool.dll
Dependencies:
- Name: Everest
Version: 1.2374.0
Version: 1.5105.0

0 comments on commit 670dde2

Please sign in to comment.