Ejemplo n.º 1
0
 public override void _Ready()
 {
     _uiScreen = GetParent().GetNode("GUILayer").GetNode <MarginContainer>("UIScreen");
     _shopList = _uiScreen.GetNode <VBoxContainer>(
         "HBoxContainer/SideMenu/Shop/Sections/VBoxContainer/ShopItemsScrollContainer/ShopItems");
     _infoSection =
         _uiScreen.GetNode <MarginContainer>("HBoxContainer/SideMenu/Shop/Sections/VBoxContainer/InfoSection");
     _towerButton  = GD.Load <PackedScene>("res://Data/Scenes/GUI/ShopElements/TowerButton.tscn");
     _towerManager = GetParent().GetNode("Level").GetNode("TowerManager") as TowerManager;
     StartButton   =
         _uiScreen.GetNode <Button>(
             "HBoxContainer/SideMenu/Shop/Sections/VBoxContainer/InfoSection/VBoxContainer/StartButton");
 }
Ejemplo n.º 2
0
        public override void _Ready()
        {
            _margin                       = GetNode <MarginContainer>("MarginContainer");
            _vBox                         = _margin.GetNode <VBoxContainer>("VBoxContainer");
            _topHBox                      = _vBox.GetNode <HBoxContainer>("Top");
            _nameMargin                   = _topHBox.GetNode <MarginContainer>("NameMargin");
            _nameLabelMargin              = _nameMargin.GetNode <MarginContainer>("NameLabelMargin");
            _nameLabel                    = _nameLabelMargin.GetNode <Label>("Name");
            _secondRowHBox                = _vBox.GetNode <HBoxContainer>("SecondRow");
            _itemMargin                   = _secondRowHBox.GetNode <MarginContainer>("ItemMargin");
            _iconMargin                   = _itemMargin.GetNode <MarginContainer>("IconMargin");
            _itemIcon                     = _iconMargin.GetNode <TextureRect>("ItemIcon");
            _buttonMargin                 = _secondRowHBox.GetNode <MarginContainer>("ButtonMargin");
            _equipButton                  = _buttonMargin.GetNode <TextureButton>("Equip");
            _useButton                    = _buttonMargin.GetNode <TextureButton>("Use");
            _damageValues                 = _vBox.GetNode <HBoxContainer>("DamageValues");
            _quickVBox                    = _damageValues.GetNode <VBoxContainer>("Quick");
            _quickDamageLabel             = _quickVBox.GetNode <Label>("DamageValue");
            _quickIconVBox                = _quickVBox.GetNode <VBoxContainer>("IconVBoxContainer");
            _quickTypeIcon                = _quickIconVBox.GetNode <TextureRect>("TypeIcon");
            _quickStatusIcon              = _quickIconVBox.GetNode <TextureRect>("StatusIcon");
            _quickStatusEffectChanceLabel =
                _quickIconVBox.GetNode <Label>("StatusEffectChance");
            _heavyVBox                    = _damageValues.GetNode <VBoxContainer>("Heavy");
            _heavyDamageLabel             = _heavyVBox.GetNode <Label>("DamageValue");
            _heavyIconVBox                = _heavyVBox.GetNode <VBoxContainer>("IconVBoxContainer");
            _heavyTypeIcon                = _heavyIconVBox.GetNode <TextureRect>("TypeIcon");
            _heavyStatusIcon              = _heavyIconVBox.GetNode <TextureRect>("StatusIcon");
            _heavyStatusEffectChanceLabel =
                _heavyIconVBox.GetNode <Label>("StatusEffectChance");
            _counterVBox                    = _damageValues.GetNode <VBoxContainer>("Counter");
            _counterDamageLabel             = _counterVBox.GetNode <Label>("DamageValue");
            _counterIconVBox                = _counterVBox.GetNode <VBoxContainer>("IconVBoxContainer");
            _counterTypeIcon                = _counterIconVBox.GetNode <TextureRect>("TypeIcon");
            _counterStatusIcon              = _counterIconVBox.GetNode <TextureRect>("StatusIcon");
            _counterStatusEffectChanceLabel =
                _counterIconVBox.GetNode <Label>("StatusEffectChance");
            _healthGainedHBox       = _vBox.GetNode <HBoxContainer>("HealthGainedHBox");
            _healthGainedValueLabel =
                _healthGainedHBox.GetNode <Label>("HealthGainedValueLabel");
            _confirmUsePopup = _margin.GetNode <MarginContainer>("ConfirmUsePopup");
            _backButton      =
                GetNode <TextureButton>("MarginContainer/VBoxContainer/Top/Back");
            _yesButton = GetNode <TextureButton>(
                "MarginContainer/ConfirmUsePopup/TextMargin/VBoxContainer/HBoxContainer/Yes");
            _noButton = GetNode <TextureButton>(
                "MarginContainer/ConfirmUsePopup/TextMargin/VBoxContainer/HBoxContainer/No");

            _confirmUsePopup.Visible = false;
        }
Ejemplo n.º 3
0
 public override void _Ready()
 {
     GetCommonNodes();
     _marginContainer     = _windowWrapper.GetNode <MarginContainer>("MarginContainer");
     _horizontalContainer = _marginContainer.GetNode <HBoxContainer>("HorizontalContainer");
     SetupView();
 }
 public void VelEntered(String newVal)
 {
     if (newVal.IsValidFloat())
     {
         EmitSignal("TargetVelChanged", newVal.ToFloat());
     }
     ((LineEdit)content.GetNode("VBoxContainer/Motor/TargVelInput")).ReleaseFocus();
 }
Ejemplo n.º 5
0
        public override void _Ready()
        {
            _overlayWrapper     = GetNode <MarginContainer>("MarginContainer");
            _gameStatusLabel    = _overlayWrapper.GetNode <Label>("GameStatusContainer/GameStatusLabel");
            _nicknameValue      = _overlayWrapper.GetNode <LineEdit>("VBoxContainer/NicknameLabel");
            _gameCodeValue      = _overlayWrapper.GetNode <LineEdit>("VBoxContainer/GameCodeValue");
            _codeErrorLabel     = _overlayWrapper.GetNode <Label>("VBoxContainer/CodeErrorLabel");
            _enterNicknameLabel = _overlayWrapper.GetNode <Label>("VBoxContainer/EnterNicknameLabel");
            _enterCodeLabel     = _overlayWrapper.GetNode <Label>("VBoxContainer/EnterCodeLabel");
            _startButton        = _overlayWrapper.GetNode <Button>("VBoxContainer/StartButton");

            _gameStatusLabel.Visible = false;
            _codeErrorLabel.Visible  = false;

            var font = (DynamicFont)GD.Load($"{Constants.ResourcesPath}Fonts/Montserrat/montserrat_regular.tres");

            font.Size = 25;

            _enterNicknameLabel.AddFontOverride("font", font);
            _enterCodeLabel.AddFontOverride("font", font);
            _codeErrorLabel.AddFontOverride("font", font);
            _nicknameValue.AddFontOverride("font", font);
            _gameCodeValue.AddFontOverride("font", font);
            _startButton.AddFontOverride("font", font);

            var boldFont = (DynamicFont)GD.Load($"{Constants.ResourcesPath}Fonts/Montserrat/montserrat_bold.tres");

            boldFont.Size = 55;

            _gameStatusLabel.AddFontOverride("font", boldFont);
            _gameStatusLabel.AddColorOverride("font_color", new Color("#bf5034"));

            _startButton.Connect("pressed", this, nameof(StartButtonPressed));
        }
    public void Configure(Godot.HingeJoint joint)
    {
        hideBtn = (Button)GetNode("Button");
        content = (MarginContainer)GetNode("Content");
        spacer  = (Control)GetNode("Spacer");

        hideBtn.Text = joint.Name;
        float upperLimDeg = joint.GetParam(Godot.HingeJoint.Param.LimitUpper);
        float lowerLimDeg = joint.GetParam(Godot.HingeJoint.Param.LimitLower);

        ((Label)content.GetNode("VBoxContainer/AngLimits/UpperVal")).Text =
            upperLimDeg.ToString();
        ((Label)content.GetNode("VBoxContainer/AngLimits/LowerVal")).Text =
            lowerLimDeg.ToString();
        ((LineEdit)content.GetNode("VBoxContainer/Motor/TargVelInput")).Text =
            joint.GetParam(Godot.HingeJoint.Param.MotorTargetVelocity).ToString();
        ((Label)content.GetNode("VBoxContainer/Motor/MaxImpulseVal")).Text =
            joint.GetParam(Godot.HingeJoint.Param.MotorMaxImpulse).ToString();
    }
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        hideBtn = (Button)GetNode("Button");
        content = (MarginContainer)GetNode("Content");
        spacer  = (Control)GetNode("Spacer");

        hideBtn.Connect("pressed", this, "ToggleHidden");

        content.GetNode("VBoxContainer/Motor/TargVelInput").Connect("text_entered", this, "VelEntered");
    }
Ejemplo n.º 8
0
        public override void _Ready()
        {
            GetCommonNodes();

            _marginContainer = _windowWrapper.GetNode <MarginContainer>("MarginContainer");
            _progressBarSideScrollControl = _marginContainer.GetNode <ProgressBarSideScrollControl>("ProgressBarSideScrollControl");
            _progressBarSideScrollControl.ValueChanged += ChangeValue;

            DefaultValue = 0;
            SetValue(DefaultValue);
        }
Ejemplo n.º 9
0
        protected override void SetupView()
        {
            _textureOff = (Texture)GD.Load($"{_resourcesPath}star_off.png");
            _textureOn  = (Texture)GD.Load($"{_resourcesPath}star_on.png");

            _background.Texture  = (Texture)GD.Load($"{_resourcesPath}rating_background.png");
            _background.Position = new Vector2(181, 155);

            var font = (DynamicFont)GD.Load($"{_resourcesPath}montserrat_light.tres");

            font.Size = 24;
            _title.AddFontOverride("font", font);
            _title.Text = "Ohodnotit";

            _windowWrapper.RectPosition = new Vector2(25, 10);
            _windowWrapper.Set("custom_constants/separation", 21);

            _marginContainer.Set("custom_constants/margin_left", 28);

            _horizontalContainer.Set("custom_constants/separation", 15);

            _commentsMarginContainer = _windowWrapper.GetNode <MarginContainer>("CommentsMarginContainer");
            _commentsMarginContainer.Set("custom_constants/margin_left", 7);

            _commentsContainer = _commentsMarginContainer.GetNode <VBoxContainer>("CommentsContainer");
            _commentsContainer.Set("custom_constants/separation", 15);

            var lineTexture = (Texture)GD.Load($"{_resourcesPath}line.png");
            var comments    = new string[]
            {
                "skvělé\nHana",
                "Líbí se mi tato verze.\nPetr"
            };

            foreach (var comment in comments)
            {
                var line = new TextureRect();
                line.Texture = lineTexture;

                _commentsContainer.AddChild(line);

                var margin = new MarginContainer();
                margin.Set("custom_constants/margin_left", 10);

                var label = new Label();
                label.AddFontOverride("font", font);
                label.Text = comment;

                margin.AddChild(label);
                _commentsContainer.AddChild(margin);
            }
        }
Ejemplo n.º 10
0
        public override void _Ready()
        {
            GetCommonNodes();

            _marginContainer  = _windowWrapper.GetNode <MarginContainer>("MarginContainer");
            _clickableControl = _marginContainer.GetNode <ClickableControl>("ClickableControl");

            SetupView();

            _clickableControl.Init(_textureOff, _textureOn, 0);
            _clickableControl.Selected   += OnSelected;
            _clickableControl.Deselected += OnDeselected;
        }
Ejemplo n.º 11
0
        public override void _Ready()
        {
            _teammateScene = (PackedScene)GD.Load("res://Controls/Teammate/TeammateControl.tscn");

            GetCommonNodes();

            _windowWrapper                = GetNode <VBoxContainer>("WindowWrapper");
            _verticalContainer            = _windowWrapper.GetNode <VBoxContainer>("VerticalContainer");
            _newTeammatesWrapper          = _verticalContainer.GetNode <VBoxContainer>("NewTeammatesWrapper");
            _sideScrollMarginContainer    = _newTeammatesWrapper.GetNode <MarginContainer>("SideScrollMarginContainer");
            _teammatesSideScrollControl   = _sideScrollMarginContainer.GetNode <TeammatesSideScrollControl>("TeammatesSideScrollControl");
            _marginContainer              = _verticalContainer.GetNode <MarginContainer>("MarginContainer");
            _addedTeammatesWrapper        = _marginContainer.GetNode <VBoxContainer>("AddedTeammatesWrapper");
            _teammatesHorizontalContainer = _addedTeammatesWrapper.GetNode <HBoxContainer>("TeammatesHorizontalContainer");
            _newTeammatesLabel            = _newTeammatesWrapper.GetNode <Label>("CenterContainer/NewTeammatesLabel");
            _addedTeammatesLabel          = _addedTeammatesWrapper.GetNode <Label>("AddedTeammatesLabel");
        }
Ejemplo n.º 12
0
 public override void _Ready()
 {
     _tween = GetNode <Tween>("Tween");
     _popupDisappearDelayTimer = GetNode <Timer>("PopupDisappearDelay");
     _background         = GetNode <TextureRect>("Background");
     _textMargin         = GetNode <MarginContainer>("TextMargin");
     _textVBox           = _textMargin.GetNode <VBoxContainer>("VBoxContainer");
     _itemNameLabel      = _textVBox.GetNode <Label>("Name");
     _damageMargin       = _textVBox.GetNode <MarginContainer>("DamageMargin");
     _damageValuesHBox   = _damageMargin.GetNode <HBoxContainer>("DamageValues");
     _quickDamageLabel   = _damageValuesHBox.GetNode <Label>("QuickDamage");
     _heavyDamageLabel   = _damageValuesHBox.GetNode <Label>("HeavyDamage");
     _counterDamageLabel = _damageValuesHBox.GetNode <Label>("CounterDamage");
     _healthGainedMargin =
         _textVBox.GetNode <MarginContainer>("HealthGainedMargin");
     _healthGainedLabel = _healthGainedMargin.GetNode <Label>("HealthGained");
 }
Ejemplo n.º 13
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

        // 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();
        }
    }
Ejemplo n.º 14
0
    public void UpdatePlayerScore(int score)
    {
        var playerScore = _scoreContainer.GetNode <Label>("NinePatchRect/PlayerScore");

        playerScore.Text = score.ToString();
    }
Ejemplo n.º 15
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        hideBtn = (Button)GetNode("Button");
        content = (MarginContainer)GetNode("Content");
        spacer  = (Control)GetNode("Spacer");

        hideBtn.Connect("pressed", this, "ToggleHidden");

        // Connect a lot of signals for the jog buttons
        content.GetNode("VBoxContainer/JogLin/PosX").Connect("pressed", this, "jogLinPosXPressed");
        content.GetNode("VBoxContainer/JogLin/NegX").Connect("pressed", this, "jogLinNegXPressed");
        content.GetNode("VBoxContainer/JogLin/PosY").Connect("pressed", this, "jogLinPosYPressed");
        content.GetNode("VBoxContainer/JogLin/NegY").Connect("pressed", this, "jogLinNegYPressed");
        content.GetNode("VBoxContainer/JogLin/PosZ").Connect("pressed", this, "jogLinPosZPressed");
        content.GetNode("VBoxContainer/JogLin/NegZ").Connect("pressed", this, "jogLinNegZPressed");

        content.GetNode("VBoxContainer/JogAng/PosX").Connect("pressed", this, "jogAngPosXPressed");
        content.GetNode("VBoxContainer/JogAng/NegX").Connect("pressed", this, "jogAngNegXPressed");
        content.GetNode("VBoxContainer/JogAng/PosY").Connect("pressed", this, "jogAngPosYPressed");
        content.GetNode("VBoxContainer/JogAng/NegY").Connect("pressed", this, "jogAngNegYPressed");
        content.GetNode("VBoxContainer/JogAng/PosZ").Connect("pressed", this, "jogAngPosZPressed");
        content.GetNode("VBoxContainer/JogAng/NegZ").Connect("pressed", this, "jogAngNegZPressed");
    }
Ejemplo n.º 16
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();
        }
    }