Skip to content

Commit 8382025

Browse files
committed
Add project files.
1 parent 79e837f commit 8382025

9 files changed

Lines changed: 1093 additions & 0 deletions

File tree

ShortStartLoader.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31025.194
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShortStartLoader", "ShortStartLoader\ShortStartLoader.csproj", "{86BD8498-F01A-468D-886F-DC55E2BC6E05}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{86BD8498-F01A-468D-886F-DC55E2BC6E05}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{86BD8498-F01A-468D-886F-DC55E2BC6E05}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{86BD8498-F01A-468D-886F-DC55E2BC6E05}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{86BD8498-F01A-468D-886F-DC55E2BC6E05}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {978980E8-DD89-4FFA-8E42-B2D95994340F}
24+
EndGlobalSection
25+
EndGlobal

ShortStartLoader/FileOpOptimize.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
using BepInEx;
2+
using HarmonyLib;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.IO;
6+
using System.Linq;
7+
8+
namespace ShortStartLoader
9+
{
10+
public class FileOpOptimize
11+
{
12+
public static readonly string Com3d2Path = Paths.GameRootPath;
13+
public static readonly string ModPath = Com3d2Path + "\\Mod";
14+
private static IEnumerable<string> _filePathInfoList;
15+
16+
// the credit for the whole thing goes to はてな (twitter @hatena_37 )
17+
//I further rewrote this and made it more simple for BepInEx.
18+
19+
//Speeds up fetching of .menu files from arcs by using a smarter heuristic. Only applies to menu files as they're the common file.
20+
21+
//Release handlers as it seems they remain open in the normal implementation causing a slow down.
22+
23+
//The original function has been deemed pretty much useless with the function of the above.
24+
[HarmonyPatch(typeof(FileSystemArchive), "GetFileListAtExtension")]
25+
[HarmonyPrefix]
26+
public static bool FileSystemArchiveGetFileListAtExtension(ref string[] __result, ref string __0)
27+
{
28+
GameUty.FileSystem.GetList("", AFileSystemBase.ListType.TopFolder);
29+
30+
__result = null;
31+
if (__0 == ".menu")
32+
{
33+
__result = GameUty.FileSystem
34+
.GetList("menu", AFileSystemBase.ListType.AllFile)
35+
.Concat(
36+
Array.FindAll(GameUty.FileSystem.GetList("parts", AFileSystemBase.ListType.AllFile), i => i.EndsWith(".menu", StringComparison.OrdinalIgnoreCase))
37+
)
38+
.ToArray();
39+
}
40+
return __result == null;
41+
}
42+
43+
[HarmonyPatch(typeof(FileSystemWindows), "AddFolder")]
44+
[HarmonyPostfix]
45+
public static void FileSystemWindowsAddFolderPost(ref FileSystemWindows __instance) //inject at start; pass invoke
46+
{
47+
__instance.AddAutoPathForAllFolder(true);
48+
while (!__instance.IsFinishedAddAutoPathJob(true))
49+
{
50+
}
51+
__instance.ReleaseAddAutoPathJob();
52+
}
53+
54+
[HarmonyPatch(typeof(FileSystemWindows), "AddAutoPath")]
55+
[HarmonyPrefix]
56+
public static bool FileSystemWindowsAddAutoPath(ref bool __result) // inject at start; modify return
57+
{
58+
__result = true;
59+
return false;
60+
}
61+
62+
[HarmonyPatch(typeof(FileSystemWindows), "GetFileListAtExtension")]
63+
[HarmonyPrefix]
64+
public static bool FileSystemWindowsGetFileListAtExtension(ref string[] __result, ref string __0) // inject at start; pass parameters; modify return
65+
{
66+
if (_filePathInfoList == null)
67+
{
68+
_filePathInfoList = Directory.GetFiles(ModPath, "*", SearchOption.AllDirectories)
69+
.Select(x => x.Replace(Paths.GameRootPath + "\\Mod\\", string.Empty).ToLower());
70+
}
71+
72+
var loc0 = __0;
73+
74+
__result = _filePathInfoList
75+
.Where(x => x.EndsWith(loc0, StringComparison.OrdinalIgnoreCase))
76+
.ToArray();
77+
78+
return false;
79+
}
80+
81+
[HarmonyPatch(typeof(FileSystemWindows), "AddFolder")]
82+
[HarmonyPatch(typeof(FileSystemWindows), "AddAutoPath")]
83+
[HarmonyPatch(typeof(FileSystemWindows), "AddAutoPathForAllFolder")]
84+
[HarmonyPrefix]
85+
public static void ResetCache()
86+
{
87+
_filePathInfoList = null;
88+
}
89+
}
90+
}

ShortStartLoader/GetFilesFix.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using HarmonyLib;
2+
using System.IO;
3+
using System.Linq;
4+
5+
namespace ShortStartLoader
6+
{
7+
internal static class GetFilesFix
8+
{
9+
[HarmonyPatch(typeof(Directory), "GetFiles", typeof(string), typeof(string), typeof(SearchOption))]
10+
[HarmonyPrefix]
11+
public static bool DirGetFilesCache(ref string __0, ref string __1, ref SearchOption searchOption, ref string[] __result)
12+
{
13+
if (__1.Equals("*"))
14+
{
15+
return true;
16+
}
17+
18+
var reg = WildcardToRegex.WildcardToRegexp("^" + __1 + "$");
19+
20+
__result = Directory.GetFiles(__0, "*", searchOption).Where(path => reg.IsMatch(Path.GetFileName(path))).ToArray();
21+
#if DEBUG
22+
Main.PLogger.LogInfo($"Returning: {__result.Count()} files... Found with reg {reg} converted from wildcard {__1}.");
23+
#endif
24+
25+
return false;
26+
}
27+
}
28+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
// General Information about an assembly is controlled through the following
5+
// set of attributes. Change these attribute values to modify the information
6+
// associated with an assembly.
7+
[assembly: AssemblyTitle("ShortStartLoader")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("ShortStartLoader")]
12+
[assembly: AssemblyCopyright("Copyright © 2021")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// Setting ComVisible to false makes the types in this assembly not visible
17+
// to COM components. If you need to access a type in this assembly from
18+
// COM, set the ComVisible attribute to true on that type.
19+
[assembly: ComVisible(false)]
20+
21+
// The following GUID is for the ID of the typelib if this project is exposed to COM
22+
[assembly: Guid("86bd8498-f01a-468d-886f-dc55e2bc6e05")]
23+
24+
// Version information for an assembly consists of the following four values:
25+
//
26+
// Major Version
27+
// Minor Version
28+
// Build Number
29+
// Revision
30+
//
31+
// You can specify all the values or you can default the Build and Revision Numbers
32+
// by using the '*' as shown below:
33+
// [assembly: AssemblyVersion("1.0.*")]
34+
[assembly: AssemblyVersion("1.0.0.0")]
35+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{86BD8498-F01A-468D-886F-DC55E2BC6E05}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>ShortStartLoader</RootNamespace>
11+
<AssemblyName>COM3D2.ShortStartLoader</AssemblyName>
12+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<Deterministic>true</Deterministic>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="0Harmony, Version=2.9.0.0, Culture=neutral, processorArchitecture=MSIL">
37+
<HintPath>..\packages\HarmonyX.2.9.0\lib\net35\0Harmony.dll</HintPath>
38+
</Reference>
39+
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
40+
<HintPath>..\packages\COM3D2.GameLibs.2.24.0-r.1\lib\net35\Assembly-CSharp.dll</HintPath>
41+
</Reference>
42+
<Reference Include="Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
43+
<HintPath>..\packages\COM3D2.GameLibs.2.24.0-r.1\lib\net35\Assembly-CSharp-firstpass.dll</HintPath>
44+
</Reference>
45+
<Reference Include="BepInEx, Version=5.4.21.0, Culture=neutral, processorArchitecture=MSIL">
46+
<HintPath>..\packages\BepInEx.BaseLib.5.4.21\lib\net35\BepInEx.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
49+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Mono.Cecil.Mdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
52+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Mdb.dll</HintPath>
53+
</Reference>
54+
<Reference Include="Mono.Cecil.Pdb, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
55+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Pdb.dll</HintPath>
56+
</Reference>
57+
<Reference Include="Mono.Cecil.Rocks, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e, processorArchitecture=MSIL">
58+
<HintPath>..\packages\Mono.Cecil.0.10.4\lib\net35\Mono.Cecil.Rocks.dll</HintPath>
59+
</Reference>
60+
<Reference Include="MonoMod.RuntimeDetour, Version=22.1.29.1, Culture=neutral, processorArchitecture=MSIL">
61+
<HintPath>..\packages\MonoMod.RuntimeDetour.22.1.29.1\lib\net35\MonoMod.RuntimeDetour.dll</HintPath>
62+
</Reference>
63+
<Reference Include="MonoMod.Utils, Version=22.1.29.1, Culture=neutral, processorArchitecture=MSIL">
64+
<HintPath>..\packages\MonoMod.Utils.22.1.29.1\lib\net35\MonoMod.Utils.dll</HintPath>
65+
</Reference>
66+
<Reference Include="SemanticVersioning, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a89bb7dc6f7a145c, processorArchitecture=MSIL">
67+
<HintPath>..\packages\SemanticVersioning.2.0.0\lib\net35\SemanticVersioning.dll</HintPath>
68+
</Reference>
69+
<Reference Include="System" />
70+
<Reference Include="System.Core" />
71+
<Reference Include="System.Threading, Version=1.0.3333.0, Culture=neutral, PublicKeyToken=402899b480e6f383, processorArchitecture=MSIL">
72+
<HintPath>..\packages\TaskParallelLibrary.Repackaged.1.0.4-custom\lib\Net35\System.Threading.dll</HintPath>
73+
</Reference>
74+
<Reference Include="System.Xml.Linq" />
75+
<Reference Include="System.Data.DataSetExtensions" />
76+
<Reference Include="System.Data" />
77+
<Reference Include="System.Xml" />
78+
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
79+
<HintPath>..\packages\UnityEngine.5.6.1\lib\net35\UnityEngine.dll</HintPath>
80+
</Reference>
81+
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
82+
<HintPath>..\packages\COM3D2.GameLibs.2.24.0-r.1\lib\net35\UnityEngine.UI.dll</HintPath>
83+
</Reference>
84+
</ItemGroup>
85+
<ItemGroup>
86+
<Compile Include="GetFilesFix.cs" />
87+
<Compile Include="FileOpOptimize.cs" />
88+
<Compile Include="StartupOptimize.cs" />
89+
<Compile Include="WildcardToRegex.cs" />
90+
<Compile Include="SslMain.cs" />
91+
<Compile Include="Properties\AssemblyInfo.cs" />
92+
<None Include="packages.config" />
93+
</ItemGroup>
94+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
95+
<PropertyGroup>
96+
<PostBuildEvent>del "G:\KISS\COM3D2Test\BepinEx\plugins\$(TargetFileName)"
97+
copy "$(TargetPath)" "G:\KISS\COM3D2Test\BepinEx\plugins"
98+
powershell start-process "G:\KISS\COM3D2Test\COM3D2x64.exe"</PostBuildEvent>
99+
</PropertyGroup>
100+
<Import Project="..\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets" Condition="Exists('..\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets')" />
101+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
102+
<PropertyGroup>
103+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
104+
</PropertyGroup>
105+
<Error Condition="!Exists('..\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\BepInEx.Core.5.4.21\build\BepInEx.Core.targets'))" />
106+
</Target>
107+
</Project>

ShortStartLoader/SslMain.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using BepInEx;
2+
using BepInEx.Configuration;
3+
using BepInEx.Logging;
4+
using HarmonyLib;
5+
using System.Security;
6+
using System.Security.Permissions;
7+
8+
[module: UnverifiableCode]
9+
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
10+
11+
namespace ShortStartLoader
12+
{
13+
[BepInPlugin("ShortStartLoader", "ShortStartLoader", "1.2")]
14+
[BepInDependency("BepInEx.SybarisLoader.Patcher", BepInDependency.DependencyFlags.SoftDependency)]
15+
public class SslMain : BaseUnityPlugin
16+
{
17+
public static ManualLogSource PubLogger;
18+
public static ConfigEntry<bool> UseNewMethod;
19+
public static ConfigEntry<bool> GetFileFilterFix;
20+
public static ConfigEntry<bool> FileOpOptimize;
21+
private static Harmony _harmony;
22+
23+
private void Awake()
24+
{
25+
PubLogger = Logger;
26+
27+
UseNewMethod = Config.Bind("General", "Use New Method", true, "Uses a new method that further incorporates optimization from the built in WSQO. Confers a nice speed boost but stability is unsure.");
28+
GetFileFilterFix = Config.Bind("General", "Fix GetFiles (Restart Required)", true, "Fixes an issue with GetFiles where using any search pattern would be significantly slower than fetching every file and filtering.");
29+
FileOpOptimize = Config.Bind("General", "Optimize File Operations", true, "Same functionality as ModMenuAccel or WSQO. It speeds up various file operations that were slow and had room for improvement.");
30+
31+
_harmony = Harmony.CreateAndPatchAll(typeof(StartupOptimize));
32+
if (FileOpOptimize.Value)
33+
{
34+
_harmony.PatchAll(typeof(FileOpOptimize));
35+
}
36+
37+
if (GetFileFilterFix.Value)
38+
{
39+
_harmony.PatchAll(typeof(GetFilesFix));
40+
}
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)