private static void load()
        {
            string serializedInfo = TLMSingleton.savedPalettes.value;

            if (TLMSingleton.instance != null && TLMSingleton.debugMode)
            {
                TLMUtils.doLog("Loading palettes - separator: {1} ; save Value: {0}", serializedInfo, SERIALIZER_ITEM_SEPARATOR);
            }
            string[] items = serializedInfo.Split(SERIALIZER_ITEM_SEPARATOR);
            foreach (string item in items)
            {
                if (TLMSingleton.instance != null && TLMSingleton.debugMode)
                {
                    TLMUtils.doLog("Loading palette {0}", items);
                }
                AutoColorPalette acp = AutoColorPalette.parseFromString(item);
                if (acp != null)
                {
                    m_palettes.Add(acp.name, acp);
                }
            }
            foreach (AutoColorPalette p in defaultPaletteArray)
            {
                m_palettes[p.name] = p;
            }
        }
Ejemplo n.º 2
0
        private static bool LoadLegacy(SavedString oldFile)
        {
            string serializedInfo = oldFile.value;

            if (!string.IsNullOrEmpty(serializedInfo))
            {
                TLMUtils.doLog("Loading palettes - separator: {1} ; save Value: {0}", serializedInfo, SERIALIZER_ITEM_SEPARATOR);
                string[] items = serializedInfo.Split(SERIALIZER_ITEM_SEPARATOR);
                foreach (string item in items)
                {
                    TLMUtils.doLog("Loading palette {0}", items);
                    AutoColorPalette acp = AutoColorPalette.parseFromString_Legacy(item);
                    if (acp != null)
                    {
                        m_palettes.Add(acp.name, acp);
                    }
                }
            }
            else
            {
                return(false);
            }
            foreach (AutoColorPalette p in defaultPaletteArray)
            {
                m_palettes[p.name] = p;
            }
            return(true);
        }
 public static List <Color32> getColors(string paletteName)
 {
     if (m_palettes.ContainsKey(paletteName))
     {
         AutoColorPalette palette = m_palettes[paletteName];
         var saida = palette.colors.GetRange(1, palette.colors.Count - 1).ToList();
         saida.Add(palette[0]);
         return(saida);
     }
     return(null);
 }
Ejemplo n.º 4
0
 private static void Load()
 {
     m_palettes = new Dictionary <string, AutoColorPalette>();
     foreach (var filename in Directory.GetFiles(TLMController.palettesFolder, "*" + EXT_PALETTE).Select(x => x.Split(Path.DirectorySeparatorChar).Last()))
     {
         string fileContents = File.ReadAllText(TLMController.palettesFolder + Path.DirectorySeparatorChar + filename, Encoding.UTF8);
         var    name         = filename.Substring(0, filename.Length - 4);
         m_palettes[name] = AutoColorPalette.FromFileContent(name, fileContents.Split(AutoColorPalette.ENTRY_SEPARATOR).Select(x => x?.Trim()).Where(x => !string.IsNullOrEmpty(x)).ToArray());
         TLMUtils.doLog("LOADED PALETTE ({0}) QTT: {1}", filename, m_palettes[name].Count);
     }
 }
 public static void setColor(int number, string paletteName, Color newColor)
 {
     if (m_palettes.ContainsKey(paletteName))
     {
         AutoColorPalette palette = m_palettes[paletteName];
         if (number <= palette.Count && number > 0)
         {
             palette[number % palette.Count] = newColor;
             save();
         }
     }
 }
Ejemplo n.º 6
0
 public static Color32 getColor(int number, string paletteName, bool randomOnPaletteOverflow)
 {
     if (m_palettes.ContainsKey(paletteName))
     {
         AutoColorPalette palette = m_palettes[paletteName];
         if (!randomOnPaletteOverflow || number <= palette.colors.Count)
         {
             return(palette[number % palette.Count]);
         }
     }
     return(gen.GetNext());
 }
        public static string addPalette()
        {
            int    id   = 0;
            string name = "New Palette";

            if (m_palettes.ContainsKey(name))
            {
                while (m_palettes.ContainsKey(name + id))
                {
                    id++;
                }
                name = name + id;
            }

            m_palettes[name] = new AutoColorPalette(name, new Color32[] { Color.white }.ToList());
            save();
            return(name);
        }
Ejemplo n.º 8
0
 public static Color32 getColor(int number, string[] paletteOrderSearch, bool randomOnPaletteOverflow, bool avoidRandom = false)
 {
     foreach (var paletteName in paletteOrderSearch)
     {
         if (m_palettes.ContainsKey(paletteName))
         {
             AutoColorPalette palette = m_palettes[paletteName];
             if (!randomOnPaletteOverflow || number <= palette.colors.Count)
             {
                 return(palette[number % palette.Count]);
             }
         }
     }
     if (avoidRandom)
     {
         return(Color.clear);
     }
     else
     {
         return(gen.GetNext());
     }
 }
Ejemplo n.º 9
0
        private static void load()
        {
            string serializedInfo = TransportLinesManagerMod.savedPalettes.value;

            if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
            {
                TLMUtils.doLog("Loading palettes - separator: {1} ; save Value: {0}", serializedInfo, SERIALIZER_ITEM_SEPARATOR);
            }
            string[] items = serializedInfo.Split(SERIALIZER_ITEM_SEPARATOR);
            foreach (string item in items)
            {
                if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode)
                {
                    TLMUtils.doLog("Loading palette {0}", items);
                }
                AutoColorPalette acp = AutoColorPalette.parseFromString(item);
                if (acp != null)
                {
                    m_palettes.Add(acp.name, acp);
                }
            }
            m_palettes["São Paulo 2035"] = new AutoColorPalette("São Paulo 2035", SaoPaulo2035);
            m_palettes["London 2016"]    = new AutoColorPalette("London 2016", London2016);
        }