From 2a1c9e8602c155e9a8b56c8676e9b8295efa4f0f Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 24 Aug 2015 18:30:45 -0400 Subject: [PATCH] TAStudio - anchor icons on frames with savestates, proof of concept. InputRoll - add offsetx,y values to queryItemIcon and queryItemText, also support ability to draw icons and text in the same cell --- .../BizHawk.Client.EmuHawk.csproj | 1 + .../Properties/Resources.Designer.cs | 12 ++++- .../Properties/Resources.resx | 3 ++ .../images/tastudio/anchor.png | Bin 0 -> 233 bytes .../tools/TAStudio/BookmarksBranchesBox.cs | 2 +- .../tools/TAStudio/InputRoll.cs | 51 +++++++++++------- .../tools/TAStudio/MarkerControl.cs | 2 +- .../tools/TAStudio/TAStudio.ListView.cs | 15 +++++- 8 files changed, 62 insertions(+), 24 deletions(-) create mode 100644 BizHawk.Client.EmuHawk/images/tastudio/anchor.png diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 6b2e6aa74a..959027469f 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -1639,6 +1639,7 @@ + diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs index 8c317b2556..d472ef228c 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs +++ b/BizHawk.Client.EmuHawk/Properties/Resources.Designer.cs @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.0 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -100,6 +100,16 @@ namespace BizHawk.Client.EmuHawk.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap anchor { + get { + object obj = ResourceManager.GetObject("anchor", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/BizHawk.Client.EmuHawk/Properties/Resources.resx b/BizHawk.Client.EmuHawk/Properties/Resources.resx index 2511965131..bc78b1645c 100644 --- a/BizHawk.Client.EmuHawk/Properties/Resources.resx +++ b/BizHawk.Client.EmuHawk/Properties/Resources.resx @@ -1497,4 +1497,7 @@ ..\images\BlankCursor.cur;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\images\tastudio\anchor.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/images/tastudio/anchor.png b/BizHawk.Client.EmuHawk/images/tastudio/anchor.png new file mode 100644 index 0000000000000000000000000000000000000000..614eaffbeffc0ba2e14554c80fdb5ace36abefaf GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqEa{HEjtmSN`?>!lvI6;>1s;*b z3=Dh+L6~vJ#O${~L5ULAh?3y^w370~qEv>0#LT=By}Z;C1rt33J+nVO$@hV3(mh=q zLo|Yu8=C%GY+w~I{&WAJz?c7w&T?FK=O?fPA7K#taqz;2|5{Vn9$Gt?wKZ|_#Qnc- z9P+>ZWB}LX6qi7TL*|m35+~hJ@Dym!cDU5Z^zXi~#^3*UYP8z?Bp51L)i}2aGfGG> Yl)efytzszO3bc~J)78&qol`;+0MlwrYXATM literal 0 HcmV?d00001 diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index ae74688a46..7281fc819c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -73,7 +73,7 @@ namespace BizHawk.Client.EmuHawk private int CurrentBranch = -1; - private void QueryItemText(int index, InputRoll.RollColumn column, out string text) + private void QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = string.Empty; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs index ef78351680..58f4b9da1c 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/InputRoll.cs @@ -366,7 +366,7 @@ namespace BizHawk.Client.EmuHawk /// /// Retrieve the text for a cell /// - public delegate void QueryItemTextHandler(int index, RollColumn column, out string text); + public delegate void QueryItemTextHandler(int index, RollColumn column, out string text, ref int offsetX, ref int offsetY); /// /// Retrieve the background color for a cell @@ -377,7 +377,7 @@ namespace BizHawk.Client.EmuHawk /// /// Retrive the image for a given cell /// - public delegate void QueryItemIconHandler(int index, RollColumn column, ref Bitmap icon); + public delegate void QueryItemIconHandler(int index, RollColumn column, ref Bitmap icon, ref int offsetX, ref int offsetY); /// /// SuuperW: Check if a given frame is a lag frame @@ -979,9 +979,11 @@ namespace BizHawk.Client.EmuHawk if (DraggingCell != null) { var text = ""; + int offsetX = 0; + int offsetY = 0; if (QueryItemText != null) { - QueryItemText(DraggingCell.RowIndex.Value, DraggingCell.Column, out text); + QueryItemText(DraggingCell.RowIndex.Value, DraggingCell.Column, out text, ref offsetX, ref offsetY); } Color bgColor = this.BackColor; @@ -999,7 +1001,7 @@ namespace BizHawk.Client.EmuHawk Gdi.SetBrush(bgColor); Gdi.FillRectangle(x1, y1, x2 - x1, y2 - y1); Gdi.PrepDrawString(this.NormalFont, this.ForeColor); - Gdi.DrawString(text, new Point(x1 + CellWidthPadding, y1 + CellHeightPadding)); + Gdi.DrawString(text, new Point(x1 + CellWidthPadding + offsetX, y1 + CellHeightPadding + offsetY)); } } @@ -1079,25 +1081,31 @@ namespace BizHawk.Client.EmuHawk Bitmap image = null; int x = 0; int y = 0; + int bitmapOffsetX = 0; + int bitmapOffsetY = 0; if (QueryItemIcon != null) - QueryItemIcon(f + startRow, columns[j], ref image); + { + QueryItemIcon(f + startRow, columns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY); + } if (image != null) { - x = RowsToPixels(i) + CellWidthPadding; - y = (j * CellHeight) + (CellHeightPadding * 2); + x = RowsToPixels(i) + CellWidthPadding + bitmapOffsetX; + y = (j * CellHeight) + (CellHeightPadding * 2) + bitmapOffsetY; Gdi.DrawBitmap(image, new Point(x, y), true); } - else - { + //else + //{ string text; - QueryItemText(f + startRow, columns[j], out text); + int strOffsetX = 0; + int strOffsetY = 0; + QueryItemText(f + startRow, columns[j], out text, ref strOffsetX, ref strOffsetY); // Center Text x = RowsToPixels(i) + (CellWidth - text.Length * _charSize.Width) / 2; y = (j * CellHeight) + CellHeightPadding - VBar.Value; - var point = new Point(x, y); + var point = new Point(x + strOffsetX, y + strOffsetY); var rePrep = false; if (SelectedItems.Contains(new Cell { Column = columns[j], RowIndex = i + startRow })) @@ -1116,7 +1124,7 @@ namespace BizHawk.Client.EmuHawk { Gdi.PrepDrawString(this.NormalFont, this.ForeColor); } - } + //} } } } @@ -1136,21 +1144,26 @@ namespace BizHawk.Client.EmuHawk RollColumn col = columns[j]; string text; + int strOffsetX = 0; + int strOffsetY = 0; Point point = new Point(col.Left.Value + xPadding, RowsToPixels(i) + CellHeightPadding); Bitmap image = null; + int bitmapOffsetX = 0; + int bitmapOffsetY = 0; + if (QueryItemIcon != null) { - QueryItemIcon(f + startRow, columns[j], ref image); + QueryItemIcon(f + startRow, columns[j], ref image, ref bitmapOffsetX, ref bitmapOffsetY); } if (image != null) { - Gdi.DrawBitmap(image, new Point(point.X, point.Y + CellHeightPadding), true); + Gdi.DrawBitmap(image, new Point(point.X + bitmapOffsetX, point.Y + bitmapOffsetY + CellHeightPadding), true); } - else - { - QueryItemText(f + startRow, columns[j], out text); + //else + //{ + QueryItemText(f + startRow, columns[j], out text, ref strOffsetX, ref strOffsetY); bool rePrep = false; if (SelectedItems.Contains(new Cell { Column = columns[j], RowIndex = f + startRow })) @@ -1161,14 +1174,14 @@ namespace BizHawk.Client.EmuHawk if (!string.IsNullOrWhiteSpace(text)) { - Gdi.DrawString(text, point); + Gdi.DrawString(text, new Point(point.X + strOffsetX, point.Y + strOffsetY)); } if (rePrep) { Gdi.PrepDrawString(this.NormalFont, this.ForeColor); } - } + //} } } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index bf16f2b32b..ed54f4856b 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -81,7 +81,7 @@ namespace BizHawk.Client.EmuHawk color = Color.White; } - private void MarkerView_QueryItemText(int index, InputRoll.RollColumn column, out string text) + private void MarkerView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { text = ""; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 81735f3057..e5447ce2b6 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -86,7 +86,7 @@ namespace BizHawk.Client.EmuHawk #region Query callbacks - private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap) + private void TasView_QueryItemIcon(int index, InputRoll.RollColumn column, ref Bitmap bitmap, ref int offsetX, ref int offsetY) { var overrideIcon = GetIconOverride(index, column); @@ -119,6 +119,16 @@ namespace BizHawk.Client.EmuHawk Properties.Resources.ts_h_arrow_green; } } + else if (columnName == FrameColumnName) + { + TasMovieRecord record = CurrentTasMovie[index]; + if (record.HasState) + { + offsetX = -2; + offsetY = 2; + bitmap = Properties.Resources.anchor; + } + } } private void TasView_QueryItemBkColor(int index, InputRoll.RollColumn column, ref Color color) @@ -183,7 +193,7 @@ namespace BizHawk.Client.EmuHawk } } - private void TasView_QueryItemText(int index, InputRoll.RollColumn column, out string text) + private void TasView_QueryItemText(int index, InputRoll.RollColumn column, out string text, ref int offsetX, ref int offsetY) { var overrideText = GetTextOverride(index, column); if (overrideText != null) @@ -207,6 +217,7 @@ namespace BizHawk.Client.EmuHawk } else if (columnName == FrameColumnName) { + offsetX = 7; text = (index).ToString().PadLeft(CurrentTasMovie.InputLogLength.ToString().Length, '0'); } else