Skip to content

Commit

Permalink
add check for dotnet folder, other minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
whichtwix committed Oct 27, 2022
1 parent 2f06966 commit c752309
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Modinstaller
![GitHub all releases](https://img.shields.io/github/downloads/whichtwix/Modinstaller/total?color=%20%2332CD32&style=plastic)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/whichtwix/Modinstaller?style=plastic)
# :hammer_and_wrench:Modinstaller
A small application that installs the Among Us mod [town of us](https://github.com/eDonnes124/Town-Of-Us-R) with minimal user interaction. Making manual to automatic

## Why this over [ModManager](https://github.com/MatuxGG/ModManager) and the ingame updater already present?
## :grey_question:Why this over [ModManager](https://github.com/MatuxGG/ModManager) and the ingame updater already present?
- ModManager requires setup before you can install your mods - here you can get right in
- Issues such as with sign in and conflicts with mod's ingame updater have been noted to arise with ModManager
- You have to put in more work navigating through more menus with ModManager
- Comparing to the updater, you dont have to open the game, update the mod, and restart the game - the exe is ultimately faster
- The updater is rendered unusable with mod updates aimed at new among us versions and a manual installation would have to be done anyway

## How it works
## :gear:How it works
- A user inputs the file path to the folder to install the mod - this is the only thing they have to do
- The program fetches the latest download link and version number from the github repo's API
- The zip is downloaded, extracted, and contents are set up in the folder without further input
Expand Down
1 change: 1 addition & 0 deletions src/Downloader.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>Net6</TargetFramework>
<Version>2.0.0</Version>
<DebugType>embedded</DebugType>
<LangVersion>latest</LangVersion>
<OutputType>Exe</OutputType>
Expand Down
28 changes: 18 additions & 10 deletions src/code/Downloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,30 @@

namespace Modinstaller
{
public class Modinstaller
public sealed class Modinstaller
{
public const string url = "https://api.github.com/repos/eDonnes124/Town-Of-Us-R/releases/latest";
public static string path;

public static string Touversion;
public static HttpClient client = new HttpClient();

public static HttpClient client = new();

public static async Task Main(string[] args)
{
bool acceptedpath = false;
string path = string.Empty;
while (acceptedpath != true)
{
Console.WriteLine("What is the path of your Amogus?:");
path = Console.ReadLine();
if (File.Exists(path + "\\Among Us.exe")) acceptedpath = true;
if (Directory.Exists(path + "\\Among Us_Data")) acceptedpath = true;
else Console.WriteLine($"the path '{path}' is not valid; vanilla files could not be found");
}
Console.WriteLine("Downloading town of us");
await Handlezip(path);
Movefiles(path, Touversion);
Movefiles(path, Touversion);
}

public static async Task Handlezip(string path)
{
try
Expand Down Expand Up @@ -57,26 +62,29 @@ public static async Task Handlezip(string path)
Console.WriteLine("Error in Handlezip()");
Console.WriteLine(e);
Console.ReadLine();

}
}

public static void Movefiles(string path, string version)
{
try
{
if (Directory.Exists(path + "\\BepInEx")) Directory.Delete(path + "\\BepInEx", true);
if (Directory.Exists(path + "\\mono")) Directory.Delete(path + "\\mono", true);
//this check will be phased out once the penultimate latest update doesnt use mono
if (Directory.Exists(path + "\\mono")) Directory.Delete(path + "\\mono", true);
if (Directory.Exists(path + "\\dotnet")) Directory.Delete(path + "\\dotnet", true);

string subfolder = $@"{path}" + $"\\ToU {version}";
string[] files = Directory.GetFiles(subfolder);
foreach (string file in files)
{
File.Move($@"{file}", $@"{path}" + $"\\{file.Substring(subfolder.Length + 1)}", true);
}

string[] movablefolders = Directory.GetDirectories(subfolder);
foreach (string moving in movablefolders)
foreach (string folder in movablefolders)
{
Directory.Move($@"{moving}", $@"{path}" + $"\\{moving.Substring(subfolder.Length + 1)}");
Directory.Move($@"{folder}", $@"{path}" + $"\\{folder.Substring(subfolder.Length + 1)}");
}

Directory.Delete(subfolder);
Expand Down
2 changes: 1 addition & 1 deletion src/code/Json.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Modinstaller
{
public class Json
public sealed class Json
{
public string Name { get; set; }
public List<Assets> Assets { get; set; }
Expand Down

0 comments on commit c752309

Please sign in to comment.