Example #1
0
        public override void _Ready()
        {
            GetTree().SetScreenStretch(SceneTree.StretchMode.Mode2d, SceneTree.StretchAspect.Ignore, new Vector2(1920, 1080));
            OS.SetWindowMaximized(true);

            _graphEdit           = GetNode <GraphEdit>("VBoxContainer/GraphEdit");
            _resourcePreloader   = GetNode <ResourcePreloader>("ResourcePreloader");
            _eventSelectorDialog = GetNode <WindowDialog>("EventSelectorDialog");
            _nodeSelectorDialog  = GetNode <WindowDialog>("NodeSelectorDialog");
            _openFileDialog      = GetNode <FileDialog>("OpenFileDialog");
            _saveFileDialog      = GetNode <FileDialog>("SaveFileDialog");

            var eventItemList = _eventSelectorDialog.GetNode <ItemList>("VBoxContainer/ItemList");

            foreach (var key in GameEventDispatcher.GameEventMapping.Keys)
            {
                var evt = GameEventDispatcher.GameEventMapping[key];
                eventItemList.AddItem(evt.DisplayName);
            }
            eventItemList.Connect("item_activated", this, nameof(OnQuestEventItemActivated));

            var nodeItemList = _nodeSelectorDialog.GetNode <ItemList>("VBoxContainer/ItemList");

            nodeItemList.AddItem(nameof(QuestStartNode));
            nodeItemList.AddItem(nameof(QuestStageNode));
            nodeItemList.AddItem(nameof(QuestEventNode));
            nodeItemList.AddItem(nameof(QuestCompleteNode));
            nodeItemList.AddItem(nameof(QuestRewardNode));
            nodeItemList.Connect("item_activated", this, nameof(OnNodeSelectorSelected));

            GetNode("VBoxContainer/HBoxContainer/AddNode").Connect("pressed", this, nameof(OnAddNodePressed));
            GetNode("VBoxContainer/HBoxContainer/SaveButton").Connect("pressed", this, nameof(OnSaveButtonPressed));
            GetNode("VBoxContainer/HBoxContainer/OpenButton").Connect("pressed", this, nameof(OnOpenButtonPressed));

            _graphEdit.Connect("connection_request", this, nameof(OnConnectionRequest));
            _graphEdit.Connect("disconnection_request", this, nameof(OnDisconnectRequest));

            _openFileDialog.Connect("file_selected", this, nameof(OnFileSelected));
            _saveFileDialog.Connect("file_selected", this, nameof(OnSaveFileSelected));
        }
Example #2
0
        /// <summary>
        /// Emitted when the user presses Ctrl + C.
        /// </summary>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnCopyNodesRequest(this GraphEdit edit, Action action)
        {
            var callback = edit.Subscribe(CopyNodesRequestSignal, action);

            return(() => edit.Unsubscribe(CopyNodesRequestSignal, callback));
        }
Example #3
0
        /// <summary>
        /// Emitted when user dragging connection from output port into empty space of the graph.
        /// </summary>
        /// <param name="edit">This GraphEdit</param>
        /// <param name="action">action ( String from, int from_slot, Vector2 release_position )</param>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnConnectionToEmpty(this GraphEdit edit, Action <string, int, Vector2> action)
        {
            var callback = edit.Subscribe(ConnectionToEmptySignal, action);

            return(() => edit.Unsubscribe(ConnectionToEmptySignal, callback));
        }
Example #4
0
        /// <summary>
        /// Emitted to the GraphEdit when the connection between the from_slot slot of the from GraphNode
        /// and the to_slot slot of the to GraphNode is attempted to be created.
        /// </summary>
        /// <param name="edit">This GraphEdit</param>
        /// <param name="action">action ( String from, int from_slot, String to, int to_slot )</param>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnConnectionRequest(this GraphEdit edit, Action <string, int, string, int> action)
        {
            var callback = edit.Subscribe(ConnectionRequestSignal, action);

            return(() => edit.Unsubscribe(ConnectionRequestSignal, callback));
        }
Example #5
0
        /// <summary>
        /// Emitted at the end of a GraphNode movement.
        /// </summary>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnEndNodeMove(this GraphEdit edit, VoidFunc action)
        {
            var callback = edit.Subscribe(EndNodeMoveSignal, action);

            return(() => edit.Unsubscribe(EndNodeMoveSignal, callback));
        }
Example #6
0
        /// <summary>
        /// Emitted when the scroll offset is changed by the user. It will not be emitted when changed in code.
        /// </summary>
        /// <param name="edit">This GraphEdit</param>
        /// <param name="action">action ( Vector2 ofs )</param>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnScrollOffsetChanged(this GraphEdit edit, Action <Vector2> action)
        {
            var callback = edit.Subscribe(ScrollOffsetChangedSignal, action);

            return(() => edit.Unsubscribe(ScrollOffsetChangedSignal, callback));
        }
Example #7
0
        /// <summary>
        /// Emitted when a popup is requested. Happens on right-clicking in the GraphEdit.
        /// position is the position of the mouse pointer when the signal is sent.
        /// </summary>
        /// <param name="edit">This GraphEdit</param>
        /// <param name="action">action ( Vector2 position )</param>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnPopupRequest(this GraphEdit edit, Action <Vector2> action)
        {
            var callback = edit.Subscribe(PopupRequestSignal, action);

            return(() => edit.Unsubscribe(PopupRequestSignal, callback));
        }
Example #8
0
        /// <summary>
        /// Emitted when a GraphNode is unselected.
        /// </summary>
        /// <param name="edit">This GraphEdit</param>
        /// <param name="action">action ( Node node )</param>
        /// <returns>Unsubscribe callback</returns>
        public static VoidFunc OnNodeUnselected(this GraphEdit edit, Action <Node> action)
        {
            var callback = edit.Subscribe(NodeUnselectedSignal, action);

            return(() => edit.Unsubscribe(NodeUnselectedSignal, callback));
        }