Skip to content

Commit

Permalink
New mod (I guess?)
Browse files Browse the repository at this point in the history
  • Loading branch information
gompocp committed Aug 22, 2021
1 parent cfbefe9 commit ba9bd6c
Show file tree
Hide file tree
Showing 11 changed files with 221 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### UpdateChecker v1.0.0
- Initial release

### StandaloneThirdPerson v1.2.0
- Added a freeform camera (You can thank [ljoonal](https://github.com/ljoonal/) for that)

Expand Down
Binary file added ILRepack/ILRepack.Lib.MSBuild.Task.dll
Binary file not shown.
42 changes: 42 additions & 0 deletions ILRepack/ILRepack.Lib.MSBuild.Task.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(ProjectDir)ILRepack.Config.props" Condition="Exists('$(ProjectDir)ILRepack.Config.props')" />
<Choose>
<When Condition="'$(ILRepackTargetsFile)' == ''">
<PropertyGroup>
<ILRepackTargetsFile>$(ProjectDir)ILRepack.targets</ILRepackTargetsFile>
</PropertyGroup>
</When>
</Choose>
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)ILRepack.Lib.MSBuild.Task.dll" TaskName="ILRepack" />
<Import Project="$(ILRepackTargetsFile)" Condition="Exists('$(ILRepackTargetsFile)')" />
<Target Name="ILRepack" AfterTargets="Build" Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)')">
<ItemGroup>
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/>
<InputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/>
</ItemGroup>

<ILRepack
Parallel="true"
DebugInfo="true"
AllowDuplicateResources="false"
InputAssemblies="@(InputAssemblies)"
TargetKind="SameAsPrimaryAssembly"
KeyFile="$(KeyFile)"
OutputFile="$(OutputPath)$(TargetName)$(TargetExt)"
/>
</Target>
<Target
AfterTargets="ILRepack"
Name="CleanReferenceCopyLocalPaths"
Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)') and '$(ClearOutputDirectory)' != 'False'">
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
<ItemGroup>
<Directories Include="$([System.IO.Directory]::GetDirectories('$(OutDir)%(DestinationSubDirectory)', '*', System.IO.SearchOption.AllDirectories))" />
<Directories>
<Files>$([System.IO.Directory]::GetFiles("%(Directories.Identity)", "*", System.IO.SearchOption.AllDirectories).get_Length())</Files>
</Directories>
</ItemGroup>
<RemoveDir Directories="@(Directories)" Condition="%(Files)=='0'" />
</Target>
</Project>
Binary file added ILRepack/ILRepack.dll
Binary file not shown.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Modding the VRChat client is against VRChat's Terms of Service. Therefore use th
- [ActionMenuApi](#actionmenuapi)
- [ActionMenuUtils](#actionmenuutils)
- [StandaloneThirdPerson](#standalonethirdperson)
- [UpdateChecker](#updatechecker)
- [WorldPredownload](#worldpredownload)

## Canny Posts
Expand All @@ -27,6 +28,12 @@ To Build simply:
3. Inside `Directory.Build.props` edit the path inside `<VRChatFolder>` to the path of your own game install
4. Build Solution


### ILRepack
A copy of [ILRepack.Lib.MSBuild.Task](https://github.com/ravibpatel/ILRepack.Lib.MSBuild.Task) and [ILRepack](https://github.com/gluck/il-repack) are included in the repo to build the solution



## ActionMenuApi

This mod doesn't do anything on it's own.
Expand Down Expand Up @@ -88,6 +95,19 @@ More information [here](https://github.com/gompocp/ActionMenuApi)
- Credit to [ljoonal](https://github.com/ljoonal/) some of the math is loosely based off of their [third person mod for cvr](https://github.com/ljoonal/CVR-Mods/blob/main/ThirdPersonCamera/ThirdPersonCamera.cs)
- Some acknowledgement needs to be given to [emmVRC](https://github.com/emmVRC/) as they are the people that originally (afaik ¯\\\_(ツ)_/¯ ) had a third person mod for vrchat

## UpdateChecker

- Simple mod for people who dislike auto updaters
- Checks for mod updates and lets you know in the console
- Only works for mods that follow the semver format

### Preview
![Console Preview](https://i.imgur.com/s3BP2qf.png)

### Acknowledgements

- Some code was used from [Slaynash](https://github.com/Slaynash/VRCModUpdater/blob/main/Core/VRCModUpdaterCore.cs)

## WorldPredownload

- You can hit preload on an invite, on a world page or on a friend user page
Expand Down
96 changes: 96 additions & 0 deletions UpdateChecker/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Net;
using MelonLoader;
using Newtonsoft.Json;
using Semver;
using Main = UpdateChecker.Main;

[assembly: MelonGame("VRChat", "VRChat")]
[assembly: MelonInfo(typeof(Main), "UpdateChecker", "1.0.0", "gompo", "https://github.com/gompocp/VRChatMods/releases/")]
[assembly: MelonColor(ConsoleColor.Magenta)]

namespace UpdateChecker
{
public partial class Main : MelonMod
{
public override void OnApplicationStart()
{
// Api fetching code comes from: https://github.com/Slaynash/VRCModUpdater/blob/main/Core/VRCModUpdaterCore.cs
string apiResponse;
using var client = new WebClient
{
Headers = {["User-Agent"] = "UpdateChecker"}
};
apiResponse = client.DownloadString("https://api.vrcmg.com/v0/mods.json");
if (string.IsNullOrEmpty(apiResponse))
{
MelonLogger.Error("Failed to contact api");
return;
}
List<Mod> mods = JsonConvert.DeserializeObject<List<Mod>>(apiResponse);

if (mods == null || mods.Count == 0)
{
MelonLogger.Error("Didn't receive any mods from the api");
return;
}

Dictionary<string, ModVersion> workingModsLookUpTable = new Dictionary<string, ModVersion>();
Dictionary<string, ModVersion> brokenModsLookUpTable = new Dictionary<string, ModVersion>();

foreach (var mod in mods)
{
if(mod.versions.Count == 0) continue;
var modVersion = mod.versions[0];
try
{
modVersion.SemVersion = SemVersion.Parse(modVersion.modversion);
}
catch (ArgumentException)
{
}
foreach (var alias in mod.aliases)
{
if(modVersion.ApprovalStatus == 2)
brokenModsLookUpTable.Add(alias, modVersion);
else if(modVersion.ApprovalStatus == 1)
workingModsLookUpTable.Add(alias, modVersion);
}
}

foreach (var melonmod in MelonHandler.Mods)
{
try
{
SemVersion semVersion = SemVersion.Parse(melonmod.Info.Version);
if (workingModsLookUpTable.ContainsKey(melonmod.Info.Name))
{
var latestVersion = workingModsLookUpTable[melonmod.Info.Name];
if (latestVersion.SemVersion == null)
{
throw new ArgumentException();
}
if (semVersion < latestVersion.SemVersion)
{
MelonLogger.Msg(ConsoleColor.Green,$"Mod {melonmod.Info.Name} by {melonmod.Info.Author} is out of date. {melonmod.Info.Version} --> {latestVersion.modversion}");
}
}
else if (brokenModsLookUpTable.ContainsKey(melonmod.Info.Name))
{
MelonLogger.Msg(ConsoleColor.Yellow,$"Running currently broken mod: {melonmod.Info.Name} by {melonmod.Info.Author}");
}
else if (!melonmod.Info.Name.Equals("UpdateChecker"))
{
MelonLogger.Msg(ConsoleColor.Blue,$"Running unknown mod: {melonmod.Info.Name} by {melonmod.Info.Author}");
}

}
catch(ArgumentException)
{
MelonLogger.Msg(ConsoleColor.Red,$"MelonMod {melonmod.Info.Name} isn't following semver. Skipping...");
}
}
}
}
}
10 changes: 10 additions & 0 deletions UpdateChecker/Mod.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace UpdateChecker
{
public class Mod
{
public List<string> aliases;
public List<ModVersion> versions;
}
}
13 changes: 13 additions & 0 deletions UpdateChecker/ModVersion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Semver;

namespace UpdateChecker
{
public class ModVersion
{
public string name;
public string modversion;
public SemVersion SemVersion;
public string downloadlink;
public int ApprovalStatus;
}
}
31 changes: 31 additions & 0 deletions UpdateChecker/UpdateChecker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<VrcReferences>true</VrcReferences>
<Version>1.0.0.0</Version>
<LangVersion>9</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="semver" Version="2.0.6" />
</ItemGroup>
<Import Project="$(MsBuildThisFileDirectory)/../ILRepack/ILRepack.Lib.MSBuild.Task.targets" />

<Target Name="ILRepack" AfterTargets="Build">
<PropertyGroup>
<WorkingDirectory>$(OutputPath)</WorkingDirectory>
</PropertyGroup>
<ItemGroup>
<InputAssemblies Include="$(OutputPath)/$(AssemblyName).dll" />
<InputAssemblies Include="$(OutputPath)/Semver.dll" />
<IlRepackLibs Include="$(OutputPath)" />
<IlRepackLibs Include="$(MelonManaged)" />
<IlRepackLibs Include="$(MelonLoader)" />
</ItemGroup>
<Message Text="MERGING: @(InputAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" />
<ILRepack Internalize="true" LibraryPath="@(IlRepackLibs)" OutputFile="$(OutputPath)/$(AssemblyName).dll" InputAssemblies="@(InputAssemblies)" />
</Target>
<Target Name="PostBuildCopy" AfterTargets="ILRepack">
<Exec Command="xcopy /c /f /y $(OutputPath)\$(AssemblyName).dll $(VRChatFolder)\Mods" />
</Target>
</Project>
6 changes: 6 additions & 0 deletions VRChatMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrityCheckGenerator", "
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StandaloneThirdPerson", "StandaloneThirdPerson\StandaloneThirdPerson.csproj", "{A5F07D37-CAB2-43C7-98AF-F8184CC71DA1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UpdateChecker", "UpdateChecker\UpdateChecker.csproj", "{2D0C38BE-2E7A-4E10-A066-9397D319EC4E}"
EndProject

Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -48,5 +50,9 @@ Global
{A5F07D37-CAB2-43C7-98AF-F8184CC71DA1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5F07D37-CAB2-43C7-98AF-F8184CC71DA1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5F07D37-CAB2-43C7-98AF-F8184CC71DA1}.Release|Any CPU.Build.0 = Release|Any CPU
{2D0C38BE-2E7A-4E10-A066-9397D319EC4E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2D0C38BE-2E7A-4E10-A066-9397D319EC4E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2D0C38BE-2E7A-4E10-A066-9397D319EC4E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2D0C38BE-2E7A-4E10-A066-9397D319EC4E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
2 changes: 0 additions & 2 deletions WorldPredownload/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
using InfoType = VRC.UI.PageUserInfo.EnumNPublicSealedvaNoOnOfSeReBlInFa10Unique;
using ListType = UiUserList.EnumNPublicSealedvaNoInFrOnOfSeInFa9vUnique;

//using OnDownloadComplete = AssetBundleDownloadManager.MulticastDelegateNInternalSealedVoObUnique;

namespace WorldPredownload
{
[HarmonyPatch(typeof(NetworkManager), "OnLeftRoom")]
Expand Down

0 comments on commit ba9bd6c

Please sign in to comment.