Exemplo n.º 1
0
        private void _tbImport_Click(object sender, RoutedEventArgs e)
        {
            Table <int, ReadableTuple <int> > btable = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

            SelectFromDialog select = new SelectFromDialog(btable, ServerDbs.Mobs, "");

            select.Owner = WpfUtilities.TopWindow;

            if (select.ShowDialog() == true)
            {
                _eventsDisabled = true;
                ReadableTuple <int> tuple = btable.GetTuple(select.Id.ToInt());
                _level = tuple.GetValue <int>(ServerMobAttributes.Lv);

                for (int i = 0; i < 6; i++)
                {
                    _rates[i] = tuple.GetValue <int>(ServerMobAttributes.Str.Index + i);
                }

                _gpRate.SetPosition(_level / Limit, false);

                _setValues();
                _eventsDisabled = false;
            }
        }
Exemplo n.º 2
0
 private static void _trySetIfDefault(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
 {
     if (tuple.GetValue <string>(attribute) != defaultValue)
     {
         builder.AppendLineUnix("\t" + attribute.AttributeName + ": " + tuple.GetValue <string>(attribute));
     }
 }
Exemplo n.º 3
0
        public static bool IsArmorType(ReadableTuple <int> tuple)
        {
            if (SdeAppConfiguration.RevertItemTypes)
            {
                return(tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Weapon);
            }

            return(tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Armor);
        }
Exemplo n.º 4
0
        public static void TrySetAttack(ReadableTuple <int> tuple, StringBuilder builder)
        {
            var atk1 = FormatConverters.IntOrHexConverter(tuple.GetValue <string>(ServerMobAttributes.Atk1));
            var atk2 = FormatConverters.IntOrHexConverter(tuple.GetValue <string>(ServerMobAttributes.Atk2));

            if (atk1 == atk2 && atk1 == 0)
            {
                return;
            }

            builder.AppendLine("\tAttack: [" + atk1 + ", " + (atk2 - atk1) + "]");
        }
Exemplo n.º 5
0
        public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple)
        {
            if (tuple != null)
            {
                string valueS;

                builder.AppendLine("  - Id: " + tuple.Key);
                builder.AppendLine("    Map: " + (String.IsNullOrEmpty((valueS = tuple.GetValue <string>(ServerCastleAttributes.MapName))) ? "SDE_NULL" : valueS));
                builder.AppendLine("    Name: " + (String.IsNullOrEmpty((valueS = tuple.GetValue <string>(ServerCastleAttributes.CastleName))) ? "SDE_NULL" : valueS));
                builder.AppendLine("    Npc: " + (String.IsNullOrEmpty((valueS = tuple.GetValue <string>(ServerCastleAttributes.NpcName))) ? "SDE_NULL" : valueS));
            }
        }
Exemplo n.º 6
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();
                }
            }
Exemplo n.º 7
0
        private void _updateFields(ReadableTuple <int> tuple)
        {
            // We update the fields
            int value = tuple.GetValue <int>(_attribute);

            _boxes.ForEach(p => p.IsChecked = false);

            if (value == 0)
            {
                _boxes[0].IsChecked = true;
            }
            else
            {
                for (int i = 1; i < 4; i++)
                {
                    CheckBox box = _boxes[i];

                    int val = 1 << (i - 1);

                    if ((value & val) == val)
                    {
                        box.IsChecked = true;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void _autoAddElement(ReadableTuple <int> tupleSource, ParameterHolder holder)
        {
            var          script = tupleSource.GetValue <string>(ServerItemAttributes.Script);
            const string Bonus  = "bonus bAtkEle";

            if (script.Contains(Bonus))
            {
                int start = script.IndexOf(Bonus, StringComparison.Ordinal) + Bonus.Length;
                int end   = script.IndexOf(";", start, StringComparison.Ordinal);

                if (end < 0)
                {
                    end = script.Length;
                }

                var bonus = script.Substring(start, end - start).Trim(',', ' ', ';');

                if (bonus.Length > 4)
                {
                    holder.Values[ParameterHolderKeys.Property] = bonus.Substring(4);
                }
            }
            else
            {
                if (ProjectConfiguration.AutocompleteNeutralProperty)
                {
                    holder.Values[ParameterHolderKeys.Property] = "Neutral";
                }
            }
        }
Exemplo n.º 9
0
        public static void SetQuestValue(Table <int, ReadableTuple <int> > table, ReadableTuple <int> tuple, string[] elements, int id)
        {
            string value = tuple.GetValue <string>(ClientQuestsAttributes.AttributeList[id]);

            if (value == "")
            {
                if (elements[id] == "")
                {
                    return;
                }

                table.Commands.Set(tuple, ClientQuestsAttributes.AttributeList[id], elements[id]);
            }
            else if (elements[id] == "")
            {
                //table.Set(tuple.Key, ClientQuestsAttributes.AttributeList[id], value);
            }
            else if (_isKorean(value))
            {
                if (elements[id] == value)
                {
                    return;
                }

                table.Commands.Set(tuple, ClientQuestsAttributes.AttributeList[id], elements[id]);
            }
            else if (_isKorean(elements[id]))
            {
                //table.Set(tuple.Key, ClientQuestsAttributes.AttributeList[id], value);
            }
        }
Exemplo n.º 10
0
 private static void _trySet(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute)
 {
     builder.Append("\t");
     builder.Append(attribute.AttributeName);
     builder.Append(": ");
     builder.AppendLineUnix(tuple.GetValue <string>(attribute));
 }
Exemplo n.º 11
0
        public static void TrySetGender(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            int    key = tuple.GetKey <int>();
            string val = tuple.GetValue <string>(attribute);

            if (key >= 1950 && key < 2000)
            {
                if (val == "0")
                {
                    return;
                }
            }

            if (key == 2635)
            {
                if (val == "0")
                {
                    return;
                }
            }

            if (val != "" && val != defaultValue && val != "-1")
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": ");
                builder.AppendLine(val);
            }
        }
Exemplo n.º 12
0
        private void _update()
        {
            try {
                GDbTab tab = _editor.FindTopmostTab();
                _tab  = tab;
                _item = null;

                if (tab != null && (tab.DbComponent.DbSource == ServerDbs.Mobs || tab.DbComponent.DbSource == ServerDbs.Mobs2))
                {
                    ReadableTuple <int> tuple = tab._listView.SelectedItem as ReadableTuple <int>;
                    _mobDb = (AbstractDb <int>)tab.DbComponent;

                    if (tab.DbComponent.DbSource == ServerDbs.Mobs && !_bind1)
                    {
                        tab._listView.SelectionChanged += (e, s) => _update();
                        _bind1 = true;
                    }

                    if (tab.DbComponent.DbSource == ServerDbs.Mobs2 && !_bind2)
                    {
                        tab._listView.SelectionChanged += (e, s) => _update();
                        _bind2 = true;
                    }

                    if (tuple != null)
                    {
                        _item = _mobDb.Table.GetTuple(tuple.Key);

                        _eventsDisabled = true;
                        _level          = _item.GetValue <int>(ServerMobAttributes.Lv);

                        for (int i = 0; i < 6; i++)
                        {
                            _rates[i] = _item.GetValue <int>(ServerMobAttributes.Str.Index + i);
                        }

                        _gpRate.SetPosition(_level / Limit, false);
                        _setValues();
                        _eventsDisabled = false;
                    }
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Exemplo n.º 13
0
        public static void ExpandFlagYaml <T>(StringBuilder builder, ReadableTuple <int> tuple, string name, DbAttribute attribute, string indent1, string indent2, Func <bool> isExtra = null, Action extra = null)
        {
            long value = FormatConverters.LongOrHexConverter(tuple.GetValue <string>(attribute));

            if (value != 0 || (isExtra != null && isExtra()))
            {
                if (name != "")
                {
                    builder.Append(indent1);
                    builder.Append(name);
                    builder.AppendLine(": {");
                }

                var flagsData = FlagsManager.GetFlag <T>();

                if (flagsData != null)
                {
                    foreach (var v in flagsData.Values)
                    {
                        long vF = v.Value;

                        if ((v.DataFlag & FlagDataProperty.Hide) == FlagDataProperty.Hide)
                        {
                            continue;
                        }

                        if ((vF & value) == vF)
                        {
                            builder.Append(indent2);
                            builder.Append(v.Name);
                            builder.AppendLine(": true");
                        }
                    }
                }
                else
                {
                    foreach (var v in Enum.GetValues(typeof(T)).Cast <T>())
                    {
                        int vF = (int)(object)v;

                        if ((vF & value) == vF)
                        {
                            builder.Append(indent2);
                            builder.Append(Constants.ToString(v));
                            builder.AppendLine(": true");
                        }
                    }
                }

                if (extra != null)
                {
                    extra();
                }

                builder.Append(indent1);
                builder.AppendLine("}");
            }
        }
Exemplo n.º 14
0
        public static void TrySetIfNotDefault(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            string val = tuple.GetValue <string>(attribute);

            if (val != defaultValue)
            {
                builder.AppendLine("\t" + attribute.AttributeName + ": " + val);
            }
        }
Exemplo n.º 15
0
        private void _autoAddJob(ReadableTuple <int> tupleSource, ParameterHolder holder, int equipLevel)
        {
            var    val            = tupleSource.GetValue <string>(ServerItemAttributes.ApplicableJob);
            string applicationJob = JobList.GetStringJobFromHex(val, _getUpper(tupleSource), _getGender(tupleSource), equipLevel);

            //if (!String.IsNullOrEmpty(applicationJob)) {
            holder.Values[ParameterHolderKeys.ApplicableJob] = applicationJob;
            //}
        }
Exemplo n.º 16
0
        public void Read(ReadableTuple <int> tuple, GDbTab tab)
        {
            PreviewSprite = null;
            KeepPreviousPreviewPosition = true;
            RemoveJobs();
            RemoveError();
            List <Job> jobs;

            _lastTuple  = tuple;
            _metaGrf    = tab.ProjectDatabase.MetaGrf;
            _currentTab = tab;

            foreach (var preview in _previews)
            {
                if (preview.CanRead(tuple))
                {
                    if (_lastMatch != preview)
                    {
                        KeepPreviousPreviewPosition = false;
                    }

                    _lastMatch = preview;
                    string job = tuple.GetValue <string>(ServerItemAttributes.ApplicableJob);
                    jobs = JobList.GetJobsFromHex("0x" + ((job == "") ? "FFFFFFFF" : job), tuple.GetIntNoThrow(ServerItemAttributes.Upper));
                    preview.Read(tuple, this, jobs);
                    break;
                }
            }

            if (_listView.Items.Count > 0)
            {
                _listView.SelectedItem = PreferredJob;

                if (_listView.SelectedItem == null)
                {
                    if (_oldJob != null)
                    {
                        _listView.SelectedItem = _oldJob;
                    }

                    if (_listView.SelectedItem == null)
                    {
                        _listView.SelectedIndex = 0;
                    }
                }
            }
            else
            {
                _updatePreview(SpriteDefault);
            }

            if (!KeepPreviousPreviewPosition)
            {
                _selector.SetAction(_lastMatch.SuggestedAction);
            }
        }
Exemplo n.º 17
0
        private void _autoAddJobIfRestricted(ReadableTuple <int> tupleSource, ParameterHolder holder)
        {
            var    val            = tupleSource.GetValue <string>(ServerItemAttributes.ApplicableJob);
            string applicationJob = JobList.GetStringJobFromHex(val, _getUpper(tupleSource), _getGender(tupleSource));

            if (String.CompareOrdinal(applicationJob, JobList.EveryJob.Name) != 0)
            {
                holder.Values[ParameterHolderKeys.ApplicableJob] = applicationJob;
            }
        }
Exemplo n.º 18
0
        private int _getGender(ReadableTuple <int> tuple)
        {
            var gender = tuple.GetValue <int>(ServerItemAttributes.Gender);

            if (gender < 0)
            {
                return(2);
            }
            return(gender);
        }
Exemplo n.º 19
0
        public static void TrySetIfDefaultLocation(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute)
        {
            string val = tuple.GetValue <string>(attribute);

            if (val != "" && val != "0")
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": ");
                builder.AppendLine(val);
            }
        }
Exemplo n.º 20
0
        private static void _trySetIfDefaultEmptyUpper(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute)
        {
            string val = tuple.GetValue <string>(attribute);

            if (val != "" && val != "7" && val != "63")
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": ");
                builder.AppendLineUnix(val);
            }
        }
Exemplo n.º 21
0
        public static void TrySetIfDefaultEmptyAddHex(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            string val = "0x" + tuple.GetValue <string>(attribute);

            if (val != "" && val != defaultValue && val.Length > 2 && val.ToLower() != "0xffffffff")
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": ");
                builder.AppendLine(val);
            }
        }
Exemplo n.º 22
0
        public static void TrySetIfDefaultEmptyScript(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            string val = tuple.GetValue <string>(attribute);

            if (val != "" && val != defaultValue)
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": <\"");
                builder.Append(ScriptFormat(val, 2, true));
                builder.AppendLine("\">");
            }
        }
Exemplo n.º 23
0
        public static void TrySetIfDefaultEmptyBracket(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            string val = tuple.GetValue <string>(attribute);

            if (val != "" && val != defaultValue)
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.Append(": [");
                builder.Append(val);
                builder.AppendLine("]");
            }
        }
Exemplo n.º 24
0
        private int _getUpper(ReadableTuple <int> tuple)
        {
            var upper = tuple.GetValue <string>(ServerItemAttributes.Upper);

            if (String.IsNullOrEmpty(upper))
            {
                return(JobGroup.All.Id);
            }

            int ival;

            Int32.TryParse(upper, out ival);
            return(ival);
        }
Exemplo n.º 25
0
        public static void TrySetIfDefaultEmptyAddHexJobEx(ReadableTuple <int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue)
        {
            string val = "0x" + tuple.GetValue <string>(attribute);

            if (val != "" && val != defaultValue && val.Length > 2 && val.ToLower() != "0xffffffff")
            {
                builder.Append("\t");
                builder.Append(attribute.AttributeName);
                builder.AppendLine(": {");

                int value = FormatConverters.IntOrHexConverter(val);

                if (value == 0)
                {
                    builder.AppendLine("\t\tAll: false");
                    builder.AppendLine("\t}");
                    return;
                }

                if (value > 0)
                {
                    foreach (var job in DbIOItems.ItemDbJobs)
                    {
                        if ((value & job.Value) == job.Value)
                        {
                            builder.Append("\t\t");
                            builder.Append(job.Key);
                            builder.AppendLine(": true");
                        }
                    }
                }
                else
                {
                    builder.AppendLine("\t\tAll: true");

                    foreach (var job in DbIOItems.ItemDbJobs.Skip(1))
                    {
                        if ((value & ~job.Value) == ~job.Value)
                        {
                            builder.Append("\t\t");
                            builder.Append(job.Key);
                            builder.AppendLine(": false");
                        }
                    }
                }

                builder.AppendLine("\t}");
            }
        }
Exemplo n.º 26
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());
			}
		}
Exemplo n.º 27
0
		private static void _trySet(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute) {
			builder.Append("\t");
			builder.Append(attribute.AttributeName);
			builder.Append(": ");
			builder.AppendLineUnix(tuple.GetValue<string>(attribute));
		}
Exemplo n.º 28
0
		private static void _trySetIfDefault(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			if (tuple.GetValue<string>(attribute) != defaultValue) {
				builder.AppendLineUnix("\t" + attribute.AttributeName + ": " + tuple.GetValue<string>(attribute));
			}
		}
Exemplo n.º 29
0
		private static void _trySetIfDefaultLocation(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != "0") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
Exemplo n.º 30
0
		private static void _trySetIfDefaultEmptyScript(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": <\"");
				builder.Append(Format(val, 2, true));
				builder.AppendLineUnix("\">");
			}
		}
Exemplo n.º 31
0
		private static void _trySetGender(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			int key = tuple.GetKey<int>();
			string val = tuple.GetValue<string>(attribute);

			if (key >= 1950 && key < 2000) {
				if (val == "0")
					return;
			}

			if (key == 2635) {
				if (val == "0")
					return;
			}

			if (val != "" && val != defaultValue && val != "-1") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
Exemplo n.º 32
0
		private static void _trySetIfDefaultEmptyBracket(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": [");
				builder.Append(val);
				builder.AppendLineUnix("]");
			}
		}
Exemplo n.º 33
0
		private static void _trySetIfRefineable(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, bool defaultValue) {
			int type = tuple.GetValue<int>(ServerItemAttributes.Type);
			bool val = tuple.GetValue<bool>(attribute);

			if (type != 4 && type != 5) {
				if (val) {
					// This is not supposed to be allowed, but... we'll let it slide
					DbLoaderErrorHandler.Handle("The refineable status on the item ID [" + tuple.GetKey<int>() + "] has been set to true but the item type is not an equipment. This is suspicious.", ErrorLevel.Warning);
					builder.AppendLineUnix("\t" + attribute.AttributeName + ": true");
				}
				return;
			}

			if (val != defaultValue) {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val.ToString().ToLower());
			}
		}
Exemplo n.º 34
0
		private static void _trySetIfDefaultEmptyAddHex(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = "0x" + tuple.GetValue<string>(attribute);

			if (val != "" && val != defaultValue && val.Length > 2 && val.ToLower() != "0xffffffff") {
				builder.Append("\t");
				builder.Append(attribute.AttributeName);
				builder.Append(": ");
				builder.AppendLineUnix(val);
			}
		}
Exemplo n.º 35
0
		private static void _trySetIfDefaultEmptyToHex(ReadableTuple<int> tuple, StringBuilder builder, DbAttribute attribute, string defaultValue) {
			string val = tuple.GetValue<string>(attribute);

			int ival;

			if (Int32.TryParse(val, out ival)) {
				string sval = "0x" + ival.ToString("X").ToLower();

				if (val != defaultValue) {
					builder.Append("\t");
					builder.Append(attribute.AttributeName);
					builder.Append(": ");
					builder.AppendLineUnix(sval);
				}
			}
			else {
				Z.F();
			}
		}