Example #1
0
        public void Display()
        {
            var width = ImGui.GetWindowWidth() * 0.5f;

            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(240, 200), true);
            ImGui.Text(_entityState.Name);
            ImGui.Text("Transfer Rate: " + _storageDatablob.TransferRateInKgHr);
            ImGui.Text("At DeltaV < " + _storageDatablob.TransferRangeDv + " Km/s");
            foreach (var storetype in CargoResourceStores)
            {
                ImGui.SetNextTreeNodeOpen(HeadersIsOpenDict[storetype.TypeID]);
                if (ImGui.CollapsingHeader(storetype.HeaderText + "###" + _entityState.Name + storetype.StorageTypeName, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    HeadersIsOpenDict[storetype.TypeID] = true;
                    foreach (CargoItemVM item in storetype.CargoItems)
                    {
                        bool isSelected = SelectedCargoVM == item;
                        if (ImGui.Selectable(item.ItemName, isSelected))
                        {
                            SelectedCargoVM = item;
                            CargoItemSelectedEvent.Invoke(this);
                        }
                        ImGui.SameLine();
                        ImGui.Text(item.ItemWeightPerUnit);
                        ImGui.SameLine();
                        ImGui.Text(item.NumberOfItems);
                        ImGui.SameLine();
                        ImGui.Text(item.TotalWeight);

                        ImGui.Text("+" + item.ItemIncomingAmount.ToString());
                        ImGui.SameLine();
                        ImGui.Text(item.GetIncomingWeight());
                        ImGui.SameLine();
                        ImGui.Text("-" + item.ItemOutgoingAmount.ToString());
                        ImGui.SameLine();
                        ImGui.Text(item.GetOutgoungWeight());
                    }
                }
                else
                {
                    HeadersIsOpenDict[storetype.TypeID] = false;
                }
            }
            ImGui.EndChild();
        }
Example #2
0
        public void Display()
        {
            ImGui.BeginChild(_entityState.Name, new System.Numerics.Vector2(260, 200), true);
            ImGui.Text(_entityState.Name);
            ImGui.Text("Transfer Rate: " + _volStorageDB.TransferRateInKgHr);
            ImGui.Text("At DeltaV < " + Stringify.Velocity(_volStorageDB.TransferRangeDv_mps));

            foreach (var typeStore in _stores)
            {
                CargoTypeSD stype        = _staticData.CargoTypes[typeStore.Key];
                var         freeVolume   = typeStore.Value.FreeVolume;
                var         maxVolume    = typeStore.Value.MaxVolume;
                var         storedVolume = maxVolume - freeVolume;

                string headerText = stype.Name + " " + Stringify.Volume(freeVolume) + " / " + Stringify.Volume(maxVolume) + " free";
                ImGui.PushID(_entityState.Entity.Guid.ToString());
                if (ImGui.CollapsingHeader(headerText, ImGuiTreeNodeFlags.CollapsingHeader))
                {
                    ImGui.Columns(3);
                    ImGui.Text("Item");
                    ImGui.NextColumn();
                    ImGui.Text("Count");
                    ImGui.NextColumn();
                    ImGui.Text("Total Mass");
                    ImGui.NextColumn();
                    ImGui.Separator();

                    foreach (var cargoItemKvp in typeStore.Value.CurrentStoreInUnits.ToArray())
                    {
                        ICargoable cargoItem = _stores[typeStore.Key].Cargoables[cargoItemKvp.Key];
                        if (cargoItem == null)
                        {
                            FactionInfoDB factionInfoDB;
                            //factionInfoDB.
                        }

                        var cname         = cargoItem.Name;
                        var unitsStored   = cargoItemKvp.Value;
                        var volumePerItem = cargoItem.VolumePerUnit;
                        var volumeStored  = _volStorageDB.GetVolumeStored(cargoItem);
                        var massStored    = _volStorageDB.GetMassStored(cargoItem);

                        bool isSelected = selectedCargo == cargoItem;
                        if (ImGui.Selectable(cname, isSelected))
                        {
                            selectedCargo = cargoItem;
                            CargoItemSelectedEvent.Invoke(this);
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Number(unitsStored));


                        if (_cargoToMove.ContainsKey(cargoItem))
                        {
                            var    unitsMoving = _cargoToMove[cargoItem];
                            string text        = Stringify.Number(unitsMoving);
                            ImGui.SameLine();

                            float blue = 0f;
                            if (_cargoToMoveDatablob.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveDatablob[cargoItem] != 0)
                                {
                                    blue = 0.25f;
                                }
                            }
                            if (_cargoToMoveOrders.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveOrders[cargoItem] != 0)
                                {
                                    blue = 0.5f;
                                }
                            }
                            if (_cargoToMoveUI.ContainsKey(cargoItem))
                            {
                                if (_cargoToMoveUI[cargoItem] != 0)
                                {
                                    blue = 0.75f;
                                }
                            }

                            if (unitsMoving > 0)
                            {
                                ImGui.TextColored(new Vector4(0.5f, 1, blue, 1), text);
                            }
                            else
                            {
                                ImGui.TextColored(new Vector4(1f, 0.5f, blue, 1), text);
                            }
                        }

                        ImGui.NextColumn();
                        ImGui.Text(Stringify.Mass(massStored));
                        ImGui.NextColumn();
                    }

                    ImGui.Columns(1);
                }
            }


            ImGui.EndChild();
        }