Exemplo n.º 1
0
        public static void ResendGump(bool force = false)
        {
            try
            {
                MacroManager _macroManager = MacroManager.GetInstance();

                IEnumerable <MacroEntry> macros = _macroManager.Items.Where(e => e.IsRunning)
                                                  .OrderByDescending(e => e.StartedOn).ToArray();

                if (_lastMacros != null && macros.SequenceEqual(_lastMacros) && !force)
                {
                    return;
                }

                if (Engine.Gumps.GetGumps(out Gump[] gumps))
                {
                    foreach (Gump macrosGump in gumps.Where(g => g is MacrosGump))
                    {
                        Commands.CloseClientGump(macrosGump.ID);
                    }
                }

                MacrosGump gump = new MacrosGump(macros);
                gump.SendGump();

                _lastMacros = macros.ToArray();
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 2
0
        public static bool Playing(string macroName)
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry macro = manager.Items.FirstOrDefault(m => m.Name.Equals(macroName));

            return(macro != null && macro.IsRunning);
        }
Exemplo n.º 3
0
        public void WillExecute()
        {
            MacroEntry me = new MacroEntry();

            MacroManager mi = MacroManager.GetInstance();

            mi.Execute(me);
        }
Exemplo n.º 4
0
        public static void Replay()
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry current = manager.GetCurrentMacro();

            Task.Run(() => current.Action(current));
        }
Exemplo n.º 5
0
        public MacrosTabViewModel() : base(Strings.Macros)
        {
            Engine.DisconnectedEvent += OnDisconnectedEvent;

            _manager = MacroManager.GetInstance();

            _manager.IsRecording    = () => _isRecording;
            _manager.InsertDocument = str => { _dispatcher.Invoke(() => { SelectedItem.Macro += str; }); };
            _manager.Items          = Items;
        }
Exemplo n.º 6
0
        public static void PlayMacro(string name)
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry macro = manager.Items.FirstOrDefault(m => m.Name == name);

            if (macro == null)
            {
                UOC.SystemMessage(Strings.Unknown_macro___);
                return;
            }

            Task.Run(() => macro.Action(macro));
        }
Exemplo n.º 7
0
        public static bool IsRunning(string name)
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry macro = manager.Items.FirstOrDefault(m => m.Name == name);

            if (macro != null)
            {
                return(macro.IsRunning);
            }

            UOC.SystemMessage(Strings.Unknown_macro___, (int)UOC.SystemMessageHues.Normal, true);
            return(false);
        }
Exemplo n.º 8
0
        public static void Replay()
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry current = manager?.GetCurrentMacro();

            if (current?.Action == null)
            {
                return;
            }

            manager.Replay = true;

            Task.Run(() => current.Action(current));
        }
Exemplo n.º 9
0
        public static void UnsetAlias(string aliasName)
        {
            MacroEntry macro = MacroManager.GetInstance().GetCurrentMacro();

            if (macro != null)
            {
                if (macro.Aliases.ContainsKey(aliasName))
                {
                    macro.Aliases.Remove(aliasName);
                }
            }

            if (_aliases.ContainsKey(aliasName))
            {
                _aliases.Remove(aliasName);
            }
        }
Exemplo n.º 10
0
        public static void ResendGump(bool force = false)
        {
            try
            {
                MacroManager _macroManager = MacroManager.GetInstance();

                IEnumerable <MacroEntry> macro = _macroManager.Items.Where(e => e.IsRunning);

                string html = string.Empty;

                foreach (MacroEntry entry in macro)
                {
                    if (entry.IsBackground)
                    {
                        html += $"<BASEFONT COLOR=#000000><I>{entry.Name}</I></BASEFONT>\n";
                    }
                    else
                    {
                        html += $"<BASEFONT COLOR=#000000>{entry.Name}</BASEFONT>\n";
                    }
                }

                if (html.Equals(_lastList) && !force)
                {
                    return;
                }

                if (Engine.Gumps.GetGumps(out Gump[] gumps))
                {
                    foreach (Gump macrosGump in gumps.Where(g => g is MacrosGump))
                    {
                        Commands.CloseClientGump(macrosGump.ID);
                    }
                }

                MacrosGump gump = new MacrosGump(html);
                gump.SendGump();

                _lastList = html;
            }
            catch (InvalidOperationException e)
            {
                Console.WriteLine(e.ToString());
            }
        }
Exemplo n.º 11
0
        public static int GetAlias(string aliasName)
        {
            MacroEntry macro = MacroManager.GetInstance().GetCurrentMacro();

            if (macro != null)
            {
                if (macro.Aliases.ContainsKey(aliasName.ToLower()))
                {
                    return(macro.Aliases[aliasName.ToLower()]);
                }
            }

            if (_aliases.ContainsKey(aliasName.ToLower()))
            {
                return(_aliases[aliasName.ToLower()]);
            }

            return(-1);
        }
Exemplo n.º 12
0
        public MacrosTabViewModel() : base(Strings.Macros)
        {
            Engine.DisconnectedEvent += OnDisconnectedEvent;

            _manager = MacroManager.GetInstance();

            _manager.IsRecording    = () => _isRecording;
            _manager.InsertDocument = str =>
            {
                _dispatcher.Invoke(() =>
                {
                    if (SelectedItem != null)
                    {
                        SelectedItem.Macro += str ?? string.Empty;
                    }
                });
            };
            _manager.NewMacro        = NewMacro;
            _manager.Items           = Items;
            Items.CollectionChanged += UpdateDraggables;
        }
Exemplo n.º 13
0
        public static void SetMacroAlias(string aliasName, object obj)
        {
            int value = ResolveSerial(obj);

            MacroEntry macro = MacroManager.GetInstance().GetCurrentMacro();

            if (macro == null)
            {
                SetAlias(aliasName, obj);
                return;
            }

            if (macro.Aliases.ContainsKey(aliasName.ToLower()))
            {
                macro.Aliases[aliasName.ToLower()] = value;
            }
            else
            {
                macro.Aliases.Add(aliasName.ToLower(), value);
            }
        }
Exemplo n.º 14
0
        public static bool CheckCommand(byte[] data, int length)
        {
            string text = null;

            if (data[0] == 0xAD)
            {
                text = ParseUnicodeSpeech(data, data.Length);
            }
            else if (data[0] == 0x03)
            {
                text = ParseAsciiSpeech(data, data.Length);
            }

            if (text != null && text.Length >= 7 && text.Substring(0, 7).Equals(">macro "))
            {
                string macroName = text.Substring(7, text.Length - 7);

                MacroEntry macro = MacroManager.GetInstance().Items.FirstOrDefault(m => m.Name == macroName);

                if (macro == null)
                {
                    UOC.SystemMessage(Strings.Macro_not_found___, 35);
                }
                else
                {
                    macro.Execute();
                }

                return(true);
            }

            if (string.IsNullOrEmpty(text) || text[0] != Options.CurrentOptions.CommandPrefix)
            {
                return(false);
            }

            string[] args = text.Remove(0, 1).Split(' ');

            return(_commands.ContainsKey(args[0]) && _commands[args[0]].Invoke(args.Skip(1).ToArray()));
        }
Exemplo n.º 15
0
        public static void PlayMacro(string name)
        {
            MacroManager manager = MacroManager.GetInstance();

            MacroEntry current = manager.GetCurrentMacro();

            if (current != null && current.IsBackground)
            {
                UOC.SystemMessage(Strings.Cannot_PlayMacro_from_background_macro___);
                return;
            }

            MacroEntry macro = manager.Items.FirstOrDefault(m => m.Name == name);

            if (macro == null)
            {
                UOC.SystemMessage(Strings.Unknown_macro___);
                return;
            }

            Task.Run(() => macro.Action(macro));
        }
Exemplo n.º 16
0
 public static void StopAll()
 {
     MacroManager.GetInstance().StopAll();
 }
Exemplo n.º 17
0
        public static void SetPlayer(PlayerMobile mobile)
        {
            Player = mobile;

            PlayerInitializedEvent?.Invoke(mobile);

            mobile.MobileStatusUpdated += (status, newStatus) =>
            {
                if (!Options.CurrentOptions.UseDeathScreenWhilstHidden)
                {
                    return;
                }

                if (newStatus.HasFlag(MobileStatus.Hidden))
                {
                    SendPacketToClient(new MobileUpdate(mobile.Serial, mobile.ID == 0x191 ? 0x193 : 0x192, mobile.Hue,
                                                        newStatus, mobile.X,
                                                        mobile.Y, mobile.Z, mobile.Direction));
                }
            };

            Task.Run(async() =>
            {
                try
                {
                    GitHubClient client = new GitHubClient(new ProductHeaderValue("ClassicAssist"));

                    IReadOnlyList <Release> releases =
                        await client.Repository.Release.GetAll("Reetus",
                                                               "ClassicAssist");

                    Release latestRelease = releases.FirstOrDefault();

                    if (latestRelease == null)
                    {
                        return;
                    }

                    Version latestVersion = Version.Parse(latestRelease.TagName);

                    if (!Version.TryParse(
                            FileVersionInfo.GetVersionInfo(Path.Combine(StartupPath, "ClassicAssist.dll"))
                            .ProductVersion,
                            out Version localVersion))
                    {
                        return;
                    }

                    if (latestVersion > localVersion && AssistantOptions.UpdateGumpVersion < latestVersion)
                    {
                        IReadOnlyList <GitHubCommit> commits =
                            await client.Repository.Commit.GetAll("Reetus", "ClassicAssist");

                        IEnumerable <GitHubCommit> latestCommits =
                            commits.OrderByDescending(c => c.Commit.Author.Date).Take(7);

                        StringBuilder commitMessage = new StringBuilder();

                        foreach (GitHubCommit gitHubCommit in latestCommits)
                        {
                            commitMessage.AppendLine($"{gitHubCommit.Commit.Author.Date.Date.ToShortDateString()}:");
                            commitMessage.AppendLine();
                            commitMessage.AppendLine(gitHubCommit.Commit.Message);
                            commitMessage.AppendLine();
                        }

                        StringBuilder message = new StringBuilder();
                        message.AppendLine(Strings.ProductName);
                        message.AppendLine($"{Strings.New_version_available_} {latestVersion}");
                        message.AppendLine();
                        message.AppendLine(commitMessage.ToString());

                        UpdateMessageGump gump = new UpdateMessageGump(message.ToString(), latestVersion);
                        gump.SendGump();
                    }
                }
                catch (Exception)
                {
                    // Squash all
                }
            });

            AbilitiesManager.GetInstance().Enabled = AbilityType.None;
            AbilitiesManager.GetInstance().ResendGump(AbilityType.None);

            Task.Run(async() =>
            {
                await Task.Delay(3000);
                MacroManager.GetInstance().Autostart();
            });
        }
Exemplo n.º 18
0
        public override void Execute()
        {
            MacroManager manager = MacroManager.GetInstance();

            manager.StopAll();
        }
Exemplo n.º 19
0
 public static void Stop(string name = null)
 {
     MacroManager.GetInstance().Stop(name);
 }
Exemplo n.º 20
0
        public static bool Playing()
        {
            MacroManager manager = MacroManager.GetInstance();

            return(manager.CurrentMacro != null && manager.CurrentMacro.IsRunning);
        }