/// <summary>
 /// Updates the visible nodes according to the given step type.
 /// </summary>
 public void UpdateStep(PatchEntity data, Sfc2dEditorControl context)
 {
     if (data.SfcStepType != _currentStepType || _stepNode == null)
     {
         ShowStepAs(data.SfcStepType);
         _currentStepType = data.SfcStepType;
     }
     _stepNode.SetEditorText(data.StepName, context);
 }
Exemplo n.º 2
0
 /// <summary>
 /// Updates the patch nodes according to the given data
 /// </summary>
 public void UpdateNodes(PatchEntity data)
 {
     GetNode <SfcStepNode>("SfcStepNode").UpdateStep(data, SfcPatchControl.Master);
     GetNode <SfcLineButton>("SfcLineButtonTop").UpdateBranchLine(data.UpperBranch);
     GetNode <SfcLineButton>("SfcLineButtonBot").UpdateBranchLine(data.LowerBranch);
     GetNode <SfcTransitionNode>("SfcTransition").UpdateTransition(data.TransitionText, SfcPatchControl.Master);
     GetNode <ActionEditorBox>("ActionEditorBox").UpdateActions(data, SfcPatchControl.Master.Data);
     GetNode <SfcConnectionLine>("SfcConnectionLine").UpdateLine(data, SfcPatchControl);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called only once when the node is created by the patch control.
 /// </summary>
 public void InitializeWith(SfcPatchControl sfcPatchControl, PatchEntity data, bool isEditable)
 {
     SfcPatchControl = sfcPatchControl;
     SetCellPosition(data.X, data.Y);
     GetNode <SfcTransitionNode>("SfcTransition").Initialise();
     GetNode <ActionEditorBox>("ActionEditorBox").InitializeWith(SfcPatchControl, isEditable);
     Connect("mouse_entered", this, nameof(OnMouseEntered));
     Connect("mouse_exited", this, nameof(OnMouseExited));
     GetNode <Control>("MouseFilterEdit").Visible = !isEditable;
 }
        /// <summary>
        /// Constructor. It will add the patch to the 2d editor.
        /// </summary>
        public SfcPatchControl(PatchEntity data, Sfc2dEditorControl control, bool isEditable)
        {
            Data         = data;
            Master       = control;
            SfcPatchMeta = new SfcPatchMeta();
            Node node = ((PackedScene)GD.Load(_patchReferencePath)).Instance();

            SfcPatchNode = (SfcPatchNode)node;
            SfcPatchNode.InitializeWith(this, data, isEditable);
            control.ReferenceRect.AddChild(SfcPatchNode);
        }
Exemplo n.º 5
0
 /// <summary>
 /// Ensures that a relevant patch has at least an empty patch on each side.
 /// </summary>
 private void EnsureNeighbours(PatchEntity patchData)
 {
     EnsurePatchAt(patchData.X + 1, patchData.Y);
     EnsurePatchAt(patchData.X + 1, patchData.Y + 1);
     EnsurePatchAt(patchData.X, patchData.Y + 1);
     EnsurePatchAt(patchData.X - 1, patchData.Y + 1);
     EnsurePatchAt(patchData.X - 1, patchData.Y);
     EnsurePatchAt(patchData.X - 1, patchData.Y - 1);
     EnsurePatchAt(patchData.X, patchData.Y - 1);
     EnsurePatchAt(patchData.X + 1, patchData.Y - 1);
 }
Exemplo n.º 6
0
 private void SetupDefaultSFC()
 {
     if (Data.SfcEntity.Lookup(1, 0) == null)
     {
         PatchEntity entity = new PatchEntity(1, 1)
         {
             SfcStepType = StepType.StartingStep
         };
         Data.SfcEntity.AddPatch(entity);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Ensures that a patch field is aviable at the given position.
        /// </summary>
        private void EnsurePatchAt(int x, int y)
        {
            PatchEntity patch = Data.SfcEntity.Lookup(x, y);

            if (patch == null)
            {
                Data.SfcEntity.CreatePatchAt((short)x, (short)y);
                patch = Data.SfcEntity.Lookup(x, y);
                SfcPatchControl control = new SfcPatchControl(patch, this, _isEditable);
                _controlMap.Add(patch.Key, control);
            }
        }
        /// <summary>
        /// Loads the data from the stream. Written in "WriteTo".
        /// </summary>
        private void ReadFrom(BinaryReader reader)
        {
            PersistenceCheckHelper.CheckSectionNumber(reader, 0x11111111);
            _patchMap.Clear();
            int count = reader.ReadInt32();

            for (int i = 0; i < count; i++)
            {
                PatchEntity entity = PatchEntity.CreateFrom(reader);
                AddPatch(entity);
            }
        }
        /// <summary>
        /// Loads the data from the stream. Written in "WriteTo".
        /// </summary>
        public static PatchEntity CreateFrom(System.IO.BinaryReader reader)
        {
            short       x      = reader.ReadInt16();
            short       y      = reader.ReadInt16();
            PatchEntity entity = new PatchEntity(x, y)
            {
                SfcStepType    = (StepType)reader.ReadInt32(),
                StepName       = reader.ReadString(),
                UpperBranch    = (BranchType)reader.ReadInt32(),
                LowerBranch    = (BranchType)reader.ReadInt32(),
                TransitionText = reader.ReadString()
            };
            int entryCount = reader.ReadInt32();

            for (int i = 0; i < entryCount; i++)
            {
                ActionEntity entry = ActionEntity.CreateFrom(reader);
                entity.ActionEntries.Add(entry);
            }
            return(entity);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Called when the model has changed or is initialized.
 /// </summary>
 public void UpdateActions(PatchEntity entity, IProcessingData context)
 {
     UpdateVisibility(entity);
     for (int i = 0; i < entity.ActionEntries.Count; i++)
     {
         if (i >= _actionEditors.Count)
         {
             AddActionEditor(context);
         }
         _actionEditors[i].UpdateAction(entity.ActionEntries[i], context);
     }
     if (_isEditable)
     {
         if (entity.ActionEntries.Count >= _actionEditors.Count)
         {
             AddActionEditor(context);
         }
         _actionEditors[entity.ActionEntries.Count].ResetAction();
         for (int i = entity.ActionEntries.Count + 1; i < _actionEditors.Count; i++)
         {
             RemoveActionEditor(_actionEditors[i]);
         }
     }
 }
Exemplo n.º 11
0
 private void UpdateVisibility(PatchEntity entity)
 {
     Visible = entity.ContainsRealStep();
 }
 /// <summary>
 /// Called when the model has changed or is initialized.
 /// </summary>
 public void UpdateLine(PatchEntity entity, SfcPatchControl control)
 {
     GetNode <ColorRect>("TransitionLineTop").Visible = entity.SfcStepType != StepType.Unused && entity.SfcStepType != StepType.Jump;
     GetNode <ColorRect>("TransitionLineMid").Visible = entity.ContainsTransition() || control.SfcPatchMeta.HasPossibleTransitionSkip;
     GetNode <ColorRect>("TransitionLineBot").Visible = control.SfcPatchMeta.RequestsLowerStepConnection;
 }
        /// <summary>
        /// Adds the patch to the data map
        /// </summary>
        public void AddPatch(PatchEntity patch)
        {
            int key = CalculateMapKey(patch.X, patch.Y);

            _patchMap.Add(key, patch);
        }
        /// <summary>
        /// Creates a new patch at the given position and adds it to the map.
        /// </summary>
        public void CreatePatchAt(short x, short y)
        {
            PatchEntity entity = new PatchEntity(x, y);

            AddPatch(entity);
        }