Пример #1
0
 public MainWindow()
 {
     OverlaySettings = new OverlaySettings();
     InitializeComponent();
     Router.StartGame = false;
     Overlay.Init(OverlaySettings);
 }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="frame">The frame that will show the pages</param>
 public RoutingHelper(Frame frame, OverlaySettings overlaySettings)
 {
     container            = frame;
     container.Navigated += OnFrameNavigation;
     StartGame            = false;
     OverlaySettings      = overlaySettings;
 }
Пример #3
0
        protected void LoadSettings()
        {
            StreamReader s = null;

            try
            {
                s = new StreamReader(ConfigFileName);
                var x = new XmlSerializer(typeof(GameSettings));
                Settings = (GameSettings)x.Deserialize(s);
                s.Close();

                s = new StreamReader(OverlayConfigFileName);
                x = new XmlSerializer(typeof(OverlaySettings));
                OverlaySettings = (OverlaySettings)x.Deserialize(s);
            }
            catch
            {
                Settings        = new GameSettings();
                OverlaySettings = new OverlaySettings();
                SaveSettings();
            }
            finally
            {
                if (s != null)
                {
                    s.Close();
                }
            }
        }
Пример #4
0
 /// <summary>
 ///     Open the OverLaySettings form
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void settingsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var ols = new OverlaySettings())
     {
         ols.ShowDialog(this);
     }
     SettingsManager(false);
 }
Пример #5
0
 /// <summary>
 /// Navigates to the given page
 /// </summary>
 /// <param name="page">The page that we want to navigate to</param>
 public void ChangeCurrentPage(PageBase page)
 {
     OverlaySettings.Reset();
     page.Router          = this;
     page.OverlaySettings = OverlaySettings;
     CurrentPage          = page;
     container.Content    = page;
     page.OnAttachedToFrame();
     CurrentPageChanged?.Invoke();
 }
Пример #6
0
    public void ShowGameAlert(OverlaySettings settings, UnityAction OnCloseCallback)
    {
        GameObject panel = (GameObject)GameObject.Instantiate(Resources.Load("InGameAlertPanel"));

        _onCloseCallback = OnCloseCallback;

        InGameAlert                       = panel.GetComponent <InGameAlertOverlay>();
        InGameAlert.BodyText              = settings.body;
        InGameAlert.OnScreenOverlayClose += OnInGameAlertClose;
        InGameAlert.transform.SetParent(ui.transform, false);
        InGameAlert.Initialize();
    }
Пример #7
0
        private void ControlService_DisplayOSSelection(List <AvailableOverlaySetting> remoteSettings, SettingSelectedHandler handler)
        {
            // Must be called via dispatcher, this event is called from a network thread
            Dispatcher.Invoke(new Action(delegate()
            {
                SelectOverlaySettings sosWindow = new SelectOverlaySettings()
                {
                    AvailableSettings = remoteSettings, Owner = this
                };

                if (handler != null)
                {
                    sosWindow.SettingSelected += handler;
                }

                sosWindow.AvailableSettings.AddRange(OverlaySettings.GetValidOverlaySettings());
                sosWindow.ShowDialog();
            }
                                         ));
        }
Пример #8
0
    // force stop will stop the vehicle and show wrong answer feedback
    // on alert close, we remove all elements running
    // game manager, race and game screen are all removed
    private void ForceStop()
    {
        PersistentModel.Instance.ClockIsStopped = true;
        UIManager.Instance.soundManager.PlaySound("PlayTooSlow", 0.2f);

        race.ForceCompleted();
        race.StopVehicle();

        string feedback = PersistentModel.Instance.TireOptionSelectedData.feedback;

        // Show Popup
        OverlaySettings settings = new OverlaySettings
        {
            body = feedback
        };

        UIManager.Instance.Overlay.ShowGameAlert(settings, OnInGameAlertClose);

        CurrentState = State.IDLE;
    }
Пример #9
0
 private void menuOpen_Click(object sender, RoutedEventArgs e)
 {
     if (ControlClientService.Instance.ConnectedStatus != ConnectionStatus.NotConnected)
     {
         ControlClientService.Instance.DisplayOpenMenuWithRemoteSettings();
     }
     else
     {
         if (ControlServerService.Instance.ConnectedStatus != ConnectionStatus.NotConnected)
         {
             ControlServerService.Instance.DisplayOpenMenuWithRemoteSettings();
         }
         else
         {
             SelectOverlaySettings sos = new SelectOverlaySettings()
             {
                 Owner = this, AvailableSettings = OverlaySettings.GetValidOverlaySettings(), LocalOnly = true
             };
             sos.SettingSelected += new SettingSelectedHandler(SelectOverlaySettings_OverlaySettingSelected);
             sos.ShowDialog();
         }
     }
 }
    // force stop will stop the vehicle and show wrong answer feedback
    // on alert close, we remove all elements running
    // game manager, race and game screen are all removed
    private void ForceStop()
    {
        DebugLog.Trace("ForceStop.Instance.ChallengeTime: " + PersistentModel.Instance.ChallengeTime);
        DebugLog.Trace("race.Time: " + race.Time);

        PersistentModel.Instance.ClockIsStopped = true;

        //UIManager.Instance.soundManager.PlayTooSlow(0.065f);
        race.ForceCompleted();
        race.StopVehicle();

        string feedback = PersistentModel.Instance.TireOptionSelectedData.feedback;

        // Show Popup
        OverlaySettings settings = new OverlaySettings
        {
            body = feedback
        };

        UIManager.Instance.Overlay.ShowGameAlert(settings, OnInGameAlertClose);

        CurrentState = State.IDLE;
    }
Пример #11
0
        // Returns true if processing was successful
        protected virtual bool ProcessSinglePacket(ControlCommand.Command?requiredCommand = null)
        {
            // Alias EncryptedStream as ns for cleaner code
            Stream ns = EncryptedStream;

            byte[] commandBuffer    = new byte[1];
            int    commandBytesRead = 0;

            // Try reading the command byte
            try
            {
                commandBytesRead = ns.Read(commandBuffer, 0, 1);
            } catch (Exception) {
                return(false);
            }

            // If we read a command byte
            if (commandBytesRead == 1)
            {
                ControlCommand.Command packetCommand = (ControlCommand.Command)commandBuffer[0];
                CommandResult          cr            = null;

                // Handle incoming commands
                switch (packetCommand)
                {
                case ControlCommand.Command.AvailableSettingsRequest:
                    cr = AvailableSettingsRequestCommand.Instance.HandleCommand(ns);

                    Dictionary <string, object> availableResponseParameters = new Dictionary <string, object>();
                    availableResponseParameters["availableSettings"] = OverlaySettings.GetValidOverlaySettings();
                    bool responseSent = AvailableSettingsResponseCommand.Instance.SendCommand(ns, availableResponseParameters);

                    break;

                case ControlCommand.Command.AvailableSettingsResponse:
                    cr = AvailableSettingsResponseCommand.Instance.HandleCommand(ns);

                    if (cr.Success)
                    {
                        AvailableRemoteSettings = (List <AvailableOverlaySetting>)cr.Data["remoteSettings"];
                    }

                    break;

                case ControlCommand.Command.DownloadSettingRequest:
                    cr = DownloadSettingRequestCommand.Instance.HandleCommand(ns);

                    if (cr.Success)
                    {
                        string settingPath = (string)cr.Data["settingPath"];

                        FileInfo      overlaySettingFile   = new FileInfo(Path.Combine(OverlaySettings.OverlaysBasePath.FullName, settingPath));
                        DirectoryInfo overlaySettingFolder = overlaySettingFile.Directory;

                        Dictionary <string, object> downloadResponseParameters = new Dictionary <string, object>();
                        downloadResponseParameters["fromDirectory"] = overlaySettingFolder;

                        DownloadSettingResponseCommand.Instance.SendCommand(ns, downloadResponseParameters);
                    }

                    break;

                case ControlCommand.Command.DownloadSettingResponse:
                    cr = DownloadSettingResponseCommand.Instance.HandleCommand(ns);

                    if (cr.Success)
                    {
                        RaiseSettingsDownloaded((DirectoryInfo)cr.Data["savedDirectory"]);
                    }

                    break;


                case ControlCommand.Command.OverlaySettingSelect:
                    cr = OverlaySettingSelectCommand.Instance.HandleCommand(ns);

                    if (cr.Success)
                    {
                        if ((bool)cr.Data["remote"])
                        {
                            Dictionary <string, object> downloadParameters = new Dictionary <string, object>();
                            downloadParameters["settingPath"] = cr.Data["selectedPath"];

                            // Open when download completes
                            SettingsDownloaded     += new SettingsDownloadedHandler(SettingsDownloaded_OpenOnComplete);
                            remoteSettingToDownload = new AvailableOverlaySetting()
                            {
                                Path = (string)cr.Data["selectedPath"], Local = !((bool)cr.Data["remote"])
                            };
                            DownloadSettingRequestCommand.Instance.SendCommand(ns, downloadParameters);
                        }
                        else
                        {
                            try
                            {
                                OverlaySettings.Instance.Load(new FileInfo(Path.Combine(OverlaySettings.OverlaysBasePath.FullName, (string)cr.Data["selectedPath"])));
                            } catch (OverlayLoadingException ole) {
                                MessageBox.Show(ole.Message);
                                return(false);
                            }
                            OverlaySettingLoadedCommand.Instance.SendCommand(ns);
                        }
                    }

                    break;

                case ControlCommand.Command.OverlaySettingLoaded:
                    cr = OverlaySettingLoadedCommand.Instance.HandleCommand(ns);
                    break;

                case ControlCommand.Command.UpdateVariable:

                    cr = UpdateVariableCommand.Instance.HandleCommand(ns);
                    if (cr.Success)
                    {
                        string variableName  = (string)cr.Data["variableName"];
                        string variableValue = (string)cr.Data["variableValue"];

                        // Update our dictionary's value of variableName with variableValue
                        OverlaySettings.Instance.UpdateVariableFromNetwork(variableName, variableValue);
                    }

                    break;

                case ControlCommand.Command.Close:

                    cr = CloseCommand.Instance.HandleCommand(ns);
                    if (cr.Success)
                    {
                        return(false);
                    }

                    break;

                // Unknown command
                default:
                    return(false);
                }

                if (!cr.Success)
                {
                    return(false);
                }

                // Mark packet processed if mutex is valid
                if (ProcessedCommands.ContainsKey(packetCommand) && ProcessedCommands[packetCommand] != null)
                {
                    ProcessedCommands[packetCommand].Set();
                }

                // If we processed a command that wasn't required, fail
                if (requiredCommand.HasValue && ((ControlCommand.Command)commandBuffer[0]) != requiredCommand.Value)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #12
0
 public void InjectOverlaySettings(OverlaySettings overlaySettings)
 {
     OverlaySettings = overlaySettings;
 }
Пример #13
0
 public override void Init(RendererBase <ToyWorld> renderer, ToyWorld world, OverlaySettings settings)
 {
     base.Init(renderer, world, settings);
 }
Пример #14
0
        private void OnDrawing(Device device)
        {
            try
            {
                OverlaySettings settings = OverlaySettings.Instance;

                if (settings.OnlyDrawInForeground &&
                    Imports.GetForegroundWindow() != StyxWoW.Memory.Process.MainWindowHandle)
                {
                    return;
                }

                if (!StyxWoW.IsInGame)
                {
                    DrawHelper.DrawShadowedText("Not in game!",
                                                settings.GameStatsPositionX,
                                                settings.GameStatsPositionY,
                                                settings.GameStatsForegroundColor,
                                                settings.GameStatsShadowColor,
                                                settings.GameStatsFontSize
                                                );
                    return;
                }

                if (!TreeRoot.IsRunning)
                {
                    ObjectManager.Update();
                }

                WoWPoint mypos    = StyxWoW.Me.Location;
                Vector3  vecStart = new Vector3(mypos.X, mypos.Y, mypos.Z);
                int      myLevel  = StyxWoW.Me.Level;

                if (settings.DrawGameStats)
                {
                    StringBuilder sb = new StringBuilder();

                    WoWUnit currentTarget = StyxWoW.Me.CurrentTarget;

                    if (currentTarget != null)
                    {
                        sb.AppendLine("Current Target: " + currentTarget.Name + ", Distance: " + Math.Round(currentTarget.Distance, 3));

                        WoWPoint end    = currentTarget.Location;
                        Vector3  vecEnd = new Vector3(end.X, end.Y, end.Z);

                        DrawHelper.DrawLine(vecStart, vecEnd, 2f, Color.FromArgb(150, Color.Black));
                    }

                    sb.AppendLine("My Position: " + StyxWoW.Me.Location);
                    sb.AppendLine("");
                    sb.AppendLine(string.Format(Globalization.XP_HR___0_, GameStats.XPPerHour.ToString("F0")));
                    sb.AppendLine(string.Format(Globalization.Kills___0____1__hr_, GameStats.MobsKilled, GameStats.MobsPerHour.ToString("F0")));
                    sb.AppendLine(string.Format(Globalization.Deaths___0____1__hr_, GameStats.Deaths, GameStats.DeathsPerHour.ToString("F0")));
                    sb.AppendLine(string.Format(Globalization.Loots___0____1__hr_, GameStats.Loots, GameStats.LootsPerHour.ToString("F0")));

                    if (BotManager.Current is BGBuddy)
                    {
                        sb.AppendLine(string.Format("Honor Gained: {0} ({1}/hr)", GameStats.HonorGained, GameStats.HonorPerHour.ToString("F0")));
                        sb.AppendLine(string.Format("BGs Won: {0} Lost: {1} Total: {2} ({3}/hr)", GameStats.BGsWon, GameStats.BGsLost, GameStats.BGsCompleted, GameStats.BGsPerHour.ToString("F0")));
                    }

                    if (myLevel < 90)
                    {
                        sb.AppendLine(string.Format("Time to Level: {0}", GameStats.TimeToLevel));
                    }

                    sb.AppendLine(string.Format("TPS: {0}", GameStats.TicksPerSecond.ToString("F2")));

                    sb.AppendLine();
                    if (!string.IsNullOrEmpty(TreeRoot.GoalText))
                    {
                        sb.AppendLine(string.Format(Globalization.Goal___0_, TreeRoot.GoalText));
                    }

                    if (settings.UseShadowedText)
                    {
                        DrawHelper.DrawShadowedText(sb.ToString(),
                                                    settings.GameStatsPositionX,
                                                    settings.GameStatsPositionY,
                                                    settings.GameStatsForegroundColor,
                                                    settings.GameStatsShadowColor,
                                                    settings.GameStatsFontSize
                                                    );
                    }
                    else
                    {
                        DrawHelper.DrawText(sb.ToString(),
                                            settings.GameStatsPositionX,
                                            settings.GameStatsPositionY,
                                            settings.GameStatsForegroundColor,
                                            settings.GameStatsFontSize
                                            );
                    }
                }

                if (settings.DrawHostilityBoxes || settings.DrawUnitLines || settings.DrawGameObjectBoxes || settings.DrawGameObjectLines)
                {
                    foreach (WoWObject obj in ObjectManager.GetObjectsOfType <WoWObject>(true))
                    {
                        string   name      = obj.Name;
                        WoWPoint objLoc    = obj.Location;
                        Vector3  vecCenter = new Vector3(objLoc.X, objLoc.Y, objLoc.Z);

                        WoWGameObject gobject = obj as WoWGameObject;
                        if (gobject != null)
                        {
                            Color color = Color.FromArgb(150, Color.Blue);

                            if (gobject.IsMineral)
                            {
                                color = Color.FromArgb(150, Color.DarkGray);
                            }
                            if (gobject.IsHerb)
                            {
                                color = Color.FromArgb(150, Color.Fuchsia);
                            }

                            if (settings.DrawGameObjectNames)
                            {
                                DrawHelper.Draw3DText(name, vecCenter);
                            }

                            if (settings.DrawGameObjectBoxes)
                            {
                                DrawHelper.DrawOutlinedBox(vecCenter,
                                                           2.0f,
                                                           2.0f,
                                                           2.0f,
                                                           Color.FromArgb(150, color)
                                                           );
                            }
                            if (settings.DrawGameObjectLines)
                            {
                                bool inLos = gobject.InLineOfSight;

                                if (settings.DrawGameObjectLinesLos && inLos)
                                {
                                    DrawHelper.DrawLine(vecStart, vecCenter, 2f, Color.FromArgb(150, color));
                                }
                                else
                                {
                                    if (!settings.DrawGameObjectLinesLos)
                                    {
                                        DrawHelper.DrawLine(vecStart, vecCenter, 2f, Color.FromArgb(150, color));
                                    }
                                }
                            }
                        }

                        WoWPlayer player = obj as WoWPlayer;
                        if (player != null)
                        {
                            if (OverlaySettings.Instance.DrawPlayerNames)
                            {
                                DrawHelper.Draw3DText(name, vecCenter);
                            }
                        }

                        WoWUnit u = obj as WoWUnit;
                        if (u != null)
                        {
                            Color hostilityColor = Color.FromArgb(150, Color.Green);

                            if (u.IsHostile)
                            {
                                hostilityColor = Color.FromArgb(150, Color.Red);

                                if (settings.DrawAggroRangeCircles)
                                {
                                    DrawHelper.DrawCircle(vecCenter, u.MyAggroRange, 16, Color.FromArgb(75, Color.DeepSkyBlue));
                                }
                            }

                            if (u.IsNeutral)
                            {
                                hostilityColor = Color.FromArgb(150, Color.Yellow);
                            }

                            if (u.IsFriendly)
                            {
                                hostilityColor = Color.FromArgb(150, Color.Green);
                            }

                            if (settings.DrawHostilityBoxes)
                            {
                                float boundingHeight = u.BoundingHeight;
                                float boundingRadius = u.BoundingRadius;

                                DrawHelper.DrawOutlinedBox(vecCenter,
                                                           boundingRadius,
                                                           boundingRadius,
                                                           boundingHeight,
                                                           hostilityColor
                                                           );

                                //DrawHelper.DrawSphere(vecCenter, 1f, 5, 5, hostilityColor);
                            }

                            if (OverlaySettings.Instance.DrawUnitNames)
                            {
                                DrawHelper.Draw3DText(name, vecCenter);
                            }

                            if (settings.DrawUnitLines)
                            {
                                vecCenter.Z += u.BoundingHeight / 2;
                                bool inLos = u.InLineOfSight;

                                if (settings.DrawUnitLinesLos && inLos)
                                {
                                    DrawHelper.DrawLine(vecStart, vecCenter, 2f, hostilityColor);
                                }
                                else
                                {
                                    if (!settings.DrawUnitLinesLos)
                                    {
                                        DrawHelper.DrawLine(vecStart, vecCenter, 2f, hostilityColor);
                                    }
                                }
                            }
                        }
                    }
                }

                if (settings.DrawCurrentPath)
                {
                    MeshNavigator navigator = Navigator.NavigationProvider as MeshNavigator;
                    if (navigator != null && navigator.CurrentMovePath != null)
                    {
                        Tripper.Tools.Math.Vector3[] points = navigator.CurrentMovePath.Path.Points;
                        for (int i = 0; i < points.Length; i++)
                        {
                            Vector3 vecEnd = new Vector3(points[i].X, points[i].Y, points[i].Z);

                            if (i - 1 >= 0)
                            {
                                Tripper.Tools.Math.Vector3 prevPoint = points[i - 1];
                                Vector3 vecPreviousPoint             = new Vector3(prevPoint.X, prevPoint.Y, prevPoint.Z);
                                DrawHelper.DrawLine(vecPreviousPoint, vecEnd, 2f, Color.FromArgb(150, Color.Black));
                            }

                            DrawHelper.DrawBox(vecEnd, 1.0f, 1.0f, 1.0f, Color.FromArgb(150, Color.BlueViolet));
                        }
                    }
                }

                if (settings.DrawBgMapboxes && BGBuddy.Instance != null)
                {
                    Battleground curBg = BGBuddy.Instance.Battlegrounds.FirstOrDefault(bg => bg.MapId == StyxWoW.Me.MapId);
                    if (curBg != null)
                    {
                        BgBotProfile curBgProfile = curBg.Profile;
                        if (curBgProfile != null)
                        {
                            foreach (var box in curBgProfile.Boxes[curBg.Side])
                            {
                                float width  = box.BottomRight.X - box.TopLeft.X;
                                float height = box.BottomRight.Z - box.TopLeft.Z;
                                var   c      = box.Center;

                                Vector3 vecCenter = new Vector3(c.X, c.Y, c.Z);
                                DrawHelper.DrawOutlinedBox(vecCenter, width, width, height, Color.FromArgb(150, Color.Gold));
                            }

                            foreach (Blackspot bs in curBgProfile.Blackspots)
                            {
                                var     p   = bs.Location;
                                Vector3 vec = new Vector3(p.X, p.Y, p.X);
                                DrawHelper.DrawCircle(vec, bs.Radius, 32, Color.FromArgb(200, Color.Black));

                                if (!string.IsNullOrWhiteSpace(bs.Name))
                                {
                                    DrawHelper.Draw3DText("Blackspot: " + bs.Name, vec);
                                }
                                else
                                {
                                    DrawHelper.Draw3DText("Blackspot", vec);
                                }
                            }
                        }
                    }
                }

                Profile curProfile = ProfileManager.CurrentProfile;
                if (curProfile != null)
                {
                    if (settings.DrawHotspots)
                    {
                        GrindArea ga = QuestState.Instance.CurrentGrindArea;
                        if (ga != null)
                        {
                            if (ga.Hotspots != null)
                            {
                                foreach (Hotspot hs in ga.Hotspots)
                                {
                                    var     p   = hs.Position;
                                    Vector3 vec = new Vector3(p.X, p.Y, p.Z);
                                    DrawHelper.DrawCircle(vec, 10.0f, 32, Color.FromArgb(200, Color.Red));

                                    if (!string.IsNullOrWhiteSpace(hs.Name))
                                    {
                                        DrawHelper.Draw3DText("Hotspot: " + hs.Name, vec);
                                    }
                                    else
                                    {
                                        DrawHelper.Draw3DText("Hotspot", vec);
                                    }
                                }
                            }
                        }

                        // This is only used by grind profiles.
                        if (curProfile.HotspotManager != null)
                        {
                            foreach (WoWPoint p in curProfile.HotspotManager.Hotspots)
                            {
                                Vector3 vec = new Vector3(p.X, p.Y, p.Z);
                                DrawHelper.DrawCircle(vec, 10.0f, 32, Color.FromArgb(200, Color.Red));
                                DrawHelper.Draw3DText("Hotspot", vec);
                            }
                        }
                    }

                    if (settings.DrawBlackspots)
                    {
                        if (curProfile.Blackspots != null)
                        {
                            foreach (Blackspot bs in curProfile.Blackspots)
                            {
                                var     p   = bs.Location;
                                Vector3 vec = new Vector3(p.X, p.Y, p.Z);
                                DrawHelper.DrawCircle(vec, bs.Radius, 32, Color.FromArgb(200, Color.Black));

                                if (!string.IsNullOrWhiteSpace(bs.Name))
                                {
                                    DrawHelper.Draw3DText("Blackspot: " + bs.Name, vec);
                                }
                                else
                                {
                                    DrawHelper.Draw3DText("Blackspot: " + vec, vec);
                                }
                            }
                        }
                    }
                }

                if (settings.DrawDbAvoidObjects)
                {
                    foreach (var avoid in AvoidanceManager.Avoids)
                    {
                        var c      = avoid.Location;
                        var center = new Vector3(c.X, c.Y, c.Z);

                        DrawHelper.DrawCircle(center, avoid.Radius, 32, Color.FromArgb(200, Color.LightBlue));

                        center.Z += 1.0f;
                        DrawHelper.Draw3DText("Db Avoid Object", center);
                    }
                }
            }
            catch (Exception)
            {
            }
        }