-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
149 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("MapRandomizer.Properties")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("MapRandomizer.Properties")] | ||
[assembly: AssemblyCopyright("Copyright © 2021")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("6e265fda-e382-411d-95b2-c04aedf0a042")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
[assembly: AssemblyVersion("1.0.0.5")] | ||
[assembly: AssemblyFileVersion("1.0.0.5")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.IO; | ||
|
||
namespace MapRandomizer | ||
{ | ||
class Logger | ||
{ | ||
private static StreamWriter logStreamWriter; | ||
private bool enableLogging = false; | ||
|
||
public Logger(string modDir, string fileName, bool enableLogging) | ||
{ | ||
string filePath = Path.Combine(modDir, $"{fileName}.log"); | ||
if (File.Exists(filePath)) | ||
{ | ||
File.Delete(filePath); | ||
} | ||
|
||
logStreamWriter = File.AppendText(filePath); | ||
logStreamWriter.AutoFlush = true; | ||
|
||
this.enableLogging = enableLogging; | ||
} | ||
|
||
public void LogMessage(string message) | ||
{ | ||
if (enableLogging) | ||
{ | ||
string ts = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture); | ||
logStreamWriter.WriteLine($"INFO: {ts} - {message}"); | ||
} | ||
} | ||
|
||
|
||
public void LogError(string message) | ||
{ | ||
string ts = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture); | ||
logStreamWriter.WriteLine($"ERROR: {ts} - {message}"); | ||
} | ||
|
||
public void LogException(Exception exception) | ||
{ | ||
string ts = DateTime.UtcNow.ToString("s", System.Globalization.CultureInfo.InvariantCulture); | ||
logStreamWriter.WriteLine($"CRITICAL: {ts} - {exception}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,42 @@ | ||
using Harmony; | ||
using System; | ||
using System.IO; | ||
using Harmony; | ||
using System.Reflection; | ||
using Newtonsoft.Json; | ||
|
||
namespace MapRandomizer | ||
{ | ||
|
||
public static class Mod | ||
public static class ModInit | ||
{ | ||
internal static Logger modLog; | ||
internal static string modDir; | ||
internal static Settings modSettings; | ||
public const string HarmonyPackage = "us.tbone.MapRandomizer"; | ||
public static void Init(string directory, string settingsJSON) | ||
{ | ||
modDir = directory; | ||
modLog = new Logger(modDir, "MapRandomizer", true); | ||
try | ||
{ | ||
ModInit.modSettings = JsonConvert.DeserializeObject<Settings>(settingsJSON); | ||
|
||
} | ||
catch (Exception ex) | ||
{ | ||
ModInit.modLog.LogException(ex); | ||
ModInit.modSettings = new Settings(); | ||
} | ||
|
||
|
||
ModInit.modLog.LogMessage($"Initializing PracticeMakesPerfect - Version {typeof(Settings).Assembly.GetName().Version}"); | ||
var harmony = HarmonyInstance.Create(HarmonyPackage); | ||
harmony.PatchAll(Assembly.GetExecutingAssembly()); | ||
} | ||
|
||
} | ||
} | ||
class Settings | ||
{ | ||
public bool enableLogging = true; | ||
public bool enableTravelFix = true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
MapRandomizer/MapRandomizer/source/Properties/AssemblyInfo.cs
This file was deleted.
Oops, something went wrong.