This commit is contained in:
Alex
2025-01-12 21:44:30 +00:00
parent c479e6aaf1
commit d85bd6c315
24 changed files with 286 additions and 134 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ using Core.Utils;
namespace Core.Callbacks;
[Injectable(InjectableTypeOverride = typeof(OnUpdate), TypePriority = OnUpdateOrder.DialogCallbacks)]
[Injectable(InjectableTypeOverride = typeof(OnUpdate), TypePriority = OnUpdateOrder.DialogueCallbacks)]
[Injectable(InjectableTypeOverride = typeof(DialogueCallbacks))]
public class DialogueCallbacks : OnUpdate
{
-53
View File
@@ -1,53 +0,0 @@
using Core.Annotations;
using Core.DI;
using Core.Models.Enums;
using Core.Models.Spt.Config;
using Core.Servers;
using Core.Services;
using Core.Utils;
using ILogger = Core.Models.Utils.ILogger;
namespace Core.Callbacks;
[Injectable(InjectableTypeOverride = typeof(OnLoad), TypePriority = OnLoadOrder.ModCallbacks)]
public class ModCallbacks : OnLoad
{
protected ILogger _logger;
protected HttpResponseUtil _httpResponseUtil;
protected HttpFileUtil _httpFileUtil;
// protected PostSptModLoader _postSptModLoader; TODO: needs to be implemented
protected LocalisationService _localisationService;
protected ConfigServer _configServer;
protected HttpConfig _httpConfig;
public ModCallbacks
(
ILogger logger,
HttpResponseUtil httpResponseUtil,
HttpFileUtil httpFileUtil,
LocalisationService localisationService,
ConfigServer configServer
)
{
_logger = logger;
_httpResponseUtil = httpResponseUtil;
_httpFileUtil = httpFileUtil;
_localisationService = localisationService;
_configServer = configServer;
_httpConfig = configServer.GetConfig<HttpConfig>(ConfigTypes.HTTP);
}
public async Task OnLoad()
{
// if (ProgramStatics.MODS) {
// await this.postSptModLoader.load();
// } TODO: needs to be implemented
return;
}
public string GetRoute()
{
return "spt-mods";
}
}
+3 -4
View File
@@ -24,9 +24,10 @@ public class ClientLogController
public void ClientLog(ClientLogRequest logRequest)
{
var message = $"[{logRequest.Source}] {logRequest.Message}";
/* TODO: what do we do with this?
var color = logRequest.Color ?? LogTextColor.White;
var backgroundColor = logRequest.BackgroundColor ?? LogBackgroundColor.Default;
*/
// Allow supporting either string or enum levels
// Required due to the C# modules serializing enums as their name
@@ -40,13 +41,11 @@ public class ClientLogController
this._logger.Warning(message);
break;
case LogLevel.SUCCESS:
this._logger.Success(message);
break;
case LogLevel.INFO:
this._logger.Info(message);
break;
case LogLevel.CUSTOM:
this._logger.Log(message, color.ToString(), backgroundColor.ToString());
this._logger.Info(message/* TODO: , color.ToString(), backgroundColor.ToString()*/);
break;
case LogLevel.DEBUG:
this._logger.Debug(message);
+1 -1
View File
@@ -135,7 +135,7 @@ public class GameController
// flag as migrated
fullProfile.SptData.Migrations.Add("39x", _timeUtil.GetTimeStamp());
_logger.Success($"Migration of 3.9.x profile: {fullProfile.ProfileInfo.Username} completed successfully");
_logger.Info($"Migration of 3.9.x profile: {fullProfile.ProfileInfo.Username} completed successfully");
}
// with our method of converting type from array for this prop, we *might* not need this?
+10 -10
View File
@@ -3,14 +3,14 @@ namespace Core.DI;
public static class OnLoadOrder
{
public const int Database = 0;
public const int PostDBModLoader = 1;
public const int HandbookCallbacks = 2;
public const int HttpCallbacks = 3;
public const int PresetCallbacks = 4;
public const int SaveCallbacks = 5;
public const int TraderCallbacks = 6;
public const int RagfairPriceService = 7;
public const int RagfairCallbacks = 8;
public const int ModCallbacks = 9;
public const int GameCallbacks = 10;
public const int GameCallbacks = 100;
public const int PostDBModLoader = 200;
public const int HandbookCallbacks = 300;
public const int HttpCallbacks = 400;
public const int SaveCallbacks = 500;
public const int TraderCallbacks = 600;
public const int PostSptModLoader = 700;
public const int PresetCallbacks = 800;
public const int RagfairPriceService = 900;
public const int RagfairCallbacks = 1000;
}
+6 -6
View File
@@ -2,10 +2,10 @@ namespace Core.DI;
public static class OnUpdateOrder
{
public const int DialogCallbacks = 0;
public const int HideoutCallbacks = 1;
public const int TraderCallbacks = 2;
public const int RagfairCallbacks = 3;
public const int InsuranceCallbacks = 4;
public const int SaveCallbacks = 5;
public const int DialogueCallbacks = 0;
public const int HideoutCallbacks = 100;
public const int TraderCallbacks = 200;
public const int RagfairCallbacks = 300;
public const int InsuranceCallbacks = 400;
public const int SaveCallbacks = 500;
}
+37
View File
@@ -0,0 +1,37 @@
using Core.Annotations;
using Core.DI;
using Core.Models.External;
using ILogger = Core.Models.Utils.ILogger;
namespace Core.Loaders;
[Injectable(InjectableTypeOverride = typeof(OnLoad), TypePriority = OnLoadOrder.PostDBModLoader)]
public class PostDBModLoader : OnLoad
{
private readonly ILogger _logger;
private readonly IEnumerable<IPostDBLoadMod> _postDbLoadMods;
public PostDBModLoader(
ILogger logger,
IEnumerable<IPostDBLoadMod> postDbLoadMods
)
{
_logger = logger;
_postDbLoadMods = postDbLoadMods;
}
public async Task OnLoad()
{
_logger.Info("Loading PostDBLoadMod...");
foreach (var postDbLoadMod in _postDbLoadMods)
{
postDbLoadMod.PostDBLoad();
}
_logger.Info("Finished loading PostDBLoadMod...");
}
public string GetRoute()
{
return "spt-post-db-mods";
}
}
+40
View File
@@ -0,0 +1,40 @@
using Core.Annotations;
using Core.DI;
using Core.Models.External;
using ILogger = Core.Models.Utils.ILogger;
namespace Core.Loaders;
[Injectable(InjectableTypeOverride = typeof(OnLoad), TypePriority = OnLoadOrder.PostSptModLoader)]
public class PostSptModLoader : OnLoad
{
private readonly ILogger _logger;
private readonly IEnumerable<IPostSptLoadMod> _postSptLoadMods;
public PostSptModLoader(
ILogger logger,
IEnumerable<IPostSptLoadMod> postSptLoadMods
)
{
_logger = logger;
_postSptLoadMods = postSptLoadMods;
}
public async Task OnLoad()
{
// if (ProgramStatics.MODS) {
// await this.postSptModLoader.load();
// } TODO: needs to be implemented
_logger.Info("Loading PostSptMods...");
foreach (var postSptLoadMod in _postSptLoadMods)
{
postSptLoadMod.PostSptLoad();
}
_logger.Info("Finished loading PostSptMods...");
}
public string GetRoute()
{
return "spt-post-spt-mods";
}
}
+9 -10
View File
@@ -2,13 +2,12 @@
public enum LogBackgroundColor
{
Default,
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White
}
Black = 40,
Red = 41,
Green = 42,
Yellow = 43,
Blue = 44,
Magenta = 45,
Cyan = 46,
White = 47
}
+9 -10
View File
@@ -2,13 +2,12 @@
public enum LogTextColor
{
Black,
Red,
Green,
Yellow,
Blue,
Magenta,
Cyan,
White,
Gray
}
Black = 30,
Red = 31,
Green = 32,
Yellow = 33,
Blue = 34,
Magenta = 35,
Cyan = 36,
White = 37
}
+7 -6
View File
@@ -4,12 +4,13 @@ namespace Core.Models.Utils;
public interface ILogger
{
void WriteToLogFile(string data);
void Log(string data, string color, string? backgroundColor = null);
void LogWithColor(string data, LogTextColor textColor, LogBackgroundColor? backgroundColor = null);
// TODO: Removing these 4 methods for now, revisit in the future
// void WriteToLogFile(string data);
// void Log(string data, LogTextColor? color, string? backgroundColor = null);
// void LogWithColor(string data, LogTextColor textColor, LogBackgroundColor? backgroundColor = null);
// void Success(string data);
void Error(string data);
void Warning(string data);
void Success(string data);
void Info(string data);
void Debug(string data, bool? onlyShowInConsole = null);
}
void Debug(string data);
}
+1 -1
View File
@@ -82,7 +82,7 @@ public class SptHttpListener : IHttpListener
}
if (!requestIsCompressed) {
_logger.Debug(value, true);
_logger.Debug(value);
}
var response = GetResponse(sessionId, req, value);
+1 -1
View File
@@ -106,7 +106,7 @@ public class SaveServer
totalTime += SaveProfile(sessionID.Key);
}
_logger.Debug($"Saved {profiles.Count} profiles, took: {totalTime}ms", false);
_logger.Debug($"Saved {profiles.Count} profiles, took: {totalTime}ms");
}
/**
+1 -1
View File
@@ -7,7 +7,7 @@ public class PostDbLoadService
{
public void PerformPostDbLoadActions()
{
throw new NotImplementedException();
// TODO:
}
protected void AdjustMinReserveRaiderSpawnChance()
+2 -1
View File
@@ -21,7 +21,8 @@ public class JsonUtil
new EftEnumConverter<SptAirdropTypeEnum>(),
new EftEnumConverter<GiftSenderType>(),
new EftEnumConverter<SeasonalEventType>(),
new EftEnumConverter<ProfileChangeEventType>()
new EftEnumConverter<ProfileChangeEventType>(),
new EftEnumConverter<QuestStatusEnum>()
}
};
private static readonly JsonSerializerOptions jsonSerializerOptionsIndented = new(jsonSerializerOptionsNoIndent)
+4 -24
View File
@@ -4,24 +4,9 @@ using ILogger = Core.Models.Utils.ILogger;
namespace Core.Utils.Logging;
[Injectable(InjectionType.Singleton)]
// [Injectable(InjectionType.Singleton)]
public class SimpleTextLogger : ILogger
{
// TODO: for now we simplify the logger into this barebones console writer
public void WriteToLogFile(string data)
{
Console.WriteLine(data);
}
public void Log(string data, string color, string? backgroundColor = null)
{
Console.WriteLine(data);
}
public void LogWithColor(string data, LogTextColor textColor, LogBackgroundColor? backgroundColor = null)
{
Console.WriteLine(data);
}
public void Error(string data)
{
@@ -32,19 +17,14 @@ public class SimpleTextLogger : ILogger
{
Console.WriteLine(data);
}
public void Success(string data)
{
Console.WriteLine(data);
}
public void Info(string data)
{
Console.WriteLine(data);
}
public void Debug(string data, bool? onlyShowInConsole = null)
public void Debug(string data)
{
Console.WriteLine(data);
}
}
}
+1 -1
View File
@@ -182,7 +182,7 @@ public class Watermark {
// Log watermark to screen
foreach (var text in result) {
_logger.LogWithColor(text, LogTextColor.Yellow);
_logger.Warning(text);
}
}
}