예제 #1
0
 private void RemoveAllChoices()
 {
     foreach (Node n in storyChoices.GetChildren())
     {
         storyChoices.RemoveChild(n);
     }
 }
예제 #2
0
    private void RemoveJoint(int index)
    {
        var child = jointList.GetChild(index);

        jointList.RemoveChild(child);
        child.Dispose();
    }
예제 #3
0
 private void RemoveAllStoryContent()
 {
     foreach (Node n in storyText.GetChildren())
     {
         storyText.RemoveChild(n);
     }
 }
예제 #4
0
    public void NetClearKillfeed()
    {
        var Children = KillFeedVBox.GetChildren();

        foreach (Node Child in Children)
        {
            KillFeedVBox.RemoveChild(Child);
        }
    }
예제 #5
0
        private void removeServer(String name)
        {
            Node node = serverList.GetNode(name);

            if (node != null)
            {
                serverList.RemoveChild(node);
            }
        }
예제 #6
0
    internal void ClearItems()
    {
        foreach (Node child in ContextItems.GetChildren())
        {
            ContextItems.RemoveChild(child);
        }

        Callbacks.Clear();
        HoveredItem = -1;
    }
예제 #7
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);
        }
    }
예제 #8
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);
            }
        }
예제 #9
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();
    }
예제 #10
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();
        }
    }
예제 #11
0
    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);
            }
        }
    }