From 0f6ef723bfefc4de61b05d896767b9dbb30953d3 Mon Sep 17 00:00:00 2001 From: feos Date: Wed, 2 Dec 2015 20:15:12 +0300 Subject: [PATCH 1/2] tastudio: fix bug with ScreenshotPopupControl's alpha channel. it was forgetting to discard alpha, and when creating a bitmap it dropped anything but lua hud, since it does have alpha bits that nothing else has, and with no lua hud involved, it showed all normally, since it didn't have to drop colors with zero alpha. lol. --- BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs | 4 +--- .../tools/TAStudio/ScreenshotPopupControl.cs | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index 6c11b03a7f..cfe97bbfba 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -189,7 +189,7 @@ namespace BizHawk.Client.EmuHawk } } - public bool EditMarkerPopUp(TasMovieMarker marker) + public void EditMarkerPopUp(TasMovieMarker marker) { var markerFrame = marker.Frame; InputPrompt i = new InputPrompt @@ -209,9 +209,7 @@ namespace BizHawk.Client.EmuHawk { marker.Message = i.PromptText; UpdateValues(); - return true; } - return false; } public void UpdateValues() diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopupControl.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopupControl.cs index 10310b0f39..877da461a3 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopupControl.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopupControl.cs @@ -19,7 +19,7 @@ namespace BizHawk.Client.EmuHawk public ScreenshotPopupControl() { - SetStyle(ControlStyles.SupportsTransparentBackColor, true); + //SetStyle(ControlStyles.SupportsTransparentBackColor, true); //SetStyle(ControlStyles.Opaque, true); //this.BackColor = Color.Transparent; @@ -28,6 +28,7 @@ namespace BizHawk.Client.EmuHawk protected override void OnPaint(PaintEventArgs e) { + Branch.OSDFrameBuffer.DiscardAlpha(); var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap(); e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, DrawingHeight)); if (UserPadding > 0) From 31cc08a954d01c6da2f2bf685d630340a2c953e2 Mon Sep 17 00:00:00 2001 From: Hathor86 Date: Wed, 2 Dec 2015 22:47:24 +0100 Subject: [PATCH 2/2] More WatchList comments Finished coments on WatchList object --- .gitignore | 1 + .../BizHawk.Client.ApiHawk.csproj | 4 +- BizHawk.Client.Common/tools/Watch/Watch.cs | 32 +- .../tools/Watch/WatchList/WatchList.cs | 373 ++++++++++++------ BizHawk.Client.EmuHawk/tools/ToolManager.cs | 4 +- 5 files changed, 276 insertions(+), 138 deletions(-) diff --git a/.gitignore b/.gitignore index eb1c604da1..fc860e7b00 100644 --- a/.gitignore +++ b/.gitignore @@ -266,3 +266,4 @@ /LuaInterface/Lua/src/Release-LUAPERKS /LuaInterface/Release-LUAPERKS output/BizHawk.Client.ApiHawk.dll +output/dll/BizHawk.Client.ApiHawk.dll diff --git a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj index f4f912a555..3ecb098c69 100644 --- a/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj +++ b/BizHawk.Client.ApiHawk/BizHawk.Client.ApiHawk.csproj @@ -32,7 +32,7 @@ true - bin\x86\Debug\ + ..\output\dll\ DEBUG;TRACE full x86 @@ -40,7 +40,7 @@ MinimumRecommendedRules.ruleset - bin\x86\Release\ + ..\output\dll\ TRACE true pdbonly diff --git a/BizHawk.Client.Common/tools/Watch/Watch.cs b/BizHawk.Client.Common/tools/Watch/Watch.cs index 3f6f9b5030..2b74007322 100644 --- a/BizHawk.Client.Common/tools/Watch/Watch.cs +++ b/BizHawk.Client.Common/tools/Watch/Watch.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Diagnostics; using BizHawk.Common.NumberExtensions; using BizHawk.Emulation.Common; @@ -13,6 +14,7 @@ namespace BizHawk.Client.Common /// with a specific size (8, 16 or 32bits). /// This is an abstract class /// + [DebuggerDisplay("Note={Notes}, Value={ValueString}")] public abstract partial class Watch : IEquatable, IEquatable, @@ -68,7 +70,7 @@ namespace BizHawk.Client.Common #region Static /// - /// Generate a from a given string + /// Generate sa from a given string /// String is tab separate /// /// Entire string, tab seperated for each value Order is: @@ -138,7 +140,7 @@ namespace BizHawk.Client.Common } /// - /// Generate a new instance + /// Generates a new instance /// Can be either , , or /// /// The where you want to watch @@ -168,7 +170,7 @@ namespace BizHawk.Client.Common } /// - /// Generate a new instance + /// Generates a new instance /// Can be either , , or /// /// The where you want to watch @@ -184,7 +186,7 @@ namespace BizHawk.Client.Common } /// - /// Generate a new instance + /// Generates a new instance /// Can be either , , or /// /// The where you want to watch @@ -310,18 +312,18 @@ namespace BizHawk.Client.Common #region Abstracts /// - /// Get a list a that can be used for this + /// Gets a list a that can be used for this /// /// An enumartion that contains all valid public abstract IEnumerable AvailableTypes(); /// - /// Reset the previous value; set it to the current one + /// Resets the previous value; set it to the current one /// public abstract void ResetPrevious(); /// - /// Update the Watch (read it from + /// Updates the Watch (read it from /// public abstract void Update(); @@ -413,7 +415,7 @@ namespace BizHawk.Client.Common #endregion Protected /// - /// Set the number of changes to 0 + /// Sets the number of changes to 0 /// public void ClearChangeCount() { @@ -423,7 +425,7 @@ namespace BizHawk.Client.Common #region IEquatable /// - /// Determine if this is equals to another + /// Determines if this is equals to another /// /// The to compare /// True if both object are equals; otherwise, false @@ -446,7 +448,7 @@ namespace BizHawk.Client.Common #region IEquatable /// - /// Determine if this is equals to an instance of + /// Determines if this is equals to an instance of /// /// The to compare /// True if both object are equals; otherwise, false @@ -463,7 +465,7 @@ namespace BizHawk.Client.Common #region IComparable /// - /// Compare two together and determine wich one comes first. + /// Compares two together and determine wich one comes first. /// First we look the address and then the size /// /// The other to compare to @@ -497,7 +499,7 @@ namespace BizHawk.Client.Common #endregion IComparable /// - /// Determine if this object is Equals to another + /// Determines if this object is Equals to another /// /// The object to compare /// True if both object are equals; otherwise, false @@ -521,14 +523,14 @@ namespace BizHawk.Client.Common /// /// Hash the current watch and gets a unique value /// - /// int that can serves as a unique representation of current Watch + /// that can serves as a unique representation of current Watch public override int GetHashCode() { return this.Domain.GetHashCode() + (int)(this.Address); } /// - /// Determine if the specified can be + /// Determines if the specified can be /// used for the current /// /// you want to check @@ -539,7 +541,7 @@ namespace BizHawk.Client.Common } /// - /// Transform the current instance into a string + /// Transforms the current instance into a string /// /// A representation of the current public override string ToString() diff --git a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs index c0775068b7..d333e787f5 100644 --- a/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs +++ b/BizHawk.Client.Common/tools/Watch/WatchList/WatchList.cs @@ -85,107 +85,161 @@ namespace BizHawk.Client.Common #region Methods - [Obsolete("Use the method with single parameter instead")] - public void RefreshDomains(IMemoryDomains core, MemoryDomain domain) - { - _memoryDomains = core; - _domain = domain; + #region ICollection - _watchList.ForEach(w => - { - if (w.Domain != null) - { - w.Domain = _memoryDomains[w.Domain.Name]; - } - }); + /// + /// Adds a into the current collection + /// + /// to add + public void Add(Watch watch) + { + _watchList.Add(watch); + Changes = true; } - public void RefreshDomains(IMemoryDomains core) + /// + /// Removes all item from the current collection + /// Clear also the file name + /// + public void Clear() { - _memoryDomains = core; - Parallel.ForEach(_watchList, watch => + _watchList.Clear(); + Changes = false; + _currentFilename = string.Empty; + } + + /// + /// Determines if the current contains the + /// specified + /// + /// The object to + /// + public bool Contains(Watch watch) + { + return _watchList.Contains(watch); + } + + /// + /// Copies the elements of the current + /// into an starting at a particular index + /// + /// The one-dimension that will serve as destination to copy + /// Zero-based index where the copy should starts + /// + /// + /// + public void CopyTo(Watch[] array, int arrayIndex) + { + _watchList.CopyTo(array, arrayIndex); + } + + /// + /// Removes the first of specified + /// + /// to remove + /// True if successfully removed; otherwise, false + public bool Remove(Watch watch) + { + bool result = _watchList.Remove(watch); + if (result) { - watch.Domain = core[watch.Domain.Name]; - watch.ResetPrevious(); - watch.Update(); - watch.ClearChangeCount(); + Changes = true; } - ); + + return result; } #endregion - public string AddressFormatStr // TODO: this is probably compensating for not using the ToHex string extension - { - get - { - if (_domain != null) - { - return "{0:X" + (_domain.Size - 1).NumHexDigits() + "}"; - } + #region IList - return string.Empty; - } + /// + /// Determines the zero-base position of the specified + /// into the + /// + /// to look for + /// Zero-base position if has been found; otherwise -1 + public int IndexOf(Watch watch) + { + return _watchList.IndexOf(watch); } - public int Count + /// + /// Insert a at the specified index + /// + /// The zero-base index where the should be inserted + /// to insert + /// + public void Insert(int index, Watch watch) { - get - { - return _watchList.Count; - } + _watchList.Insert(index, watch); } - public int WatchCount + /// + /// Removes item at the specified index + /// + /// Zero-based index of the to remove + /// + public void RemoveAt(int index) { - get - { - return _watchList.Count(watch => !watch.IsSeparator); - } + _watchList.RemoveAt(index); + Changes = true; } - [Obsolete("Use count property instead")] - public int ItemCount - { - get - { - return Count; - } - } + #endregion IList - [Obsolete("Use domain from individual watch instead")] - public MemoryDomain Domain - { - get { return _domain; } - set { _domain = value; } - } - - public bool IsReadOnly { get { return false; } } - - public string CurrentFileName - { - get { return _currentFilename; } - set { _currentFilename = value; } - } - - public bool Changes { get; set; } - - public Watch this[int index] - { - get { return _watchList[index]; } - set { _watchList[index] = value; } - } + #region IEnumerable + /// + /// Returns an enumerator that iterates through the collection + /// + /// An for the current collection public IEnumerator GetEnumerator() { return _watchList.GetEnumerator(); } + /// + /// Returns an enumerator that iterates through the collection + /// + /// An for the current collection IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } + #endregion IEnumerable + + /// + /// Add an existing collection of into the current one + /// equality will be checked to avoid doubles + /// + /// of watch to merge + public void AddRange(IEnumerable watches) + { + Parallel.ForEach(watches, watch => + { + if (!_watchList.Contains(watch)) + { + _watchList.Add(watch); + } + }); + Changes = true; + } + + /// + /// Clears change count of all in the collection + /// + public void ClearChangeCounts() + { + Parallel.ForEach(_watchList, watch => watch.ClearChangeCount()); + } + + /// + /// Sort the current list based on one of the constant + /// + /// Value that specify sorting base + /// Value that define the ordering. Ascending (true) or desceding (false) public void OrderWatches(string column, bool reverse) { switch (column) @@ -324,13 +378,27 @@ namespace BizHawk.Client.Common } } - public void Clear() + /// + /// Sets WatchList's domain list to a new one + /// domain will also be refreshed + /// + /// New domains + public void RefreshDomains(IMemoryDomains core) { - _watchList.Clear(); - Changes = false; - _currentFilename = string.Empty; + _memoryDomains = core; + Parallel.ForEach(_watchList, watch => + { + watch.Domain = core[watch.Domain.Name]; + watch.ResetPrevious(); + watch.Update(); + watch.ClearChangeCount(); + } + ); } + /// + /// Updates all ine the current collection + /// public void UpdateValues() { Parallel.ForEach(_watchList, watch => @@ -339,66 +407,134 @@ namespace BizHawk.Client.Common }); } - public void Add(Watch watch) + public string AddressFormatStr // TODO: this is probably compensating for not using the ToHex string extension { - _watchList.Add(watch); - Changes = true; - } - - public void AddRange(IList watches) - { - _watchList.AddRange(watches); - Changes = true; - } - - public bool Remove(Watch watch) - { - var result = _watchList.Remove(watch); - if (result) + get { - Changes = true; - } + if (_domain != null) + { + return "{0:X" + (_domain.Size - 1).NumHexDigits() + "}"; + } - return result; - } - - public void Insert(int index, Watch watch) - { - _watchList.Insert(index, watch); - } - - public void ClearChangeCounts() - { - foreach (var watch in _watchList) - { - watch.ClearChangeCount(); + return string.Empty; } } - public bool Contains(Watch watch) + #endregion + + #region Propeties + + #region ICollection + + /// + /// Gets the number of elements contained in this + /// + public int Count { - return _watchList.Any(w => - w.Size == watch.Size && - w.Type == watch.Type && - w.Domain == watch.Domain && - w.Address == watch.Address && - w.BigEndian == watch.BigEndian); + get + { + return _watchList.Count; + } } - public void CopyTo(Watch[] array, int arrayIndex) + /// + /// is alsways read-write + /// so this value will be always false + /// + public bool IsReadOnly { - _watchList.CopyTo(array, arrayIndex); + get + { + return false; + } } - public int IndexOf(Watch watch) + #endregion ICollection + + #region IList + + /// + /// Gets or sets element at the specified index + /// + /// The zero based index of the element you want to get or set + /// at the specified index + public Watch this[int index] { - return _watchList.IndexOf(watch); + get + { + return _watchList[index]; + } + set + { + _watchList[index] = value; + } } - public void RemoveAt(int index) + #endregion IList + + /// + /// Gets a value indicating if collection has changed or not + /// + public bool Changes { get; set; } + + /// + /// Gets or sets current 's filename + /// + public string CurrentFileName { - _watchList.RemoveAt(index); - Changes = true; + get + { + return _currentFilename; + } + set + { + _currentFilename = value; + } + } + + /// + /// Gets the number of that are not + /// + public int WatchCount + { + get + { + return _watchList.Count(watch => !watch.IsSeparator); + } + } + + #endregion + + + [Obsolete("Use the method with single parameter instead")] + public void RefreshDomains(IMemoryDomains core, MemoryDomain domain) + { + _memoryDomains = core; + _domain = domain; + + _watchList.ForEach(w => + { + if (w.Domain != null) + { + w.Domain = _memoryDomains[w.Domain.Name]; + } + }); + } + + [Obsolete("Use count property instead")] + public int ItemCount + { + get + { + return Count; + } + } + + [Obsolete("Use domain from individual watch instead")] + public MemoryDomain Domain + { + get { return _domain; } + set { _domain = value; } } #region File handling logic - probably needs to be its own class @@ -608,7 +744,6 @@ namespace BizHawk.Client.Common return true; } - #endregion } } diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 53d8b4bda6..74e7fdaf9a 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -84,7 +84,7 @@ namespace BizHawk.Client.EmuHawk public T Load(string toolPath, bool focus = true) where T : class, IToolForm { - if (!IsAvailable()) + if (!IsAvailable() && typeof(T) != typeof(IExternalToolForm)) { return null; } @@ -566,7 +566,7 @@ namespace BizHawk.Client.EmuHawk //Hard stuff as we need a proxy object that inherit from MarshalByRefObject. if (toolType == typeof(IExternalToolForm)) { - if (MessageBox.Show(@"Are you sure want to load this external tool?\r\nAccept ONLY if you trust the source and if you know what you're doing. In any other case, choose no." + if (MessageBox.Show("Are you sure want to load this external tool?\r\nAccept ONLY if you trust the source and if you know what you're doing. In any other case, choose no." , "Confirmm loading", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try