Add startup console info & version check,
This commit is contained in:
parent
a8890bde6a
commit
17f26a1458
5 changed files with 197 additions and 3 deletions
|
|
@ -8,6 +8,7 @@ using src.player;
|
|||
using src.utils;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using WASDSharedAPI;
|
||||
using static CounterStrikeSharp.API.Core.Listeners;
|
||||
|
||||
|
|
@ -27,7 +28,7 @@ namespace src
|
|||
public override string ModuleName => "[CS2] [ jRandomSkills ]";
|
||||
public override string ModuleAuthor => "D3X, Juzlus";
|
||||
public override string ModuleDescription => "Plugin adds random skills every round for CS2 by D3X. Modified by Juzlus.";
|
||||
public override string ModuleVersion => "1.2.1";
|
||||
public override string ModuleVersion => "1.2.1.b3";
|
||||
|
||||
public override void Load(bool hotReload)
|
||||
{
|
||||
|
|
@ -44,6 +45,12 @@ namespace src
|
|||
LoadAllSkills();
|
||||
|
||||
Instance.RegisterListener<OnServerPrecacheResources>(LoadManifest);
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
await Task.Delay(3500);
|
||||
PrintInfoToConsole();
|
||||
});
|
||||
}
|
||||
|
||||
internal void AddToManifest(string prop)
|
||||
|
|
@ -108,6 +115,170 @@ namespace src
|
|||
|
||||
public uint[] footstepSoundEvents = [3109879199, 70939233, 1342713723, 2722081556, 1909915699, 3193435079, 2300993891, 3847761506, 4084367249, 1342713723, 3847761506, 2026488395, 2745524735, 2684452812, 2265091453, 1269567645, 520432428, 3266483468, 1346129716, 2061955732, 2240518199, 2829617974, 1194677450, 1803111098, 3749333696, 29217150, 1692050905, 2207486967, 2633527058, 3342414459, 988265811, 540697918, 1763490157, 3755338324, 3161194970, 3753692454, 3166948458, 3997353267, 3161194970, 3753692454, 3166948458, 3997353267, 809738584, 3368720745, 3295206520, 3184465677, 123085364, 3123711576, 737696412, 1403457606, 1770765328, 892882552, 3023174225, 4163677892, 3952104171, 4082928848, 1019414932, 1485322532, 1161855519, 1557420499, 1163426340, 809738584, 3368720745, 2708661994, 2479376962, 3295206520, 1404198078, 1194093029, 1253503839, 2189706910, 1218015996, 96240187, 1116700262, 84876002, 1598540856, 2231399653];
|
||||
public uint[] silentSoundEvents = [2551626319, 765706800, 765706800, 2860219006, 2162652424, 2551626319, 2162652424, 117596568, 117596568, 740474905, 1661204257, 3009312615, 1506215040, 115843229, 3299941720, 1016523349, 2684452812, 2067683805, 2067683805, 1016523349, 4160462271, 1543118744, 585390608, 3802757032, 2302139631, 2546391140, 144629619, 4152012084, 4113422219, 1627020521, 2899365092, 819435812, 3218103073, 961838155, 1535891875, 1826799645, 3460445620, 1818046345, 3666896632, 3099536373, 1440734007, 1409986305, 1939055066, 782454593, 4074593561, 1540837791, 3257325156];
|
||||
|
||||
private static async void PrintInfoToConsole()
|
||||
{
|
||||
string? versionFromGithub = await GetLatestVersion();
|
||||
var diffrentConfig = JsonSerializer.Serialize(Config.LoadedConfig) != JsonSerializer.Serialize(new Config.SettingsModel());
|
||||
var diffrentSkillsInfo = JsonSerializer.Serialize(SkillsInfo.LoadedConfig) != JsonSerializer.Serialize(new SkillsInfo.SkillsInfoModel());
|
||||
|
||||
// Top border
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Magenta;
|
||||
Console.WriteLine($"\n************************************************************************************************************\n");
|
||||
|
||||
// ASCII tag
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.WriteLine(" || '||''|. '|| .|'''.| '|| || '|| '|| \r\n ... || || .... .. ... .. || ... .. .. .. ||.. ' || .. ... || || .... \r\n || ||''|' '' .|| || || .' '|| .| '|. || || || ''|||. || .' || || || ||. ' \r\n || || |. .|' || || || |. || || || || || || . '|| ||'|. || || || . '|.. \r\n || .||. '|' '|..'|' .||. ||. '|..'||. '|..|' .|| || ||. |'....|' .||. ||. .||. .||. .||. |'..|' \r\n .. |' \r\n '' ");
|
||||
|
||||
// Version info
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write($"\njRandomSkills ");
|
||||
|
||||
if (versionFromGithub == null)
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Yellow;
|
||||
Console.Write($"v{Instance.ModuleVersion} (failed to get version from github)");
|
||||
}
|
||||
else if (versionFromGithub == Instance.ModuleVersion)
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Green;
|
||||
Console.Write($"v{Instance.ModuleVersion} (latest version)");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Red;
|
||||
Console.Write($"v{Instance.ModuleVersion} (new version {versionFromGithub} detected)");
|
||||
}
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.WriteLine($" ({SkillData.Skills.Count - 1}/{SkillsInfo.LoadedConfig.Count - 1} Skills) loaded!");
|
||||
|
||||
if (versionFromGithub != null && versionFromGithub != Instance.ModuleVersion)
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Red;
|
||||
Console.WriteLine($"\n#########################################################");
|
||||
Console.WriteLine($"# Download the new version from: #");
|
||||
Console.WriteLine($"# https://github.com/Juzlus/jRandomSkills/releases #");
|
||||
Console.WriteLine($"#########################################################");
|
||||
}
|
||||
|
||||
// Config preset
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write("\nConfig preset: ");
|
||||
Console.ForegroundColor = Config.LoadedConfig.ConfigName == "Default" && diffrentConfig ? (ConsoleColor)CS2ConsoleColors.Yellow : (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.Write($"{(Config.LoadedConfig.ConfigName == "Default" && diffrentConfig ? "(CUSTOM)" : Config.LoadedConfig.ConfigName)}");
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write("\nSkillsInfo preset: ");
|
||||
Console.ForegroundColor = SkillsInfo.LoadedConfig.Name == "Default" && diffrentSkillsInfo ? (ConsoleColor)CS2ConsoleColors.Yellow : (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.WriteLine($"{(SkillsInfo.LoadedConfig.Name == "Default" && diffrentSkillsInfo ? "(CUSTOM)" : SkillsInfo.LoadedConfig.Name)}");
|
||||
|
||||
// Main config info
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write("\nGameMode: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.Write($"{(Config.GameModes)Config.LoadedConfig.GameMode} ({Config.LoadedConfig.GameMode})");
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write(", Lang: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.Write(Config.LoadedConfig.LanguageSystem.DefaultLangCode);
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write(", DebugMode: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.WriteLine(Config.LoadedConfig.DebugMode);
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write("SkillHudDuration: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.Write(Config.LoadedConfig.SkillHudDuration == -1 ? "infinity" : Config.LoadedConfig.SkillHudDuration);
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write(", SkillButton: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.Write(Config.LoadedConfig.AlternativeSkillButton);
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.Write(", HtmlHudFix: ");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightBlue;
|
||||
Console.WriteLine(Config.LoadedConfig.FlashingHtmlHudFix);
|
||||
|
||||
// Dependences
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.WriteLine($"\nDependences:");
|
||||
var files = new Dictionary<string, string> {
|
||||
{ "Newtonsoft Json", "./Newtonsoft.Json.dll" },
|
||||
{ "WASDMenuAPI", "./WASDMenuAPI.dll" },
|
||||
{ "MaxMind", "./MaxMind.Db.dll" },
|
||||
{ "GeoLite2", "./packages/GeoLite2-Country.mmdb" },
|
||||
{ "CS2TraceRay", "./../../shared/CS2TraceRay/CS2TraceRay.dll" },
|
||||
{ "CS2TraceRay gamedata", "./../../gamedata/CS2TraceRay.gamedata.json" },
|
||||
{ "jRandomSkills gamedata", "./../../gamedata/jRandomSkills.gamedata.json" }
|
||||
};
|
||||
|
||||
foreach (var fileInfo in files)
|
||||
{
|
||||
string fullPath = Path.GetFullPath(Path.Combine(Instance.ModuleDirectory, fileInfo.Value));
|
||||
if (File.Exists(fullPath))
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Green3;
|
||||
Console.WriteLine($"- {fileInfo.Key} [OK]");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.LightRed;
|
||||
Console.WriteLine($"- {fileInfo.Key} (Missing: {fileInfo.Value})");
|
||||
}
|
||||
}
|
||||
|
||||
// Skills info
|
||||
List<Skills> enabled = [];
|
||||
List<Skills> disabled = [];
|
||||
|
||||
foreach (Skills skill in Enum.GetValues(typeof(Skills)))
|
||||
if (skill.ToString() == "None")
|
||||
continue;
|
||||
else if (SkillsInfo.GetValue<bool>(skill, "active"))
|
||||
enabled.Add(skill);
|
||||
else
|
||||
disabled.Add(skill);
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.WriteLine($"\nEnabled skills ({enabled.Count}):");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Green;
|
||||
Console.WriteLine(" " + string.Join("\n ", enabled.Chunk(10).Select(group => string.Join(", ", group))));
|
||||
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Cyan;
|
||||
Console.WriteLine($"\nDisabled skills ({disabled.Count}):");
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Red;
|
||||
Console.WriteLine(" " + string.Join("\n ", disabled.Chunk(10).Select(group => string.Join(", ", group))));
|
||||
|
||||
// Bottom border
|
||||
Console.ForegroundColor = (ConsoleColor)CS2ConsoleColors.Magenta;
|
||||
Console.WriteLine($"\n************************************************************************************************************\n");
|
||||
Console.ResetColor();
|
||||
}
|
||||
|
||||
private static async Task<string?> GetLatestVersion()
|
||||
{
|
||||
using HttpClient client = new HttpClient();
|
||||
client.DefaultRequestHeaders.UserAgent.Add(new System.Net.Http.Headers.ProductInfoHeaderValue("jRandomSkills", "1.0"));
|
||||
const string URL = "https://api.github.com/repos/Juzlus/jRandomSkills/releases/latest";
|
||||
|
||||
try
|
||||
{
|
||||
string response = await client.GetStringAsync(URL);
|
||||
using JsonDocument doc = JsonDocument.Parse(response);
|
||||
if (doc.RootElement.TryGetProperty("tag_name", out JsonElement value))
|
||||
return value.GetString()?.Replace("v", "");
|
||||
return null;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class jSkill_PlayerInfo
|
||||
|
|
@ -141,4 +312,24 @@ namespace src
|
|||
{
|
||||
public static ConcurrentBag<jSkill_SkillInfo> Skills { get; } = [];
|
||||
}
|
||||
|
||||
public enum CS2ConsoleColors
|
||||
{
|
||||
Black = ConsoleColor.Black,
|
||||
White = ConsoleColor.DarkBlue,
|
||||
Orange = ConsoleColor.DarkGreen,
|
||||
Yellow = ConsoleColor.DarkCyan,
|
||||
LightGreen = ConsoleColor.DarkRed,
|
||||
Green = ConsoleColor.DarkMagenta,
|
||||
Green2 = ConsoleColor.DarkYellow,
|
||||
Green3 = ConsoleColor.Gray,
|
||||
Cyan = ConsoleColor.DarkGray,
|
||||
LightBlue = ConsoleColor.Blue,
|
||||
Blue = ConsoleColor.Green,
|
||||
DarkPurple = ConsoleColor.Cyan,
|
||||
Purple = ConsoleColor.Red,
|
||||
Magenta = ConsoleColor.Magenta,
|
||||
LightRed = ConsoleColor.Yellow,
|
||||
Red = ConsoleColor.White,
|
||||
}
|
||||
}
|
||||
|
|
@ -74,6 +74,7 @@ namespace src.utils
|
|||
[DisplayName("Game Mode")]
|
||||
[Description("TESTfafw..")]
|
||||
[Range(0, 5)]
|
||||
public string ConfigName { get; set; }
|
||||
public int GameMode { get; set; }
|
||||
public bool YourSkillChatInfo { get; set; }
|
||||
public bool KillerSkillChatInfo { get; set; }
|
||||
|
|
@ -98,6 +99,7 @@ namespace src.utils
|
|||
|
||||
public SettingsModel()
|
||||
{
|
||||
ConfigName = "Default";
|
||||
GameMode = (int)GameModes.NoRepeat;
|
||||
YourSkillChatInfo = true;
|
||||
KillerSkillChatInfo = true;
|
||||
|
|
@ -106,8 +108,8 @@ namespace src.utils
|
|||
DebugMode = false;
|
||||
AlternativeSkillButton = null;
|
||||
SkillTimeBeforeStart = 7;
|
||||
SkillHudDuration = 999;
|
||||
SkillDescriptionDuration = 999;
|
||||
SkillHudDuration = -1;
|
||||
SkillDescriptionDuration = -1;
|
||||
DisplayAlwaysDescription = false;
|
||||
FlashingHtmlHudFix = true;
|
||||
CS2TraceRayDebug = false;
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ namespace src.utils
|
|||
|
||||
public class SkillsInfoModel : ConcurrentBag<DefaultSkillInfo>
|
||||
{
|
||||
public string Name { get; set; } = "Default";
|
||||
public SkillsInfoModel()
|
||||
{
|
||||
foreach (var skill in
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue