-
Notifications
You must be signed in to change notification settings - Fork 401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tastudio Lua Branch Action Callbacks, getselectedbranch() #4216
base: master
Are you sure you want to change the base?
Changes from all commits
ed3ff8a
b26edfa
cfe9354
46ae71d
74e2628
4292983
a348b9a
77ebc46
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,14 @@ private enum BranchUndo | |
|
||
public Action<int> RemovedCallback { get; set; } | ||
|
||
public Action LoadUndoneCallback { get; set; } | ||
|
||
public Action<int> UpdateUndoneCallback { get; set; } | ||
|
||
public Action<int> RemoveUndoneCallback { get; set; } | ||
|
||
public Action<int, int> ReorderedCallback { get; set; } | ||
|
||
public TAStudio Tastudio { get; set; } | ||
|
||
public IDialogController DialogController => Tastudio.MainForm; | ||
|
@@ -358,7 +366,7 @@ private void UndoBranchToolStripMenuItem_Click(object sender, EventArgs e) | |
if (_branchUndo == BranchUndo.Load) | ||
{ | ||
LoadBranch(_backupBranch); | ||
LoadedCallback?.Invoke(Branches.IndexOf(_backupBranch)); | ||
LoadUndoneCallback?.Invoke(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quick glance at this PR and it seems you're adding a bunch more callbacks when ones already exist? Would it not be suitable to subscribe to those? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently it only properly works with undoing branch loads, because there it's possible to get that a branch action undo has been occured, since the the index of the backup branch is -1 when doing an undo load. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I understand—you're changing this callsite to differentiate it from the callsite in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's something I thought about doing too, but only have one onbranchaction method and make luaf a function that takes an integer for the index and a string for every action "save", "load", "remove", "undoload" "undoupdate" and "undoremove" and make the current deprecated. Reordering then still has it's own method. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Agreed.
That's not what Yoshi is suggesting. Just expand the existing ones a little bit to include the info on whether they come from the undo operation. Combining everything into one megacallback passing around strings is not better (tho I can't verbalize why). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because then the script author would be forced to care. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing with string would mean the user can then just make a lua table with functions and make each table index a string. Then there wouldn't be many if-statements in the callback function. |
||
Tastudio.MainForm.AddOnScreenMessage("Branch Load canceled"); | ||
} | ||
else if (_branchUndo == BranchUndo.Update) | ||
|
@@ -367,7 +375,7 @@ private void UndoBranchToolStripMenuItem_Click(object sender, EventArgs e) | |
if (branch != null) | ||
{ | ||
Branches.Replace(branch, _backupBranch); | ||
SavedCallback?.Invoke(Branches.IndexOf(_backupBranch)); | ||
UpdateUndoneCallback?.Invoke(Branches.IndexOf(_backupBranch)); | ||
Tastudio.MainForm.AddOnScreenMessage("Branch Update canceled"); | ||
} | ||
} | ||
|
@@ -385,7 +393,7 @@ private void UndoBranchToolStripMenuItem_Click(object sender, EventArgs e) | |
{ | ||
Branches.Add(_backupBranch); | ||
BranchView.RowCount = Branches.Count; | ||
SavedCallback?.Invoke(Branches.IndexOf(_backupBranch)); | ||
RemoveUndoneCallback?.Invoke(Branches.IndexOf(_backupBranch)); | ||
Tastudio.MainForm.AddOnScreenMessage("Branch Removal canceled"); | ||
} | ||
|
||
|
@@ -453,6 +461,11 @@ public void RemoveBranchExternal() | |
RemoveBranchToolStripMenuItem_Click(null, null); | ||
} | ||
|
||
public int? GetSelectedBranch() | ||
{ | ||
return BranchView.SelectionStartIndex; | ||
} | ||
|
||
public void SelectBranchExternal(int slot) | ||
{ | ||
if (Tastudio.AxisEditingMode) | ||
|
@@ -635,6 +648,7 @@ private void BranchView_CellDropped(object sender, InputRoll.CellEventArgs e) | |
: Branches[Branches.Current].Uuid; | ||
|
||
Branches.Swap(e.OldCell.RowIndex.Value, e.NewCell.RowIndex.Value); | ||
ReorderedCallback?.Invoke(e.OldCell.RowIndex.Value, e.NewCell.RowIndex.Value); | ||
int newIndex = Branches.IndexOfHash(guid); | ||
Branches.Current = newIndex; | ||
Select(newIndex, true); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use existing docs as inspiration because they suck
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What needs rewrite? LuaMethodExample or LuaMethod?