Exemplo n.º 1
0
        private void DoWithSettingsUI(UIHelperExtension helper)
        {
            foreach (Transform child in helper.Self?.transform)
            {
                GameObject.Destroy(child?.gameObject);
            }

            var newSprites = new List <SpriteInfo>();

            TextureAtlasUtils.LoadImagesFromResources("commons.UI.Images", ref newSprites);
            TextureAtlasUtils.LoadImagesFromResources("UI.Images", ref newSprites);
            LogUtils.DoLog($"ADDING {newSprites.Count} sprites!");
            TextureAtlasUtils.RegenerateDefaultTextureAtlas(newSprites);


            helper.Self.eventVisibilityChanged += delegate(UIComponent component, bool b)
            {
                if (b)
                {
                    ShowVersionInfoPopup();
                }
            };

            TopSettingsUI(helper);

            if (UseGroup9)
            {
                CreateGroup9(helper);
            }

            ShowVersionInfoPopup();
            SearchIncompatibilitiesModal();
            LogUtils.DoLog("End Loading Options");
        }
Exemplo n.º 2
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);
        }
        /// <param name="theme">         an input theme containing valid render theme XML data. </param>
        /// <param name="themeCallback"> the theme callback. </param>
        /// <returns> a new RenderTheme which is created by parsing the XML data from the input theme. </returns>
        /// <exception cref="ThemeException"> if an error occurs while parsing the render theme XML. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback) throws org.oscim.theme.IRenderTheme.ThemeException
        public static IRenderTheme read(ThemeFile theme, ThemeCallback themeCallback)
        {
            IDictionary <object, TextureRegion> outputMap    = new Dictionary <object, TextureRegion>();
            IList <TextureAtlas>          atlasList          = new List <TextureAtlas>();
            XmlMapsforgeAtlasThemeBuilder renderThemeHandler = new XmlMapsforgeAtlasThemeBuilder(theme, themeCallback, outputMap, atlasList);

            try
            {
                (new XMLReaderAdapter()).parse(renderThemeHandler, theme.RenderThemeAsStream);
            }
            catch (Exception e)
            {
                throw new ThemeException(e.Message);
            }

            TextureAtlasUtils.createTextureRegions(renderThemeHandler.bitmapMap, outputMap, atlasList, true, CanvasAdapter.platform == Platform.IOS);

            return(replaceThemeSymbols(renderThemeHandler.mRenderTheme, outputMap));
        }
Exemplo n.º 4
0
        private void ScanImagesForTextureAtlas()
        {
            var newSprites = new List <SpriteInfo>();

            FileUtils.ScanPrefabsFoldersDirectoryNoLoad("kf_imageFiles", (path, pack, asset) =>
            {
                try
                {
                    TextureAtlasUtils.LoadPathTexturesIntoInGameTextureAtlas($"PACK.{(asset.isWorkshopAsset ? $"{(pack.GetPublishedFileID().AsUInt64).ToString("00000000000000000")}" : asset.name)}", path, ref newSprites);
                }
                catch (Exception e)
                {
                    LogUtils.DoErrorLog($"An error occurred trying to load path \"{path}\": {e.GetType()} => {e.Message}");
                }
            });
            FileUtils.EnsureFolderCreation(m_localImageFilesPath);
            TextureAtlasUtils.LoadPathTexturesIntoInGameTextureAtlas($"KF_LOCAL", m_localImageFilesPath, ref newSprites);
            if (newSprites.Count > 0)
            {
                TextureAtlasUtils.RegenerateDefaultTextureAtlas(newSprites);
            }
        }
Exemplo n.º 5
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.º 6
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.º 7
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;
        }