Skip to content

Commit

Permalink
feat: Copy/Pasting IStateVariables
Browse files Browse the repository at this point in the history
BREAKING CHANGE: IStateVariables & IConditionVariables have copy methods.
  • Loading branch information
christides11 committed Feb 27, 2023
1 parent 3993234 commit 7812abc
Show file tree
Hide file tree
Showing 17 changed files with 232 additions and 307 deletions.
45 changes: 45 additions & 0 deletions Assets/HnSF/Editor/StateEditor/StateTimelineEditorWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class StateTimelineEditorWindow : EditorWindow
};

public Color parentColor = new Color(0.05f, 0.05f, 0.05f);

public static IStateVariables stateVariableCopy;
public static IConditionVariables conditionVariablesCopy;

public static StateTimelineEditorWindow OpenWindow(StateTimeline stateTimeline)
{
Expand Down Expand Up @@ -176,6 +179,14 @@ public virtual void RefreshSideBar()
RefreshAll(true);
});
}
if (stateVariableCopy != null)
{
evt.menu.AppendAction("Paste", (x) =>
{
stateTimeline.AddStateVariable(stateVariableCopy);
RefreshAll(true);
});
}
});
sidebarPanel.AddManipulator(sidebarPanelMenuManipulator);

Expand Down Expand Up @@ -238,6 +249,23 @@ public virtual void SidebarSetupLabel(StateTimeline stateTimeline, int dataID, B
RemoveStateVariable(index);
RefreshAll(true);
});
evt.menu.AppendAction("Copy", (x) =>
{
CopyStateVariable(stateTimeline, index);
});
if (stateVariableCopy != null)
{
evt.menu.AppendAction("Paste in Place", (x) =>
{
PasteInPlaceStateVariable(index);
RefreshAll(true);
});
evt.menu.AppendAction("Paste as Child", (x) =>
{
PasteAsChildStateVariable(index);
RefreshAll(true);
});
}
evt.menu.AppendAction("Move Up", (x) =>
{
MoveStateVarUp(stateTimeline, dataID);
Expand All @@ -251,6 +279,23 @@ public virtual void SidebarSetupLabel(StateTimeline stateTimeline, int dataID, B
}));
}

protected virtual void CopyStateVariable(StateTimeline stateTimeline, int index)
{
stateVariableCopy = stateTimeline.CopyStateVariable(index);
}

protected virtual void PasteInPlaceStateVariable(int index)
{
if (stateVariableCopy == null) return;
stateTimeline.PasteInPlace(index, stateVariableCopy);
}

protected virtual void PasteAsChildStateVariable(int index)
{
if (stateVariableCopy == null) return;
stateTimeline.PasteAsChild(index, stateVariableCopy);
}

protected virtual void UpdateData(StateTimeline stateTimeline1, int id)
{
RefreshAll(true);
Expand Down
Loading

0 comments on commit 7812abc

Please sign in to comment.