Ejemplo n.º 1
0
        public static void UpdateInGameInfo()
        {
            for (int slot = 0; slot < 5; slot++)
            {
                try
                {
                    if (DS3Interop.GetPlayerBase(slot) == 0)
                    {
                        continue;
                    }

                    CSteamID id = DS3Interop.GetPlayerSteamId(slot);
                    if (!activePlayers.ContainsKey(id))
                    {
                        continue;
                    }

                    activePlayers[id].CharSlot = slot.ToString();
                    activePlayers[id].CharName = DS3Interop.GetPlayerName(slot);
                    activePlayers[id].TeamId   = DS3Interop.GetPlayerTeam(slot);
                }
                catch (Exception)
                {
                }
            }
        }
Ejemplo n.º 2
0
 private void swBorderless_Toggled(object sender, RoutedEventArgs e)
 {
     if (DS3Interop.WinThread != 0 && swBorderless.IsOn ^ DS3Interop.Borderless)
     {
         DS3Interop.MakeBorderless(swBorderless.IsOn);
     }
 }
        public void UpdateVisibility()
        {
            bool shouldShow = DS3Interop.IsGameFocused() || IsActive;

            if (!IsVisible && Settings.Default.DisplayOverlay && shouldShow)
            {
                Show();
                UpdatePosition();
            }
            if (IsVisible && !(Settings.Default.DisplayOverlay && shouldShow))
            {
                Hide();
            }
        }
Ejemplo n.º 4
0
        private void GameStartTimer_Tick(object sender, EventArgs e)
        {   // Wait for both process attach & main window existing
            if (DS3Interop.TryAttach() && DS3Interop.FindWindow())
            {
                DS3Interop.Process.EnableRaisingEvents = true;
                DS3Interop.Process.Exited += DarkSouls_HasExited;
                labelGameState.Content     = "DS3: RUNNING";
                labelGameState.Foreground  = Brushes.LawnGreen;

                File.WriteAllText("steam_appid.txt", "374320");
                if (!SteamAPI.Init())
                {
                    MessageBox.Show("Could not initialize Steam API", "Steam API Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Close();
                }

                if (!HotkeyManager.Enable())
                {
                    MessageBox.Show("Could not initialize keyboard hook for hotkeys", "WINAPI Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                if (!overlay.InstallMsgHook())
                {
                    MessageBox.Show("Could not overlay message hook", "WINAPI Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }

                overlay.UpdateVisibility();
                if (swBorderless.IsOn ^ DS3Interop.Borderless)
                {
                    DS3Interop.MakeBorderless(swBorderless.IsOn);
                }

                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.BorderlessHotkey, () => swBorderless.IsOn ^= true);
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.OverlayHotkey, () => swOverlay.IsOn       ^= true);
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.PingFilterHotkey, () => Settings.Default.UsePingFilter ^= true);
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.REOHotkey, () => OnlineHotkey(11));
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.RSDHotkey, () => OnlineHotkey(10));
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.WSDHotkey, () => OnlineHotkey(4));
                HotkeyManager.AddHotkey(DS3Interop.WinHandle, () => Settings.Default.LeaveSessionHotkey, () => DS3Interop.LeaveSession());

                ETWPingMonitor.Start();
                updateTimer.Start();
                gameStartTimer.Stop();
            }
        }
Ejemplo n.º 5
0
        private void PingFilterTimer_Tick(object sender, EventArgs e)
        {
            double sumPing = 0;  int n = 0;
            bool   absPingRespected = true;

            foreach (Player p in Player.ActivePlayers())
            {
                if (p.Ping != -1)
                {
                    absPingRespected &= p.Ping < Settings.Default.MaxAbsPing;
                    sumPing          += p.Ping;
                    n++;
                }
            }
            if (n == 0)
            {   // Wait until at least one player has a ping
                pingFilterTimer.Interval = TimeSpan.FromSeconds(0.5);
                return;
            }
            if ((!absPingRespected || sumPing / n > Settings.Default.MaxAvgPing) && !DS3Interop.InLoadingScreen())
            {
                var joinMethod = DS3Interop.GetJoinMethod();
                DS3Interop.LeaveSession();
                if (joinMethod == DS3Interop.JoinMethod.RedEyeOrb)
                {
                    hadInvaded = true;
                }
                else if (joinMethod == DS3Interop.JoinMethod.RedSign)
                {
                    DS3Interop.ApplyEffect(10);
                }
                else if (joinMethod == DS3Interop.JoinMethod.WhiteSign)
                {
                    DS3Interop.ApplyEffect(4);
                }
            }
            else
            {
                reoSpamming = false;
            }
            pingFilterTimer.Stop();
        }
Ejemplo n.º 6
0
 private void OnlineHotkey(int effect)
 {
     if (DS3Interop.InLoadingScreen())
     {
         return;
     }
     if (effect == 11 && Settings.Default.SpamRedEyeOrb)
     {
         reoSpamming ^= true;
         reoSpamCnt   = 0;
         if (!reoSpamming && DS3Interop.IsSearchingInvasion())
         {
             DS3Interop.ApplyEffect(11);
         }
     }
     else
     {
         DS3Interop.ApplyEffect(effect);
     }
 }
Ejemplo n.º 7
0
        private void UpdateTimer_Tick(object sender, EventArgs e)
        {
            Player.UpdatePlayerList();
            Player.UpdateInGameInfo();
            playerData.Clear();

            foreach (Player p in Player.ActivePlayers())
            {
                playerData.Add(p);
            }

            // Update session info column sizes
            foreach (var col in dataGridSession.Columns)
            {
                col.Width = new DataGridLength(1, DataGridLengthUnitType.Pixel);
                col.Width = new DataGridLength(1, DataGridLengthUnitType.Auto);
            }
            dataGridSession.UpdateLayout();

            // Update overlay column sizes
            foreach (var col in overlay.dataGrid.Columns)
            {
                col.Width = new DataGridLength(1, DataGridLengthUnitType.Pixel);
                col.Width = new DataGridLength(1, DataGridLengthUnitType.SizeToCells);
            }
            overlay.dataGrid.UpdateLayout();

            // Queue position update after the overlay has re-rendered
            Dispatcher.BeginInvoke(DispatcherPriority.ContextIdle, new Action(overlay.UpdatePosition));

            DS3Interop.NetStatus status = DS3Interop.GetNetworkState();
            if (reoSpamming && !Settings.Default.SpamRedEyeOrb)
            {
                reoSpamming = false;
                reoSpamCnt  = 0;
            }
            if (status == DS3Interop.NetStatus.None)
            {
                if (hadInvaded && !reoSpamming)
                {
                    DS3Interop.ApplyEffect(11);
                }
                if (reoSpamming)
                {
                    reoSpamCnt = (reoSpamCnt + 1) % 5;
                    if (DS3Interop.IsSearchingInvasion() ^ (reoSpamCnt != 0))
                    {
                        DS3Interop.ApplyEffect(11);
                    }
                }
                hadInvaded = false;
                pingCheked = false;
            }
            if (Settings.Default.UsePingFilter)
            {
                if (status == DS3Interop.NetStatus.Host || status == DS3Interop.NetStatus.TryCreateSession || DS3Interop.InLoadingScreen())
                {   // Someone invaded, or the local player summoned a phantom, or ping filter was too late
                    pingFilterTimer.Stop();
                    reoSpamming = false;
                    reoSpamCnt  = 0;
                    pingCheked  = false;
                }
                if (status == DS3Interop.NetStatus.Client && !pingFilterTimer.IsEnabled && !pingCheked)
                {   // Connection has been established
                    pingCheked = true;
                    pingFilterTimer.Interval = TimeSpan.FromSeconds(Settings.Default.SamplingDelay);
                    pingFilterTimer.Start();
                }
            }
            else
            {
                pingFilterTimer.Stop();
            }
        }