added import/export to discord rpc + fixes
This commit is contained in:
parent
884e12f980
commit
79dcc39826
8 changed files with 220 additions and 17 deletions
|
@ -44,7 +44,7 @@ namespace WeeXnes
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(ex);
|
WeeXnes.Core.CustomConsole.Error(ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,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);
|
||||||
Console.WriteLine(file.Name + " loaded");
|
WeeXnes.Core.CustomConsole.WriteLine(file.Name + " loaded");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(file.Name + ": " + ex.Message);
|
WeeXnes.Core.CustomConsole.Error(file.Name + ": " + ex.Message);
|
||||||
MessageBox.Show(file.Name + ": " + ex.Message);
|
MessageBox.Show(file.Name + ": " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -127,12 +127,12 @@ namespace WeeXnes
|
||||||
);
|
);
|
||||||
newItem.Filename = file.Name;
|
newItem.Filename = file.Name;
|
||||||
KeyManagerView.Data.KeyItemsList.Add(newItem);
|
KeyManagerView.Data.KeyItemsList.Add(newItem);
|
||||||
Console.WriteLine(file.Name + " loaded");
|
WeeXnes.Core.CustomConsole.WriteLine(file.Name + " loaded");
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine(file.Name + ": " + ex.Message);
|
WeeXnes.Core.CustomConsole.Error(file.Name + ": " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
130
WeeXnes/Core/CustomConsole.cs
Normal file
130
WeeXnes/Core/CustomConsole.cs
Normal file
|
@ -0,0 +1,130 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using VanillaConsole = System.Console;
|
||||||
|
|
||||||
|
namespace WeeXnes.Core
|
||||||
|
{
|
||||||
|
public class CustomConsole
|
||||||
|
{
|
||||||
|
public static class Data
|
||||||
|
{
|
||||||
|
public static class Colors
|
||||||
|
{
|
||||||
|
public static bool colored_output = true;
|
||||||
|
public static ConsoleColor int_color = ConsoleColor.Blue;
|
||||||
|
public static ConsoleColor double_color = ConsoleColor.Cyan;
|
||||||
|
public static ConsoleColor float_color = ConsoleColor.DarkCyan;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Formatting
|
||||||
|
{
|
||||||
|
public static string success_char = "✓";
|
||||||
|
public static string warning_char = "⌬";
|
||||||
|
public static string info_char = "◈";
|
||||||
|
public static string error_char = "☓";
|
||||||
|
public static string writeline_char = "•";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void ConfiguredWriteline(
|
||||||
|
string text,
|
||||||
|
ConsoleColor color,
|
||||||
|
ConsoleColor foregroundColor = ConsoleColor.White)
|
||||||
|
{
|
||||||
|
VanillaConsole.OutputEncoding = Encoding.UTF8;
|
||||||
|
ConsoleColor prevColor = VanillaConsole.BackgroundColor;
|
||||||
|
ConsoleColor prevForeColor = VanillaConsole.ForegroundColor;
|
||||||
|
if (Data.Colors.colored_output)
|
||||||
|
{
|
||||||
|
VanillaConsole.BackgroundColor = color;
|
||||||
|
VanillaConsole.ForegroundColor = foregroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
VanillaConsole.WriteLine(text + " ");
|
||||||
|
if (Data.Colors.colored_output)
|
||||||
|
{
|
||||||
|
|
||||||
|
VanillaConsole.BackgroundColor = prevColor;
|
||||||
|
VanillaConsole.ForegroundColor = prevForeColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLine(string text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,VanillaConsole.BackgroundColor, ConsoleColor.White);
|
||||||
|
}
|
||||||
|
public static void WriteLine(float text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,Data.Colors.float_color, ConsoleColor.White);
|
||||||
|
}
|
||||||
|
public static void WriteLine(double text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,Data.Colors.double_color, ConsoleColor.White);
|
||||||
|
}
|
||||||
|
public static void WriteLine(int text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.writeline_char + " (" + lineNumber + "|" + caller + ") " + text,Data.Colors.int_color, ConsoleColor.White);
|
||||||
|
}
|
||||||
|
public static void Success(string text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.success_char + " (" + lineNumber + "|" + caller + ") " + text, ConsoleColor.Green,
|
||||||
|
ConsoleColor.Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Info(string text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.info_char + " (" + lineNumber + "|" + caller + ") " + text, ConsoleColor.Blue,
|
||||||
|
ConsoleColor.Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Error(string text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.error_char + " (" + lineNumber + "|" + caller + ") " + text, ConsoleColor.DarkRed,
|
||||||
|
ConsoleColor.Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Warning(string text,
|
||||||
|
[CallerLineNumber] int lineNumber = 0,
|
||||||
|
[CallerMemberName] string caller = null)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline(" " + Data.Formatting.warning_char + " (" + lineNumber + "|" + caller + ") " + text, ConsoleColor.DarkYellow,
|
||||||
|
ConsoleColor.Black);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLine<T>(List<T> List, bool verbose = true)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline("List contains " + typeof(T) + "(" + List.Count + ")", ConsoleColor.DarkMagenta,
|
||||||
|
ConsoleColor.Black);
|
||||||
|
if (!verbose)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (int i = 0; i < List.Count; i++)
|
||||||
|
{
|
||||||
|
if (i % 2 == 0)
|
||||||
|
{
|
||||||
|
ConfiguredWriteline("(" + i + "): " + List[i], ConsoleColor.DarkGray);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfiguredWriteline("(" + i + "): " + List[i], ConsoleColor.Black);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -8,7 +8,7 @@ namespace WeeXnes.Core
|
||||||
{
|
{
|
||||||
public class Information
|
public class Information
|
||||||
{
|
{
|
||||||
public const string Version = "4.3.0";
|
public const string Version = "4.3.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";
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,11 +24,17 @@
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<MenuItem Header="Edit"
|
<MenuItem Header="Edit"
|
||||||
Name="ButtonContextEdit"
|
Name="ButtonContextEdit"
|
||||||
Click="ContextEdit_OnClick"/>
|
Click="ContextMenu_Edit"/>
|
||||||
|
<MenuItem Header="Export"
|
||||||
|
Name="ButtonContextExport"
|
||||||
|
Click="ContextMenu_Export"/>
|
||||||
|
<MenuItem Header="Import"
|
||||||
|
Name="ButtonContextImport"
|
||||||
|
Click="ContextMenu_Import"/>
|
||||||
<Separator />
|
<Separator />
|
||||||
<MenuItem Header="Remove"
|
<MenuItem Header="Remove"
|
||||||
Name="ButtonContextRemove"
|
Name="ButtonContextRemove"
|
||||||
Click="ContextRemove_OnClick"/>
|
Click="ContextMenu_Remove"/>
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
</ListBox.ContextMenu>
|
</ListBox.ContextMenu>
|
||||||
</ListBox>
|
</ListBox>
|
||||||
|
|
|
@ -4,7 +4,10 @@ using System.IO;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using Microsoft.Win32;
|
||||||
|
using Nocksoft.IO.ConfigFiles;
|
||||||
using WeeXnes.Core;
|
using WeeXnes.Core;
|
||||||
|
using CConsole = WeeXnes.Core.CustomConsole;
|
||||||
|
|
||||||
namespace WeeXnes.Views.DiscordRPC
|
namespace WeeXnes.Views.DiscordRPC
|
||||||
{
|
{
|
||||||
|
@ -42,14 +45,66 @@ namespace WeeXnes.Views.DiscordRPC
|
||||||
Data.SelectedItem = (Game)listBox.SelectedItem;
|
Data.SelectedItem = (Game)listBox.SelectedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ContextEdit_OnClick(object sender, RoutedEventArgs e)
|
private void ContextMenu_Edit(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if(Data.SelectedItem == null)
|
if(Data.SelectedItem == null)
|
||||||
return;
|
return;
|
||||||
NavigationService.Navigate(new Uri("/Views/DiscordRPC/EditRPCView.xaml",UriKind.Relative));
|
NavigationService.Navigate(new Uri("/Views/DiscordRPC/EditRPCView.xaml",UriKind.Relative));
|
||||||
}
|
}
|
||||||
|
private void ContextMenu_Export(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Game selectedCache = Data.SelectedItem;
|
||||||
|
if(selectedCache == null)
|
||||||
|
return;
|
||||||
|
string filepath = Global.AppDataPathRPC.Value + "\\" + selectedCache.UUID + ".rpc";
|
||||||
|
|
||||||
|
SaveFileDialog dialog = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
FileName = selectedCache.UUID,
|
||||||
|
Filter = "RPC File (*.rpc)|*.rpc",
|
||||||
|
Title = "Export RPC File"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
File.Copy(filepath, dialog.FileName, true);
|
||||||
|
CustomConsole.WriteLine("Exported to: " + dialog.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ContextMenu_Import(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
Game selectedCache = Data.SelectedItem;
|
||||||
|
if(selectedCache == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
OpenFileDialog dialog = new OpenFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "RPC File (*.rpc)|*.rpc",
|
||||||
|
Title = "Import RPC File"
|
||||||
|
};
|
||||||
|
if (dialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
|
||||||
|
Game newGame = Game.Methods.GameFromIni(new INIFile(dialog.FileName));
|
||||||
|
|
||||||
|
if (!File.Exists(Global.AppDataPathRPC.Value + "\\" + newGame.UUID + ".rpc"))
|
||||||
|
{
|
||||||
|
File.Copy(dialog.FileName, Global.AppDataPathRPC.Value + "\\" + newGame.UUID + ".rpc", true);
|
||||||
|
DiscordRPCView.Data.Games.Add(newGame);
|
||||||
|
CustomConsole.WriteLine("Imported: " + dialog.FileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CustomConsole.Error("not imported: " + dialog.FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private void ContextRemove_OnClick(object sender, RoutedEventArgs e)
|
private void ContextMenu_Remove(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
Game selectedCache = Data.SelectedItem;
|
Game selectedCache = Data.SelectedItem;
|
||||||
if(selectedCache == null)
|
if(selectedCache == null)
|
||||||
|
|
|
@ -6,6 +6,7 @@ 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
|
||||||
{
|
{
|
||||||
|
@ -34,6 +35,7 @@ namespace WeeXnes.Views.KeyManager
|
||||||
|
|
||||||
SaveFileDialog dialog = new SaveFileDialog()
|
SaveFileDialog dialog = new SaveFileDialog()
|
||||||
{
|
{
|
||||||
|
FileName = this.Filename,
|
||||||
Filter = "WXFiles (*.wx)|*.wx",
|
Filter = "WXFiles (*.wx)|*.wx",
|
||||||
Title = "Export KeyFile"
|
Title = "Export KeyFile"
|
||||||
};
|
};
|
||||||
|
@ -48,10 +50,12 @@ namespace WeeXnes.Views.KeyManager
|
||||||
{
|
{
|
||||||
OpenFileDialog dialog = new OpenFileDialog()
|
OpenFileDialog dialog = new OpenFileDialog()
|
||||||
{
|
{
|
||||||
Filter = "WXFiles (*.wx)|*.wx"
|
Filter = "WXFiles (*.wx)|*.wx",
|
||||||
|
Title = "Import KeyFile"
|
||||||
};
|
};
|
||||||
if (dialog.ShowDialog() == true)
|
if (dialog.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
|
string filename = System.IO.Path.GetFileName(dialog.FileName);
|
||||||
WXFile wxFile = new WXFile(dialog.FileName);
|
WXFile wxFile = new WXFile(dialog.FileName);
|
||||||
KeyItem newItem = new KeyItem(
|
KeyItem newItem = new KeyItem(
|
||||||
wxFile.GetName(),
|
wxFile.GetName(),
|
||||||
|
@ -60,11 +64,17 @@ namespace WeeXnes.Views.KeyManager
|
||||||
wxFile.GetValue()
|
wxFile.GetValue()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
newItem.Filename = System.IO.Path.GetFileName(dialog.FileName);
|
newItem.Filename = filename;
|
||||||
WXFile newWxFile = new WXFile(Global.AppDataPathKEY.Value + "\\" + newItem.Filename);
|
if (!File.Exists(Global.AppDataPathKEY.Value + "\\" + filename))
|
||||||
WXFile.Methods.WriteFile(newItem, newWxFile);
|
{
|
||||||
KeyManagerView.Data.KeyItemsList.Add(newItem);
|
File.Copy(dialog.FileName, Global.AppDataPathKEY.Value + "\\" + filename, true);
|
||||||
Console.WriteLine("Imported: " + dialog.FileName);
|
KeyManagerView.Data.KeyItemsList.Add(newItem);
|
||||||
|
Console.WriteLine("Imported: " + dialog.FileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Error("Not Imported, already exists: " + dialog.FileName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
<MenuItem Header="Remove"
|
<MenuItem Header="Remove"
|
||||||
Name="btn_context_remove"
|
Name="btn_context_remove"
|
||||||
Click="ContextMenu_Remove"/>
|
Click="ContextMenu_Remove"/>
|
||||||
|
<Separator />
|
||||||
<MenuItem Header="Export"
|
<MenuItem Header="Export"
|
||||||
Name="btn_context_export"
|
Name="btn_context_export"
|
||||||
Click="ContextMenu_Export"/>
|
Click="ContextMenu_Export"/>
|
||||||
|
|
|
@ -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.3.0</Version>
|
<Version>4.3.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>
|
||||||
|
@ -68,6 +68,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\EncryptorLibrary.cs" />
|
<Compile Include="Core\EncryptorLibrary.cs" />
|
||||||
<Compile Include="Core\HandleLaunchArguments.cs" />
|
<Compile Include="Core\HandleLaunchArguments.cs" />
|
||||||
<Compile Include="Core\RpcLogEvents.cs" />
|
<Compile Include="Core\RpcLogEvents.cs" />
|
||||||
|
|
Loading…
Add table
Reference in a new issue