Exemplo n.º 1
0
        public void Paste(M64CopiedData copiedData, int index, bool insert, int multiplicity)
        {
            if (RawBytes == null)
            {
                return;
            }
            index = MoreMath.Clamp(index, 0, Inputs.Count);
            int  pasteCount = copiedData.TotalFrames * multiplicity;
            bool bigPaste   = pasteCount > M64Config.PasteWarningLimit;

            if (bigPaste)
            {
                if (!DialogUtilities.AskQuestionAboutM64Pasting(pasteCount))
                {
                    return;
                }
                SetPasteProgressCount(0, pasteCount);
                SetPasteProgressVisibility(true);
            }

            if (insert)
            {
                int currentPosition = _gui.DataGridViewInputs.FirstDisplayedScrollingRowIndex;
                _gui.DataGridViewInputs.DataSource = null;
                for (int i = 0; i < pasteCount; i++)
                {
                    int           insertionIndex = index + i;
                    M64InputFrame newInput       = new M64InputFrame(
                        insertionIndex, copiedData.GetRawValue(i), false, this, _gui.DataGridViewInputs);
                    Inputs.Insert(insertionIndex, newInput);
                    ModifiedFrames.Add(newInput);

                    if (bigPaste)
                    {
                        SetPasteProgressCount(i + 1, pasteCount);
                    }
                }
                RefreshInputFrames(index);
                _gui.DataGridViewInputs.DataSource = Inputs;
                Config.M64Manager.UpdateTableSettings(ModifiedFrames);
                ControlUtilities.TableGoTo(_gui.DataGridViewInputs, currentPosition);
            }
            else
            {
                List <M64InputFrame> inputsToOverwrite = Inputs.Skip(index).Take(pasteCount).ToList();
                copiedData.Apply(inputsToOverwrite);
            }

            if (bigPaste)
            {
                SetPasteProgressVisibility(false);
            }

            IsModified       = true;
            Header.NumInputs = Inputs.Count;
            RefreshInputFrames(index);
            _gui.DataGridViewInputs.Refresh();
            Config.M64Manager.UpdateSelectionTextboxes();
        }
Exemplo n.º 2
0
        public void AddPauseBufferFrames(int startIndex, int endIndex)
        {
            if (RawBytes == null)
            {
                return;
            }
            if (startIndex > endIndex)
            {
                return;
            }
            startIndex = MoreMath.Clamp(startIndex, 0, Inputs.Count - 1);
            endIndex   = MoreMath.Clamp(endIndex, 0, Inputs.Count - 1);

            for (int index = startIndex; index <= endIndex; index++)
            {
                M64CopiedData.OnePauseFrameOverwrite.Apply(Inputs[index]);
            }

            int currentPosition = _gui.DataGridViewInputs.FirstDisplayedScrollingRowIndex;

            _gui.DataGridViewInputs.DataSource = null;

            for (int index = startIndex; index <= endIndex; index++)
            {
                int currentFrame = startIndex + (index - startIndex) * 4;

                M64InputFrame newInput1 = new M64InputFrame(
                    currentFrame + 1, M64CopiedData.OneEmptyFrame.GetRawValue(0), false, this, _gui.DataGridViewInputs);
                Inputs.Insert(currentFrame + 1, newInput1);
                ModifiedFrames.Add(newInput1);

                M64InputFrame newInput2 = new M64InputFrame(
                    currentFrame + 2, M64CopiedData.OnePauseFrame.GetRawValue(0), false, this, _gui.DataGridViewInputs);
                Inputs.Insert(currentFrame + 2, newInput2);
                ModifiedFrames.Add(newInput2);

                M64InputFrame newInput3 = new M64InputFrame(
                    currentFrame + 3, M64CopiedData.OneEmptyFrame.GetRawValue(0), false, this, _gui.DataGridViewInputs);
                Inputs.Insert(currentFrame + 3, newInput3);
                ModifiedFrames.Add(newInput3);
            }

            RefreshInputFrames(startIndex);
            _gui.DataGridViewInputs.DataSource = Inputs;
            Config.M64Manager.UpdateTableSettings(ModifiedFrames);
            ControlUtilities.TableGoTo(_gui.DataGridViewInputs, currentPosition);

            IsModified       = true;
            Header.NumInputs = Inputs.Count;
            _gui.DataGridViewInputs.Refresh();
            Config.M64Manager.UpdateSelectionTextboxes();
        }
Exemplo n.º 3
0
 public static M64CopiedFrame CreateCopiedFrame(M64InputFrame input, bool useRows, string inputsList)
 {
     return(new M64CopiedFrame(
                useRows || inputsList.Contains("X") ? input.X : (sbyte?)null,
                useRows || inputsList.Contains("Y") ? input.Y : (sbyte?)null,
                useRows || inputsList.Contains("A") ? input.A : (bool?)null,
                useRows || inputsList.Contains("B") ? input.B : (bool?)null,
                useRows || inputsList.Contains("Z") ? input.Z : (bool?)null,
                useRows || inputsList.Contains("S") ? input.S : (bool?)null,
                useRows || inputsList.Contains("R") ? input.R : (bool?)null,
                useRows || inputsList.Contains("C^") ? input.C_Up : (bool?)null,
                useRows || inputsList.Contains("Cv") ? input.C_Down : (bool?)null,
                useRows || inputsList.Contains("C<") ? input.C_Left : (bool?)null,
                useRows || inputsList.Contains("C>") ? input.C_Right : (bool?)null,
                useRows || inputsList.Contains("L") ? input.L : (bool?)null,
                useRows || inputsList.Contains("D^") ? input.D_Up : (bool?)null,
                useRows || inputsList.Contains("Dv") ? input.D_Down : (bool?)null,
                useRows || inputsList.Contains("D<") ? input.D_Left : (bool?)null,
                useRows || inputsList.Contains("D>") ? input.D_Right : (bool?)null));
 }
Exemplo n.º 4
0
 public void Apply(M64InputFrame input)
 {
     if (X.HasValue)
     {
         input.X = X.Value;
     }
     if (Y.HasValue)
     {
         input.Y = Y.Value;
     }
     if (A.HasValue)
     {
         input.A = A.Value;
     }
     if (B.HasValue)
     {
         input.B = B.Value;
     }
     if (Z.HasValue)
     {
         input.Z = Z.Value;
     }
     if (S.HasValue)
     {
         input.S = S.Value;
     }
     if (R.HasValue)
     {
         input.R = R.Value;
     }
     if (C_Up.HasValue)
     {
         input.C_Up = C_Up.Value;
     }
     if (C_Down.HasValue)
     {
         input.C_Down = C_Down.Value;
     }
     if (C_Left.HasValue)
     {
         input.C_Left = C_Left.Value;
     }
     if (C_Right.HasValue)
     {
         input.C_Right = C_Right.Value;
     }
     if (L.HasValue)
     {
         input.L = L.Value;
     }
     if (D_Up.HasValue)
     {
         input.D_Up = D_Up.Value;
     }
     if (D_Down.HasValue)
     {
         input.D_Down = D_Down.Value;
     }
     if (D_Left.HasValue)
     {
         input.D_Left = D_Left.Value;
     }
     if (D_Right.HasValue)
     {
         input.D_Right = D_Right.Value;
     }
 }
Exemplo n.º 5
0
        public static void SetSpecificInputValue(
            M64InputFrame inputFrame, string headerText, bool value, int?intOnValue = null)
        {
            switch (headerText)
            {
            case "X":
                if (value)
                {
                    if (intOnValue.HasValue)
                    {
                        sbyte sbyteValue = ParsingUtilities.ParseSByteRoundingCapping(intOnValue.Value);
                        inputFrame.X = sbyteValue;
                    }
                }
                else
                {
                    inputFrame.X = 0;
                }
                break;

            case "Y":
                if (value)
                {
                    if (intOnValue.HasValue)
                    {
                        sbyte sbyteValue = ParsingUtilities.ParseSByteRoundingCapping(intOnValue.Value);
                        inputFrame.Y = sbyteValue;
                    }
                }
                else
                {
                    inputFrame.Y = 0;
                }
                break;

            case "A":
                inputFrame.A = value;
                break;

            case "B":
                inputFrame.B = value;
                break;

            case "Z":
                inputFrame.Z = value;
                break;

            case "S":
                inputFrame.S = value;
                break;

            case "R":
                inputFrame.R = value;
                break;

            case "C^":
                inputFrame.C_Up = value;
                break;

            case "Cv":
                inputFrame.C_Down = value;
                break;

            case "C<":
                inputFrame.C_Left = value;
                break;

            case "C>":
                inputFrame.C_Right = value;
                break;

            case "L":
                inputFrame.L = value;
                break;

            case "D^":
                inputFrame.D_Up = value;
                break;

            case "Dv":
                inputFrame.D_Down = value;
                break;

            case "D<":
                inputFrame.D_Left = value;
                break;

            case "D>":
                inputFrame.D_Right = value;
                break;
            }
        }