private void LoadImagesFromPrefab(ulong workshopId, string directoryPath, PrefabInfo info) { if (workshopId > 0 && workshopId != ~0UL && !AssetAtlases.ContainsKey(workshopId)) { CreateAtlasEntry(AssetAtlases, workshopId, directoryPath, false); } }
public void GetAtlas(string atlasName, out UITextureAtlas result) { if (!LocalAtlases.TryGetValue(atlasName ?? string.Empty, out result) && ulong.TryParse(atlasName ?? string.Empty, out ulong workshopId)) { AssetAtlases.TryGetValue(workshopId, out result); } }
internal string[] OnFilterParamImagesAndFoldersByText(UISprite sprite, string inputText, string propName, out string protocolFound) { Match match; if ((inputText?.Length ?? 0) >= 4 && (match = Regex.Match(inputText ?? "", $"^({PROTOCOL_IMAGE}|{PROTOCOL_IMAGE_ASSET}|{PROTOCOL_FOLDER}|{PROTOCOL_FOLDER_ASSET})(([^/]+)/)?(.*)$")).Success) { protocolFound = match.Groups[1].Value; var subfolder = match.Groups[3].Value; var searchName = match.Groups[4].Value; string[] results; UITextureAtlas atlas; switch (protocolFound) { default: case PROTOCOL_IMAGE: results = (subfolder.IsNullOrWhiteSpace() ? WriteTheSignsMod.Controller.AtlasesLibrary.FindByInLocalFolders(searchName).Select(x => $"{x}/") : new List <string>()).Concat(WriteTheSignsMod.Controller.AtlasesLibrary.FindByInLocal(subfolder == "<ROOT>" ? null : subfolder, searchName, out atlas)).ToArray(); break; case PROTOCOL_IMAGE_ASSET: results = WriteTheSignsMod.Controller.AtlasesLibrary.FindByInAsset(ulong.TryParse(propName?.Split('.')[0] ?? "", out ulong wId) ? wId : 0u, searchName, out atlas, true); break; case PROTOCOL_FOLDER: results = WriteTheSignsMod.Controller.AtlasesLibrary.FindByInLocalFolders(searchName); atlas = null; break; case PROTOCOL_FOLDER_ASSET: results = AssetAtlases.TryGetValue(ulong.TryParse(propName?.Split('.')[0] ?? "", out wId) ? wId : 0, out atlas) ? new string[] { "<ROOT>" } : new string[0]; break; } sprite.atlas = atlas; return(results); } else { protocolFound = null; return(null); } }
public BasicRenderInformation GetFromAssetAtlases(ulong assetId, string spriteName, bool fallbackOnInvalid = false) { if (spriteName.IsNullOrWhiteSpace() || !AssetAtlases.ContainsKey(assetId)) { return(null); } if (AssetAtlasesCache.TryGetValue(assetId, out Dictionary <string, BasicRenderInformation> resultDicCache) && resultDicCache.TryGetValue(spriteName ?? "", out BasicRenderInformation cachedInfo)) { return(cachedInfo); } if (!AssetAtlases.TryGetValue(assetId, out UITextureAtlas atlas) || !atlas.spriteNames.Contains(spriteName)) { return(fallbackOnInvalid ? GetFromLocalAtlases(null, "K45_WTS FrameParamsInvalidImageAsset") : null); } if (resultDicCache == null) { AssetAtlasesCache[assetId] = new Dictionary <string, BasicRenderInformation>(); } AssetAtlasesCache[assetId][spriteName] = null; StartCoroutine(CreateItemAtlasCoroutine(AssetAtlases, AssetRenderMaterial, AssetAtlasesCache, assetId, spriteName)); return(null); }
public bool HasAtlas(ulong workshopId) => AssetAtlases.TryGetValue(workshopId, out _);
public string[] GetSpritesFromAssetAtlas(ulong workshopId) => AssetAtlases.TryGetValue(workshopId, out UITextureAtlas atlas) ? atlas.spriteNames : null;
internal string[] FindByInAssetSimple(ulong assetId, string searchName, out UITextureAtlas atlas) => AssetAtlases.TryGetValue(assetId, out atlas) ? atlas.spriteNames.Where((x, i) => i > 0 && x.ToLower().Contains(searchName.ToLower())).OrderBy(x => x).ToArray() : (new string[0]);
internal string[] FindByInAsset(ulong assetId, string searchName, out UITextureAtlas atlas, bool asRoot = false) => AssetAtlases.TryGetValue(assetId, out atlas) ? atlas.spriteNames.Where((x, i) => i > 0 && x.ToLower().Contains(searchName.ToLower())).Select(x => $"{(asRoot ? "<ROOT>" : assetId.ToString())}/{x}").OrderBy(x => x).ToArray() : (new string[0]);
public BasicRenderInformation GetSlideFromAsset(ulong assetId, Func <int, int> idxFunc, bool fallbackOnInvalid = false) => !AssetAtlases.TryGetValue(assetId, out UITextureAtlas atlas) ? fallbackOnInvalid ? GetFromLocalAtlases(null, "K45_WTS FrameParamsInvalidFolder") : null : GetFromAssetAtlases(assetId, atlas.spriteNames[idxFunc(atlas.spriteNames.Length - 1) + 1], fallbackOnInvalid);