Exemplo n.º 1
0
        private UITextureAtlas CreateAtlasEntry <T>(Dictionary <T, UITextureAtlas> atlasDic, T atlasName, string path, bool addPrefix)
        {
            UITextureAtlas targetAtlas = ScriptableObject.CreateInstance <UITextureAtlas>();

            targetAtlas.material = new Material(WTSController.DEFAULT_SHADER_TEXT);
            WTSAtlasLoadingUtils.LoadAllImagesFromFolder(path, out List <SpriteInfo> spritesToAdd, out List <string> errors, addPrefix);
            TextureAtlasUtils.RegenerateTextureAtlas(targetAtlas, spritesToAdd);
            foreach (string error in errors)
            {
                LogUtils.DoErrorLog($"ERROR LOADING IMAGE: {error}");
            }
            atlasDic[atlasName] = targetAtlas;
            return(targetAtlas);
        }
Exemplo n.º 2
0
        protected override void OnLevelLoadingInternal()
        {
            if (!ZMController.m_ghostMode)
            {
                ZoneManager.instance.m_properties.m_zoneColors      = new Color[0x10].Select((x, i) => ZoneManager.instance.m_properties.m_zoneColors.ElementAtOrDefault(i)).ToArray();
                ZoneManager.instance.m_properties.m_zoneColors[0x8] = new Color32(0x99, 0x20, 0x21, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0x9] = new Color32(0xcc, 0x40, 0x41, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0xA] = new Color32(0x00, 0xFF, 0x00, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0xB] = new Color32(0xFF, 0x00, 0xFF, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0xC] = new Color32(0x00, 0xFF, 0xFF, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0xD] = new Color32(0x88, 0x88, 0x88, 0xff);
                ZoneManager.instance.m_properties.m_zoneColors[0xE] = new Color32(0xFF, 0xFF, 0x00, 0xff);
                ZoneManager.instance.m_zoneNotUsed   = new ZoneTypeGuide[0x10].Select((x, i) => ZoneManager.instance.m_zoneNotUsed.ElementAtOrDefault(i) ?? new ZoneTypeGuide()).ToArray();
                ZoneManager.instance.m_goodAreaFound = new short[0x10].Select((x, i) => ZoneManager.instance.m_goodAreaFound.ElementAtOrDefault(i)).ToArray();
                typeof(ZoneProperties).GetMethod("InitializeProperties", RedirectorUtils.allFlags).Invoke(ZoneManager.instance.m_properties, new object[0]);


                var newSprites = new List <SpriteInfo>();
                TextureAtlasUtils.LoadImagesFromResources("UI.Images.InfoTooltip", ref newSprites);
                TextureAtlasUtils.RegenerateTextureAtlas(GeneratedScrollPanel.tooltipBox.Find <UISprite>("Sprite").atlas, newSprites);
            }
        }
Exemplo n.º 3
0
        public void LoadImagesFromLocalFolders()
        {
            LocalAtlases.Clear();
            var errors = new List <string>();
            var folders = new string[] { WTSController.ExtraSpritesFolder }.Concat(Directory.GetDirectories(WTSController.ExtraSpritesFolder));

            foreach (var dir in folders)
            {
                bool isRoot       = dir == WTSController.ExtraSpritesFolder;
                var  spritesToAdd = new List <SpriteInfo>();
                WTSAtlasLoadingUtils.LoadAllImagesFromFolderRef(dir, ref spritesToAdd, ref errors, isRoot);
                if (isRoot || spritesToAdd.Count > 0)
                {
                    var atlasName = isRoot ? string.Empty : Path.GetFileNameWithoutExtension(dir);
                    LocalAtlases[atlasName] = new UITextureAtlas
                    {
                        material = new Material(UIView.GetAView().defaultAtlas.material.shader)
                    };
                    if (isRoot)
                    {
                        spritesToAdd.AddRange(UIView.GetAView().defaultAtlas.sprites.Select(x => CloneSpriteInfo(x)).ToList());
                        TextureAtlasUtils.LoadImagesFromResources("commons.UI.Images", ref spritesToAdd);
                        TextureAtlasUtils.LoadImagesFromResources("UI.Images", ref spritesToAdd);
                    }
                    TextureAtlasUtils.RegenerateTextureAtlas(LocalAtlases[atlasName], spritesToAdd);
                }
            }
            LocalAtlasesCache.Clear();
            LocalRenderMaterial.Clear();
            if (errors.Count > 0)
            {
                K45DialogControl.ShowModal(new K45DialogControl.BindProperties
                {
                    message = $"{Locale.Get("K45_WTS_CUSTOMSPRITE_ERRORHEADER")}:\n\t{string.Join("\n\t", errors.ToArray())}"
                }, (x) => true);
            }
        }
Exemplo n.º 4
0
        private IEnumerator WriteHwShieldTextureCoroutine(ushort seedId)
        {
            string id = $"{seedId}";

            if (m_hwShieldsAtlas[id] is null)
            {
                yield return(0);

                while (!CheckHwShieldCoroutineCanContinue())
                {
                    yield return(null);
                }
                var hwData = WriteTheSignsMod.Controller.ConnectorADR.GetHighwayData(seedId);
                if (hwData is null)
                {
                    yield break;
                }
                WTSHighwayShieldsSingleton.GetTargetDescriptor(hwData.layoutName ?? "", out ConfigurationSource src, out HighwayShieldDescriptor layoutDescriptor);
                if (src == ConfigurationSource.NONE)
                {
                    yield break;
                }

                var drawingCoroutine = CoroutineWithData.From(this, RenderHighwayShield(
                                                                  FontServer.instance[layoutDescriptor.FontName] ?? FontServer.instance[WTSEtcData.Instance.FontSettings.HighwayShieldsFont] ?? FontServer.instance[WTSController.DEFAULT_FONT_KEY],
                                                                  layoutDescriptor, hwData));
                yield return(drawingCoroutine.Coroutine);

                while (!CheckHwShieldCoroutineCanContinue())
                {
                    yield return(null);
                }
                TextureAtlasUtils.RegenerateTextureAtlas(m_hwShieldsAtlas, new List <UITextureAtlas.SpriteInfo>
                {
                    new UITextureAtlas.SpriteInfo
                    {
                        name    = id,
                        texture = drawingCoroutine.result
                    }
                });
                HwShieldIsDirty     = true;
                m_hwShieldsMaterial = null;
                HighwayShieldsCache.Clear();
                StopAllCoroutines();
                yield break;
            }
            yield return(0);

            var bri = new BasicRenderInformation
            {
                m_YAxisOverflows = new RangeVector {
                    min = 0, max = 20
                },
            };

            yield return(0);

            WTSAtlasesLibrary.BuildMeshFromAtlas(id, bri, m_hwShieldsAtlas);
            yield return(0);

            if (m_hwShieldsMaterial is null)
            {
                m_hwShieldsMaterial = new Material(m_hwShieldsAtlas.material)
                {
                    shader = WTSController.DEFAULT_SHADER_TEXT,
                };
            }
            WTSAtlasesLibrary.RegisterMeshSingle(seedId, bri, HighwayShieldsCache, m_hwShieldsAtlas, HwShieldIsDirty, m_hwShieldsMaterial);
            HwShieldIsDirty = false;
            yield break;
        }