示例#1
0
        private void ClearDialogueOptions()
        {
            var options = _dialogueOptionsContainer.GetChildren();

            foreach (Button option in options)
            {
                option.QueueFree();
            }
        }
示例#2
0
 public void Clear()
 {
     foreach (RichTextLabel msgInstance in messageBox.GetChildren())
     {
         if (msgInstance != chatMessage)
         {
             msgInstance.QueueFree();
         }
     }
 }
示例#3
0
    private void On_Click_Refresh()
    {
        var children = vBoxContainer.GetChildren();

        for (int i = 0; i < children.Count; i++)
        {
            ((CanvasItem)children[i]).QueueFree();
        }

        pathEdit.Text = ConfigurationPath;

        LoadConfiguration();
    }
示例#4
0
    void StartResolve()
    {
        GD.Print("has been resolve");

        List <int> listCut = new List <int>();

        foreach (var item in vBoxContainer.GetChildren())
        {
            switch (item)
            {
            case ButtonDebit buttonDebit when buttonDebit.length != null:
                listCut.Add((int)buttonDebit.length);
                break;
            }
        }

        pipeManager = new PipeManager(lineEdit.Text, 6005, listCut, 5);

        pipeManager.Process();
        foreach (var pipe in pipeManager.GetEnumerable())
        {
            String cutString = $"{lineEdit.Text} : ";
            foreach (var cut in pipe)
            {
                cutString += cut.ToString();
                cutString += "-";
            }
            GD.Print(cutString);
        }
    }
示例#5
0
 private void RemoveAllChoices()
 {
     foreach (Node n in storyChoices.GetChildren())
     {
         storyChoices.RemoveChild(n);
     }
 }
示例#6
0
 public void _Start()
 {
     AddLayer(32);
     Children = vBoxContainer.GetChildren();
     tool     = (Tool)GetParent().GetParent();
     // LoadData();
 }
示例#7
0
 /// <summary>
 /// Deletes all instructions from the instruction container.
 /// </summary>
 protected void DeleteInstructions()
 {
     foreach (Label item in _instructionsContainer.GetChildren())
     {
         item.QueueFree();
     }
 }
示例#8
0
 private void RemoveAllStoryContent()
 {
     foreach (Node n in storyText.GetChildren())
     {
         storyText.RemoveChild(n);
     }
 }
示例#9
0
 public void ClearDataPipe()
 {
     foreach (Control child in vBoxContainer.GetChildren())
     {
         child.QueueFree();
     }
     RectSize = new Vector2(RectSize.x, 68);
 }
示例#10
0
    public void NetClearKillfeed()
    {
        var Children = KillFeedVBox.GetChildren();

        foreach (Node Child in Children)
        {
            KillFeedVBox.RemoveChild(Child);
        }
    }
示例#11
0
    private void ClearMessages()
    {
        Godot.Collections.Array messageChildren = textContainer.GetChildren();

        foreach (Label child in messageChildren)
        {
            child.QueueFree();
        }
    }
示例#12
0
    internal void ClearItems()
    {
        foreach (Node child in ContextItems.GetChildren())
        {
            ContextItems.RemoveChild(child);
        }

        Callbacks.Clear();
        HoveredItem = -1;
    }
示例#13
0
        public override void _Ready()
        {
            container = GetNode <HBoxContainer>("Container");

            for (int i = 0; i < container.GetChildCount(); i++)
            {
                Panel         cardPanel = container.GetChildren()[i] as Panel;
                VBoxContainer infoBox   = cardPanel.GetNode <Panel>("Info").GetNode <VBoxContainer>("VBoxContainer");

                // add 2 first children, which are usually Title & Description
                Interface.LabelGroup.Add(infoBox.GetChildren()[0] as Label);
                Interface.LabelGroup.Add(infoBox.GetChildren()[1] as Label);

                // add the animation player for this card panel
                Interface.cardAnimationGroup.Add(cardPanel.GetNode <AnimationPlayer>("AnimationPlayer"));
            }

            Vars.load();
        }
示例#14
0
 public override void _Ready()
 {
     boxContainer = GetNode <VBoxContainer>("Panel/VBoxContainer");
     foreach (Button bt in boxContainer.GetChildren())
     {
         bt.Connect("mouse_entered", this, nameof(OnMouseHover), new Godot.Collections.Array()
         {
             bt.HintTooltip
         });
     }
 }
示例#15
0
    public void CloseMenu()
    {
        Godot.Collections.Array equipmentButtons = equipmentContainer.GetChildren();

        foreach (Button child in equipmentButtons)
        {
            child.QueueFree();
        }

        Visible = false;
    }
示例#16
0
    // Adds a new column using an existing
    // column as a template.
    public void AddColumn()
    {
        VBoxContainer NewColumn = (VBoxContainer)ColumnsNode !.GetChild(ColumnsNode.GetChildCount() - 1) !.Duplicate();
        int           count     = NewColumn.GetChildCount();

        Godot.Collections.Array NewColumnChildren = NewColumn.GetChildren();
        for (int i = 0; i < count; i++)
        {
            (NewColumnChildren[i] as LineEdit) !.Text = "";
        }
        ColumnsNode !.AddChild(NewColumn);
        Columns++;
        return;
    }
示例#17
0
    public void ProceedToCrushPressed()
    {
        for (int i = 0; i < _potionReagentsBox.GetChildCount(); i++)
        {
            //ItemSprite
            Node2D N = ((Node)_potionReagentsBox.GetChildren()[i]).GetChild(0).GetChild(0) as Node2D;

            _tween.InterpolateProperty(GetNode("MortarPestle/PickReagents"), "modulate", Colors.White, new Color(1f, 1f, 1f, 0f), .5f);
            _tween.InterpolateProperty(_proceedToCrush, "modulate", Colors.White, new Color(1f, 1f, 1f, 0f), .5f);

            Sprite reagentSprite = new Sprite()
            {
                Texture        = _potionReagents[i].IconTex,
                GlobalPosition = N.GlobalPosition + new Vector2(2f, 2f),
                Centered       = false,
                ZIndex         = -2
            };
            AddChild(reagentSprite);
            _reagentAnimSprites[i] = reagentSprite;
        }
        _tween.Start();
        _reagentAnimState = ReagentAnim.Hover;
    }
示例#18
0
 public static void SetupTowerShop()
 {
     GameUtil.ClearChildren(_shopList);
     TowerType.Types.ForEach(type =>
     {
         if (!(_towerButton.Instance() is TowerButton button))
         {
             return;
         }
         if (_towerManager != null)
         {
             button.Setup(type, _towerManager);
         }
         _shopList.AddChild(button);
     });
     foreach (var towerButton in _shopList.GetChildren().OfType <TowerButton>())
     {
         if (towerButton.TowerType != null && GameInfo.GameCurrency.CanAfford(towerButton.TowerType.Cost))
         {
             towerButton.Locked = false;
         }
     }
 }
示例#19
0
    public void ItemDelete()
    {
        panelContainer.RectSize -= new Vector2(0, 50);
        bool noFreeItem = false;

        foreach (var item in vBoxContainer.GetChildren())
        {
            switch (item)
            {
            case ButtonDebit2 buttonDebit when buttonDebit.length == null || buttonDebit.qt == null:
                noFreeItem = true;
                GD.PrintErr(true, buttonDebit);
                break;
            }
        }
        if (noFreeItem == false)
        {
            AddButtonDebit();
        }
        if (vBoxContainer.GetChildCount() == 0)
        {
            AddButtonDebit();
        }
    }
    public void poblateList()
    {
        //borra
        foreach (Node obj in list.GetChildren())
        {
            obj.QueueFree();
        }

        //read directory terrain
        Directory dir = new Directory();
        Error     err = dir.Open(basePath);

        if (err != Error.Ok)
        {
            return;
        }

        dir.ListDirBegin();
        string        fileName;
        List <string> fileNames = new List <string>();

        while (true)
        {
            fileName = dir.GetNext();
            if (fileName == "")
            {
                break;                //fin
            }
            if (fileName.BeginsWith("."))
            {
                continue;                         //subdirectorios no
            }
            fileNames.Add(fileName);
        }

        //poblate list with buttons
        foreach (string fn in fileNames)
        {
            Button buFile = new Button();
            buFile.Text        = (fn);
            buFile.RectMinSize = new Vector2(0, 30f);
            Godot.Collections.Array data = new Godot.Collections.Array();
            data.Add(fn);
            buFile.Connect("pressed", this, "onCLickFileButton", data);
            list.AddChild(buFile);
        }
    }
示例#21
0
    public void ResetSlotsVBox()
    {
        foreach (Node Child in SlotsVBox.GetChildren())
        {
            Child.QueueFree();
        }

        Directory     SaveDir = new Directory();
        List <string> Names   = new List <string>();

        if (SaveDir.DirExists("user://Saves"))
        {
            SaveDir.Open("user://Saves");
            SaveDir.ListDirBegin(skipNavigational: true, skipHidden: true);
            while (true)
            {
                string SaveName = SaveDir.GetNext();
                if (SaveName == "")
                {
                    break;
                }
                Names.Add(SaveName);
            }
            Names.Sort();

            foreach (string Name in Names)
            {
                SlotButton Instanced = SlotButtonScene.Instance() as SlotButton;
                Instanced.HostMenuInstance = this;
                Instanced.Text             = Name;
                SlotsVBox.AddChild(Instanced);
            }
        }

        if (Names.Count <= 0)
        {
            Label Message = LabelPieceScene.Instance() as Label;
            Message.Text = "No saves to load";
            SlotsVBox.AddChild(Message);
        }
    }
示例#22
0
    public override void _Ready()
    {
        shopMenu   = this;
        Text       = GetNode <Label>("Layer2/ShopDialog/Text");
        nameLabel  = GetNode <Label>("Layer2/ShopDialog/NameLabel");
        shopDialog = GetNode <Panel>("Layer2/ShopDialog");
        shopPanel  = GetNode <Panel>("Layer2/ShopPanel");
        talkSound  = GetNode <AudioStreamPlayer>("TalkSound");

        itemButtonsContainer = GetNode <VBoxContainer>("Layer2/ShopPanel/ItemButtonsContainer");

        foreach (Button button in itemButtonsContainer.GetChildren())
        {
            shopButtons.Add(button);
        }
        foreach (object child in shopPanel.GetChildren())
        {
            if (child is Label)
            {
                Label price = child as Label;
                shopPrices.Add(price);
            }
        }
    }
    private void addButtons()
    {
        foreach (Button button in dock.GetChildren())
        {
            dock.RemoveChild(button);
        }

        var lastConnector = getLastConnector();

        Button bt3 = new Button();

        bt3.Name = "Reload";
        bt3.Text = "Reload";
        bt3.Connect("pressed", this, "LoadList");

        Button bt4 = new Button();

        bt4.Name = "Swap";
        bt4.Text = "Swap";
        bt4.Connect("pressed", this, "swapLastNode");

        Button bt5 = new Button();

        bt5.Name = "Undo";
        bt5.Text = "Undo";
        bt5.Connect("pressed", this, "undoLastNode");

        dock.AddChild(bt3);
        dock.AddChild(bt4);
        dock.AddChild(bt5);

        //add extra nodes with swapping
        //compare levels
        var extraList = new List <RoadConnector>();

        if (lastConnector != null)
        {
            foreach (var scene in tempScenes)
            {
                int port = 0;
                foreach (var res in lastConnector.findFreeRoute(lastConnector, scene))
                {
                    Button bt = new Button();
                    bt.Name = scene.Name;
                    var name = scene.Name + ": Port " + port;

                    bt.Text = (res.needSwaped) ? name + " (Right) " : name;

                    dock.AddChild(bt);

                    var col = new Godot.Collections.Array();

                    col.Add(scene);
                    col.Add((res.needSwaped) ? 180 : 0);
                    col.Add(res.side);

                    bt.Connect("pressed", this, "addNode", col);
                    port++;
                }
            }
        }
        else
        {
            foreach (var scene in tempScenes)
            {
                Button bt = new Button();
                bt.Name = scene.Name;
                bt.Text = scene.Name;

                dock.AddChild(bt);

                var col = new Godot.Collections.Array();
                col.Add(scene);
                col.Add(0);
                col.Add(null);

                bt.Connect("pressed", this, "addNode", col);
            }
        }
    }
示例#24
0
    /// <summary>
    ///   Updates the mouse hover box with stuff.
    /// </summary>
    /// <remarks>
    ///   <para>
    ///     This creates and removes GUI elements every frame.
    ///     Supposedly that's quite expensive, but I think that's
    ///     how the old JS code do it anyway.
    ///   </para>
    /// </remarks>
    private void UpdateHoverInfo()
    {
        foreach (Node children in hoveredItems.GetChildren())
        {
            hoveredItems.RemoveChild(children);

            // Using QueueFree leaves a gap at
            // the bottom of the panel
            children.Free();
        }

        if (mouseHoverPanel.RectSize != new Vector2(270, 130))
        {
            mouseHoverPanel.RectSize = new Vector2(270, 130);
        }

        if (mouseHoverPanel.MarginLeft != -280)
        {
            mouseHoverPanel.MarginLeft = -280;
        }
        if (mouseHoverPanel.MarginRight != -10)
        {
            mouseHoverPanel.MarginRight = -10;
        }

        var compounds = stage.Clouds.GetAllAvailableAt(stage.Camera.CursorWorldPos);

        var builder = new StringBuilder(string.Empty, 250);

        if (showMouseCoordinates)
        {
            builder.AppendFormat(CultureInfo.CurrentCulture, "Stuff at {0:F1}, {1:F1}:\n",
                                 stage.Camera.CursorWorldPos.x, stage.Camera.CursorWorldPos.z);
        }

        var mousePosLabel = hoveredItems.GetParent().GetNode <Label>("MousePos");

        if (compounds.Count == 0)
        {
            builder.Append("Nothing to eat here");
        }
        else
        {
            builder.Append("At cursor:");

            bool first = true;

            // Create for each compound the information in GUI
            foreach (var entry in compounds)
            {
                if (first)
                {
                    var compoundsLabel = new Label();
                    compoundsLabel.Valign = Label.VAlign.Center;
                    hoveredItems.AddChild(compoundsLabel);
                    compoundsLabel.AddConstantOverride("line_spacing", -5);
                    compoundsLabel.Text = "Compounds: \n";
                }

                first = false;

                var hBox         = new HBoxContainer();
                var compoundText = new Label();

                var readableName = entry.Key.Name;
                var compoundIcon = GUICommon.Instance.CreateCompoundIcon(readableName, 25, 25);

                var compoundsText = new StringBuilder(readableName, 150);
                compoundsText.AppendFormat(CultureInfo.CurrentCulture, ": {0:F1}", entry.Value);

                compoundText.Text = compoundsText.ToString();

                hBox.AddChild(compoundIcon);
                hBox.AddChild(compoundText);
                hoveredItems.AddChild(hBox);
            }
        }

        var aiMicrobes = GetTree().GetNodesInGroup(Constants.AI_GROUP);

        // Show the hovered over microbe's species
        foreach (Microbe entry in aiMicrobes)
        {
            var distance = (entry.Translation - stage.Camera.CursorWorldPos).Length();

            // Find only cells that have the mouse
            // position within their membrane
            if (distance > entry.Radius)
            {
                continue;
            }

            var microbeText = new Label();
            microbeText.Valign = Label.VAlign.Center;
            hoveredItems.AddChild(microbeText);

            microbeText.Text = "Cell of species " + entry.Species.FormattedName;
        }

        mousePosLabel.Text = builder.ToString();
    }
示例#25
0
    /// <summary>
    ///   Updates the mouse hover indicator box with stuff.
    /// </summary>
    private void UpdateHoverInfo(float delta)
    {
        hoverInfoTimeElapsed += delta;

        if (hoverInfoTimeElapsed < Constants.HOVER_PANEL_UPDATE_INTERVAL)
        {
            return;
        }

        hoverInfoTimeElapsed = 0;

        // Refresh compounds list
        foreach (Node children in hoveredCompoundsContainer.GetChildren())
        {
            hoveredCompoundsContainer.RemoveChild(children);

            // Using QueueFree leaves a gap at
            // the bottom of the panel
            children.Free();
        }

        // Refresh cells list
        foreach (Node children in hoveredCellsContainer.GetChildren())
        {
            hoveredCellsContainer.RemoveChild(children);
            children.Free();
        }

        if (mouseHoverPanel.RectSize != new Vector2(240, 80))
        {
            mouseHoverPanel.RectSize = new Vector2(240, 80);
        }

        if (mouseHoverPanel.MarginLeft != -240)
        {
            mouseHoverPanel.MarginLeft = -240;
        }
        if (mouseHoverPanel.MarginRight != 0)
        {
            mouseHoverPanel.MarginRight = 0;
        }

        var compounds = stage.Clouds.GetAllAvailableAt(stage.Camera.CursorWorldPos);

        var container     = mouseHoverPanel.GetNode("PanelContainer/MarginContainer/VBoxContainer");
        var mousePosLabel = container.GetNode <Label>("MousePos");
        var nothingHere   = container.GetNode <MarginContainer>("NothingHere");

        if (showMouseCoordinates)
        {
            mousePosLabel.Text = string.Format(CultureInfo.CurrentCulture, "Stuff at {0:F1}, {1:F1}:",
                                               stage.Camera.CursorWorldPos.x, stage.Camera.CursorWorldPos.z);
        }

        if (compounds.Count == 0)
        {
            hoveredCompoundsContainer.GetParent <VBoxContainer>().Visible = false;
        }
        else
        {
            hoveredCompoundsContainer.GetParent <VBoxContainer>().Visible = true;

            // Create for each compound the information in GUI
            foreach (var entry in compounds)
            {
                var hBox          = new HBoxContainer();
                var compoundName  = new Label();
                var compoundValue = new Label();

                var readableName = entry.Key.Name;
                var compoundIcon = GUICommon.Instance.CreateCompoundIcon(readableName, 20, 20);

                compoundName.SizeFlagsHorizontal = (int)Control.SizeFlags.ExpandFill;
                compoundName.Text = readableName;

                compoundValue.Text = string.Format(CultureInfo.CurrentCulture, "{0:F1}", entry.Value);

                hBox.AddChild(compoundIcon);
                hBox.AddChild(compoundName);
                hBox.AddChild(compoundValue);
                hoveredCompoundsContainer.AddChild(hBox);
            }
        }

        var aiMicrobes = GetTree().GetNodesInGroup(Constants.AI_GROUP);

        // Show the species name of hovered cells
        foreach (Microbe entry in aiMicrobes)
        {
            var distance = (entry.Translation - stage.Camera.CursorWorldPos).Length();

            // Find only cells that have the mouse
            // position within their membrane
            if (distance > entry.Radius + Constants.MICROBE_HOVER_DETECTION_EXTRA_RADIUS)
            {
                continue;
            }

            // TODO: Combine cells of same species within mouse over
            // into a single line with total number of them

            var microbeText = new Label();
            microbeText.Valign = Label.VAlign.Center;
            hoveredCellsContainer.AddChild(microbeText);

            microbeText.Text = entry.Species.FormattedName;
        }

        hoveredCellsSeparator.Visible = hoveredCellsContainer.GetChildCount() > 0 &&
                                        hoveredCompoundsContainer.GetChildCount() > 0;

        hoveredCellsContainer.GetParent <VBoxContainer>().Visible = hoveredCellsContainer.GetChildCount() > 0;

        if (compounds.Count > 0 || hoveredCellsContainer.GetChildCount() > 0)
        {
            nothingHere.Hide();
        }
        else
        {
            nothingHere.Show();
        }
    }
示例#26
0
    private void WriteOrganelleProcessList(List <ProcessSpeedInformation> processList,
                                           VBoxContainer targetElement)
    {
        // Remove previous process list
        if (targetElement.GetChildCount() > 0)
        {
            foreach (Node children in targetElement.GetChildren())
            {
                children.QueueFree();
            }
        }

        if (processList == null)
        {
            var noProcesslabel = new Label();
            noProcesslabel.Text = "No processes";
            targetElement.AddChild(noProcesslabel);
            return;
        }

        foreach (var process in processList)
        {
            var processContainer = new VBoxContainer();
            targetElement.AddChild(processContainer);

            var processTitle = new Label();
            processTitle.AddColorOverride("font_color", new Color(1.0f, 0.84f, 0.0f));
            processTitle.Text = process.Process.Name;
            processContainer.AddChild(processTitle);

            var processBody = new HBoxContainer();

            bool usePlus;

            if (process.OtherInputs.Count == 0)
            {
                // Just environmental stuff
                usePlus = true;
            }
            else
            {
                // Something turns into something else, uses the arrow notation
                usePlus = false;

                // Show the inputs
                // TODO: add commas or maybe pluses for multiple inputs
                foreach (var key in process.OtherInputs.Keys)
                {
                    var inputCompound = process.OtherInputs[key];

                    var amountLabel = new Label();
                    amountLabel.Text = Math.Round(inputCompound.Amount, 3) + " ";
                    processBody.AddChild(amountLabel);
                    processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(inputCompound.Compound.Name));
                }

                // And the arrow
                var arrow = new TextureRect();
                arrow.Expand      = true;
                arrow.RectMinSize = new Vector2(20, 20);
                arrow.Texture     = GD.Load <Texture>("res://assets/textures/gui/bevel/WhiteArrow.png");
                processBody.AddChild(arrow);
            }

            // Outputs of the process. It's assumed that every process has outputs
            foreach (var key in process.Outputs.Keys)
            {
                var outputCompound = process.Outputs[key];

                var amountLabel = new Label();

                var stringBuilder = new StringBuilder(string.Empty, 150);

                // Changes process title and process# to red if process has 0 output
                if (outputCompound.Amount == 0)
                {
                    processTitle.AddColorOverride("font_color", new Color(1.0f, 0.1f, 0.1f));
                    amountLabel.AddColorOverride("font_color", new Color(1.0f, 0.1f, 0.1f));
                }

                if (usePlus)
                {
                    stringBuilder.Append(outputCompound.Amount >= 0 ? "+" : string.Empty);
                }

                stringBuilder.Append(Math.Round(outputCompound.Amount, 3) + " ");

                amountLabel.Text = stringBuilder.ToString();

                processBody.AddChild(amountLabel);
                processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(outputCompound.Compound.Name));
            }

            var perSecondLabel = new Label();
            perSecondLabel.Text = "/second";

            processBody.AddChild(perSecondLabel);

            // Environment conditions
            if (process.EnvironmentInputs.Count > 0)
            {
                var atSymbol = new Label();

                atSymbol.Text        = "@";
                atSymbol.RectMinSize = new Vector2(30, 20);
                atSymbol.Align       = Label.AlignEnum.Center;
                processBody.AddChild(atSymbol);

                var first = true;

                foreach (var key in process.EnvironmentInputs.Keys)
                {
                    if (!first)
                    {
                        var commaLabel = new Label();
                        commaLabel.Text = ", ";
                        processBody.AddChild(commaLabel);
                    }

                    first = false;

                    var environmentCompound = process.EnvironmentInputs[key];

                    // To percentage
                    var percentageLabel = new Label();

                    // TODO: sunlight needs some special handling (it used to say the lux amount)
                    percentageLabel.Text = Math.Round(environmentCompound.AvailableAmount * 100, 1) + "%";

                    processBody.AddChild(percentageLabel);
                    processBody.AddChild(GUICommon.Instance.CreateCompoundIcon(environmentCompound.Compound.Name));
                }
            }

            processContainer.AddChild(processBody);
        }
    }
示例#27
0
    private void UpdateShownPatchDetails()
    {
        var patch = mapDrawer.SelectedPatch;

        if (patch == null)
        {
            patchDetails.Visible         = false;
            patchNothingSelected.Visible = true;

            return;
        }

        patchDetails.Visible         = true;
        patchNothingSelected.Visible = false;

        patchName.Text          = patch.Name;
        patchBiome.Text         = "Biome: " + patch.Biome.Name;
        patchPlayerHere.Visible = editor.CurrentPatch == patch;

        // Atmospheric gasses
        patchTemperature.Text = patch.Biome.AverageTemperature + " °C";
        patchPressure.Text    = "20 bar";
        patchLight.Text       = (patch.Biome.Compounds["sunlight"].Dissolved * 100) + "% lux";
        patchOxygen.Text      = (patch.Biome.Compounds["oxygen"].Dissolved * 100) + "%";
        patchNitrogen.Text    = (patch.Biome.Compounds["nitrogen"].Dissolved * 100) + "% ppm";
        patchCO2.Text         = (patch.Biome.Compounds["carbondioxide"].Dissolved * 100) + "% ppm";

        // Compounds
        patchHydrogenSulfide.Text = Math.Round(patch.Biome.Compounds["hydrogensulfide"].Density *
                                               patch.Biome.Compounds["hydrogensulfide"].Amount + GetPatchChunkTotalCompoundAmount(
                                                   patch, "hydrogensulfide"), 3) + "%";

        patchAmmonia.Text = Math.Round(patch.Biome.Compounds["ammonia"].Density *
                                       patch.Biome.Compounds["ammonia"].Amount + GetPatchChunkTotalCompoundAmount(
                                           patch, "ammonia"), 3) + "%";

        patchGlucose.Text = Math.Round(patch.Biome.Compounds["glucose"].Density *
                                       patch.Biome.Compounds["glucose"].Amount + GetPatchChunkTotalCompoundAmount(
                                           patch, "glucose"), 3) + "%";

        patchPhosphate.Text = Math.Round(patch.Biome.Compounds["phosphates"].Density *
                                         patch.Biome.Compounds["phosphates"].Amount + GetPatchChunkTotalCompoundAmount(
                                             patch, "phosphates"), 3) + "%";

        patchIron.Text = GetPatchChunkTotalCompoundAmount(patch, "iron") + "%";

        // Delete previous species list
        if (speciesList.GetChildCount() > 0)
        {
            foreach (Node child in speciesList.GetChildren())
            {
                child.QueueFree();
            }
        }

        foreach (var species in patch.SpeciesInPatch.Keys)
        {
            var speciesLabel = new Label();
            speciesLabel.Text = species.FormattedName + " with population: " + species.Population;
            speciesList.AddChild(speciesLabel);
        }

        // Enable move to patch button if this is a valid move
        moveToPatchButton.Disabled = !editor.IsPatchMoveValid(patch);

        UpdateConditionDifferencesBetweenPatches(patch, editor.CurrentPatch);
    }
示例#28
0
    private void UpdateShownPatchDetails()
    {
        var patch = mapDrawer.SelectedPatch;

        if (patch == null)
        {
            patchDetails.Visible         = false;
            patchNothingSelected.Visible = true;

            return;
        }

        patchDetails.Visible         = true;
        patchNothingSelected.Visible = false;

        patchName.Text          = patch.Name;
        patchBiome.Text         = "Biome: " + patch.BiomeTemplate.Name;
        patchPlayerHere.Visible = editor.CurrentPatch == patch;

        // Atmospheric gasses
        patchTemperature.Text = patch.Biome.AverageTemperature + " °C";
        patchPressure.Text    = "20 bar";
        patchLight.Text       = (patch.Biome.Compounds[sunlight].Dissolved * 100) + "% lux";
        patchOxygen.Text      = (patch.Biome.Compounds[oxygen].Dissolved * 100) + "%";
        patchNitrogen.Text    = (patch.Biome.Compounds[nitrogen].Dissolved * 100) + "% ppm";
        patchCO2.Text         = (patch.Biome.Compounds[carbondioxide].Dissolved * 100) + "% ppm";

        // Compounds
        patchHydrogenSulfide.Text = Math.Round(patch.Biome.Compounds[hydrogensulfide].Density *
                                               patch.Biome.Compounds[hydrogensulfide].Amount + GetPatchChunkTotalCompoundAmount(
                                                   patch, hydrogensulfide), 3) + "%";

        patchAmmonia.Text = Math.Round(patch.Biome.Compounds[ammonia].Density *
                                       patch.Biome.Compounds[ammonia].Amount + GetPatchChunkTotalCompoundAmount(
                                           patch, ammonia), 3) + "%";

        patchGlucose.Text = Math.Round(patch.Biome.Compounds[glucose].Density *
                                       patch.Biome.Compounds[glucose].Amount + GetPatchChunkTotalCompoundAmount(
                                           patch, glucose), 3) + "%";

        patchPhosphate.Text = Math.Round(patch.Biome.Compounds[phosphates].Density *
                                         patch.Biome.Compounds[phosphates].Amount + GetPatchChunkTotalCompoundAmount(
                                             patch, phosphates), 3) + "%";

        patchIron.Text = GetPatchChunkTotalCompoundAmount(patch, iron) + "%";

        // Delete previous species list
        if (speciesList.GetChildCount() > 0)
        {
            foreach (Node child in speciesList.GetChildren())
            {
                child.QueueFree();
            }
        }

        foreach (var species in patch.SpeciesInPatch.Keys)
        {
            var speciesLabel = new Label();
            speciesLabel.Text = species.FormattedName + " with population: " + patch.GetSpeciesPopulation(species);
            speciesList.AddChild(speciesLabel);

            // Yes, apparently this has to be done so that the rect size is updated immediately
            speciesList.RectSize = speciesList.RectSize;

            if (speciesListIsHidden)
            {
                // Adjust the species list's clipping area's "height" value
                var clip = speciesList.GetParent <MarginContainer>();
                clip.AddConstantOverride("margin_top", -(int)speciesList.RectSize.y);
            }
        }

        // Enable move to patch button if this is a valid move
        moveToPatchButton.Disabled = !editor.IsPatchMoveValid(patch);

        UpdateConditionDifferencesBetweenPatches(patch, editor.CurrentPatch);
    }