private void _list_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (_itemDescriptionDialog != null && _itemDescriptionDialog.IsVisible) { _itemDescriptionDialog.LoadItem(_tab.List.SelectedItem as ReadableTuple <int>); } if (_scriptEdit != null) { _scriptEdit._textEditor.Text = DbIOFormatting.ScriptFormat(_update(_tab.List.SelectedItem as ReadableTuple <int>), 0); } }
public ScriptEditDialog(string text) : base("Script edit", "cde.ico", SizeToContent.Manual, ResizeMode.CanResize) { InitializeComponent(); AvalonLoader.Load(_textEditor); AvalonLoader.SetSyntax(_textEditor, "Script"); string script = DbIOFormatting.ScriptFormat(text, 0); _textEditor.Text = script; _textEditor.TextArea.TextEntered += new TextCompositionEventHandler(_textArea_TextEntered); _textEditor.TextArea.TextEntering += new TextCompositionEventHandler(_textArea_TextEntering); _textEditor.TextChanged += (e, a) => OnValueChanged(); //_textEditor.TextArea.IndentationStrategy = new CSharpIndentationStrategy(); _completionWindow = new CompletionWindow(_textEditor.TextArea); _completionWindow.Background = Application.Current.Resources["TabItemBackground"] as Brush; _li = _completionWindow.CompletionList; ListView lv = _li.ListBox; lv.SelectionMode = SelectionMode.Single; lv.Background = Application.Current.Resources["TabItemBackground"] as Brush; //Image ListViewDataTemplateHelper.GenerateListViewTemplateNew(lv, new ListViewDataTemplateHelper.GeneralColumnInfo[] { new ListViewDataTemplateHelper.ImageColumnInfo { Header = "", DisplayExpression = "Image", TextAlignment = TextAlignment.Center, FixedWidth = 22, MaxHeight = 22, SearchGetAccessor = "Commands" }, new ListViewDataTemplateHelper.GeneralColumnInfo { Header = "Commands", DisplayExpression = "Text", TextAlignment = TextAlignment.Left, IsFill = true, ToolTipBinding = "Description" } }, null, new string[] { }, "generateHeader", "false"); _completionWindow.Content = null; _completionWindow = null; WindowStartupLocation = WindowStartupLocation.CenterOwner; _textEditor.Loaded += delegate { _textEditor.Focus(); }; }
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("},"); }
public static void WriteEntry(BaseDb db, StringBuilder builder, ReadableTuple <int> tuple) { bool useExtendedJobs = db.Attached["ItemDb.UseExtendedJobs"] != null && (bool)db.Attached["ItemDb.UseExtendedJobs"]; builder.AppendLine("{"); builder.AppendLine("\tId: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)); builder.AppendLine("\tAegisName: \"" + tuple.GetValue <string>(ServerItemAttributes.AegisName) + "\""); builder.AppendLine("\tName: \"" + tuple.GetValue <string>(ServerItemAttributes.Name) + "\""); DbIOFormatting.SetType(tuple, builder, ServerItemAttributes.Type); DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerItemAttributes.Buy, ""); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sell, (tuple.GetIntNoThrow(ServerItemAttributes.Buy) / 2).ToString(CultureInfo.InvariantCulture)); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Weight, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Attack, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Matk, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Defense, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Range, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.NumberOfSlots, "0"); if (useExtendedJobs) { DbIOFormatting.TrySetIfDefaultEmptyAddHexJobEx(tuple, builder, ServerItemAttributes.ApplicableJob, ""); } else { DbIOFormatting.TrySetIfDefaultEmptyAddHex(tuple, builder, ServerItemAttributes.ApplicableJob, ""); } DbIOFormatting.TrySetIfDefaultEmptyUpper(tuple, builder, ServerItemAttributes.Upper); DbIOFormatting.TrySetGender(tuple, builder, ServerItemAttributes.Gender, "2"); DbIOFormatting.TrySetIfDefaultLocation(tuple, builder, ServerItemAttributes.Location); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.WeaponLevel, "0"); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.EquipLevel, "0"); DbIOFormatting.TrySetIfRefineable(tuple, builder, ServerItemAttributes.Refineable, true); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.ClassNumber, "0"); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BindOnEquip, false); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.ForceSerial, false); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.BuyingStore, false); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Delay, "0"); DbIOFormatting.TrySetIfDefaultBoolean(tuple, builder, ServerItemAttributes.KeepAfterUse, false); var tradeOverride = tuple.GetIntNoThrow(ServerItemAttributes.TradeOverride); var tradeFlag = tuple.GetIntNoThrow(ServerItemAttributes.TradeFlag); if (tradeOverride != 100 || tradeFlag != 0) { builder.AppendLine(" Trade: {"); if (tradeOverride != 100) { builder.AppendLine(" override: "+ tradeOverride); } if ((tradeFlag & (1 << 0)) == (1 << 0)) { builder.AppendLine(" nodrop: true"); } if ((tradeFlag & (1 << 1)) == (1 << 1)) { builder.AppendLine(" notrade: true"); } if ((tradeFlag & (1 << 2)) == (1 << 2)) { builder.AppendLine(" partneroverride: true"); } if ((tradeFlag & (1 << 3)) == (1 << 3)) { builder.AppendLine(" noselltonpc: true"); } if ((tradeFlag & (1 << 4)) == (1 << 4)) { builder.AppendLine(" nocart: true"); } if ((tradeFlag & (1 << 5)) == (1 << 5)) { builder.AppendLine(" nostorage: true"); } if ((tradeFlag & (1 << 6)) == (1 << 6)) { builder.AppendLine(" nogstorage: true"); } if ((tradeFlag & (1 << 7)) == (1 << 7)) { builder.AppendLine(" nomail: true"); } if ((tradeFlag & (1 << 8)) == (1 << 8)) { builder.AppendLine(" noauction: true"); } builder.AppendLine(" }"); } var nouseOverride = tuple.GetIntNoThrow(ServerItemAttributes.NoUseOverride); var nouseFlag = tuple.GetIntNoThrow(ServerItemAttributes.NoUseFlag); if (nouseOverride != 100 || nouseFlag != 0) { builder.AppendLine(" Nouse: {"); if (nouseOverride != 100) { builder.AppendLine(" override: "+ nouseOverride); } if ((nouseFlag & (1 << 0)) == (1 << 0)) { builder.AppendLine(" sitting: true"); } builder.AppendLine(" }"); } DbIOFormatting.TrySetIfDefaultEmptyBracket(tuple, builder, ServerItemAttributes.Stack, ""); DbIOFormatting.TrySetIfDefaultEmpty(tuple, builder, ServerItemAttributes.Sprite, "0"); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.Script, ""); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnEquipScript, ""); DbIOFormatting.TrySetIfDefaultEmptyScript(tuple, builder, ServerItemAttributes.OnUnequipScript, ""); builder.Append("},"); }
public static void DbItemsWriterSub <TKey>(StringBuilder builder, AbstractDb <TKey> db, IEnumerable <ReadableTuple <TKey> > tuples, ServerType to) { if (to == ServerType.RAthena) { bool fromTxtDb = DbPathLocator.DetectPath(db.DbSource).IsExtension(".txt"); foreach (ReadableTuple <TKey> tuple in tuples) { List <string> rawElements = tuple.GetRawElements().Take(22).Select(p => p.ToString()).ToList(); if (tuple.Normal && fromTxtDb && tuple.GetValue <int>(ServerItemAttributes.Matk) == 0) { builder.AppendLine(String.Join(",", rawElements.ToArray())); continue; } string script1 = tuple.GetValue <string>(19); string script2 = tuple.GetValue <string>(20); string script3 = tuple.GetValue <string>(21); string refine = tuple.GetValue <string>(17); if (refine == "") { } else if (refine == "true" || refine == "1") { refine = "1"; } else { refine = "0"; } string atk = DbIOFormatting.ZeroDefault(rawElements[7]); if (db.ProjectDatabase.IsRenewal) { string matk = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? ""; if (matk != "" && matk != "0") { atk = (atk == "" ? "0" : atk) + ":" + matk; } } builder.AppendLine(String.Join(",", new string[] { rawElements[0], // ID rawElements[1], // AegisName rawElements[2], // Name DbIOFormatting.OutputInteger(rawElements[3]), // Type DbIOFormatting.ZeroDefault(rawElements[4]), // Buy DbIOFormatting.ZeroDefault(rawElements[5]), // Sell String.IsNullOrEmpty(rawElements[6]) ? "0" : rawElements[6], // Weight atk, // ATK + matk DbIOFormatting.ZeroDefault(rawElements[8]), DbIOFormatting.ZeroDefault(rawElements[9]), DbIOFormatting.ZeroDefault(rawElements[10]), // Slots String.IsNullOrEmpty(rawElements[11]) ? "0xFFFFFFFF" : !rawElements[11].StartsWith("0x") ? "0x" + Int32.Parse(rawElements[11]).ToString("X8") : rawElements[11], DbIOFormatting.HexToInt(rawElements[12]), // Upper DbIOFormatting.ZeroDefault(rawElements[13]), DbIOFormatting.ZeroDefault(DbIOFormatting.HexToInt(rawElements[14])), DbIOFormatting.ZeroDefault(rawElements[15]), DbIOFormatting.ZeroDefault(rawElements[16]), refine, DbIOFormatting.ZeroDefault(rawElements[18]), String.IsNullOrEmpty(script1) ? "{}" : "{ " + script1 + " }", String.IsNullOrEmpty(script2) ? "{}" : "{ " + script2 + " }", String.IsNullOrEmpty(script3) ? "{}" : "{ " + script3 + " }" })); } } else if (to == ServerType.Hercules) { foreach (var tuple in tuples.OrderBy(p => p.GetKey <int>()).OfType <ReadableTuple <int> >()) { WriteEntry(db, builder, tuple); builder.AppendLine(); } } }
public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb, MetaTable <int> mobDb) { if (tuple != null) { string valueS; bool valueB; builder.AppendLine(" - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture))); if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LureId)) != "" && valueS != "0") { builder.AppendLine(" TameItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EggId)) != "" && valueS != "0") { builder.AppendLine(" EggItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EquipId)) != "" && valueS != "0") { builder.AppendLine(" EquipItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.FoodId)) != "" && valueS != "0") { builder.AppendLine(" FoodItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS)); } builder.AppendLine(" Fullness: " + tuple.GetValue <int>(ServerPetAttributes.Fullness)); if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungryDelay)) != "60") { builder.AppendLine(" HungryDelay: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungerIncrease)) != "20") { builder.AppendLine(" HungerIncrease: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyStart)) != "250") { builder.AppendLine(" IntimacyStart: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyFed)) != "50") { builder.AppendLine(" IntimacyFed: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOverfed)) != "-100") { builder.AppendLine(" IntimacyOverfed: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyHungry)) != "-5") { builder.AppendLine(" IntimacyHungry: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOwnerDie)) != "-20") { builder.AppendLine(" IntimacyOwnerDie: " + valueS); } builder.AppendLine(" CaptureRate: " + tuple.GetValue <int>(ServerPetAttributes.CaptureRate)); if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.SpecialPerformance)) == false) { builder.AppendLine(" SpecialPerformance: false"); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.AttackRate)) != "" && valueS != "0") { builder.AppendLine(" AttackRate: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.RetaliateRate)) != "" && valueS != "0") { builder.AppendLine(" RetaliateRate: " + valueS); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.ChangeTargetRate)) != "" && valueS != "0") { builder.AppendLine(" ChangeTargetRate: " + valueS); } if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.AllowAutoFeed)) == true) { builder.AppendLine(" AllowAutoFeed: true"); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LoyalScript)) != "" && valueS != "{}") { builder.AppendLine(" Script: >"); builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, " ")); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.PetScript)) != "" && valueS != "{}") { builder.AppendLine(" SupportScript: >"); builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, " ")); } if ((valueS = tuple.GetValue <string>(ServerPetAttributes.Evolution)) != "" && valueS != "0") { builder.AppendLine(" Evolution:"); Evolution evolution = new Evolution(valueS); foreach (var evo in evolution.Targets) { builder.Append(" - Target: "); builder.AppendLine(DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, evo.Target)); if (evo.ItemRequirements.Count > 0) { builder.AppendLine(" ItemRequirements:"); foreach (var item in evo.ItemRequirements) { builder.Append(" - Item: "); builder.AppendLine(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, item.Item1.ToString())); builder.Append(" Amount: "); builder.AppendLine(item.Item2.ToString(CultureInfo.InvariantCulture)); } } } } } }