示例#1
0
        public void UpdateValues(VehicleScheduleData data, RootTask _)
        {
            if (data != _scheduleData)
            {
                throw new ArgumentException("Schedule data is not for this ScheduleTotalIndicator");
            }

            Locale locale = LazyManager <LocaleManager> .Current.Locale;
            IReadOnlyDictionary <Item, TransferData> routeTotalTransfers = null;

            if (_capacityIndicator != null)
            {
                _lastTotalTransfers = data.Capacity.GetTotalTransfers();
                routeTotalTransfers = RouteTotalTransfers;
            }
            int itemsLimit = routeTotalTransfers != null ? 7 : 10;

            _lastTransfersPerStation = null;
            _lastMonthMultiplier     = data.ScheduleMonthlyMultiplier;
            _lastTotalTime           = data.ScheduleAvereageDuration;
            _lastInaccurate          = _lastTotalTime is { Estimated : true };
            _lastInaccurate          = false;
            if (_text != null)
            {
                itemsLimit = routeTotalTransfers != null ? 3 : 5;
                if (_lastTotalTime != null)
                {
                    _lastInaccurate = _lastTotalTime.Estimated;
                    _text.text      = locale.GetString("schedule_stopwatch/days_hours").Format(((int)_lastTotalTime.Duration.TotalDays).ToString("N0"), _lastTotalTime.Duration.Hours.ToString("N0"));
                    if (_lastInaccurate)
                    {
                        _text.color = Color.gray;
                    }
                    else
                    {
                        _text.color = Color.black;
                    }
                }
                else
                {
                    _text.text = locale.GetString("schedule_stopwatch/unknown").ToUpper();
                }
            }

            if (_capacityIndicator != null)
            {
                _lastTotalTransfers = data.Capacity.GetTotalTransfers();
                _capacityIndicator.UpdateItems(_lastTotalTransfers, _lastMonthMultiplier, routeTotalTransfers, itemsLimit: itemsLimit, transfDirection: TransferDirection.unloading);
            }
        }
示例#2
0
        public static string GetCapacityTooltipText(float?monthMultiplier, IReadOnlyDictionary <Item, TransferData> totalTransfers, TransfersPerStationCont transfPerSt, bool isInaccurate, IReadOnlyDictionary <Item, TransferData> routeTotalTransfers = null, TransfersPerStationCont routeTransfPerStation = null)
        {
            Locale locale = LazyManager <LocaleManager> .Current.Locale;

            if (monthMultiplier != null && ((totalTransfers != null && totalTransfers.Count > 0) || (transfPerSt != null && transfPerSt.Count > 0)))
            {
                bool          isRoute = routeTotalTransfers != null && routeTotalTransfers.Count > 0;
                StringBuilder sb      = new StringBuilder();
                sb.Append(StringHelper.Boldify(locale.GetString("schedule_stopwatch/estim_monthly_transf").ToUpper()));
                if (isRoute)
                {
                    sb.AppendLine().Append(StringHelper.Colorify(locale.GetString("schedule_stopwatch/estim_monthly_transf_hint"), UIColors.Solid.Text * 0.5f));
                }
                if (isInaccurate)
                {
                    sb.AppendLine().Append(StringHelper.Colorify(locale.GetString("schedule_stopwatch/inaccurate"), UIColors.Solid.Text * 0.5f));
                }
                if (transfPerSt != null && transfPerSt.Count > 0)
                {
                    foreach (KeyValuePair <VehicleStationLocation, IReadOnlyDictionary <Item, TransferData> > pair in transfPerSt)
                    {
                        StringBuilder stationSb   = new StringBuilder();
                        string        stationName = StringHelper.Boldify(pair.Key.Name);
                        stationSb.Append(stationName);
                        IReadOnlyDictionary <Item, TransferData> routeTransfers = routeTransfPerStation?[pair.Key];

                        if (TooltipTextForStation(pair.Value, stationSb, routeTransfers, monthMultiplier.Value))
                        {
                            sb.AppendLine().AppendLine().Append(stationSb.ToString());
                        }
                    }
                }
                if (totalTransfers != null && totalTransfers.Count > 0)
                {
                    sb.AppendLine().AppendLine().Append(StringHelper.Colorify(StringHelper.Boldify(locale.GetString("schedule_stopwatch/total_transfer").ToUpper()), UIColors.Solid.Text * 0.8f));
                    foreach (KeyValuePair <Item, TransferData> transfer in totalTransfers)
                    {
                        string countStr = (transfer.Value.unload * monthMultiplier.Value).ToString("N0");
                        if (isRoute && routeTotalTransfers.TryGetValue(transfer.Key, out TransferData routeCount))
                        {
                            countStr += "/" + routeCount.unload.ToString();
                        }
                        sb.AppendLine().Append(StringHelper.FormatCountString(transfer.Key.DisplayName, countStr));
                    }
                }
                return(sb.ToString());
            }
            return("");
        }