diff --git a/DLLS/agsXMPP.dll b/DLLS/agsXMPP.dll index 3513792b..08c8b870 100644 Binary files a/DLLS/agsXMPP.dll and b/DLLS/agsXMPP.dll differ diff --git a/LCDevWindow/Commands/Command.cs b/LCDevWindow/Commands/Command.cs index 278e1bef..74b35419 100644 --- a/LCDevWindow/Commands/Command.cs +++ b/LCDevWindow/Commands/Command.cs @@ -1,4 +1,4 @@ -using LCDevWindow.Commands.LegendaryClient; +using LCDevWindow.Commands.Sightstone; using System; using System.Collections.Generic; @@ -18,7 +18,7 @@ public static object GetCommand(string command) if (t != null) return (Command)Activator.CreateInstance(t); - t = Type.GetType("LCDevWindow.Commands.LegendaryClient." + command); + t = Type.GetType("LCDevWindow.Commands.Sightstone." + command); if (t != null) return (LCCommand)Activator.CreateInstance(t); diff --git a/LCDevWindow/Commands/Help.cs b/LCDevWindow/Commands/Help.cs index 1db8a416..6fa440ae 100644 --- a/LCDevWindow/Commands/Help.cs +++ b/LCDevWindow/Commands/Help.cs @@ -1,4 +1,4 @@ -using LCDevWindow.Commands.LegendaryClient; +using LCDevWindow.Commands.Sightstone; using System; using System.Collections.Generic; using System.Linq; @@ -40,7 +40,7 @@ public override object ActivateCommand(string[] args) Main.win.Log(help, Brushes.Black); } } - Main.win.Log("LegendaryClient Commands", Brushes.LightSeaGreen); + Main.win.Log("Sightstone Commands", Brushes.LightSeaGreen); List lccommands = GetInstances(); foreach (LCCommand command in lccommands) { diff --git a/LCDevWindow/Commands/LegendaryClient/LCCommand.cs b/LCDevWindow/Commands/Sightstone/LCCommand.cs similarity index 83% rename from LCDevWindow/Commands/LegendaryClient/LCCommand.cs rename to LCDevWindow/Commands/Sightstone/LCCommand.cs index f4f31e0d..c7c422f7 100644 --- a/LCDevWindow/Commands/LegendaryClient/LCCommand.cs +++ b/LCDevWindow/Commands/Sightstone/LCCommand.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; -namespace LCDevWindow.Commands.LegendaryClient +namespace LCDevWindow.Commands.Sightstone { // ReSharper disable once InconsistentNaming public abstract class LCCommand @@ -18,7 +18,7 @@ public static Command GetCommand(string command) if (t != null) return (Command)Activator.CreateInstance(t); - t = Type.GetType("LCDevWindow.Commands.LegendaryClient." + command); + t = Type.GetType("LCDevWindow.Commands.Sightstone." + command); if (t != null) return (Command)Activator.CreateInstance(t); diff --git a/LCDevWindow/Commands/LegendaryClient/MessageReceived.cs b/LCDevWindow/Commands/Sightstone/MessageReceived.cs similarity index 94% rename from LCDevWindow/Commands/LegendaryClient/MessageReceived.cs rename to LCDevWindow/Commands/Sightstone/MessageReceived.cs index b364823b..4ba19969 100644 --- a/LCDevWindow/Commands/LegendaryClient/MessageReceived.cs +++ b/LCDevWindow/Commands/Sightstone/MessageReceived.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace LCDevWindow.Commands.LegendaryClient +namespace LCDevWindow.Commands.Sightstone { public abstract class MessageReceived : LCCommand { diff --git a/LCDevWindow/Commands/LegendaryClient/SendOverlay.cs b/LCDevWindow/Commands/Sightstone/SendOverlay.cs similarity index 90% rename from LCDevWindow/Commands/LegendaryClient/SendOverlay.cs rename to LCDevWindow/Commands/Sightstone/SendOverlay.cs index 82c40a77..09f23c32 100644 --- a/LCDevWindow/Commands/LegendaryClient/SendOverlay.cs +++ b/LCDevWindow/Commands/Sightstone/SendOverlay.cs @@ -1,7 +1,7 @@ using System.Collections.Generic; using System.Linq; -namespace LCDevWindow.Commands.LegendaryClient +namespace LCDevWindow.Commands.Sightstone { public sealed class SendOverlay : LCCommand { @@ -9,7 +9,7 @@ public override List HelpTips() { List result = new List { - "Send an overlay to LegendaryClient", + "Send an overlay to Sightstone", "Usage: SendOverlay(string (1), string (2), [string (3)]) -> string (1) = Title; string (2) = Content; string (FullOVER)" }; return result; diff --git a/LCDevWindow/Commands/LegendaryClient/SendRtmpObject.cs b/LCDevWindow/Commands/Sightstone/SendRtmpObject.cs similarity index 94% rename from LCDevWindow/Commands/LegendaryClient/SendRtmpObject.cs rename to LCDevWindow/Commands/Sightstone/SendRtmpObject.cs index 4230f172..c99f0ec6 100644 --- a/LCDevWindow/Commands/LegendaryClient/SendRtmpObject.cs +++ b/LCDevWindow/Commands/Sightstone/SendRtmpObject.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; -namespace LCDevWindow.Commands.LegendaryClient +namespace LCDevWindow.Commands.Sightstone { public sealed class SendRtmpObject : LCCommand { diff --git a/LCDevWindow/LCDevWindow.csproj b/LCDevWindow/LCDevWindow.csproj index 01affdb9..b812cfa4 100644 --- a/LCDevWindow/LCDevWindow.csproj +++ b/LCDevWindow/LCDevWindow.csproj @@ -19,7 +19,7 @@ true full false - ..\LegendaryClient\bin\Debug\DevWin\ + ..\Sightstone\bin\Debug\DevWin\ DEBUG;TRACE prompt 4 @@ -29,11 +29,31 @@ false None true - bin\Release\ + ..\Sightstone\bin\Release\DevWin\ TRACE prompt 4 + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + None + x86 + prompt + MinimumRecommendedRules.ruleset + true + ..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll @@ -74,10 +94,10 @@ - - - - + + + + MainWindow.xaml diff --git a/LCDevWindow/MainWindow.xaml.cs b/LCDevWindow/MainWindow.xaml.cs index e9651bb3..f790d0b1 100644 --- a/LCDevWindow/MainWindow.xaml.cs +++ b/LCDevWindow/MainWindow.xaml.cs @@ -1,5 +1,5 @@ using LCDevWindow.Commands; -using LCDevWindow.Commands.LegendaryClient; +using LCDevWindow.Commands.Sightstone; using System; using System.Globalization; using System.IO; @@ -30,11 +30,11 @@ public MainWindow() InitializeComponent(); Main.win = this; //191537514598135486vneaoifjidafd are just random chars, they will match up to the one in LC - Log("LegendaryClient Logger. Starting Pipe, please wait.", Brushes.Brown); - Main.inPipeClient = new NamedPipeClientStream(".", "LegendaryClientPipe@191537514598135486vneaoifjidafd", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation); + Log("Sightstone Logger. Starting Pipe, please wait.", Brushes.Brown); + Main.inPipeClient = new NamedPipeClientStream(".", "SightstonePipe@191537514598135486vneaoifjidafd", PipeDirection.InOut, PipeOptions.None, TokenImpersonationLevel.Impersonation); Main.inPipeClient.Connect(); Main.inPipeStream = new StreamString(Main.inPipeClient); - Log("Pipe to LegendaryClient Created! Logging has started", Brushes.Green); + Log("Pipe to Sightstone Created! Logging has started", Brushes.Green); var xls = new Thread(() => { while (_pipe) @@ -45,7 +45,7 @@ public MainWindow() { case "191537514598135486vneaoifjidafd": _pipe = false; - Log("LegendaryClient has closed and the pipe has been shut down!", Brushes.Red); + Log("Sightstone has closed and the pipe has been shut down!", Brushes.Red); Log("This window will now close in 30 seconds, do \"-abortShutdown\" to stop the shutdown", Brushes.Red); _shutdown.Interval = 1000; _shutdownint = 0; @@ -65,7 +65,7 @@ public MainWindow() case "AwaitStart": StartPipe(); - Log("Starting another pipe to LegendaryClient for sending data", Brushes.Blue); + Log("Starting another pipe to Sightstone for sending data", Brushes.Blue); break; default: if (!x.ToLower().Contains("exception")) @@ -94,7 +94,7 @@ public static void StartPipe() private static void ServerThread(object data) { var pipeServer = - new NamedPipeServerStream("LegendaryClientPipe@191537514598135486vneaoifjidafdOUTPUT", PipeDirection.InOut, NumThreads); + new NamedPipeServerStream("SightstonePipe@191537514598135486vneaoifjidafdOUTPUT", PipeDirection.InOut, NumThreads); //var threadId = Thread.CurrentThread.ManagedThreadId; pipeServer.WaitForConnection(); try @@ -139,9 +139,9 @@ private void Button_Click(object sender, RoutedEventArgs e) var xm = tempsplit[1].Replace(")", "").Split(','); var splittwo = xm.ToList(); - if (!x.GetType().ToString().Contains("LCDevWindow.Commands.LegendaryClient") && x.GetType().ToString().Contains("LCDevWindow.Commands")) + if (!x.GetType().ToString().Contains("LCDevWindow.Commands.Sightstone") && x.GetType().ToString().Contains("LCDevWindow.Commands")) ((Command)x).ActivateCommand(splittwo.ToArray()); - else if (x.GetType().ToString().Contains("LCDevWindow.Commands.LegendaryClient")) + else if (x.GetType().ToString().Contains("LCDevWindow.Commands.Sightstone")) ((LCCommand)x).ActivateCommand(splittwo.ToArray()); } else diff --git a/LCDevWindow/Properties/AssemblyInfo.cs b/LCDevWindow/Properties/AssemblyInfo.cs index 162e53ad..251277f5 100644 --- a/LCDevWindow/Properties/AssemblyInfo.cs +++ b/LCDevWindow/Properties/AssemblyInfo.cs @@ -10,7 +10,7 @@ [assembly: AssemblyTitle("LCDevWindow")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("LegendaryClient")] +[assembly: AssemblyCompany("Sightstone")] [assembly: AssemblyProduct("LCDevWindow")] [assembly: AssemblyCopyright("Copyright © eddy5641 (And Github collabs) 2015")] [assembly: AssemblyTrademark("")] diff --git a/LCLog/LCLog.csproj b/LCLog/LCLog.csproj index 0800eb0e..1ca66a22 100644 --- a/LCLog/LCLog.csproj +++ b/LCLog/LCLog.csproj @@ -38,6 +38,32 @@ prompt MinimumRecommendedRules.ruleset + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\Release\ + TRACE + None + x86 + prompt + MinimumRecommendedRules.ruleset + + + bin\x86\DispersiaRelease\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + diff --git a/LCLog/Log.cs b/LCLog/Log.cs index cd0632c4..a9345d68 100644 --- a/LCLog/Log.cs +++ b/LCLog/Log.cs @@ -9,7 +9,7 @@ namespace LCLog { /// - /// Worlds most basic logger for LegendaryClient + /// Worlds most basic logger for Sightstone /// public class Log { diff --git a/LCLog/WriteToLog.cs b/LCLog/WriteToLog.cs index b8857501..09eea63b 100644 --- a/LCLog/WriteToLog.cs +++ b/LCLog/WriteToLog.cs @@ -8,7 +8,7 @@ namespace LCLog { /// - /// Worlds most basic logger for LegendaryClient + /// Worlds most basic logger for Sightstone /// public class WriteToLog { diff --git a/LegendaryClient.Patcher/App.xaml b/LegendaryClient.Patcher/App.xaml deleted file mode 100644 index 70183992..00000000 --- a/LegendaryClient.Patcher/App.xaml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/LegendaryClient.Patcher/Logic/LeagueDownloadLogic.cs b/LegendaryClient.Patcher/Logic/LeagueDownloadLogic.cs deleted file mode 100644 index 09117436..00000000 --- a/LegendaryClient.Patcher/Logic/LeagueDownloadLogic.cs +++ /dev/null @@ -1,84 +0,0 @@ -// ReSharper disable InconsistentNaming -#region - -using System; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using ComponentAce.Compression.Libs.zlib; -using LegendaryClient.Patcher.Logic.Region; - -#endregion - -namespace LegendaryClient.Patcher.Logic -{ - internal class LeagueDownloadLogic - { - public static string ReleaseListing = ""; - public static string SolutionManifest = ""; - - - /// - /// Gets the Latest LeagueOfLegends lol_game_client_sln version - /// - public string[] GetLolClientSlnVersion(MainRegion Region) - { - //Get the GameClientSln version - using (new WebClient()) - { - ReleaseListing = new WebClient().DownloadString(Region.GameReleaseListingUri); - } - - return ReleaseListing.Split(new[] {Environment.NewLine}, StringSplitOptions.None).Skip(1).ToArray(); - } - - public string GetLatestLCLOLVersion() - { - if (File.Exists(Path.Combine(Client.ExecutingDirectory, "LC_LOL.Version"))) - { - return File.ReadAllText(Path.Combine(Client.ExecutingDirectory, "LC_LOL.Version")).Split( new []{Environment.NewLine}, StringSplitOptions.None)[0]; - } - var encoding = new ASCIIEncoding(); - File.Create(Path.Combine(Client.ExecutingDirectory, "LC_LOL.Version")).Write(encoding.GetBytes("0.0.0.0"), 0, encoding.GetBytes("0.0.0.0").Length); - return "0.0.0.0"; - } - - /// - /// Gets the SolutionManifest - /// - /// - /// The SolutionManifest file from riot - /// - public string CreateConfigurationManifest(MainRegion Region) - { - string latestSlnVersion = Convert.ToString(GetLolClientSlnVersion(Region)); - //Get GameClient Language files - using (new WebClient()) - { - SolutionManifest = - new WebClient().DownloadString( - "http://l3cdn.riotgames.com/releases/live/solutions/lol_game_client_sln/releases/" + - latestSlnVersion + "/solutionmanifest"); - } - return SolutionManifest; - } - - public static void DecompressFile(string inFile, string outFile) - { - int data; - const int stopByte = -1; - var outFileStream = new FileStream(outFile, FileMode.Create); - var inZStream = new ZInputStream(File.Open(inFile, FileMode.Open, FileAccess.Read)); - - while (stopByte != (data = inZStream.Read())) - { - var databyte = (byte) data; - outFileStream.WriteByte(databyte); - } - - inZStream.Close(); - outFileStream.Close(); - } - } -} \ No newline at end of file diff --git a/LegendaryClient.Patcher/Logic/Region/BR.cs b/LegendaryClient.Patcher/Logic/Region/BR.cs deleted file mode 100644 index c77b8ad0..00000000 --- a/LegendaryClient.Patcher/Logic/Region/BR.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class BR : MainRegion - { - public override string RegionName - { - get { return "BR"; } - } - - public override string[] Locals - { - get { return new[] { "pt_BR" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new []{Environment.NewLine}, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_BR"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/EUNE.cs b/LegendaryClient.Patcher/Logic/Region/EUNE.cs deleted file mode 100644 index 08cf0287..00000000 --- a/LegendaryClient.Patcher/Logic/Region/EUNE.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class EUNE : MainRegion - { - public override string RegionName - { - get { return "EUNE"; } - } - - public override string[] Locals - { - get { return new[] { "en_PL", "pl_PL", "el_GR", "ro_RO", "hu_HU", "cs_CZ" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_EUNE"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/EUW.cs b/LegendaryClient.Patcher/Logic/Region/EUW.cs deleted file mode 100644 index 333ac4dc..00000000 --- a/LegendaryClient.Patcher/Logic/Region/EUW.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class EUW : MainRegion - { - public override string RegionName - { - get { return "EUW"; } - } - - public override string[] Locals - { - get { return new[] { "en_GB", "de_DE", "es_ES", "fr_FR", "it_IT" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_EUW"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/KR.cs b/LegendaryClient.Patcher/Logic/Region/KR.cs deleted file mode 100644 index 87c8a2e0..00000000 --- a/LegendaryClient.Patcher/Logic/Region/KR.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class KR : MainRegion - { - public override string RegionName - { - get { return "KR"; } - } - - public override string[] Locals - { - get { return new[] { "ko_KR" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.KR; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://legendspatch-lol.x-cdn.com/KR_CBT/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://legendspatch-lol.x-cdn.com/KR_CBT/projects/lol_air_client/releases/releaselisting_KR"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/LAN.cs b/LegendaryClient.Patcher/Logic/Region/LAN.cs deleted file mode 100644 index 19d9513b..00000000 --- a/LegendaryClient.Patcher/Logic/Region/LAN.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class LAN : MainRegion - { - public override string RegionName - { - get { return "LAN"; } - } - - public override string[] Locals - { - get { return new[] { "es_MX" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - //Weird LAN isn't there - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/LAS.cs b/LegendaryClient.Patcher/Logic/Region/LAS.cs deleted file mode 100644 index 07ffd1f8..00000000 --- a/LegendaryClient.Patcher/Logic/Region/LAS.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class LAS : MainRegion - { - public override string RegionName - { - get { return "LAS"; } - } - - public override string[] Locals - { - get { return new[] { "es_AR" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - //LAS Also not there - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/NA.cs b/LegendaryClient.Patcher/Logic/Region/NA.cs deleted file mode 100644 index 75eb400d..00000000 --- a/LegendaryClient.Patcher/Logic/Region/NA.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - // ReSharper disable once InconsistentNaming - internal class NA : MainRegion - { - public override string RegionName - { - get { return "NA"; } - } - - public override string[] Locals - { - get { return new[] { "en_US" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_NA"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} \ No newline at end of file diff --git a/LegendaryClient.Patcher/Logic/Region/OCE.cs b/LegendaryClient.Patcher/Logic/Region/OCE.cs deleted file mode 100644 index b0b9d395..00000000 --- a/LegendaryClient.Patcher/Logic/Region/OCE.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class OCE : MainRegion - { - public override string RegionName - { - get { return "OCE"; } - } - - public override string[] Locals - { - get { return new[] { "en_AU" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - //OCE not there - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/PBE.cs b/LegendaryClient.Patcher/Logic/Region/PBE.cs deleted file mode 100644 index a7b78132..00000000 --- a/LegendaryClient.Patcher/Logic/Region/PBE.cs +++ /dev/null @@ -1,60 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class PBE : MainRegion - { - public override string RegionName - { - get { return "PBE"; } - } - - public override string[] Locals - { - get { return new[] { "en_US" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.PBE; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/pbe/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - //This isn't actually real I will try to find out what it is - return new Uri("http://l3cdn.riotgames.com/releases/pbe/projects/lol_air_client/releases/releaselisting_PBE"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/RU.cs b/LegendaryClient.Patcher/Logic/Region/RU.cs deleted file mode 100644 index 9f9a57f4..00000000 --- a/LegendaryClient.Patcher/Logic/Region/RU.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class RU : MainRegion - { - public override string RegionName - { - get { return "RU"; } - } - - public override string[] Locals - { - get { return new[] { "ru_RU" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_RU"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/Logic/Region/TR.cs b/LegendaryClient.Patcher/Logic/Region/TR.cs deleted file mode 100644 index b4272b8d..00000000 --- a/LegendaryClient.Patcher/Logic/Region/TR.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Net; - -namespace LegendaryClient.Patcher.Logic.Region -{ - class TR : MainRegion - { - public override string RegionName - { - get { return "TR"; } - } - - public override string[] Locals - { - get { return new[] { "tr_TR" }; } - } - - public override RegionType RegionType - { - get - { - return RegionType.Riot; - } - } - - public override Uri ClientUpdateUri - { - get - { - var x = new WebClient().DownloadString(ReleaseListingUri).Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; - return new Uri(string.Format("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/{0}/packages/files/packagemanifest", x)); - } - } - - public override Uri ReleaseListingUri - { - get - { - return new Uri("http://l3cdn.riotgames.com/releases/live/projects/lol_air_client/releases/releaselisting_TR"); - } - } - - public override Uri GameClientUpdateUri - { - get - { - return new Uri(""); - } - } - - public override Uri GameReleaseListingUri - { - get - { - return new Uri(""); - } - } - } -} diff --git a/LegendaryClient.Patcher/MainWindow.xaml b/LegendaryClient.Patcher/MainWindow.xaml deleted file mode 100644 index 381633f8..00000000 --- a/LegendaryClient.Patcher/MainWindow.xaml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/LegendaryClient/Windows/ChampSelectPage.xaml b/LegendaryClient/Windows/ChampSelectPage.xaml deleted file mode 100644 index 40f022dc..00000000 --- a/LegendaryClient/Windows/ChampSelectPage.xaml +++ /dev/null @@ -1,179 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/LegendaryClient/Windows/TeamBuilderPage.xaml b/LegendaryClient/Windows/TeamBuilderPage.xaml deleted file mode 100644 index beb1478b..00000000 --- a/LegendaryClient/Windows/TeamBuilderPage.xaml +++ /dev/null @@ -1,143 +0,0 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient.Patcher/PatcherElements/FreeWeekChampion.xaml.cs b/Sightstone.Patcher/PatcherElements/FreeWeekChampion.xaml.cs similarity index 81% rename from LegendaryClient.Patcher/PatcherElements/FreeWeekChampion.xaml.cs rename to Sightstone.Patcher/PatcherElements/FreeWeekChampion.xaml.cs index 251e5218..ccdb9828 100644 --- a/LegendaryClient.Patcher/PatcherElements/FreeWeekChampion.xaml.cs +++ b/Sightstone.Patcher/PatcherElements/FreeWeekChampion.xaml.cs @@ -1,4 +1,4 @@ -namespace LegendaryClient.Patcher.PatcherElements +namespace Sightstone.Patcher.PatcherElements { /// /// Interaction logic for FreeWeekChampion.xaml diff --git a/Sightstone.Patcher/PatcherElements/NewsItem.xaml b/Sightstone.Patcher/PatcherElements/NewsItem.xaml new file mode 100644 index 00000000..14c1db29 --- /dev/null +++ b/Sightstone.Patcher/PatcherElements/NewsItem.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient.Patcher/PatcherElements/NewsItem.xaml.cs b/Sightstone.Patcher/PatcherElements/NewsItem.xaml.cs similarity index 80% rename from LegendaryClient.Patcher/PatcherElements/NewsItem.xaml.cs rename to Sightstone.Patcher/PatcherElements/NewsItem.xaml.cs index e29dc3e2..8842054b 100644 --- a/LegendaryClient.Patcher/PatcherElements/NewsItem.xaml.cs +++ b/Sightstone.Patcher/PatcherElements/NewsItem.xaml.cs @@ -1,4 +1,4 @@ -namespace LegendaryClient.Patcher.PatcherElements +namespace Sightstone.Patcher.PatcherElements { /// /// Interaction logic for NewsItem.xaml diff --git a/LegendaryClient.Patcher/Properties/AssemblyInfo.cs b/Sightstone.Patcher/Properties/AssemblyInfo.cs similarity index 91% rename from LegendaryClient.Patcher/Properties/AssemblyInfo.cs rename to Sightstone.Patcher/Properties/AssemblyInfo.cs index 9dce1367..1b19cad5 100644 --- a/LegendaryClient.Patcher/Properties/AssemblyInfo.cs +++ b/Sightstone.Patcher/Properties/AssemblyInfo.cs @@ -10,11 +10,11 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("LegendaryClient.Patcher")] -[assembly: AssemblyDescription("")] +[assembly: AssemblyTitle("Sightstone.Patcher")] +[assembly: AssemblyDescription("League of legends custom updator (that also updates sightstone)")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("LegendaryClient.Patcher")] +[assembly: AssemblyProduct("Sightstone.Patcher")] [assembly: AssemblyCopyright("Copyright © 2014")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/LegendaryClient.Patcher/Properties/Resources.Designer.cs b/Sightstone.Patcher/Properties/Resources.Designer.cs similarity index 93% rename from LegendaryClient.Patcher/Properties/Resources.Designer.cs rename to Sightstone.Patcher/Properties/Resources.Designer.cs index a6ce36fe..ed05d8b0 100644 --- a/LegendaryClient.Patcher/Properties/Resources.Designer.cs +++ b/Sightstone.Patcher/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace LegendaryClient.Patcher.Properties { +namespace Sightstone.Patcher.Properties { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("LegendaryClient.Patcher.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sightstone.Patcher.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/LegendaryClient.Patcher/Properties/Resources.resx b/Sightstone.Patcher/Properties/Resources.resx similarity index 100% rename from LegendaryClient.Patcher/Properties/Resources.resx rename to Sightstone.Patcher/Properties/Resources.resx diff --git a/LegendaryClient.Patcher/Properties/Settings.Designer.cs b/Sightstone.Patcher/Properties/Settings.Designer.cs similarity index 98% rename from LegendaryClient.Patcher/Properties/Settings.Designer.cs rename to Sightstone.Patcher/Properties/Settings.Designer.cs index 0e63e062..cb446441 100644 --- a/LegendaryClient.Patcher/Properties/Settings.Designer.cs +++ b/Sightstone.Patcher/Properties/Settings.Designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.35317 +// Runtime Version:4.0.30319.0 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace LegendaryClient.Patcher.Properties { +namespace Sightstone.Patcher.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] diff --git a/LegendaryClient.Patcher/Properties/Settings.settings b/Sightstone.Patcher/Properties/Settings.settings similarity index 96% rename from LegendaryClient.Patcher/Properties/Settings.settings rename to Sightstone.Patcher/Properties/Settings.settings index b5592f5d..c988a89c 100644 --- a/LegendaryClient.Patcher/Properties/Settings.settings +++ b/Sightstone.Patcher/Properties/Settings.settings @@ -1,5 +1,5 @@  - + diff --git a/LegendaryClient.Patcher/LegendaryClient.Patcher.csproj b/Sightstone.Patcher/Sightstone.Patcher.csproj similarity index 67% rename from LegendaryClient.Patcher/LegendaryClient.Patcher.csproj rename to Sightstone.Patcher/Sightstone.Patcher.csproj index 5df595ce..e4487304 100644 --- a/LegendaryClient.Patcher/LegendaryClient.Patcher.csproj +++ b/Sightstone.Patcher/Sightstone.Patcher.csproj @@ -7,8 +7,8 @@ {9C7F7F35-2F26-4191-A954-7770C7854D27} WinExe Properties - LegendaryClient.Patcher - LegendaryClient.Patcher + Sightstone.Patcher + Sightstone.Patcher v4.5.1 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -20,7 +20,7 @@ true full false - ..\LegendaryClient\bin\Debug\ + ..\Sightstone\bin\Debug\Client\ DEBUG;TRACE prompt 4 @@ -29,7 +29,7 @@ AnyCPU pdbonly true - bin\Release\ + ..\Sightstone\bin\Release\Client TRACE prompt 4 @@ -44,6 +44,36 @@ MinimumRecommendedRules.ruleset true + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + + + bin\x86\DispersiaRelease\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + true + ..\DLLS\Awesomium.Core.dll @@ -51,18 +81,35 @@ ..\DLLS\awesomium.windows.controls.dll - - ..\DLLS\MahApps.Metro.dll + + ..\packages\DotNetZip.1.9.6\lib\net20\Ionic.Zip.dll + True - - False - ..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll + + ..\packages\MahApps.Metro.1.1.3-ALPHA210\lib\net45\MahApps.Metro.dll + True + + + ..\packages\MaterialDesignThemes.1.1.1-ci283\lib\net45\MaterialDesignThemes.Wpf.dll + True + + + ..\packages\MediaToolkit.1.0.4.11\lib\net40\MediaToolkit.dll + True + + + ..\packages\Newtonsoft.Json.8.0.1-beta1\lib\net45\Newtonsoft.Json.dll + True + + ..\packages\MahApps.Metro.1.1.3-ALPHA210\lib\net45\System.Windows.Interactivity.dll + True + @@ -82,10 +129,24 @@ Designer - + + + + + + + + + + + SplashPage.xaml + + Designer + MSBuild:Compile + MSBuild:Compile Designer @@ -195,7 +256,12 @@ - + + + {a6f20d1a-8523-42ef-bed7-90915047ab44} + Sightstone + + + + + + + + + + + + + + + + + + + pack://application:,,,/MaterialDesignThemes.Wpf;component/Resources/Roboto/#Roboto + + + + + + #40000000 + #50000000 + #60000000 + #60000000 + #60000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient/Windows/ChampSelectPage.xaml.cs b/Sightstone/Windows/ChampSelectPage.xaml.cs similarity index 85% rename from LegendaryClient/Windows/ChampSelectPage.xaml.cs rename to Sightstone/Windows/ChampSelectPage.xaml.cs index 7b06c670..31c08650 100644 --- a/LegendaryClient/Windows/ChampSelectPage.xaml.cs +++ b/Sightstone/Windows/ChampSelectPage.xaml.cs @@ -1,12 +1,12 @@ -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.PlayerSpell; -using LegendaryClient.Logic.Replays; -using LegendaryClient.Logic.Riot; -using LegendaryClient.Logic.Riot.Platform; -using LegendaryClient.Logic.SoundLogic; -using LegendaryClient.Logic.SQLite; -using LegendaryClient.Properties; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.PlayerSpell; +using Sightstone.Logic.Replays; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Platform; +using Sightstone.Logic.SoundLogic; +using Sightstone.Logic.SQLite; +using Sightstone.Properties; using System; using System.Collections.Generic; using System.Globalization; @@ -29,8 +29,10 @@ using agsXMPP.protocol.x.muc; using agsXMPP; using agsXMPP.Collections; +using Sightstone.Logic.MultiUser; +using System.Windows.Media.Imaging; -namespace LegendaryClient.Windows +namespace Sightstone.Windows { /// /// Interaction logic for ChampSelectPage.xaml @@ -62,7 +64,8 @@ public partial class ChampSelectPage private string firstPlayer = null; private Jid jid; private List Skins; - + private RiotCalls RiotCalls; + private UserClient UserClient; #region champs private readonly string[] bandleCityChampions = @@ -132,19 +135,21 @@ public partial class ChampSelectPage "Blitzcrank", "Dr. Mundo", "Janna", "Jinx", "Renekton", "Singed", "Twisted Fate", "Twitch", "Urgot", "Viktor", "Warwick", "Zac" }; + private double lastVolume; #endregion champs public ChampSelectPage(string RoomName, string RoomPassword) { InitializeComponent(); + UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; var Jid = Client.GetChatroomJid(RoomName.Replace("@sec", ""), RoomPassword, false); jid = new Jid(Jid); - Chatroom = new MucManager(Client.XmppConnection); - Client.XmppConnection.OnMessage += XmppConnection_OnMessage; - Client.XmppConnection.OnPresence += XmppConnection_OnPresence; + Chatroom = new MucManager(UserClient.XmppConnection); + UserClient.XmppConnection.OnMessage += XmppConnection_OnMessage; + UserClient.XmppConnection.OnPresence += XmppConnection_OnPresence; Chatroom.AcceptDefaultConfiguration(jid); - Chatroom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, RoomPassword); + Chatroom.JoinRoom(jid, UserClient.LoginPacket.AllSummonerData.Summoner.Name, RoomPassword); } void XmppConnection_OnPresence(object sender, Presence pres) @@ -153,23 +158,23 @@ void XmppConnection_OnPresence(object sender, Presence pres) return; - if (Client.InstaCall) + if (UserClient.InstaCall) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { - Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": " + Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.OrangeRed); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) - tr.Text = Client.CallString.Filter() + Environment.NewLine; + if (UserClient.Filter) + tr.Text = UserClient.CallString.Filter() + Environment.NewLine; else - tr.Text = Client.CallString + Environment.NewLine; + tr.Text = UserClient.CallString + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); - Client.XmppConnection.Send(new Message(jid, Client.CallString)); + UserClient.XmppConnection.Send(new Message(jid, UserClient.CallString)); ChatText.ScrollToEnd(); var t = new Timer { @@ -178,7 +183,7 @@ void XmppConnection_OnPresence(object sender, Presence pres) t.Start(); t.Tick += (o, e) => { - Client.InstaCall = false; + UserClient.InstaCall = false; t.Stop(); }; })); @@ -192,8 +197,8 @@ void XmppConnection_OnPresence(object sender, Presence pres) { if (firstPlayer == pres.From.User) { - Client.XmppConnection.MessageGrabber.Remove(jid); - Client.XmppConnection.OnPresence -= XmppConnection_OnPresence; + UserClient.XmppConnection.MessageGrabber.Remove(jid); + UserClient.XmppConnection.OnPresence -= XmppConnection_OnPresence; } } @@ -218,7 +223,7 @@ void XmppConnection_OnMessage(object sender, Message msg) if (jid.Bare.Contains(msg.From.User)) return; - if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (msg.From.Resource == UserClient.LoginPacket.AllSummonerData.Summoner.Name) return; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => @@ -233,7 +238,7 @@ void XmppConnection_OnMessage(object sender, Message msg) }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = msg.Body.Replace("", "").Filter() + Environment.NewLine; else @@ -251,10 +256,13 @@ public ChampSelectPage Load(Page previousPage) Client.OverlayContainer.Content = null; this.previousPage = previousPage; StartChampSelect(); - if (!Settings.Default.DisableClientSound) + var sound = AmbientChampSelect.CurrentQueueToSoundFile(UserClient.QueueId); + AmbientChampSelect.PlayAmbientChampSelectSound(sound); + + if (Settings.Default.ChampSelectMusicVolume != -1) { - var sound = AmbientChampSelect.CurrentQueueToSoundFile(Client.QueueId); - AmbientChampSelect.PlayAmbientChampSelectSound(sound); + slider.Value = Settings.Default.LoginMusicVolume; + Client.AmbientSoundPlayer.Volume = Settings.Default.LoginMusicVolume / 100; } Client.LastPageContent = Content; Client.runonce = true; @@ -268,7 +276,7 @@ public ChampSelectPage Load(Page previousPage) private void GetLocalRunePages() { - foreach (var item in Client.LocalRunePages) + foreach (var item in UserClient.LocalRunePages) { LocalRuneComboBox.Items.Add(item.Key); } @@ -320,24 +328,24 @@ private async void StartChampSelect() //Get champions and sort alphabetically CanLockIn = false; - ChampList = new List(Client.PlayerChampions); + ChampList = new List(UserClient.PlayerChampions); ChampList.Sort( (x, y) => string.Compare(champions.GetChampion(x.ChampionId) .displayName, champions.GetChampion(y.ChampionId).displayName, StringComparison.Ordinal)); - if (Client.LoginPacket.ClientSystemStates.freeToPlayChampionsForNewPlayersMaxLevel >= - Client.LoginPacket.AllSummonerData.SummonerLevel.Level) + if (UserClient.LoginPacket.ClientSystemStates.freeToPlayChampionsForNewPlayersMaxLevel >= + UserClient.LoginPacket.AllSummonerData.SummonerLevel.Level) foreach (var item in ChampList) { - if (Client.LoginPacket.ClientSystemStates.freeToPlayChampionIdList.Contains(item.ChampionId)) + if (UserClient.LoginPacket.ClientSystemStates.freeToPlayChampionIdList.Contains(item.ChampionId)) item.FreeToPlay = true; else item.FreeToPlay = false; } //Retrieve masteries and runes - MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; - MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; + MyMasteries = UserClient.LoginPacket.AllSummonerData.MasteryBook; + MyRunes = UserClient.LoginPacket.AllSummonerData.SpellBook; //Put masteries & runes into combo boxes int i = 0; @@ -368,13 +376,13 @@ private async void StartChampSelect() QuickLoad = true; //Signal to the server we are in champion select - await RiotCalls.SetClientReceivedGameMessage(Client.GameID, "CHAMP_SELECT_CLIENT"); + await UserClient.calls.SetClientReceivedGameMessage(UserClient.GameID, "CHAMP_SELECT_CLIENT"); GameDTO latestDto = await - RiotCalls.GetLatestGameTimerState(Client.GameID, Client.ChampSelectDTO.GameState, - Client.ChampSelectDTO.PickTurn); + UserClient.calls.GetLatestGameTimerState(UserClient.GameID, UserClient.ChampSelectDTO.GameState, + UserClient.ChampSelectDTO.PickTurn); //Find the game config for timers - configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == latestDto.GameTypeConfigId); + configType = UserClient.LoginPacket.GameTypeConfigs.Find(x => x.Id == latestDto.GameTypeConfigId); if (configType == null) //Invalid config... abort! { QuitCurrentGame(); @@ -384,7 +392,7 @@ private async void StartChampSelect() MessageTextBox = { Text = "Invalid Config ID (" + latestDto.GameTypeConfigId + - "). Report to Eddy5641 [https://github.com/Eddy5641/LegendaryClient/issues/new]" + "). Report to Eddy5641 [https://github.com/Eddy5641/Sightstone/issues/new]" }, MessageTitle = { Content = "Invalid Config" } }; @@ -404,7 +412,7 @@ private async void StartChampSelect() //Get the champions for the other team to ban & sort alpabetically if (latestDto.GameState.ToUpper() == "PRE_CHAMP_SELECT") { - ChampionBanInfoDTO[] champsForBan = await RiotCalls.GetChampionsForBan(); + ChampionBanInfoDTO[] champsForBan = await UserClient.calls.GetChampionsForBan(); ChampionsForBan = new List(champsForBan); ChampionsForBan.Sort( (x, y) => @@ -419,7 +427,7 @@ private async void StartChampSelect() //Start recieving champ select Select_OnMessageReceived(this, latestDto); //Client.OnFixChampSelect += ChampSelect_OnMessageReceived; - Client.RiotConnection.MessageReceived += ChampSelect_OnMessageReceived; + UserClient.RiotConnection.MessageReceived += ChampSelect_OnMessageReceived; } } @@ -474,7 +482,7 @@ private void Select_OnMessageReceived(object sender, object message) if (LatestDto.QueueTypeName == "COUNTER_PICK") //fix for nemesis draft, get your champ from GameDTO { - var selectedChamp = champDto.PlayerChampionSelections.Find(item => item.SummonerInternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName); + var selectedChamp = champDto.PlayerChampionSelections.Find(item => item.SummonerInternalName == UserClient.LoginPacket.AllSummonerData.Summoner.InternalName); ChangeSelectedChampionSkins(selectedChamp.ChampionId); } foreach (PlayerParticipant participant in allParticipants.Select(p => p as PlayerParticipant)) @@ -485,14 +493,14 @@ private void Select_OnMessageReceived(object sender, object message) //If it is our turn to pick if (play.PickTurn == champDto.PickTurn) { - if (play.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) + if (play.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId) { if (Settings.Default.PickBanFocus) Client.MainWin.Focus(); if (Settings.Default.PickBanFlash) Client.MainWin.FlashWindow(); //Allows us to instapick any champ we own. - if (Client.usingInstaPick) + if (UserClient.usingInstaPick) { bool champbanned = false; //disallow picking banned champs @@ -501,24 +509,24 @@ private void Select_OnMessageReceived(object sender, object message) foreach ( BannedChampion x in champDto.BannedChampions.Where( - x => x.ChampionId == Client.SelectChamp)) + x => x.ChampionId == UserClient.SelectChamp)) champbanned = true; //disallow picking picked champs foreach ( PlayerChampionSelectionDTO selection in champDto.PlayerChampionSelections.Where( - selection => selection.ChampionId == Client.SelectChamp)) + selection => selection.ChampionId == UserClient.SelectChamp)) champbanned = true; var temp = new ListViewItem { - Tag = Client.SelectChamp + Tag = UserClient.SelectChamp }; if (!champbanned) ListViewItem_PreviewMouseDown(temp, null); - Client.usingInstaPick = false; + UserClient.usingInstaPick = false; } catch { @@ -540,7 +548,7 @@ PlayerChampionSelectionDTO selection in } } //Otherwise block selection of champions unless in dev mode - if (!Client.Dev) + if (!UserClient.Dev) { ChampionSelectListView.IsHitTestVisible = false; ChampionSelectListView.Opacity = 0.5; @@ -556,7 +564,7 @@ PlayerChampionSelectionDTO selection in if (CountdownTimer != null) CountdownTimer.Stop(); - Client.FixChampSelect(); + UserClient.FixChampSelect(); return; } @@ -625,7 +633,7 @@ ChampionBanInfoDTO banChamps in else if (champDto.GameState == "POST_CHAMP_SELECT") { //Post game has started. Allow trading - CanTradeWith = await RiotCalls.GetPotentialTraders(); + CanTradeWith = await UserClient.calls.GetPotentialTraders(); HasLockedIn = true; GameStatusLabel.Content = "All players have picked!"; if (configType != null) @@ -652,10 +660,10 @@ ChampionBanInfoDTO banChamps in Client.ReturnButton.Visibility = Visibility.Visible; Client.inQueueTimer.Visibility = Visibility.Visible; Client.NotificationGrid.Children.Add(pop); - Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; + UserClient.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; //Client.OnFixChampSelect -= ChampSelect_OnMessageReceived; - Client.GameStatus = "inQueue"; - Client.SetChatHover(); + UserClient.GameStatus = "inQueue"; + UserClient.SetChatHover(); Client.SwitchPage(previousPage); Client.ClearPage(typeof(ChampSelectPage)); @@ -698,7 +706,7 @@ ChampionBanInfoDTO banChamps in try { AllPublicSummonerDataDTO summoner = - await RiotCalls.GetAllPublicSummonerDataByAccount(player.SummonerId); + await UserClient.calls.GetAllPublicSummonerDataByAccount(player.SummonerId); if (summoner.Summoner != null && !string.IsNullOrEmpty(summoner.Summoner.Name)) control.PlayerName.Content = summoner.Summoner.Name; else @@ -746,7 +754,7 @@ ChampionBanInfoDTO banChamps in //If we have locked in render skin select if (!HasLockedIn || selection.SummonerInternalName != - Client.LoginPacket.AllSummonerData.Summoner.InternalName || (Client.Dev && champDto.MapId != 12)) + UserClient.LoginPacket.AllSummonerData.Summoner.InternalName || (UserClient.Dev && champDto.MapId != 12)) continue; if (purpleSide) @@ -835,12 +843,12 @@ ChampionBanInfoDTO banChamps in } else if (message is PlayerCredentialsDto) { - Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; + UserClient.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; #region Launching Game var dto = message as PlayerCredentialsDto; - Client.CurrentGame = dto; + UserClient.CurrentGame = dto; if (HasLaunchedGame) return; @@ -854,15 +862,15 @@ ChampionBanInfoDTO banChamps in { PlatformGameLifecycleDTO n = await - RiotCalls.RetrieveInProgressSpectatorGameInfo( - Client.LoginPacket.AllSummonerData.Summoner.Name); + UserClient.calls.RetrieveInProgressSpectatorGameInfo( + UserClient.LoginPacket.AllSummonerData.Summoner.Name); if (n.GameName != null) { string ip = n.PlayerCredentials.ObserverServerIp + ":" + n.PlayerCredentials.ObserverServerPort; string key = n.PlayerCredentials.ObserverEncryptionKey; var gameId = (int)n.PlayerCredentials.GameId; - new ReplayRecorder(ip, gameId, Client.Region.InternalName, key); + new ReplayRecorder(ip, gameId, UserClient.Region.InternalName, key); } }); } @@ -917,7 +925,7 @@ ChampionBanInfoDTO banChamps in TextInfo text = new CultureInfo("en-US", false).TextInfo; var pop = new NotificationPopup(ChatSubjects.INVITE_STATUS_CHANGED, string.Format("{0} has {1} this trade", tradeDto.RequesterInternalSummonerName, - text.ToTitleCase(tradeDto.State))); + text.ToTitleCase(tradeDto.State)), UserClient); if (tradeDto.State == "BUSY") pop.NotificationTextBox.Text = string.Format("{0} is currently busy", @@ -947,7 +955,7 @@ internal void RenderLockInGrid(PlayerChampionSelectionDTO selection) LockInButton.Content = "Locked In"; - Switch.IsChecked = true; + Switch.IsEnabled = false; ChangeSelectedChampionSkins(selection.ChampionId); } @@ -966,9 +974,9 @@ internal void ChangeSelectedChampionSkins(int selectedChampionId) //Render default skin var defaultSkinItem = new ListViewItem(); var skinImage = new Image(); - if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champion.portraitPath))) + if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", champion.portraitPath))) { - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champion.portraitPath); + string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", champion.portraitPath); skinImage.Source = Client.GetImage(UriSource); skinImage.Width = 191; skinImage.Stretch = Stretch.UniformToFill; @@ -1025,9 +1033,14 @@ from skin in champ.ChampionSkins where skin.Owned select skin) { + if (championSkins.GetSkin(skin.SkinId) == null) + { + Client.Log("Could not find skin : " + skin.SkinId); + continue; + } ListViewItem skinItem = new ListViewItem(); skinImage = new Image(); - UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", championSkins.GetSkin(skin.SkinId).portraitPath); skinImage.Source = Client.GetImage(UriSource); skinImage.Width = 191; @@ -1043,7 +1056,7 @@ where skin.Owned int index = SkinSelectListView.Items.IndexOf((ListViewItem)defaultSkinItem); ListViewItem randomSkinItem = new ListViewItem(); Image randomSkinImage = new Image(); - var src = "/LegendaryClient;component/NONE.png"; + var src = "/Sightstone;component/NONE.png"; randomSkinImage.Source = Client.GetImage(src); randomSkinImage.Width = 191; randomSkinImage.Stretch = Stretch.UniformToFill; @@ -1188,29 +1201,24 @@ internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, Pl //Render summoner spells if (selection.Spell1Id != 0) { - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); - control.SummonerSpell1.Source = Client.GetImage(UriSource); - UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); - control.SummonerSpell2.Source = Client.GetImage(UriSource); + var UriSource = Client.GetSpellIconUri((NameToImage)(int)selection.Spell1Id); + control.SummonerSpell1.Source = new BitmapImage(UriSource); + UriSource = Client.GetSpellIconUri((NameToImage)(int)selection.Spell2Id); + control.SummonerSpell2.Source = new BitmapImage(UriSource); } //Set our summoner spells in client - if (player.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (player.SummonerName == UserClient.LoginPacket.AllSummonerData.Summoner.Name) { - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); - SummonerSpell1Image.Source = Client.GetImage(UriSource); - UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); - SummonerSpell2Image.Source = Client.GetImage(UriSource); + var UriSource = Client.GetSpellIconUri((NameToImage)(int)selection.Spell1Id); + SummonerSpell1Image.Source = new BitmapImage(UriSource); + UriSource = Client.GetSpellIconUri((NameToImage)(int)selection.Spell2Id); + SummonerSpell2Image.Source = new BitmapImage(UriSource); MyChampId = selection.ChampionId; } //Has locked in if (player.PickMode == 2) { - const string UriSource = "/LegendaryClient;component/Locked.png"; - control.LockedInIcon.Source = Client.GetImage(UriSource); + control.LockedInIcon.Visibility = Visibility.Visible; } //Make obvious whos pick turn it is if (player.PickTurn != LatestDto.PickTurn && @@ -1221,7 +1229,7 @@ internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, Pl control.Opacity = 1; //If trading with this player is possible - if (CanTradeWith != null && (CanTradeWith.PotentialTraders.Contains(player.SummonerInternalName) || Client.Dev)) + if (CanTradeWith != null && (CanTradeWith.PotentialTraders.Contains(player.SummonerInternalName) || UserClient.Dev)) control.TradeButton.Visibility = Visibility.Visible; //If this player is duo/trio/quadra queued with players @@ -1239,10 +1247,10 @@ internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, Pl var converter = new BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); - control.TeamRectangle.Fill = brush; + control.TeamRectangle.BorderBrush = brush; control.TeamRectangle.Visibility = Visibility.Visible; } - control.LockedInIcon.Visibility = Visibility.Visible; + control.LockedInIcon.Visibility = Visibility.Hidden; control.TradeButton.Tag = new KeyValuePair(selection, player); control.TradeButton.Click += TradeButton_Click; control.PlayerName.Content = player.SummonerName; @@ -1253,7 +1261,7 @@ internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, Pl private async void TradeButton_Click(object sender, RoutedEventArgs e) { var p = (KeyValuePair)((Button)sender).Tag; - await RiotCalls.AttemptTrade(p.Value.SummonerInternalName, p.Key.ChampionId); + await UserClient.calls.AttemptTrade(p.Value.SummonerInternalName, p.Key.ChampionId); PlayerTradeControl.Visibility = Visibility.Visible; champions myChampion = champions.GetChampion((int)MyChampId); @@ -1278,9 +1286,9 @@ private async void ListViewItem_PreviewMouseDown(object sender, MouseButtonEvent if (item.Tag == null) return; //SelectChampion.SelectChampion(selection.ChampionId)*/ - await RiotCalls.SelectChampion(SelectChampion.SelectChamp((int)item.Tag)); + await UserClient.calls.SelectChampion(SelectChampion.SelectChamp((int)item.Tag)); CanLockIn = true; - Client.ChampId = (int)item.Tag; + UserClient.ChampId = (int)item.Tag; //TODO: Fix stupid animation glitch on left hand side var fadingAnimation = new DoubleAnimation { @@ -1290,7 +1298,7 @@ private async void ListViewItem_PreviewMouseDown(object sender, MouseButtonEvent }; fadingAnimation.Completed += (eSender, eArgs) => { - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", champions.GetChampion((int)item.Tag).splashPath); BackgroundSplash.Source = Client.GetImage(UriSource); fadingAnimation = new DoubleAnimation @@ -1309,7 +1317,7 @@ private async void ListViewItem_PreviewMouseDown(object sender, MouseButtonEvent else if (item.Tag != null) { SearchTextBox.Text = string.Empty; - await RiotCalls.BanChampion((int)item.Tag); + await UserClient.calls.BanChampion((int)item.Tag); } } @@ -1328,20 +1336,20 @@ private async void SkinSelectListView_PreviewMouseDown(object sender, MouseButto int index = new Random().Next(0, Skins.Count); int skinId = Skins[index]; championSkins skin = championSkins.GetSkin(skinId); - await RiotCalls.SelectChampionSkin(skin.championId, skin.id); + await UserClient.calls.SelectChampionSkin(skin.championId, skin.id); var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { Text = "Selected a random skin" + Environment.NewLine }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); - if (Client.Dev) Client.Log("Selected " + skin.displayName + " as skin"); + if (UserClient.Dev) Client.Log("Selected " + skin.displayName + " as skin"); } else if (s != null) { string[] splitItem = s.Split(':'); int championId = Convert.ToInt32(splitItem[1]); champions champion = champions.GetChampion(championId); - await RiotCalls.SelectChampionSkin(championId, 0); + await UserClient.calls.SelectChampionSkin(championId, 0); var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { Text = "Selected Default " + champion.name + " as skin" + Environment.NewLine @@ -1351,7 +1359,7 @@ private async void SkinSelectListView_PreviewMouseDown(object sender, MouseButto else { championSkins skin = championSkins.GetSkin((int)item.Tag); - await RiotCalls.SelectChampionSkin(skin.championId, skin.id); + await UserClient.calls.SelectChampionSkin(skin.championId, skin.id); var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { Text = "Selected " + skin.displayName + " as skin" + Environment.NewLine @@ -1395,12 +1403,12 @@ private void DodgeButton_Click(object sender, RoutedEventArgs e) private async void QuitCurrentGame() { Client.AmbientSoundPlayer.Stop(); - await RiotCalls.QuitGame(); - Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; + await UserClient.calls.QuitGame(); + UserClient.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; Client.ClearPage(typeof(CustomGameLobbyPage)); Client.ClearPage(typeof(CreateCustomGamePage)); - Client.GameStatus = "outOfGame"; - Client.SetChatHover(); + UserClient.GameStatus = "outOfGame"; + UserClient.SetChatHover(); Client.ReturnButton.Visibility = Visibility.Hidden; Client.SwitchPage(Client.MainPage); Client.ClearPage(typeof(ChampSelectPage)); @@ -1408,15 +1416,15 @@ private async void QuitCurrentGame() private async void InGame() { - await RiotCalls.QuitGame(); - Client.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; + await UserClient.calls.QuitGame(); + UserClient.RiotConnection.MessageReceived -= ChampSelect_OnMessageReceived; Client.ClearPage(typeof(CustomGameLobbyPage)); Client.ClearPage(typeof(CreateCustomGamePage)); Client.ClearPage(typeof(FactionsCreateGamePage)); - Client.GameStatus = "inGame"; - Client.timeStampSince = + UserClient.GameStatus = "inGame"; + UserClient.timeStampSince = (DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime()).TotalMilliseconds; - Client.SetChatHover(); + UserClient.SetChatHover(); Client.SwitchPage(new InGame(true)); Client.ClearPage(typeof(ChampSelectPage)); @@ -1429,7 +1437,7 @@ private async void LockInButton_Click(object sender, RoutedEventArgs e) if (!CanLockIn) return; - await RiotCalls.ChampionSelectCompleted(); + await UserClient.calls.ChampionSelectCompleted(); HasLockedIn = true; CanLockIn = false; this.LockInButton.IsEnabled = false; @@ -1437,7 +1445,7 @@ private async void LockInButton_Click(object sender, RoutedEventArgs e) } else { - await RiotCalls.Roll(); + await UserClient.calls.Roll(); HasLockedIn = true; } } @@ -1474,7 +1482,7 @@ private async void MasteryComboBox_SelectionChanged(object sender, SelectionChan int i = 0; var bookDto = new MasteryBookDTO { - SummonerId = Client.LoginPacket.AllSummonerData.Summoner.SumId, + SummonerId = UserClient.LoginPacket.AllSummonerData.Summoner.SumId, BookPages = new List() }; foreach (MasteryBookPageDTO masteryPage in MyMasteries.BookPages) @@ -1499,7 +1507,7 @@ private async void MasteryComboBox_SelectionChanged(object sender, SelectionChan bookDto.BookPages.Add(masteryPage); } if (hasChanged) - await RiotCalls.SaveMasteryBook(bookDto); + await UserClient.calls.SaveMasteryBook(bookDto); } private async void RuneComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) @@ -1531,7 +1539,7 @@ private async void RuneComboBox_SelectionChanged(object sender, SelectionChanged ChatText.ScrollToEnd(); } if (hasChanged) - await RiotCalls.SelectDefaultSpellBookPage(selectedRunePage); + await UserClient.calls.SelectDefaultSpellBookPage(selectedRunePage); } private void ChatButton_Click(object sender, RoutedEventArgs e) @@ -1539,7 +1547,7 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) //Enable dev mode if !~dev is typed in chat if (ChatTextBox.Text == "!~dev") { - if (!Client.Dev) + if (!UserClient.Dev) { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { @@ -1553,17 +1561,17 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { - Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": " + Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = ChatTextBox.Text.Filter() + Environment.NewLine; else tr.Text = ChatTextBox.Text + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); - Client.XmppConnection.Send(new Message(jid, MessageType.chat, ChatTextBox.Text)); + UserClient.XmppConnection.Send(new Message(jid, MessageType.groupchat, ChatTextBox.Text)); ChatTextBox.Text = ""; ChatText.ScrollToEnd(); } @@ -1571,20 +1579,17 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) private void Switch_Click(object sender, RoutedEventArgs e) { - if (!Switch.IsChecked.HasValue) - return; - - if ((bool)Switch.IsChecked) + if (ChampionSelectListView.IsVisible) { - Switch.Content = "Champions"; ChampionSelectListView.Visibility = Visibility.Hidden; AfterChampionSelectGrid.Visibility = Visibility.Visible; + Switch.Content = "Skins"; } else { - Switch.Content = "Skins"; - ChampionSelectListView.Visibility = Visibility.Visible; AfterChampionSelectGrid.Visibility = Visibility.Hidden; + ChampionSelectListView.Visibility = Visibility.Visible; + Switch.Content = "Champions"; } } @@ -1594,21 +1599,21 @@ private async void LocalRuneComboBox_SelectionChanged(object sender, SelectionCh return; int i = 0; - string[] runeIds = Client.LocalRunePages[LocalRuneComboBox.SelectedItem.ToString()].Split(','); + string[] runeIds = UserClient.LocalRunePages[LocalRuneComboBox.SelectedItem.ToString()].Split(','); - var failsafe = Client.LoginPacket.AllSummonerData.SpellBook; + var failsafe = UserClient.LoginPacket.AllSummonerData.SpellBook; try { foreach (string item in runeIds) { - Client.LoginPacket.AllSummonerData.SpellBook.BookPages[RuneComboBox.SelectedIndex].SlotEntries[i].RuneId = Convert.ToInt32(item); + UserClient.LoginPacket.AllSummonerData.SpellBook.BookPages[RuneComboBox.SelectedIndex].SlotEntries[i].RuneId = Convert.ToInt32(item); i++; } - if ((await RiotCalls.SaveSpellBook(Client.LoginPacket.AllSummonerData.SpellBook)).DefaultPage == null) + if ((await UserClient.calls.SaveSpellBook(UserClient.LoginPacket.AllSummonerData.SpellBook)).DefaultPage == null) { - Client.LoginPacket.AllSummonerData.SpellBook = failsafe; + UserClient.LoginPacket.AllSummonerData.SpellBook = failsafe; var pop = new NotifyPlayerPopup("Save failed", "Failed to use local rune page.") { HorizontalAlignment = HorizontalAlignment.Right, @@ -1619,7 +1624,7 @@ private async void LocalRuneComboBox_SelectionChanged(object sender, SelectionCh } catch { - Client.LoginPacket.AllSummonerData.SpellBook = failsafe; + UserClient.LoginPacket.AllSummonerData.SpellBook = failsafe; var pop = new NotifyPlayerPopup("Save failed", "Failed to use local rune page.") { HorizontalAlignment = HorizontalAlignment.Right, @@ -1628,5 +1633,49 @@ private async void LocalRuneComboBox_SelectionChanged(object sender, SelectionCh Client.NotificationGrid.Children.Add(pop); } } + + private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if ((sender as Slider).IsInitialized) + { + Client.AmbientSoundPlayer.Volume = e.NewValue / 100; + Settings.Default.ChampSelectMusicVolume = e.NewValue; + lastVolume = e.OldValue / 100; + if (e.NewValue == 0) + { + //Change to muted icon + muteButton.Data = Geometry.Parse("M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"); + } + else + { + //Change to volume icon + muteButton.Data = Geometry.Parse("M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"); + } + } + } + + private void MuteButton_Click(object sender, RoutedEventArgs e) + { + if ((sender as Button).IsInitialized) + { + if (Client.AmbientSoundPlayer.Volume == 0) + { + if (lastVolume != 0) + { + Client.AmbientSoundPlayer.Volume = lastVolume; + slider.Value = lastVolume * 100; + } + else + { + Client.AmbientSoundPlayer.Volume = 0.5; + slider.Value = 50; + } + } + else + { + slider.Value = 0; + } + } + } } } diff --git a/LegendaryClient/Windows/ChampionDetailsPage.xaml b/Sightstone/Windows/ChampionDetailsPage.xaml similarity index 98% rename from LegendaryClient/Windows/ChampionDetailsPage.xaml rename to Sightstone/Windows/ChampionDetailsPage.xaml index 6908ed59..283ab0d8 100644 --- a/LegendaryClient/Windows/ChampionDetailsPage.xaml +++ b/Sightstone/Windows/ChampionDetailsPage.xaml @@ -1,4 +1,4 @@ - - + diff --git a/LegendaryClient/Windows/ChampionDetailsPage.xaml.cs b/Sightstone/Windows/ChampionDetailsPage.xaml.cs similarity index 91% rename from LegendaryClient/Windows/ChampionDetailsPage.xaml.cs rename to Sightstone/Windows/ChampionDetailsPage.xaml.cs index fa621c36..33bffee2 100644 --- a/LegendaryClient/Windows/ChampionDetailsPage.xaml.cs +++ b/Sightstone/Windows/ChampionDetailsPage.xaml.cs @@ -1,7 +1,8 @@ -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.SQLite; -using LegendaryClient.Properties; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.MultiUser; +using Sightstone.Logic.SQLite; +using Sightstone.Properties; using System; using System.Collections.Generic; using System.IO; @@ -12,7 +13,7 @@ using System.Windows.Media; using System.Windows.Media.Animation; -namespace LegendaryClient.Windows +namespace Sightstone.Windows { /// /// Interaction logic for ChampionDetailsPage.xaml @@ -36,7 +37,7 @@ public ChampionDetailsPage(int championId, int skinId) championSkins skin = championSkins.GetSkin(skinId); SkinName.Content = skin.displayName; - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", skin.splashPath); + string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", skin.splashPath); ChampionImage.Source = Client.GetImage(UriSource); } @@ -68,13 +69,12 @@ public void RenderChampions(int championId) MovementSpeedLabel.Content = string.Format("Speed: {0}", champ.moveSpeed); if (champ.Skins != null) - foreach (Dictionary skins in champ.Skins) + foreach (var skins in champ.Skins) { - int skin = Convert.ToInt32(skins["id"]); + int skin = Convert.ToInt32(skins.Id); var item = new ListViewItem(); var skinImage = new Image(); - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", - championSkins.GetSkin(skin).portraitPath); + string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", skins.PortraitPath); skinImage.Source = Client.GetImage(UriSource); skinImage.Width = 96.25; skinImage.Height = 175; @@ -96,10 +96,10 @@ public void RenderChampions(int championId) AbilityListView.Items.Add(detailAbility); ChampionImage.Source = - Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champ.splashPath)); + Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", champ.splashPath)); - if (champ.Lore != null) - LoreText.Text = champ.Lore.Replace("
", Environment.NewLine); + if (champ.description != null) + LoreText.Text = champ.description; TipsText.Text = string.Format("Tips while playing {0}:{1}{2}{2}{2}Tips while playing aginst {0}:{3}", champ.displayName, champ.tips.Replace("*", Environment.NewLine + "*"), Environment.NewLine, @@ -125,7 +125,7 @@ private void SkinSelectListView_PreviewMouseDown(object sender, MouseButtonEvent }; fadingAnimation.Completed += (eSender, eArgs) => { - string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + string UriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", skin.splashPath); ChampionImage.Source = Client.GetImage(UriSource); fadingAnimation = new DoubleAnimation diff --git a/LegendaryClient/Windows/ChooseProfilePicturePage.xaml b/Sightstone/Windows/ChooseProfilePicturePage.xaml similarity index 96% rename from LegendaryClient/Windows/ChooseProfilePicturePage.xaml rename to Sightstone/Windows/ChooseProfilePicturePage.xaml index d2091804..3e26d906 100644 --- a/LegendaryClient/Windows/ChooseProfilePicturePage.xaml +++ b/Sightstone/Windows/ChooseProfilePicturePage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for ChooseProfilePicturePage.xaml ///
public partial class ChooseProfilePicturePage { + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public ChooseProfilePicturePage() { InitializeComponent(); @@ -23,7 +25,7 @@ public ChooseProfilePicturePage() private async void GetIcons() { SummonerIconInventoryDTO playerIcons = - await RiotCalls.GetSummonerIconInventory(Client.LoginPacket.AllSummonerData.Summoner.SumId); + await UserClient.calls.GetSummonerIconInventory(UserClient.LoginPacket.AllSummonerData.Summoner.SumId); foreach (Icon ic in playerIcons.SummonerIcons) { var champImage = new Image @@ -32,10 +34,8 @@ private async void GetIcons() Width = 64, Margin = new Thickness(5, 5, 5, 5) }; - var UriSource = - new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ic.IconId + ".png"), - UriKind.Absolute); - champImage.Source = new BitmapImage(UriSource); + + champImage.Source = new BitmapImage(Client.GetIconUri(ic.IconId.ToInt())); champImage.Tag = ic.IconId; SummonerIconListView.Items.Add(champImage); } @@ -47,9 +47,7 @@ private async void GetIcons() Width = 64, Margin = new Thickness(5, 5, 5, 5) }; - var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", i + ".png"), - UriKind.Absolute); - champImage.Source = new BitmapImage(UriSource); + champImage.Source = new BitmapImage(Client.GetIconUri(i)); champImage.Tag = i; SummonerIconListView.Items.Add(champImage); } @@ -66,9 +64,9 @@ private async void SetButton_Click(object sender, RoutedEventArgs e) { var m = (Image) SummonerIconListView.SelectedItem; int summonerIcon = Convert.ToInt32(m.Tag); - await RiotCalls.UpdateProfileIconId(summonerIcon); - Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId = summonerIcon; - Client.SetChatHover(); + await UserClient.calls.UpdateProfileIconId(summonerIcon); + UserClient.LoginPacket.AllSummonerData.Summoner.ProfileIconId = summonerIcon; + UserClient.SetChatHover(); var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summonerIcon + ".png"), UriKind.RelativeOrAbsolute); @@ -76,7 +74,7 @@ private async void SetButton_Click(object sender, RoutedEventArgs e) Client.MainPageProfileImage.Source = new BitmapImage(UriSource); } Client.OverlayContainer.Visibility = Visibility.Hidden; - Client.done = true; + UserClient.done = true; } } } \ No newline at end of file diff --git a/LegendaryClient/Windows/CreateCustomGamePage.xaml b/Sightstone/Windows/CreateCustomGamePage.xaml similarity index 98% rename from LegendaryClient/Windows/CreateCustomGamePage.xaml rename to Sightstone/Windows/CreateCustomGamePage.xaml index 78dacccb..08536eab 100644 --- a/LegendaryClient/Windows/CreateCustomGamePage.xaml +++ b/Sightstone/Windows/CreateCustomGamePage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for CreateCustomGamePage.xaml @@ -17,12 +18,13 @@ namespace LegendaryClient.Windows public partial class CreateCustomGamePage { private readonly bool initFinished; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public CreateCustomGamePage() { InitializeComponent(); - Client.Whitelist = new List(); - NameTextBox.Text = Client.LoginPacket.AllSummonerData.Summoner.Name + "'s game"; + UserClient.Whitelist = new List(); + NameTextBox.Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + "'s game"; initFinished = true; } @@ -30,7 +32,7 @@ private async void CreateGameButton_Click(object sender, RoutedEventArgs e) { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = GenerateGameConfig(); - CreatedGame(await RiotCalls.CreatePracticeGame(gameConfig)); + CreatedGame(await UserClient.calls.CreatePracticeGame(gameConfig)); } private PracticeGameConfig GenerateGameConfig() @@ -128,16 +130,16 @@ private void CreatedGame(GameDTO result) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { - if (result.Name == null) + if (result == null) { NameInvalidLabel.Visibility = Visibility.Visible; NameInvalidLabel.Content = "Name is already taken!"; } else { - Client.GameID = result.Id; - Client.GameName = result.Name; - Client.GameLobbyDTO = result; + UserClient.GameID = result.Id; + UserClient.GameName = result.Name; + UserClient.GameLobbyDTO = result; Client.SwitchPage(new CustomGameLobbyPage()); } })); @@ -173,10 +175,10 @@ private void WhitelistAddButton_Click(object sender, RoutedEventArgs e) if (string.IsNullOrWhiteSpace(WhiteListTextBox.Text)) return; - if (Client.Whitelist.Contains(WhiteListTextBox.Text.ToLower())) + if (UserClient.Whitelist.Contains(WhiteListTextBox.Text.ToLower())) return; - Client.Whitelist.Add(WhiteListTextBox.Text.ToLower()); + UserClient.Whitelist.Add(WhiteListTextBox.Text.ToLower()); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { WhitelistListBox.Items.Add(WhiteListTextBox.Text); @@ -194,10 +196,10 @@ private void WhitelistRemoveButton_Click(object sender, RoutedEventArgs e) { if (WhitelistListBox.SelectedIndex != -1) { - if (Client.Whitelist.Count == 1) + if (UserClient.Whitelist.Count == 1) WhitelistRemoveButton.IsEnabled = false; - Client.Whitelist.Remove(WhitelistListBox.SelectedValue.ToString().ToLower()); + UserClient.Whitelist.Remove(WhitelistListBox.SelectedValue.ToString().ToLower()); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => WhitelistListBox.Items.Remove(WhitelistListBox.SelectedValue))); } diff --git a/LegendaryClient/Windows/CreateSummonerNameOverlay.xaml b/Sightstone/Windows/CreateSummonerNameOverlay.xaml similarity index 95% rename from LegendaryClient/Windows/CreateSummonerNameOverlay.xaml rename to Sightstone/Windows/CreateSummonerNameOverlay.xaml index 45b6ad85..aba27928 100644 --- a/LegendaryClient/Windows/CreateSummonerNameOverlay.xaml +++ b/Sightstone/Windows/CreateSummonerNameOverlay.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for CreateSummonerNameOverlay.xaml ///
public partial class CreateSummonerNameOverlay { - public CreateSummonerNameOverlay() + static UserClient UserClient; + public CreateSummonerNameOverlay(UserClient client) { InitializeComponent(); + UserClient = client; MessageTextBox.Text = "Your Summoner Name is how other players will know you.\n * Must be 3-16 characters in length\n * Letters, numbers and spaces are allowed\n * Must not contain profanity\n * Must not include the word \"Riot\" (reserved for Riot employees)"; } @@ -20,10 +23,10 @@ private async void AcceptButton_Click(object sender, RoutedEventArgs e) { if (UsernameTextBox.Text.Length > 0) { - if (await RiotCalls.CreateDefaultSummoner(UsernameTextBox.Text) != null) + if (await UserClient.calls.CreateDefaultSummoner(UsernameTextBox.Text) != null) { Client.OverlayContainer.Visibility = Visibility.Hidden; - Client.done = true; + UserClient.done = true; } else MessageBox.Show("That username is invalid."); diff --git a/LegendaryClient/Windows/CustomGameListingPage.xaml b/Sightstone/Windows/CustomGameListingPage.xaml similarity index 98% rename from LegendaryClient/Windows/CustomGameListingPage.xaml rename to Sightstone/Windows/CustomGameListingPage.xaml index c0e1b99c..46f288e7 100644 --- a/LegendaryClient/Windows/CustomGameListingPage.xaml +++ b/Sightstone/Windows/CustomGameListingPage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for CustomGameListingPage.xaml @@ -15,6 +16,7 @@ namespace LegendaryClient.Windows public partial class CustomGameListingPage { private readonly List allItems = new List(); + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public CustomGameListingPage() { @@ -36,7 +38,7 @@ private async void GetGames() { CustomGameListView.Items.Clear(); allItems.Clear(); - PracticeGameSearchResult[] games = await RiotCalls.ListAllPracticeGames(); + PracticeGameSearchResult[] games = await UserClient.calls.ListAllPracticeGames(); foreach (GameItem item in games.Select(game => new GameItem { GameName = game.Name, @@ -87,12 +89,12 @@ private void JoinGameButton_Click(object sender, RoutedEventArgs e) gameName = item.GameName; } if (!string.IsNullOrEmpty(PasswordTextBox.Text)) - RiotCalls.JoinGame(gameId, PasswordTextBox.Text); + UserClient.calls.JoinGame(gameId, PasswordTextBox.Text); else - RiotCalls.JoinGame(gameId); + UserClient.calls.JoinGame(gameId); - Client.GameID = gameId; - Client.GameName = gameName; + UserClient.GameID = gameId; + UserClient.GameName = gameName; Client.SwitchPage(new CustomGameLobbyPage()); } diff --git a/LegendaryClient/Windows/CustomGameLobbyPage.xaml b/Sightstone/Windows/CustomGameLobbyPage.xaml similarity index 99% rename from LegendaryClient/Windows/CustomGameLobbyPage.xaml rename to Sightstone/Windows/CustomGameLobbyPage.xaml index e942c1a3..6ad3b208 100644 --- a/LegendaryClient/Windows/CustomGameLobbyPage.xaml +++ b/Sightstone/Windows/CustomGameLobbyPage.xaml @@ -1,5 +1,5 @@  /// Interaction logic for CustomGameLobbyPage.xaml @@ -37,22 +38,23 @@ public partial class CustomGameLobbyPage private double OptomisticLock; private MucManager newRoom; private static Jid roomJid; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public CustomGameLobbyPage(GameDTO gameLobby = null) { InitializeComponent(); //Hopefully this works better - foreach (var champs in Client.PlayerChampions.Where(champs => champs.BotEnabled)) + foreach (var champs in UserClient.PlayerChampions.Where(champs => champs.BotEnabled)) bots.Add(champs.ChampionId); - GameName.Content = Client.GameName; - Client.RiotConnection.MessageReceived += GameLobby_OnMessageReceived; + GameName.Content = UserClient.GameName; + UserClient.RiotConnection.MessageReceived += GameLobby_OnMessageReceived; //If client has created game use initial DTO - if (Client.GameLobbyDTO != null) - Lobby_OnMessageReceived(null, Client.GameLobbyDTO); + if (UserClient.GameLobbyDTO != null) + Lobby_OnMessageReceived(null, UserClient.GameLobbyDTO); else { - Client.GameLobbyDTO = gameLobby; - Lobby_OnMessageReceived(null, Client.GameLobbyDTO); + UserClient.GameLobbyDTO = gameLobby; + Lobby_OnMessageReceived(null, UserClient.GameLobbyDTO); } Client.InviteListView = InviteListView; Client.CurrentPage = this; @@ -82,7 +84,7 @@ private void Lobby_OnMessageReceived(object sender, object message) BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); - GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); + GameTypeConfigDTO configType = UserClient.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; @@ -90,12 +92,12 @@ private void Lobby_OnMessageReceived(object sender, object message) string obfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt64(dto.Id), ChatPrefixes.Arranging_Practice); string Jid = Client.GetChatroomJid(obfuscatedName, dto.RoomPassword, false); - newRoom = new MucManager(Client.XmppConnection); - Client.XmppConnection.OnMessage +=XmppConnection_OnMessage; - Client.XmppConnection.OnPresence += XmppConnection_OnPresence; + newRoom = new MucManager(UserClient.XmppConnection); + UserClient.XmppConnection.OnMessage +=XmppConnection_OnMessage; + UserClient.XmppConnection.OnPresence += XmppConnection_OnPresence; roomJid = new Jid(Jid); newRoom.AcceptDefaultConfiguration(roomJid); - newRoom.JoinRoom(roomJid, Client.LoginPacket.AllSummonerData.Summoner.Name); + newRoom.JoinRoom(roomJid, UserClient.LoginPacket.AllSummonerData.Summoner.Name); } switch (dto.GameState) { @@ -115,18 +117,18 @@ private void Lobby_OnMessageReceived(object sender, object message) var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); - Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; - StartGameButton.IsEnabled = Client.isOwnerOfGame; - AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; - AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; + UserClient.isOwnerOfGame = dto.OwnerSummary.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId; + StartGameButton.IsEnabled = UserClient.isOwnerOfGame; + AddBotBlueTeam.IsEnabled = UserClient.isOwnerOfGame; + AddBotPurpleTeam.IsEnabled = UserClient.isOwnerOfGame; BlueTeamListView.Items.Add(lobbyPlayer); - if (Client.Whitelist.Count <= 0) + if (UserClient.Whitelist.Count <= 0) continue; - if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) - await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId); + if (!UserClient.Whitelist.Contains(player.SummonerName.ToLower())) + await UserClient.calls.BanUserFromGame(UserClient.GameID, player.AccountId); } else if (playerTeam is BotParticipant) { @@ -143,18 +145,18 @@ private void Lobby_OnMessageReceived(object sender, object message) var lobbyPlayer = new CustomLobbyPlayer(); var player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); - Client.isOwnerOfGame = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; - StartGameButton.IsEnabled = Client.isOwnerOfGame; - AddBotBlueTeam.IsEnabled = Client.isOwnerOfGame; - AddBotPurpleTeam.IsEnabled = Client.isOwnerOfGame; + UserClient.isOwnerOfGame = dto.OwnerSummary.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId; + StartGameButton.IsEnabled = UserClient.isOwnerOfGame; + AddBotBlueTeam.IsEnabled = UserClient.isOwnerOfGame; + AddBotPurpleTeam.IsEnabled = UserClient.isOwnerOfGame; PurpleTeamListView.Items.Add(lobbyPlayer); - if (Client.Whitelist.Count <= 0) + if (UserClient.Whitelist.Count <= 0) continue; - if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) - await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId); + if (!UserClient.Whitelist.Contains(player.SummonerName.ToLower())) + await UserClient.calls.BanUserFromGame(UserClient.GameID, player.AccountId); } else if (playerTeam is BotParticipant) { @@ -166,7 +168,7 @@ private void Lobby_OnMessageReceived(object sender, object message) } foreach (GameObserver observer in dto.Observers) { - if (observer.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) + if (observer.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId) isSpectator = true; var spectatorItem = new CustomLobbyObserver(); @@ -194,11 +196,11 @@ private void Lobby_OnMessageReceived(object sender, object message) case "CHAMP_SELECT": if (!LaunchedTeamSelect) { - Client.ChampSelectDTO = dto; + UserClient.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this)); - Client.GameStatus = "championSelect"; - Client.SetChatHover(); + UserClient.GameStatus = "championSelect"; + UserClient.SetChatHover(); LaunchedTeamSelect = true; } break; @@ -222,10 +224,10 @@ void XmppConnection_OnPresence(object sender, Presence pres) void XmppConnection_OnMessage(object sender, Message msg) { - if (roomJid.Bare.Contains(msg.From.User)) + if (msg.From.Resource == UserClient.LoginPacket.AllSummonerData.Summoner.Name) return; - if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (msg.From.Resource == UserClient.LoginPacket.AllSummonerData.Summoner.Name) return; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => @@ -239,7 +241,7 @@ void XmppConnection_OnMessage(object sender, Message msg) }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = msg.Body.Replace("", "").Filter() + Environment.NewLine; else tr.Text = msg.Body.Replace("", "") + Environment.NewLine; @@ -258,17 +260,17 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { - Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": " + Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = ChatTextBox.Text.Filter() + Environment.NewLine; else tr.Text = ChatTextBox.Text + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); - Client.XmppConnection.Send(new Message(roomJid, MessageType.groupchat, ChatTextBox.Text)); + UserClient.XmppConnection.Send(new Message(roomJid, MessageType.groupchat, ChatTextBox.Text)); ChatTextBox.Text = ""; } @@ -281,14 +283,14 @@ private CustomLobbyPlayer RenderPlayer(PlayerParticipant player, bool IsOwner) Content = player.SummonerName } }; - var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", player.ProfileIconId + ".png"), UriKind.RelativeOrAbsolute); + var UriSource = Client.GetIconUri(player.ProfileIconId); lobbyPlayer.ProfileImage.Source = new BitmapImage(UriSource); if (IsOwner) lobbyPlayer.OwnerLabel.Visibility = Visibility.Visible; lobbyPlayer.Width = 400; lobbyPlayer.Margin = new Thickness(0, 0, 0, 5); - if ((player.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) || (player.SummonerId != Client.LoginPacket.AllSummonerData.Summoner.SumId && !Client.isOwnerOfGame)) + if ((player.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId) || (player.SummonerId != UserClient.LoginPacket.AllSummonerData.Summoner.SumId && !UserClient.isOwnerOfGame)) lobbyPlayer.BanButton.Visibility = Visibility.Hidden; lobbyPlayer.BanButton.Tag = player; @@ -301,7 +303,7 @@ private BotControl RenderBot(BotParticipant BotPlayer) { var botPlayer = new BotControl(); champions champ = champions.GetChampion(BotPlayer.SummonerInternalName.Split('_')[1]); - var Source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", champ.name + ".png")); + var Source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", champ.name + "_Square_0.png")); botPlayer.Width = 400; botPlayer.Margin = new Thickness(0, 0, 0, 5); @@ -309,31 +311,42 @@ private BotControl RenderBot(BotParticipant BotPlayer) botPlayer.ProfileImage.Source = new BitmapImage(Source); botPlayer.blueSide = BotPlayer.SummonerInternalName.Split('_')[2] == "100"; botPlayer.difficulty = BotPlayer.BotSkillLevel; - botPlayer.cmbSelectDificulty.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; + botPlayer.cmbSelectDificulty.Visibility = UserClient.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectDificulty.Items.Add("Beginner"); botPlayer.cmbSelectDificulty.Items.Add("Intermediate"); botPlayer.cmbSelectDificulty.Items.Add("Doom"); botPlayer.cmbSelectDificulty.Items.Add("Intro"); botPlayer.cmbSelectDificulty.SelectedIndex = BotPlayer.BotSkillLevel; + champ.Skins.Sort((x, y) => { return x.Num.CompareTo(y.Num); }); + foreach (var skin in champ.Skins) + botPlayer.cmbSelectSkin.Items.Add(skin.Name); foreach (int bot in bots) botPlayer.cmbSelectChamp.Items.Add(champions.GetChampion(bot).name); - botPlayer.cmbSelectChamp.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; + botPlayer.cmbSelectSkin.SelectedIndex = BotPlayer.LastSelectedSkinIndex; + + botPlayer.cmbSelectChamp.Visibility = UserClient.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectChamp.SelectedItem = champ.name; - botPlayer.BanButton.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; + botPlayer.BanButton.Visibility = UserClient.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.BanButton.Tag = BotPlayer; botPlayer.BanButton.Click += KickAndBan_Click; botPlayer.cmbSelectChamp.SelectionChanged += async (a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); - await RiotCalls.RemoveBotChampion(champ.id, BotPlayer); + await UserClient.calls.RemoveBotChampion(champ.id, BotPlayer); AddBot(c.id, botPlayer.blueSide, botPlayer.difficulty); }; botPlayer.cmbSelectDificulty.SelectionChanged += async (a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); - await RiotCalls.RemoveBotChampion(champ.id, BotPlayer); - AddBot(c.id, botPlayer.blueSide, botPlayer.cmbSelectDificulty.SelectedIndex); + await UserClient.calls.RemoveBotChampion(champ.id, BotPlayer); + AddBot(c.id, botPlayer.blueSide, botPlayer.cmbSelectDificulty.SelectedIndex, botPlayer.cmbSelectSkin.SelectedIndex); + }; + botPlayer.cmbSelectSkin.SelectionChanged += async (a, b) => + { + champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); + await UserClient.calls.RemoveBotChampion(champ.id, BotPlayer); + AddBot(c.id, botPlayer.blueSide, botPlayer.cmbSelectDificulty.SelectedIndex, botPlayer.cmbSelectSkin.SelectedIndex); }; return botPlayer; @@ -353,7 +366,7 @@ private CustomLobbyObserver RenderObserver(GameObserver observer) lobbyPlayer.Width = 250; lobbyPlayer.Margin = new Thickness(0, 0, 0, 5); - if ((observer.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) || (observer.SummonerId != Client.LoginPacket.AllSummonerData.Summoner.SumId && !Client.isOwnerOfGame)) + if ((observer.SummonerId == UserClient.LoginPacket.AllSummonerData.Summoner.SumId) || (observer.SummonerId != UserClient.LoginPacket.AllSummonerData.Summoner.SumId && !UserClient.isOwnerOfGame)) lobbyPlayer.BanButton.Visibility = Visibility.Hidden; lobbyPlayer.BanButton.Tag = observer; @@ -369,12 +382,12 @@ private async void KickAndBanObserver_Click(object sender, RoutedEventArgs e) return; var player = button.Tag as GameObserver; - await RiotCalls.BanObserverFromGame(Client.GameID, player.AccountId); + await UserClient.calls.BanObserverFromGame(UserClient.GameID, player.AccountId); } private async void QuitGameButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.QuitGame(); + await UserClient.calls.QuitGame(); Client.ReturnButton.Visibility = Visibility.Hidden; Client.SwitchPage(Client.MainPage); Client.ClearPage(typeof(CustomGameLobbyPage)); //Clear pages @@ -383,7 +396,7 @@ private async void QuitGameButton_Click(object sender, RoutedEventArgs e) private async void SwitchTeamsButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.SwitchTeams(Client.GameID); + await UserClient.calls.SwitchTeams(UserClient.GameID); } private static async void KickAndBan_Click(object sender, RoutedEventArgs e) @@ -396,7 +409,7 @@ private static async void KickAndBan_Click(object sender, RoutedEventArgs e) if (player != null) { PlayerParticipant banPlayer = player; - await RiotCalls.BanUserFromGame(Client.GameID, banPlayer.AccountId); + await UserClient.calls.BanUserFromGame(UserClient.GameID, banPlayer.AccountId); } else { @@ -405,13 +418,13 @@ private static async void KickAndBan_Click(object sender, RoutedEventArgs e) return; BotParticipant banPlayer = tag; - await RiotCalls.RemoveBotChampion(champions.GetChampion(banPlayer.SummonerInternalName.Split('_')[1]).id, banPlayer); + await UserClient.calls.RemoveBotChampion(champions.GetChampion(banPlayer.SummonerInternalName.Split('_')[1]).id, banPlayer); } } private async void StartGameButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.StartChampionSelection(Client.GameID, OptomisticLock); + await UserClient.calls.StartChampionSelection(UserClient.GameID, OptomisticLock); } public static string GetGameMode(int i) @@ -447,7 +460,7 @@ public static string GetGameMode(int i) return "One for All";*/ default: - return Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == i).Name; + return UserClient.LoginPacket.GameTypeConfigs.Find(x => x.Id == i).Name; } } @@ -459,7 +472,7 @@ private static int GetRandomChampInt() return bots[r]; } - private static async void AddBot(int id, bool blueSide, int difficulty) + private static async void AddBot(int id, bool blueSide, int difficulty, int skinIndex = 0) { int champint = (id == 0 ? GetRandomChampInt() : id); champions champions = champions.GetChampion(champint); @@ -472,14 +485,17 @@ private static async void AddBot(int id, bool blueSide, int difficulty) DisplayName = champions.displayName }; - List skinlist = (from Dictionary skins in champions.Skins - select new ChampionSkinDTO - { + List skinlist = new List(); + foreach(var skins in champions.Skins) + { + skinlist.Add(new ChampionSkinDTO { ChampionId = champint, - SkinId = Convert.ToInt32(skins["id"]), - SkinIndex = Convert.ToInt32(skins["num"]), + SkinId = skins.Id, + SkinIndex = skins.Num, StillObtainable = true - }).ToList(); + }); + } + champDTO.ChampionSkins = skinlist; var par = new BotParticipant @@ -492,7 +508,8 @@ private static async void AddBot(int id, bool blueSide, int difficulty) Badges = 0, TeamName = null, Team = 0, - SummonerName = champions.displayName + " bot" + SummonerName = champions.displayName + " bot", + LastSelectedSkinIndex = skinIndex }; if (blueSide) { @@ -523,7 +540,7 @@ private static async void AddBot(int id, bool blueSide, int difficulty) par.BotSkillLevel = difficulty; break; } - await RiotCalls.SelectBotChampion(champint, par); + await UserClient.calls.SelectBotChampion(champint, par); } private void AddBotBlueTeam_Click(object sender, RoutedEventArgs e) @@ -538,17 +555,17 @@ private void AddBotPurpleTeam_Click(object sender, RoutedEventArgs e) private async void SpectatorButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.SwitchPlayerToObserver(Client.GameID); + await UserClient.calls.SwitchPlayerToObserver(UserClient.GameID); } private async void JoinPurpleTeamFromSpectator_Click(object sender, RoutedEventArgs e) { - await RiotCalls.SwitchObserverToPlayer(Client.GameID, 200); + await UserClient.calls.SwitchObserverToPlayer(UserClient.GameID, 200); } private async void JoinBlueTeamFromSpectator_Click(object sender, RoutedEventArgs e) { - await RiotCalls.SwitchObserverToPlayer(Client.GameID, 100); + await UserClient.calls.SwitchObserverToPlayer(UserClient.GameID, 100); } } } diff --git a/LegendaryClient/Windows/EndOfGamePage.xaml b/Sightstone/Windows/EndOfGamePage.xaml similarity index 99% rename from LegendaryClient/Windows/EndOfGamePage.xaml rename to Sightstone/Windows/EndOfGamePage.xaml index dfd85645..56b28a57 100644 --- a/LegendaryClient/Windows/EndOfGamePage.xaml +++ b/Sightstone/Windows/EndOfGamePage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for EndOfGamePage.xaml @@ -34,22 +35,23 @@ public partial class EndOfGamePage private readonly MucManager newRoom; private string MatchStatsOnline; private readonly string RoomJid; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public EndOfGamePage(EndOfGameStats statistics) { InitializeComponent(); + UserClient.RiotConnection.MessageReceived += RiotConnection_MessageReceived; RenderStats(statistics); Client.SwitchPage(Client.MainPage); Client.runonce = false; - Client.ChampId = -1; + UserClient.ChampId = -1; RoomJid = Client.GetChatroomJid(statistics.RoomName, statistics.RoomPassword, false); - newRoom = new MucManager(Client.XmppConnection); - Client.XmppConnection.OnMessage += XmppConnection_OnMessage; - Client.XmppConnection.OnPresence += XmppConnection_OnPresence; - Client.RiotConnection.MessageReceived += RiotConnection_MessageReceived; + newRoom = new MucManager(UserClient.XmppConnection); + UserClient.XmppConnection.OnMessage += XmppConnection_OnMessage; + UserClient.XmppConnection.OnPresence += XmppConnection_OnPresence; newRoom.AcceptDefaultConfiguration(new Jid(RoomJid)); - newRoom.JoinRoom(new Jid(RoomJid), Client.LoginPacket.AllSummonerData.Summoner.Name); + newRoom.JoinRoom(new Jid(RoomJid), UserClient.LoginPacket.AllSummonerData.Summoner.Name); } void RiotConnection_MessageReceived(object sender, RtmpSharp.Messaging.MessageReceivedEventArgs e) @@ -96,7 +98,7 @@ void XmppConnection_OnMessage(object sender, Message msg) if (RoomJid.Contains(msg.From.User)) return; - if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (msg.From.Resource == UserClient.LoginPacket.AllSummonerData.Summoner.Name) return; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { @@ -109,7 +111,7 @@ void XmppConnection_OnMessage(object sender, Message msg) }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = msg.Body.Replace("", "").Filter() + Environment.NewLine; else @@ -125,11 +127,11 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { - Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": " + Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (UserClient.Filter) tr.Text = ChatTextBox.Text.Filter() + Environment.NewLine; else tr.Text = ChatTextBox.Text + Environment.NewLine; @@ -138,7 +140,7 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) if (string.IsNullOrEmpty(ChatTextBox.Text)) return; - Client.XmppConnection.Send(new Message(new Jid(RoomJid), MessageType.groupchat, ChatTextBox.Text)); + UserClient.XmppConnection.Send(new Message(new Jid(RoomJid), MessageType.groupchat, ChatTextBox.Text)); ChatTextBox.Text = ""; ChatText.ScrollToEnd(); } @@ -150,10 +152,10 @@ private void RenderStats(EndOfGameStats statistics) ModeLabel.Content = statistics.GameMode; TypeLabel.Content = statistics.GameType; // Add Garena TW match history - if (Client.Garena && !string.IsNullOrEmpty(Settings.Default.DefaultGarenaRegion) && Settings.Default.DefaultGarenaRegion == "TW") + if (UserClient.Garena && !string.IsNullOrEmpty(Settings.Default.DefaultGarenaRegion) && Settings.Default.DefaultGarenaRegion == "TW") MatchStatsOnline = string.Format("http://lol.moa.tw/summoner/show/{0}#tabs-recentgame2", statistics.SummonerName.Replace(" ", "_")); else - MatchStatsOnline = "http://matchhistory.na.leagueoflegends.com/en/#match-details/" + Client.Region.InternalName + "/" + statistics.ReportGameId + "/" + statistics.UserId; + MatchStatsOnline = "http://matchhistory.na.leagueoflegends.com/en/#match-details/" + UserClient.Region.InternalName + "/" + statistics.ReportGameId + "/" + statistics.UserId; GainedIP.Content = "+" + statistics.IpEarned + " IP"; TotalIP.Content = statistics.IpTotal.ToString(CultureInfo.InvariantCulture).Replace(".0", "") + " IP Total"; @@ -168,27 +170,16 @@ private void RenderStats(EndOfGameStats statistics) playerStats.ChampImage.Source = champ.icon; playerStats.ChampLabel.Content = champ.name; playerStats.PlayerLabel.Content = summary.SummonerName; - if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell1Id)))) - { - var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell1Id)), UriKind.Absolute); - playerStats.Spell1Image.Source = new BitmapImage(UriSource); - } - else - Client.Log(SummonerSpell.GetSpellImageName((int)summary.Spell1Id) + " is missing"); - if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell2Id)))) - { - var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell2Id)), UriKind.Absolute); - playerStats.Spell2Image.Source = new BitmapImage(UriSource); - } - else - Client.Log(SummonerSpell.GetSpellImageName((int)summary.Spell2Id) + " is missing"); + playerStats.Spell1Image.Source = new BitmapImage(Client.GetSpellIconUri((NameToImage)(int)summary.Spell1Id)); + playerStats.Spell2Image.Source = new BitmapImage(Client.GetSpellIconUri((NameToImage)(int)summary.Spell2Id)); + double championsKilled = 0; double assists = 0; double deaths = 0; bool victory = false; foreach (RawStatDTO stat in summary.Statistics.Where(stat => stat.StatTypeName.ToLower() == "win")) { - if (summary.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (summary.SummonerName == UserClient.LoginPacket.AllSummonerData.Summoner.Name) { victory = true; GameResultLabel.Content = "Victory"; @@ -204,7 +195,7 @@ private void RenderStats(EndOfGameStats statistics) } else { - if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30) + if (UserClient.LoginPacket.AllSummonerData.SummonerLevel.Level < 30) { GainedXP.Content = "+" + statistics.ExperienceEarned + game; TotalXP.Content = statistics.ExperienceTotal + game; @@ -221,13 +212,9 @@ private void RenderStats(EndOfGameStats statistics) if (stat.StatTypeName.StartsWith("ITEM") && Math.Abs(stat.Value) > 0) { var item = new Image(); - if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png"))) - { - var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png"), UriKind.Absolute); - item.Source = new BitmapImage(UriSource); - } - else - Client.Log(stat.Value + ".png is missing"); + item.Source = Client.GetItemIcon(stat.Value.ToInt()); + + playerStats.ItemsListView.Items.Add(item); } switch (stat.StatTypeName) @@ -271,7 +258,7 @@ private void RenderStats(EndOfGameStats statistics) return; var skinSource = - new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", skin.splashPath), + new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "items", "champions", skin.splashPath), UriKind.Absolute); SkinImage.Source = new BitmapImage(skinSource); } @@ -282,8 +269,8 @@ private void RenderStats(EndOfGameStats statistics) private void CloseButton_Click(object sender, RoutedEventArgs e) { - Client.RiotConnection.MessageReceived -= RiotConnection_MessageReceived; - newRoom.LeaveRoom(new Jid(RoomJid), Client.LoginPacket.AllSummonerData.Summoner.Name); + UserClient.RiotConnection.MessageReceived -= RiotConnection_MessageReceived; + newRoom.LeaveRoom(new Jid(RoomJid), UserClient.LoginPacket.AllSummonerData.Summoner.Name); Client.OverlayContainer.Visibility = Visibility.Hidden; Client.ClearPage(typeof(EndOfGamePage)); } diff --git a/LegendaryClient/Windows/FactionsCreateGamePage.xaml b/Sightstone/Windows/FactionsCreateGamePage.xaml similarity index 98% rename from LegendaryClient/Windows/FactionsCreateGamePage.xaml rename to Sightstone/Windows/FactionsCreateGamePage.xaml index 01222619..3e8e3e99 100644 --- a/LegendaryClient/Windows/FactionsCreateGamePage.xaml +++ b/Sightstone/Windows/FactionsCreateGamePage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for FactionsCreateGamePage.xaml ///
public partial class FactionsCreateGamePage { + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public FactionsCreateGamePage() { InitializeComponent(); - Client.Whitelist = new List(); - NameTextBox.Text = Client.LoginPacket.AllSummonerData.Summoner.Name + "'s game"; + UserClient.Whitelist = new List(); + NameTextBox.Text = UserClient.LoginPacket.AllSummonerData.Summoner.Name + "'s game"; } private async void CreateGameButton_Click(object sender, RoutedEventArgs e) { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = GenerateGameConfig(); - CreatedGame(await RiotCalls.CreatePracticeGame(gameConfig)); + CreatedGame(await UserClient.calls.CreatePracticeGame(gameConfig)); } private PracticeGameConfig GenerateGameConfig() @@ -144,9 +146,9 @@ private void CreatedGame(GameDTO result) } else { - Client.GameID = result.Id; - Client.GameName = result.Name; - Client.GameLobbyDTO = result; + UserClient.GameID = result.Id; + UserClient.GameName = result.Name; + UserClient.GameLobbyDTO = result; Client.ClearPage(typeof(FactionsGameLobbyPage)); Client.SwitchPage(new FactionsGameLobbyPage()); } @@ -179,10 +181,10 @@ private void WhitelistAddButton_Click(object sender, RoutedEventArgs e) if (string.IsNullOrWhiteSpace(WhiteListTextBox.Text)) return; - if (Client.Whitelist.Contains(WhiteListTextBox.Text.ToLower())) + if (UserClient.Whitelist.Contains(WhiteListTextBox.Text.ToLower())) return; - Client.Whitelist.Add(WhiteListTextBox.Text.ToLower()); + UserClient.Whitelist.Add(WhiteListTextBox.Text.ToLower()); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { WhitelistListBox.Items.Add(WhiteListTextBox.Text); @@ -201,10 +203,10 @@ private void WhitelistRemoveButton_Click(object sender, RoutedEventArgs e) if (WhitelistListBox.SelectedIndex == -1) return; - if (Client.Whitelist.Count == 1) + if (UserClient.Whitelist.Count == 1) WhitelistRemoveButton.IsEnabled = false; - Client.Whitelist.Remove(WhitelistListBox.SelectedValue.ToString().ToLower()); + UserClient.Whitelist.Remove(WhitelistListBox.SelectedValue.ToString().ToLower()); Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => WhitelistListBox.Items.Remove(WhitelistListBox.SelectedValue))); } diff --git a/LegendaryClient/Windows/FactionsGameLobbyPage.xaml b/Sightstone/Windows/FactionsGameLobbyPage.xaml similarity index 99% rename from LegendaryClient/Windows/FactionsGameLobbyPage.xaml rename to Sightstone/Windows/FactionsGameLobbyPage.xaml index 45339eaa..1bf22f73 100644 --- a/LegendaryClient/Windows/FactionsGameLobbyPage.xaml +++ b/Sightstone/Windows/FactionsGameLobbyPage.xaml @@ -1,5 +1,5 @@  /// Interaction logic for FactionsGameLobbyPage.xaml @@ -35,25 +36,27 @@ public partial class FactionsGameLobbyPage private double OptomisticLock; private MucManager newRoom; private Jid jid; + private static UserClient userClient; public FactionsGameLobbyPage() { InitializeComponent(); - GameName.Content = Client.GameName; - Client.RiotConnection.MessageReceived += GameLobby_OnMessageReceived; + userClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; + GameName.Content = userClient.GameName; + userClient.RiotConnection.MessageReceived += GameLobby_OnMessageReceived; //If client has created game use initial DTO - if (Client.GameLobbyDTO != null) + if (userClient.GameLobbyDTO != null) { - Lobby_OnMessageReceived(null, Client.GameLobbyDTO); + Lobby_OnMessageReceived(null, userClient.GameLobbyDTO); } Client.InviteListView = InviteListView; - if (Client.GameLobbyDTO != null) + if (userClient.GameLobbyDTO != null) { string result = GameName.Content.ToString() .Replace("FACTIONS – ", "") .Replace(" vs. ", "|") - .Replace(Client.GameLobbyDTO.OwnerSummary.SummonerName + "'s game– ", ""); + .Replace(userClient.GameLobbyDTO.OwnerSummary.SummonerName + "'s game– ", ""); string[] x = result.Split('|'); if (x.Length == 2) { @@ -88,7 +91,7 @@ private void Lobby_OnMessageReceived(object sender, object message) MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = - Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); + userClient.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; @@ -97,12 +100,12 @@ private void Lobby_OnMessageReceived(object sender, object message) Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt64(dto.Id), ChatPrefixes.Arranging_Practice); string Jid = Client.GetChatroomJid(obfuscatedName, dto.RoomPassword, false); - newRoom = new MucManager(Client.XmppConnection); - Client.XmppConnection.OnMessage += XmppConnection_OnMessage; - Client.XmppConnection.OnPresence += XmppConnection_OnPresence; + newRoom = new MucManager(userClient.XmppConnection); + userClient.XmppConnection.OnMessage += XmppConnection_OnMessage; + userClient.XmppConnection.OnPresence += XmppConnection_OnPresence; jid = new Jid(dto.RoomName); newRoom.AcceptDefaultConfiguration(jid); - newRoom.JoinRoom(jid, Client.LoginPacket.AllSummonerData.Summoner.Name, dto.RoomPassword); + newRoom.JoinRoom(jid, userClient.LoginPacket.AllSummonerData.Summoner.Name, dto.RoomPassword); } switch (dto.GameState) { @@ -131,12 +134,12 @@ private void Lobby_OnMessageReceived(object sender, object message) ///BotParticipant botParticipant = playerTeam as BotParticipant; //botPlayer = RenderBot(botParticipant); IsOwner = dto.OwnerSummary.SummonerId == - Client.LoginPacket.AllSummonerData.Summoner.SumId; + userClient.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = IsOwner; - if (Client.Whitelist.Count > 0) - if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) - await RiotCalls.BanUserFromGame(Client.GameID, player.AccountId); + if (userClient.Whitelist.Count > 0) + if (!userClient.Whitelist.Contains(player.SummonerName.ToLower())) + await userClient.calls.BanUserFromGame(userClient.GameID, player.AccountId); } if (i > dto.TeamOne.Count) @@ -156,7 +159,7 @@ private void Lobby_OnMessageReceived(object sender, object message) case "CHAMP_SELECT": if (!LaunchedTeamSelect) { - Client.ChampSelectDTO = dto; + userClient.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(dto.RoomName, dto.RoomPassword).Load(this)); LaunchedTeamSelect = true; @@ -187,7 +190,7 @@ void XmppConnection_OnMessage(object sender, Message msg) if (jid.Bare.Contains(msg.From.User)) return; - if (msg.From.Resource == Client.LoginPacket.AllSummonerData.Summoner.Name) + if (msg.From.Resource == userClient.LoginPacket.AllSummonerData.Summoner.Name) return; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { @@ -200,7 +203,7 @@ void XmppConnection_OnMessage(object sender, Message msg) }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Turquoise); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (userClient.Filter) tr.Text = msg.Body.Replace("", "").Filter() + Environment.NewLine; else @@ -220,17 +223,17 @@ private void ChatButton_Click(object sender, RoutedEventArgs e) { var tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd) { - Text = Client.LoginPacket.AllSummonerData.Summoner.Name + ": " + Text = userClient.LoginPacket.AllSummonerData.Summoner.Name + ": " }; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow); tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); - if (Client.Filter) + if (userClient.Filter) tr.Text = ChatTextBox.Text.Filter() + Environment.NewLine; else tr.Text = ChatTextBox.Text + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); - Client.XmppConnection.Send(new Message(jid, MessageType.groupchat, ChatTextBox.Text)); + userClient.XmppConnection.Send(new Message(jid, MessageType.groupchat, ChatTextBox.Text)); ChatTextBox.Text = ""; } @@ -253,8 +256,8 @@ private CustomLobbyPlayer RenderPlayer(PlayerParticipant player, bool IsOwner) lobbyPlayer.Width = 400; lobbyPlayer.Margin = new Thickness(0, 0, 0, 5); - if ((player.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) || - (player.SummonerId != Client.LoginPacket.AllSummonerData.Summoner.SumId && !this.IsOwner)) + if ((player.SummonerId == userClient.LoginPacket.AllSummonerData.Summoner.SumId) || + (player.SummonerId != userClient.LoginPacket.AllSummonerData.Summoner.SumId && !this.IsOwner)) lobbyPlayer.BanButton.Visibility = Visibility.Hidden; lobbyPlayer.BanButton.Tag = player; @@ -265,7 +268,7 @@ private CustomLobbyPlayer RenderPlayer(PlayerParticipant player, bool IsOwner) private async void QuitGameButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.QuitGame(); + await userClient.calls.QuitGame(); Client.ReturnButton.Visibility = Visibility.Hidden; Client.SwitchPage(Client.MainPage); Client.ClearPage(typeof(FactionsGameLobbyPage)); //Clear pages @@ -274,7 +277,7 @@ private async void QuitGameButton_Click(object sender, RoutedEventArgs e) private async void SwitchTeamsButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.SwitchTeams(Client.GameID); + await userClient.calls.SwitchTeams(userClient.GameID); } private async void KickAndBan_Click(object sender, RoutedEventArgs e) @@ -284,16 +287,17 @@ private async void KickAndBan_Click(object sender, RoutedEventArgs e) return; var banPlayer = (PlayerParticipant)button.Tag; - await RiotCalls.BanUserFromGame(Client.GameID, banPlayer.AccountId); + await userClient.calls.BanUserFromGame(userClient.GameID, banPlayer.AccountId); } private async void StartGameButton_Click(object sender, RoutedEventArgs e) { - await RiotCalls.StartChampionSelection(Client.GameID, OptomisticLock); + await userClient.calls.StartChampionSelection(userClient.GameID, OptomisticLock); } public static string GetGameMode(int i) { + var result = userClient.LoginPacket.GameTypeConfigs.Find(x => x.Id == i).Name; switch (i) { case 1: @@ -325,7 +329,7 @@ public static string GetGameMode(int i) return "One for All";*/ default: - return Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == i).Name; + return result; } } diff --git a/LegendaryClient/Windows/FactionsJoinGamePage.xaml b/Sightstone/Windows/FactionsJoinGamePage.xaml similarity index 97% rename from LegendaryClient/Windows/FactionsJoinGamePage.xaml rename to Sightstone/Windows/FactionsJoinGamePage.xaml index 44cbfef2..b6110951 100644 --- a/LegendaryClient/Windows/FactionsJoinGamePage.xaml +++ b/Sightstone/Windows/FactionsJoinGamePage.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for FactionsJoinGamePage.xaml @@ -16,6 +17,7 @@ namespace LegendaryClient.Windows public partial class FactionsJoinGamePage { private readonly List allItems = new List(); + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public FactionsJoinGamePage() { @@ -37,7 +39,7 @@ private async void GetGames() { CustomGameListView.Items.Clear(); allItems.Clear(); - PracticeGameSearchResult[] games = await RiotCalls.ListAllPracticeGames(); + PracticeGameSearchResult[] games = await UserClient.calls.ListAllPracticeGames(); foreach (GameItem item in games.Select(game => new GameItem { GameName = game.Name, @@ -81,12 +83,12 @@ private void JoinGameButton_Click(object sender, RoutedEventArgs e) gameName = item.GameName; } if (!string.IsNullOrEmpty("factions")) - RiotCalls.JoinGame(gameId, "factions"); + UserClient.calls.JoinGame(gameId, "factions"); else - RiotCalls.JoinGame(gameId); + UserClient.calls.JoinGame(gameId); - Client.GameID = gameId; - Client.GameName = gameName; + UserClient.GameID = gameId; + UserClient.GameName = gameName; Client.SwitchPage(new FactionsGameLobbyPage()); } diff --git a/LegendaryClient/Windows/FriendList.xaml b/Sightstone/Windows/FriendList.xaml similarity index 57% rename from LegendaryClient/Windows/FriendList.xaml rename to Sightstone/Windows/FriendList.xaml index 43592c56..4d1d264c 100644 --- a/LegendaryClient/Windows/FriendList.xaml +++ b/Sightstone/Windows/FriendList.xaml @@ -1,4 +1,4 @@ - + d:DesignWidth="250" + Foreground="{StaticResource MaterialDesignBody}"> @@ -20,14 +21,15 @@ - - - - + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Sightstone/Windows/LoginPage.xaml.cs b/Sightstone/Windows/LoginPage.xaml.cs new file mode 100644 index 00000000..ee7af5a5 --- /dev/null +++ b/Sightstone/Windows/LoginPage.xaml.cs @@ -0,0 +1,1324 @@ +using Sightstone.Logic.JSON; +using Sightstone.Logic.Region; +using Sightstone.Logic.SQLite; +using Sightstone.Logic.SWF; +using Sightstone.Logic.SWF.SWFTypes; +using Sightstone.Logic.UpdateRegion; +using Sightstone.Properties; +using MahApps.Metro.Controls; +using MahApps.Metro.Controls.Dialogs; +using SQLite; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Management; +using System.Net; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Web; +using System.Web.Script.Serialization; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Threading; +using Sightstone.Controls; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Platform; +using RtmpSharp.IO; +using RtmpSharp.Messaging; +using RtmpSharp.Net; +using Brush = System.Windows.Media.Brush; +using Point = System.Windows.Point; +using RiotPatcher = Sightstone.Logic.Patcher.RiotPatcher; +using agsXMPP.protocol.iq.roster; +using agsXMPP.protocol.client; +using System.Security.Principal; +using System.Security.Cryptography; +using Microsoft.Win32; +using Sightstone.Logic.MultiUser; +using System.ComponentModel; + +namespace Sightstone.Windows +{ + /// + /// Interaction logic for LoginPage.xaml + /// + public partial class LoginPage + { + private bool shouldExit; + private bool authed; + bool switchpage; + Dictionary dataLogin = new Dictionary(); + private bool saveuser; + + public LoginPage() + { + InitializeComponent(); + string lolRootPath = GetLolRootPath(false); + Client.Log("League of Legends is located at: " + lolRootPath); + //RADS\solutions\lol_game_client_sln\releases + string gameLocation = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln", + "releases"); + string solutionListing = new RiotPatcher().GetListing("http://l3cdn.riotgames.com/releases/live/solutions/lol_game_client_sln/releases/releaselisting_NA"); + + string solutionVersion = solutionListing.Split(new[] { Environment.NewLine }, StringSplitOptions.None)[0]; + Client.GameClientVersion = solutionVersion; + Client.Location = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln", + "releases", solutionVersion, "deploy"); + + if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", "themedata"))) + Client.Theme = File.ReadAllLines(Path.Combine(Client.ExecutingDirectory, "Assets", "themes", "themedata"))[0]; + + if (File.Exists(Path.Combine(Settings.Default.GarenaLocation, "Air", "Lib", "ClientLibCommon.dat"))) + { + File.Copy(Path.Combine(Settings.Default.GarenaLocation, "Air", "Lib", "ClientLibCommon.dat"), + Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat"), true); + + Client.Log("Garena is Up-To-Date"); + Client.GLocation = Path.Combine(lolRootPath.Replace("lol.exe", ""), "Game"); + Client.GRootLocation = lolRootPath; + } + if (Directory.Exists(Path.Combine(gameLocation, solutionVersion))) + { + Client.Log("League of Legends is Up-To-Date"); + Client.Location = Path.Combine(lolRootPath, "RADS", "solutions", "lol_game_client_sln", + "releases", solutionVersion, "deploy"); + Client.RootLocation = lolRootPath; + } + + Client.CurrentServer = "NA"; + Version.TextChanged += WaterTextbox_TextChanged; + bool x = Settings.Default.DarkTheme; + if (!x) + { + var bc = new BrushConverter(); + HideGrid.Background = (Brush)bc.ConvertFrom("#B24F4F4F"); + LoggingInProgressRing.Foreground = (Brush)bc.ConvertFrom("#FFFFFFFF"); + } + //#B2C8C8C8 + UpdateRegionComboBox.ItemsSource = new[] { "PBE", "Live", "Korea", "Garena" }; + + UpdateRegionComboBox.SelectedIndex = 1; + //switch (user.Instance.UpdateRegion) + switch (UpdateRegionComboBox.SelectedItem.ToString()) + { + case "PBE": + RegionComboBox.ItemsSource = new[] { "PBE" }; + LoginUsernameBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + break; + + case "Live": + RegionComboBox.ItemsSource = new[] { "BR", "EUNE", "EUW", "NA", "OCE", "RU", "LAS", "LAN", "TR", "CS" }; + LoginUsernameBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + break; + + case "Korea": + RegionComboBox.ItemsSource = new[] { "KR" }; + LoginUsernameBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + LoginPasswordBox.Visibility = Visibility.Visible; + break; + + case "Garena": + RegionComboBox.ItemsSource = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN", "ID" }; + LoginUsernameBox.Visibility = Visibility.Hidden; + RememberUsernameCheckbox.Visibility = Visibility.Hidden; + LoginPasswordBox.Visibility = Visibility.Hidden; + if (!string.IsNullOrEmpty(Settings.Default.DefaultGarenaRegion)) + RegionComboBox.SelectedValue = Settings.Default.DefaultGarenaRegion; // Default Garena Region + break; + } + + string themeLocation = ""; + if (!String.IsNullOrEmpty(Client.Theme)) + themeLocation = Path.Combine(Client.ExecutingDirectory, "assets", "themes", Client.Theme); + + if (!Settings.Default.DisableLoginMusic) + { + string[] music = null; + string soundpath = Path.Combine(Client.ExecutingDirectory, "Assets", "sounds", "sound_o_heaven.ogg"); + if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) + { + if (!File.Exists(soundpath)) + { + using (WebClient wc = new WebClient()) + { + wc.DownloadFile("http://images.wikia.com/leagueoflegends/images/1/10/Teemo.laugh3.ogg", soundpath); + } + } + music = new[] { soundpath }; + } + else + { + if (!String.IsNullOrEmpty(themeLocation)) + music = Directory.GetFiles(themeLocation, "*.mp3"); + } + if (music != null && music.Length > 0 && !String.IsNullOrEmpty(themeLocation)) + { + SoundPlayer.Source = new System.Uri(Path.Combine(themeLocation, music[0])); + SoundPlayer.Play(); + } + if (Settings.Default.LoginMusicVolume != -1) + { + slider.Value = Settings.Default.LoginMusicVolume; + SoundPlayer.Volume = Settings.Default.LoginMusicVolume / 100; + } + Sound.IsChecked = false; + } + else + Sound.IsChecked = true; + + if (DateTime.Now.Month == 4 && DateTime.Now.Day == 1) + { + string SkinPath = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + "Teemo_Splash_" + new Random().Next(0, 8) + ".jpg"); + if (File.Exists(SkinPath)) + { + LoginImage.Source = new BitmapImage(new System.Uri(SkinPath, UriKind.Absolute)); + } + } + else if (Settings.Default.LoginPageImage == "" && !String.IsNullOrEmpty(themeLocation)) + { + string[] videos = Directory.GetFiles(themeLocation, "*.mp4"); + if (videos.Length > 0 && File.Exists(videos[0])) + LoginPic.Source = new System.Uri(videos[0]); + LoginPic.LoadedBehavior = MediaState.Manual; + LoginPic.MediaEnded += LoginPic_MediaEnded; + SoundPlayer.MediaEnded += SoundPlayer_MediaEnded; + LoginPic.Play(); + } + else + { + if ( + File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + Settings.Default.LoginPageImage.Replace("\r\n", "")))) + LoginImage.Source = + new BitmapImage( + new System.Uri( + Path.Combine(Client.ExecutingDirectory, "Assets", "champions", + Settings.Default.LoginPageImage), UriKind.Absolute)); + } + + Video.IsChecked = false; + + //Get client data after patcher completed + + Client.SQLiteDatabase = new SQLiteConnection(Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite")); + + // Check database error + try + { + Client.Champions = (from s in Client.SQLiteDatabase.Table() + orderby s.name + select s).ToList(); + + //* to remove just remove one slash from the comment + //Pls bard the tard for april fools + Client.Champions.Find(bard => bard.name == "Bard").displayName = "Tard"; + //*/ + } + catch (Exception e) // Database broken? + { + Client.Log("Database is broken : \r\n" + e.Message + "\r\n" + e.Source); + var overlay = new MessageOverlay + { + MessageTextBox = { Text = "Database is broken. Click OK to exit Sightstone." }, + MessageTitle = { Content = "Database Error" } + }; + Client.SQLiteDatabase.Close(); + File.Delete(Path.Combine(Client.ExecutingDirectory, "gameStats_en_US.sqlite")); + overlay.AcceptButton.Click += (o, i) => { Environment.Exit(0); }; + Client.OverlayContainer.Content = overlay.Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + return; + } + + var FreeToPlay = FreeToPlayChampions.GetInstance(); + + + Client.ChampionSkins = (from s in Client.SQLiteDatabase.Table() + orderby s.name + select s).ToList(); + Client.ChampionAbilities = (from s in Client.SQLiteDatabase.Table() + orderby s.name + select s).ToList(); + + foreach (var champ in Client.Champions) + { + var source = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champ.iconPath), + UriKind.Absolute); + if (File.Exists(source.AbsolutePath)) + champ.icon = new BitmapImage(source); + + if (FreeToPlay != null) + { + champ.IsFreeToPlay = FreeToPlay.IsFreeToPlay(champ); + } + + var c1 = champ; + foreach (var skins in Client.ChampionSkins.Where(skins => c1.id == skins.championId)) + { + var skin = new Skins + { + Id = skins.id, + Name = skins.displayName, + Num = skins.rank, + PortraitPath = skins.portraitPath, + IsBase = false, + SplashPath = skins.splashPath + }; + if (skins.isBase == 1) + { + skin.IsBase = true; + } + if (string.IsNullOrWhiteSpace(skin.Name)) + skin.Name = champ.displayName; + champ.Skins.Add(skin); + } + + foreach (var spell in Client.ChampionAbilities) + { + if (spell.championId == champ.id) + { + var newSpell = new Spell(); + newSpell.Description = spell.description; + newSpell.Tooltip = spell.effect; + newSpell.ID = champ.displayName + spell.hotkey; + } + } + + //Champions.InsertExtraChampData(champ); + } + + Client.SQLiteDatabase.Close(); + + Client.Items = ParseItems.PopulateItems(); + Client.Masteries = Masteries.PopulateMasteries(new WebClient().DownloadString("http://ddragon.leagueoflegends.com/cdn/5.19.1/data/en_US/mastery.json")); + Client.Runes = Runes.PopulateRunes(new WebClient().DownloadString("http://ddragon.leagueoflegends.com/cdn/5.19.1/data/en_US/rune.json")); + //BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion(user.Instance.UpdateRegion); + BaseUpdateRegion updateRegion = BaseUpdateRegion.GetUpdateRegion("Live"); + var patcher = new RiotPatcher(); + //if (user.Instance.UpdateRegion != "Garena") + if ("Live" != "Garena") + { + string tempString = patcher.GetListing(updateRegion.AirListing); + + string[] packages = patcher.GetManifest( + updateRegion.AirManifest + "releases/" + tempString + "/packages/files/packagemanifest"); + foreach ( + string usestring in + packages.Select(package => package.Split(',')[0]) + .Where(usestring => usestring.Contains("ClientLibCommon.dat"))) + new WebClient().DownloadFile(new System.Uri(updateRegion.BaseLink + usestring), + Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat")); + } + var reader = new SWFReader(Path.Combine(Client.ExecutingDirectory, "ClientLibCommon.dat")); + foreach (var secondSplit in from abcTag in reader.Tags.OfType() + where abcTag.Name.Contains("riotgames/platform/gameclient/application/Version") + select Encoding.Default.GetString(abcTag.ABCData) + into str + select str.Split((char)6) + into firstSplit + + select firstSplit[0].Split((char)18)) + + + if (secondSplit.Count() > 1) + { + Client.Version = secondSplit[1]; + } + else + { + var thirdSplit = secondSplit[0].Split((char)19); + Client.Version = thirdSplit[1]; + } + + + Version.Text = Client.Version; + + if (!string.IsNullOrWhiteSpace(Settings.Default.SavedUsername)) + { + RememberUsernameCheckbox.IsChecked = true; + LoginUsernameBox.Text = Settings.Default.SavedUsername; + } + if (!string.IsNullOrWhiteSpace(Settings.Default.SavedPassword)) + { + SHA1 sha = new SHA1CryptoServiceProvider(); + RememberPasswordCheckbox.IsChecked = true; + LoginPasswordBox.Password = + Settings.Default.SavedPassword.DecryptStringAES( + sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString()); + } + if (!string.IsNullOrWhiteSpace(Settings.Default.Region)) + RegionComboBox.SelectedValue = Settings.Default.Region; + + invisibleLoginCheckBox.IsChecked = Settings.Default.incognitoLogin; + } + + private string GetLolRootPath(bool restart) + { + if (!restart) + { + switch (RegionComboBox.SelectedValuePath) + { + case "PBE": + if (Settings.Default.PBELocation != string.Empty) + return Settings.Default.PBELocation; + break; + case "Live": + if (Settings.Default.LiveLocation != string.Empty) + return Settings.Default.LiveLocation; + break; + case "Korea": + if (Settings.Default.KRLocation != string.Empty) + return Settings.Default.KRLocation; + break; + case "Garena": + if (Settings.Default.GarenaLocation != string.Empty && Settings.Default.GarenaLocation.EndsWith("lol.exe")) + { + Settings.Default.GarenaLocation = Settings.Default.GarenaLocation.Replace("lol.exe", ""); + return Settings.Default.GarenaLocation; + } + if (Settings.Default.GarenaLocation != string.Empty) + return Settings.Default.GarenaLocation; + break; + } + var possiblePaths = new List> + { + new Tuple(@"HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\SightstoneLol", + "Path"), + new Tuple( + @"HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\RIOT GAMES", "Path"), + new Tuple( + @"HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\RIOT GAMES", + "Path"), + new Tuple(@"HKEY_CURRENT_USER\Software\RIOT GAMES", "Path"), + new Tuple(@"HKEY_CURRENT_USER\Software\Wow6432Node\Riot Games", "Path"), + new Tuple(@"HKEY_LOCAL_MACHINE\Software\Riot Games\League Of Legends", "Path"), + new Tuple(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Riot Games", "Path"), + new Tuple(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Riot Games\League Of Legends", + "Path"), + // Yes, a f*ckin whitespace after "Riot Games".. + new Tuple(@"HKEY_LOCAL_MACHINE\Software\Wow6432Node\Riot Games \League Of Legends", + "Path"), + }; + foreach (var tuple in possiblePaths) + { + var path = tuple.Item1; + var valueName = tuple.Item2; + try + { + var value = Registry.GetValue(path, valueName, string.Empty); + if (value == null || value.ToString() == string.Empty) continue; + var regKey = Registry.CurrentUser.CreateSubKey("Sightstone"); + if (regKey == null) return value.ToString(); + regKey.SetValue( + value.ToString().Contains("lol.exe") ? "GarenaLocation" : "LoLLocation", + value.ToString()); + regKey.Close(); + return value.ToString(); + } + catch (Exception e) + { + Client.Log(e); + } + } + } + + var findLeagueDialog = new OpenFileDialog(); + + if (!Directory.Exists(Path.Combine("C:\\", "Riot Games", "League of Legends"))) + findLeagueDialog.InitialDirectory = Path.Combine("C:\\", "Program Files (x86)", "GarenaLoL", "GameData", + "Apps", "LoL"); + else + findLeagueDialog.InitialDirectory = Path.Combine("C:\\", "Riot Games", "League of Legends"); + + findLeagueDialog.DefaultExt = ".exe"; + findLeagueDialog.Filter = "League of Legends Launcher|lol.launcher*.exe|Garena Launcher|lol.exe"; + + var result = findLeagueDialog.ShowDialog(); + if (result != true) + return string.Empty; + + var key = Registry.CurrentUser.CreateSubKey("Software\\RIOT GAMES"); + key?.SetValue("Path", + findLeagueDialog.FileName.Replace("lol.launcher.exe", string.Empty).Replace("lol.launcher.admin.exe", string.Empty)); + + if (restart) + { + MessageBox.Show("Saved value, please restart the client to login.", "press any key to restart"); + Process.Start(Path.Combine(Client.ExecutingDirectory, "Client", "Sightstone.exe")); + } + + return findLeagueDialog.FileName.Replace("lol.launcher.exe", string.Empty).Replace("lol.launcher.admin.exe", string.Empty); + } + + private void LoginPic_MediaEnded(object sender, RoutedEventArgs e) + { + LoginPic.Position = TimeSpan.FromSeconds(0); + LoginPic.Play(); + } + + private void WaterTextbox_TextChanged(object sender, RoutedEventArgs e) + { + Client.Version = Version.Text; + } + + private bool playingSound = true; + + private void DisableSound_Click(object sender, RoutedEventArgs e) + { + if (playingSound) + { + SoundPlayer.Pause(); + Sound.IsChecked = true; + playingSound = false; + } + else + { + SoundPlayer.Source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", + "themes", Client.Theme, "LoginScreenLoop.mp3")); + SoundPlayer.Volume = slider.Value/100; + SoundPlayer.Play(); + Sound.IsChecked = false; + playingSound = true; + } + + Settings.Default.DisableLoginMusic = Sound.IsChecked.Value; + } + + private void SoundPlayer_MediaEnded(object sender, RoutedEventArgs e) + { + SoundPlayer.Position = TimeSpan.FromSeconds(0); + SoundPlayer.Play(); + } + + private bool playingVideo = true; + + private void DisableVideo_Click(object sender, RoutedEventArgs e) + { + if (Settings.Default.LoginPageImage == "") + { + if (playingVideo) + { + Video.IsChecked = true; + playingVideo = false; + LoginPic.Source = new System.Uri("http://eddy5641.github.io/Sightstone/Login/Login.png"); + } + else + { + LoginPic.Source = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", + "themes", Client.Theme, "login-loop.mp4")); + LoginPic.LoadedBehavior = MediaState.Manual; + LoginPic.MediaEnded += LoginPic_MediaEnded; + LoginPic.Play(); + Video.IsChecked = false; + playingVideo = true; + } + } + } + + private void ShowLogin_Click(object sender, RoutedEventArgs e) + { + if (LoginGrid.IsVisible) + { + LoginGrid.Visibility = Visibility.Hidden; + } + else + { + LoginGrid.Visibility = Visibility.Visible; + } + } + + private async void LoginButton_Click(object sender, RoutedEventArgs e) + { + if (RegionComboBox.SelectedIndex == -1) + return; + if ((string)UpdateRegionComboBox.SelectedValue == "Garena") + { + if (RegionComboBox.SelectedIndex == -1) + return; + if (!string.IsNullOrEmpty(RegionComboBox.SelectedValue.ToString())) + { + Settings.Default.DefaultGarenaRegion = RegionComboBox.SelectedValue.ToString(); // Set default Garena region + Settings.Default.Save(); + } + await garenaLogin(BaseRegion.GetRegion((string)RegionComboBox.SelectedValue), new UserClient { Garena = true }); + return; + } + string UserName = LoginUsernameBox.Text; + LoggingInLabel.Content = "Logging in..."; + if (string.IsNullOrEmpty(Settings.Default.Guid)) + Settings.Default.Guid = Guid.NewGuid().ToString(); + + Settings.Default.Save(); + SHA1 sha = new SHA1CryptoServiceProvider(); + if (RememberPasswordCheckbox.IsChecked == true) + Settings.Default.SavedPassword = + LoginPasswordBox.Password.EncryptStringAES( + sha.ComputeHash(Encoding.UTF8.GetBytes(Settings.Default.Guid)).ToString()); + else + Settings.Default.SavedPassword = ""; + + Settings.Default.SavedUsername = RememberUsernameCheckbox.IsChecked == true ? LoginUsernameBox.Text : ""; + + if (invisibleLoginCheckBox.IsChecked != null) + Settings.Default.incognitoLogin = (bool)invisibleLoginCheckBox.IsChecked; + + Settings.Default.Region = (string)RegionComboBox.SelectedValue; + Settings.Default.Save(); + + EncryptBox.Visibility = Visibility.Hidden; + HideGrid.Visibility = Visibility.Hidden; + ErrorTextBox.Visibility = Visibility.Hidden; + LoggingInLabel.Visibility = Visibility.Visible; + LoggingInProgressRing.Visibility = Visibility.Visible; + BaseRegion selectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue); + + Login(LoginUsernameBox.Text, LoginPasswordBox.Password, selectedRegion, new UserClient()); + if (sender != null) + switchpage = true; + } + + void client_MessageReceived(object sender, MessageReceivedEventArgs e) + { + ; + } + + void client_CallbackException(object sender, Exception e) + { + throw e; + } + +#pragma warning disable 4014 //Code does not need to be awaited + async void Login(string username, string pass, BaseRegion selectedRegion, Deletable user) + { + user.Instance.Region = selectedRegion; + user.Instance.calls = new RiotCalls(user.Instance); + //BaseRegion selectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue); + var authToken = await user.Instance.calls.GetRestToken(username, pass, selectedRegion.LoginQueue); + if (authToken == "invalid_credentials") + { + ErrorTextBox.Text = "Wrong login data"; + user.Delete(); + HideGrid.Visibility = Visibility.Visible; + ErrorTextBox.Visibility = Visibility.Visible; + LoggingInLabel.Visibility = Visibility.Hidden; + LoggingInProgressRing.Visibility = Visibility.Collapsed; + return; + } + user.Instance.RiotConnection = new RtmpClient(new System.Uri("rtmps://" + selectedRegion.Server + ":2099"), user.Instance.calls.RegisterObjects(), ObjectEncoding.Amf3); + user.Instance.RiotConnection.CallbackException += client_CallbackException; + user.Instance.RiotConnection.MessageReceived += client_MessageReceived; + try + { + + await user.Instance.RiotConnection.ConnectAsync(); + } + catch + { + ErrorTextBox.Text = "Failed to login. SSL error."; + HideGrid.Visibility = Visibility.Visible; + ErrorTextBox.Visibility = Visibility.Visible; + LoggingInLabel.Visibility = Visibility.Hidden; + LoggingInProgressRing.Visibility = Visibility.Collapsed; + //user.Delete(); + Login(username, pass, selectedRegion, user); + return; + } + + user.Instance.RiotConnection.SetChunkSize(2147483647); + AuthenticationCredentials newCredentials = new AuthenticationCredentials + { + Username = username, + Password = pass, + ClientVersion = Client.Version, + IpAddress = user.Instance.calls.GetIpAddress(), + Locale = selectedRegion.Locale, + OperatingSystem = "Windows 7", + Domain = "lolclient.lol.riotgames.com", + AuthToken = authToken + }; + Session login = await user.Instance.calls.Login(newCredentials); + if (login == null) + { + Client.Log("Login session is null."); + var overlay = new MessageOverlay + { + MessageTextBox = { Text = "Login session is null. Login failed. Please check whether the version number is correct or not.", IsReadOnly = true }, + MessageTitle = { Content = "Login session is null." } + }; + Client.OverlayContainer.Content = overlay.Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + ErrorTextBox.Text = "Failed to login. Login session is null."; + HideGrid.Visibility = Visibility.Visible; + ErrorTextBox.Visibility = Visibility.Visible; + LoggingInLabel.Visibility = Visibility.Hidden; + LoggingInProgressRing.Visibility = Visibility.Collapsed; + return; + } + user.Instance.PlayerSession = login; + + var str1 = string.Format("gn-{0}", login.AccountSummary.AccountId); + var str2 = string.Format("cn-{0}", login.AccountSummary.AccountId); + var str3 = string.Format("bc-{0}", login.AccountSummary.AccountId); + Task[] taskArray = { user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str1, str1), + user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str2, str2), + user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", str3) }; + + await Task.WhenAll(taskArray); + //Riot added this for no reason but make it look like the riot client we have to do this + var plainTextbytes = Encoding.UTF8.GetBytes(login.AccountSummary.Username + ":" + login.Token); + user.Instance.reconnectToken = Convert.ToBase64String(plainTextbytes); + + var LoggedIn = await user.Instance.RiotConnection.LoginAsync(username.ToLower(), login.Token); + + var packetx = await user.Instance.calls.GetLoginDataPacketForUser(); + + if (packetx == null || packetx.AllSummonerData == null) + { + user.Instance.RiotConnection.CallbackException -= client_CallbackException; + user.Instance.RiotConnection.MessageReceived -= client_MessageReceived; + //Just Created Account, need to put logic here. + user.Instance.done = false; + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => + { + var createSummoner = new CreateSummonerNameOverlay(user.Instance); + Client.OverlayContainer.Content = createSummoner.Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + })); + while (!user.Instance.done) + { + } + Login(username, pass, selectedRegion, user); + return; + } + + if (saveuser || !string.IsNullOrWhiteSpace(Client.EncrytKey)) + { + UserList.AddUser(username, pass, packetx.AllSummonerData.Summoner.InternalName, + "Using Sightstone", packetx.AllSummonerData.Summoner.ProfileIconId, + selectedRegion, ShowType.chat, Client.EncrytKey); + saveuser = false; + } + DoGetOnLoginPacket(username, pass, selectedRegion, packetx, user); + } + + private async void DoGetOnLoginPacket(string username, string pass, BaseRegion selectedRegion, LoginDataPacket packetx, Deletable user) + { + //TODO: Finish this so all calls are used + + user.Instance.Queues = await user.Instance.calls.GetAvailableQueues(); + user.Instance.PlayerChampions = await user.Instance.calls.GetAvailableChampions(); + //var runes = await RiotCalls.GetSummonerRuneInventory(packetx.AllSummonerData.Summoner.AcctId); + user.Instance.StartHeartbeat(); + //var leaguePos = await RiotCalls.GetMyLeaguePositions(); + //var preferences = await RiotCalls.LoadPreferencesByKey(); + //var masterybook = await RiotCalls.GetMasteryBook(packetx.AllSummonerData.Summoner.AcctId); + //var lobby = await RiotCalls.CheckLobbyStatus(); + var invites = await user.Instance.calls.GetPendingInvitations(); + //var player = await RiotCalls.CreatePlayer(); + GotLoginPacket(packetx, username, pass, selectedRegion, user); + + foreach (var pop in from InvitationRequest invite in invites + select new GameInvitePopup(invite, user.Instance) + { + HorizontalAlignment = HorizontalAlignment.Right, + VerticalAlignment = VerticalAlignment.Bottom, + Height = 230 + }) + Client.NotificationGrid.Children.Add(pop); + if (invites.Length != 0) + Client.MainWin.FlashWindow(); + + user.Instance.LoginPacket = packetx; + if (!dataLogin.ContainsKey(packetx.AllSummonerData.Summoner.InternalName + ":" + selectedRegion)) + { + dataLogin.Add(packetx.AllSummonerData.Summoner.InternalName + ":" + selectedRegion, new LoginData + { + Pass = pass, + Region = selectedRegion, + ShowType = ShowType.chat, + Status = "Using Sightstone", + SumIcon = packetx.AllSummonerData.Summoner.ProfileIconId, + SumName = packetx.AllSummonerData.Summoner.InternalName, + User = username + }); + + LoggingInLabel.Visibility = Visibility.Hidden; + LoggingInProgressRing.Visibility = Visibility.Hidden; + Encrypt.Visibility = Visibility.Hidden; + EncryptCheck.Visibility = Visibility.Hidden; + } + } + + private void GotLoginPacket(LoginDataPacket packet, string username, string pass, BaseRegion selectedRegion, Deletable user) + { + + user.Instance.LoginPacket = packet; + Client.CurrentServer = selectedRegion.Server + ":" + packet.AllSummonerData.Summoner.InternalName; + UserList.Users.Add(selectedRegion.Server + ":" + packet.AllSummonerData.Summoner.InternalName, new Dictionary { { packet.AllSummonerData.Summoner.InternalName, user.Instance } }); + if (packet.AllSummonerData.Summoner.ProfileIconId == -1) + { + user.Instance.RiotConnection.CallbackException -= client_CallbackException; + user.Instance.RiotConnection.MessageReceived -= client_MessageReceived; + user.Instance.done = false; + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => + { + Client.OverlayContainer.Content = new ChooseProfilePicturePage().Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + })); + while (!user.Instance.done) + { + } + Login(username, pass, selectedRegion, user); + + return; + } + + user.Instance.RiotConnection.MessageReceived += user.Instance.OnMessageReceived; + user.Instance.RiotConnection.Disconnected += user.Instance.RiotConnection_Disconnected; + user.Instance.GameConfigs = packet.GameTypeConfigs; + user.Instance.IsLoggedIn = true; + + + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () => + { + //MessageBox.Show("Do not play ANY games. I am not sure if they will work ~eddy", "XMPP", MessageBoxButton.OK, MessageBoxImage.Warning); + Client.StatusContainer.Visibility = Visibility.Visible; + Client.Container.Margin = new Thickness(0, 0, 0, 40); + user.Instance.XmppConnection = new agsXMPP.XmppClientConnection("pvp.net", 5223) + { + AutoResolveConnectServer = false, + ConnectServer = "chat." + user.Instance.Region.ChatName + ".lol.riotgames.com", + Resource = "xiff", + UseSSL = true, + KeepAliveInterval = 10, + KeepAlive = true, + UseCompression = true + }; + user.Instance.XmppConnection.OnMessage += user.Instance.XmppConnection_OnMessage; + user.Instance.XmppConnection.OnError += user.Instance.XmppConnection_OnError; + if (switchpage) + { + user.Instance.XmppConnection.OnLogin += (o) => + { + Client.Log("Connected to XMPP Server"); + //Set up chat + Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => + { + user.Instance.XmppConnection.Send(invisibleLoginCheckBox.IsChecked != true + ? new Presence(ShowType.chat, user.Instance.GetPresence(), 0) + { + Type = PresenceType.available + } + : new Presence(ShowType.NONE, user.Instance.GetPresence(), 0) + { + Type = PresenceType.invisible + }); + })); + }; + } + Client.ready = false; + Client.loadedGroups = false; + user.Instance.RostManager = new RosterManager(user.Instance.XmppConnection); + user.Instance.XmppConnection.OnRosterItem += user.Instance.RostManager_OnRosterItem; + + user.Instance.XmppConnection.OnRosterEnd += user.Instance.XmppConnection_OnRosterEnd; + user.Instance.PresManager = new PresenceManager(user.Instance.XmppConnection); + user.Instance.XmppConnection.OnPresence += user.Instance.XmppConnection_OnPresence; + user.Instance.XmppConnection.OnMessage += Client.statusPage.XmppConnection_OnMessage; + if (!user.Instance.Garena) + { + user.Instance.userpass = new KeyValuePair(username, + "AIR_" + pass); + + user.Instance.XmppConnection.Open(username, "AIR_" + pass); + + //Client.XmppConnection.OnInvalidCertificate += Client.XmppConnection_OnInvalidCertificate; + } + else + { + user.Instance.XmppConnection.ConnectServer = "chat" + user.Instance.Region.ChatName + ".lol.garenanow.com"; + var gas = getGas(user); + user.Instance.XmppConnection.Open(user.Instance.UID, "AIR_" + gas); + user.Instance.userpass = new KeyValuePair(user.Instance.UID, "AIR_" + gas); + } + + Client.Log("Connected to " + user.Instance.Region.RegionName + " and logged in as " + + user.Instance.LoginPacket.AllSummonerData.Summoner.Name); + + PlatformGameLifecycleDTO data = (PlatformGameLifecycleDTO)user.Instance.LoginPacket.ReconnectInfo; + Client.CurrentUser = packet.AllSummonerData.Summoner.InternalName; + Client.MainPage = new MainPage(); + + if (data != null && data.Game != null) + { + Client.Log(data.PlayerCredentials.ChampionId.ToString(CultureInfo.InvariantCulture)); + user.Instance.CurrentGame = data.PlayerCredentials; + user.Instance.GameType = data.Game.GameType; + if (switchpage) + Client.SwitchPage(new InGame()); + } + else if (switchpage) + { + while (!Client.ready) + { + await Task.Delay(1000); + } + Client.SwitchPage(Client.MainPage); + + Client.loadedGroups = true; + } + if (switchpage) return; + var sum = dataLogin[packet.AllSummonerData.Summoner.InternalName + ":" + selectedRegion]; + user.Instance.presenceStatus = sum.ShowType; + user.Instance.XmppConnection.Send(sum.ShowType == ShowType.NONE + ? new Presence(sum.ShowType, user.Instance.GetPresence(), 0) { Type = PresenceType.invisible } + : new Presence(sum.ShowType, user.Instance.GetPresence(), 0) { Type = PresenceType.available }); + UserAccount acc = new UserAccount + { + PlayerName = { Content = packet.AllSummonerData.Summoner.InternalName }, + StatusColour = { Fill = System.Windows.Media.Brushes.Green }, + ProfileImage = + { + Source = new BitmapImage(Client.GetIconUri(sum.SumIcon)) + }, + RegionLabel = { Content = sum.Region.RegionName }, + LevelLabel = { Content = packet.AllSummonerData.SummonerLevel.Level }, + PlayerStatus = { Content = sum.Status } + }; + foreach (var lgndata in dataLogin.Where(lgndata => lgndata.Key == packet.AllSummonerData.Summoner.InternalName + ":" + selectedRegion)) + { + user.Instance.presenceStatus = lgndata.Value.ShowType; + user.Instance.XmppConnection.Send(lgndata.Value.ShowType == ShowType.NONE + ? new Presence(sum.ShowType, user.Instance.GetPresence(), 0) { Type = PresenceType.invisible } + : new Presence(sum.ShowType, user.Instance.GetPresence(), 0) { Type = PresenceType.available }); + } + switch (user.Instance.presenceStatus) + { + case ShowType.away: + case ShowType.dnd: + case ShowType.xa: + acc.StatusColour.Fill = System.Windows.Media.Brushes.Red; + break; + case ShowType.NONE: + acc.StatusColour.Fill = System.Windows.Media.Brushes.Silver; + break; + } + + user.Instance.userAccount = acc; + UserListView.Items.Add(acc); + acc.MouseDown += async (o, e) => + { + Client.CurrentServer = selectedRegion.Server + ":" + packet.AllSummonerData.Summoner.InternalName; + Client.CurrentUser = packet.AllSummonerData.Summoner.InternalName; + Client.SwitchPage(Client.MainPage); + while (!Client.ready) + { + await Task.Delay(1000); + } + Client.loadedGroups = true; + }; + })); + } + + public static string GetNewIpAddress() + { + var sb = new StringBuilder(); + + WebRequest con = WebRequest.Create("http://ll.leagueoflegends.com/services/connection_info"); + WebResponse response = con.GetResponse(); + + int c; + Stream responseStream = response.GetResponseStream(); + while (responseStream != null && (c = responseStream.ReadByte()) != -1) + sb.Append((char)c); + + con.Abort(); + + var serializer = new JavaScriptSerializer(); + var deserializedJson = serializer.Deserialize>(sb.ToString()); + try + { + if (deserializedJson.Any(x => x.Key.Contains("403") || x.Value.Contains("403"))) + throw new HttpListenerException(403); + + return deserializedJson["ip_address"]; + } + catch + { + string localIp = "?"; + IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName()); + foreach (IPAddress ip in host.AddressList.Where(ip => ip.AddressFamily.ToString() == "InterNetwork")) + localIp = ip.ToString(); + + return localIp; + } + } + + private Vector moveOffset; + private Point _currentLocation; + private double _lastVolume; + + private async Task garenaLogin(BaseRegion garenaregion, Deletable user) + { + user.Instance.Region = garenaregion; + user.Instance.calls = new RiotCalls(user.Instance); + WindowsIdentity winIdentity = WindowsIdentity.GetCurrent(); + WindowsPrincipal winPrincipal = new WindowsPrincipal(winIdentity); + if (!winPrincipal.IsInRole(WindowsBuiltInRole.Administrator)) + { + var overlay = new MessageOverlay + { + MessageTextBox = + { + Text = "Press OK to restart as admin." + }, + MessageTitle = { Content = "Insufficient Privledges" } + }; + Client.OverlayContainer.Content = overlay.Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + overlay.AcceptButton.Click += (o, i) => + { + var info = new ProcessStartInfo(Path.Combine(Client.ExecutingDirectory, "Client", "Sightstone.exe")) + { + UseShellExecute = true, + Verb = "runas" + }; + try + { + Process.Start(info); + } + catch (Win32Exception e) //User click "No" in UAC dialog or user does not have sufficient permission + { + overlay = new MessageOverlay + { + MessageTextBox = + { + Text = "Windows UAC denied Sightstone from restarting as admin." + }, + MessageTitle = { Content = "Insufficient Permission" } + }; + Client.OverlayContainer.Content = overlay.Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + } + Environment.Exit(0); + }; + return; + } + + LoggingInLabel.Content = "Waiting for user to launch League from garena"; + HideGrid.Visibility = Visibility.Hidden; + ErrorTextBox.Visibility = Visibility.Hidden; + LoggingInLabel.Visibility = Visibility.Visible; + LoggingInProgressRing.Visibility = Visibility.Visible; + LoginPasswordBox.Visibility = Visibility.Hidden; + shouldExit = false; + while (!shouldExit) + { + await Task.Delay(500); + foreach (var process in Process.GetProcessesByName("lol")) + { + var s1 = GetCommandLine(process); + process.Kill(); + foreach (var lolclient in Process.GetProcessesByName("LolClient")) + { + lolclient.Kill(); + } + if (s1.StartsWith("\"")) + { + try + { + s1 = s1.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)[1]; + } + catch + { + Client.Log("Error splitting path from command line."); + } + } + else + { + s1 = s1.Substring(1); + } + Client.Log("Received token, it is: " + s1); + shouldExit = true; + user.Instance.Region = garenaregion; + Dispatcher.BeginInvoke( + DispatcherPriority.Input, new ThreadStart(() => + { + HideGrid.Visibility = Visibility.Hidden; + ErrorTextBox.Visibility = Visibility.Hidden; + LoggingInLabel.Visibility = Visibility.Visible; + LoggingInLabel.Content = "Logging in..."; + LoggingInProgressRing.Visibility = Visibility.Visible; + })); + var context = user.Instance.calls.RegisterObjects(); + user.Instance.RiotConnection = new RtmpClient(new System.Uri("rtmps://" + garenaregion.Server + ":2099"), context, ObjectEncoding.Amf3); + user.Instance.RiotConnection.CallbackException += client_CallbackException; + user.Instance.RiotConnection.MessageReceived += client_MessageReceived; + await user.Instance.RiotConnection.ConnectAsync(); + user.Instance.RiotConnection.SetChunkSize(2147483647); + + AuthenticationCredentials newCredentials = new AuthenticationCredentials + { + AuthToken = await + user.Instance.calls.GetRestToken(LoginUsernameBox.Text, LoginPasswordBox.Password, garenaregion.LoginQueue, reToken(s1)), + Username = user.Instance.UID, + Password = null, + ClientVersion = Client.Version, + IpAddress = user.Instance.calls.GetIpAddress(), + Locale = garenaregion.Locale, + PartnerCredentials = "8393 " + s1, + OperatingSystem = "Windows 7", + Domain = "lolclient.lol.riotgames.com", + }; + Session login = await user.Instance.calls.Login(newCredentials); + user.Instance.PlayerSession = login; + var str1 = string.Format("gn-{0}", login.AccountSummary.AccountId); + var str2 = string.Format("cn-{0}", login.AccountSummary.AccountId); + var str3 = string.Format("bc-{0}", login.AccountSummary.AccountId); + Task[] taskArray = { user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str1, str1), + user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", str2, str2), + user.Instance.RiotConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", str3) }; + + await Task.WhenAll(taskArray); + var LoggedIn = await user.Instance.RiotConnection.LoginAsync(user.Instance.UID, login.Token); + var packet = await user.Instance.calls.GetLoginDataPacketForUser(); + DoGetOnLoginPacket(user.Instance.UID, null, garenaregion, packet, user); + } + } + } + + private static string GetCommandLine(Process process) + { + var commandLine = new StringBuilder(""); + + using (var searcher = new ManagementObjectSearcher("SELECT CommandLine FROM Win32_Process WHERE ProcessId = " + process.Id)) + { + foreach (var @object in searcher.Get()) + { + commandLine.Append(@object["CommandLine"]); + } + } + + return commandLine.ToString(); + } + + private void UpdateRegionComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.RemovedItems.Count != 0) + { + Settings.Default.updateRegion = (string)UpdateRegionComboBox.SelectedValue; + Settings.Default.Save(); + + //user.Instance.UpdateRegion = (string)UpdateRegionComboBox.SelectedValue; + /* + if (!RegionComboBox.Items.IsInUse) + { + RegionComboBox.Items.Clear(); + Thread.Sleep(100); + } + //*/ + switch ((string)UpdateRegionComboBox.SelectedValue) + { + case "PBE": + RegionComboBox.ItemsSource = new[] { "PBE" }; + LoginUsernameBox.Visibility = Visibility.Visible; + LoginPasswordBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + break; + + case "Live": + RegionComboBox.ItemsSource = new[] { "BR", "EUNE", "EUW", "NA", "OCE", "RU", "LAS", "LAN", "TR", "CS" }; + LoginUsernameBox.Visibility = Visibility.Visible; + LoginPasswordBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + break; + + case "Korea": + RegionComboBox.ItemsSource = new[] { "KR" }; + LoginUsernameBox.Visibility = Visibility.Visible; + RememberUsernameCheckbox.Visibility = Visibility.Visible; + LoginPasswordBox.Visibility = Visibility.Visible; + break; + + case "Garena": + RegionComboBox.ItemsSource = new[] { "PH", "SG", "SGMY", "TH", "TW", "VN", "ID" }; + LoginUsernameBox.Visibility = Visibility.Hidden; + RememberUsernameCheckbox.Visibility = Visibility.Hidden; + LoginPasswordBox.Visibility = Visibility.Hidden; + break; + } + } + } + + public string getGas(Deletable user) + { + //string begin = "{\"signature\":\""; + //string end = "}"; + string gas = user.Instance.Gas; + gas = gas.Replace("\r\n ", ""); + byte[] encbuff = Encoding.UTF8.GetBytes(gas); + gas = HttpServerUtility.UrlTokenEncode(encbuff); + + return gas; + } + + private static string reToken(string s) + { + var s1 = s.Replace("/", "%2F"); + s1 = s1.Replace("+", "%2B"); + s1 = s1.Replace("=", "%3D"); + + return s1; + } + + private void AutoLoginCheckBox_CheckChanged(object sender, RoutedEventArgs e) + { + if ((AutoLoginCheckBox.IsChecked == true && RememberUsernameCheckbox.IsChecked == true && RememberPasswordCheckbox.IsChecked == true) || (string)UpdateRegionComboBox.SelectedValue == "Garena") + { + Settings.Default.AutoLogin = true; + } + else + { + RememberPasswordCheckbox.IsChecked = true; + RememberUsernameCheckbox.IsChecked = true; + Settings.Default.AutoLogin = true; + } + + Settings.Default.Save(); + } + + private void MouseGrid_Loaded(object sender, RoutedEventArgs e) + { + Dispatcher.BeginInvoke(new ThreadStart(() => + { + AutoLoginCheckBox.IsChecked = Settings.Default.AutoLogin; + }), DispatcherPriority.Input); + + System.Timers.Timer timer = new System.Timers.Timer { Interval = 3000 }; + + timer.Elapsed += (s, a) => + { + timer.Stop(); + + bool autoLogin = false; + Dispatcher.Invoke(() => + { + autoLogin = (bool)AutoLoginCheckBox.IsChecked; + }); + + if (autoLogin) + { + Client.Log("Auto login"); + Dispatcher.BeginInvoke(new ThreadStart(() => + { + LoginButton_Click(1, null); + }), DispatcherPriority.Input); + } + }; + //timer.Start(); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + if (String.IsNullOrWhiteSpace(Encrypt.Password)) + { + MessageBox.Show("Please enter an encryption password"); + return; + } + if (!UserList.VerifyEncrypt(Encrypt.Password)) + { + MessageBox.Show("Encryption is WRONG"); + return; + } + Client.EncrytKey = Encrypt.Password; + authed = true; + List data = UserList.GetAllUsers(Encrypt.Password); + foreach (var acc in data) + { + Client.Log("Found " + acc.SumName); +#if DEBUG + Client.Log(string.Format("User: {0} Pass: {1} Region: {2}", acc.User, acc.Pass, acc.Region)); +#endif + dataLogin.Add(acc.SumName + ":" + acc.Region, acc); + if (acc.Region.Garena) + garenaLogin(acc.Region, new UserClient { Garena = true }); + else + Login(acc.User, acc.Pass, acc.Region, new UserClient()); + } + EncryptBox.Visibility = Visibility.Hidden; + } + + private void AddAccountButton_Click(object sender, RoutedEventArgs e) + { + Client.Log("starting to login"); + if (!authed) + { + ErrorTextBox.Text = "You must auth yourself first"; + Client.Log("Auth first"); + return; + } + + var region = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue); + saveuser = true; + if (region.Garena) + garenaLogin(region, new UserClient()); + else + Login(LoginUsernameBox.Text, LoginPasswordBox.Password, region, new UserClient()); + } + + private void slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) + { + if ((sender as Slider).IsInitialized) + { + SoundPlayer.Volume = e.NewValue / 100; + Settings.Default.LoginMusicVolume = e.NewValue; + Settings.Default.Save(); + _lastVolume = e.OldValue / 100; + if (e.NewValue == 0) + { + //Change to muted icon + muteButton.Data = Geometry.Parse("M16.5 12c0-1.77-1.02-3.29-2.5-4.03v2.21l2.45 2.45c.03-.2.05-.41.05-.63zm2.5 0c0 .94-.2 1.82-.54 2.64l1.51 1.51C20.63 14.91 21 13.5 21 12c0-4.28-2.99-7.86-7-8.77v2.06c2.89.86 5 3.54 5 6.71zM4.27 3L3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25c-.67.52-1.42.93-2.25 1.18v2.06c1.38-.31 2.63-.95 3.69-1.81L19.73 21 21 19.73l-9-9L4.27 3zM12 4L9.91 6.09 12 8.18V4z"); + } + else + { + //Change to volume icon + muteButton.Data = Geometry.Parse("M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z"); + } + } + } + + private void MuteButton_Click(object sender, RoutedEventArgs e) + { + if ((sender as Button).IsInitialized) + { + if (SoundPlayer.Volume == 0) + { + if (_lastVolume != 0) + { + SoundPlayer.Volume = _lastVolume; + slider.Value = _lastVolume * 100; + } + else + { + SoundPlayer.Volume = 0.5; + slider.Value = 50; + } + } + else + { + slider.Value = 0; + } + } + } + } +} diff --git a/Sightstone/Windows/MainPage.xaml b/Sightstone/Windows/MainPage.xaml new file mode 100644 index 00000000..65bb3538 --- /dev/null +++ b/Sightstone/Windows/MainPage.xaml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient/Windows/MainPage.xaml.cs b/Sightstone/Windows/MainPage.xaml.cs similarity index 78% rename from LegendaryClient/Windows/MainPage.xaml.cs rename to Sightstone/Windows/MainPage.xaml.cs index 0a44bbcd..3969ba8e 100644 --- a/LegendaryClient/Windows/MainPage.xaml.cs +++ b/Sightstone/Windows/MainPage.xaml.cs @@ -19,66 +19,80 @@ using System.Windows.Media.Imaging; using System.Windows.Threading; using System.Xml; -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.Maps; -using LegendaryClient.Logic.PlayerSpell; -using LegendaryClient.Logic.Region; -using LegendaryClient.Logic.Replays; -using LegendaryClient.Logic.SQLite; -using LegendaryClient.Scripting_Environment; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.Maps; +using Sightstone.Logic.PlayerSpell; +using Sightstone.Logic.Region; +using Sightstone.Logic.Replays; +using Sightstone.Logic.SQLite; +using Sightstone.Scripting_Environment; using Newtonsoft.Json; using Image = System.Windows.Controls.Image; using Point = System.Drawing.Point; using Size = System.Drawing.Size; using Timer = System.Timers.Timer; -using LegendaryClient.Logic.Crypto; -using LegendaryClient.Logic.Riot; -using LegendaryClient.Logic.Riot.Leagues; -using LegendaryClient.Logic.Riot.Platform; +using Sightstone.Logic.Crypto; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Leagues; +using Sightstone.Logic.Riot.Platform; using RtmpSharp.Messaging; using agsXMPP.protocol.client; +using Sightstone.Logic.MultiUser; #endregion -namespace LegendaryClient.Windows +namespace Sightstone.Windows { /// /// Interaction logic for MainPage.xaml /// + /// + public partial class MainPage { + private void ScrollViewer_PreviewMouseWheel(object sender, MouseWheelEventArgs e) + { + ScrollViewer scrollviewer = sender as ScrollViewer; + if (e.Delta > 0) + scrollviewer.LineLeft(); + else + scrollviewer.LineRight(); + e.Handled = true; + } + internal static Timer timer = new Timer(); internal ArrayList GameList; internal ArrayList NewsList; internal int SelectedGame = 0; internal bool CheckedDev = false; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public MainPage() { InitializeComponent(); - GotPlayerData(Client.LoginPacket); - SpectatorComboBox.SelectedValue = Client.Region.RegionName.ToUpper(); - BaseRegion region = BaseRegion.GetRegion(Client.Region.RegionName); + GotPlayerData(UserClient.LoginPacket); + SpectatorComboBox.SelectedValue = UserClient.Region.RegionName.ToUpper(); + BaseRegion region = BaseRegion.GetRegion(UserClient.Region.RegionName); Client.Profile = new ProfilePage(); GetNews(region); - ChangeSpectatorRegion(Client.Region); + ChangeSpectatorRegion(UserClient.Region); var update = new Timer { Interval = 5000 }; update.Elapsed += (o, e) => - Client.XmppConnection.Send(new Presence(Client.presenceStatus, Client.GetPresence(), 0)); + UserClient.XmppConnection.Send(new Presence(UserClient.presenceStatus, UserClient.GetPresence(), 0)); timer.Interval = (5000); //timer.Start(); timer.Elapsed += (o, e) => Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { string Jid = - Client.GetChatroomJid(Client.GetObfuscatedChatroomName("legendaryclient", ChatPrefixes.Public), + Client.GetChatroomJid(Client.GetObfuscatedChatroomName("Sightstone", ChatPrefixes.Public), string.Empty, true); - GroupChatItem item = Join(Jid, "LegendaryClient"); + GroupChatItem item = Join(Jid, "Sightstone"); var chatGroup = new NotificationChatGroup { Tag = item, @@ -86,7 +100,7 @@ public MainPage() Margin = new Thickness(1, 0, 1, 0), GroupLabelName = { Content = item.GroupTitle } }; - if (Client.GroupChatItems.All(i => i.GroupTitle != "LegendaryClient")) + if (Client.GroupChatItems.All(i => i.GroupTitle != "Sightstone")) { Client.ChatListView.Items.Add(chatGroup); Client.GroupChatItems.Add(item); @@ -125,20 +139,20 @@ private GroupChatItem Join(string Jid, string chat) private void GotPlayerData(LoginDataPacket packet) { - Client.RiotConnection.MessageReceived += PVPNet_OnMessageReceived; + UserClient.RiotConnection.MessageReceived += PVPNet_OnMessageReceived; UpdateSummonerInformation(); } internal async void UpdateSummonerInformation() { - if (Client.IsLoggedIn) + if (UserClient.IsLoggedIn) { AllSummonerData playerData = - await RiotCalls.GetAllSummonerDataByAccount(Client.LoginPacket.AllSummonerData.Summoner.AcctId); + await UserClient.calls.GetAllSummonerDataByAccount(UserClient.LoginPacket.AllSummonerData.Summoner.AcctId); SummonerNameLabel.Content = playerData.Summoner.Name; - SummonerActiveBoostsDTO activeBoost = await RiotCalls.GetSummonerActiveBoosts(); + SummonerActiveBoostsDTO activeBoost = await UserClient.calls.GetSummonerActiveBoosts(); string xpBoostTime = ConvertBoostTime(activeBoost.XpBoostEndDate); if (xpBoostTime != string.Empty && activeBoost.XpBoostEndDate > 0) @@ -179,14 +193,14 @@ internal async void UpdateSummonerInformation() Sha1 sha1 = new Sha1(); if (!CheckedDev) { - if (DevUsers.getDevelopers().Contains(sha1.Hash(playerData.Summoner.Name + " " + Client.Region.RegionName))) + if (DevUsers.getDevelopers().Contains(sha1.Hash(playerData.Summoner.Name + " " + UserClient.Region.RegionName))) { - Client.Dev = true; + UserClient.Dev = true; } CheckedDev = true; } - if (Client.Dev) + if (UserClient.Dev) { Client.UserTitleBarLabel.Content = "Dev ∙ " + playerData.Summoner.Name; } @@ -195,7 +209,7 @@ internal async void UpdateSummonerInformation() Client.UserTitleBarLabel.Content = playerData.Summoner.Name; } - if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30) + if (UserClient.LoginPacket.AllSummonerData.SummonerLevel.Level < 30) { PlayerProgressBar.Value = (playerData.SummonerLevelAndPoints.ExpPoints / playerData.SummonerLevel.ExpToNextLevel) * 100; @@ -205,40 +219,39 @@ internal async void UpdateSummonerInformation() Client.UserTitleBarLabel.Content = Client.UserTitleBarLabel.Content + string.Format(" ∙ Level: {0}", playerData.SummonerLevel.Level); } else - GotLeaguesForPlayer(await RiotCalls.GetAllLeaguesForPlayer(playerData.Summoner.SumId)); + GotLeaguesForPlayer(await UserClient.calls.GetAllLeaguesForPlayer(playerData.Summoner.SumId)); - if (Client.LoginPacket.BroadcastNotification.broadcastMessages != null) + if (UserClient.LoginPacket.BroadcastNotification.broadcastMessages != null) { - var message = Client.LoginPacket.BroadcastNotification.broadcastMessages[0]; + var message = UserClient.LoginPacket.BroadcastNotification.broadcastMessages[0]; if (message != null) { //BroadcastMessage.Text = message.Content; } } - foreach (PlayerStatSummary x in Client.LoginPacket.PlayerStatSummaries.PlayerStatSummarySet) + foreach (PlayerStatSummary x in UserClient.LoginPacket.PlayerStatSummaries.PlayerStatSummarySet) { if (x.PlayerStatSummaryTypeString == "Unranked") { - Client.IsRanked = false; - Client.AmountOfWins = x.Wins; + UserClient.IsRanked = false; + UserClient.AmountOfWins = x.Wins; } if (x.PlayerStatSummaryTypeString != "RankedSolo5x5") continue; if (x.Rating != 0) { - Client.IsRanked = true; - Client.AmountOfWins = x.Wins; + UserClient.IsRanked = true; + UserClient.AmountOfWins = x.Wins; } break; } - Client.InfoLabel.Content = "IP: " + Client.LoginPacket.IpBalance + " ∙ RP: " + Client.LoginPacket.RpBalance; - int profileIconId = Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId; - var UriSource = - new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", profileIconId + ".png"), - UriKind.RelativeOrAbsolute); + Client.InfoLabel.Content = "IP: " + UserClient.LoginPacket.IpBalance + " ∙ RP: " + UserClient.LoginPacket.RpBalance; + int profileIconId = UserClient.LoginPacket.AllSummonerData.Summoner.ProfileIconId; + + var UriSource = Client.GetIconUri(profileIconId); try { ProfileImage.Source = new BitmapImage(UriSource); @@ -263,8 +276,8 @@ private string ConvertBoostTime(double millisTimeStamp) TimeSpan diff2 = dtDateTime.Subtract(DateTime.Now); if (diff2.Days >= 0 && diff2.Hours > 0) { - string time = diff2.Days.ToString() + " Days "; - time += diff2.Hours.ToString() + " Hours"; + string time = diff2.Days + " Days "; + time += diff2.Hours + " Hours"; return time; } return string.Empty; @@ -285,9 +298,9 @@ private void GotLeaguesForPlayer(SummonerLeaguesDTO result) { var leagues = result.SummonerLeagues.Single(x => x.Queue == "RANKED_SOLO_5x5"); - Client.Tier = leagues.RequestorsRank; - Client.TierName = leagues.Tier; - Client.LeagueName = leagues.Name; + UserClient.Tier = leagues.RequestorsRank; + UserClient.TierName = leagues.Tier; + UserClient.LeagueName = leagues.Name; CurrentTier = leagues.Tier + " " + leagues.RequestorsRank; List players = leagues.Entries.OrderBy(o => o.LeaguePoints) @@ -295,7 +308,7 @@ private void GotLeaguesForPlayer(SummonerLeaguesDTO result) .ToList(); foreach (LeagueItemDTO player in players) { - if (player.PlayerOrTeamName != Client.LoginPacket.AllSummonerData.Summoner.Name) + if (player.PlayerOrTeamName != UserClient.LoginPacket.AllSummonerData.Summoner.Name) continue; string Series = ""; @@ -380,12 +393,6 @@ private void HoverLabel_MouseLeave(object sender, MouseEventArgs e) HoverLabel.Opacity = 0; } - private void InviteTest_Click(object sender, RoutedEventArgs e) - { - //Client.OverlayContainer.Content = new GameInviteTest().Content; - //Client.OverlayContainer.Visibility = Visibility.Visible; - } - private void PVPNet_OnMessageReceived(object sender, MessageReceivedEventArgs message) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => @@ -393,11 +400,11 @@ private void PVPNet_OnMessageReceived(object sender, MessageReceivedEventArgs me if (!(message.Body is BroadcastNotification)) return; - //var notif = message as BroadcastNotification; - //if (notif.BroadcastMessages == null) - // return; - // - //var Message = notif.BroadcastMessages[0]; + var notif = (BroadcastNotification) message.Body; + if (notif.broadcastMessages == null) + return; + + var Message = notif.broadcastMessages[0]; //if (Message != null && Message.Active) // BroadcastMessage.Text = Message.Content; //else @@ -451,10 +458,17 @@ private void GetNews(BaseRegion region) deserializedJson = null; return; } - - var rss = deserializedJson["rss"] as Dictionary; - if (rss == null) + Dictionary rss = null; + try + { + rss = deserializedJson["rss"] as Dictionary; + if (rss == null) + return; + } + catch + { return; + } var channel = rss["channel"] as Dictionary; if (channel != null) @@ -587,17 +601,11 @@ private void ParseSpectatorGames() if (GameList.Count <= 0) return; - - BlueBansLabel.Visibility = Visibility.Hidden; - PurpleBansLabel.Visibility = Visibility.Hidden; - BlueBanListView.Items.Clear(); - PurpleBanListView.Items.Clear(); BlueListView.Items.Clear(); PurpleListView.Items.Clear(); int gameId = 0; object objectGame = GameList[SelectedGame]; - var spectatorGame = objectGame as Dictionary; - ImageGrid.Children.Clear(); + var spectatorGame = objectGame as Dictionary;; if (spectatorGame != null) foreach (var pair in spectatorGame) { @@ -637,24 +645,15 @@ private void ParseSpectatorGames() break; } } - var control = new ChampSelectPlayer + var control = new MainPagePlayer { ChampionImage = { Source = champions.GetChampion(championId).icon }, champID = championId, sumName = playerName, KnownPar = true }; - var UriSource = - new System.Uri( - Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName(spell1Id)), UriKind.Absolute); - control.SummonerSpell1.Source = new BitmapImage(UriSource); - UriSource = - new System.Uri( - Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName(spell2Id)), UriKind.Absolute); - control.SummonerSpell2.Source = new BitmapImage(UriSource); - control.PlayerName.Content = playerName; + + control.Tag = new List { playerName, championId }; var m = new Image(); @@ -668,7 +667,7 @@ private void ParseSpectatorGames() var cropRect = new Rectangle(new Point(100, 0), new Size(100, 560)); var src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, - "Assets", + "Assets", "images", "champions", champions.GetChampion(championId).portraitPath)) as Bitmap; var target = new Bitmap(cropRect.Width, cropRect.Height); @@ -678,7 +677,6 @@ private void ParseSpectatorGames() GraphicsUnit.Pixel); m.Source = Client.ToWpfBitmap(target); - ImageGrid.Children.Add(m); if (teamId == 100) BlueListView.Items.Add(control); else @@ -720,53 +718,6 @@ private void ParseSpectatorGames() break; case "bannedChampions": { - //ArrayList players = pair.Value as ArrayList; - //Dictionary playerInfo = objectPlayer as Dictionary; - //foreach (KeyValuePair playerPair in playerInfo) - var keyArray = pair.Value as ArrayList; - if (keyArray.Count > 0) - { - BlueBansLabel.Visibility = Visibility.Visible; - PurpleBansLabel.Visibility = Visibility.Visible; - } - foreach (Dictionary keyArrayP in keyArray) - //Dictionary keyArrayP = keyArray as Dictionary; - { - int cid = 0; - int teamId = 100; - foreach (var keyArrayPair in keyArrayP) - { - switch (keyArrayPair.Key) - { - case "championId": - cid = (int)keyArrayPair.Value; - break; - case "teamId": - teamId = (int)keyArrayPair.Value; - break; - } - } - var item = new ListViewItem(); - var champImage = new Image - { - Height = 58, - Width = 58 - }; - //temp - try - { - champImage.Source = champions.GetChampion(cid).icon; - } - catch - { - } - - item.Content = champImage; - if (teamId == 100) - BlueBanListView.Items.Add(item); - else - PurpleBanListView.Items.Add(item); - } } break; } @@ -790,7 +741,7 @@ private void ParseSpectatorGames() MMRLabel.Content = "N/A"; } - if (Client.curentlyRecording.Contains(gameId)) + if (UserClient.curentlyRecording.Contains(gameId)) { RecordButton.IsEnabled = false; RecordButton.Content = "Recording..."; diff --git a/Sightstone/Windows/MasteriesOverlay.xaml b/Sightstone/Windows/MasteriesOverlay.xaml new file mode 100644 index 00000000..3b28c466 --- /dev/null +++ b/Sightstone/Windows/MasteriesOverlay.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient/Windows/MasteriesOverlay.xaml.cs b/Sightstone/Windows/MasteriesOverlay.xaml.cs similarity index 79% rename from LegendaryClient/Windows/MasteriesOverlay.xaml.cs rename to Sightstone/Windows/MasteriesOverlay.xaml.cs index 9774fc63..ac9d7b9d 100644 --- a/LegendaryClient/Windows/MasteriesOverlay.xaml.cs +++ b/Sightstone/Windows/MasteriesOverlay.xaml.cs @@ -1,8 +1,9 @@ -using LegendaryClient.Logic; -using LegendaryClient.Windows.Profile; +using Sightstone.Logic; +using Sightstone.Logic.MultiUser; +using Sightstone.Windows.Profile; using System.Windows; -namespace LegendaryClient.Windows +namespace Sightstone.Windows { /// /// Interaction logic for MasteriesOverlay.xaml diff --git a/Sightstone/Windows/MessageOverlay.xaml b/Sightstone/Windows/MessageOverlay.xaml new file mode 100644 index 00000000..c3a31da6 --- /dev/null +++ b/Sightstone/Windows/MessageOverlay.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/Sightstone/Windows/PluginsPage.xaml.cs b/Sightstone/Windows/PluginsPage.xaml.cs new file mode 100644 index 00000000..7f83373e --- /dev/null +++ b/Sightstone/Windows/PluginsPage.xaml.cs @@ -0,0 +1,51 @@ +using Sightstone.Controls; +using Sightstone.Logic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.NetworkInformation; +using System.Threading; +using System.Threading.Tasks; +using System.Timers; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Threading; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Platform; +using RtmpSharp.IO; +using RtmpSharp.Messaging; + +namespace Sightstone.Windows +{ + /// + /// Interaction logic for PluginsPage.xaml + /// + public partial class PluginsPage + { + private Scripting_Environment.Plugin_Core Core = new Scripting_Environment.Plugin_Core(); + public PluginsPage() + { + InitializeComponent(); + } + private void LoadScript_Click(object sender, RoutedEventArgs e) + { + Microsoft.Win32.OpenFileDialog myFile = new Microsoft.Win32.OpenFileDialog(); + if (myFile.ShowDialog().GetValueOrDefault() == false) + return; + var PluginPath = myFile.FileName; + var loadedPlugin = Core.LoadScript(PluginPath, myFile.SafeFileName); + Core.runAll(); + PluginList.Items.Add(new test { Enabled = true, Author = "", Description = loadedPlugin.Description, Name = loadedPlugin.Name, Version = "1.0.0.0" }); + } + public class test + { + public bool Enabled; + public string Name; + public string Version; + public string Author; + public string Description; + } + } +} \ No newline at end of file diff --git a/LegendaryClient/Windows/Profile/AggregatedStatsOverlay.xaml b/Sightstone/Windows/Profile/AggregatedStatsOverlay.xaml similarity index 98% rename from LegendaryClient/Windows/Profile/AggregatedStatsOverlay.xaml rename to Sightstone/Windows/Profile/AggregatedStatsOverlay.xaml index a71d86be..03c55c91 100644 --- a/LegendaryClient/Windows/Profile/AggregatedStatsOverlay.xaml +++ b/Sightstone/Windows/Profile/AggregatedStatsOverlay.xaml @@ -1,4 +1,4 @@ - /// Interaction logic for AggregatedStatsOverlay.xaml @@ -23,7 +24,7 @@ public partial class AggregatedStatsOverlay private readonly List championStats; private readonly bool isOwnPlayer; - public AggregatedStatsOverlay(AggregatedStats stats, bool isSelf) + public AggregatedStatsOverlay(AggregatedStats stats, bool isSelf, int autoDisplayChampionId = 0) { InitializeComponent(); isOwnPlayer = isSelf; @@ -33,6 +34,28 @@ public AggregatedStatsOverlay(AggregatedStats stats, bool isSelf) selectedStats = allStats; HideGrid.Visibility = Visibility.Visible; DisplayStats(); + if (autoDisplayChampionId != 0) + { + foreach (var item in ChampionsListView.Items) + { + if (item is ListViewItem) + { + ListViewItem i = item as ListViewItem; + var tempStats = (AggregatedChampion)i.Tag; + if (tempStats.ChampionId == autoDisplayChampionId) + { + selectedStats = tempStats; + if (!isOwnPlayer) + { + HideGrid.Visibility = Visibility.Hidden; + } + DisplayStats(); + ChampionsListView.SelectedIndex = ChampionsListView.Items.IndexOf(i); + i.Focus(); + } + } + } + } } private void DisplayStats() diff --git a/Sightstone/Windows/Profile/Champions.xaml b/Sightstone/Windows/Profile/Champions.xaml new file mode 100644 index 00000000..557c692e --- /dev/null +++ b/Sightstone/Windows/Profile/Champions.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + Filters: + Name: + + Availability: + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient/Windows/Profile/Champions.xaml.cs b/Sightstone/Windows/Profile/Champions.xaml.cs similarity index 86% rename from LegendaryClient/Windows/Profile/Champions.xaml.cs rename to Sightstone/Windows/Profile/Champions.xaml.cs index f5a28f66..1405b2be 100644 --- a/LegendaryClient/Windows/Profile/Champions.xaml.cs +++ b/Sightstone/Windows/Profile/Champions.xaml.cs @@ -1,15 +1,16 @@ -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.SQLite; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.SQLite; using System; using System.Collections.Generic; using System.Linq; using System.Windows; using System.Windows.Controls; -using LegendaryClient.Logic.Riot; -using LegendaryClient.Logic.Riot.Platform; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Platform; +using Sightstone.Logic.MultiUser; -namespace LegendaryClient.Windows.Profile +namespace Sightstone.Windows.Profile { /// /// Interaction logic for Champions.xaml @@ -19,7 +20,7 @@ public partial class Champions private List _championList; private bool _noFilterOnLoad; //private static readonly ILog log = LogManager.GetLogger(typeof(Champions)); - + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public Champions() { InitializeComponent(); @@ -27,7 +28,7 @@ public Champions() public async void Update() { - var champList = await RiotCalls.GetAvailableChampions(); + var champList = await UserClient.calls.GetAvailableChampions(); _championList = new List(champList); @@ -35,11 +36,11 @@ public async void Update() (x, y) => string.Compare(champions.GetChampion(x.ChampionId) .displayName, champions.GetChampion(y.ChampionId).displayName, StringComparison.Ordinal)); - if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level <= Client.LoginPacket.ClientSystemStates.freeToPlayChampionsForNewPlayersMaxLevel) + if (UserClient.LoginPacket.AllSummonerData.SummonerLevel.Level <= UserClient.LoginPacket.ClientSystemStates.freeToPlayChampionsForNewPlayersMaxLevel) { _championList.ForEach(x => x.FreeToPlay = false); _championList.FindAll(x => - Client.LoginPacket.ClientSystemStates.freeToPlayChampionForNewPlayersIdList.Contains(x.ChampionId)). + UserClient.LoginPacket.ClientSystemStates.freeToPlayChampionForNewPlayersIdList.Contains(x.ChampionId)). ForEach(x => x.FreeToPlay = true); } FilterChampions(); diff --git a/LegendaryClient/Windows/Profile/Ingame.xaml b/Sightstone/Windows/Profile/Ingame.xaml similarity index 97% rename from LegendaryClient/Windows/Profile/Ingame.xaml rename to Sightstone/Windows/Profile/Ingame.xaml index d7a6a859..292d507b 100644 --- a/LegendaryClient/Windows/Profile/Ingame.xaml +++ b/Sightstone/Windows/Profile/Ingame.xaml @@ -1,4 +1,4 @@ - - + diff --git a/LegendaryClient/Windows/Profile/Ingame.xaml.cs b/Sightstone/Windows/Profile/Ingame.xaml.cs similarity index 84% rename from LegendaryClient/Windows/Profile/Ingame.xaml.cs rename to Sightstone/Windows/Profile/Ingame.xaml.cs index 18faeb34..a605e2d3 100644 --- a/LegendaryClient/Windows/Profile/Ingame.xaml.cs +++ b/Sightstone/Windows/Profile/Ingame.xaml.cs @@ -1,7 +1,7 @@ -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.PlayerSpell; -using LegendaryClient.Logic.SQLite; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.PlayerSpell; +using Sightstone.Logic.SQLite; using System; using System.Collections.Generic; using System.Drawing; @@ -13,14 +13,15 @@ using System.Windows.Controls; using System.Windows.Media; using System.Windows.Media.Imaging; -using LegendaryClient.Logic.Riot.Platform; +using Sightstone.Logic.Riot.Platform; using Brush = System.Windows.Media.Brush; using Color = System.Drawing.Color; using Image = System.Windows.Controls.Image; using Point = System.Drawing.Point; using Size = System.Drawing.Size; +using Sightstone.Logic.MultiUser; -namespace LegendaryClient.Windows.Profile +namespace Sightstone.Windows.Profile { /// /// Interaction logic for Ingame.xaml @@ -29,6 +30,7 @@ public partial class Ingame { private PlatformGameLifecycleDTO game; private string user; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public Ingame() { @@ -70,17 +72,9 @@ var championSelect in control.sumName = participant.SummonerInternalName; control.champID = championSelect.ChampionId; control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon; - var UriSource = - new System.Uri( - Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), - UriKind.Absolute); + var UriSource = Client.GetSpellIconUri((NameToImage)championSelect.Spell1Id); control.SummonerSpell1.Source = new BitmapImage(UriSource); - UriSource = - new System.Uri( - Path.Combine(Client.ExecutingDirectory, "Assets", "spell", - SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), - UriKind.Absolute); + UriSource = Client.GetSpellIconUri((NameToImage)championSelect.Spell2Id); control.SummonerSpell2.Source = new BitmapImage(UriSource); var m = new Image(); @@ -90,10 +84,10 @@ var championSelect in m.Opacity = 0.50; m.HorizontalAlignment = HorizontalAlignment.Left; m.VerticalAlignment = VerticalAlignment.Stretch; - m.Margin = new Thickness(y++*100, 0, 0, 0); + m.Margin = new Thickness(y++ * 100, 0, 0, 0); var cropRect = new Rectangle(new Point(100, 0), new Size(100, 560)); var src = - System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", + System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "images", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as Bitmap; var target = new Bitmap(cropRect.Width, cropRect.Height); @@ -127,7 +121,7 @@ var championSelect in var converter = new BrushConverter(); var brush = (Brush) converter.ConvertFromString("#" + myColor.Name); - control.TeamRectangle.Fill = brush; + control.TeamRectangle.BorderBrush = brush; control.TeamRectangle.Visibility = Visibility.Visible; } } @@ -170,7 +164,7 @@ var championSelect in try { string mmrJson; - var url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + + var url = UserClient.Region.SpectatorLink + "consumer/getGameMetaData/" + UserClient.Region.InternalName + "/" + currentGame.Game.Id + "/token"; using (var client = new WebClient()) { @@ -197,10 +191,12 @@ private void GameScouter_Click(object sender, RoutedEventArgs e) private void SpectateButton_Click(object sender, RoutedEventArgs e) { + if (game == null) return; + var ip = game.PlayerCredentials.ObserverServerIp; var key = game.PlayerCredentials.ObserverEncryptionKey; var gameId = game.PlayerCredentials.GameId; - Client.LaunchSpectatorGame(ip, key, (int) gameId, Client.Region.InternalName); + Client.LaunchSpectatorGame(ip, key, (int) gameId, UserClient.Region.InternalName); } } } \ No newline at end of file diff --git a/Sightstone/Windows/Profile/Leagues.xaml b/Sightstone/Windows/Profile/Leagues.xaml new file mode 100644 index 00000000..cdcbb5ae --- /dev/null +++ b/Sightstone/Windows/Profile/Leagues.xaml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + Devision: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LegendaryClient/Windows/Profile/Leagues.xaml.cs b/Sightstone/Windows/Profile/Leagues.xaml.cs similarity index 80% rename from LegendaryClient/Windows/Profile/Leagues.xaml.cs rename to Sightstone/Windows/Profile/Leagues.xaml.cs index ab89a2f9..8de5c000 100644 --- a/LegendaryClient/Windows/Profile/Leagues.xaml.cs +++ b/Sightstone/Windows/Profile/Leagues.xaml.cs @@ -1,6 +1,6 @@ -using LegendaryClient.Controls; -using LegendaryClient.Logic; -using LegendaryClient.Logic.SQLite; +using Sightstone.Controls; +using Sightstone.Logic; +using Sightstone.Logic.SQLite; using System; using System.Collections.Generic; using System.Linq; @@ -9,10 +9,11 @@ using System.Windows.Controls; using System.Windows.Media; using System.Windows.Threading; -using LegendaryClient.Logic.Riot; -using LegendaryClient.Logic.Riot.Platform; +using Sightstone.Logic.Riot; +using Sightstone.Logic.Riot.Platform; +using Sightstone.Logic.MultiUser; -namespace LegendaryClient.Windows.Profile +namespace Sightstone.Windows.Profile { /// /// Interaction logic for Leagues.xaml @@ -24,6 +25,7 @@ public partial class Leagues private string queue; private AggregatedStats selectedAggregatedStats; private string selectedRank; + static UserClient UserClient = (UserList.Users[Client.CurrentServer])[Client.CurrentUser]; public Leagues() { @@ -80,7 +82,7 @@ public void RenderLeague() } CurrentLeagueLabel.Content = leagues.Tier + " " + selectedRank; - CurrentLeagueNameLabel.Content = leagues.Name; + CurrentLeagueNameLabel.Content = "(" + leagues.Name + ")"; var players = leagues.Entries.OrderBy(o => o.LeaguePoints).Where(item => item.Rank == selectedRank).ToList(); players.Reverse(); @@ -180,8 +182,8 @@ private async void LeaguesListView_SelectionChanged(object sender, SelectionChan var item = (LeagueItem) LeaguesListView.SelectedItem; PlayerLabel.Content = item.PlayerLabel.Content; - var x = await RiotCalls.GetSummonerByName((string) item.PlayerLabel.Content); - GotStats(await RiotCalls.GetAggregatedStats(x.AcctId, "CLASSIC", Client.LoginPacket.ClientSystemStates.currentSeason.ToString())); + var x = await UserClient.calls.GetSummonerByName((string) item.PlayerLabel.Content); + GotStats(await UserClient.calls.GetAggregatedStats(x.AcctId, "CLASSIC", UserClient.LoginPacket.ClientSystemStates.currentSeason.ToString())); } private void GotStats(AggregatedStats stats) @@ -236,19 +238,28 @@ private void GotStats(AggregatedStats stats) } var champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); - var player = new ChatPlayer + var player = new ProfileTopChampion { - LevelLabel = {Visibility = Visibility.Hidden}, - PlayerName = {Content = champion.displayName}, - PlayerStatus = {Content = info.TotalSessionsPlayed + " games played"}, - ProfileImage = {Source = champions.GetChampion(champion.id).icon}, - Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)), - Width = 270 + ChampionName = { Content = champion.displayName, Foreground = FindResource("MaterialDesignBody") as SolidColorBrush, }, + GamesCounter = { Content = info.TotalSessionsPlayed + " games played", Foreground = FindResource("MaterialDesignBody") as SolidColorBrush }, + ChampionImage = { Source = champions.GetChampion(champion.id).icon }, + Width = TopChampionsListView.ActualWidth, }; TopChampionsListView.Items.Add(player); } })); } + + private async void ViewAggregatedStatsButton_Click(object sender, RoutedEventArgs e) + { + if (!(LeaguesListView.SelectedItem is LeagueItem)) return; + var player = LeaguesListView.SelectedItem as LeagueItem; + var summoner = await UserClient.calls.GetSummonerByName(player.PlayerLabel.Content.ToString()); + var x = await UserClient.calls.GetAggregatedStats(summoner.AcctId, "CLASSIC", UserClient.LoginPacket.ClientSystemStates.currentSeason.ToString()); + Client.OverlayContainer.Content = + new AggregatedStatsOverlay(x, summoner.AcctId == UserClient.LoginPacket.AllSummonerData.Summoner.AcctId).Content; + Client.OverlayContainer.Visibility = Visibility.Visible; + } } } diff --git a/Sightstone/Windows/Profile/Masteries.xaml b/Sightstone/Windows/Profile/Masteries.xaml new file mode 100644 index 00000000..05e7dfd7 --- /dev/null +++ b/Sightstone/Windows/Profile/Masteries.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + Page: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Settings: +