Пример #1
0
        private void AddAction(object sender, RoutedEventArgs e)
        {
            int                      actionType = ((KeyValuePair <string, int>)ActionsListBox.SelectedItem).Value;
            WalkerStatement          action     = null;
            Dictionary <string, int> type       = StatementType.getType;

            try
            {
                if (actionType == type["Waypoint"] || actionType == type["Stand"])
                {
                    int[] position = Coordinates();
                    action = new Waypoint(position[0], position[1], position[2], actionType == type["Stand"]);
                }
                else if (actionType == type["Go To Label"])
                {
                    action = new Modules.WalkerModule.Action(actionType, ActionTextBox.Text);
                }
                else if (actionType == type["Mouse Click"])
                {
                    int[] pos = Coordinates();
                    action = new Modules.WalkerModule.Action(actionType, pos[0], pos[1], pos[2], RightClickCheckBox.IsChecked);
                }
                else if (actionType == type["Say"] || actionType == type["Hotkey"] || actionType == type["Hotkey"])
                {
                    action = new Modules.WalkerModule.Action(actionType, ActionTextBox.Text);
                }
                else if (actionType == type["Use On Field"])
                {
                    int[] pos = Coordinates();
                    action = new Modules.WalkerModule.Action(actionType, ActionTextBox.Text, pos[0], pos[1], pos[2]);
                }
                else if (actionType == type["Wait"])
                {
                    action = new Modules.WalkerModule.Action(actionType, int.Parse(ActionTextBox.Text));
                }
                else if (actionType == type["Condition"])
                {
                    if (_conditionsList.Count > 0)
                    {
                        if (_condition.connector == StatementType.conditionElement["Not set"])
                        {
                            if (ConditionFulfilledTextBox.Text != "")
                            {
                                action = new Modules.WalkerModule.Action(actionType, ConditionFulfilledTextBox.Text, _conditionsList);
                            }
                            else
                            {
                                showPopUpWindow("Condition must has specified label name to go to when condition is fulfilled");
                                return;
                            }
                        }
                        else
                        {
                            showPopUpWindow("Condition not completed. Every particular condition contains first value comparator and second value.");
                            return;
                        }
                    }
                    else
                    {
                        showPopUpWindow("You can not add empty condition");
                        return;
                    }
                }
                else if (actionType == type["Trade"])
                {
                    if (_tradeList.Count > 0)
                    {
                        action             = new Modules.WalkerModule.Action(actionType, _tradeList);
                        _tradeList         = new List <TradeItem>();
                        AmountTextBox.Text = "";
                        refreshTradeList();
                        TradeGrid.Visibility       = Visibility.Hidden;
                        ItemAndHintGrid.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        showPopUpWindow("Can not add empty action. Add an action first.");
                    }
                }
                else if (actionType == type["Deposit"])
                {
                    if (_putIntoList.Count > 0 || _takeFromList.Count > 0)
                    {
                        action              = new Modules.WalkerModule.Action(actionType, DepositOrMailBoxComboBox.SelectedItem.ToString() == "Deposit", _putIntoList, _takeFromList);
                        _putIntoList        = new List <DepositItem>();
                        _takeFromList       = new List <DepositItem>();
                        _takenItemContainer = ItemList.Items[0];

                        RefreshPutIntoList();
                        RefreshTakeFromList();

                        DepositGrid.Visibility     = Visibility.Hidden;
                        ItemAndHintGrid.Visibility = Visibility.Hidden;
                    }
                    else
                    {
                        showPopUpWindow("Can not add empty action. Add items first.");
                    }
                }
                else
                {
                    return;  //protect from adding null to the list
                }
                if (action != null)
                {
                    insertToList(action);
                }
                ConditionGrid.Visibility = Visibility.Hidden;
            }
            catch (Exception)
            {
                showPopUpWindow();
            }

            //    Modules.WalkerModule.Action action = new Modules.WalkerModule.Action(actionType,;
        }
Пример #2
0
        private void Edit(object sender, RoutedEventArgs e)
        {
            WalkerStatement selected     = listBox.SelectedItem as WalkerStatement;
            string          action       = "";
            int             selectedType = selected.type;

            if (selected != null)
            {
                hideActionFields();
                ActionsListBox.SelectedIndex = -1;

                if (selected.type == StatementType.getType["Action"])
                {
                    Modules.WalkerModule.Action act = selected as Modules.WalkerModule.Action;
                    selectedType = act.defaultAction;
                }
                foreach (var type in StatementType.getType)
                {
                    if (type.Value == selectedType)
                    {
                        ActionsListBox.SelectedItem = type;
                        action = StatementType.getTypeName(selectedType);
                        break;
                    }
                }


                if (action == "Hotkey")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    ActionTextBox.Text = statement.args[0].ToString();
                }
                else if (action == "Stand")
                {
                    Waypoint statement = selected as Waypoint;
                    setPositionTextBoxes(statement);
                }
                else if (action == "Use On Field")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    ActionTextBox.Text = statement.args[0].ToString();

                    XPositionTextBox.Text = statement.args[1].ToString();
                    YPositionTextBox.Text = statement.args[2].ToString();
                    FloorTextBox.Text     = statement.args[3].ToString();
                }
                else if (action == "Say")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    ActionTextBox.Text = statement.args[0].ToString();
                }
                else if (action == "Go To Label")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    ActionTextBox.Text = statement.args[0].ToString();
                }
                else if (action == "Mouse Click")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    XPositionTextBox.Text        = statement.args[0].ToString();
                    YPositionTextBox.Text        = statement.args[1].ToString();
                    FloorTextBox.Text            = statement.args[2].ToString();
                    RightClickCheckBox.IsChecked = statement.args[3] as bool?;
                }
                else if (action == "Waypoint")
                {
                    Waypoint statement = selected as Waypoint;
                    setPositionTextBoxes(statement);
                }
                else if (action == "Condition")
                {
                    CreateCondition(null, null);
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    ConditionFulfilledTextBox.Text = statement.args[0].ToString();
                    _conditionsList = statement.args[1] as List <Modules.WalkerModule.Condition>;
                    refreshCondition();
                }
                else if (action == "Trade")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    _tradeList = (List <TradeItem>)statement.args[0];
                    ShowTradeGrid(new object(), new RoutedEventArgs());
                    refreshTradeList();
                }
                else if (action == "Deposit")
                {
                    Modules.WalkerModule.Action statement = selected as Modules.WalkerModule.Action;
                    _putIntoList  = (List <DepositItem>)statement.args[1];
                    _takeFromList = (List <DepositItem>)statement.args[2];
                    DepositOrMailBoxComboBox.SelectedItem = ((bool)statement.args[0]) ? "Deposit" : "Mail box";

                    ShowDepositButton(new object(), new RoutedEventArgs());
                    RefreshPutIntoList();
                    RefreshTakeFromList();
                }
            }
        }