public static void CheckAttributeRestrictions <TKey>(GDbTabWrapper <TKey, ReadableTuple <TKey> > tab, GTabSettings <TKey, ReadableTuple <TKey> > settings, BaseDb gdb) { foreach (var attributeS in settings.AttributeList.Attributes) { DbAttribute attribute = attributeS; if (attribute.Requirements.Renewal == RenewalType.Both && attribute.Requirements.Server == ServerType.Both) { continue; } tab.PropertiesGrid.Dispatch(delegate { var gridAttributes = GetAll(tab.PropertiesGrid, attribute); RenewalType rType = DbPathLocator.GetIsRenewal() ? RenewalType.Renewal : RenewalType.PreRenewal; ServerType sType = DbPathLocator.GetServerType(); gridAttributes.ForEach(p => p.IsEnabled = false); if ((attribute.Requirements.Renewal & rType) == rType && (attribute.Requirements.Server & sType) == sType) { gridAttributes.ForEach(p => p.IsEnabled = true); } else { gridAttributes.ForEach(p => p.IsEnabled = false); } }); } }
public void Show(ServerType serverType, bool?renewal, params DbAttribute[] attributes) { bool enable = DbPathLocator.GetServerType() == serverType; if (renewal == null || renewal.Value == DbPathLocator.GetIsRenewal()) { Show(enable, attributes); } }
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; }
private void _menuItemExportSqlCurrent_Click(object sender, RoutedEventArgs e) { _export(DbPathLocator.GetServerType(), DbPathLocator.GetIsRenewal() ? "re" : "pre-re", FileType.Sql); }
private void _validateMobDb(MetaTable <int> db, List <ValidationErrorView> errors) { foreach (var tuple in db.FastItems) { if (SdeAppConfiguration.DbValidMaxItemDbId >= 0) { if (tuple.Key <= 1000 || tuple.Key > SdeAppConfiguration.DbValidMaxMobDbId) { errors.Add(new TableError(ValidationErrors.TbMobId, tuple.Key, String.Format("Invalid monster ID {0}, allowed values {1} < ID <= {2} (MAX_MOB_DB).", tuple.Key, 1000, SdeAppConfiguration.DbValidMaxMobDbId), ServerDbs.Mobs, this)); } } if (_pcCheckId((uint)tuple.Key)) { errors.Add(new TableError(ValidationErrors.TbReservedId, tuple.Key, String.Format("Invalid monster ID {0}, reserved for player classes.", tuple.Key), ServerDbs.Mobs, this)); } if (tuple.Key >= (SdeAppConfiguration.DbValidMaxMobDbId - 999) && tuple.Key < SdeAppConfiguration.DbValidMaxMobDbId) { errors.Add(new TableError(ValidationErrors.TbInvalidRange, tuple.Key, String.Format("Invalid monster ID {0}. Range {1}-{2} is reserved for player clones. Please increase MAX_MOB_DB ({3}).", tuple.Key, SdeAppConfiguration.DbValidMaxMobDbId - 999, SdeAppConfiguration.DbValidMaxMobDbId - 1, SdeAppConfiguration.DbValidMaxMobDbId), ServerDbs.Mobs, this)); } var level = tuple.GetIntNoThrow(ServerMobAttributes.Lv); var minAtk = tuple.GetIntNoThrow(ServerMobAttributes.Atk1); var maxAtk = tuple.GetIntNoThrow(ServerMobAttributes.Atk2); var def = tuple.GetIntNoThrow(ServerMobAttributes.Def); var mdef = tuple.GetIntNoThrow(ServerMobAttributes.Mdef); //var baseExp = tuple.GetIntNoThrow(ServerMobAttributes.Lv); //var jobExp = tuple.GetIntNoThrow(ServerMobAttributes.Lv); _capValue(level, "level", 1, 0xffff, tuple, errors); _capValue(minAtk, "minAtk", 0, 0xffff, tuple, errors); _capValue(maxAtk, "maxAtk", 0, 0xffff, tuple, errors); var isRenewal = DbPathLocator.GetIsRenewal(); _capValue(def, "def", isRenewal ? -32768 : -128, isRenewal ? 32767 : 127, tuple, errors); _capValue(mdef, "mdef", isRenewal ? -32768 : -128, isRenewal ? 32767 : 127, tuple, errors); for (int i = 0; i < 6; i++) { var value = tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i); _capValue(value, ServerMobAttributes.AttributeList.Attributes[ServerMobAttributes.Str.Index + i].DisplayName, 0, 0xffff, tuple, errors); } var defEle = tuple.GetIntNoThrow(ServerMobAttributes.Element) % 10; var eleLevel = tuple.GetIntNoThrow(ServerMobAttributes.Element) / 20; if (defEle >= SdeAppConfiguration.DbValidMaxMobDbElement) { errors.Add(new TableError(ValidationErrors.TbElementType, tuple.Key, String.Format("Invalid element type {0} for monster ID {1} (max = {2}).", defEle, tuple.Key, SdeAppConfiguration.DbValidMaxMobDbElement - 1), ServerDbs.Mobs, this)); } if (eleLevel < 1 || eleLevel > 4) { errors.Add(new TableError(ValidationErrors.TbElementLevel, tuple.Key, String.Format("Invalid element level {0} for monster ID {1}, must be in range 1-4.", eleLevel, tuple.Key), ServerDbs.Mobs, this)); } var adelay = tuple.GetIntNoThrow(ServerMobAttributes.AttackDelay); var amotion = tuple.GetIntNoThrow(ServerMobAttributes.AttackMotion); var hp = (long)tuple.GetIntNoThrow(ServerMobAttributes.Hp); var mexp = (long)tuple.GetIntNoThrow(ServerMobAttributes.MvpExp); _capValue(adelay, "aDelay", 0, 4000, tuple, errors); _capValue(amotion, "aMotion", 0, 2000, tuple, errors); _capValue(hp, "HP", 0, Int32.MaxValue, tuple, errors); _capValue(mexp, "MExp", 0, Int32.MaxValue, tuple, errors); } }