private string _viewIdToString(int viewId) { NpcPreview preview = new NpcPreview(); _helper.ViewId = viewId; preview.Read(null, _helper, new List <Job>()); return(preview.GetSpriteFromJob(null, _helper)); }
private void _findResourceErrors(List <ValidationErrorView> errors) { var itemDb = _database.GetMetaTable <int>(ServerDbs.Items); var citemDb = _database.GetMetaTable <int>(ServerDbs.CItems); HashSet <string> processed = new HashSet <string>(); _helper = new PreviewHelper( new RangeListView(), _database.GetDb <int>(ServerDbs.Items), null, null, null, null ); Dictionary <int, string> npcsIds = new Dictionary <int, string>(); if (SdeAppConfiguration.VaResNpc) { string error; LuaHelper.GetIdToSpriteTable(_database.GetDb <int>(ServerDbs.Items), LuaHelper.ViewIdTypes.Npc, out npcsIds, out error); } int totalEntries = citemDb.Count + itemDb.Count + npcsIds.Count; int current = 0; char[] invalid = Path.GetInvalidFileNameChars(); foreach (var citem in citemDb.FastItems) { AProgress.IsCancelling(this); Progress = (float)current / totalEntries * 100f; current++; if (SdeAppConfiguration.VaResExistingOnly) { if (itemDb.TryGetTuple(citem.Key) == null) { continue; } } var idresource = citem.GetValue <string>(ClientItemAttributes.IdentifiedResourceName) ?? ""; var unresource = citem.GetValue <string>(ClientItemAttributes.UnidentifiedResourceName) ?? ""; if (idresource == "") { if (SdeAppConfiguration.VaResEmpty) { errors.Add(new ResourceError(ValidationErrors.ResEmpty, citem.Key, "Empty identified resource.", ServerDbs.CItems, this, null)); } } else if (invalid.Any(idresource.Contains)) { if (SdeAppConfiguration.VaResInvalidCharacters) { errors.Add(new ResourceError(ValidationErrors.ResInvalidName, citem.Key, "Illegal characters found in resource name.", ServerDbs.CItems, this, null)); } } else { _resource(citem, ResourceType.Identified, idresource, processed, errors); } if (unresource == "") { if (SdeAppConfiguration.VaResEmpty) { errors.Add(new ResourceError(ValidationErrors.ResEmpty, citem.Key, "Empty identified resource.", ServerDbs.CItems, this, null)); } } else if (invalid.Any(unresource.Contains)) { if (SdeAppConfiguration.VaResInvalidCharacters) { errors.Add(new ResourceError(ValidationErrors.ResInvalidName, citem.Key, "Illegal characters found in resource name.", ServerDbs.CItems, this, null)); } } else { _resource(citem, ResourceType.Unidentified, unresource, processed, errors); } } foreach (var item in itemDb.FastItems) { AProgress.IsCancelling(this); Progress = (float)current / totalEntries * 100f; current++; var citem = citemDb.TryGetTuple(item.Key); if (citem == null) { if (SdeAppConfiguration.VaResClientItemMissing) { errors.Add(new ResourceError(ValidationErrors.ResClientMissing, item.Key, "Client Items: " + item.Key + " missing", ServerDbs.Items, this, null)); } continue; } if (SdeAppConfiguration.VaResHeadgear) { var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(HeadgearPreview)); foreach (var sprite in sprites) { _checkResource(sprite, errors, item, processed, ValidationErrors.ResHeadgear, "Headgear", ServerDbs.Items); } } if (SdeAppConfiguration.VaResShield) { var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(ShieldPreview)); foreach (var sprite in sprites) { _checkResource(sprite, errors, item, processed, ValidationErrors.ResShield, "Shield", ServerDbs.Items); } } if (SdeAppConfiguration.VaResWeapon) { var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(WeaponPreview)); foreach (var sprite in sprites) { _checkResource(sprite, errors, item, processed, ValidationErrors.ResWeapon, "Weapon", ServerDbs.Items); } } if (SdeAppConfiguration.VaResGarment) { var sprites = _helper.TestItem(item, _database.MetaGrf, typeof(GarmentPreview)); foreach (var sprite in sprites) { _checkResource(sprite, errors, item, processed, ValidationErrors.ResGarment, "Garment", ServerDbs.Items); } } } if (SdeAppConfiguration.VaResNpc) { NpcPreview preview = new NpcPreview(); foreach (var id in npcsIds.OrderBy(p => p.Key)) { AProgress.IsCancelling(this); Progress = (float)current / totalEntries * 100f; current++; _helper.ViewId = id.Key; preview.Read(null, _helper, new List <Job>()); var sprite = preview.GetSpriteFromJob(null, _helper); _checkResource(sprite, errors, id.Key, processed, ValidationErrors.ResNpc, "NPC", ServerDbs.Zero); if (!sprite.EndsWith(".gr2", StringComparison.OrdinalIgnoreCase)) { _checkResource(sprite.ReplaceExtension(".spr"), errors, id.Key, processed, ValidationErrors.ResNpc, "NPC", ServerDbs.Zero); } } } }
private void _updateViewShop() { try { var viewIds = _primaryShop.NpcViewId; var shopLocation = _primaryShop.ShopLocation; var locations = shopLocation.Split(','); int dir = 0; int viewId = -1; if (locations.Length == 4) { Int32.TryParse(locations[3], out dir); } if (viewIds == "-1") { } else { if (!Int32.TryParse(viewIds, out viewId)) { // Constant var constDb = SdeEditor.Instance.ProjectDatabase.GetDb <string>(ServerDbs.Constants); var tuple = constDb.Table.TryGetTuple(viewIds); if (tuple != null) { viewId = tuple.GetValue <int>(ServerConstantsAttributes.Value); } else { viewId = -1; } } } if (viewId < 0) { _act = null; } else { NpcPreview preview = new NpcPreview(); _helper.ViewId = viewId; preview.Read(null, _helper, new List <Job>()); var sprite = preview.GetSpriteFromJob(null, _helper); if (sprite.EndsWith(".act")) { var actData = SdeEditor.Instance.ProjectDatabase.MetaGrf.GetData(sprite); var sprData = SdeEditor.Instance.ProjectDatabase.MetaGrf.GetData(sprite.ReplaceExtension(".spr")); if (actData != null && sprData != null) { _act = new Act(actData, sprData); } else { _act = null; } } else { _act = null; } } _actIndexSelected.Load(_act); _actIndexSelected.Update(); _actIndexSelected.SetAction(_convertAction(dir)); _frameViewer.Update(); } catch { //ErrorHandler.HandleException(err); } }