Skip to content

Commit

Permalink
Rip out old overlay implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
molenzwiebel committed Aug 5, 2020
1 parent b791fa4 commit b190179
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 450 deletions.
215 changes: 0 additions & 215 deletions Deceive/LCUOverlay.cs

This file was deleted.

51 changes: 3 additions & 48 deletions Deceive/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@ internal class MainController : ApplicationContext
private bool _createdFakePlayer = false;
private bool _sentIntroductionText = false;

private LCUOverlay _overlay;
private WindowFollower _follower;

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

internal event EventHandler ConnectionErrored;

internal MainController(bool createOverlay)
internal MainController()
{
_trayIcon = new NotifyIcon
{
Expand All @@ -44,32 +41,10 @@ internal MainController(bool createOverlay)
};
_trayIcon.ShowBalloonTip(5000);

// Create overlay and start following the LCU with it.
if (createOverlay) CreateOverlay();

LoadStatus();
UpdateTray();
}

private async void CreateOverlay()
{
while (true)
{
var process = Process.GetProcessesByName("LeagueClientUx").FirstOrDefault();
if (process == null)
{
await Task.Delay(5000);
continue;
}

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

private void UpdateTray()
{
var aboutMenuItem = new MenuItem(StartupHandler.DeceiveTitle)
Expand All @@ -87,25 +62,6 @@ private void UpdateTray()
Checked = _enabled
};

var overlayMenuItem = new MenuItem("Show status overlay", (a, e) =>
{
if (_overlay == null)
{
CreateOverlay();
}
else
{
_follower.Dispose();
_overlay.Close();
_overlay = null;
}

UpdateTray();
})
{
Checked = _overlay != null
};

var mucMenuItem = new MenuItem("Enable lobby chat", (a, e) =>
{
_connectToMuc = !_connectToMuc;
Expand Down Expand Up @@ -169,11 +125,10 @@ private void UpdateTray()
var closeOut = new MenuItem("Close outgoing", (a, e) => { _outgoing.Close(); });
var sendTestMsg = new MenuItem("Send message", (a, e) => { SendMessageFromFakePlayer("Test"); });

_trayIcon.ContextMenu = new ContextMenu(new[] {aboutMenuItem, enabledMenuItem, typeMenuItem, overlayMenuItem, mucMenuItem, closeIn, closeOut, sendTestMsg, quitMenuItem});
_trayIcon.ContextMenu = new ContextMenu(new[] {aboutMenuItem, enabledMenuItem, typeMenuItem, mucMenuItem, closeIn, closeOut, sendTestMsg, quitMenuItem});
#else
_trayIcon.ContextMenu = new ContextMenu(new[] {aboutMenuItem, enabledMenuItem, typeMenuItem, overlayMenuItem, mucMenuItem, quitMenuItem});
_trayIcon.ContextMenu = new ContextMenu(new[] {aboutMenuItem, enabledMenuItem, typeMenuItem, mucMenuItem, quitMenuItem});
#endif
_overlay?.UpdateStatus(_status, _enabled);
}

public void StartThreads(SslStream incoming, SslStream outgoing)
Expand Down
5 changes: 1 addition & 4 deletions Deceive/StartupHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,14 @@ private static void StartDeceive(string[] cmdArgs)
var proxyServer = new ConfigProxy("https://clientconfig.rpg.riotgames.com", port);

// Step 4: Start the Riot Client and wait for a connect.
var overlayEnabled = cmdArgs.All(x => x.ToLower() != "--no-overlay");
var game = "league_of_legends";
if (cmdArgs.Any(x => x.ToLower() == "lor"))
{
overlayEnabled = false;
game = "bacon";
}

if (cmdArgs.Any(x => x.ToLower() == "valorant"))
{
overlayEnabled = false;
game = "valorant";
}

Expand Down Expand Up @@ -172,7 +169,7 @@ private static void StartDeceive(string[] cmdArgs)
sslOutgoing.AuthenticateAsClient(chatHost);

// Step 7: All sockets are now connected, start tray icon.
var mainController = new MainController(overlayEnabled);
var mainController = new MainController();
mainController.StartThreads(sslIncoming, sslOutgoing);
mainController.ConnectionErrored += (sender, args) =>
{
Expand Down
Loading

0 comments on commit b190179

Please sign in to comment.