/// <summary>
        /// Simulates text as if it were sent by the game.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuItemSimulateIncomingTextAsync_Click(object sender, RoutedEventArgs e)
        {
            // Set the initial text for the editor.
            var win = new StringEditor();

            // Startup position of the dialog should be in the center of the parent window.  The
            // owner has to be set for this to work.
            win.Owner = App.MainWindow;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.Title            = "Simulate Incoming Text";
            win.ActionButtonText = "Simulate";
            win.StatusText       = "Although a simulation of incoming text, triggers and aliases will actually fire.";

            // Show the Lua dialog.
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                var lines = win.Text.Split(Environment.NewLine);

                foreach (string line in lines)
                {
                    // Like it really came in, send it to the places it should go to display
                    // it and then process it.
                    HandleDataReceived(sender, $"{line}\r\n");
                    HandleLineReceived(sender, line.Trim());
                    await Task.Delay(50);
                }
            }
        }
        /// <summary>
        /// Sends text to the game with a specified delay between each line.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuItemSendTextToGameAsync_Click(object sender, RoutedEventArgs e)
        {
            // Set the initial text for the editor.
            var win = new StringEditor();

            // Startup position of the dialog should be in the center of the parent window.  The
            // owner has to be set for this to work.
            win.Owner = App.MainWindow;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.ActionButtonText      = "Send";

            // Show the Lua dialog.
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                var lines = win.Text.Split(Environment.NewLine);

                foreach (string line in lines)
                {
                    await this.Interp.Send(line, false, false);

                    await Task.Delay(500);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Simulates text as if it were sent by the game.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuItemSimulateIncomingTextAsync_Click(object sender, RoutedEventArgs e)
        {
            var win = new StringEditor
            {
                Owner = App.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                Title            = "Simulate Incoming Text",
                ActionButtonText = "Simulate",
                StatusText       = "Although a simulation of incoming text, triggers and aliases will actually fire."
            };

            // Show the Lua dialog.
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                foreach (string line in win.Text.Split(Environment.NewLine))
                {
                    // Like it really came in, send it to the places it should go to display
                    // it and then process it.
                    HandleDataReceived(sender, $"{line}\r\n");
                    HandleLineReceived(sender, line.Trim());
                    await Task.Delay(50);
                }
            }
        }
        /// <summary>
        /// Edits the global Lua file that is loaded into all Lua scripts to allow for shared
        /// Lua logic between all Lua instances.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MenuItemEditGlobalLuaFile_Click(object sender, RoutedEventArgs e)
        {
            // Set the initial text for the editor.
            var win = new StringEditor();

            // Startup position of the dialog should be in the center of the parent window.  The
            // owner has to be set for this to work.
            win.Owner = App.MainWindow;
            win.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            win.ActionButtonText      = "Save";
            win.EditorMode            = StringEditor.EditorType.Lua;
            win.StatusText            = "Global Lua File";
            win.Text = App.Settings?.ProfileSettings?.LuaGlobalScript ?? "";

            // Show the Lua dialog.
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                App.Settings.ProfileSettings.LuaGlobalScript = win.Text;
            }
        }
Пример #5
0
        /// <summary>
        /// Sends text to the game with a specified delay between each line.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuItemSendTextToGameAsync_Click(object sender, RoutedEventArgs e)
        {
            var win = new StringEditor
            {
                Owner = App.MainWindow,
                WindowStartupLocation = WindowStartupLocation.CenterOwner,
                ActionButtonText      = "Send"
            };

            // Show the Lua dialog.
            var result = win.ShowDialog();

            // If the result
            if (result != null && result.Value)
            {
                foreach (string line in win.Text.Split(Environment.NewLine))
                {
                    await this.Interp.Send(line, false, false);

                    await Task.Delay(500);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Attempts to open the editor last edited alias or trigger.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void MenuItemOpenLastEditedAliasOrTrigger_Click(object sender, RoutedEventArgs e)
        {
            if (App.InstanceGlobals.LastEdited == InstanceGlobals.EditItem.None)
            {
                await WindowManager.MsgBox("No triggers or aliases have been edited this session.", "Edit Last Alias or Trigger");

                return;
            }

            if (App.InstanceGlobals.LastEdited == InstanceGlobals.EditItem.Alias)
            {
                // Get the alias from the current line.
                var alias = App.Settings.ProfileSettings.AliasList.FirstOrDefault(x => x.AliasExpression.Equals(App.InstanceGlobals.LastEditedId, StringComparison.OrdinalIgnoreCase));

                // Hmm, no alias.. gracefully exit.
                if (alias == null)
                {
                    await WindowManager.MsgBox("No alias you wish to edit could not be found or no longer exists.", "Edit Last Alias or Trigger");

                    return;
                }

                // Set the initial text for the editor.
                var win = new StringEditor
                {
                    Text = alias.Command
                };

                // Set the initial type for highlighting.
                if (alias.ExecuteAs == ExecuteType.LuaMoonsharp)
                {
                    win.EditorMode = StringEditor.EditorType.Lua;
                }

                // Show what alias is being edited in the status bar of the string editor window.
                win.StatusText = $"Alias: {alias.AliasExpression}";

                // Startup position of the dialog should be in the center of the parent window.  The
                // owner has to be set for this to work.
                win.Owner = App.MainWindow;
                win.WindowStartupLocation = WindowStartupLocation.CenterOwner;

                // Show the Lua dialog.
                var result = win.ShowDialog();

                // If the result
                if (result != null && result.Value)
                {
                    alias.Command = win.Text;
                }
            }
            else if (App.InstanceGlobals.LastEdited == InstanceGlobals.EditItem.Trigger)
            {
                // Get the Trigger from the current line.
                var trigger = App.Settings.ProfileSettings.TriggerList.FirstOrDefault(x => x.Identifier.Equals(App.InstanceGlobals.LastEditedId, StringComparison.OrdinalIgnoreCase));

                // Hmm, no Trigger.. gracefully exit.
                if (trigger == null)
                {
                    await WindowManager.MsgBox("No trigger you wish to edit could not be found or no longer exists.", "Edit Last Alias or Trigger");

                    return;
                }

                var win = new TriggerEditorWindow(trigger)
                {
                    StatusText = $"This trigger has fired {trigger.Count.ToString().FormatIfNumber(0)} times."
                };

                // Save the last item and type so the Control+Alt+L alias can re-open it.
                App.InstanceGlobals.LastEditedId = trigger.Identifier;
                App.InstanceGlobals.LastEdited   = InstanceGlobals.EditItem.Trigger;

                // Startup position of the dialog should be in the center of the parent window.  The
                // owner has to be set for this to work.
                win.WindowStartupLocation = WindowStartupLocation.CenterScreen;

                // Show the Trigger editor window.
                win.Show();
            }
        }