Esempio n. 1
0
        private void updateSliders()
        {
            if (TLMSingleton.isIPTLoaded)
            {
                m_lineBudgetSlidersTitle.parent.isVisible = false;
                return;
            }


            TLMConfigWarehouse.ConfigIndex transportType = tsd.toConfigIndex();
            ModoNomenclatura mnPrefixo = (ModoNomenclatura)TLMConfigWarehouse.getCurrentConfigInt(TLMConfigWarehouse.ConfigIndex.PREFIX | transportType);

            uint[] multipliers;
            IBudgetableExtension bte;
            uint idx;

            var tsdRef = tsd;

            idx         = (uint)SelectedPrefix;
            bte         = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
            multipliers = bte.GetBudgetsMultiplier(idx);

            m_lineBudgetSlidersTitle.text = string.Format(Locale.Get("TLM_BUDGET_MULTIPLIER_TITLE_PREFIX"), idx > 0 ? TLMUtils.getStringFromNumber(TLMUtils.getStringOptionsForPrefix(mnPrefixo), (int)idx + 1) : Locale.Get("TLM_UNPREFIXED"), TLMConfigWarehouse.getNameForTransportType(tsdRef.toConfigIndex()));


            bool budgetPerHourEnabled = multipliers.Length == 8;

            m_disableBudgetPerHour.isVisible = budgetPerHourEnabled;
            m_enableBudgetPerHour.isVisible  = !budgetPerHourEnabled && tsdRef.hasVehicles();
            for (int i = 0; i < m_budgetSliders.Length; i++)
            {
                UILabel budgetSliderLabel = m_budgetSliders[i].transform.parent.GetComponentInChildren <UILabel>();
                if (i == 0)
                {
                    if (multipliers.Length == 1)
                    {
                        budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL_ALL");
                    }
                    else
                    {
                        budgetSliderLabel.prefix = Locale.Get("TLM_BUDGET_MULTIPLIER_PERIOD_LABEL", 0);
                    }
                }
                else
                {
                    m_budgetSliders[i].isEnabled        = budgetPerHourEnabled;
                    m_budgetSliders[i].parent.isVisible = budgetPerHourEnabled;
                }

                if (i < multipliers.Length)
                {
                    m_budgetSliders[i].value = multipliers[i] / 100f;
                }
            }
        }
Esempio n. 2
0
        private void setBudgetHour(float x, int selectedHourIndex)
        {
            if (!isChanging && m_prefixSelector.selectedIndex >= 0)
            {
                uint   idx = (uint)SelectedPrefix;
                ushort val = (ushort)(x * 100 + 0.5f);
                IBudgetableExtension bte;
                uint[] saveData;

                var tsdRef = tsd;
                bte      = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
                saveData = bte.GetBudgetsMultiplier(idx);
                if (selectedHourIndex >= saveData.Length || saveData[selectedHourIndex] == val)
                {
                    return;
                }
                saveData[selectedHourIndex] = val;
                bte.SetBudgetMultiplier(idx, saveData);
            }
        }
Esempio n. 3
0
        private void CreateToggleBudgetButtons(UIPanel reference)
        {
            TLMUtils.createUIElement(out m_enableBudgetPerHour, reference.transform);
            m_enableBudgetPerHour.relativePosition = new Vector3(reference.width - 65f, 0f);
            m_enableBudgetPerHour.textScale        = 0.6f;
            m_enableBudgetPerHour.width            = 40;
            m_enableBudgetPerHour.height           = 40;
            m_enableBudgetPerHour.tooltip          = Locale.Get("TLM_USE_PER_PERIOD_BUDGET");
            TLMUtils.initButton(m_enableBudgetPerHour, true, "ButtonMenu");
            m_enableBudgetPerHour.name        = "EnableBudgetPerHour";
            m_enableBudgetPerHour.isVisible   = true;
            m_enableBudgetPerHour.eventClick += (component, eventParam) =>
            {
                IBudgetableExtension bte;
                uint idx;
                var  tsdRef = tsd;
                bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
                idx = (uint)SelectedPrefix;

                uint[] saveData    = bte.GetBudgetsMultiplier(idx);
                uint[] newSaveData = new uint[8];
                for (int i = 0; i < 8; i++)
                {
                    newSaveData[i] = saveData[0];
                }
                bte.SetBudgetMultiplier(idx, newSaveData);
                updateSliders();
            };

            var icon = m_enableBudgetPerHour.AddUIComponent <UISprite>();

            icon.relativePosition = new Vector3(2, 2);
            icon.atlas            = TLMController.taTLM;
            icon.width            = 36;
            icon.height           = 36;
            icon.spriteName       = "PerHourIcon";


            TLMUtils.createUIElement(out m_disableBudgetPerHour, reference.transform);
            m_disableBudgetPerHour.relativePosition = new Vector3(reference.width - 65f, 0f);
            m_disableBudgetPerHour.textScale        = 0.6f;
            m_disableBudgetPerHour.width            = 40;
            m_disableBudgetPerHour.height           = 40;
            m_disableBudgetPerHour.tooltip          = Locale.Get("TLM_USE_SINGLE_BUDGET");
            TLMUtils.initButton(m_disableBudgetPerHour, true, "ButtonMenu");
            m_disableBudgetPerHour.name        = "DisableBudgetPerHour";
            m_disableBudgetPerHour.isVisible   = true;
            m_disableBudgetPerHour.eventClick += (component, eventParam) =>
            {
                IBudgetableExtension bte;
                uint idx;
                var  tsdRef = tsd;
                bte = TLMLineUtils.getExtensionFromTransportSystemDefinition(ref tsdRef);
                idx = (uint)SelectedPrefix;

                uint[] saveData    = bte.GetBudgetsMultiplier(idx);
                uint[] newSaveData = new uint[] { saveData[0] };
                bte.SetBudgetMultiplier(idx, newSaveData);

                updateSliders();
            };

            icon = m_disableBudgetPerHour.AddUIComponent <UISprite>();
            icon.relativePosition = new Vector3(2, 2);
            icon.atlas            = TLMController.taTLM;
            icon.width            = 36;
            icon.height           = 36;
            icon.spriteName       = "24hLineIcon";
        }