示例#1
0
        public void EditSelection(DbAttribute attribute)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetTable <int>(_configuration.ServerDb);

            try {
                btable.Commands.Begin();

                var            selectedItem = (ReadableTuple <int>)_lv.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.Key.ToString(CultureInfo.InvariantCulture), selectedItem.GetValue <int>(attribute).ToString(CultureInfo.InvariantCulture), _configuration.SubTableServerDbSearch, _tab.ProjectDatabase)
                {
                    Element2 = attribute.DisplayName
                };
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);
                    Int32.TryParse(svalue, out value);

                    if (id <= 0)
                    {
                        return;
                    }

                    var dico = _getSelectedGroups();

                    if (selectedItem.Key != id && dico.ContainsKey(id))
                    {
                        throw new Exception("The item ID " + id + " already exists.");
                    }

                    btable.Commands.SetDico((ReadableTuple <int>)_tab.List.SelectedItem, _configuration.AttributeTable, selectedItem, attribute, value);

                    if (selectedItem.Key != id)
                    {
                        btable.Commands.ChangeKeyDico((ReadableTuple <int>)_tab.List.SelectedItem, _configuration.AttributeTable, selectedItem.Key, id, null);
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
            finally {
                btable.Commands.End();
                ((RangeObservableCollection <ReadableTuple <int> >)_lv.ItemsSource).Update();
            }
        }
示例#2
0
        private void _miEditDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                var            selectedItem = (MobDropView)_lv.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex, id);
                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex + 1, value);
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    selectedItem.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
示例#3
0
        public void AddItem(string itemId, string itemProperty, bool selectId, DbAttribute attribute)
        {
            Table <int, ReadableTuple <int> > btable = _table;

            try {
                DropEditDialog dialog = new DropEditDialog(itemId, itemProperty, _configuration.SubTableServerDbSearch, _tab.ProjectDatabase, selectId)
                {
                    Element2 = attribute.DisplayName
                };
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);
                    Int32.TryParse(svalue, out value);

                    if (id <= 0)
                    {
                        return;
                    }

                    ReadableTuple <int> tuple = new ReadableTuple <int>(id, _configuration.SubTableAttributeList);
                    tuple.SetRawValue(attribute, value);
                    tuple.SetRawValue(_configuration.SubTableParentAttribute, ((ReadableTuple <int>)_tab.List.SelectedItem).Key);
                    tuple.Added = true;
                    btable.Commands.AddTupleDico((ReadableTuple <int>)_tab.List.SelectedItem, _configuration.AttributeTable, id, tuple, _addedItem);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
示例#4
0
        private void _miAddDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.Items.Count >= 3)
            {
                ErrorHandler.HandleException("You cannot add more than 3 MVP drops. Delete an item and then add a new one.");
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, false, (DbPathLocator.IsYamlMob() ? 2 : 0));
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid       = dialog.Id;
                    string svalue    = dialog.DropChance;
                    string randGroup = "";
                    int    value;
                    int    id;

                    if (DbPathLocator.IsYamlMob())
                    {
                        randGroup = dialog.RandGroup;
                    }

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    TValue item = (TValue)_tab.List.SelectedItem;

                    try {
                        btable.Commands.Begin();

                        int startIndex = ServerMobAttributes.Mvp1ID.Index;

                        for (int i = 0; i < 6; i += 2)
                        {
                            if (item.GetValue <int>(startIndex + i) == 0)
                            {
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);

                                if (DbPathLocator.IsYamlMob())
                                {
                                    btable.Commands.Set((ReadableTuple <int>)(object) item, ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2), randGroup);
                                }
                                break;
                            }
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _lv.ItemsSource = null;
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
示例#5
0
        private void _miAddDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.Items.Count >= 10)
            {
                ErrorHandler.HandleException("You cannot add more than 10 drops. Delete an item and then add a new one.");
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "", ServerDbs.Items, _tab.ProjectDatabase, true);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    TValue item = (TValue)_tab.List.SelectedItem;

                    try {
                        btable.Commands.Begin();

                        int startIndex = ServerMobAttributes.Drop1ID.Index;

                        for (int i = 0; i < 18; i += 2)
                        {
                            if (item.GetValue <int>(startIndex + i) == 0)
                            {
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i, id);
                                btable.Commands.Set((ReadableTuple <int>)(object) item, startIndex + i + 1, value);
                                break;
                            }
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    //_lv.Items.OfType<MobDropView>().ToList().ForEach(p => p.RemoveEvents());
                    _lv.ItemsSource = null;
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
示例#6
0
        private void _miEditDrop_Click(object sender, RoutedEventArgs e)
        {
            if (_lv.SelectedItems.Count <= 0)
            {
                return;
            }

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                var            selectedItem = (MobDropView)_lv.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.DropOriginal.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase, false, DbPathLocator.IsYamlMob() ? 3 : 0);

                if (DbPathLocator.IsYamlMob())
                {
                    dialog._tbRandGroup.Text           = selectedItem.RandomOptionGroup;
                    dialog._tbStealProtected.IsChecked = selectedItem.StealProtected;
                }

                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid            = dialog.Id;
                    string svalue         = dialog.DropChance;
                    string randGroup      = "";
                    bool   stealProtected = false;
                    int    value;
                    int    id;

                    if (DbPathLocator.IsYamlMob())
                    {
                        randGroup      = dialog.RandGroup;
                        stealProtected = dialog.StealProtected;
                    }

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex, id);
                        btable.Commands.Set(selectedItem.Tuple, selectedItem.AttributeIndex + 1, value);

                        if (DbPathLocator.IsYamlMob())
                        {
                            int b             = (selectedItem.AttributeIndex - ServerMobAttributes.Drop1ID.Index) / 2;
                            int distRandGroup = ServerMobAttributes.Drop1RandomOptionGroup.Index + b;
                            int distSteal     = ServerMobAttributes.Drop1Flags.Index + b;

                            btable.Commands.Set(selectedItem.Tuple, distRandGroup, randGroup);
                            btable.Commands.Set(selectedItem.Tuple, distSteal, stealProtected.ToString());
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    selectedItem.Update();
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
示例#7
0
        private void _miAddDrop_Click(bool mvp)
        {
            TValue item = (TValue)_tab.List.SelectedItem;

            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            try {
                DropEditDialog dialog = new DropEditDialog("", "10.0 %", ServerDbs.Mobs, _tab.ProjectDatabase, true);
                dialog.Owner = WpfUtilities.TopWindow;

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (id <= 0)
                    {
                        return;
                    }

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    var tuple = btable.TryGetTuple(id);

                    if (tuple == null)
                    {
                        ErrorHandler.HandleException("Mob id not found.");
                        return;
                    }

                    try {
                        btable.Commands.Begin();
                        bool added = false;

                        if (mvp)
                        {
                            int startIndex = ServerMobAttributes.Mvp1ID.Index;

                            for (int i = 0; i < 6; i += 2)
                            {
                                if (tuple.GetValue <int>(startIndex + i) == 0)
                                {
                                    btable.Commands.Set(tuple, startIndex + i, item.GetKey <int>());
                                    btable.Commands.Set(tuple, startIndex + i + 1, value);
                                    added = true;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            int startIndex = ServerMobAttributes.Drop1ID.Index;

                            for (int i = 0; i < 18; i += 2)
                            {
                                if (tuple.GetValue <int>(startIndex + i) == 0)
                                {
                                    btable.Commands.Set(tuple, startIndex + i, item.GetKey <int>());
                                    btable.Commands.Set(tuple, startIndex + i + 1, value);
                                    added = true;
                                    break;
                                }
                            }
                        }

                        if (!added)
                        {
                            ErrorHandler.HandleException("Couldn't add the item (no space left).");
                        }
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _lv.ItemsSource = null;
                    _update(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }
示例#8
0
        private void _miEditRequirement_Click(object sender, RoutedEventArgs e)
        {
            if (_lvRequirements.SelectedItems.Count <= 0 || _tab.List.SelectedItem == null)
            {
                return;
            }

            TValue item   = (TValue)_tab.List.SelectedItem;
            var    btable = _tab.Table;

            try {
                var            selectedItem = (PetEvolutionTargetView)_lvRequirements.SelectedItem;
                DropEditDialog dialog       = new DropEditDialog(selectedItem.ID.ToString(CultureInfo.InvariantCulture), selectedItem.Amount.ToString(CultureInfo.InvariantCulture), ServerDbs.Items, _tab.ProjectDatabase);
                dialog.Owner    = WpfUtilities.TopWindow;
                dialog.Element2 = "Amount";

                if (dialog.ShowDialog() == true)
                {
                    string sid    = dialog.Id;
                    string svalue = dialog.DropChance;
                    int    value;
                    int    id;

                    Int32.TryParse(sid, out id);

                    if (!Extensions.GetIntFromFloatValue(svalue, out value))
                    {
                        ErrorHandler.HandleException("Invalid format (integer or float value only)");
                        return;
                    }

                    if (id <= 0)
                    {
                        return;
                    }

                    try {
                        btable.Commands.Begin();

                        _evolution = new Evolution();

                        foreach (var targetEv in _lv.Items.OfType <PetEvolutionView>())
                        {
                            if (targetEv == _lv.SelectedItem)
                            {
                                List <Utilities.Extension.Tuple <object, int> > requirements = new List <Utilities.Extension.Tuple <object, int> >();

                                foreach (var requirement in _lvRequirements.Items.OfType <PetEvolutionTargetView>())
                                {
                                    if (requirement == _lvRequirements.SelectedItem)
                                    {
                                        requirements.Add(new Utilities.Extension.Tuple <object, int>(dialog.Id, value));
                                    }
                                    else
                                    {
                                        requirements.Add(requirement.Requirement);
                                    }
                                }

                                targetEv.EvolutionTarget.ItemRequirements = requirements;
                            }

                            _evolution.Targets.Add(targetEv.EvolutionTarget);
                        }

                        btable.Commands.Set(item, ServerPetAttributes.Evolution, _evolution.ToString());
                    }
                    finally {
                        btable.Commands.EndEdit();
                    }

                    _update(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            btable.Commands.EndEdit();
        }