public Color AutoColor(ushort i, bool ignoreRandomIfSet = true, bool ignoreAnyIfSet = false)
        {
            TransportLine t = tm.m_lines.m_buffer[(int)i];

            try
            {
                var tsd = TransportSystemDefinition.getDefinitionForLine(i);
                if (tsd == default(TransportSystemDefinition) || (((t.m_flags & TransportLine.Flags.CustomColor) > 0) && ignoreAnyIfSet))
                {
                    return(Color.clear);
                }
                TLMCW.ConfigIndex transportType = tsd.toConfigIndex();
                Color             c             = TLMUtils.CalculateAutoColor(t.m_lineNumber, transportType, ((t.m_flags & TransportLine.Flags.CustomColor) > 0) && ignoreRandomIfSet, true);
                if (c.a == 1)
                {
                    TLMLineUtils.setLineColor(i, c);
                }
                //TLMUtils.doLog("Colocada a cor {0} na linha {1} ({3} {2})", c, i, t.m_lineNumber, t.Info.m_transportType);
                return(c);
            }
            catch (Exception e)
            {
                TLMUtils.doErrorLog("ERRO!!!!! " + e.Message);
                TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false);
                return(Color.clear);
            }
        }
Esempio n. 2
0
        public Color AutoColor(ushort i)
        {
            TransportLine t = tm.m_lines.m_buffer[(int)i];

            try
            {
                var tsd = TLMCW.getDefinitionForLine(i);
                if (tsd == default(TransportSystemDefinition))
                {
                    return(Color.clear);
                }
                TLMCW.ConfigIndex transportType = tsd.toConfigIndex();
                Color             c             = TLMUtils.CalculateAutoColor(t.m_lineNumber, transportType);
                TLMLineUtils.setLineColor(i, c);
                //TLMUtils.doLog("Colocada a cor {0} na linha {1} ({3} {2})", c, i, t.m_lineNumber, t.Info.m_transportType);
                return(c);
            }
            catch (Exception e)
            {
                TLMUtils.doErrorLog("ERRO!!!!! " + e.Message);
                TLMCW.setCurrentConfigBool(TLMCW.ConfigIndex.AUTO_COLOR_ENABLED, false);
                return(Color.clear);
            }
        }
        private void updateUI(bool syncFromInput = false)
        {
            TransportSystemDefinition tsd = TransportSystemDefinition.from(transportTool.m_prefab);

            TLMLineUtils.GetNamingRulesFromTSD(out ModoNomenclatura prefixo, out Separador sep, out ModoNomenclatura sufixo, out ModoNomenclatura nonPrefix, out bool zeros, out bool invertPrefixSuffix, tsd);

            if (syncFromInput)
            {
                String value      = "0" + lineNumberTxtBox.text;
                int    valPrefixo = linePrefixDropDown.selectedIndex;

                ushort num = ushort.Parse(value);
                if (prefixo != ModoNomenclatura.Nenhum)
                {
                    num = (ushort)(valPrefixo * 1000 + (num % 1000));
                }
                if (nextLineNumber + 1 != num)
                {
                    nextLineNumber = (ushort)(num - 1);
                }
            }


            var   configIdx = tsd.toConfigIndex();
            Color color;

            if (TLMConfigWarehouse.getCurrentConfigBool(TLMConfigWarehouse.ConfigIndex.AUTO_COLOR_ENABLED))
            {
                color = TLMUtils.CalculateAutoColor((ushort)(nextLineNumber + 1), TLMConfigWarehouse.getConfigIndexForTransportInfo(transportTool.m_prefab), true);
            }
            else
            {
                color = TLMConfigWarehouse.getColorForTransportType(configIdx);
            }

            lineNumberTxtBox.color      = color;
            lineFormat.color            = color;
            lineFormat.backgroundSprite = TLMLineUtils.GetIconForIndex(configIdx);
            lineNumber.text             = TLMUtils.getString(prefixo, sep, sufixo, nonPrefix, (nextLineNumber + 1) & 0xFFFF, zeros, invertPrefixSuffix);
            lineNumber.textColor        = TLMUtils.contrastColor(color);
            int txtLen = lineNumber.text.Length;

            switch (txtLen)
            {
            case 1:
                lineNumber.textScale = 4;
                break;

            case 2:
                lineNumber.textScale = 3;
                break;

            case 3:
                lineNumber.textScale = 2.25f;
                break;

            case 4:
                lineNumber.textScale = 1.75f;
                break;

            case 5:
                lineNumber.textScale = 1.5f;
                break;

            case 6:
                lineNumber.textScale = 1.35f;
                break;

            case 7:
                lineNumber.textScale = 1.2f;
                break;

            case 8:
                lineNumber.textScale = 1.1f;
                break;

            default:
                lineNumber.textScale = 1f;
                break;
            }
        }