Skip to content

Commit

Permalink
Allow command line flag to launch LoR instead
Browse files Browse the repository at this point in the history
  • Loading branch information
molenzwiebel committed Feb 6, 2020
1 parent 0e73c81 commit ab34445
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
12 changes: 6 additions & 6 deletions Deceive/Deceive.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" />
<Import Project="..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -45,8 +45,8 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="Costura, Version=4.1.0.0, Culture=neutral, PublicKeyToken=9919ef960d84173d">
<HintPath>..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll</HintPath>
<Reference Include="Costura, Version=3.3.3.0, Culture=neutral, PublicKeyToken=9919ef960d84173d">
<HintPath>..\packages\Costura.Fody.3.3.3\lib\net40\Costura.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EmbedIO, Version=3.3.3.0, Culture=neutral, PublicKeyToken=5e5f048b6e04267e">
Expand Down Expand Up @@ -116,12 +116,12 @@
<EmbeddedResource Include="Resources\deceive.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Fody.4.0.2\build\Fody.targets" Condition="Exists('..\packages\Fody.4.0.2\build\Fody.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105.The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.4.1.0\build\Costura.Fody.props'))" />
<Error Condition="!Exists('..\packages\Fody.6.1.0\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.6.1.0\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.4.0.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.4.0.2\build\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props'))" />
</Target>
<Import Project="..\packages\Fody.6.1.0\build\Fody.targets" Condition="Exists('..\packages\Fody.6.1.0\build\Fody.targets')" />
</Project>
22 changes: 12 additions & 10 deletions Deceive/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ internal class MainController : ApplicationContext
private string _status;
private readonly string _statusFile = Path.Combine(Utils.DataDir, "status");

private LCUOverlay _overlay;
private WindowFollower _follower;
private LCUOverlay _overlay = null;
private WindowFollower _follower = null;

private SslStream _incoming;
private SslStream _outgoing;
private string _lastPresence; // we resend this if the state changes

internal MainController()
internal MainController(bool isLeague)
{
_trayIcon = new NotifyIcon
{
Expand All @@ -37,12 +37,15 @@ internal MainController()
_trayIcon.ShowBalloonTip(5000);

// Create overlay and start following the LCU with it.
var lcu = Process.GetProcessesByName("LeagueClientUx").FirstOrDefault();
if (isLeague)
{
var process = Process.GetProcessesByName("LeagueClientUx").First();

_overlay = new LCUOverlay();
_overlay.Show();
_follower = new WindowFollower(_overlay, lcu);
_follower.StartFollowing();
_overlay = new LCUOverlay();
_overlay.Show();
_follower = new WindowFollower(_overlay, process);
_follower.StartFollowing();
}

LoadStatus();
UpdateUI();
Expand Down Expand Up @@ -105,8 +108,7 @@ private void UpdateUI()
});

_trayIcon.ContextMenu = new ContextMenu(new[] {aboutMenuItem, enabledMenuItem, typeMenuItem, quitMenuItem});

_overlay.UpdateStatus(_status, _enabled);
_overlay?.UpdateStatus(_status, _enabled);
}

public void StartThreads(SslStream incoming, SslStream outgoing)
Expand Down
13 changes: 8 additions & 5 deletions Deceive/StartupHandler.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
Expand All @@ -15,11 +16,11 @@ internal static class StartupHandler
internal static string DeceiveTitle => "Deceive " + Resources.DeceiveVersion;

[STAThread]
private static void Main()
private static void Main(string[] args)
{
try
{
StartDeceive();
StartDeceive(args);
}
catch (Exception ex)
{
Expand All @@ -37,7 +38,7 @@ private static void Main()
/**
* Actual main function. Wrapped into a separate function so we can catch exceptions.
*/
private static void StartDeceive()
private static void StartDeceive(string[] cmdArgs)
{
// We are supposed to launch league, so if it's already running something is going wrong.
if (Utils.IsClientRunning())
Expand Down Expand Up @@ -84,10 +85,12 @@ private static void StartDeceive()
var proxyServer = new ConfigProxy("https://clientconfig.rpg.riotgames.com", port);

// Step 4: Start the Riot Client and wait for a connect.
var isLor = cmdArgs.Any(x => x.ToLower() == "lor");
var game = isLor ? "bacon" : "league_of_legends";
var startArgs = new ProcessStartInfo
{
FileName = riotClientPath,
Arguments = "--client-config-url=\"http://localhost:" + proxyServer.ConfigPort + "\" --launch-product=league_of_legends --launch-patchline=live"
Arguments = "--client-config-url=\"http://localhost:" + proxyServer.ConfigPort + "\" --launch-product=" + game + " --launch-patchline=live"
};
Process.Start(startArgs);

Expand Down Expand Up @@ -125,7 +128,7 @@ private static void StartDeceive()
sslOutgoing.AuthenticateAsClient(chatHost);

// Step 7: All sockets are now connected, start tray icon.
var mainController = new MainController();
var mainController = new MainController(!isLor);
mainController.StartThreads(sslIncoming, sslOutgoing);
Application.EnableVisualStyles();
Application.Run(mainController);
Expand Down
4 changes: 2 additions & 2 deletions Deceive/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Costura.Fody" version="4.1.0" targetFramework="net48" />
<package id="Costura.Fody" version="3.3.3" targetFramework="net48" />
<package id="EmbedIO" version="3.3.3" targetFramework="net48" />
<package id="Fody" version="6.1.0" targetFramework="net48" developmentDependency="true" />
<package id="Fody" version="4.0.2" targetFramework="net48" developmentDependency="true" />
<package id="SimpleJson" version="0.38.0" targetFramework="net461" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="Unosquare.Swan.Lite" version="2.6.1" targetFramework="net48" />
Expand Down

0 comments on commit ab34445

Please sign in to comment.