コード例 #1
0
 void clearTeamList()
 {
     for (int i = 0; i < teamsList.GetChildCount(); i++)
     {
         teamsList.GetChild(i).QueueFree();
     }
 }
コード例 #2
0
    void onRefreshButtonPressed()
    {
        requestReloadingTeams();

        for (int i = 0; i < teamsList.GetChildCount(); i++)
        {
            teamsList.GetChild(i).QueueFree();
        }
    }
コード例 #3
0
 void onConfirmButtonPressed()
 {
     for (int i = 0; i < footballersList.GetChildCount(); i++)
     {
         if (footballersList.GetChild(i).GetType().Name == "FootballerFullInfoField")
         {
             FootballerFullInfoField field = (FootballerFullInfoField)footballersList.GetChild(i);
             if (field.IsChecked())
             {
                 handleConfirmSelection(field);
             }
         }
     }
 }
コード例 #4
0
    void updateTeamsData()
    {
        for (int i = 0; i < teamList.GetChildCount(); i++)
        {
            teamList.GetChild(i).QueueFree();
        }

        List <Row> rows = getTeamsData();

        foreach (Row row in rows)
        {
            generateTeamButton(row.Values[0]);
        }
    }
コード例 #5
0
    bool controlSchemeCorrectness()
    {
        for (int i = 0; i < schemesList.GetChildCount(); i++)
        {
            CheckBoxListItem field = (CheckBoxListItem)schemesList.GetChild(i);
            if (field.IsChecked())
            {
                return(true);
            }
        }

        errorInfo.Text = ERROR_NO_SCHEMA_TEXT;
        return(false);
    }
コード例 #6
0
    void onChallengeAccepted(TeamChallengeField sender)
    {
        for (int i = 0; i < challengesList.GetChildCount(); i++)
        {
            TeamChallengeField field = (TeamChallengeField)challengesList.GetChild(i);
            if (field == sender)
            {
                RequestCaller.RequestChallengeAnswer(field.Team.TeamAlias, true);
                field.QueueFree();
            }
        }

        GameData.CurrentOpponentTeam = sender.Team;
        paired = true;
    }
コード例 #7
0
        private void PopulateHistoryHelp(List <string> StringList, bool UseHelpText)
        {
            int HelpLabelsCount = HistoryHelpBox.GetChildCount();
            int HelpCmdCount    = StringList.Count;
            int i = 0;

            // Update existing controls
            for (; i < Mathf.Min(HelpLabelsCount, HelpCmdCount); ++i)
            {
                int   StringIndex = HelpCmdCount - i - 1;
                Label HelpLabel   = HistoryHelpBox.GetChild <Label>(i);
                HelpLabel.Text =
                    UseHelpText ? MDCommands.GetHelpText(StringList[StringIndex]) : StringList[StringIndex];
                HelpLabel.Visible = true;
            }

            // Create new ones as needed
            for (; i < HelpCmdCount; ++i)
            {
                int   StringIndex = HelpCmdCount - i - 1;
                Label HelpLabel   = new Label
                {
                    Text = UseHelpText ? MDCommands.GetHelpText(StringList[StringIndex]) : StringList[StringIndex]
                };
                HistoryHelpBox.AddChild(HelpLabel);
            }

            // Hide the extras
            for (; i < HelpLabelsCount; ++i)
            {
                Label HelpLabel = HistoryHelpBox.GetChild <Label>(i);
                HelpLabel.Visible = false;
            }
        }
コード例 #8
0
 void clearTournamentsList()
 {
     for (int i = 0; i < tournamentsList.GetChildCount(); i++)
     {
         tournamentsList.GetChild(i).QueueFree();
     }
 }
コード例 #9
0
 void clearFootballersList()
 {
     for (int i = 0; i < footballersList.GetChildCount(); i++)
     {
         footballersList.GetChild(i).QueueFree();
     }
 }
コード例 #10
0
ファイル: Chat.cs プロジェクト: lampaBiurkowa/PZPN-Windows
 void controlBuffer()
 {
     if (messagesList.GetChildCount() > MESSAGE_BUFFER_LENGTH)
     {
         messagesList.GetChild(0).QueueFree();
     }
 }
コード例 #11
0
 void clearRoundSection()
 {
     for (int i = 0; i < itemsList.GetChildCount(); i++)
     {
         itemsList.GetChild(i).QueueFree();
     }
 }
コード例 #12
0
    void onScored(string scoringTeamAlias)
    {
        for (int i = 0; i < matchesList.GetChildCount(); i++)
        {
            MatchInfo match = (MatchInfo)matchesList.GetChild(i);

            if (match.Team1Alias == scoringTeamAlias)
            {
                match.AddScore(scoringTeamAlias);
                return;
            }
            if (match.Team2Alias == scoringTeamAlias)
            {
                match.AddScore(scoringTeamAlias);
                return;
            }
        }
    }
コード例 #13
0
    private void AddButtonDebit()
    {
        ButtonDebit instance = packedSceneButton.Instance <ButtonDebit>();

        instance.Connect("hasDelete", this, nameof(ResizeHeigth));
        instance.Connect("hasValidate", this, nameof(AddButtonDebit));
        vBoxContainer.AddChild(instance);
        vBoxContainer.MoveChild(instance, vBoxContainer.GetChildCount() - 2);
        instance.GetFocusLineEdit();
    }
コード例 #14
0
 // Adds and configures a Gen6DoFJointControllerDetail scene to the
 // detail list, replacing any current detail
 private void AddJoint(Godot.Generic6DOFJoint joint)
 {
     if (jointList.GetChildCount() == 1)
     {
         RemoveJoint(0);
     }
     try
     {
         Gen6DoFJointControllerDetail jointDetail = (Gen6DoFJointControllerDetail)GenDetailScene.Instance();
         jointDetail.Configure(joint);
         jointDetail.Name = joint.Name;
         jointList.AddChild(jointDetail);
         ActiveJoint = joint;
     }
     catch (Exception e)
     {
         GD.Print("Error adding joint...\n" + e.Message);
     }
 }
コード例 #15
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;
    }
コード例 #16
0
        public override void _Input(InputEvent @event)
        {
            if (@event.IsActionReleased("ui_console"))
            {
                if (ConsoleVisible)
                {
                    Window.Hide();
                    ConsoleVisible = false;
                }
                else
                {
                    Window.Popup_();
                    ConsoleLine.CallDeferred("grab_focus");
                    ConsoleVisible = true;
                }
            }

            if (ConsoleVisible)
            {
                if (@event.IsActionPressed("ui_accept"))
                {
                    Sys.Ref.Shared.GetNode <InterpreterSys>().ProcessScript(ConsoleLine.Text);
                    ConsoleLine.Clear();
                }

                if (@event.IsActionPressed("ui_autofill"))
                {
                    if (Autofill.GetChildCount() != 0)
                    {
                        string Text = Autofill.GetChild <Node>(0).GetNode <Label>("Alias").Text;
                        Text                      = Text.GetPartsFromBeginToIndex('(', 0) + '(';
                        ConsoleLine.Text          = Text;
                        ConsoleLine.CaretPosition = Text.Length;
                    }
                }
            }
        }
コード例 #17
0
    private void _LoadButtons()
    {
        _CreateButtons();

        VBoxContainer container = GetNode <VBoxContainer>("ColorRect/VBoxContainer");

        for (int i = 0; i < container.GetChildCount(); i += 1)
        {
            container.RemoveChild(container.GetChild(i));
        }
        foreach (TextureButton button in _Buttons)
        {
            CenterContainer center = new CenterContainer();
            center.AddChild(button);
            container.AddChild(center);
        }
    }
コード例 #18
0
    private void onStoryChoices(String[] choices)
    {
        int i = 0;

        foreach (String choice in choices)
        {
            if (i < storyChoices.GetChildCount())
            {
                continue;
            }
            Button button = new Button();
            button.Text = choice;
            button.Connect("pressed", this, nameof(clickChoice), new Godot.Collections.Array()
            {
                i
            });
            storyChoices.AddChild(button);
            ++i;
        }
    }
コード例 #19
0
        public override void _Ready()
        {
            Input.SetMouseMode(Input.MouseMode.Visible);

            Button addButton  = GetNode("CenterContainer/VBoxContainer/ButtonBar/Add") as Button;
            Button backButton = GetNode("CenterContainer/VBoxContainer/ButtonBar/Back") as Button;

            serverList = GetNode("CenterContainer/VBoxContainer/Servers") as VBoxContainer;

            addServerPopup = GetNode("AddServerPopup") as PopupDialog;
            Button popupAddButton  = GetNode("AddServerPopup/HBoxContainer/ButtonBar/Add") as Button;
            Button popupBackButton = GetNode("AddServerPopup/HBoxContainer/ButtonBar/Back") as Button;

            serverName    = GetNode("AddServerPopup/HBoxContainer/Name") as LineEdit;
            serverAddress = GetNode("AddServerPopup/HBoxContainer/Address") as LineEdit;

            addButton?.Connect("pressed", this, nameof(onAdd));
            backButton?.Connect("pressed", this, nameof(onBack));
            popupAddButton?.Connect("pressed", this, nameof(onPopupAdd));
            popupBackButton?.Connect("pressed", this, nameof(onPopupBack));

            random = new RandomNumberGenerator();
            random.Randomize();

            // remove visual indicators we have in editor
            while (serverList?.GetChildCount() > 0)
            {
                Node child = serverList.GetChild(0);
                serverList.RemoveChild(child);
                child.QueueFree();
            }

            // load servers from server manager
            foreach (Server server in SingletonHandler.instance.serverManager.getServers())
            {
                addServer(server.name, server.host, server.port);
            }
        }
コード例 #20
0
ファイル: Alchemy.cs プロジェクト: ConnorRowe/PotionSeller
    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;
    }
コード例 #21
0
        private void AddEntry(string Text, ConsoleColors TextColor)
        {
            if (ConsoleHistory.GetChildCount() >= ConsoleMaxLines)
            {
                ConsoleHistory.GetChild(0).QueueFree();
            }

            Node  ConsoleEntryNode  = ConsoleEntry.Instance();
            Label ConsoleEntryLabel = (Label)ConsoleEntryNode;

            switch (TextColor)
            {
            default:
            case ConsoleColors.Message:
                ConsoleEntryLabel.AddColorOverride("font_color", new Color(1.0f, 1.0f, 1.0f));
                break;

            case ConsoleColors.Warning:
                ConsoleEntryLabel.AddColorOverride("font_color", new Color(0.988f, 0.91f, 0.012f));
                break;

            case ConsoleColors.Error:
                ConsoleEntryLabel.AddColorOverride("font_color", new Color(0.988f, 0.012f, 0.012f));
                break;
            }

            ConsoleEntryLabel.Text = Text;

            if (Sys.Ref.Shared.Contains <RCONSys>())
            {
                Sys.Ref.Shared.GetNode <RCONSys>().Send(Text, TextColor);
            }

            ConsoleHistory.AddChild(ConsoleEntryLabel);

            CallDeferred(nameof(SetScrollbar));
        }
コード例 #22
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();
        }
    }
コード例 #23
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);
        }
    }
コード例 #24
0
ファイル: MicrobeEditorGUI.cs プロジェクト: Doomsdayrs/Thrive
    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);
    }
コード例 #25
0
ファイル: MicrobeHUD.cs プロジェクト: charliehogger31/Thrive
    /// <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

        // Using QueueFree leaves a gap at the bottom of the panel
        hoveredCompoundsContainer.FreeChildren();

        // Refresh cells list
        hoveredCellsContainer.FreeChildren();

        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, TranslationServer.Translate("STUFF_AT"),
                                               stage.Camera.CursorWorldPos.x, stage.Camera.CursorWorldPos.z) + "\n";
        }

        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)
            {
                // It is not useful to show trace amounts of a compound, so those are skipped
                if (entry.Value < 0.1)
                {
                    continue;
                }

                var hBox          = new HBoxContainer();
                var compoundName  = new Label();
                var compoundValue = new Label();

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

                compoundName.SizeFlagsHorizontal = (int)Control.SizeFlags.ExpandFill;
                compoundName.Text = entry.Key.Name;

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

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

        var allMicrobes = GetTree().GetNodesInGroup(Constants.AI_TAG_MICROBE);

        // Show the species name of hovered cells
        foreach (Microbe entry in allMicrobes)
        {
            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;

            if (entry.IsPlayerMicrobe)
            {
                microbeText.Text += " (" + TranslationServer.Translate("PLAYER_CELL") + ")";
            }
        }

        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
ファイル: MicrobeEditorGUI.cs プロジェクト: patana93/Thrive
    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);
    }
コード例 #27
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)
            {
                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();
        }
    }