Beispiel #1
0
            private void _reload()
            {
                ID = _tuple.GetValue <int>(_index);

                Name = "";

                if (_itemsTable.ContainsKey(ID))
                {
                    Name = (string)_itemsTable.GetTuple(ID).GetRawValue(ServerItemAttributes.Name.Index);
                }

                DropOriginal = Int32.Parse(((string)_tuple.GetRawValue(_index + 1)));
                Drop         = String.Format("{0:0.00} %", DropOriginal / 100f);
                MVP          = _index < ServerMobAttributes.Drop1ID.Index ? "MVP" : "";

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

                    StealProtected    = Boolean.Parse(_tuple.GetRawValue <string>(distSteal));
                    RandomOptionGroup = (_tuple.GetRawValue(distRandGroup) ?? "").ToString();
                }
            }
        public override void ButtonClicked()
        {
            ReadableTuple <TKey> tuple = _tab.List.SelectedItem as ReadableTuple <TKey>;

            if (tuple == null)
            {
                return;
            }

            var dbMobs   = _tab.GetMetaTable <int>(ServerDbs.Mobs);
            var dbSkills = _tab.GetTable <int>(ServerDbs.Skills);

            try {
                string mobName   = "";
                string skillName = "";

                var tupleMob   = dbMobs.TryGetTuple(Int32.Parse(tuple.GetRawValue <string>(1)));
                var tupleSkill = dbSkills.TryGetTuple(Int32.Parse(tuple.GetRawValue <string>(4)));

                if (tupleMob != null)
                {
                    mobName = tupleMob.GetValue <string>(ServerMobAttributes.KRoName);
                }

                if (tupleSkill != null)
                {
                    skillName = tupleSkill.GetValue <string>(ServerSkillAttributes.Name);
                }

                _textBox.Text = mobName + "@" + skillName;
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Beispiel #3
0
 private void _reload()
 {
     ID           = _tuple.GetKey <int>();
     Name         = (string)_tuple.GetRawValue(ServerMobAttributes.KRoName.Index);
     DropOriginal = Int32.Parse(((string)_tuple.GetRawValue(_index + 1)));
     Drop         = String.Format("{0:0.00} %", DropOriginal / 100f);
     MVP          = _index < ServerMobAttributes.Drop1ID.Index ? "MVP" : "";
 }
            private void _reload()
            {
                ID = _tuple.GetValue <int>(_index);

                Name = "";

                if (_itemsTable.ContainsKey(ID))
                {
                    Name = (string)_itemsTable.GetTuple(ID).GetRawValue(ServerItemAttributes.Name.Index);
                }

                DropOriginal = Int32.Parse(((string)_tuple.GetRawValue(_index + 1)));
                Drop         = String.Format("{0:0.00} %", DropOriginal / 100f);
                MVP          = _index < ServerMobAttributes.Drop1ID.Index ? "MVP" : "";
            }
Beispiel #5
0
        public static void TrySetIfDefaultBoolean(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue)
        {
            if (tuple.GetRawValue(attribute.Index) as string == "")
            {
                return;
            }

            bool val = tuple.GetValue <bool>(attribute);

            if (val != defaultValue)
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": ");
                builder.AppendLine(val.ToString().ToLower());
            }
        }
Beispiel #6
0
        public static void CopyTuplesDefault(TabGenerator <TKey> tabGenerator, List <ReadableTuple <TKey> > items, DbAttribute[] attributes)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < items.Count; i++)
            {
                ReadableTuple <TKey> item = items[i];
                List <string>        objs = new List <string>();

                for (int j = 0; j < attributes.Length; j++)
                {
                    objs.Add((item.GetRawValue(attributes[j].Index) ?? "").ToString());
                }

                builder.AppendLine(string.Join(",", objs.ToArray()));
            }

            Clipboard.SetDataObject(builder.ToString());
        }
Beispiel #7
0
        protected void _addedItem(ReadableTuple <int> tupleParent, int dkey, ReadableTuple <int> dvalue, bool executed)
        {
            RangeObservableCollection <ReadableTuple <int> > result = (RangeObservableCollection <ReadableTuple <int> >)_lv.ItemsSource;

            if (executed)
            {
                Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)tupleParent.GetRawValue(1);
                SearchEngine.AddTuple((ReadableTuple <TKey>)(object) dico[dkey]);
            }
            else
            {
                result.Remove(result.FirstOrDefault(p => p.Key == dkey));
            }

            ((RangeObservableCollection <ReadableTuple <int> >)_lv.ItemsSource).Update();
        }
Beispiel #8
0
        private void _updateTable(ReadableTuple <TKey> item)
        {
            Dictionary <int, ReadableTuple <int> > groups = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1);

            if (groups == null)
            {
                groups = new Dictionary <int, ReadableTuple <int> >();
                item.SetRawValue(1, groups);
            }

            SearchEngine.Filter(this);

            //SearchEngine.FilterFinished += (s, l) => {
            //	_lv.Dispatch(p => {
            //
            //		//_lv.OnResize(new SizeChangedInfo(_lv, new Size(_lv.Width, _lv.Height), true, false));
            //		//_lv.Measure(new Size(_lv.Width, _lv.Height));
            //	});
            //};
        }
Beispiel #9
0
        public static void WriteEntry(StringBuilder builder, ReadableTuple <int> tuple, bool end = false)
        {
            builder.Append("\t[");
            builder.Append(tuple.GetValue <int>(0));
            builder.AppendLine("] = {");

            if (SdeAppConfiguration.DbWriterItemInfoUnDisplayName)
            {
                builder.Append("\t\tunidentifiedDisplayName = \"");
                builder.Append(_toAnsiEscaped(((string)tuple.GetRawValue(ClientItemAttributes.UnidentifiedDisplayName.Index)) ?? ""));
                builder.AppendLine("\",");
            }

            if (SdeAppConfiguration.DbWriterItemInfoUnResource)
            {
                builder.Append("\t\tunidentifiedResourceName = \"");
                builder.Append(_toAnsiEscaped(((string)tuple.GetRawValue(ClientItemAttributes.UnidentifiedResourceName.Index)) ?? ""));
                builder.AppendLine("\",");
            }

            if (SdeAppConfiguration.DbWriterItemInfoUnDescription)
            {
                builder.AppendLine("\t\tunidentifiedDescriptionName = {");
                _toLuaDescription(builder, _toAnsiEscaped((string)tuple.GetRawValue(ClientItemAttributes.UnidentifiedDescription.Index) ?? ""));
                builder.AppendLine("\t\t},");
            }

            if (SdeAppConfiguration.DbWriterItemInfoIdDisplayName)
            {
                builder.Append("\t\tidentifiedDisplayName = \"");
                builder.Append(_toAnsiEscaped(((string)tuple.GetRawValue(ClientItemAttributes.IdentifiedDisplayName.Index)) ?? ""));
                builder.AppendLine("\",");
            }

            if (SdeAppConfiguration.DbWriterItemInfoIdResource)
            {
                builder.Append("\t\tidentifiedResourceName = \"");
                builder.Append(_toAnsiEscaped(((string)tuple.GetRawValue(ClientItemAttributes.IdentifiedResourceName.Index)) ?? ""));
                builder.AppendLine("\",");
            }

            if (SdeAppConfiguration.DbWriterItemInfoIdDescription)
            {
                builder.AppendLine("\t\tidentifiedDescriptionName = {");
                _toLuaDescription(builder, _toAnsiEscaped((string)tuple.GetRawValue(ClientItemAttributes.IdentifiedDescription.Index) ?? ""));
                builder.AppendLine("\t\t},");
            }

            if (SdeAppConfiguration.DbWriterItemInfoSlotCount)
            {
                builder.Append("\t\tslotCount = ");
                builder.Append(_toAnsiEscaped((String.IsNullOrEmpty(tuple.GetValue <string>(ClientItemAttributes.NumberOfSlots.Index)) ? "0" : tuple.GetValue <string>(ClientItemAttributes.NumberOfSlots.Index))));
                builder.AppendLine(",");
            }

            if (SdeAppConfiguration.DbWriterItemInfoClassNum)
            {
                builder.Append("\t\tClassNum = ");

                if (SdeAppConfiguration.DbWriterItemInfoIsCostume)
                {
                    builder.Append(_toAnsiEscaped((String.IsNullOrEmpty(tuple.GetValue <string>(ClientItemAttributes.ClassNumber.Index)) ? "0" : tuple.GetValue <string>(ClientItemAttributes.ClassNumber.Index))));
                    builder.AppendLine(",");
                }
                else
                {
                    builder.AppendLine(_toAnsiEscaped((String.IsNullOrEmpty(tuple.GetValue <string>(ClientItemAttributes.ClassNumber.Index)) ? "0" : tuple.GetValue <string>(ClientItemAttributes.ClassNumber.Index))));
                }
            }

            if (SdeAppConfiguration.DbWriterItemInfoIsCostume)
            {
                builder.Append("\t\tcostume = ");
                builder.AppendLine(tuple.GetValue <bool>(ClientItemAttributes.IsCostume.Index).ToString().ToLowerInvariant());
            }

            builder.AppendLine(end ? "\t}" : "\t},");
        }
Beispiel #10
0
        public static void Writer2 <TKey>(ReadableTuple <TKey> item, ServerType destServer, StringBuilder builder, BaseDb db, List <string> aegisNames, List <string> names)
        {
            var itemCopy = new ReadableTuple <TKey>(item.GetKey <TKey>(), item.Attributes);

            itemCopy.Copy(item);
            item = itemCopy;

            int key = item.GetKey <int>();

            if (destServer == ServerType.RAthena)
            {
                var        itemDb = db.GetMeta <int>(ServerDbs.Items);
                ServerType source = DbPathLocator.GetServerType();

                if (source == ServerType.Hercules)
                {
                    List <string> constantsList             = Constants.Keys.ToList();
                    Table <int, ReadableTuple <int> > table = db.GetMeta <int>(ServerDbs.Items);

                    var tuple = item;
                    var res2  = table.TryGetTuple(key);

                    if (res2 != null)
                    {
                        string name  = res2.GetValue(ServerItemAttributes.AegisName).ToString();
                        int    low   = Int32.MaxValue;
                        int    index = -1;

                        for (int j = 0; j < Constants.Count; j++)
                        {
                            int dist = Methods.LevenshteinDistance(name, constantsList[j]);

                            if (dist < low)
                            {
                                low   = dist;
                                index = j;
                            }
                        }

                        string closestString = constantsList[index];

                        int groupId = Constants[closestString];
                        tuple.SetRawValue(0, groupId);
                    }
                }

                Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)item.GetRawValue(1);
                key = item.GetKey <int>();

                foreach (var pair in dico.OrderBy(p => p.Key))
                {
                    var           dbTuple = itemDb.TryGetTuple(pair.Key);
                    List <string> items   = ServerItemGroupSubAttributes.AttributeList.Attributes.Select(p => pair.Value.GetValue <string>(p)).ToList();
                    RemoveDefaultValues(items);
                    builder.AppendLine(key + "," + string.Join(",", items.ToArray()) + (dbTuple == null ? "" : "\t// " + dbTuple.GetValue(ServerItemAttributes.Name)));
                }

                builder.AppendLine();
            }
            else if (destServer == ServerType.Hercules)
            {
                builder.AppendLine(ItemGroupParser.ToHerculesDbEntry(db, item.GetKey <int>(), aegisNames, names));
                builder.AppendLine();
            }
        }
Beispiel #11
0
        private void _addedItem(ReadableTuple <int> tuple, DbAttribute attribute, int dkey, ReadableTuple <int> dvalue, int newdkey, bool executed)
        {
            RangeObservableCollection <ItemView> result = (RangeObservableCollection <ItemView>)_lv.ItemsSource;

            if (result == null)
            {
                result          = new RangeObservableCollection <ItemView>();
                _lv.ItemsSource = result;
            }

            if (executed)
            {
                Dictionary <int, ReadableTuple <int> > dico = (Dictionary <int, ReadableTuple <int> >)tuple.GetRawValue(1);
                var itemView = new ItemView(((GenericDatabase)_tab.Database).GetMetaTable <int>(ServerDbs.Items), dico, dkey);
                Extensions.InsertIntoList(_lv, itemView, result);
                _lv.SelectedItem = itemView;
                _lv.ScrollToCenterOfView(itemView);
            }
            else
            {
                result.Remove(result.FirstOrDefault(p => p.ID == dkey));
            }
        }
Beispiel #12
0
		private static void _trySetIfDefaultBoolean(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) {
			if (tuple.GetRawValue(attribute.Index) as string == "")
				return;

			bool val = tuple.GetValue<bool>(attribute);

			if (val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val.ToString().ToLower());
			}
		}