Exemplo n.º 1
0
    public override void _Ready()
    {
        differentVersionDialog = GetNode <AcceptDialog>(DifferentVersionDialogPath);

        // Keep this node running while paused
        PauseMode = PauseModeEnum.Process;
    }
Exemplo n.º 2
0
    private void Pressed()
    {
        string path = window.GetFilePath();

        if (!path.Empty())
        {
            string fileContents = System.IO.File.ReadAllText(path);
            editor.Text = fileContents;

            // Hide unneeded
            TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
            textPreview.Hide();

            VSeparator seperator = GetNode <VSeparator>("/root/Window/VB/MainHB/VSeparator");
            seperator.Hide();
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
        this.Hide();
        addButton.Hide();
        saveButton.Show();
    }
Exemplo n.º 3
0
    public override void _Ready()
    {
        var statusUpdate = GetTree().GetNodesInGroup("PlayerStatusUpdate");

        currentPortrait   = (TextureRect)statusUpdate[0];
        currentSprite     = (TextureRect)statusUpdate[1];
        currentStatOutput = (RichTextLabel)statusUpdate[2];

        var buttons = GetTree().GetNodesInGroup("CharGenButtons");

        steps    = new CharGenStep[4];
        steps[0] = new CharGenStep(0, (Button)buttons[0]);          //Name
        steps[1] = new CharGenStep(1, (Button)buttons[1]);          //Attributes
        steps[2] = new CharGenStep(2, (Button)buttons[2]);          //Special Abilities
        steps[3] = new CharGenStep(3, (Button)buttons[3]);          //Customization

        saveCharacterButton = (Button)buttons[4];
        previousStepButton  = (Button)buttons[5];
        nextStepButton      = (Button)buttons[6];

        var nd = Owner.GetNode("CenterContainer").GetNode("NameDialog");

        nameDialog = (AcceptDialog)nd;
        SetNameDialogVisible(true);
    }
Exemplo n.º 4
0
    private void Pressed()
    {
        string path = window.GetFilePath();

        if (!path.Empty())
        {
            string fileContents = editor.Text;
            using (StreamWriter swriter = new StreamWriter(path, false))
            {
                swriter.Write(fileContents);
            }
            editor.Text = "";

            // Reapply text
            TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
            textPreview.SetTextFromFile(path);
            textPreview.Show();

            VSeparator seperator = GetNode <VSeparator>("/root/Window/VB/MainHB/VSeparator");
            seperator.Show();
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
        this.Hide();
        addButton.Show();
        editButton.Show();
    }
Exemplo n.º 5
0
    public void OpenPopup()
    {
        var popup = new AcceptDialog();

        popup.SizeFlagsHorizontal = (int)Control.SizeFlags.ExpandFill;
        popup.SizeFlagsVertical   = (int)Control.SizeFlags.ExpandFill;
        popup.PopupExclusive      = true;
        popup.WindowTitle         = "Configure snap";
        var container = new VBoxContainer();
        var snapSpin  = new SpinBox();

        snapSpin.MinValue = 0;
        snapSpin.MaxValue = 99;
        snapSpin.Step     = 0.0001f;
        snapSpin.Value    = snapLength;
        snapSpin.Connect("value_changed", this, "SetSnapLength");
        var snapHBox  = new HBoxContainer();
        var snapLabel = new Label();

        snapLabel.Text = "Snap length";
        snapHBox.AddChild(snapLabel);
        snapHBox.AddChild(snapSpin);
        container.AddChild(snapHBox);
        popup.AddChild(container);

        popup.Connect("popup_hide", popup, "queue_free");
        baseControl.AddChild(popup);

        popup.PopupCentered(new Vector2(200, 100));
    }
Exemplo n.º 6
0
    public override void _Ready()
    {
        var txts = GetTree().GetNodesInGroup("txt");

        for (int i = 0; i < txts.Count; i++)
        {
            if ((txts[i] as Node).Name == "txtEmail")
            {
                txtEmail = txts[i] as LineEdit;
            }
            else if ((txts[i] as Node).Name == "txtNome")
            {
                txtNome = txts[i] as LineEdit;
            }
            else if ((txts[i] as Node).Name == "txtSenha")
            {
                txtSenha = txts[i] as LineEdit;
            }
            else if ((txts[i] as Node).Name == "txtRSenha")
            {
                txtRSenha = txts[i] as LineEdit;
            }
        }
        carregando = GetParent().GetParent().GetNode <PopupDialog>("LoadingDialog");
        erro       = GetParent().GetParent().GetNode <AcceptDialog>("ErroDialog");
    }
Exemplo n.º 7
0
    public override void _Ready()
    {
        // Options control buttons
        resetButton = GetNode <Button>(ResetButtonPath);
        saveButton  = GetNode <Button>(SaveButtonPath);

        // Tab selector buttons
        graphicsButton    = GetNode <Button>(GraphicsButtonPath);
        soundButton       = GetNode <Button>(SoundButtonPath);
        performanceButton = GetNode <Button>(PerformanceButtonPath);
        miscButton        = GetNode <Button>(MiscButtonPath);

        // Graphics
        graphicsTab               = GetNode <Control>(GraphicsTabPath);
        vsync                     = GetNode <CheckBox>(VSyncPath);
        fullScreen                = GetNode <CheckBox>(FullScreenPath);
        msaaResolution            = GetNode <OptionButton>(MSAAResolutionPath);
        colourblindSetting        = GetNode <OptionButton>(ColourblindSettingPath);
        chromaticAberrationToggle = GetNode <CheckBox>(ChromaticAberrationTogglePath);
        chromaticAberrationSlider = GetNode <Slider>(ChromaticAberrationSliderPath);

        // Sound
        soundTab       = GetNode <Control>(SoundTabPath);
        masterVolume   = GetNode <Slider>(MasterVolumePath);
        masterMuted    = GetNode <CheckBox>(MasterMutedPath);
        musicVolume    = GetNode <Slider>(MusicVolumePath);
        musicMuted     = GetNode <CheckBox>(MusicMutedPath);
        ambianceVolume = GetNode <Slider>(AmbianceVolumePath);
        ambianceMuted  = GetNode <CheckBox>(AmbianceMutedPath);
        sfxVolume      = GetNode <Slider>(SFXVolumePath);
        sfxMuted       = GetNode <CheckBox>(SFXMutedPath);
        guiVolume      = GetNode <Slider>(GUIVolumePath);
        guiMuted       = GetNode <CheckBox>(GUIMutedPath);

        // Performance
        performanceTab           = GetNode <Control>(PerformanceTabPath);
        cloudInterval            = GetNode <OptionButton>(CloudIntervalPath);
        cloudResolution          = GetNode <OptionButton>(CloudResolutionPath);
        runAutoEvoDuringGameplay = GetNode <CheckBox>(RunAutoEvoDuringGameplayPath);

        // Misc
        miscTab                   = GetNode <Control>(MiscTabPath);
        playIntro                 = GetNode <CheckBox>(PlayIntroPath);
        playMicrobeIntro          = GetNode <CheckBox>(PlayMicrobeIntroPath);
        tutorialsEnabledOnNewGame = GetNode <CheckBox>(TutorialsEnabledOnNewGamePath);
        cheats                = GetNode <CheckBox>(CheatsPath);
        autosave              = GetNode <CheckBox>(AutoSavePath);
        maxAutosaves          = GetNode <SpinBox>(MaxAutoSavesPath);
        maxQuicksaves         = GetNode <SpinBox>(MaxQuickSavesPath);
        tutorialsEnabled      = GetNode <CheckBox>(TutorialsEnabledPath);
        customUsernameEnabled = GetNode <CheckBox>(CustomUsernameEnabledPath);
        customUsername        = GetNode <LineEdit>(CustomUsernamePath);

        backConfirmationBox     = GetNode <WindowDialog>(BackConfirmationBoxPath);
        defaultsConfirmationBox = GetNode <ConfirmationDialog>(DefaultsConfirmationBoxPath);
        errorAcceptBox          = GetNode <AcceptDialog>(ErrorAcceptBoxPath);

        selectedOptionsTab = SelectedOptionsTab.Graphics;
    }
Exemplo n.º 8
0
    private void AddEntry()
    {
        Window w    = GetNode <Window>("/root/Window");
        string path = w.GetFilePath();

        if (!path.Empty())
        {
            if (!editor.Text.Empty())
            {
                string date  = DateTime.Now.ToString("dd.MM.yy");
                bool   found = false;
                LinkedList <string> fileContents = new LinkedList <string>();

                foreach (string line in System.IO.File.ReadLines(path))
                {
                    GD.Print($"{date} in {line}? -> {line.Contains(date)}");
                    if (!found && line.Contains(date))
                    {
                        found = true;

                        fileContents.AddLast(line);
                        fileContents.AddLast($"* {editor.Text}");
                        continue;
                    }
                    fileContents.AddLast(line);
                }

                if (!found)
                {
                    // Have to add in reverse order because we're adding to the top
                    fileContents.AddFirst($"* {editor.Text}");
                    fileContents.AddFirst($"# {date}");
                }

                using (StreamWriter swriter = new StreamWriter(path, false))
                {
                    foreach (string line in fileContents)
                    {
                        swriter.WriteLine(line);
                    }
                }

                // Reapply text
                TextPreview textPreview = GetNode <TextPreview>("/root/Window/VB/MainHB/TextPreview");
                textPreview.SetTextFromFile(path);

                // Clear editor
                editor.Text = "";
            }
        }
        else
        {
            AcceptDialog ad = GetNode <AcceptDialog>("/root/Window/Notifications/NoFile");
            ad.Show();
            GD.Print("Path is not set");
        }
    }
Exemplo n.º 9
0
 public override void _Ready()
 {
     loader = GetNode<Loader>("SpaceHUD/MarginContainer/HBoxContainer/Loader");
     tutorial = GetNode<AcceptDialog>("SpaceHUD/Tutorial");
     if (!PlayerData.Instance.ViewedTutorial)
     {
         tutorial.PopupCentered();
         PlayerData.Instance.ViewedTutorial = false;
         GD.Print("Tutorial is popped");
     }
 }
Exemplo n.º 10
0
    void CloseNetwork()
    {
        SafeDisconnect("server_disconnected", this, "CloseNetwork");
        SafeDisconnect("connection_failed", this, "CloseNetwork");
        SafeDisconnect("connected_to_server", this, "Connected");
        StopGame();
        AcceptDialog acceptDialog = GetNode <AcceptDialog>("AcceptDialog");

        acceptDialog.ShowModal();
        acceptDialog.GetCloseButton().GrabFocus();
        GetTree().NetworkPeer = null;
    }
Exemplo n.º 11
0
    public override void _Ready()
    {
        loadingItem              = GetNode <Control>(LoadingItemPath);
        savesList                = GetNode <BoxContainer>(SavesListPath);
        deleteConfirmDialog      = GetNode <ConfirmationDialog>(DeleteConfirmDialogPath);
        loadOlderConfirmDialog   = GetNode <ConfirmationDialog>(LoadOlderSaveDialogPath);
        loadNewerConfirmDialog   = GetNode <ConfirmationDialog>(LoadNewerSaveDialogPath);
        loadInvalidConfirmDialog = GetNode <ConfirmationDialog>(LoadInvalidSaveDialogPath);
        loadIncompatibleDialog   = GetNode <AcceptDialog>(LoadIncompatibleDialogPath);

        listItemScene = GD.Load <PackedScene>("res://src/saving/SaveListItem.tscn");
    }
Exemplo n.º 12
0
        public void Initialize()
        {
            if (GameController.OnGodot)
            {
                CanvasLayer = new Godot.CanvasLayer
                {
                    Name  = "UILayer",
                    Layer = CanvasLayers.LAYER_GUI
                };

                _sceneTreeHolder.SceneTree.GetRoot().AddChild(CanvasLayer);
            }

            RootControl = new Control("UIRoot")
            {
                MouseFilter = Control.MouseFilterMode.Ignore
            };
            RootControl.SetAnchorPreset(Control.LayoutPreset.Wide);

            if (GameController.OnGodot)
            {
                CanvasLayer.AddChild(RootControl.SceneControl);
            }

            StateRoot = new Control("StateRoot")
            {
                MouseFilter = Control.MouseFilterMode.Ignore
            };
            StateRoot.SetAnchorPreset(Control.LayoutPreset.Wide);
            RootControl.AddChild(StateRoot);

            WindowRoot             = new Control("WindowRoot");
            WindowRoot.MouseFilter = Control.MouseFilterMode.Ignore;
            WindowRoot.SetAnchorPreset(Control.LayoutPreset.Wide);
            RootControl.AddChild(WindowRoot);

            PopupControl           = new AcceptDialog("RootPopup");
            PopupControl.Resizable = true;
            RootControl.AddChild(PopupControl);

            DebugConsole = new DebugConsole();
            RootControl.AddChild(DebugConsole);

            _debugMonitors = new DebugMonitors();
            RootControl.AddChild(_debugMonitors);

            _inputManager.SetInputCommand(EngineKeyFunctions.ShowDebugMonitors,
                                          InputCmdHandler.FromDelegate(enabled: session => { DebugMonitors.Visible = true; },
                                                                       disabled: session => { DebugMonitors.Visible = false; }));
        }
Exemplo n.º 13
0
    public override void _Ready()
    {
        loader      = GetNode <Loader>("SpaceHUD/MarginContainer/HBoxContainer/Loader");
        tutorial    = GetNode <AcceptDialog>("SpaceHUD/Tutorial");
        upgradeMenu = GetNode <CanvasLayer>("SpaceHUD").GetNode <UpgradeMain>("MainUpgradeMenu");

        upgradeMenu.Visible = false;

        if (!PlayerData.Instance.ViewedTutorial)
        {
            tutorial.PopupCentered();
            PlayerData.Instance.ViewedTutorial = false;
            GD.Print("Tutorial is popped");
        }
    }
Exemplo n.º 14
0
    public override void _Ready()
    {
        var dados = GetTree().GetNodesInGroup("dados");

        foreach (var dado in dados)
        {
            if ((dado as Node).Name == "txtEmail")
            {
                txtEmail = dado as LineEdit;
            }
            else if ((dado as Node).Name == "txtSenha")
            {
                txtSenha = dado as LineEdit;
            }
        }
        carregando = GetNode <PopupDialog>("LoadingDialog");
        erroDialog = GetNode <AcceptDialog>("SemPreencherDialog");
    }
Exemplo n.º 15
0
    public override void _Ready()

    {
        story = GetNode <AcceptDialog>("CanvasLayer/Story");

        CheckChildren(GetChildren());

        foreach (TileMap map in tileMaps)
        {
            MakeTileCollisionShapes(map);
        }

        if (!PlayerData.Instance.ViewedStory)
        {
            story.PopupCentered();
            PlayerData.Instance.ViewedStory = false;
        }
    }
Exemplo n.º 16
0
    /// <summary>
    ///   Setup the main menu.
    /// </summary>
    private void RunMenuSetup()
    {
        Background      = GetNode <TextureRect>("Background");
        guiAnimations   = GetNode <AnimationPlayer>("GUIAnimations");
        thriveLogo      = GetNode <TextureRect>(ThriveLogoPath);
        newGameButton   = GetNode <Button>(NewGameButtonPath);
        freebuildButton = GetNode <Button>(FreebuildButtonPath);

        MenuArray?.Clear();

        // Get all of menu items
        MenuArray = GetTree().GetNodesInGroup("MenuItem");

        if (MenuArray == null)
        {
            GD.PrintErr("Failed to find all the menu items!");
            return;
        }

        RandomizeBackground();

        options    = GetNode <OptionsMenu>("OptionsMenu");
        saves      = GetNode <SaveManagerGUI>("SaveManagerGUI");
        gles2Popup = GetNode <AcceptDialog>(GLES2PopupPath);

        // Load settings
        if (Settings.Instance == null)
        {
            GD.PrintErr("Failed to initialize settings.");
        }

        // Set initial menu
        SwitchMenu();

        // Easter egg message
        ToolTipHelper.RegisterToolTipForControl(
            thriveLogo, toolTipCallbacks, ToolTipManager.Instance.GetToolTip("thriveLogoEasterEgg", "mainMenu"));

        if (OS.GetCurrentVideoDriver() == OS.VideoDriver.Gles2 && !IsReturningToMenu)
        {
            gles2Popup.PopupCenteredMinsize();
        }
    }
Exemplo n.º 17
0
    public override void _Ready()

    {
        story = GetNode <AcceptDialog>("CanvasLayer/Story");

        CheckChildren(GetChildren());

        foreach (TileMap map in tileMaps)
        {
            MakeTileCollisionShapes(map);
        }

        if (!PlayerData.Instance.ViewedStory)
        {
            story.PopupCentered();
            PlayerData.Instance.ViewedStory = false;
            GD.Print("Story is popped");
        }

        Signals.PublishRoverFuelChangedEvent();
    }
Exemplo n.º 18
0
        public override void _Ready()
        {
            _payment     = GetNode <GooglePlayBilling>("GooglePlayBilling");
            _alertDialog = GetNode <AcceptDialog>("AlertDialog");
            _label       = GetNode <Label>("Label");

            if (_payment.IsAvailable)
            {
                _label.Text += $"\n\n\nTest item SKU: {TestItemSku}";

                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Connected), this, nameof(OnConnected));
                // No params.
                _payment.Connect(nameof(GooglePlayBilling.Disconnected), this, nameof(OnDisconnected));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.ConnectError), this, nameof(OnConnectError));
                // Purchases (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.PurchasesUpdated), this, nameof(OnPurchasesUpdated));
                // Response ID (int), Debug message (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseError), this, nameof(OnPurchaseError));
                // SKUs (Dictionary[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryCompleted), this, nameof(OnSkuDetailsQueryCompleted));
                // Response ID (int), Debug message (string), Queried SKUs (string[]).
                _payment.Connect(nameof(GooglePlayBilling.SkuDetailsQueryError), this, nameof(OnSkuDetailsQueryError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledged), this, nameof(OnPurchaseAcknowledged));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseAcknowledgementError), this, nameof(OnPurchaseAcknowledgementError));
                // Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumed), this, nameof(OnPurchaseConsumed));
                // Response ID (int), Debug message (string), Purchase token (string).
                _payment.Connect(nameof(GooglePlayBilling.PurchaseConsumptionError), this, nameof(OnPurchaseConsumptionError));
                _payment.StartConnection();
            }
            else
            {
                ShowAlert("Android IAP support is not enabled. Make sure you have enabled 'Custom Build' and installed and enabled the GodotGooglePlayBilling plugin in your Android export settings! This application will not work.");
            }
        }
    private void Init()
    {
        canvas      = (TextureRect)FindNode("MapImage");
        progressBar = (ProgressBar)FindNode("ProgressBar");
        progress    = (Control)FindNode("Progress");

        progressBar.MaxValue = (THREADS * 2) + 3;

        progress.Hide();

        useEarth     = (CheckBox)FindNode("UseEarth");
        save         = (Button)FindNode("Save");
        saveas       = (Button)FindNode("Save as");
        load         = (Button)FindNode("Load");
        generate     = (Button)FindNode("Generate");
        pathLabel    = (Label)FindNode("Path");
        loadDialog   = (FileDialog)FindNode("LoadDialog");
        saveasDialog = (FileDialog)FindNode("SaveAsDialog");
        saveDialog   = (AcceptDialog)FindNode("SaveDialog");

        useEarth.Pressed = USE_EARTH_IMAGE;
        useEarth.Connect("pressed", this, "Generate");

        UpdatePath();

        save.Connect("pressed", this, nameof(SaveDialog));
        saveas.Connect("pressed", this, nameof(SaveAsDialog));
        load.Connect("pressed", this, nameof(LoadDialog));

        generate.Connect("pressed", this, nameof(Generate));

        loadDialog.Connect("file_selected", this, nameof(LoadConfig));
        loadDialog.Connect("dir_selected", this, nameof(UpdateDirectory));

        saveasDialog.Connect("file_selected", this, nameof(SaveConfig));
        saveasDialog.Connect("dir_selected", this, nameof(UpdateDirectory));

        Generate();
    }
Exemplo n.º 20
0
    public override void _Ready()
    {
        GD.Randomize();

        // Get references to all the nodes we need to manipulate
        _mortar            = GetNode <Mortar>("MortarPestle/Mortar");
        _potionCircle      = GetNode <PotionCircle>("MortarPestle/Crush/PotionCircle");
        _potionReagentsBox = GetNode <VBoxContainer>("MortarPestle/PickReagents/PotionReagentsBox");
        _helpDialog        = GetNode <AcceptDialog>("HelpDialog");
        _proceedToCrush    = GetNode <Button>("MortarPestle/PickReagents/ProceedToCrush");
        _tween             = GetNode <Tween>("MortarPestle/PickReagents/Tween");
        _inventory         = GetNode <Inventory>("MortarPestle/PickReagents/Inventory");
        _inventory.SetSize(4, 4);
        _inventory.DrawPosition = new Vector2(324f, 16f);
        _inventory.CanDeselect  = false;
        _itemTooltip            = GetNode <ItemTooltip>("MortarPestle/PickReagents/ItemTooltip");
        _debugOverlay           = GetNode <DebugOverlay>("DebugOverlay");

        // Load assets needed
        _itemBtnBg      = GD.Load <Texture>("res://textures/item_slot.png");
        _singleItemSlot = GD.Load <Texture>("res://textures/single_item_slot.png");
        _smallFont      = GD.Load <DynamicFont>("res://font/small_font.tres");

        // Signal connections
        GetNode <TouchScreenButton>("HelpButton").Connect("released", this, nameof(DisplayHelpPopup));
        _proceedToCrush.Connect("pressed", this, nameof(ProceedToCrushPressed));
        _tween.Connect("tween_all_completed", this, nameof(TweenAllCompleted));
        _inventory.Connect("ItemSlotSelected", this, nameof(InventorySlotSelected));
        GetNode <Button>("MortarPestle/PickReagents/AddToPotion").Connect("pressed", this, nameof(ItemButtonReleased));

        // Adding items to simulate an inventory
        _itemList.AddRange(new Item.ItemStack[] { new Item.ItemStack(Items.BRIMSTONE, 1), new Item.ItemStack(Items.FLY_AGARIC, 3), new Item.ItemStack(Items.ELDERBERRIES, 5), new Item.ItemStack(Items.ORPIMENT, 1), new Item.ItemStack(Items.HOLLY_BERRIES, 3) });
        _inventory.UpdateSlots(_itemList);

        // Tracking stuff for debug
        _debugOverlay.TrackProperty(nameof(_mortarPestleStage), this, "MortarPestleStage");
        _debugOverlay.TrackProperty(nameof(_mortar.CurrentParticleColour), _mortar, "Splash Colour");
    }
Exemplo n.º 21
0
    public override void _Ready()
    {
        // Initialize global events
        GameState.instance.Connect("connectionFailed", this, "connectionFailed");
        GameState.instance.Connect("connectionSuccessful", this, "connectionSuccessful");
        GameState.instance.Connect("playerUpdated", this, "refreshLobby");
        GameState.instance.Connect("gameEnded", this, "gameEnded");
        GameState.instance.Connect("gameError", this, "gameError");

        // Initialize UI events
        connectPanel = (Panel)GetNode("connect");
        playersPanel = (Panel)GetNode("players");
        dialog       = (AcceptDialog)GetNode("dialog");

        // Initialize visibility
        connectPanel.Hide();
        playersPanel.Show();

        // -- Name, IP Input --
        nameEdit = (LineEdit)playersPanel.GetNode("v_container/edit_name");
        ipEdit   = (LineEdit)playersPanel.GetNode("v_container/edit_ip");

        // Players list
        playersList = (ItemList)connectPanel.GetNode("v_container/list_player");

        // -- Host --
        hostButton = (Button)playersPanel.GetNode("v_container/h_container/btn_host");
        hostButton.Connect("pressed", this, "handleHost");

        // -- Join --
        joinButton = (Button)playersPanel.GetNode("v_container/h_container/btn_join");
        joinButton.Connect("pressed", this, "handleJoin");

        // -- Start --
        startButton = (Button)connectPanel.GetNode("v_container/btn_start");
        startButton.Connect("pressed", this, "handleStart");
    }
Exemplo n.º 22
0
        public override void EnablePlugin()
        {
            base.EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            editorSettings = editorInterface.GetEditorSettings();

            errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(errorDialog);

            BottomPanel = new BottomPanel();

            bottomPanelBtn = AddControlToBottomPanel(BottomPanel, "Mono".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            menuPopup = new PopupMenu();
            menuPopup.Hide();
            menuPopup.SetAsToplevel(true);

            AddToolSubmenuItem("Mono", menuPopup);

            // TODO: Remove or edit this info dialog once Mono support is no longer in alpha
            {
                menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp);
                aboutDialog = new AcceptDialog();
                editorBaseControl.AddChild(aboutDialog);
                aboutDialog.WindowTitle = "Important: C# support is not feature-complete";

                // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
                // we'll add. Instead we add containers and a new autowrapped Label inside.

                // Main VBoxContainer (icon + label on top, checkbox at bottom)
                var aboutVBox = new VBoxContainer();
                aboutDialog.AddChild(aboutVBox);

                // HBoxContainer for icon + label
                var aboutHBox = new HBoxContainer();
                aboutVBox.AddChild(aboutHBox);

                var aboutIcon = new TextureRect();
                aboutIcon.Texture = aboutIcon.GetIcon("NodeWarning", "EditorIcons");
                aboutHBox.AddChild(aboutIcon);

                var aboutLabel = new Label();
                aboutHBox.AddChild(aboutLabel);
                aboutLabel.RectMinSize       = new Vector2(600, 150) * EditorScale;
                aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill;
                aboutLabel.Autowrap          = true;
                aboutLabel.Text =
                    "C# support in Godot Engine is in late alpha stage and, while already usable, " +
                    "it is not meant for use in production.\n\n" +
                    "Projects can be exported to Linux, macOS, Windows and Android, but not yet to iOS, HTML5 or UWP. " +
                    "Bugs and usability issues will be addressed gradually over future releases, " +
                    "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" +
                    "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" +
                    "        https://github.com/godotengine/godot/issues\n\n" +
                    "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";

                EditorDef("mono/editor/show_info_on_start", true);

                // CheckBox in main container
                aboutDialogCheckBox = new CheckBox {
                    Text = "Show this warning when starting the editor"
                };
                aboutDialogCheckBox.Connect("toggled", this, nameof(_ToggleAboutDialogOnStart));
                aboutVBox.AddChild(aboutDialogCheckBox);
            }

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                // Make sure the existing project has Api assembly references configured correctly
                CsProjOperations.FixApiHintPath(GodotSharpDirs.ProjectCsProjPath);
            }
            else
            {
                bottomPanelBtn.Hide();
                menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));

            var buildButton = new ToolButton
            {
                Text        = "Build",
                HintTooltip = "Build solution",
                FocusMode   = Control.FocusModeEnum.None
            };

            buildButton.Connect("pressed", this, nameof(_BuildSolutionPressed));
            AddControlToContainer(CustomControlContainer.Toolbar, buildButton);

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsOSX)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike())
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            exportPluginWeak = WeakRef(exportPlugin);

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }
Exemplo n.º 23
0
 public static IObservable <Unit> OnConfirm(this AcceptDialog dialog)
 {
     return(dialog.FromSignal("confirmed").AsUnitObservable());
 }
Exemplo n.º 24
0
        public override void EnablePlugin()
        {
            base.EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            _editorSettings = editorInterface.GetEditorSettings();

            _errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(_errorDialog);

            MSBuildPanel    = new MSBuildPanel();
            _bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            _menuPopup = new PopupMenu();
            _menuPopup.Hide();
            _menuPopup.SetAsToplevel(true);

            AddToolSubmenuItem("C#", _menuPopup);

            var buildSolutionShortcut = (ShortCut)EditorShortcut("mono/build_solution");

            _toolBarButton = new ToolButton
            {
                Text              = "Build",
                HintTooltip       = "Build Solution".TTR(),
                FocusMode         = Control.FocusModeEnum.None,
                Shortcut          = buildSolutionShortcut,
                ShortcutInTooltip = true
            };
            _toolBarButton.Connect("pressed", this, nameof(BuildSolutionPressed));
            AddControlToContainer(CustomControlContainer.Toolbar, _toolBarButton);

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                ApplyNecessaryChangesToSolution();
            }
            else
            {
                _bottomPanelBtn.Hide();
                _toolBarButton.Hide();
                _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            _menuPopup.Connect("id_pressed", this, nameof(_MenuOptionPressed));

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsOSX)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            _editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            _exportPluginWeak = WeakRef(exportPlugin);

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }
Exemplo n.º 25
0
 public static IObservable <string> OnCustomAction(this AcceptDialog dialog)
 {
     return(dialog.FromSignal("custom_action")
            .SelectMany(args => args.HeadOrNone().OfType <string>().ToObservable()));
 }
Exemplo n.º 26
0
    public override void _Ready()
    {
        // Options control buttons
        resetButton = GetNode <Button>(ResetButtonPath);
        saveButton  = GetNode <Button>(SaveButtonPath);

        // Tab selector buttons
        graphicsButton    = GetNode <Button>(GraphicsButtonPath);
        soundButton       = GetNode <Button>(SoundButtonPath);
        performanceButton = GetNode <Button>(PerformanceButtonPath);
        inputsButton      = GetNode <Button>(InputsButtonPath);
        miscButton        = GetNode <Button>(MiscButtonPath);

        // Graphics
        graphicsTab               = GetNode <Control>(GraphicsTabPath);
        vsync                     = GetNode <CheckBox>(VSyncPath);
        fullScreen                = GetNode <CheckBox>(FullScreenPath);
        msaaResolution            = GetNode <OptionButton>(MSAAResolutionPath);
        colourblindSetting        = GetNode <OptionButton>(ColourblindSettingPath);
        chromaticAberrationToggle = GetNode <CheckBox>(ChromaticAberrationTogglePath);
        chromaticAberrationSlider = GetNode <Slider>(ChromaticAberrationSliderPath);

        // Sound
        soundTab            = GetNode <Control>(SoundTabPath);
        masterVolume        = GetNode <Slider>(MasterVolumePath);
        masterMuted         = GetNode <CheckBox>(MasterMutedPath);
        musicVolume         = GetNode <Slider>(MusicVolumePath);
        musicMuted          = GetNode <CheckBox>(MusicMutedPath);
        ambianceVolume      = GetNode <Slider>(AmbianceVolumePath);
        ambianceMuted       = GetNode <CheckBox>(AmbianceMutedPath);
        sfxVolume           = GetNode <Slider>(SFXVolumePath);
        sfxMuted            = GetNode <CheckBox>(SFXMutedPath);
        guiVolume           = GetNode <Slider>(GUIVolumePath);
        guiMuted            = GetNode <CheckBox>(GUIMutedPath);
        languageSelection   = GetNode <OptionButton>(LanguageSelectionPath);
        resetLanguageButton = GetNode <Button>(ResetLanguageButtonPath);
        LoadLanguages(languageSelection);

        // Performance
        performanceTab           = GetNode <Control>(PerformanceTabPath);
        cloudInterval            = GetNode <OptionButton>(CloudIntervalPath);
        cloudResolution          = GetNode <OptionButton>(CloudResolutionPath);
        runAutoEvoDuringGameplay = GetNode <CheckBox>(RunAutoEvoDuringGameplayPath);

        // Inputs
        inputsTab      = GetNode <Control>(InputsTabPath);
        inputGroupList = GetNode <InputGroupList>(InputGroupListPath);
        inputGroupList.OnControlsChanged += OnControlsChanged;

        // Misc
        miscTab                   = GetNode <Control>(MiscTabPath);
        playIntro                 = GetNode <CheckBox>(PlayIntroPath);
        playMicrobeIntro          = GetNode <CheckBox>(PlayMicrobeIntroPath);
        tutorialsEnabledOnNewGame = GetNode <CheckBox>(TutorialsEnabledOnNewGamePath);
        cheats                = GetNode <CheckBox>(CheatsPath);
        autoSave              = GetNode <CheckBox>(AutoSavePath);
        maxAutoSaves          = GetNode <SpinBox>(MaxAutoSavesPath);
        maxQuickSaves         = GetNode <SpinBox>(MaxQuickSavesPath);
        tutorialsEnabled      = GetNode <CheckBox>(TutorialsEnabledPath);
        customUsernameEnabled = GetNode <CheckBox>(CustomUsernameEnabledPath);
        customUsername        = GetNode <LineEdit>(CustomUsernamePath);

        backConfirmationBox     = GetNode <AcceptDialog>(BackConfirmationBoxPath);
        defaultsConfirmationBox = GetNode <ConfirmationDialog>(DefaultsConfirmationBoxPath);
        errorAcceptBox          = GetNode <AcceptDialog>(ErrorAcceptBoxPath);

        selectedOptionsTab = SelectedOptionsTab.Graphics;

        // We're only utilizing the AcceptDialog's auto resize functionality,
        // so hide the default Ok button since it's not needed
        backConfirmationBox.GetOk().Hide();
    }
Exemplo n.º 27
0
        public override void _EnablePlugin()
        {
            base._EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            _editorSettings = editorInterface.GetEditorSettings();

            _errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(_errorDialog);

            MSBuildPanel    = new MSBuildPanel();
            _bottomPanelBtn = AddControlToBottomPanel(MSBuildPanel, "MSBuild".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            _menuPopup = new PopupMenu();
            _menuPopup.Hide();

            AddToolSubmenuItem("C#", _menuPopup);

            var buildSolutionShortcut = (Shortcut)EditorShortcut("mono/build_solution");

            _toolBarBuildButton = new Button
            {
                Text              = "Build",
                HintTooltip       = "Build Solution".TTR(),
                FocusMode         = Control.FocusModeEnum.None,
                Shortcut          = buildSolutionShortcut,
                ShortcutInTooltip = true
            };
            _toolBarBuildButton.PressedSignal += BuildSolutionPressed;
            AddControlToContainer(CustomControlContainer.Toolbar, _toolBarBuildButton);

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                ApplyNecessaryChangesToSolution();
            }
            else
            {
                _bottomPanelBtn.Hide();
                _toolBarBuildButton.Hide();
                _menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            _menuPopup.IdPressed += _MenuOptionPressed;

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsMacOS)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            _editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            _exportPluginWeak = WeakRef(exportPlugin);

            try
            {
                // At startup we make sure NuGet.Config files have our Godot NuGet fallback folder included
                NuGetUtils.AddFallbackFolderToUserNuGetConfigs(NuGetUtils.GodotFallbackFolderName, NuGetUtils.GodotFallbackFolderPath);
            }
            catch (Exception e)
            {
                GD.PushError("Failed to add Godot NuGet Offline Packages to NuGet.Config: " + e.Message);
            }

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }
Exemplo n.º 28
0
    public override void _Ready()
    {
        // Options control buttons
        resetButton = GetNode <Button>(ResetButtonPath);
        saveButton  = GetNode <Button>(SaveButtonPath);

        // Tab selector buttons
        graphicsButton    = GetNode <Button>(GraphicsButtonPath);
        soundButton       = GetNode <Button>(SoundButtonPath);
        performanceButton = GetNode <Button>(PerformanceButtonPath);
        miscButton        = GetNode <Button>(MiscButtonPath);

        // Graphics
        graphicsTab               = GetNode <Control>(GraphicsTabPath);
        vsync                     = GetNode <CheckBox>(VSyncPath);
        fullScreen                = GetNode <CheckBox>(FullScreenPath);
        msaaResolution            = GetNode <OptionButton>(MSAAResolutionPath);
        colourblindSetting        = GetNode <OptionButton>(ColourblindSettingPath);
        chromaticAberrationToggle = GetNode <CheckBox>(ChromaticAberrationTogglePath);
        chromaticAberrationSlider = GetNode <Slider>(ChromaticAberrationSliderPath);

        // Sound
        soundTab       = GetNode <Control>(SoundTabPath);
        masterVolume   = GetNode <Slider>(MasterVolumePath);
        masterMuted    = GetNode <CheckBox>(MasterMutedPath);
        musicVolume    = GetNode <Slider>(MusicVolumePath);
        musicMuted     = GetNode <CheckBox>(MusicMutedPath);
        ambianceVolume = GetNode <Slider>(AmbianceVolumePath);
        ambianceMuted  = GetNode <CheckBox>(AmbianceMutedPath);
        sfxVolume      = GetNode <Slider>(SFXVolumePath);
        sfxMuted       = GetNode <CheckBox>(SFXMutedPath);
        guiVolume      = GetNode <Slider>(GUIVolumePath);
        guiMuted       = GetNode <CheckBox>(GUIMutedPath);

        // Performance
        performanceTab  = GetNode <Control>(PerformanceTabPath);
        cloudInterval   = GetNode <OptionButton>(CloudIntervalPath);
        cloudResolution = GetNode <OptionButton>(CloudResolutionPath);

        // Misc
        miscTab          = GetNode <Control>(MiscTabPath);
        playIntro        = GetNode <CheckBox>(PlayIntroPath);
        playMicrobeIntro = GetNode <CheckBox>(PlayMicrobeIntroPath);
        tutorialsEnabled = GetNode <CheckBox>(TutorialsEnabledPath);
        cheats           = GetNode <CheckBox>(CheatsPath);
        autosave         = GetNode <CheckBox>(AutoSavePath);
        maxAutosaves     = GetNode <SpinBox>(MaxAutoSavesPath);
        maxQuicksaves    = GetNode <SpinBox>(MaxQuickSavesPath);

        backConfirmationBox     = GetNode <WindowDialog>(BackConfirmationBoxPath);
        defaultsConfirmationBox = GetNode <ConfirmationDialog>(DefaultsConfirmationBoxPath);
        errorAcceptBox          = GetNode <AcceptDialog>(ErrorAcceptBoxPath);

        selectedOptionsTab = SelectedOptionsTab.Graphics;

        // Copy settings from the singleton to serve as a copy of the last saved settings.
        savedSettings = Settings.Instance.Clone();

        // Set the initial state of the options controls to match the settings data.
        ApplySettingsToControls(savedSettings);
        CompareSettings();
    }
Exemplo n.º 29
0
    public override void _Ready()
    {
        organelleSelectionElements = GetTree().GetNodesInGroup("OrganelleSelectionElement");
        membraneSelectionElements  = GetTree().GetNodesInGroup("MembraneSelectionElement");

        reportTabButton  = GetNode <Button>(ReportTabButtonPath);
        patchMapButton   = GetNode <Button>(PatchMapButtonPath);
        cellEditorButton = GetNode <Button>(CellEditorButtonPath);

        structureTab       = GetNode <PanelContainer>(StructureTabPath);
        structureTabButton = GetNode <Button>(StructureTabButtonPath);

        appearanceTab       = GetNode <PanelContainer>(ApperanceTabPath);
        appearanceTabButton = GetNode <Button>(AppearanceTabButtonPath);

        statisticsPanel = GetNode <PanelContainer>(OrganismStatisticsPath);
        sizeLabel       = GetNode <Label>(SizeLabelPath);
        speedLabel      = GetNode <Label>(SpeedLabelPath);
        hpLabel         = GetNode <Label>(HpLabelPath);
        generationLabel = GetNode <Label>(GenerationLabelPath);

        mutationPointsLabel       = GetNode <Label>(MutationPointsLabelPath);
        mutationPointsBar         = GetNode <ProgressBar>(MutationPointsBarPath);
        mutationPointsSubtractBar = GetNode <ProgressBar>(MutationPointsSubtractBarPath);

        rigiditySlider      = GetNode <Slider>(RigiditySliderPath);
        membraneColorPicker = GetNode <ColorPicker>(MembraneColorPickerPath);

        menuButton      = GetNode <TextureButton>(MenuButtonPath);
        helpButton      = GetNode <TextureButton>(HelpButtonPath);
        undoButton      = GetNode <TextureButton>(UndoButtonPath);
        redoButton      = GetNode <TextureButton>(RedoButtonPath);
        symmetryButton  = GetNode <TextureButton>(SymmetryButtonPath);
        newCellButton   = GetNode <TextureButton>(NewCellButtonPath);
        speciesNameEdit = GetNode <LineEdit>(SpeciesNameEditPath);
        finishButton    = GetNode <Button>(FinishButtonPath);

        atpBalanceLabel     = GetNode <Label>(ATPBalanceLabelPath);
        atpProductionLabel  = GetNode <Label>(ATPProductionLabelPath);
        atpConsumptionLabel = GetNode <Label>(ATPConsumptionLabelPath);
        atpProductionBar    = GetNode <SegmentedBar>(ATPProductionBarPath);
        atpConsumptionBar   = GetNode <SegmentedBar>(ATPConsumptionBarPath);

        timeIndicator         = GetNode <Label>(TimeIndicatorPath);
        glucoseReductionLabel = GetNode <Label>(GlucoseReductionLabelPath);
        autoEvoLabel          = GetNode <Label>(AutoEvoLabelPath);
        externalEffectsLabel  = GetNode <Label>(ExternalEffectsLabelPath);
        mapDrawer             = GetNode <PatchMapDrawer>(MapDrawerPath);
        patchNothingSelected  = GetNode <Control>(PatchNothingSelectedPath);
        patchDetails          = GetNode <Control>(PatchDetailsPath);
        patchName             = GetNode <Label>(PatchNamePath);
        patchPlayerHere       = GetNode <Control>(PatchPlayerHerePath);
        patchBiome            = GetNode <Label>(PatchBiomePath);
        patchDepth            = GetNode <Label>(PatchDepthPath);
        patchTemperature      = GetNode <Label>(PatchTemperaturePath);
        patchPressure         = GetNode <Label>(PatchPressurePath);
        patchLight            = GetNode <Label>(PatchLightPath);
        patchOxygen           = GetNode <Label>(PatchOxygenPath);
        patchNitrogen         = GetNode <Label>(PatchNitrogenPath);
        patchCO2             = GetNode <Label>(PatchCO2Path);
        patchHydrogenSulfide = GetNode <Label>(PatchHydrogenSulfidePath);
        patchAmmonia         = GetNode <Label>(PatchAmmoniaPath);
        patchGlucose         = GetNode <Label>(PatchGlucosePath);
        patchPhosphate       = GetNode <Label>(PatchPhosphatePath);
        patchIron            = GetNode <Label>(PatchIronPath);
        speciesListBox       = GetNode <CollapsibleList>(SpeciesCollapsibleBoxPath);
        moveToPatchButton    = GetNode <Button>(MoveToPatchButtonPath);
        symmetryIcon         = GetNode <TextureRect>(SymmetryIconPath);

        patchTemperatureSituation     = GetNode <TextureRect>(PatchTemperatureSituationPath);
        patchLightSituation           = GetNode <TextureRect>(PatchLightSituationPath);
        patchHydrogenSulfideSituation = GetNode <TextureRect>(PatchHydrogenSulfideSituationPath);
        patchGlucoseSituation         = GetNode <TextureRect>(PatchGlucoseSituationPath);
        patchIronSituation            = GetNode <TextureRect>(PatchIronSituationPath);
        patchAmmoniaSituation         = GetNode <TextureRect>(PatchAmmoniaSituationPath);
        patchPhosphateSituation       = GetNode <TextureRect>(PatchPhosphateSituationPath);

        speedIndicator = GetNode <TextureRect>(SpeedIndicatorPath);
        hpIndicator    = GetNode <TextureRect>(HpIndicatorPath);
        sizeIndicator  = GetNode <TextureRect>(SizeIndicatorPath);

        negativeAtpPopup = GetNode <ConfirmationDialog>(NegativeAtpPopupPath);
        islandPopup      = GetNode <AcceptDialog>(IslandErrorPath);

        menu = GetNode <PauseMenu>(MenuPath);

        mapDrawer.OnSelectedPatchChanged = drawer => { UpdateShownPatchDetails(); };

        atpProductionBar.SelectedType  = SegmentedBar.Type.ATP;
        atpProductionBar.IsProduction  = true;
        atpConsumptionBar.SelectedType = SegmentedBar.Type.ATP;

        RegisterTooltips();
    }
Exemplo n.º 30
0
        public override void EnablePlugin()
        {
            base.EnablePlugin();

            if (Instance != null)
            {
                throw new InvalidOperationException();
            }
            Instance = this;

            var editorInterface   = GetEditorInterface();
            var editorBaseControl = editorInterface.GetBaseControl();

            editorSettings = editorInterface.GetEditorSettings();

            errorDialog = new AcceptDialog();
            editorBaseControl.AddChild(errorDialog);

            BottomPanel = new BottomPanel();

            bottomPanelBtn = AddControlToBottomPanel(BottomPanel, "Mono".TTR());

            AddChild(new HotReloadAssemblyWatcher {
                Name = "HotReloadAssemblyWatcher"
            });

            menuPopup = new PopupMenu();
            menuPopup.Hide();

            AddToolSubmenuItem("Mono", menuPopup);

            // TODO: Remove or edit this info dialog once Mono support is no longer in alpha
            {
                menuPopup.AddItem("About C# support".TTR(), (int)MenuOptions.AboutCSharp);
                aboutDialog = new AcceptDialog();
                editorBaseControl.AddChild(aboutDialog);
                aboutDialog.Title = "Important: C# support is not feature-complete";

                // We don't use DialogText as the default AcceptDialog Label doesn't play well with the TextureRect and CheckBox
                // we'll add. Instead we add containers and a new autowrapped Label inside.

                // Main VBoxContainer (icon + label on top, checkbox at bottom)
                var aboutVBox = new VBoxContainer();
                aboutDialog.AddChild(aboutVBox);

                // HBoxContainer for icon + label
                var aboutHBox = new HBoxContainer();
                aboutVBox.AddChild(aboutHBox);

                var aboutIcon = new TextureRect();
                aboutIcon.Texture = aboutIcon.GetThemeIcon("NodeWarning", "EditorIcons");
                aboutHBox.AddChild(aboutIcon);

                var aboutLabel = new Label();
                aboutHBox.AddChild(aboutLabel);
                aboutLabel.RectMinSize       = new Vector2(600, 150) * EditorScale;
                aboutLabel.SizeFlagsVertical = (int)Control.SizeFlags.ExpandFill;
                aboutLabel.Autowrap          = true;
                aboutLabel.Text =
                    "C# support in Godot Engine is in late alpha stage and, while already usable, " +
                    "it is not meant for use in production.\n\n" +
                    "Projects can be exported to Linux, macOS, Windows, Android, iOS and HTML5, but not yet to UWP. " +
                    "Bugs and usability issues will be addressed gradually over future releases, " +
                    "potentially including compatibility breaking changes as new features are implemented for a better overall C# experience.\n\n" +
                    "If you experience issues with this Mono build, please report them on Godot's issue tracker with details about your system, MSBuild version, IDE, etc.:\n\n" +
                    "        https://github.com/godotengine/godot/issues\n\n" +
                    "Your critical feedback at this stage will play a great role in shaping the C# support in future releases, so thank you!";

                EditorDef("mono/editor/show_info_on_start", true);

                // CheckBox in main container
                aboutDialogCheckBox = new CheckBox {
                    Text = "Show this warning when starting the editor"
                };
                aboutDialogCheckBox.Toggled += enabled =>
                {
                    bool showOnStart = (bool)editorSettings.GetSetting("mono/editor/show_info_on_start");
                    if (showOnStart != enabled)
                    {
                        editorSettings.SetSetting("mono/editor/show_info_on_start", enabled);
                    }
                };
                aboutVBox.AddChild(aboutDialogCheckBox);
            }

            if (File.Exists(GodotSharpDirs.ProjectSlnPath) && File.Exists(GodotSharpDirs.ProjectCsProjPath))
            {
                try
                {
                    // Migrate solution from old configuration names to: Debug, ExportDebug and ExportRelease
                    DotNetSolution.MigrateFromOldConfigNames(GodotSharpDirs.ProjectSlnPath);

                    var msbuildProject = ProjectUtils.Open(GodotSharpDirs.ProjectCsProjPath)
                                         ?? throw new Exception("Cannot open C# project");

                    // NOTE: The order in which changes are made to the project is important

                    // Migrate csproj from old configuration names to: Debug, ExportDebug and ExportRelease
                    ProjectUtils.MigrateFromOldConfigNames(msbuildProject);

                    // Apply the other fixes only after configurations have been migrated

                    // Make sure the existing project has the ProjectTypeGuids property (for VisualStudio)
                    ProjectUtils.EnsureHasProjectTypeGuids(msbuildProject);

                    // Make sure the existing project has Api assembly references configured correctly
                    ProjectUtils.FixApiHintPath(msbuildProject);

                    // Make sure the existing project references the Microsoft.NETFramework.ReferenceAssemblies nuget package
                    ProjectUtils.EnsureHasNugetNetFrameworkRefAssemblies(msbuildProject);

                    if (msbuildProject.HasUnsavedChanges)
                    {
                        // Save a copy of the project before replacing it
                        FileUtils.SaveBackupCopy(GodotSharpDirs.ProjectCsProjPath);

                        msbuildProject.Save();
                    }
                }
                catch (Exception e)
                {
                    GD.PushError(e.ToString());
                }
            }
            else
            {
                bottomPanelBtn.Hide();
                menuPopup.AddItem("Create C# solution".TTR(), (int)MenuOptions.CreateSln);
            }

            menuPopup.IdPressed += _MenuOptionPressed;

            var buildButton = new Button
            {
                Text        = "Build",
                HintTooltip = "Build solution",
                FocusMode   = Control.FocusModeEnum.None
            };

            buildButton.PressedSignal += _BuildSolutionPressed;
            AddControlToContainer(CustomControlContainer.Toolbar, buildButton);

            // External editor settings
            EditorDef("mono/editor/external_editor", ExternalEditorId.None);

            string settingsHintStr = "Disabled";

            if (OS.IsWindows)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudio}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsOSX)
            {
                settingsHintStr += $",Visual Studio:{(int)ExternalEditorId.VisualStudioForMac}" +
                                   $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }
            else if (OS.IsUnixLike)
            {
                settingsHintStr += $",MonoDevelop:{(int)ExternalEditorId.MonoDevelop}" +
                                   $",Visual Studio Code:{(int)ExternalEditorId.VsCode}" +
                                   $",JetBrains Rider:{(int)ExternalEditorId.Rider}";
            }

            editorSettings.AddPropertyInfo(new Godot.Collections.Dictionary
            {
                ["type"]        = Variant.Type.Int,
                ["name"]        = "mono/editor/external_editor",
                ["hint"]        = PropertyHint.Enum,
                ["hint_string"] = settingsHintStr
            });

            // Export plugin
            var exportPlugin = new ExportPlugin();

            AddExportPlugin(exportPlugin);
            exportPlugin.RegisterExportSettings();
            exportPluginWeak = WeakRef(exportPlugin);

            BuildManager.Initialize();
            RiderPathManager.Initialize();

            GodotIdeManager = new GodotIdeManager();
            AddChild(GodotIdeManager);
        }