Пример #1
0
        public virtual void Instantiate(SdeDatabase database)
        {
            Database = database;

            _dbs.Add(new DbClientResource());
            _dbs.Add(new DbItems());
            _dbs.Add(new DbItems2());
            _dbs.Add(new DbClientItems());
            _dbs.Add(new DbClientQuest());
            _dbs.Add(new DbClientCheevo());
            _dbs.Add(new DbItemCombos());
            _dbs.Add(new DbItemCombos2());
            //_dbs.Add(new DbItemGroups());
            _dbs.Add(new DbMobGroups());
            _dbs.Add(new DbSkills());
            _dbs.Add(new DbSkillRequirements());
            _dbs.Add(new DbMobs());
            _dbs.Add(new DbMobs2());
            _dbs.Add(new DbMobSkills());
            _dbs.Add(new DbMobSkills2());
            _dbs.Add(new DbQuest());
            _dbs.Add(new DbQuest2());
            _dbs.Add(new DbCheevo());
            _dbs.Add(new DbHomuns());
            _dbs.Add(new DbHomuns2());
            _dbs.Add(new DbPet());
            _dbs.Add(new DbPet2());
            _dbs.Add(new DbCastle());
            _dbs.Add(new DbCastle2());
            _dbs.Add(new DbConstants());

            _dbs.ForEach(p => p.Holder = this);
            _dbs.ForEach(p => p.Init(database));
        }
Пример #2
0
        public AccEditDialog(SdeDatabase gdb)
            : base("View IDs editor", "treeList.png", SizeToContent.WidthAndHeight, ResizeMode.NoResize)
        {
            _gdb      = gdb;
            _multiGrf = gdb.MetaGrf;

            InitializeComponent();
            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner  = WpfUtilities.TopWindow;
            _async = new AsyncOperation(_progressBar);

            _obItems = new ObservableCollection <AccessoryItemView>(new List <AccessoryItemView>());
            _dataGrid.ItemsSource           = _obItems;
            _dataGrid.CanUserAddRows        = true;
            _dataGrid.CanUserDeleteRows     = true;
            _dataGrid.IsReadOnly            = false;
            _dataGrid.CanUserReorderColumns = false;
            _dataGrid.CanUserResizeColumns  = false;
            _dataGrid.CanUserSortColumns    = true;
            _dataGrid.SelectionMode         = Microsoft.Windows.Controls.DataGridSelectionMode.Extended;
            _dataGrid.SelectionUnit         = Microsoft.Windows.Controls.DataGridSelectionUnit.CellOrRowHeader;
            _dataGrid.CanUserResizeRows     = false;

            _dataGrid.KeyDown += new KeyEventHandler(_dataGrid_KeyDown);

            _loadData();
        }
Пример #3
0
        public ValidationDialog(GDbTab tab) : base("Table validation", "validity.png", SizeToContent.Manual, ResizeMode.CanResize)
        {
            //_editor = editor;

            InitializeComponent();

            _asyncOperation = new AsyncOperation(_progressBar);

            WindowStartupLocation = WindowStartupLocation.CenterOwner;
            Owner = WpfUtilities.TopWindow;

            _loadSettingsUI();

            _sdb        = tab.ProjectDatabase;
            _validation = new DbValidationEngine(_sdb);

            _addSelectAll(_findErrors, _cbResSelectAll);
            _addSelectAll(_scanClientItems, _cbCiSelectAll);

            Binder.Bind(_cbResCollection, () => SdeAppConfiguration.VaResCollection);
            Binder.Bind(_cbResDrag, () => SdeAppConfiguration.VaResDrag);
            Binder.Bind(_cbResExistingOnly, () => SdeAppConfiguration.VaResExistingOnly);
            Binder.Bind(_cbResHeadger, () => SdeAppConfiguration.VaResHeadgear);
            Binder.Bind(_cbResIllust, () => SdeAppConfiguration.VaResIllustration);
            Binder.Bind(_cbResItem, () => SdeAppConfiguration.VaResInventory);
            Binder.Bind(_cbResMonster, () => SdeAppConfiguration.VaResMonster);
            Binder.Bind(_cbResNpc, () => SdeAppConfiguration.VaResNpc);
            Binder.Bind(_cbResShield, () => SdeAppConfiguration.VaResShield);
            Binder.Bind(_cbResWeapon, () => SdeAppConfiguration.VaResWeapon);
            Binder.Bind(_cbResGarment, () => SdeAppConfiguration.VaResGarment);
            Binder.Bind(_cbResInvalidFormat, () => SdeAppConfiguration.VaResInvalidFormat);
            Binder.Bind(_cbResEmpty, () => SdeAppConfiguration.VaResEmpty);
            Binder.Bind(_cbResInvalidCharacters, () => SdeAppConfiguration.VaResInvalidCharacters);
            Binder.Bind(_cbResClientMissing, () => SdeAppConfiguration.VaResClientItemMissing);

            Binder.Bind(_cbCiClassNumber, () => SdeAppConfiguration.VaCiViewId);
            Binder.Bind(_cbCiDescription, () => SdeAppConfiguration.VaCiDescription);
            Binder.Bind(_cbCiItemType, () => SdeAppConfiguration.VaCiItemRange);
            Binder.Bind(_cbCiClass, () => SdeAppConfiguration.VaCiClass);
            Binder.Bind(_cbCiAttack, () => SdeAppConfiguration.VaCiAttack);
            Binder.Bind(_cbCiDefense, () => SdeAppConfiguration.VaCiDefense);
            Binder.Bind(_cbCiProperty, () => SdeAppConfiguration.VaCiProperty);
            Binder.Bind(_cbCiRequiredLevel, () => SdeAppConfiguration.VaCiRequiredLevel);
            Binder.Bind(_cbCiWeaponLevel, () => SdeAppConfiguration.VaCiWeaponLevel);
            Binder.Bind(_cbCiWeight, () => SdeAppConfiguration.VaCiWeight);
            Binder.Bind(_cbCiLocation, () => SdeAppConfiguration.VaCiLocation);
            Binder.Bind(_cbCiCompoundOn, () => SdeAppConfiguration.VaCiCompoundOn);
            Binder.Bind(_cbCiNumberOfSlots, () => SdeAppConfiguration.VaCiNumberOfSlots);
            Binder.Bind(_cbCiIsCard, () => SdeAppConfiguration.VaCiIsCard);
            Binder.Bind(_cbCiName, () => SdeAppConfiguration.VaCiName);
            Binder.Bind(_cbCiJob, () => SdeAppConfiguration.VaCiJob);

            _listViewResults.MouseDoubleClick += (s, e) => _select();
            _listViewResults.KeyUp            += (s, e) => {
                if (e.Key == Key.Enter)
                {
                    _select();
                }
            };
        }
Пример #4
0
		public override sealed void Init(SdeDatabase database) {
			if (Table == null)
				Table = new Table<TKey, ReadableTuple<TKey>>(AttributeList, UnsafeContext);

			ProjectDatabase = database;
			database.AddDb(DbSource, this);
		}
Пример #5
0
        public void DummyInit(SdeDatabase database)
        {
            if (Table == null)
            {
                Table = new Table <TKey, ReadableTuple <TKey> >(AttributeList, UnsafeContext);
            }

            ProjectDatabase = database;
        }
Пример #6
0
        private static void _dbClientQuestWrite(SdeDatabase gdb, AbstractDb <int> db, string path)
        {
            if (path == null || gdb.MetaGrf.GetData(path) == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CQuests, "data\\questid2display.txt", null, "Table not saved."));
                return;
            }

            BackupEngine.Instance.BackupClient(path, gdb.MetaGrf);

            //string tmpFilename = Path.Combine(SdeAppConfiguration.TempPath, Path.GetFileName(path));
            Encoding encoder = EncodingService.DisplayEncoding;

            byte[] tmpBuffer;
            byte[] lineFeedByte       = encoder.GetBytes(SdeStrings.LineFeed);
            byte[] doubleLineFeedByte = encoder.GetBytes(SdeStrings.LineFeed + SdeStrings.LineFeed);

            using (MemoryStream memStream = new MemoryStream()) {
                IEnumerable <ReadableTuple <int> > items = gdb.GetDb <int>(ServerDbs.CQuests).Table.GetSortedItems();

                foreach (ReadableTuple <int> item in items)
                {
                    tmpBuffer = encoder.GetBytes(
                        item.GetValue <int>(ClientQuestsAttributes.Id) + "#" +
                        item.GetValue <string>(ClientQuestsAttributes.Name) + "#" +
                        item.GetValue <string>(ClientQuestsAttributes.SG) + "#" +
                        item.GetValue <string>(ClientQuestsAttributes.QUE) + "#" +
                        "\r\n" + item.GetValue <string>(ClientQuestsAttributes.FullDesc) + "#" +
                        "\r\n" + item.GetValue <string>(ClientQuestsAttributes.ShortDesc) + "#");

                    memStream.Write(tmpBuffer, 0, tmpBuffer.Length);
                    memStream.Write(doubleLineFeedByte, 0, doubleLineFeedByte.Length);
                }

                memStream.Write(lineFeedByte, 0, lineFeedByte.Length);

                tmpBuffer = new byte[memStream.Length];
                Buffer.BlockCopy(memStream.GetBuffer(), 0, tmpBuffer, 0, tmpBuffer.Length);

                //File.WriteAllBytes(tmpFilename, tmpBuffer);
            }

            string copyPath = path;

            try {
                gdb.MetaGrf.SetData(copyPath, tmpBuffer);
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }

            Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CQuests, db.ProjectDatabase.MetaGrf.FindTkPath(path), null, "Saving client table (questdb)."));
        }
Пример #7
0
 public static void SaveAsLua(SdeDatabase gdb, string path)
 {
     try {
         _saveFile(gdb, ProjectConfiguration.ClientCardIllustration, path, ClientItemAttributes.Illustration, item => item.GetValue <bool>(ClientItemAttributes.IsCard));
         _saveFile(gdb, ProjectConfiguration.ClientCardPrefixes, path, ClientItemAttributes.Affix, item => item.GetValue <bool>(ClientItemAttributes.IsCard));
         _saveFile(gdb, ProjectConfiguration.ClientCardPostfixes, path, null, item => item.GetValue <bool>(ClientItemAttributes.Postfix), false);
         _saveItemDataToLua(gdb, ProjectConfiguration.ClientItemInfo, path);
     }
     catch (Exception err) {
         ErrorHandler.HandleException(err);
     }
 }
Пример #8
0
        public DropEditDialog(string id, string dropChance, ServerDbs sdb, SdeDatabase gdb, bool selectId = false, int flag = 0) : base("Item edit", "cde.ico", SizeToContent.Height, ResizeMode.NoResize)
        {
            _id         = id;
            _dropChance = dropChance;
            _sdb        = sdb;
            _gdb        = gdb;

            InitializeComponent();

            _tbChance.Text = _dropChance;
            _tbId.Text     = _id;

            PreviewKeyDown += new KeyEventHandler(_dropEdit_PreviewKeyDown);

            Loaded += delegate {
                if (selectId)
                {
                    _tbId.SelectAll();
                    _tbId.Focus();
                }
                else
                {
                    _tbChance.SelectAll();
                    _tbChance.Focus();
                }

                if ((flag & 1) == 1)
                {
                    _tbDStealProtected.Visibility = Visibility.Visible;
                    _tbStealProtected.Visibility  = Visibility.Visible;
                }

                if ((flag & 2) == 2)
                {
                    _tbDRandGroup.Visibility = Visibility.Visible;
                    _tbRandGroup.Visibility  = Visibility.Visible;
                }
            };

            if (sdb != null)
            {
                _buttonQuery.Click += new RoutedEventHandler(_buttonQuery_Click);
            }
            else
            {
                _buttonQuery.Visibility = Visibility.Collapsed;
            }
        }
Пример #9
0
        private static void _saveItemDataToLua(SdeDatabase gdb, string filename, string output)
        {
            if (output == null && gdb.MetaGrf.GetData(filename) == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, filename, null, "ItemInfo table not saved."));
                return;
            }

            if (output == null)
            {
                BackupEngine.Instance.BackupClient(filename, gdb.MetaGrf);
            }

            StringBuilder builder = new StringBuilder();

            builder.AppendLine("tbl = {");

            List <ReadableTuple <int> > tuples = gdb.GetDb <int>(ServerDbs.CItems).Table.GetSortedItems().ToList();
            ReadableTuple <int>         tuple;

            for (int index = 0, count = tuples.Count; index < count; index++)
            {
                tuple = tuples[index];
                WriteEntry(builder, tuple, index == count - 1);
            }

            builder.AppendLine("}");
            builder.AppendLine();
            builder.AppendLine(ResourceString.Get("ItemInfoFunction"));

            if (output == null)
            {
                gdb.MetaGrf.SetData(filename, EncodingService.Ansi.GetBytes(builder.ToString()));
            }
            else
            {
                string copyPath = Path.Combine(output, Path.GetFileName(filename));

                try {
                    File.WriteAllText(copyPath, builder.ToString(), EncodingService.Ansi);
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            }

            Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, gdb.MetaGrf.FindTkPath(filename), null, "Saving ItemInfo table."));
        }
Пример #10
0
 public static void SaveAsTxt(SdeDatabase gdb, string path)
 {
     try {
         _saveFile(gdb, ProjectConfiguration.ClientCardIllustration, path, ClientItemAttributes.Illustration, item => item.GetValue <bool>(ClientItemAttributes.IsCard));
         _saveFile(gdb, ProjectConfiguration.ClientCardPrefixes, path, ClientItemAttributes.Affix, item => item.GetValue <bool>(ClientItemAttributes.IsCard));
         _saveFile(gdb, ProjectConfiguration.ClientCardPostfixes, path, null, item => item.GetValue <bool>(ClientItemAttributes.Postfix), false);
         _saveFile(gdb, ProjectConfiguration.ClientItemSlotCount, path, ClientItemAttributes.NumberOfSlots, item => (item.GetValue <string>(ClientItemAttributes.NumberOfSlots)).Length > 0, false);
         _saveFile(gdb, ProjectConfiguration.ClientItemIdentifiedResourceName, path, ClientItemAttributes.IdentifiedResourceName, item => (item.GetValue <string>(ClientItemAttributes.IdentifiedResourceName)).Length > 0, true);
         _saveFile(gdb, ProjectConfiguration.ClientItemUnidentifiedResourceName, path, ClientItemAttributes.UnidentifiedResourceName, item => (item.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName)).Length > 0, true);
         _saveFile(gdb, ProjectConfiguration.ClientItemIdentifiedDescription, path, ClientItemAttributes.IdentifiedDescription, item => (item.GetValue <string>(ClientItemAttributes.IdentifiedDescription)).Length > 0, false);
         _saveFile(gdb, ProjectConfiguration.ClientItemUnidentifiedDescription, path, ClientItemAttributes.UnidentifiedDescription, item => (item.GetValue <string>(ClientItemAttributes.UnidentifiedDescription)).Length > 0, false);
         _saveFile(gdb, ProjectConfiguration.ClientItemIdentifiedName, path, ClientItemAttributes.IdentifiedDisplayName, item => (item.GetValue <string>(ClientItemAttributes.IdentifiedDisplayName)).Length > 0, true);
         _saveFile(gdb, ProjectConfiguration.ClientItemUnidentifiedName, path, ClientItemAttributes.UnidentifiedDisplayName, item => (item.GetValue <string>(ClientItemAttributes.UnidentifiedDisplayName)).Length > 0, true);
     }
     catch (Exception err) {
         ErrorHandler.HandleException(err);
     }
 }
Пример #11
0
        public static void WeaponViewIdRepair(SdeDatabase sdb, BaseDb currentDb)
        {
            var itemDb  = sdb.GetMetaTable <int>(ServerDbs.Items);
            var itemDb1 = sdb.GetDb <int>(ServerDbs.Items);
            var itemDb2 = sdb.GetDb <int>(ServerDbs.Items2);

            string error;
            Dictionary <int, string> dico;

            if (LuaHelper.GetIdToSpriteTable(itemDb2, LuaHelper.ViewIdTypes.Weapon, out dico, out error))
            {
            }

            foreach (var tuple in itemDb1.Table.FastItems)
            {
                if (ItemParser.IsWeaponType(tuple))
                {
                    int viewId = tuple.GetIntNoThrow(ServerItemAttributes.ClassNumber);
                }
            }
        }
Пример #12
0
        public LuaTableDialog(SdeDatabase database)
            : base("Lua settings", "settings.png", SizeToContent.Height, ResizeMode.NoResize)
        {
            _multiGrf = database.MetaGrf;
            InitializeComponent();

            Binder.Bind(_cbMobTables, () => ProjectConfiguration.SyncMobTables, _updateMobTables, true);
            Binder.Bind(_cbAccTables, () => ProjectConfiguration.HandleViewIds, _updateccTables, true);

            WpfUtils.AddMouseInOutEffectsBox(_cbMobTables, _cbAccTables);
            _database = database;

            _oldPath1 = ProjectConfiguration.SyncMobId;
            _oldPath2 = ProjectConfiguration.SyncMobName;

            _spMob.Children.Add(new TextViewItem(null, new GetSetSetting(v => ProjectConfiguration.SyncMobId = v, () => ProjectConfiguration.SyncMobId), _multiGrf)
            {
                Description = "npcidentity.lub"
            });
            _spMob.Children.Add(new TextViewItem(null, new GetSetSetting(v => ProjectConfiguration.SyncMobName = v, () => ProjectConfiguration.SyncMobName), _multiGrf)
            {
                Description = "jobname.lub"
            });
            _spAcc.Children.Add(new TextViewItem(null, new GetSetSetting(v => ProjectConfiguration.SyncAccId = v, () => ProjectConfiguration.SyncAccId), _multiGrf)
            {
                Description = "accessoryid.lub"
            });
            _spAcc.Children.Add(new TextViewItem(null, new GetSetSetting(v => ProjectConfiguration.SyncAccName = v, () => ProjectConfiguration.SyncAccName), _multiGrf)
            {
                Description = "accname.lub"
            });

            _spMob.SizeChanged += _grid_SizeChanged;
            _spAcc.SizeChanged += _grid_SizeChanged;

            Extensions.SetMinimalSize(this);
            this.Owner = WpfUtilities.TopWindow;
        }
Пример #13
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas);
            }
            else if (debug.FileType == FileType.Conf)
            {
                DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["mob_db"])
                {
                    TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                    table.SetRaw(itemId, ServerMobAttributes.AegisName, parser["SpriteName"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.KRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Lv"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Exp, parser["Exp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JExp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Atk1, Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0));
                    table.SetRaw(itemId, ServerMobAttributes.Atk2, (Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0)) + Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 1))).ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Def, parser["Def"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["Mdef"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Str, parser["Stats.Str"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Stats.Agi"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Stats.Vit"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Int, parser["Stats.Int"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Stats.Dex"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Stats.Luk"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["ViewRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Size, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Size"] ?? "1").ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Race, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Race"] ?? "0").ToString(CultureInfo.InvariantCulture));

                    var element = parser["Element"];
                    int elLevel;
                    int elType;

                    if (element != null)
                    {
                        debug.AbsractDb.Attached["MobDb.UseConstants"] = true;
                        elLevel = Int32.Parse(((ParserList)element).Objects[1].ObjectValue);
                        elType  = SdeEditor.Instance.ProjectDatabase.ConstantToInt(((ParserList)element).Objects[0].ObjectValue);
                    }
                    else
                    {
                        elLevel = 0;
                        elType  = 0;
                    }

                    table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.Mode, (
                                     (!Boolean.Parse((parser["Mode.CanMove"] ?? "false")) ? 0 : (1 << 0)) |
                                     (!Boolean.Parse((parser["Mode.Looter"] ?? "false")) ? 0 : (1 << 1)) |
                                     (!Boolean.Parse((parser["Mode.Aggressive"] ?? "false")) ? 0 : (1 << 2)) |
                                     (!Boolean.Parse((parser["Mode.Assist"] ?? "false")) ? 0 : (1 << 3)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorIdle"] ?? "false")) ? 0 : (1 << 4)) |
                                     (!Boolean.Parse((parser["Mode.Boss"] ?? "false")) ? 0 : (1 << 5)) |
                                     (!Boolean.Parse((parser["Mode.Plant"] ?? "false")) ? 0 : (1 << 6)) |
                                     (!Boolean.Parse((parser["Mode.CanAttack"] ?? "false")) ? 0 : (1 << 7)) |
                                     (!Boolean.Parse((parser["Mode.Detector"] ?? "false")) ? 0 : (1 << 8)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorChase"] ?? "false")) ? 0 : (1 << 9)) |
                                     (!Boolean.Parse((parser["Mode.ChangeChase"] ?? "false")) ? 0 : (1 << 10)) |
                                     (!Boolean.Parse((parser["Mode.Angry"] ?? "false")) ? 0 : (1 << 11)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetMelee"] ?? "false")) ? 0 : (1 << 12)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetChase"] ?? "false")) ? 0 : (1 << 13)) |
                                     (!Boolean.Parse((parser["Mode.TargetWeak"] ?? "false")) ? 0 : (1 << 14))
                                     ).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["MoveSpeed"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "4000");
                    table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "2000");
                    table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");

                    int id = 0;

                    var mvpDrops = parser["MvpDrops"];

                    if (mvpDrops != null)
                    {
                        foreach (var drop in mvpDrops)
                        {
                            if (id > 2)
                            {
                                debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((ParserKeyValue)drop).Key);
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }

                    id = 0;

                    var regularDrops = parser["Drops"];

                    if (regularDrops != null)
                    {
                        foreach (var drop in regularDrops)
                        {
                            if (id > 8)
                            {
                                debug.ReportIdException("Too regular mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((ParserKeyValue)drop).Key);
                            var tuple   = SdeDatabase.GetTuple(debug, tItemId);

                            if (tuple != null && tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Card)
                            {
                                table.SetRaw(itemId, ServerMobAttributes.DropCardid, tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.DropCardper, drop.ObjectValue);
                                id++;
                                continue;
                            }

                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }
                }
            }
            else if (debug.FileType == FileType.Yaml)
            {
                try {
                    DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                    var ele   = new YamlParser(debug.FilePath);
                    var table = debug.AbsractDb.Table;

                    if (ele.Output == null || ((ParserArray)ele.Output).Objects.Count == 0)
                    {
                        return;
                    }

                    if ((ele.Output["copy_paste"] ?? ele.Output["Body"]) == null)
                    {
                        return;
                    }

                    DbIOUtils.ClearBuffer();
                    var mobDb  = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);
                    var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["Body"])
                    {
                        TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                        table.SetRaw(itemId, ServerMobAttributes.AegisName, parser["AegisName"].ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.KRoName, (parser["JapaneseName"] ?? parser["Name"]).ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Level"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Exp, parser["BaseExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JobExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Atk1, parser["Attack"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Atk2, parser["Attack2"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Def, parser["Defense"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["MagicDefense"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Str, parser["Str"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Agi"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Vit"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Int, parser["Int"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Dex"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Luk"] ?? "1");

                        table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["SkillRange"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Size, DbIOUtils.LoadFlag <SizeType>(parser["Size"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.Race, DbIOUtils.LoadFlag <MobRaceType>(parser["Race"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.RaceGroups, DbIOUtils.LoadFlag <MobGroup2Type>(parser["RaceGroups"], "0"));

                        var element = parser["Element"];
                        int elLevel;
                        int elType;

                        if (element != null)
                        {
                            switch (element.ObjectValue)
                            {
                            case "Neutral": elType = 0; break;

                            case "Water": elType = 1; break;

                            case "Earth": elType = 2; break;

                            case "Fire": elType = 3; break;

                            case "Wind": elType = 4; break;

                            case "Poison": elType = 5; break;

                            case "Holy": elType = 6; break;

                            case "Dark": elType = 7; break;

                            case "Ghost": elType = 8; break;

                            case "Undead": elType = 9; break;

                            default: elType = 0; break;
                            }
                        }
                        else
                        {
                            elType = 0;
                        }

                        element = parser["ElementLevel"];

                        if (element != null)
                        {
                            elLevel = Int32.Parse(element.ObjectValue);
                        }
                        else
                        {
                            elLevel = 1;
                        }

                        table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                        table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["WalkSpeed"] ?? "");
                        table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.DamageTaken, parser["DamageTaken"] ?? "100");

                        long mode = 0;

                        if (parser["Ai"] != null)
                        {
                            int ai = Int32.Parse(parser["Ai"].ObjectValue);

                            switch (ai)
                            {
                            case 1: mode |= 0x81; break;

                            case 2: mode |= 0x83; break;

                            case 3: mode |= 0x1089; break;

                            case 4: mode |= 0x3885; break;

                            case 5: mode |= 0x2085; break;

                            case 6: mode |= 0; break;

                            case 7: mode |= 0x108B; break;

                            case 8: mode |= 0x7085; break;

                            case 9: mode |= 0x3095; break;

                            case 10: mode |= 0x84; break;

                            case 11: mode |= 0x84; break;

                            case 12: mode |= 0x2085; break;

                            case 13: mode |= 0x308D; break;

                            case 17: mode |= 0x91; break;

                            case 19: mode |= 0x3095; break;

                            case 20: mode |= 0x3295; break;

                            case 21: mode |= 0x3695; break;

                            case 24: mode |= 0xA1; break;

                            case 25: mode |= 0x1; break;

                            case 26: mode |= 0xB695; break;

                            case 27: mode |= 0x8084; break;
                            }
                        }

                        mode |= Int64.Parse(DbIOUtils.LoadFlag <NewMobModeType>(parser["Modes"], "0"));

                        table.SetRaw(itemId, ServerMobAttributes.NewMode, mode.ToString(CultureInfo.InvariantCulture));
                        table.SetRaw(itemId, ServerMobAttributes.Class, DbIOUtils.LoadFlag <ClassType>(parser["Class"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.Sprite, parser["Sprite"] ?? "");


                        int id = 0;

                        var mvpDrops = parser["MvpDrops"];

                        if (mvpDrops != null)
                        {
                            foreach (var drop in mvpDrops)
                            {
                                if (id > 2)
                                {
                                    debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                    break;
                                }

                                int tItemId = (int)DbIOUtils.Name2IdBuffered(itemDb, ServerItemAttributes.AegisName, drop["Item"] ?? "", "item_db", false);
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop["Rate"] ?? "0");

                                if (drop["RandomOptionGroup"] != null)
                                {
                                    table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1RandomOptionGroup.Index + id], drop["RandomOptionGroup"].ObjectValue);
                                }

                                id++;
                            }
                        }

                        id = 0;

                        var regularDrops = parser["Drops"];

                        if (regularDrops != null)
                        {
                            foreach (var drop in regularDrops)
                            {
                                if (id > 9)
                                {
                                    debug.ReportIdException("Too many regular mob drops.", itemId, ErrorLevel.Critical);
                                    break;
                                }

                                int tItemId = (int)DbIOUtils.Name2IdBuffered(itemDb, ServerItemAttributes.AegisName, drop["Item"] ?? "", "item_db", false);

                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop["Rate"] ?? "0");

                                if (drop["StealProtected"] != null)
                                {
                                    if (Boolean.Parse(drop["StealProtected"].ObjectValue))
                                    {
                                        table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1Flags.Index + id], "true");
                                    }
                                }

                                if (drop["RandomOptionGroup"] != null)
                                {
                                    table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1RandomOptionGroup.Index + id], drop["RandomOptionGroup"].ObjectValue);
                                }

                                id++;
                            }
                        }
                    }
                }
                finally {
                    DbIOUtils.ClearBuffer();
                }
            }
        }
Пример #14
0
        public SdeEditor() : base("Server database editor", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize)
        {
            SplashDialog loading = new SplashDialog();

            loading.Show();
            Loaded += delegate {
                loading.Terminate();
            };

            try {
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
            }
            catch (Exception err) {
                SdeAppConfiguration.Remapper.Clear();
                ApplicationShortcut.OverrideBindings(SdeAppConfiguration.Remapper);
                ErrorHandler.HandleException("Failed to load the custom key bindings. The bindings will be reset to their default values.", err);
            }

            string configFile = _parseCommandLineArguments();

            GrfPath.Delete(ProjectConfiguration.DefaultFileName);

            InitializeComponent();
            Instance      = this;
            ShowInTaskbar = true;

            _asyncOperation = new AsyncOperation(_progressBar);
            _clientDatabase = new SdeDatabase(_metaGrf);
            _loadMenu();

            if (configFile == null)
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(ProjectConfiguration.DefaultFileName);

                if (SdeAppConfiguration.AlwaysReopenLatestProject)
                {
                    if (_recentFilesManager.Files.Count > 0 && File.Exists(_recentFilesManager.Files[0]))
                    {
                        ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile = _recentFilesManager.Files[0]);
                    }
                }
            }
            else if (File.Exists(configFile))
            {
                ProjectConfiguration.ConfigAsker = new ConfigAsker(configFile);
            }

            _loadSettingsTab();
            if (configFile != null)
            {
                ReloadSettings(configFile);
            }
            _loadGenericTab();

            _clientDatabase.Commands.ModifiedStateChanged += new AbstractCommand <IGenericDbCommand> .AbstractCommandsEventHandler(_commands_ModifiedStateChanged);

            ApplicationShortcut.Link(ApplicationShortcut.Undo, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.UndoGlobal, () => _clientDatabase.Commands.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Redo, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.RedoGlobal, () => _clientDatabase.Commands.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Search, () => _execute(v => v.Search()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Delete, () => _execute(v => v.DeleteItems()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Rename, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward, () => _tabEngine.Undo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationBackward2, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.NavigationForward, () => _tabEngine.Redo(), this);
            ApplicationShortcut.Link(ApplicationShortcut.Change, () => _execute(v => v.ChangeId()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Restrict, () => _execute(v => v.ShowSelectedOnly()), this);
            ApplicationShortcut.Link(ApplicationShortcut.CopyTo, () => _execute(v => v.CopyItemTo()), this);
            ApplicationShortcut.Link(ApplicationShortcut.New, () => _execute(v => v.AddNewItem()), this);
            ApplicationShortcut.Link(ApplicationShortcut.Save, () => _menuItemDatabaseSave_Click(this, null), this);
            ApplicationShortcut.Link(ApplicationShortcut.Replace, () => { if (_menuItemReplaceAll.IsEnabled)
                                                                          {
                                                                              _menuItemReplaceAll_Click(this, null);
                                                                          }
                                     }, this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Enter", "Select next entry"), () => _execute(v => v.SelectNext()), this);
            ApplicationShortcut.Link(ApplicationShortcut.FromString("Ctrl-Shift-Enter", "Select previous entry"), () => _execute(v => v.SelectPrevious()), this);
            Configuration.EnableDebuggerTrace = false;

            _tnbUndo.SetUndo(_tabEngine);
            _tnbRedo.SetRedo(_tabEngine);

            _tmbUndo.SetUndo(_clientDatabase.Commands);
            _tmbRedo.SetRedo(_clientDatabase.Commands);

            Extensions.GenerateListViewTemplate(_debugList, new ListViewDataTemplateHelper.GeneralColumnInfo[] {
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "#", DisplayExpression = "ErrorNumber", SearchGetAccessor = "ErrorNumber", FixedWidth = 35, ToolTipBinding = "ErrorNumber", TextAlignment = TextAlignment.Right
                },
                new ListViewDataTemplateHelper.ImageColumnInfo {
                    Header = "", DisplayExpression = "DataImage", SearchGetAccessor = "Exception", FixedWidth = 20, MaxHeight = 24
                },
                new ListViewDataTemplateHelper.RangeColumnInfo {
                    Header = "Exception", DisplayExpression = "Exception", SearchGetAccessor = "Exception", IsFill = true, TextAlignment = TextAlignment.Left, ToolTipBinding = "OriginalException", TextWrapping = TextWrapping.Wrap, MinWidth = 120
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Id", DisplayExpression = "Id", SearchGetAccessor = "Id", FixedWidth = 90, TextAlignment = TextAlignment.Left, ToolTipBinding = "Id", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "File", DisplayExpression = "FileName", SearchGetAccessor = "FilePath", FixedWidth = 145, TextAlignment = TextAlignment.Left, ToolTipBinding = "FilePath", TextWrapping = TextWrapping.Wrap
                },
                new ListViewDataTemplateHelper.GeneralColumnInfo {
                    Header = "Line", DisplayExpression = "Line", SearchGetAccessor = "Line", FixedWidth = 40, TextAlignment = TextAlignment.Left, ToolTipBinding = "Line"
                },
            }, null, new string[] { "Added", "Blue", "Default", "Black" });

            ApplicationShortcut.Link(ApplicationShortcut.Copy, () => WpfUtils.CopyContent(_debugList), _debugList);

            _debugItems            = new ObservableCollection <DebugItemView>();
            _debugList.ItemsSource = _debugItems;

            DbIOErrorHandler.ClearListeners();
            DbIOErrorHandler.AddListener(this);

            _clientDatabase.PreviewReloaded += delegate {
                this.BeginDispatch(delegate {
                    foreach (TabItem tabItem in _mainTabControl.Items)
                    {
                        tabItem.IsEnabled = true;

                        var tabItemHeader = tabItem.Header as DisplayLabel;

                        if (tabItemHeader != null)
                        {
                            tabItemHeader.ResetEnabled();
                        }
                    }
                });
            };

            _clientDatabase.Reloaded += delegate {
                _mainTabControl.Dispatch(p => p.RaiseEvent(new SelectionChangedEventArgs(Selector.SelectionChangedEvent, new List <object>(), _mainTabControl.SelectedItem == null ? new List <object>() : new List <object> {
                    _mainTabControl.SelectedItem
                })));
                ServerType serverType = DbPathLocator.GetServerType();
                bool       renewal    = DbPathLocator.GetIsRenewal();
                string     header     = String.Format("Current ({0} - {1})", serverType == ServerType.RAthena ? "rA" : "Herc", renewal ? "Renewal" : "Pre-Renewal");

                this.BeginDispatch(delegate {
                    _menuItemExportDbCurrent.IsEnabled = true;
                    _menuItemExportDbCurrent.Header    = header;

                    _menuItemExportSqlCurrent.IsEnabled = true;
                    _menuItemExportSqlCurrent.Header    = header;
                });
            };

            SelectionChanged += _sdeEditor_SelectionChanged;
        }
Пример #15
0
        public override void Init(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, DisplayableProperty <TKey, ReadableTuple <TKey> > dp)
        {
            _tab           = tab;
            _configuration = (CustomTableInitializer)tab.Settings.AttributeList[1].AttachedObject;
            _configuration.AttributeTable       = tab.Settings.AttributeList[1];
            _tab.Settings.NewItemAddedFunction += item => item.SetRawValue(_configuration.AttributeTable, new Dictionary <int, ReadableTuple <int> >());

            SdeDatabase gdb = _tab.ProjectDatabase;

            _table.Commands.CommandUndo          += _commandChanged;
            _table.Commands.CommandRedo          += _commandChanged;
            _table.Commands.CommandExecuted      += _commandChanged;
            _table.Commands.ModifiedStateChanged += _visualUpdate;

            gdb.Commands.CommandUndo     += _commandChanged2;
            gdb.Commands.CommandRedo     += _commandChanged2;
            gdb.Commands.CommandExecuted += _commandChanged2;

            Grid grid = new Grid();

            grid.SetValue(Grid.RowProperty, _row);
            grid.SetValue(Grid.ColumnProperty, 0);
            grid.SetValue(Grid.ColumnSpanProperty, 1);

            grid.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(-1, GridUnitType.Auto)
            });
            grid.RowDefinitions.Add(new RowDefinition());
            grid.ColumnDefinitions.Add(new ColumnDefinition());

            _lv = new RangeListView();
            _lv.SetValue(TextSearch.TextPathProperty, "ID");
            _lv.SetValue(WpfUtils.IsGridSortableProperty, true);
            _lv.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled);
            _lv.SetValue(Grid.RowProperty, 1);
            _lv.Width               = 334;
            _lv.FocusVisualStyle    = null;
            _lv.Margin              = new Thickness(3);
            _lv.BorderThickness     = new Thickness(1);
            _lv.HorizontalAlignment = HorizontalAlignment.Left;
            _lv.SelectionChanged   += _lv_SelectionChanged;
            SdeEditor.Instance.ProjectDatabase.Reloaded += _database_Reloaded;

            OnInitListView();

            _lv.PreviewMouseDown += delegate {
                _lv.Focus();
                Keyboard.Focus(_lv);
            };
            _lv.ContextMenu         = new ContextMenu();
            _configuration.ListView = _lv;
            dp.AddResetField(_lv);
            dp.AddUpdateAction(_updateTable);

            _dp                   = new DisplayableProperty <TKey, ReadableTuple <TKey> >();
            _dp.IsDico            = true;
            _dp.DicoConfiguration = _configuration;

            grid.Children.Add(_lv);
            OnDeplayTable();
            _tab.PropertiesGrid.Children.Add(grid);
            _dp.Deploy(_tab, null, true);

            DbSearchPanel dbSearchPanel = new DbSearchPanel();

            dbSearchPanel._border1.BorderThickness = new Thickness(1);
            dbSearchPanel.Margin = new Thickness(3, 0, 3, 0);
            grid.Children.Add(dbSearchPanel);

            Settings = new GTabSettings <TKey, ReadableTuple <TKey> >(ServerDbs.MobGroups, tab.DbComponent);

            var attributes = _configuration.SubTableAttributeList.Take(_configuration.MaxElementsToCopy).Where(p => !p.IsSkippable).ToList();

            if (!attributes.Any(p => p.IsDisplayAttribute))
            {
                var att = _configuration.SubTableAttributeList.Attributes.FirstOrDefault(p => p.IsDisplayAttribute);

                if (att != null)
                {
                    attributes.Insert(1, att);
                }
            }

            if (attributes.Count % 2 != 0)
            {
                attributes.Add(null);
            }

            Settings.AttributeList = _configuration.SubTableAttributeList;
            Settings.DbData        = _configuration.ServerDb;
            Settings.AttId         = attributes[0];
            Settings.AttDisplay    = attributes[1];

            SearchEngine = Settings.SearchEngine;
            SearchEngine.SetAttributes();
            SearchEngine.SetSettings(attributes[0], true);
            SearchEngine.SetSettings(attributes[1], true);
            SearchEngine.SetAttributes(attributes);

            SearchEngine.Init(dbSearchPanel, _lv, () => {
                var dico = _getSelectedGroups();

                if (dico == null)
                {
                    return(new List <ReadableTuple <TKey> >());
                }

                return(dico.Values.Cast <ReadableTuple <TKey> >().ToList());
            });

            ApplicationShortcut.Link(ApplicationShortcut.Cut, Cut, _lv);

            foreach (var update in _dp.Updates)
            {
                Tuple <DbAttribute, FrameworkElement> x = update;

                if (x.Item1.DataType == typeof(bool))
                {
                    CheckBox element = (CheckBox)x.Item2;
                    _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(p => Debug.Ignore(() => p.IsChecked = item.GetValue <bool>(x.Item1)))));

                    element.Checked   += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, true); };
                    element.Unchecked += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, false); };
                }
                else if (
                    x.Item1.DataType == typeof(string) ||
                    x.Item1.DataType == typeof(int))
                {
                    // This will convert integers to strings, but the database engine
                    // is smart enough to auto-convert them to integers afterwards.
                    TextBox element = (TextBox)x.Item2;
                    _dp.AddUpdateAction(new Action <ReadableTuple <TKey> >(item => element.Dispatch(
                                                                               delegate {
                        try {
                            string val = item.GetValue <string>(x.Item1);

                            if (val == element.Text)
                            {
                                return;
                            }

                            element.Text      = item.GetValue <string>(x.Item1);
                            element.UndoLimit = 0;
                            element.UndoLimit = int.MaxValue;
                        }
                        catch {
                        }
                    })));

                    element.TextChanged += delegate { _dp.ApplyDicoCommand(_tab, _lv, (ReadableTuple <TKey>)_tab.List.SelectedItem, _configuration.AttributeTable, (ReadableTuple <TKey>)_lv.SelectedItem, x.Item1, element.Text); };
                }
            }

            foreach (var property in _dp.FormattedProperties)
            {
                //property.Initialize()
                property.Init(tab, _dp);
            }
        }
Пример #16
0
 public GDbTab GenerateTab(SdeDatabase database, TabControl control, BaseDb baseDb)
 {
     return(GDbTabMaker(database, control, baseDb));
 }
Пример #17
0
        private GDbTab _gDbTabMaker(SdeDatabase database, TabControl control, BaseDb gdb)
        {
            GTabSettings <TKey, ReadableTuple <TKey> >  settings = new GTabSettings <TKey, ReadableTuple <TKey> >(gdb);
            GDbTabWrapper <TKey, ReadableTuple <TKey> > tab      = new GDbTabWrapper <TKey, ReadableTuple <TKey> >();
            Table <TKey, ReadableTuple <TKey> >         table    = gdb.To <TKey>().Table;

            settings.Table   = table;
            settings.Control = control;

            Settings.Control  = control;
            Settings.Gdb      = gdb;
            Settings.Tab      = tab;
            Settings.Table    = table;
            Settings.Database = database;

            InitStyle(tab, settings, gdb);
            InitAttributes(tab, settings, gdb);
            if (OnInitSettings != null)
            {
                OnInitSettings(tab, settings, gdb);
            }

            DisplayableProperty <TKey, ReadableTuple <TKey> > generalProperties = new DisplayableProperty <TKey, ReadableTuple <TKey> >();

            generalProperties.Spacing  = DefaultSpacing;
            Settings.GeneralProperties = generalProperties;

            SdeEditor.Instance.SelectionChanged += new SdeEditor.SdeSelectionChangedEventHandler((sender, oldTab, newTab) => {
                try {
                    TabItem item = newTab;

                    if (gdb.DbSource.AlternativeName != null)
                    {
                        if (WpfUtilities.IsTab(item, gdb.DbSource.Filename) || WpfUtilities.IsTab(item, gdb.DbSource.AlternativeName))
                        {
                            if (generalProperties.OnTabVisible != null)
                            {
                                generalProperties.OnTabVisible(this);
                            }
                            if (OnPreviewTabVisualUpdate != null)
                            {
                                OnPreviewTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabVisualUpdate != null)
                            {
                                OnTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabRefreshed != null)
                            {
                                OnTabRefreshed(Settings);
                            }
                        }
                    }
                    else
                    {
                        if (WpfUtilities.IsTab(item, gdb.DbSource))
                        {
                            if (generalProperties.OnTabVisible != null)
                            {
                                generalProperties.OnTabVisible(this);
                            }
                            if (OnPreviewTabVisualUpdate != null)
                            {
                                OnPreviewTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabVisualUpdate != null)
                            {
                                OnTabVisualUpdate(tab, settings, gdb);
                            }
                            if (OnTabRefreshed != null)
                            {
                                OnTabRefreshed(Settings);
                            }
                        }
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            });

            database.PreviewReloaded += delegate {
                if (OnPreviewDatabaseReloaded != null)
                {
                    OnPreviewDatabaseReloaded(tab, settings, gdb);
                }
            };

            database.Reloaded += delegate {
                //if (OnPreviewTabVisualUpdate != null) OnPreviewTabVisualUpdate(tab, settings, gdb);
                //if (OnTabVisualUpdate != null) OnTabVisualUpdate(tab, settings, gdb);

                DisplayablePropertyHelper.CheckAttributeRestrictions(tab, settings, gdb);

                if (OnDatabaseReloaded != null)
                {
                    OnDatabaseReloaded(tab, settings, gdb);
                }

                if (OnTabRefreshed != null)
                {
                    OnTabRefreshed(Settings);
                }
            };

            int line = 0;

            if (OnPreviewGenerateGrid != null)
            {
                OnPreviewGenerateGrid(ref line, Settings);
            }
            if (GenerateGrid != null)
            {
                GenerateGrid(ref line, Settings);
            }
            if (OnGenerateGrid != null)
            {
                OnGenerateGrid(ref line, Settings);
            }

            settings.DisplayablePropertyMaker = generalProperties;
            settings.ClientDatabase           = database;

            if (SetSettings != null)
            {
                SetSettings(tab, settings, gdb);
            }
            if (OnSetCustomCommands != null)
            {
                OnSetCustomCommands(tab, settings, gdb);
            }
            if (OnPreviewTabInitialize != null)
            {
                OnPreviewTabInitialize(tab, settings, gdb);
            }
            tab.Initialize(settings);
            if (OnAfterTabInitialize != null)
            {
                OnAfterTabInitialize(tab, settings, gdb);
            }
            return(tab);
        }
Пример #18
0
        private static void _saveFile(SdeDatabase gdb, string filename, string output, DbAttribute attribute, RequiredCondition <ReadableTuple <int> > condition = null, bool allowReturns = true)
        {
            if (output == null && gdb.MetaGrf.GetData(filename) == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, filename, null, "Table not saved (" + attribute.GetQueryName() + ")."));
                return;
            }

            if (output == null)
            {
                BackupEngine.Instance.BackupClient(filename, gdb.MetaGrf);
            }

            string   tmpFilename = Path.Combine(SdeAppConfiguration.TempPath, Path.GetFileName(filename));
            Encoding encoder     = EncodingService.DisplayEncoding;

            byte[] tmpBuffer;
            byte[] lineFeedByte       = encoder.GetBytes(SdeStrings.LineFeed);
            byte[] doubleLineFeedByte = encoder.GetBytes(SdeStrings.LineFeed + SdeStrings.LineFeed);

            using (MemoryStream memStream = new MemoryStream()) {
                IEnumerable <ReadableTuple <int> > items = gdb.GetDb <int>(ServerDbs.CItems).Table.GetSortedItems();

                int  previousId = -1;
                bool firstItem  = true;

                foreach (ReadableTuple <int> item in items)
                {
                    if (condition == null || condition(item))
                    {
                        string itemProperty = attribute != null?item.GetRawValue(attribute.Index) as string : null;

                        if (itemProperty != null || attribute == null)
                        {
                            if (attribute == ClientItemAttributes.IdentifiedDisplayName || attribute == ClientItemAttributes.UnidentifiedDisplayName)
                            {
                                itemProperty = itemProperty.Replace(" ", "_");
                            }

                            if (!firstItem)
                            {
                                if (allowReturns)
                                {
                                    if (previousId == (item.GetValue <int>(ClientItemAttributes.Id) - 1))
                                    {
                                        memStream.Write(lineFeedByte, 0, lineFeedByte.Length);
                                    }
                                    else
                                    {
                                        memStream.Write(doubleLineFeedByte, 0, doubleLineFeedByte.Length);
                                    }
                                }
                                else
                                {
                                    memStream.Write(lineFeedByte, 0, lineFeedByte.Length);
                                }
                            }

                            if (attribute == null)
                            {
                                tmpBuffer = encoder.GetBytes(item.GetValue <int>(ClientItemAttributes.Id) + "#");
                            }
                            else
                            {
                                tmpBuffer = encoder.GetBytes(item.GetValue <int>(ClientItemAttributes.Id) + "#" + itemProperty + "#");
                            }

                            memStream.Write(tmpBuffer, 0, tmpBuffer.Length);

                            previousId = item.GetValue <int>(ClientItemAttributes.Id);
                            firstItem  = false;
                        }
                    }
                }

                memStream.Write(lineFeedByte, 0, lineFeedByte.Length);

                tmpBuffer = new byte[memStream.Length];
                Buffer.BlockCopy(memStream.GetBuffer(), 0, tmpBuffer, 0, tmpBuffer.Length);

                File.WriteAllBytes(tmpFilename, tmpBuffer);
            }

            if (output == null)
            {
                var data    = gdb.MetaGrf.GetData(filename);
                var toWrite = File.ReadAllBytes(tmpFilename);

                if (data != null && Methods.ByteArrayCompare(data, toWrite))
                {
                    return;
                }

                gdb.MetaGrf.SetData(filename, toWrite);
            }
            else
            {
                string copyPath = Path.Combine(output, Path.GetFileName(filename));

                try {
                    File.Delete(copyPath);
                    File.Copy(tmpFilename, copyPath);
                    File.Delete(tmpFilename);
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }
            }

            Debug.Ignore(() => DbDebugHelper.OnWriteStatusUpdate(ServerDbs.CItems, gdb.MetaGrf.FindTkPath(filename), null, "Saving client table (" + (attribute == null ? "" : attribute.GetQueryName()) + ")."));
        }
Пример #19
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas);
            }
            else if (debug.FileType == FileType.Conf)
            {
                DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["mob_db"])
                {
                    TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                    table.SetRaw(itemId, ServerMobAttributes.SpriteName, parser["SpriteName"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.KRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Lv"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Exp, parser["Exp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JExp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Atk1, Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0));
                    table.SetRaw(itemId, ServerMobAttributes.Atk2, (Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0)) + Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 1))).ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Def, parser["Def"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["Mdef"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Str, parser["Stats.Str"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Stats.Agi"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Stats.Vit"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Int, parser["Stats.Int"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Stats.Dex"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Stats.Luk"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["ViewRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Size, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Size"] ?? "1").ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Race, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Race"] ?? "0").ToString(CultureInfo.InvariantCulture));

                    var element = parser["Element"];
                    int elLevel;
                    int elType;

                    if (element != null)
                    {
                        debug.AbsractDb.Attached["MobDb.UseConstants"] = true;
                        elLevel = Int32.Parse(((LibconfigList)element).Objects[1].ObjectValue);
                        elType  = SdeEditor.Instance.ProjectDatabase.ConstantToInt(((LibconfigList)element).Objects[0].ObjectValue);
                    }
                    else
                    {
                        elLevel = 0;
                        elType  = 0;
                    }

                    table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.Mode, (
                                     (!Boolean.Parse((parser["Mode.CanMove"] ?? "false")) ? 0 : (1 << 0)) |
                                     (!Boolean.Parse((parser["Mode.Looter"] ?? "false")) ? 0 : (1 << 1)) |
                                     (!Boolean.Parse((parser["Mode.Aggressive"] ?? "false")) ? 0 : (1 << 2)) |
                                     (!Boolean.Parse((parser["Mode.Assist"] ?? "false")) ? 0 : (1 << 3)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorIdle"] ?? "false")) ? 0 : (1 << 4)) |
                                     (!Boolean.Parse((parser["Mode.Boss"] ?? "false")) ? 0 : (1 << 5)) |
                                     (!Boolean.Parse((parser["Mode.Plant"] ?? "false")) ? 0 : (1 << 6)) |
                                     (!Boolean.Parse((parser["Mode.CanAttack"] ?? "false")) ? 0 : (1 << 7)) |
                                     (!Boolean.Parse((parser["Mode.Detector"] ?? "false")) ? 0 : (1 << 8)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorChase"] ?? "false")) ? 0 : (1 << 9)) |
                                     (!Boolean.Parse((parser["Mode.ChangeChase"] ?? "false")) ? 0 : (1 << 10)) |
                                     (!Boolean.Parse((parser["Mode.Angry"] ?? "false")) ? 0 : (1 << 11)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetMelee"] ?? "false")) ? 0 : (1 << 12)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetChase"] ?? "false")) ? 0 : (1 << 13)) |
                                     (!Boolean.Parse((parser["Mode.TargetWeak"] ?? "false")) ? 0 : (1 << 14))
                                     ).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["MoveSpeed"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "4000");
                    table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "2000");
                    table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");

                    int id = 0;

                    var mvpDrops = parser["MvpDrops"];

                    if (mvpDrops != null)
                    {
                        foreach (var drop in mvpDrops)
                        {
                            if (id > 2)
                            {
                                debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((LibconfigKeyValue)drop).Key);
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }

                    id = 0;

                    var regularDrops = parser["Drops"];

                    if (regularDrops != null)
                    {
                        foreach (var drop in regularDrops)
                        {
                            if (id > 8)
                            {
                                debug.ReportIdException("Too regular mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((LibconfigKeyValue)drop).Key);
                            var tuple   = SdeDatabase.GetTuple(debug, tItemId);

                            if (tuple != null && tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Card)
                            {
                                table.SetRaw(itemId, ServerMobAttributes.DropCardid, tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.DropCardper, drop.ObjectValue);
                                id++;
                                continue;
                            }

                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }
                }
            }
        }
Пример #20
0
 public abstract void Init(SdeDatabase database);
Пример #21
0
 public abstract GDbTab GenerateTab(SdeDatabase database, TabControl control, BaseDb baseDb);
Пример #22
0
 public override sealed GDbTab GenerateTab(SdeDatabase database, TabControl control, BaseDb baseDb)
 {
     return(TabGenerator.GenerateTab(database, control, baseDb));
 }
Пример #23
0
        public Shop(TextEditor shop, string toParse) : this()
        {
            _shop = shop;

            string[] data = toParse.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
            ShopItems.Clear();

            if (data.Length > 3)
            {
                ShopLocation = data[0];
                data         = data.Skip(1).ToArray();
            }

            if (data.Length > 2)
            {
                ShopType = data[0];
                data     = data.Skip(1).ToArray();
            }

            if (data.Length > 1)
            {
                NpcDisplayName = data[0];
                data           = data.Skip(1).ToArray();
            }

            if (data.Length > 0)
            {
                var shopInformation = data[0].Split(new char[] { ',' });

                if (shopInformation.Length > 0 && !shopInformation[0].Contains(":"))
                {
                    NpcViewId       = shopInformation[0];
                    shopInformation = shopInformation.Skip(1).ToArray();
                }

                if (shopInformation.Length > 0 && !shopInformation[0].Contains(":"))
                {
                    ShopCurrency    = Int32.Parse(shopInformation[0]);
                    shopInformation = shopInformation.Skip(1).ToArray();
                }

                if (ShopType == "trader")
                {
                    foreach (var line in toParse.Split(new string[] { "\r\n" }, StringSplitOptions.None))
                    {
                        var subLine = line.Trim('\t', ' ', ';');

                        if (subLine.StartsWith("sellitem "))
                        {
                            subLine = subLine.Substring("sellitem ".Length);

                            data = subLine.Split(',');
                            int itemId = 0;

                            if (data.Length > 0)
                            {
                                if (Int32.TryParse(data[0], out itemId))
                                {
                                }
                                else
                                {
                                    itemId = SdeDatabase.AegisNameToId(null, 0, data[0]);
                                }

                                data = data.Skip(1).ToArray();
                            }

                            int price = -1;

                            if (data.Length > 0)
                            {
                                price = Int32.Parse(data[0]);
                            }

                            ShopItems.Add(new ShopItemData {
                                ItemId = itemId, Price = price
                            });
                        }
                    }

                    return;
                }

                foreach (var shopItem in shopInformation)
                {
                    data = shopItem.Split(':');
                    ShopItems.Add(new ShopItemData {
                        ItemId = Int32.Parse(data[0]), Price = Int32.Parse(data[1])
                    });
                }
            }
        }
Пример #24
0
        public static void WriteEntry(BaseDb db, StringBuilder builder, ReadableTuple <int> tuple)
        {
            bool useConstants = db.Attached["MobDb.UseConstants"] != null && (bool)db.Attached["MobDb.UseConstants"];

            builder.AppendLine("{");
            builder.AppendLine("\tId: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture));
            builder.AppendLine("\tSpriteName: \"" + tuple.GetValue <string>(ServerMobAttributes.AegisName) + "\"");
            builder.AppendLine("\tName: \"" + tuple.GetValue <string>(ServerMobAttributes.KRoName) + "\"");

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Lv, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Hp, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Sp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Exp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.JExp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackRange, "1");
            DbIOFormatting.TrySetAttack(tuple, builder);
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Def, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Mdef, "0");

            int stat = 0;

            for (int i = 0; i < 6; i++)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	Stats: {");

                for (int i = 0; i < 6; i++)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i);

                    if (stat != 0)
                    {
                        builder.AppendLine(String.Format("		{0}: {1}", ServerMobAttributes.AttributeList[ServerMobAttributes.Str.Index + i].AttributeName, stat));
                    }
                }

                builder.AppendLine("	}");
            }

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ViewRange, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ChaseRange, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Size, "1", useConstants, "Size_");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Race, "0", useConstants, "RC_");

            int element  = tuple.GetIntNoThrow(ServerMobAttributes.Element);
            int level    = element / 10;
            int property = element - level * 10;

            level = level / 2;

            if (useConstants)
            {
                builder.AppendLine("\tElement: (\"" + SdeEditor.Instance.ProjectDatabase.IntToConstant(property, "Ele_") + "\", " + level + ")");
            }
            else
            {
                builder.AppendLine("\tElement: (" + property + ", " + level + ")");
            }

            int mode = tuple.GetIntNoThrow(ServerMobAttributes.Mode);

            if ((mode & 32767) != 0)
            {
                builder.AppendLine("	Mode: {");

                if ((mode & (1 << 0)) == (1 << 0))
                {
                    builder.AppendLine("		CanMove: true");
                }
                if ((mode & (1 << 1)) == (1 << 1))
                {
                    builder.AppendLine("		Looter: true");
                }
                if ((mode & (1 << 2)) == (1 << 2))
                {
                    builder.AppendLine("		Aggressive: true");
                }
                if ((mode & (1 << 3)) == (1 << 3))
                {
                    builder.AppendLine("		Assist: true");
                }
                if ((mode & (1 << 4)) == (1 << 4))
                {
                    builder.AppendLine("		CastSensorIdle: true");
                }
                if ((mode & (1 << 5)) == (1 << 5))
                {
                    builder.AppendLine("		Boss: true");
                }
                if ((mode & (1 << 6)) == (1 << 6))
                {
                    builder.AppendLine("		Plant: true");
                }
                if ((mode & (1 << 7)) == (1 << 7))
                {
                    builder.AppendLine("		CanAttack: true");
                }
                if ((mode & (1 << 8)) == (1 << 8))
                {
                    builder.AppendLine("		Detector: true");
                }
                if ((mode & (1 << 9)) == (1 << 9))
                {
                    builder.AppendLine("		CastSensorChase: true");
                }
                if ((mode & (1 << 10)) == (1 << 10))
                {
                    builder.AppendLine("		ChangeChase: true");
                }
                if ((mode & (1 << 11)) == (1 << 11))
                {
                    builder.AppendLine("		Angry: true");
                }
                if ((mode & (1 << 12)) == (1 << 12))
                {
                    builder.AppendLine("		ChangeTargetMelee: true");
                }
                if ((mode & (1 << 13)) == (1 << 13))
                {
                    builder.AppendLine("		ChangeTargetChase: true");
                }
                if ((mode & (1 << 14)) == (1 << 14))
                {
                    builder.AppendLine("		TargetWeak: true");
                }

                builder.AppendLine("	}");
            }

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MoveSpeed, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackDelay, "4000");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackMotion, "2000");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.DamageMotion, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MvpExp, "0");

            stat = 0;

            for (int i = 0; i < 6; i += 2)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	MvpDrops: {");

                for (int i = 0; i < 6; i += 2)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i);

                    if (stat != 0)
                    {
                        var ttuple = SdeDatabase.GetTuple(null, stat);

                        if (ttuple != null)
                        {
                            builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i + 1)));
                        }
                    }
                }

                builder.AppendLine("	}");
            }

            stat = 0;

            for (int i = 0; i < 18; i += 2)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	Drops: {");

                for (int i = 0; i < 18; i += 2)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i);

                    if (stat != 0)
                    {
                        var ttuple = SdeDatabase.GetTuple(null, stat);

                        if (ttuple != null)
                        {
                            builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i + 1)));
                        }
                    }
                }

                stat = tuple.GetIntNoThrow(ServerMobAttributes.DropCardid);

                if (stat != 0)
                {
                    var ttuple = SdeDatabase.GetTuple(null, stat);

                    if (ttuple != null)
                    {
                        builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.DropCardper.Index)));
                    }
                }

                builder.AppendLine("	}");
            }

            builder.Append("},");
        }
Пример #25
0
 public static string GetSpriteFromViewId(int viewIdToFind, ViewIdTypes type, SdeDatabase db, ReadableTuple <int> tuple)
 {
     return(GetSpriteFromViewId(viewIdToFind, type, db.GetDb <int>(ServerDbs.Items), tuple));
 }
Пример #26
0
 public DbValidationEngine(SdeDatabase database)
 {
     _database = database;
     Grf       = new GrfHolder();
 }