Ejemplo n.º 1
0
    public override void _Ready()
    {
        hostWindow          = GetNode <WindowDialog>("HostWindow");
        joinWindow          = GetNode <WindowDialog>("JoinWindow");
        hostPortEdit        = (LineEdit)hostWindow.FindNode("PortEdit");
        joinHostEdit        = (LineEdit)joinWindow.FindNode("HostEdit");
        joinPortEdit        = (LineEdit)joinWindow.FindNode("PortEdit");
        easyModeCheckButton = (CheckButton)FindNode("EasyModeCheckButton");

        hostPortEdit.Text           = GameSettings.Instance.ServerPort.ToString();
        joinHostEdit.Text           = GameSettings.Instance.ClientHost;
        joinPortEdit.Text           = GameSettings.Instance.ClientPort.ToString();
        easyModeCheckButton.Pressed = GameSettings.Instance.Easy;

        FindNode("ExitButton").Connect("pressed", this, nameof(OnExitButtonPressed));
        FindNode("SettingsButton").Connect("pressed", this, nameof(OnSettingsButtonPressed));
        FindNode("NewGameButton").Connect("pressed", this, nameof(OnNewGameButtonPressed));
        FindNode("HostGameButton").Connect("pressed", this, nameof(OnHostGameButtonPressed));
        FindNode("JoinGameButton").Connect("pressed", this, nameof(OnJoinGameButtonPressed));
        easyModeCheckButton.Connect("toggled", this, nameof(OnEasyModeCheckButtonPressed));

        joinWindow.Connect("popup_hide", this, nameof(OnJoinWindoPopupHide));
        joinWindow.FindNode("CancelButton").Connect("pressed", this, nameof(OnJoinWindowCancelButtonPressed));
        joinWindow.FindNode("JoinButton").Connect("pressed", this, nameof(OnJoinWindowJoinButtonPressed));
        hostWindow.Connect("popup_hide", this, nameof(OnHostWindowPopupHide));
        hostWindow.FindNode("HostButton").Connect("pressed", this, nameof(OnHostWindowHostButtonPressed));

        Signals.PlayerUpdatedEvent += OnPlayerUpdated;
        GetTree().Connect("server_disconnected", this, nameof(OnServerDisconnected));
        GetTree().Connect("connection_failed", this, nameof(OnConnectionFailed));
    }
Ejemplo n.º 2
0
 public override void _Ready()
 {
     base._Ready();
     FullScreenButton = GetNode <CheckButton>("Center2/Menu/FullScreenButton");
     if (FullScreenButton != null)
     {
         FullScreenButton.Pressed = OS.WindowFullscreen;
         FullScreenButton.Connect("pressed", this, nameof(OnFullScreenButtonPressed));
     }
     MusicSlider = GetNode <Slider>("Center2/Menu/MusicSlider");
     if (MusicSlider != null)
     {
         MusicSlider.MinValue = Audio.MinVolumeDb;
         MusicSlider.MaxValue = Audio.MaxVolumeDb;
         MusicSlider.Value    = Audio.GetMusicVolume();
         MusicSlider.Connect("value_changed", this, nameof(OnMusicSliderChanged));
     }
     SFXSlider = GetNode <Slider>("Center2/Menu/SFXSlider");
     if (SFXSlider != null)
     {
         SFXSlider.MinValue = Audio.MinVolumeDb;
         SFXSlider.MaxValue = Audio.MaxVolumeDb;
         SFXSlider.Value    = Audio.GetSFXVolume();
         SFXSlider.Connect("value_changed", this, nameof(OnSFXSliderChanged));
     }
 }
Ejemplo n.º 3
0
    public override void _Ready()
    {
        musicCheckButton         = (CheckButton)FindNode("MusicCheckButton");
        musicCheckButton.Pressed = GameSettings.Instance.PlayMusic;

        musicCheckButton.Connect("toggled", this, nameof(OnMusicCheckButtonToggled));
        ((Button)FindNode("BackButton")).Connect("pressed", this, nameof(OnBackPressed));
    }
Ejemplo n.º 4
0
    private void AddOptions(VBoxContainer options_scroll_holder)
    {
        var bcBt = new CheckButton();

        bcBt.Text = "Show Border:";
        bcBt.Connect("toggled", this, nameof(OnBorderEnabledToggled));
        bcBt.Pressed = Lib.Node.BoderEnabled;
        options_scroll_holder.AddChild(bcBt);

        options_scroll_holder.AddChild(new Label()
        {
            Text = "Border Color:"
        });
        var bcp = new ColorPickerButton();

        bcp.Connect("color_changed", this, nameof(OnNewBorderColor));
        bcp.Color = new Color(Lib.Node.BorderColorHtmlCode);
        options_scroll_holder.AddChild(bcp);

        options_scroll_holder.AddChild(new Label()
        {
            Text = "Background Color:"
        });
        var bgcp = new ColorPickerButton();

        bgcp.Connect("color_changed", this, nameof(OnNewBackgroundColor));
        bgcp.Color = new Color(Lib.Node.BackgroundColorHtmlCode);
        options_scroll_holder.AddChild(bgcp);

        var sdBt = new CheckButton();

        sdBt.Text = "Sound Enabled:";
        sdBt.Connect("toggled", this, nameof(OnSoundEnabledToggled));
        sdBt.Pressed = Lib.Node.SoundEnabled;
        options_scroll_holder.AddChild(sdBt);

        var vgBt = new CheckButton();

        vgBt.Text = "Show Vignette:";
        vgBt.Connect("toggled", this, nameof(OnVignetteEnabledToggled));
        vgBt.Pressed = Lib.Node.VignetteEnabled;
        options_scroll_holder.AddChild(vgBt);

        options_scroll_holder.AddChild(new Label()
        {
            Text = "Candle Color:"
        });
        var ccp = new ColorPickerButton();

        ccp.Connect("color_changed", this, nameof(OnNewCandleColor));
        ccp.Color = new Color(Lib.Node.CandleColorHtmlCode);
        options_scroll_holder.AddChild(ccp);
    }
Ejemplo n.º 5
0
    // Called when the node enters the scene tree for the first time.
    public override void _Ready()
    {
        // when show gui button is clicked, show or hide gui
        CheckButton showGuiBtn = (CheckButton)this.GetNode("CheckButton");

        showGuiBtn.Connect("pressed", this, nameof(OnShowGuiPressed));

        // when create creatures button is clicked, emit signal
        Button createCreaturesBtn = (Button)this.GetNode("TabContainer/Creature/Panel/Panel/Button");

        createCreaturesBtn.Connect("pressed", this, nameof(OnCreateCreaturesPressed));

        // when update food button is clicked, emit signal
        Button updateFoodBtn = (Button)this.GetNode("TabContainer/World/Panel/Panel/Button");

        updateFoodBtn.Connect("pressed", this, nameof(OnUpdateFoodSpawnRatePressed));

        // when time scale slider is changed, emit signal
        HSlider timeSlider = (HSlider)this.GetNode("TabContainer/World/Panel/Panel2/HSlider");

        timeSlider.Connect("value_changed", this, nameof(OnTimeSliderValueChanged));

        // when bounds is changed, emit signal
        Button updateBoundsBtn = this.GetNode <Button>("TabContainer/World/Panel/Panel3/Button");

        updateBoundsBtn.Connect("pressed", this, nameof(OnUpdateBoundsPressed));

        // when paint food button is clicked, emit signal
        Button paintFoodBtn = this.GetNode <Button>("TabContainer/World/Panel/Panel/Button2");

        paintFoodBtn.Connect("pressed", this, nameof(OnPaintFoodClicked));

        // when create creature button is clicked, emit signal
        Button createCreatureBtn = this.GetNode <Button>("TabContainer/Creature/Panel/Panel2/Button");

        createCreatureBtn.Connect("pressed", this, nameof(OnCreateCreaturePressed));

        Button selectCreatureBtn = this.GetNode <Button>("TabContainer/Stats/Panel/Panel2/Button");

        selectCreatureBtn.Connect("pressed", this, nameof(OnSelectCreaturePressed));
    }