fully implemented user debug flag for trouble shooting

This commit is contained in:
WeeXnes 2023-11-24 10:38:05 +01:00
parent 30099b56d2
commit d5f6e160da
17 changed files with 48 additions and 52 deletions

View file

@ -41,6 +41,7 @@ namespace WeeXnes
private void App_OnStartup(object sender, StartupEventArgs e) private void App_OnStartup(object sender, StartupEventArgs e)
{ {
Environment.CurrentDirectory = Application.StartupPath; Environment.CurrentDirectory = Application.StartupPath;
Console.Data.Colors.colored_output = false;
SetExceptionHandler(); SetExceptionHandler();
CheckForDebugMode(); CheckForDebugMode();
CheckUpdatedFiles(); CheckUpdatedFiles();
@ -66,7 +67,7 @@ namespace WeeXnes
} }
catch (Exception ex) catch (Exception ex)
{ {
WeeXnes.Core.CustomConsole.Error(ex.ToString()); Console.Error(ex.ToString());
} }
} }
} }
@ -128,11 +129,11 @@ namespace WeeXnes
{ {
Game newGame = Game.Methods.GameFromIni(new INIFile(file.FullName)); Game newGame = Game.Methods.GameFromIni(new INIFile(file.FullName));
DiscordRPCView.Data.Games.Add(newGame); DiscordRPCView.Data.Games.Add(newGame);
WeeXnes.Core.CustomConsole.WriteLine(file.Name + " loaded -> " + newGame.ProcessName); Console.WriteLine(file.Name + " loaded -> " + newGame.ProcessName);
} }
catch (Exception ex) catch (Exception ex)
{ {
WeeXnes.Core.CustomConsole.Error(file.Name + ": " + ex.Message); Console.Error(file.Name + ": " + ex.Message);
new FluentMessageBox(file.Name + ": " + ex.Message).ShowDialog(); new FluentMessageBox(file.Name + ": " + ex.Message).ShowDialog();
} }
} }
@ -154,12 +155,12 @@ namespace WeeXnes
); );
newItem.Filename = file.Name; newItem.Filename = file.Name;
KeyManagerView.Data.KeyItemsList.Add(newItem); KeyManagerView.Data.KeyItemsList.Add(newItem);
WeeXnes.Core.CustomConsole.WriteLine(file.Name + " loaded -> " + newItem.Name); Console.WriteLine(file.Name + " loaded -> " + newItem.Name);
} }
catch (Exception ex) catch (Exception ex)
{ {
WeeXnes.Core.CustomConsole.Error(file.Name + ": " + ex.Message); Console.Error(file.Name + ": " + ex.Message);
new FluentMessageBox(file.Name + ": " + ex.Message).ShowDialog(); new FluentMessageBox(file.Name + ": " + ex.Message).ShowDialog();
} }
} }
@ -187,11 +188,7 @@ namespace WeeXnes
private void CheckForDebugMode() private void CheckForDebugMode()
{ {
#if DEBUG #if DEBUG
DebugMode = true; HandleLaunchArguments.arg_debugMode();
HandleLaunchArguments.arg_enableConsole();
//Allow untrusted certs in Debug mode
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
#endif #endif
} }
} }

View file

@ -1,13 +1,17 @@
using System; global using Console = WeeXnes.Core.Console;
global using VanillaConsole = System.Console;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Text; using System.Text;
using VanillaConsole = System.Console;
namespace WeeXnes.Core namespace WeeXnes.Core
{ {
public class CustomConsole
public static class Console
{ {
public static class Data public static class Data
{ {
@ -28,7 +32,6 @@ namespace WeeXnes.Core
public static string writeline_char = "•"; public static string writeline_char = "•";
} }
} }
private static void ConfiguredWriteline( private static void ConfiguredWriteline(
string text, string text,
ConsoleColor color, ConsoleColor color,
@ -36,9 +39,7 @@ namespace WeeXnes.Core
{ {
if(!App.DebugMode) if(!App.DebugMode)
return; return;
//VanillaConsole.OutputEncoding = Encoding.UTF8; //VanillaConsole.OutputEncoding = Encoding.UTF8;
ConsoleColor prevColor = VanillaConsole.BackgroundColor; ConsoleColor prevColor = VanillaConsole.BackgroundColor;
ConsoleColor prevForeColor = VanillaConsole.ForegroundColor; ConsoleColor prevForeColor = VanillaConsole.ForegroundColor;
if (Data.Colors.colored_output) if (Data.Colors.colored_output)
@ -62,13 +63,6 @@ namespace WeeXnes.Core
{ {
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,VanillaConsole.BackgroundColor, ConsoleColor.White); ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,VanillaConsole.BackgroundColor, ConsoleColor.White);
} }
public static void WriteLineVerbose(string text,
[CallerLineNumber] int lineNumber = 0,
[CallerMemberName] string caller = null,
[CallerFilePath] string filePath = null)
{
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + Path.GetFileName(filePath) + "|" + caller + "|" + lineNumber + ") " + text,VanillaConsole.BackgroundColor, ConsoleColor.White);
}
public static void WriteLine(float text, public static void WriteLine(float text,
[CallerLineNumber] int lineNumber = 0, [CallerLineNumber] int lineNumber = 0,
[CallerMemberName] string caller = null) [CallerMemberName] string caller = null)

View file

@ -8,7 +8,7 @@ namespace WeeXnes.Core
{ {
public class Information public class Information
{ {
public const string Version = "4.5.0"; public const string Version = "4.5.1";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_"; public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest"; public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
} }

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Net;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
@ -19,7 +20,11 @@ namespace WeeXnes.Core
} }
public static void arg_debugMode() public static void arg_debugMode()
{ {
MessageBox.Show("user debug mode enabled"); App.DebugMode = true;
HandleLaunchArguments.arg_enableConsole();
//Allow untrusted certs in Debug mode
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
} }
public static void arg_enableConsole() public static void arg_enableConsole()
{ {

View file

@ -37,13 +37,13 @@ namespace WeeXnes.Core
} }
catch (Exception ex) catch (Exception ex)
{ {
WeeXnes.Core.CustomConsole.WriteLine(ex.ToString()); Console.Error(ex.ToString());
this.ExceptionCache.Value = ex; this.ExceptionCache.Value = ex;
} }
}; };
this._loginWorker.RunWorkerCompleted += (sender, args) => this._loginWorker.RunWorkerCompleted += (sender, args) =>
{ {
WeeXnes.Core.CustomConsole.WriteLine("LoginWorker complete"); Console.WriteLine("LoginWorker complete");
}; };
this._loginUrl = loginUrl; this._loginUrl = loginUrl;
this._userDataUrl = userDataUrl; this._userDataUrl = userDataUrl;
@ -79,7 +79,7 @@ namespace WeeXnes.Core
} }
else else
{ {
WeeXnes.Core.CustomConsole.WriteLine("Error: " + response.StatusCode); Console.Error("Error: " + response.StatusCode);
LoginView.errorStringCache.Value = response.StatusCode.ToString(); LoginView.errorStringCache.Value = response.StatusCode.ToString();
return null; return null;
} }
@ -117,7 +117,7 @@ namespace WeeXnes.Core
user = user.user; user = user.user;
// Now you can access the user object properties dynamically // Now you can access the user object properties dynamically
WeeXnes.Core.CustomConsole.WriteLine("authenticated user: " + user.name); Console.WriteLine("authenticated user: " + user.name);
//Console.WriteLine($"Email: {user.email}"); //Console.WriteLine($"Email: {user.email}");
// Access other properties as needed // Access other properties as needed
_currentUserCache.Value = user; _currentUserCache.Value = user;
@ -129,7 +129,7 @@ namespace WeeXnes.Core
// Handle the error, e.g., print the status code // Handle the error, e.g., print the status code
_currentUserCache.Value = null; _currentUserCache.Value = null;
WeeXnes.Core.CustomConsole.WriteLine("Error: " + response.StatusCode); Console.Error("Error: " + response.StatusCode);
LoginView.errorStringCache.Value = response.StatusCode.ToString(); LoginView.errorStringCache.Value = response.StatusCode.ToString();
return null; return null;

View file

@ -29,7 +29,7 @@ namespace WeeXnes.Core
} }
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine(e); Console.WriteLine(e.ToString());
returnval = null; returnval = null;
} }
} }
@ -48,7 +48,7 @@ namespace WeeXnes.Core
returnval = rawcontent[2]; returnval = rawcontent[2];
}catch (Exception e) }catch (Exception e)
{ {
Console.WriteLine(e); Console.WriteLine(e.ToString());
returnval = null; returnval = null;
} }
} }

View file

@ -42,7 +42,7 @@ namespace WeeXnes.Views.DiscordRPC
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex.ToString());
} }
CloseDialog(); CloseDialog();

View file

@ -7,7 +7,6 @@ using System.Windows.Controls;
using Microsoft.Win32; using Microsoft.Win32;
using Nocksoft.IO.ConfigFiles; using Nocksoft.IO.ConfigFiles;
using WeeXnes.Core; using WeeXnes.Core;
using CConsole = WeeXnes.Core.CustomConsole;
namespace WeeXnes.Views.DiscordRPC namespace WeeXnes.Views.DiscordRPC
{ {
@ -67,7 +66,7 @@ namespace WeeXnes.Views.DiscordRPC
if (dialog.ShowDialog() == true) if (dialog.ShowDialog() == true)
{ {
File.Copy(filepath, dialog.FileName, true); File.Copy(filepath, dialog.FileName, true);
CustomConsole.WriteLine("Exported to: " + dialog.FileName); Console.WriteLine("Exported to: " + dialog.FileName);
} }
} }
@ -92,11 +91,11 @@ namespace WeeXnes.Views.DiscordRPC
{ {
File.Copy(dialog.FileName, Global.AppDataPathRPC.Value + "\\" + newGame.UUID + ".rpc", true); File.Copy(dialog.FileName, Global.AppDataPathRPC.Value + "\\" + newGame.UUID + ".rpc", true);
DiscordRPCView.Data.Games.Add(newGame); DiscordRPCView.Data.Games.Add(newGame);
CustomConsole.WriteLine("Imported: " + dialog.FileName); Console.WriteLine("Imported: " + dialog.FileName);
} }
else else
{ {
CustomConsole.Error("not imported: " + dialog.FileName); Console.Error("not imported: " + dialog.FileName);
} }

View file

@ -33,7 +33,7 @@ namespace WeeXnes.Views.DiscordRPC
private void LogChanged() private void LogChanged()
{ {
Console.WriteLine("Log Write Data: " + Data.LogCache.Value); VanillaConsole.WriteLine("Log Write Data: " + Data.LogCache.Value);
this.Dispatcher.Invoke(() => this.Dispatcher.Invoke(() =>
{ {
RpcLogView.Items.Add(Data.LogCache.Value); RpcLogView.Items.Add(Data.LogCache.Value);
@ -58,7 +58,7 @@ namespace WeeXnes.Views.DiscordRPC
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); VanillaConsole.WriteLine(ex.ToString());
} }
} }
public void StopBackgroundWorker() public void StopBackgroundWorker()
@ -71,7 +71,7 @@ namespace WeeXnes.Views.DiscordRPC
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); VanillaConsole.WriteLine(ex.ToString());
} }
//Stop RPC //Stop RPC
} }
@ -98,7 +98,7 @@ namespace WeeXnes.Views.DiscordRPC
{ {
foreach (Game game in DiscordRPCView.Data.Games) foreach (Game game in DiscordRPCView.Data.Games)
game.Stop(); game.Stop();
Console.WriteLine("Thread Stopped"); VanillaConsole.WriteLine("Thread Stopped");
Data.LogCache.Value = new customEvent("[INFO] RPC Thread has stopped", EventType.ProcessStoppedEvent); Data.LogCache.Value = new customEvent("[INFO] RPC Thread has stopped", EventType.ProcessStoppedEvent);
} }

View file

@ -6,7 +6,6 @@ using System.Net;
using Wpf.Ui.Controls; using Wpf.Ui.Controls;
using Microsoft.Win32; using Microsoft.Win32;
using Path = System.Windows.Shapes.Path; using Path = System.Windows.Shapes.Path;
using Console = WeeXnes.Core.CustomConsole;
namespace WeeXnes.Views.KeyManager namespace WeeXnes.Views.KeyManager
{ {

View file

@ -87,7 +87,7 @@ namespace WeeXnes.Views.KeyManager
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex.ToString());
} }
} }

View file

@ -43,7 +43,7 @@ namespace WeeXnes.Views.PasswordGenerator
CustomPasswordBuilderString += PasswordBuilderStrings.special; CustomPasswordBuilderString += PasswordBuilderStrings.special;
CustomConsole.WriteLine("Generating Password from: " + CustomPasswordBuilderString); Console.WriteLine("Generating Password from: " + CustomPasswordBuilderString);
//MessageBox.Show(CustomPasswordBuilderString); //MessageBox.Show(CustomPasswordBuilderString);
string generatedPassword = ""; string generatedPassword = "";

View file

@ -38,6 +38,7 @@ namespace WeeXnes.Views.ProfileView
{ {
CardAction button = (CardAction)sender; CardAction button = (CardAction)sender;
dynamic messageObj = button.Tag; dynamic messageObj = button.Tag;
Console.WriteLine(messageObj.ToString());
MessageFullView.MessageToShow = messageObj; MessageFullView.MessageToShow = messageObj;
NavigationService.Navigate(new Uri("/Views/ProfileView/MessageFullView.xaml",UriKind.Relative)); NavigationService.Navigate(new Uri("/Views/ProfileView/MessageFullView.xaml",UriKind.Relative));
} }

View file

@ -22,9 +22,9 @@ namespace WeeXnes.Views.ProfileView
auth.ExceptionCache.ValueChanged += LoginWorkerException; auth.ExceptionCache.ValueChanged += LoginWorkerException;
auth._currentUserCache.ValueChanged += userCacheChanged; auth._currentUserCache.ValueChanged += userCacheChanged;
LoginView.errorStringCache.ValueChanged += errorStringChanged; LoginView.errorStringCache.ValueChanged += errorStringChanged;
WeeXnes.Core.CustomConsole.WriteLine("Error Hooks loaded"); Console.WriteLine("Error Hooks loaded");
WeeXnes.Core.CustomConsole.WriteLine("Event hooks loaded"); Console.WriteLine("Event hooks loaded");
if (auth._currentUserCache.Value == null) if (auth._currentUserCache.Value == null)
{ {
LoadingScreen.Visibility = Visibility.Visible; LoadingScreen.Visibility = Visibility.Visible;
@ -83,7 +83,7 @@ namespace WeeXnes.Views.ProfileView
auth._currentUserCache.ValueChanged -= userCacheChanged; auth._currentUserCache.ValueChanged -= userCacheChanged;
LoginView.errorStringCache.ValueChanged -= errorStringChanged; LoginView.errorStringCache.ValueChanged -= errorStringChanged;
WeeXnes.Core.CustomConsole.WriteLine("Event hooks unloaded"); Console.WriteLine("Event hooks unloaded");
} }
private void errorStringChanged() private void errorStringChanged()
{ {

View file

@ -73,7 +73,7 @@ namespace WeeXnes.Views.Settings
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex.ToString());
} }
} }

View file

@ -48,7 +48,7 @@ namespace WeeXnes.Views.Settings
} }
catch (Exception ex) catch (Exception ex)
{ {
Console.WriteLine(ex); Console.WriteLine(ex.ToString());
} }
} }

View file

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.5.0</Version> <Version>4.5.1</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid> <ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace> <RootNamespace>WeeXnes</RootNamespace>
@ -15,6 +15,7 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<ApplicationIcon>wicns.ico</ApplicationIcon> <ApplicationIcon>wicns.ico</ApplicationIcon>
<LangVersion>10</LangVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
@ -70,7 +71,7 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Compile Include="Core\CustomConsole.cs" /> <Compile Include="Core\Console.cs" />
<Compile Include="Core\EncryptorLibrary.cs" /> <Compile Include="Core\EncryptorLibrary.cs" />
<Compile Include="Core\HandleLaunchArguments.cs" /> <Compile Include="Core\HandleLaunchArguments.cs" />
<Compile Include="Core\LoginLib.cs" /> <Compile Include="Core\LoginLib.cs" />