Example #1
0
        /// <summary>
        /// Initializes labels that need only be updated once.
        /// </summary>
        public override void OnSpawn()
        {
            var op = es.overviewPanel;

            base.OnSpawn();
            op.SetActive(true);
            if (op.TryGetComponent(out CollapsibleDetailContentPanel panel))
            {
                var overviewParent = panel.Content.gameObject;
                joulesAvailable = new EnergyInfoLabel(es.labelTemplate, overviewParent,
                                                      nameof(joulesAvailable));
                joulesAvailable.tooltip.toolTip = ENERGYGENERATOR.AVAILABLE_JOULES_TOOLTIP;
                wattageGenerated = new EnergyInfoLabel(es.labelTemplate, overviewParent,
                                                       nameof(wattageGenerated));
                wattageGenerated.tooltip.toolTip = ENERGYGENERATOR.WATTAGE_GENERATED_TOOLTIP;
                wattageConsumed = new EnergyInfoLabel(es.labelTemplate, overviewParent, nameof(
                                                          wattageConsumed));
                wattageConsumed.tooltip.toolTip = ENERGYGENERATOR.WATTAGE_CONSUMED_TOOLTIP;
                potentialWattageConsumed        = new EnergyInfoLabel(es.labelTemplate,
                                                                      overviewParent, nameof(potentialWattageConsumed));
                potentialWattageConsumed.tooltip.toolTip = ENERGYGENERATOR.
                                                           POTENTIAL_WATTAGE_CONSUMED_TOOLTIP;
                maxSafeWattage = new EnergyInfoLabel(es.labelTemplate, overviewParent, nameof(
                                                         maxSafeWattage));
                maxSafeWattage.tooltip.toolTip = ENERGYGENERATOR.MAX_SAFE_WATTAGE_TOOLTIP;
                noCircuit = new EnergyInfoLabel(es.labelTemplate, overviewParent, nameof(
                                                    noCircuit));
                noCircuit.tooltip.toolTip = ENERGYGENERATOR.DISCONNECTED;
            }
            else
            {
                noCircuit = null;
            }
            if (es.generatorsPanel.TryGetComponent(out panel))
            {
                generatorParent = panel.Content.gameObject;
            }
            else
            {
                generatorParent = null;
            }
            if (es.batteriesPanel.TryGetComponent(out panel))
            {
                batteryParent = panel.Content.gameObject;
            }
            else
            {
                batteryParent = null;
            }
            if (es.consumersPanel.TryGetComponent(out panel))
            {
                consumerParent = panel.Content.gameObject;
            }
            else
            {
                consumerParent = null;
            }
            lastSelected = default;
            dirty        = true;
        }
Example #2
0
 public override void OnCleanUp()
 {
     joulesAvailable?.Dispose();
     wattageGenerated?.Dispose();
     wattageConsumed?.Dispose();
     potentialWattageConsumed?.Dispose();
     maxSafeWattage?.Dispose();
     noCircuit?.Dispose();
     noCircuit       = null;
     consumerParent  = null;
     batteryParent   = null;
     generatorParent = null;
     lastSelected    = default;
     foreach (var pair in cache)
     {
         pair.Value.Dispose();
     }
     cache.Clear();
     batteryLabels.Clear();
     consumerLabels.Clear();
     generatorLabels.Clear();
     wasValid = false;
     base.OnCleanUp();
     Instance = null;
 }
Example #3
0
 public void Dispose()
 {
     amountLookup.Clear();
     attributeLookup.Clear();
     lastSelection = default;
     panel         = default;
 }
Example #4
0
 private VitalsPanelWrapper()
 {
     amountLookup    = new Dictionary <string, AmountInstance>(64);
     attributeLookup = new Dictionary <string, AttributeInstance>(64);
     lastSelection   = default;
     panel           = default;
 }
        /// <summary>
        /// Refreshes the space POI info panel.
        /// </summary>
        /// <param name="panel">The parent info panel.</param>
        /// <param name="details">The panel to refresh.</param>
        /// <param name="target">The currently selected object.</param>
        public void Refresh(SpacePOISimpleInfoPanel panel,
                            CollapsibleDetailContentPanel details, GameObject target)
        {
            bool active = false;

            if (target != null)
            {
                bool changed = lastSelection.lastTarget != target;
                if (changed)
                {
                    lastSelection = new LastSelectionDetails(target);
                    if (panel.massHeader == null)
                    {
                        Init(panel, details);
                    }
                }
                var asteroidField = lastSelection.asteroidField;
                var artifact      = lastSelection.artifact;
                var harvestable   = lastSelection.harvestable;
                if (asteroidField != null || artifact != null)
                {
                    if (changed)
                    {
                        InitElements(panel, harvestable, details);
                        panel.artifactsSpacer.transform.SetAsLastSibling();
                        panel.artifactRow.transform.SetAsLastSibling();
                    }
                    if (harvestable != null && massLabel != null)
                    {
                        RefreshMassHeader(harvestable);
                    }
                    RefreshElements(panel, harvestable);
                    if (artifact != null)
                    {
                        RefreshArtifacts(panel, artifact);
                    }
                    if (!wasActive)
                    {
                        details.gameObject.SetActive(true);
                    }
                    active    = true;
                    wasActive = true;
                }
            }
            if (!active && wasActive)
            {
                details.gameObject.SetActive(false);
                wasActive = false;
            }
        }
        /// <summary>
        /// Updates the additional details panel.
        /// </summary>
        /// <param name="instance">The panel to update.</param>
        internal void Update(AdditionalDetailsPanel instance)
        {
            GameObject target;
            Element    element;

            if (instance != null && (target = instance.selectedTarget) != null)
            {
                var  drawer  = instance.drawer;
                bool changed = target != lastSelection.target;
                if (changed)
                {
                    var detailsPanel = instance.detailsPanel;
                    lastSelection = new LastSelectionDetails(target);
                    detailsPanel.SetActive(true);
                    if (detailsPanel.TryGetComponent(out CollapsibleDetailContentPanel panel))
                    {
                        panel.HeaderLabel.SetText(STRINGS.UI.DETAILTABS.DETAILS.
                                                  GROUPNAME_DETAILS);
                    }
                }
                element = lastSelection.element;
                if (element != null)
                {
                    string massStr = GameUtil.GetFormattedMass(lastSelection.Mass);
                    var    id      = element.id;
                    changed |= !SpeedControlScreen.Instance.IsPaused;
                    lastSelection.elementName.AddLine(drawer);
                    drawer.NewLabel(drawer.Format(ELEMENTAL.MASS.NAME, massStr)).
                    Tooltip(drawer.Format(ELEMENTAL.MASS.TOOLTIP, massStr));
                    AddCreationTime(drawer, changed);
                    AddUptimeStats(drawer, changed);
                    if (id != SimHashes.Vacuum && id != SimHashes.Void)
                    {
                        AddElementInfo(drawer);
                    }
                    AddPhaseChangeInfo(drawer, element);
                    DetailDescriptors(drawer);
                }
            }
        }
Example #7
0
 internal SimpleInfoScreenWrapper()
 {
     allGeysers      = null;
     conditionParent = null;
     labelCache      = new Dictionary <string, CachedStorageLabel>(64);
     lastReport      = null;
     lastSelection   = default;
     lastStressEntry = null;
     processHeaders  = new List <ProcessConditionRow>(8);
     processRows     = new List <ProcessConditionRow>(24);
     processVisible  = new List <ProcessConditionRow>(32);
     rocketLabels    = new HashSet <CachedStorageLabel>();
     setInactive     = new HashSet <CachedStorageLabel>();
     statusActive    = false;
     storages        = new List <Storage>(8);
     storageActive   = false;
     storageLabels   = new HashSet <CachedStorageLabel>();
     storageParent   = null;
     stressActive    = false;
     vitalsActive    = false;
     wasPaused       = false;
     instance        = this;
 }
Example #8
0
        /// <summary>
        /// Refreshes the parts of the info screen that are only updated when a different item
        /// is selected.
        /// </summary>
        /// <param name="target">The selected target object.</param>
        private void OnSelectTarget(GameObject target)
        {
            lastReport = null;
            storages.Clear();
            if (target == null)
            {
                lastSelection = default;
                vitalsActive  = false;
            }
            else
            {
                var found = ListPool <Storage, SimpleInfoScreen> .Allocate();

                lastSelection = new LastSelectionDetails(target);
                target.GetComponentsInChildren(found);
                // Add only storages that should be shown
                int n = found.Count;
                for (int i = 0; i < n; i++)
                {
                    var storage = found[i];
                    if (storage != null && storage.ShouldShowInUI())
                    {
                        storages.Add(storage);
                    }
                }
                found.Recycle();
                // Geysers can be uncovered over time
                if (lastSelection.world != null)
                {
                    allGeysers = FindObjectsOfType <Geyser>();
                }
                else
                {
                    allGeysers = null;
                }
            }
        }
Example #9
0
        public override void OnCleanUp()
        {
            int n = processHeaders.Count;

            allGeysers = null;
            foreach (var pair in labelCache)
            {
                pair.Value.Dispose();
            }
            labelCache.Clear();
            // Avoid leaking the report
            lastReport      = null;
            lastStressEntry = null;
            lastSelection   = default;
            // Destroy all process rows
            for (int i = 0; i < n; i++)
            {
                processHeaders[i].Dispose();
            }
            n = processRows.Count;
            for (int i = 0; i < n; i++)
            {
                processRows[i].Dispose();
            }
            processHeaders.Clear();
            processRows.Clear();
            processVisible.Clear();
            storages.Clear();
            // All of these were in the label cache so they should already be disposed
            rocketLabels.Clear();
            storageLabels.Clear();
            storageParent   = null;
            conditionParent = null;
            instance        = null;
            base.OnCleanUp();
        }
 public void Dispose()
 {
     lastSelection = default;
 }
 public void Dispose()
 {
     lastSelection = default;
     massLabel     = null;
 }
 internal SpacePOIInfoPanelWrapper()
 {
     lastSelection = default;
     massLabel     = null;
     wasActive     = false;
 }
Example #13
0
        internal void Refresh()
        {
            var    manager   = Game.Instance.circuitManager;
            var    target    = es.selectedTarget;
            bool   update    = dirty;
            ushort circuitID = ushort.MaxValue;

            if (target != null)
            {
                int cell;
                if (target != lastSelected.lastTarget)
                {
                    lastSelected = new LastSelectionDetails(target);
                    update       = true;
                }
                var conn = lastSelected.connected;
                if (conn != null)
                {
                    circuitID = manager.GetCircuitID(conn);
                }
                else if (Grid.IsValidCell(cell = lastSelected.cell))
                {
                    circuitID = manager.GetCircuitID(cell);
                }
            }
            if (update)
            {
                if (circuitID != ushort.MaxValue)
                {
                    RefreshSummary(manager, circuitID);
                    if (!wasValid)
                    {
                        es.generatorsPanel.SetActive(true);
                        es.consumersPanel.SetActive(true);
                        es.batteriesPanel.SetActive(true);
                        joulesAvailable.SetActive(true);
                        wattageGenerated.SetActive(true);
                        wattageConsumed.SetActive(true);
                        potentialWattageConsumed.SetActive(true);
                        maxSafeWattage.SetActive(true);
                        noCircuit.SetActive(false);
                        wasValid = true;
                    }
                    RefreshGenerators(manager, circuitID);
                    RefreshConsumers(manager, circuitID);
                    RefreshBatteries(manager, circuitID);
                }
                else if (wasValid)
                {
                    es.generatorsPanel.SetActive(false);
                    es.consumersPanel.SetActive(false);
                    es.batteriesPanel.SetActive(false);
                    joulesAvailable.SetActive(false);
                    wattageGenerated.SetActive(false);
                    wattageConsumed.SetActive(false);
                    potentialWattageConsumed.SetActive(false);
                    maxSafeWattage.SetActive(false);
                    noCircuit.SetActive(true);
                }
                dirty = false;
            }
        }