tastudio: a bunch of fixes.

- update branches per RefreshDialog()
- clear selection per right click if it's beyond movie length
- fix crash when load branch is called with null selection (can't stably reproduce, but it happens)
- assign guid to branches from the right place. this required setting some statics, don't know if it was right, but it works.
This commit is contained in:
feos 2015-10-04 13:39:14 +03:00
parent e5de3bdaa7
commit 4625bdce0f
6 changed files with 29 additions and 15 deletions

View File

@ -9,6 +9,14 @@ namespace BizHawk.Client.Common
{
public class TasBranch
{
public TasBranch()
{
do
{
UniqueIdentifier = Guid.NewGuid();
} while (TasMovie.BranchIndexByHash(UniqueIdentifier.GetHashCode()) != -1);
}
public int Frame { get; set; }
public byte[] CoreData { get; set; }
public List<string> InputLog { get; set; }

View File

@ -22,7 +22,7 @@ namespace BizHawk.Client.Common
private readonly Dictionary<int, IController> InputStateCache = new Dictionary<int, IController>();
public readonly List<string> VerificationLog = new List<string>(); // For movies that do not begin with power-on, this is the input required to get into the initial state
private readonly TasBranchCollection Branches = new TasBranchCollection();
public static readonly TasBranchCollection Branches = new TasBranchCollection();
private BackgroundWorker _progressReportWorker = null;
public void NewBGWorker(BackgroundWorker newWorker)
@ -85,7 +85,7 @@ namespace BizHawk.Client.Common
public TasBranch GetBranch(int index) { return Branches[index]; }
public int BranchHashByIndex(int index) { return Branches[index].UniqueIdentifier.GetHashCode(); }
public int BranchIndexByHash(int hash)
public static int BranchIndexByHash(int hash)
{
TasBranch branch = Branches.Where(b => b.UniqueIdentifier.GetHashCode() == hash).SingleOrDefault();
if (branch == null)
@ -524,12 +524,6 @@ namespace BizHawk.Client.Common
public void AddBranch(TasBranch branch)
{
// before adding, make sure guid hash is unique too, we can't afford branch id clashes
do
{
branch.UniqueIdentifier = Guid.NewGuid();
} while (BranchIndexByHash(branch.UniqueIdentifier.GetHashCode()) != -1);
Branches.Add(branch);
TasStateManager.AddBranch();
Changes = true;

View File

@ -710,7 +710,7 @@ namespace BizHawk.Client.Common
SortedList<int, StateManagerState> stateList = BranchStates[frame];
for (int i = 0; i < _movie.BranchCount; i++)
{
if (i == _movie.BranchIndexByHash(branchHash))
if (i == TasMovie.BranchIndexByHash(branchHash))
continue;
if (stateList != null && stateList.ContainsKey(i) && stateList[i] == stateToMatch)

View File

@ -141,12 +141,11 @@ namespace BizHawk.Client.EmuHawk
private void LoadSelectedBranch()
{
int index = BranchView.SelectedRows.First();
//if (CurrentBranch == index) // if the current branch was edited, we should allow loading it. some day there might be a proper check
// return;
if (SelectedBranch != null)
{
int index = BranchView.SelectedRows.First();
//if (CurrentBranch == index) // if the current branch was edited, we should allow loading it. some day there might be a proper check
// return;
CurrentBranch = index;
LoadBranch(SelectedBranch);
BranchView.Refresh();

View File

@ -271,7 +271,6 @@ namespace BizHawk.Client.EmuHawk
{
CurrentTasMovie.Markers.Add(TasView.LastSelectedIndex.Value, "");
RefreshDialog();
}
else if (columnName != CursorColumnName) // TODO: what about float?
{
@ -541,7 +540,18 @@ namespace BizHawk.Client.EmuHawk
{
if (e.Button == MouseButtons.Right && !TasView.IsPointingAtColumnHeader && !_supressContextMenu)
{
RightClickMenu.Show(TasView, e.X, e.Y);
if (Global.MovieSession.Movie.FrameCount < TasView.SelectedRows.Max())
{
// trying to be smart here
// if a loaded branch log is shorter than selection, keep selection until you attempt to call context menu
// you might need it when you load again the branch where this frame exists
TasView.DeselectAll();
RefreshTasView();
}
else
{
RightClickMenu.Show(TasView, e.X, e.Y);
}
}
else if (e.Button == MouseButtons.Left)
{

View File

@ -594,6 +594,9 @@ namespace BizHawk.Client.EmuHawk
if (MarkerControl != null)
MarkerControl.UpdateValues();
if (BookMarkControl != null)
BookMarkControl.UpdateValues();
if (undoForm != null && !undoForm.IsDisposed)
undoForm.UpdateValues();
}