attempt to reconstruct reorg with history

This commit is contained in:
zeromus 2013-10-25 00:57:23 +00:00
parent 249ddea268
commit 1a2b2c3dc5
166 changed files with 5989 additions and 10235 deletions

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
using BizHawk.Client.Common;
//some helpful p/invoke from http://www.codeproject.com/KB/audio-video/Motion_Detection.aspx?msg=1142967
namespace BizHawk.MultiClient

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
/// <summary>

View File

@ -5,6 +5,8 @@ using System.Text;
using System.IO;
using System.Drawing;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.AVOut
{
public class GifWriter : IVideoWriter

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.AVOut
{
public partial class GifWriterForm : Form

View File

@ -7,6 +7,8 @@ using System.Text;
using ICSharpCode.SharpZipLib.Zip.Compression.Streams;
using ICSharpCode.SharpZipLib.Zip.Compression;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
/// <summary>

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
/// <summary>

View File

@ -4,6 +4,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class ArchiveChooser : Form

View File

@ -60,6 +60,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<UseVSHostingProcess>false</UseVSHostingProcess>
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
<DefineConstants>WINDOWS</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<NoWin32Manifest>true</NoWin32Manifest>
@ -159,8 +160,6 @@
<Compile Include="BizBox.Designer.cs">
<DependentUpon>BizBox.cs</DependentUpon>
</Compile>
<Compile Include="Config.cs" />
<Compile Include="ConfigService.cs" />
<Compile Include="config\AutofireConfig.cs">
<SubType>Form</SubType>
</Compile>
@ -194,6 +193,12 @@
<Compile Include="config\FirmwaresConfig.Designer.cs">
<DependentUpon>FirmwaresConfig.cs</DependentUpon>
</Compile>
<Compile Include="config\FirmwaresConfigInfo.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="config\FirmwaresConfigInfo.Designer.cs">
<DependentUpon>FirmwaresConfigInfo.cs</DependentUpon>
</Compile>
<Compile Include="config\GifAnimator.cs">
<SubType>Form</SubType>
</Compile>
@ -240,12 +245,44 @@
<Compile Include="config\SoundConfig.Designer.cs">
<DependentUpon>SoundConfig.cs</DependentUpon>
</Compile>
<Compile Include="CoreFileProvider.cs" />
<Compile Include="CustomControls\FolderBrowserDialogEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\HexTextBox.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\InputConfigBase.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CustomControls\MiscControls.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\QuickProgressPopup.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CustomControls\QuickProgressPopup.Designer.cs">
<DependentUpon>QuickProgressPopup.cs</DependentUpon>
</Compile>
<Compile Include="CustomControls\SmartTextBoxControl.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\TextDebugView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\ToolStripEx.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\Util.cs" />
<Compile Include="CustomControls\ViewportPanel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\VirtualListView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="CustomControls\Win32.cs" />
<Compile Include="DisplayManager\DisplayManager.cs" />
<Compile Include="DisplayManager\Filters\Hq2x.cs" />
<Compile Include="FirmwareManager.cs" />
<Compile Include="Global.cs" />
<Compile Include="HawkFile.cs" />
<Compile Include="GlobalWinF.cs" />
<Compile Include="Input\ControllerBinding.cs" />
<Compile Include="Input\GamePad.cs" Condition=" '$(OS)' == 'Windows_NT' " />
<Compile Include="Input\GamePad360.cs" />
@ -271,7 +308,6 @@
<Compile Include="movie\EditCommentsForm.Designer.cs">
<DependentUpon>EditCommentsForm.cs</DependentUpon>
</Compile>
<Compile Include="movie\InputAdapters.cs" />
<Compile Include="Input\Keyboard.cs" Condition=" '$(OS)' == 'Windows_NT' " />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
@ -289,13 +325,7 @@
<Compile Include="movie\EditSubtitlesForm.Designer.cs">
<DependentUpon>EditSubtitlesForm.cs</DependentUpon>
</Compile>
<Compile Include="movie\Movie.cs" />
<Compile Include="movie\MovieHeader.cs" />
<Compile Include="movie\MovieImport.cs" />
<Compile Include="movie\MovieLog.cs" />
<Compile Include="movie\MovieMnemonics.cs" />
<Compile Include="movie\MovieSession.cs" />
<Compile Include="movie\MultitrackRecording.cs" />
<Compile Include="movie\PlayMovie.cs">
<SubType>Form</SubType>
</Compile>
@ -308,8 +338,6 @@
<Compile Include="movie\RecordMovie.Designer.cs">
<DependentUpon>RecordMovie.cs</DependentUpon>
</Compile>
<Compile Include="movie\Subtitle.cs" />
<Compile Include="movie\SubtitleList.cs" />
<Compile Include="movie\SubtitleMaker.cs">
<SubType>Form</SubType>
</Compile>
@ -325,7 +353,6 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="tools\Cheats\Cheat.cs" />
<Compile Include="tools\Cheats\CheatEdit.cs">
<SubType>UserControl</SubType>
</Compile>
@ -338,7 +365,6 @@
<Compile Include="tools\Cheats\CheatForm.Designer.cs">
<DependentUpon>CheatForm.cs</DependentUpon>
</Compile>
<Compile Include="tools\Cheats\CheatList.cs" />
<Compile Include="tools\GBA\GBAGPUView.cs">
<SubType>Form</SubType>
</Compile>
@ -708,7 +734,6 @@
<Compile Include="tools\Watch\RamWatch.Designer.cs">
<DependentUpon>RamWatch.cs</DependentUpon>
</Compile>
<Compile Include="tools\Watch\Watch.cs" />
<Compile Include="tools\Watch\WatchEditor.cs">
<SubType>Form</SubType>
</Compile>
@ -745,6 +770,9 @@
<EmbeddedResource Include="config\FirmwaresConfig.resx">
<DependentUpon>FirmwaresConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\FirmwaresConfigInfo.resx">
<DependentUpon>FirmwaresConfigInfo.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="config\GifAnimator.resx">
<DependentUpon>GifAnimator.cs</DependentUpon>
</EmbeddedResource>
@ -760,6 +788,12 @@
<EmbeddedResource Include="config\RewindConfig.resx">
<DependentUpon>RewindConfig.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CustomControls\InputConfigBase.resx">
<DependentUpon>InputConfigBase.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CustomControls\QuickProgressPopup.resx">
<DependentUpon>QuickProgressPopup.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
<SubType>Designer</SubType>
@ -955,9 +989,7 @@
<Compile Include="tools\InputPrompt.Designer.cs">
<DependentUpon>InputPrompt.cs</DependentUpon>
</Compile>
<Compile Include="RecentFiles.cs" />
<Compile Include="RenderPanel.cs" />
<Compile Include="RomGame.cs" />
<Compile Include="ScreenSaver.cs" />
<Compile Include="Sound.cs" />
<Compile Include="tools\TAStudio.cs">
@ -974,14 +1006,14 @@
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BizHawk.Client.Common\BizHawk.Client.Common.csproj">
<Project>{24A0AA3C-B25F-4197-B23D-476D6462DBA0}</Project>
<Name>BizHawk.Client.Common</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Emulation\BizHawk.Emulation.csproj">
<Project>{197D4314-8A9F-49BA-977D-54ACEFAEB6BA}</Project>
<Name>BizHawk.Emulation</Name>
</ProjectReference>
<ProjectReference Include="..\BizHawk.Util\BizHawk.Util.csproj">
<Project>{EE135301-08B3-4EFC-A61C-1C53E1C65CB9}</Project>
<Name>BizHawk.Util</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AboutBox.resx">

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +0,0 @@
using System;
using System.IO;
using System.Reflection;
using System.Windows.Forms;
using Newtonsoft.Json;
namespace BizHawk.MultiClient
{
public static class ConfigService
{
public static T Load<T>(string filepath, T currentConfig) where T : new()
{
T config = new T();
try
{
var file = new FileInfo(filepath);
if (file.Exists)
using (var reader = file.OpenText())
{
var s = new JsonSerializer {SuppressMissingMemberException = true, SuppressDuplicateMemberException = true};
var r = new JsonReader(reader);
config = (T)s.Deserialize(r, typeof(T));
}
}
catch (Exception e) { MessageBox.Show(e.ToString(), "Config Error"); }
if (config == null) return new T();
//patch up arrays in the config with the minimum number of things
foreach(var fi in typeof(T).GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public))
if (fi.FieldType.IsArray)
{
Array aold = fi.GetValue(currentConfig) as Array;
Array anew = fi.GetValue(config) as Array;
if (aold.Length == anew.Length) continue;
//create an array of the right size
Array acreate = Array.CreateInstance(fi.FieldType.GetElementType(), Math.Max(aold.Length,anew.Length));
//copy the old values in, (presumably the defaults), and then copy the new ones on top
Array.Copy(aold, acreate, Math.Min(aold.Length,acreate.Length));
Array.Copy(anew, acreate, Math.Min(anew.Length, acreate.Length));
//stash it into the config struct
fi.SetValue(config, acreate);
}
return config;
}
public static void Save(string filepath, object config)
{
var file = new FileInfo(filepath);
using (var writer = file.CreateText())
{
var s = new JsonSerializer();
var w = new JsonWriter(writer) { Formatting = Formatting.Indented };
s.Serialize(w, config);
}
}
}
}

View File

@ -1,28 +0,0 @@
using System;
using System.IO;
using System.Collections.Generic;
namespace BizHawk.MultiClient
{
class CoreFileProvider : ICoreFileProvider
{
public string SubfileDirectory;
public FirmwareManager FirmwareManager;
public Stream OpenFirmware(string sysId, string key)
{
var fn = PathFirmware(sysId, key);
return new FileStream(fn, FileMode.Open, FileAccess.Read, FileShare.Read);
}
public string PathFirmware(string sysId, string key)
{
return FirmwareManager.Request(sysId, key);
}
public string PathSubfile(string fname)
{
return Path.Combine(Path.GetDirectoryName(SubfileDirectory), fname);
}
}
}

View File

@ -0,0 +1,307 @@
using System.Runtime.InteropServices;
using System.Text;
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Security.Permissions;
namespace BizHawk
{
/// <summary>
/// Component wrapping access to the Browse For Folder common dialog box.
/// Call the ShowDialog() method to bring the dialog box up.
/// </summary>
public sealed class FolderBrowserEx : Component
{
private const int MAX_PATH = 260;
// Root node of the tree view.
private FolderID startLocation = FolderID.Desktop;
// Browse info options.
private int publicOptions = (int) Win32API.Shell32.BffStyles.RestrictToFilesystem |
(int) Win32API.Shell32.BffStyles.RestrictToDomain;
private const int privateOptions = (int) (Win32API.Shell32.BffStyles.NewDialogStyle | Win32API.Shell32.BffStyles.ShowTextBox);
// Description text to show.
public string Description = "Please select a folder below:";
/// <summary>
/// Enum of CSIDLs identifying standard shell folders.
/// </summary>
public enum FolderID
{
Desktop = 0x0000,
Printers = 0x0004,
MyDocuments = 0x0005,
Favorites = 0x0006,
Recent = 0x0008,
SendTo = 0x0009,
StartMenu = 0x000b,
MyComputer = 0x0011,
NetworkNeighborhood = 0x0012,
Templates = 0x0015,
MyPictures = 0x0027,
NetAndDialUpConnections = 0x0031,
}
/// <summary>
/// Helper function that returns the IMalloc interface used by the shell.
/// </summary>
private static Win32API.IMalloc GetSHMalloc()
{
Win32API.IMalloc malloc;
Win32API.Shell32.SHGetMalloc(out malloc);
return malloc;
}
/// <summary>
/// Shows the folder browser dialog box.
/// </summary>
public DialogResult ShowDialog()
{
return ShowDialog(null);
}
private int callback(IntPtr hwnd, uint uMsg, IntPtr lParam, IntPtr lpData)
{
switch (uMsg)
{
case 1:
{
IntPtr str = Marshal.StringToHGlobalUni(SelectedPath);
Win32.SendMessage(hwnd, (0x400 + 103), 1, str.ToInt32());
Marshal.FreeHGlobal(str);
break;
}
}
return 0;
}
/// <summary>
/// Shows the folder browser dialog box with the specified owner window.
/// </summary>
public DialogResult ShowDialog(IWin32Window owner)
{
IntPtr pidlRoot = IntPtr.Zero;
// Get/find an owner HWND for this dialog.
IntPtr hWndOwner;
if (owner != null)
{
hWndOwner = owner.Handle;
}
else
{
hWndOwner = Win32API.GetActiveWindow();
}
// Get the IDL for the specific startLocation.
Win32API.Shell32.SHGetSpecialFolderLocation(hWndOwner, (int) startLocation, out pidlRoot);
if (pidlRoot == IntPtr.Zero)
{
return DialogResult.Cancel;
}
int mergedOptions = (int) publicOptions | (int) privateOptions;
if ((mergedOptions & (int) Win32API.Shell32.BffStyles.NewDialogStyle) != 0)
{
if (System.Threading.ApartmentState.MTA == Application.OleRequired())
mergedOptions = mergedOptions & (~(int) Win32API.Shell32.BffStyles.NewDialogStyle);
}
IntPtr pidlRet = IntPtr.Zero;
try
{
// Construct a BROWSEINFO.
Win32API.Shell32.BROWSEINFO bi = new Win32API.Shell32.BROWSEINFO();
IntPtr buffer = Marshal.AllocHGlobal(MAX_PATH);
bi.pidlRoot = pidlRoot;
bi.hwndOwner = hWndOwner;
bi.pszDisplayName = buffer;
bi.lpszTitle = Description;
bi.ulFlags = mergedOptions;
bi.lpfn = new Win32API.Shell32.BFFCALLBACK(callback);
// The rest of the fields are initialized to zero by the constructor.
// bi.lParam = IntPtr.Zero; bi.iImage = 0;
// Show the dialog.
pidlRet = Win32API.Shell32.SHBrowseForFolder(ref bi);
// Free the buffer you've allocated on the global heap.
Marshal.FreeHGlobal(buffer);
if (pidlRet == IntPtr.Zero)
{
// User clicked Cancel.
return DialogResult.Cancel;
}
// Then retrieve the path from the IDList.
StringBuilder sb = new StringBuilder(MAX_PATH);
if (0 == Win32API.Shell32.SHGetPathFromIDList(pidlRet, sb))
{
return DialogResult.Cancel;
}
// Convert to a string.
}
finally
{
Win32API.IMalloc malloc = GetSHMalloc();
malloc.Free(pidlRoot);
if (pidlRet != IntPtr.Zero)
{
malloc.Free(pidlRet);
}
}
return DialogResult.OK;
}
/// <summary>
/// Helper function used to set and reset bits in the publicOptions bitfield.
/// </summary>
private void SetOptionField(int mask, bool turnOn)
{
if (turnOn)
publicOptions |= mask;
else
publicOptions &= ~mask;
}
/// <summary>
/// Only return file system directories. If the user selects folders
/// that are not part of the file system, the OK button is unavailable.
/// </summary>
[Category("Navigation")]
[Description("Only return file system directories. If the user selects folders " +
"that are not part of the file system, the OK button is unavailable.")]
[DefaultValue(true)]
public bool OnlyFilesystem
{
get { return (publicOptions & (int) Win32API.Shell32.BffStyles.RestrictToFilesystem) != 0; }
set { SetOptionField((int) Win32API.Shell32.BffStyles.RestrictToFilesystem, value); }
}
/// <summary>
/// Location of the root folder from which to start browsing. Only the specified
/// folder and any folders beneath it in the namespace hierarchy appear
/// in the dialog box.
/// </summary>
[Category("Navigation")]
[Description("Location of the root folder from which to start browsing. Only the specified " +
"folder and any folders beneath it in the namespace hierarchy appear " +
"in the dialog box.")]
[DefaultValue(typeof (FolderID), "0")]
public FolderID StartLocation
{
get { return startLocation; }
set
{
new UIPermission(UIPermissionWindow.AllWindows).Demand();
startLocation = value;
}
}
public string SelectedPath;
}
internal class Win32API
{
// C# representation of the IMalloc interface.
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("00000002-0000-0000-C000-000000000046")]
public interface IMalloc
{
[PreserveSig]
IntPtr Alloc([In] int cb);
[PreserveSig]
IntPtr Realloc([In] IntPtr pv, [In] int cb);
[PreserveSig]
void Free([In] IntPtr pv);
[PreserveSig]
int GetSize([In] IntPtr pv);
[PreserveSig]
int DidAlloc(IntPtr pv);
[PreserveSig]
void HeapMinimize();
}
[DllImport("User32.DLL")]
public static extern IntPtr GetActiveWindow();
public class Shell32
{
// Styles used in the BROWSEINFO.ulFlags field.
[Flags]
public enum BffStyles
{
RestrictToFilesystem = 0x0001, // BIF_RETURNONLYFSDIRS
RestrictToDomain = 0x0002, // BIF_DONTGOBELOWDOMAIN
RestrictToSubfolders = 0x0008, // BIF_RETURNFSANCESTORS
ShowTextBox = 0x0010, // BIF_EDITBOX
ValidateSelection = 0x0020, // BIF_VALIDATE
NewDialogStyle = 0x0040, // BIF_NEWDIALOGSTYLE
BrowseForComputer = 0x1000, // BIF_BROWSEFORCOMPUTER
BrowseForPrinter = 0x2000, // BIF_BROWSEFORPRINTER
BrowseForEverything = 0x4000, // BIF_BROWSEINCLUDEFILES
}
// Delegate type used in BROWSEINFO.lpfn field.
public delegate int BFFCALLBACK(IntPtr hwnd, uint uMsg, IntPtr lParam, IntPtr lpData);
[StructLayout(LayoutKind.Sequential, Pack = 8)]
public struct BROWSEINFO
{
public IntPtr hwndOwner;
public IntPtr pidlRoot;
public IntPtr pszDisplayName;
[MarshalAs(UnmanagedType.LPTStr)] public string lpszTitle;
public int ulFlags;
[MarshalAs(UnmanagedType.FunctionPtr)] public BFFCALLBACK lpfn;
public IntPtr lParam;
public int iImage;
}
[DllImport("Shell32.DLL")]
public static extern int SHGetMalloc(out IMalloc ppMalloc);
[DllImport("Shell32.DLL")]
public static extern int SHGetSpecialFolderLocation(
IntPtr hwndOwner, int nFolder, out IntPtr ppidl);
[DllImport("Shell32.DLL")]
public static extern int SHGetPathFromIDList(
IntPtr pidl, StringBuilder Path);
[DllImport("Shell32.DLL", CharSet = CharSet.Auto)]
public static extern IntPtr SHBrowseForFolder(ref BROWSEINFO bi);
}
}
}

View File

@ -0,0 +1,245 @@
using System;
using System.Globalization;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk
{
public interface INumberBox
{
int ToRawInt();
void SetFromRawInt(int rawint);
bool Nullable { get; }
}
public class HexTextBox : TextBox, INumberBox
{
private string _addressFormatStr = "{0:X4}";
private int? _maxSize = null;
private bool _nullable = true;
public bool Nullable { get { return _nullable; } set { _nullable = value; } }
public void SetHexProperties(int domainSize)
{
_maxSize = domainSize - 1;
MaxLength = IntHelpers.GetNumDigits(_maxSize.Value);
_addressFormatStr = "{0:X" + MaxLength.ToString() + "}";
ResetText();
}
private uint GetMax()
{
if (_maxSize.HasValue)
{
return (uint)_maxSize.Value;
}
else
{
return IntHelpers.MaxHexValueFromMaxDigits(MaxLength);
}
}
public override void ResetText()
{
if (_nullable)
{
Text = String.Empty;
}
else
{
Text = String.Format(_addressFormatStr, 0);
}
}
public HexTextBox()
{
CharacterCasing = CharacterCasing.Upper;
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
return;
}
else if (!InputValidate.IsValidHexNumber(e.KeyChar))
{
e.Handled = true;
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
if (InputValidate.IsValidHexNumber(Text))
{
uint val = (uint)ToRawInt();
if (val == GetMax())
{
val = 0;
}
else
{
val++;
}
Text = String.Format(_addressFormatStr, val);
}
}
else if (e.KeyCode == Keys.Down)
{
if (InputValidate.IsValidHexNumber(Text))
{
uint val = (uint)ToRawInt();
if (val == 0)
{
val = GetMax();
}
else
{
val--;
}
Text = String.Format(_addressFormatStr, val);
}
}
else
{
base.OnKeyDown(e);
}
}
protected override void OnTextChanged(EventArgs e)
{
if (String.IsNullOrWhiteSpace(Text))
{
ResetText();
}
}
public int ToRawInt()
{
if (String.IsNullOrWhiteSpace(Text))
{
return 0;
}
else
{
return int.Parse(Text, NumberStyles.HexNumber);
}
}
public void SetFromRawInt(int val)
{
Text = String.Format(_addressFormatStr, val);
}
}
public class UnsignedIntegerBox : TextBox, INumberBox
{
public UnsignedIntegerBox()
{
CharacterCasing = CharacterCasing.Upper;
}
private bool _nullable = true;
public bool Nullable { get { return _nullable; } set { _nullable = value; } }
protected override void OnKeyPress(KeyPressEventArgs e)
{
if (e.KeyChar == '\b' || e.KeyChar == 22 || e.KeyChar == 1 || e.KeyChar == 3)
{
return;
}
else if (!InputValidate.IsValidUnsignedNumber(e.KeyChar))
{
e.Handled = true;
}
}
public override void ResetText()
{
if (_nullable)
{
Text = String.Empty;
}
else
{
Text = "0";
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.KeyCode == Keys.Up)
{
if (InputValidate.IsValidUnsignedNumber(Text))
{
uint val = (uint)ToRawInt();
if (val == uint.MaxValue)
{
val = 0;
}
else
{
val++;
}
Text = val.ToString();
}
}
else if (e.KeyCode == Keys.Down)
{
if (InputValidate.IsValidUnsignedNumber(Text))
{
uint val = (uint)ToRawInt();
if (val == 0)
{
val = uint.MaxValue;
}
else
{
val--;
}
Text = val.ToString();
}
}
else
{
base.OnKeyDown(e);
}
}
protected override void OnTextChanged(EventArgs e)
{
if (String.IsNullOrWhiteSpace(Text))
{
ResetText();
}
}
public int ToRawInt()
{
if (String.IsNullOrWhiteSpace(Text))
{
return 0;
}
else
{
return (int)uint.Parse(Text);
}
}
public void SetFromRawInt(int val)
{
Text = val.ToString();
}
}
}

View File

@ -0,0 +1,25 @@
using System.Collections.Generic;
using System.Windows.Forms;
namespace BizHawk
{
public class InputConfigBase : Form
{
public void CheckDups()
{
Dictionary<string,bool> dups = new Dictionary<string,bool>();
foreach (Control c in Controls)
{
SmartTextBoxControl stbc = c as SmartTextBoxControl;
if (stbc == null) continue;
if (dups.ContainsKey(stbc.Text))
{
MessageBox.Show("DUP!");
return;
}
dups[stbc.Text] = true;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,72 @@
using System.Drawing;
using System.Windows.Forms;
namespace BizHawk.Core
{
public class HorizontalLine : Control
{
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
base.SetBoundsCore(x, y, width, 2, specified);
}
protected override void OnPaint(PaintEventArgs e)
{
ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, 2, Border3DStyle.Etched);
}
}
public class CustomCheckBox : CheckBox
{
Color _CheckBackColor = SystemColors.Control;
public Color CheckBackColor
{
get { return _CheckBackColor; }
set { _CheckBackColor = value; Refresh(); }
}
bool? _ForceChecked;
public bool? ForceChecked
{
get { return _ForceChecked; }
set { _ForceChecked = value; Refresh(); }
}
protected override void OnPaint(PaintEventArgs pevent)
{
//draw text-label part of the control with something so that it isn't hallofmirrorsy
using(var brush = new SolidBrush(Parent.BackColor))
pevent.Graphics.FillRectangle(brush, ClientRectangle);
var r = new Rectangle(ClientRectangle.Location, SystemInformation.MenuCheckSize);
var glyphLoc = ClientRectangle;
glyphLoc.Size = SystemInformation.MenuCheckSize;
//draw the selectedbackdrop color roughly where the glyph belongs
using (var brush = new SolidBrush(_CheckBackColor))
pevent.Graphics.FillRectangle(brush, glyphLoc);
//draw a checkbox menu glyph (we could do this more elegantly with DrawFrameControl)
bool c = CheckState == CheckState.Checked;
if (ForceChecked.HasValue)
{
c = ForceChecked.Value;
}
if (c)
{
glyphLoc.Y--;
glyphLoc.X++;
ControlPaint.DrawMenuGlyph(pevent.Graphics, glyphLoc, MenuGlyph.Checkmark, Color.Black, Color.Transparent);
}
//draw a border on top of it all
ControlPaint.DrawBorder3D(pevent.Graphics, r, Border3DStyle.Sunken);
//stuff that didnt work
//CheckBoxRenderer.DrawParentBackground(pevent.Graphics, ClientRectangle, this);
//CheckBoxRenderer.DrawCheckBox(pevent.Graphics, ClientRectangle.Location, System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal);
//glyphLoc.Size = new System.Drawing.Size(SystemInformation.MenuCheckSize.Width-1,SystemInformation.MenuCheckSize.Height-1);
}
}
}

View File

@ -0,0 +1,77 @@
namespace BizHawk
{
partial class QuickProgressPopup
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.progressBar = new System.Windows.Forms.ProgressBar();
this.lblProgress = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// progressBar
//
this.progressBar.Location = new System.Drawing.Point(12, 12);
this.progressBar.Name = "progressBar";
this.progressBar.Size = new System.Drawing.Size(194, 23);
this.progressBar.TabIndex = 0;
//
// lblProgress
//
this.lblProgress.AutoSize = true;
this.lblProgress.Location = new System.Drawing.Point(12, 41);
this.lblProgress.Margin = new System.Windows.Forms.Padding(3);
this.lblProgress.Name = "lblProgress";
this.lblProgress.Size = new System.Drawing.Size(35, 13);
this.lblProgress.TabIndex = 1;
this.lblProgress.Text = "label1";
//
// QuickProgressPopup
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(229, 63);
this.ControlBox = false;
this.Controls.Add(this.lblProgress);
this.Controls.Add(this.progressBar);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "QuickProgressPopup";
this.Text = "Please wait...";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.ProgressBar progressBar;
private System.Windows.Forms.Label lblProgress;
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk
{
public partial class QuickProgressPopup : Form
{
public QuickProgressPopup()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,34 @@
using System;
using System.Windows.Forms;
namespace BizHawk
{
public class SmartTextBoxControl : TextBox
{
public SmartTextBoxControl()
{
ReadOnly = true;
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.Text = e.KeyCode.ToString();
OnTextChanged(new EventArgs());
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
}
protected override void OnKeyUp(KeyEventArgs e)
{
}
public override string Text
{
get { return base.Text; }
set { }
}
}
}

View File

@ -0,0 +1,58 @@
using System.Drawing;
using System.Windows.Forms;
namespace BizHawk
{
public class TextDebugView : Control
{
public TextDebugView()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.Clear(SystemColors.Control);
Font font = new Font(new FontFamily("Courier New"), 8);
e.Graphics.DrawString(Text, font, Brushes.Black,0,0);
font.Dispose();
}
public override string Text
{
get
{
return base.Text;
}
set
{
base.Text = value;
Invalidate();
}
}
}
public class TextDebugForm : Form
{
public TextDebugView view = new TextDebugView();
public TextDebugForm()
{
view.Dock = DockStyle.Fill;
Controls.Add(view);
}
public override string Text
{
get
{
return view.Text;
}
set
{
view.Text = value;
}
}
}
}

View File

@ -0,0 +1,84 @@
//credit: http://blogs.msdn.com/b/rickbrew/archive/2006/01/09/511003.aspx
using System;
using System.Windows.Forms;
/// <summary>
/// This class adds on to the functionality provided in System.Windows.Forms.ToolStrip.
/// </summary>
public class ToolStripEx : ToolStrip
{
private bool clickThrough = true;
/// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
/// not have input focus.
/// </summary>
public bool ClickThrough
{
get
{
return clickThrough;
}
set
{
clickThrough = value;
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (clickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
/// <summary>
/// This class adds on to the functionality provided in System.Windows.Forms.MenuStrip.
/// </summary>
public class MenuStripEx : MenuStrip
{
private bool clickThrough = true;
/// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does
/// not have input focus.
/// </summary>
public bool ClickThrough
{
get
{
return clickThrough;
}
set
{
clickThrough = value;
}
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (clickThrough &&
m.Msg == NativeConstants.WM_MOUSEACTIVATE &&
m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
internal sealed class NativeConstants
{
private NativeConstants(){}
internal const uint WM_MOUSEACTIVATE = 0x21;
internal const uint MA_ACTIVATE = 1;
internal const uint MA_ACTIVATEANDEAT = 2;
internal const uint MA_NOACTIVATE = 3;
internal const uint MA_NOACTIVATEANDEAT = 4;
}

View File

@ -0,0 +1,142 @@
using System;
using System.Text;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace BizHawk
{
public static class Extensions
{
//extension method to make Control.Invoke easier to use
public static void Invoke(this Control control, Action action)
{
control.Invoke((Delegate)action);
}
}
public static class ListViewExtensions
{
[StructLayout(LayoutKind.Sequential)]
public struct HDITEM
{
public Mask mask;
public int cxy;
[MarshalAs(UnmanagedType.LPTStr)]
public string pszText;
public IntPtr hbm;
public int cchTextMax;
public Format fmt;
public IntPtr lParam;
// _WIN32_IE >= 0x0300
public int iImage;
public int iOrder;
// _WIN32_IE >= 0x0500
public uint type;
public IntPtr pvFilter;
// _WIN32_WINNT >= 0x0600
public uint state;
[Flags]
public enum Mask
{
Format = 0x4, // HDI_FORMAT
};
[Flags]
public enum Format
{
SortDown = 0x200, // HDF_SORTDOWN
SortUp = 0x400, // HDF_SORTUP
};
};
public const int LVM_FIRST = 0x1000;
public const int LVM_GETHEADER = LVM_FIRST + 31;
public const int HDM_FIRST = 0x1200;
public const int HDM_GETITEM = HDM_FIRST + 11;
public const int HDM_SETITEM = HDM_FIRST + 12;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 msg, IntPtr wParam, ref HDITEM lParam);
/// <summary>
/// Dumps the contents of the ListView into a tab separated list of lines
/// </summary>
public static string CopyItemsAsText(this ListView listViewControl)
{
ListView.SelectedIndexCollection indexes = listViewControl.SelectedIndices;
if (indexes.Count <= 0)
return "";
StringBuilder sb = new StringBuilder();
//walk over each selected item and subitem within it to generate a string from it
foreach (int index in indexes)
{
foreach (ListViewItem.ListViewSubItem item in listViewControl.Items[index].SubItems)
{
if (!String.IsNullOrWhiteSpace(item.Text))
sb.Append(item.Text).Append('\t');
}
//remove the last tab
sb.Remove(sb.Length - 1, 1);
sb.Append("\r\n");
}
//remove last newline
sb.Length -= 2;
return sb.ToString();
}
public static void SetSortIcon(this ListView listViewControl, int columnIndex, SortOrder order)
{
IntPtr columnHeader = SendMessage(listViewControl.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);
for (int columnNumber = 0; columnNumber <= listViewControl.Columns.Count - 1; columnNumber++)
{
var columnPtr = new IntPtr(columnNumber);
var item = new HDITEM
{
mask = HDITEM.Mask.Format
};
if (SendMessage(columnHeader, HDM_GETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
if (order != SortOrder.None && columnNumber == columnIndex)
{
switch (order)
{
case SortOrder.Ascending:
item.fmt &= ~HDITEM.Format.SortDown;
item.fmt |= HDITEM.Format.SortUp;
break;
case SortOrder.Descending:
item.fmt &= ~HDITEM.Format.SortUp;
item.fmt |= HDITEM.Format.SortDown;
break;
}
}
else
{
item.fmt &= ~HDITEM.Format.SortDown & ~HDITEM.Format.SortUp;
}
if (SendMessage(columnHeader, HDM_SETITEM, columnPtr, ref item) == IntPtr.Zero)
{
throw new Win32Exception();
}
}
}
}
}

View File

@ -0,0 +1,239 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace BizHawk.Core
{
/// <summary>
/// A programmatic PictureBox, really, which will paint itself using the last bitmap that was provided
/// </summary>
public class RetainedViewportPanel : Control
{
Thread threadPaint;
EventWaitHandle ewh;
volatile bool killSignal;
public Func<Bitmap,bool> ReleaseCallback;
/// <summary>
/// Turns this panel into multi-threaded mode.
/// This will sort of glitch out other gdi things on the system, but at least its fast...
/// </summary>
public void ActivateThreaded()
{
ewh = new EventWaitHandle(false, EventResetMode.AutoReset);
threadPaint = new Thread(PaintProc);
threadPaint.IsBackground = true;
threadPaint.Start();
}
public RetainedViewportPanel(bool doubleBuffer = false)
{
CreateHandle();
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, doubleBuffer);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.UserMouse, true);
SetBitmap(new Bitmap(2, 2));
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (threadPaint != null)
{
killSignal = true;
ewh.Set();
ewh.WaitOne();
}
CleanupDisposeQueue();
}
public bool ScaleImage = true;
void DoPaint()
{
if (bmp != null)
{
using (Graphics g = CreateGraphics())
{
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
g.InterpolationMode = InterpolationMode.NearestNeighbor;
g.CompositingMode = CompositingMode.SourceCopy;
g.CompositingQuality = CompositingQuality.HighSpeed;
if (ScaleImage)
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Half;
g.DrawImage(bmp, 0, 0, Width, Height);
}
else
{
using (var sb = new SolidBrush(Color.Black))
{
g.FillRectangle(sb, bmp.Width, 0, Width - bmp.Width, Height);
g.FillRectangle(sb, 0, bmp.Height, bmp.Width, Height - bmp.Height);
}
g.DrawImageUnscaled(bmp, 0, 0);
}
}
}
CleanupDisposeQueue();
}
void PaintProc()
{
for (; ; )
{
ewh.WaitOne();
if (killSignal)
{
ewh.Set();
return;
}
DoPaint();
}
}
void CleanupDisposeQueue()
{
lock (this)
{
while (DisposeQueue.Count > 0)
{
var bmp = DisposeQueue.Dequeue();
bool dispose = true;
if(ReleaseCallback != null)
dispose = ReleaseCallback(bmp);
if(dispose) bmp.Dispose();
}
}
}
Queue<Bitmap> DisposeQueue = new Queue<Bitmap>();
void SignalPaint()
{
if (threadPaint == null)
DoPaint();
else
ewh.Set();
}
//Size logicalSize;
////int pitch;
//public void SetLogicalSize(int w, int h)
//{
// if (bmp != null) bmp.Dispose();
// bmp = new Bitmap(w, h, PixelFormat.Format32bppArgb);
// logicalSize = new Size(w, h);
//}
/// <summary>
/// Takes ownership of the provided bitmap and will use it for future painting
/// </summary>
public void SetBitmap(Bitmap newbmp)
{
lock (this)
{
if(bmp != null) DisposeQueue.Enqueue(bmp);
bmp = newbmp;
}
SignalPaint();
}
Bitmap bmp;
/// <summary>bit of a hack; use at your own risk</summary>
/// <returns>you probably shouldn't modify this?</returns>
public Bitmap GetBitmap()
{
return bmp;
}
protected override void OnPaintBackground(PaintEventArgs pevent)
{
}
protected override void OnPaint(PaintEventArgs e)
{
SignalPaint();
base.OnPaint(e);
}
}
/// <summary>
/// A dumb panel which functions as a placeholder for framebuffer painting
/// </summary>
public class ViewportPanel : Control
{
public ViewportPanel()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.UserMouse, true);
}
}
/// <summary>
/// A ViewportPanel with a vertical scroll bar
/// </summary>
public class ScrollableViewportPanel : UserControl
{
TableLayoutPanel table;
ViewportPanel view;
VScrollBar scroll;
public ViewportPanel View { get { return view; } }
public VScrollBar Scrollbar { get { return scroll; } }
public int ScrollMax { get { return Scrollbar.Maximum; } set { Scrollbar.Maximum = value; } }
public int ScrollLargeChange { get { return Scrollbar.LargeChange; } set { Scrollbar.LargeChange = value; } }
public ScrollableViewportPanel()
{
InitializeComponent();
}
public void InitializeComponent()
{
table = new TableLayoutPanel();
view = new ViewportPanel();
scroll = new VScrollBar();
scroll.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom;
view.Dock = DockStyle.Fill;
table.Dock = DockStyle.Fill;
table.RowStyles.Add(new RowStyle(SizeType.Percent, 100));
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100));
table.ColumnStyles.Add(new ColumnStyle(SizeType.AutoSize, 0));
table.RowCount = 1;
table.ColumnCount = 2;
table.Controls.Add(view);
table.Controls.Add(scroll);
table.SetColumn(view, 0);
table.SetColumn(scroll, 1);
scroll.Scroll += (sender, e) => OnScroll(e);
view.Paint += (sender, e) => OnPaint(e);
Controls.Add(table);
}
}
}

View File

@ -0,0 +1,695 @@
using System;
using System.Windows.Forms;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Drawing;
namespace BizHawk
{
#region win32interop
[StructLayout(LayoutKind.Sequential)]
internal struct LVDISPINFO {
public NMHDR hdr;
public LVITEM item;
}
[StructLayout(LayoutKind.Sequential)]
internal struct NMHDR {
public int hwndFrom;
public int idFrom;
public int code;
}
[StructLayout(LayoutKind.Sequential)]
internal struct NMITEMACTIVATE {
NMHDR hdr;
int iItem;
int iSubItem;
uint uNewState;
uint uOldState;
uint uChanged;
POINT ptAction;
uint lParam;
uint uKeyFlags;
}
[StructLayout(LayoutKind.Sequential)]
internal struct RECT {
public int left, top, right, bottom;
}
[StructLayout(LayoutKind.Sequential)]
internal struct NMCUSTOMDRAWINFO {
public NMHDR hdr;
public uint dwDrawStage;
public IntPtr hdc;
public RECT rc;
public int dwItemSpec;
public uint uItemState;
public int lItemlParam;
}
[StructLayout(LayoutKind.Sequential)]
internal struct NMLVCUSTOMDRAW {
public NMCUSTOMDRAWINFO nmcd;
public int clrText;
public int clrTextBk;
public int iSubItem;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct LVITEM {
public uint mask;
public int iItem;
public int iSubItem;
public uint state;
public uint stateMask;
public IntPtr pszText;
public int cchTextMax;
public int iImage;
public IntPtr lParam;
//#if (_WIN32_IE >= 0x0300)
public int iIndent;
//#endif
//#if (_WIN32_WINNT >= 0x501)
//public int iGroupId;
//public uint cColumns;
//public IntPtr puColumns;
//#endif
}
[FlagsAttribute]
enum CUSTOMDRAWRETURNFLAGS {
CDRF_DODEFAULT = 0x00000000,
CDRF_NEWFONT = 0x00000002,
CDRF_SKIPDEFAULT = 0x00000004,
CDRF_NOTIFYPOSTPAINT = 0x00000010,
CDRF_NOTIFYITEMDRAW = 0x00000020,
//#if (_WIN32_IE >= 0x0400)
CDRF_NOTIFYSUBITEMDRAW = 0x00000020,//[sic]
//#endif
CDRF_NOTIFYPOSTERASE = 0x00000040,
}
[FlagsAttribute]
enum CUSTOMDRAWDRAWSTAGEFLAGS {
CDDS_PREPAINT = 0x00000001,
CDDS_POSTPAINT = 0x00000002,
CDDS_PREERASE = 0x00000003,
CDDS_POSTERASE = 0x00000004,
// the 0x000010000 bit means it's individual item specific
CDDS_ITEM = 0x00010000,
CDDS_ITEMPREPAINT = (CDDS_ITEM | CDDS_PREPAINT),
CDDS_ITEMPOSTPAINT = (CDDS_ITEM | CDDS_POSTPAINT),
CDDS_ITEMPREERASE = (CDDS_ITEM | CDDS_PREERASE),
CDDS_ITEMPOSTERASE = (CDDS_ITEM | CDDS_POSTERASE),
//#if (_WIN32_IE >= 0x0400)
CDDS_SUBITEM = 0x00020000,
CDDS_SUBITEMPREPAINT = (CDDS_SUBITEM | CDDS_ITEMPREPAINT),
CDDS_SUBITEMPOSTPAINT = (CDDS_SUBITEM | CDDS_ITEMPOSTPAINT),
CDDS_SUBITEMPREERASE = (CDDS_SUBITEM | CDDS_ITEMPREERASE),
CDDS_SUBITEMPOSTERASE = (CDDS_SUBITEM | CDDS_ITEMPOSTERASE),
//#endif
}
[FlagsAttribute]
enum LVHITTESTFLAGS {
LVHT_NOWHERE = 0x0001,
LVHT_ONITEMICON = 0x0002,
LVHT_ONITEMLABEL = 0x0004,
LVHT_ONITEMSTATEICON = 0x0008,
LVHT_ONITEM = (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON),
LVHT_ABOVE = 0x0008,
LVHT_BELOW = 0x0010,
LVHT_TORIGHT = 0x0020,
LVHT_TOLEFT = 0x0040
}
[StructLayout(LayoutKind.Sequential)]
internal struct POINT {
public int x;
public int y;
}
[StructLayout(LayoutKind.Sequential)]
internal class LVHITTESTINFO {
public POINT pt;
public uint flags;
public int iItem;
public int iSubItem;
}
[StructLayout(LayoutKind.Sequential)]
internal struct NMLISTVIEW {
public NMHDR hdr;
public int iItem;
public int iSubItem;
public uint uNewState;
public uint uOldState;
public uint uChanged;
public POINT ptAction;
public IntPtr lParam;
}
internal enum ListViewItemMask : short {
LVIF_TEXT = 0x0001,
LVIF_IMAGE = 0x0002,
LVIF_PARAM = 0x0004,
LVIF_STATE = 0x0008,
LVIF_INDENT = 0x0010,
LVIF_NORECOMPUTE = 0x0800,
LVIF_GROUPID = 0x0100,
LVIF_COLUMNS = 0x0200
}
internal enum LVNI {
ALL = 0x0000,
FOCUSED = 0x0001,
SELECTED = 0x0002,
CUT = 0x0004,
DROPHILITED = 0x0008,
ABOVE = 0x0100,
BELOW = 0x0200,
TOLEFT = 0x0400,
TORIGHT = 0x0800
}
internal enum ListViewMessages {
LVM_FIRST = 0x1000,
LVM_GETITEMCOUNT = (LVM_FIRST + 4),
LVM_SETCALLBACKMASK = (LVM_FIRST + 11),
LVM_GETNEXTITEM = (LVM_FIRST + 12),
LVM_HITTEST = (LVM_FIRST + 18),
LVM_ENSUREVISIBLE = (LVM_FIRST + 19),
LVM_SETITEMSTATE = (LVM_FIRST + 43),
LVM_GETITEMSTATE = (LVM_FIRST + 44),
LVM_SETITEMCOUNT = (LVM_FIRST + 47),
LVM_GETSUBITEMRECT = (LVM_FIRST + 56)
}
internal enum ListViewStyles : short {
LVS_OWNERDATA = 0x1000,
LVS_SORTASCENDING = 0x0010,
LVS_SORTDESCENDING = 0x0020,
LVS_SHAREIMAGELISTS = 0x0040,
LVS_NOLABELWRAP = 0x0080,
LVS_AUTOARRANGE = 0x0100
}
internal enum ListViewStylesICF : uint {
LVSICF_NOINVALIDATEALL = 0x00000001,
LVSICF_NOSCROLL = 0x00000002
}
internal enum WindowsMessage : uint {
WM_ERASEBKGND = 0x0014,
WM_SCROLL = 0x115,
WM_LBUTTONDOWN = 0x0201,
WM_LBUTTONUP = 0x0202,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205,
WM_RBUTTONDBLCLK = 0x0206,
WM_SETFOCUS = 0x0007,
WM_NOTIFY = 0x004E,
WM_USER = 0x0400,
WM_REFLECT = WM_USER + 0x1c00
}
internal enum Notices : int {
NM_FIRST = 0,
NM_CUSTOMDRAW = NM_FIRST - 12,
NM_CLICK = NM_FIRST - 2,
NM_DBLCLICK = NM_FIRST - 3,
}
internal enum ListViewNotices : int {
LVN_FIRST = (0 - 100),
LVN_LAST = (0 - 199),
LVN_BEGINDRAG = (int)LVN_FIRST - 9,
LVN_BEGINRDRAG = (int)LVN_FIRST - 11,
LVN_GETDISPINFOA = (int)LVN_FIRST - 50,
LVN_GETDISPINFOW = (int)LVN_FIRST - 77,
LVN_SETDISPINFOA = (int)LVN_FIRST - 51,
LVN_SETDISPINFOW = (int)LVN_FIRST - 78,
LVN_ODCACHEHINT = (int)LVN_FIRST - 13,
LVN_ODFINDITEMW = (int)LVN_FIRST - 79
}
[Flags]
internal enum ListViewCallBackMask : uint {
LVIS_FOCUSED = 0x0001,
LVIS_SELECTED = 0x0002,
LVIS_CUT = 0x0004,
LVIS_DROPHILITED = 0x0008,
LVIS_GLOW = 0x0010,
LVIS_ACTIVATING = 0x0020,
LVIS_OVERLAYMASK = 0x0F00,
LVIS_STATEIMAGEMASK = 0xF000,
}
#endregion
#region VirtualListView Delegates
/// <summary>
/// Retrieve the background color for a Listview cell (item and subitem).
/// </summary>
/// <param name="item">Listview item (row).</param>
/// <param name="subItem">Listview subitem (column).</param>
/// <param name="color">Background color to use</param>
public delegate void QueryItemBkColorHandler(int item, int subItem, ref Color color);
/// <summary>
/// Retrieve the text for a Listview cell (item and subitem).
/// </summary>
/// <param name="item">Listview item (row).</param>
/// <param name="subItem">Listview subitem (column).</param>
/// <param name="text">Text to display.</param>
public delegate void QueryItemTextHandler(int item, int subItem, out string text);
/// <summary>
/// Retrieve the image index for a Listview item.
/// </summary>
/// <param name="item">Listview item (row).</param>
/// <param name="subItem">Listview subitem (column) - should always be zero.</param>
/// <param name="imageIndex">Index of associated ImageList.</param>
public delegate void QueryItemImageHandler(int item, int subItem, out int imageIndex);
/// <summary>
/// Retrieve the indent for a Listview item. The indent is always width of an image.
/// For example, 1 indents the Listview item one image width.
/// </summary>
/// <param name="item">Listview item (row).</param>
/// <param name="itemIndent">The amount to indent the Listview item.</param>
public delegate void QueryItemIndentHandler(int item, out int itemIndent);
public delegate void QueryItemHandler(int idx, out ListViewItem item);
#endregion
/// <summary>
/// VirtualListView is a virtual Listview which allows for a large number of items(rows)
/// to be displayed. The virtual Listview contains very little actual information -
/// mainly item selection and focus information.
/// </summary>
public class VirtualListView : ListView {
// store the item count to prevent the call to SendMessage(LVM_GETITEMCOUNT)
private int itemCount = 0;
#region Display query callbacks
/// <summary>
/// Fire the QueryItemBkColor event which requests the background color for the passed Listview cell
/// </summary>
public event QueryItemBkColorHandler QueryItemBkColor;
/// <summary>
/// Fire the QueryItemText event which requests the text for the passed Listview cell.
/// </summary>
[Category("Data")]
public event QueryItemTextHandler QueryItemText;
/// <summary>
/// Fire the QueryItemImage event which requests the ImageIndex for the passed Listview item.
/// </summary>
[Category("Data")]
public event QueryItemImageHandler QueryItemImage;
/// <summary>
/// Fire the QueryItemIndent event which requests the indent for the passed Listview item.
/// </summary>
[Category("Data")]
public event QueryItemIndentHandler QueryItemIndent;
[Category("Data")]
public event QueryItemHandler QueryItem;
#endregion
#region Properties
/// <summary>
/// Gets/sets the sets the virtual number of items to be displayed.
/// </summary>
[Category("Behavior")]
public int ItemCount {
get {
return itemCount;
}
set {
itemCount = value;
// if the virtual item count is set before the handle is created
// then the image lists don't get loaded properly
if(!this.IsHandleCreated)
return;
SetVirtualItemCount();
}
}
/// <summary>
/// Gets/sets how list items are to be displayed.
///
/// Hide the ListView.View property.
/// Virtual Listviews only allow Details or List.
/// </summary>
public new System.Windows.Forms.View View {
get {
return base.View;
}
set {
if(value == View.LargeIcon ||
value == View.SmallIcon) {
throw new ArgumentException("Icon views are invalid for virtual ListViews", "View");
}
base.View = value;
}
}
/// <summary>
/// Gets the required creation parameters when the control handle is created.
///
/// Use LVS_OWNERDATA to set this as a virtual Listview.
/// </summary>
protected override System.Windows.Forms.CreateParams CreateParams {
get {
CreateParams cp = base.CreateParams;
// LVS_OWNERDATA style must be set when the control is created
cp.Style |= (int)ListViewStyles.LVS_OWNERDATA;
return cp;
}
}
#endregion
#region Constructors
/// <summary>
/// Create a new instance of this control.
/// </summary>
public VirtualListView() {
// virtual listviews must be Details or List view with no sorting
View = View.Details;
Sorting = SortOrder.None;
ptrlvhti = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(LVHITTESTINFO)));
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.Opaque, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
~VirtualListView() {
Marshal.FreeHGlobal(ptrlvhti);
}
#endregion
#region Methods
/// <summary>
/// Set the state of the passed Listview item's index.
/// </summary>
/// <param name="index">Listview item's index.</param>
/// <param name="selected">Select the passed item?</param>
public void SelectItem(int index, bool selected) {
IntPtr ptrItem = IntPtr.Zero;
try {
// Determine whether selecting or unselecting.
uint select = selected ? (uint)ListViewCallBackMask.LVIS_SELECTED : 0;
// Fill in the LVITEM structure with state fields.
LVITEM stateItem = new LVITEM();
stateItem.mask = (uint)ListViewItemMask.LVIF_STATE;
stateItem.iItem = index;
stateItem.iSubItem = 0;
stateItem.state = select;
stateItem.stateMask = (uint)ListViewCallBackMask.LVIS_SELECTED;
// Copy the structure to unmanaged memory.
ptrItem = Marshal.AllocHGlobal(Marshal.SizeOf(stateItem.GetType()));
Marshal.StructureToPtr(stateItem, ptrItem, true);
// Send the message to the control window.
int result = Win32.SendMessage(
this.Handle,
(int)ListViewMessages.LVM_SETITEMSTATE,
index,
ptrItem.ToInt32());
} catch(Exception ex) {
System.Diagnostics.Trace.WriteLine("VirtualListView.SetItemState error=" + ex.Message);
// TODO: should this eat any exceptions?
throw ex;
} finally {
// Always release the unmanaged memory.
if(ptrItem != IntPtr.Zero) {
Marshal.FreeHGlobal(ptrItem);
}
}
}
private void SetVirtualItemCount() {
int result;
result = Win32.SendMessage(
this.Handle,
(int)ListViewMessages.LVM_SETITEMCOUNT,
itemCount,
0);
}
protected void OnDispInfoNotice(ref Message m, bool useAnsi) {
LVDISPINFO info = (LVDISPINFO)m.GetLParam(typeof(LVDISPINFO));
string lvtext = null;
if((info.item.mask & (uint)ListViewItemMask.LVIF_TEXT) > 0) {
if(QueryItemText != null) {
QueryItemText(info.item.iItem, info.item.iSubItem, out lvtext);
if(lvtext != null) {
try {
int maxIndex = Math.Min(info.item.cchTextMax - 1, lvtext.Length);
char[] data = new char[maxIndex + 1];
lvtext.CopyTo(0, data, 0, lvtext.Length);
data[maxIndex] = '\0';
System.Runtime.InteropServices.Marshal.Copy(data, 0, info.item.pszText, data.Length);
} catch(Exception e) {
Debug.WriteLine("Failed to copy text name from client: " + e.ToString(), "VirtualListView.OnDispInfoNotice");
}
}
}
}
if((info.item.mask & (uint)ListViewItemMask.LVIF_IMAGE) > 0) {
int imageIndex = 0;
if(QueryItemImage != null) {
QueryItemImage(info.item.iItem, info.item.iSubItem, out imageIndex);
}
info.item.iImage = imageIndex;
System.Runtime.InteropServices.Marshal.StructureToPtr(info, m.LParam, false);
}
if((info.item.mask & (uint)ListViewItemMask.LVIF_INDENT) > 0) {
int itemIndent = 0;
if(QueryItemIndent != null) {
QueryItemIndent(info.item.iItem, out itemIndent);
}
info.item.iIndent = itemIndent;
System.Runtime.InteropServices.Marshal.StructureToPtr(info, m.LParam, false);
}
m.Result = new IntPtr(0);
}
protected void OnCustomDrawNotice(ref System.Windows.Forms.Message m) {
NMLVCUSTOMDRAW cd = (NMLVCUSTOMDRAW)m.GetLParam(typeof(NMLVCUSTOMDRAW));
switch(cd.nmcd.dwDrawStage) {
case (int)CUSTOMDRAWDRAWSTAGEFLAGS.CDDS_ITEMPREPAINT:
case (int)CUSTOMDRAWDRAWSTAGEFLAGS.CDDS_PREPAINT:
m.Result = new IntPtr((int)CUSTOMDRAWRETURNFLAGS.CDRF_NOTIFYSUBITEMDRAW);
break;
case (int)CUSTOMDRAWDRAWSTAGEFLAGS.CDDS_SUBITEMPREPAINT:
Color color;
if(QueryItemBkColor != null) {
color = Color.FromArgb(cd.clrTextBk & 0xFF, (cd.clrTextBk >> 8) & 0xFF, (cd.clrTextBk >> 16) & 0xFF);
QueryItemBkColor(cd.nmcd.dwItemSpec, cd.iSubItem, ref color);
cd.clrTextBk = (color.B << 16) | (color.G << 8) | (color.R);
System.Runtime.InteropServices.Marshal.StructureToPtr(cd, m.LParam, false);
}
m.Result = new IntPtr((int)CUSTOMDRAWRETURNFLAGS.CDRF_DODEFAULT);
break;
}
}
/// <summary>
/// Event to be fired whenever the control scrolls
/// </summary>
public event ScrollEventHandler Scroll;
protected virtual void OnScroll(ScrollEventArgs e)
{
ScrollEventHandler handler = this.Scroll;
if (handler != null) handler(this, e);
}
protected override void WndProc(ref System.Windows.Forms.Message m) {
NMHDR nm1;
bool messageProcessed = false;
switch(m.Msg) {
case (int)WindowsMessage.WM_REFLECT + (int)WindowsMessage.WM_NOTIFY:
nm1 = (NMHDR)m.GetLParam(typeof(NMHDR));
switch(nm1.code) {
case (int)Notices.NM_CUSTOMDRAW:
OnCustomDrawNotice(ref m);
messageProcessed = true;
break;
case (int)ListViewNotices.LVN_GETDISPINFOW:
OnDispInfoNotice(ref m, false);
messageProcessed = true;
break;
case (int)ListViewNotices.LVN_BEGINDRAG:
OnBeginItemDrag(MouseButtons.Left, ref m);
messageProcessed = true;
break;
case (int)ListViewNotices.LVN_BEGINRDRAG:
OnBeginItemDrag(MouseButtons.Right, ref m);
messageProcessed = true;
break;
//case (int)Notices.NM_CLICK:
//case (int)Notices.NM_DBLCLICK:
// {
// NMITEMACTIVATE test = (NMITEMACTIVATE)m.GetLParam(typeof(NMITEMACTIVATE));
// messageProcessed = true;
// break;
// }
default:
break;
}
break;
case (int)WindowsMessage.WM_SCROLL:
//http://stackoverflow.com/questions/1851620/handling-scroll-event-on-listview-in-c-sharp
OnScroll(new ScrollEventArgs((ScrollEventType)(m.WParam.ToInt32() & 0xffff), 0));
break;
//obscure message loop flakiness when exceptions are thrown from the message loop...
//THIS BREAKS PROPER LISTVIEW FOCUS SELECTION (blue)
//next time we run into this, debug it better.
//case (int)WindowsMessage.WM_SETFOCUS:
// if (SelectedIndices.Count > 0 && SelectedIndices[0] >= VirtualListSize)
// messageProcessed = true;
// break;
//TRY THIS HACK INSTEAD TO FIX THE EXCEPTION
// (( NOPE, THEY ALL BREAK ONE THING OR ANOTHER. WINFORMS LISTVIEW JUST THROWS EXCEPTIONS, WHAT CAN WE DO? ))
//case 0x100C:
// {
// base.WndProc(ref m);
// int num = m.Result.ToInt32();
// messageProcessed = true;
// m.Result = new IntPtr(-1);
// break;
// }
//case 0x1012:
// {
// base.WndProc(ref m);
// int num = m.Result.ToInt32();
// messageProcessed = true;
// m.Result = new IntPtr(-1);
// break;
// }
case (int)WindowsMessage.WM_ERASEBKGND:
if (BlazingFast)
{
messageProcessed = true;
m.Result = new IntPtr(1);
}
break;
default:
break;
}
if(!messageProcessed) {
try {
base.WndProc(ref m);
} catch(Exception ex) {
Trace.WriteLine(string.Format("Message {0} caused an exception: {1}", m, ex.Message));
}
}
}
public bool BlazingFast = false;
protected ListViewItem GetItem(int idx) {
ListViewItem item = null;
if(QueryItem != null) {
QueryItem(idx, out item);
}
if(item == null) {
throw new ArgumentException("cannot find item " + idx.ToString() + " via QueryItem event");
}
return item;
}
protected void OnBeginItemDrag(MouseButtons mouseButton, ref System.Windows.Forms.Message m) {
NMLISTVIEW info = (NMLISTVIEW)m.GetLParam(typeof(NMLISTVIEW));
ListViewItem item = null;
if(QueryItem != null) {
QueryItem(info.iItem, out item);
}
OnItemDrag(new ItemDragEventArgs(mouseButton, item));
}
protected override void OnHandleCreated(System.EventArgs e) {
base.OnHandleCreated(e);
// ensure the value for ItemCount is sent to the control properly if the user set it
// before the handle was created
SetVirtualItemCount();
}
protected override void OnHandleDestroyed(System.EventArgs e) {
// the ListView OnHandleDestroyed accesses the Items list for all selected items
ItemCount = 0;
base.OnHandleDestroyed(e);
}
#endregion
LVHITTESTINFO lvhti = new LVHITTESTINFO();
IntPtr ptrlvhti;
int selection = -1;
public int hitTest(int x, int y) {
lvhti.pt.x = x;
lvhti.pt.y = y;
Marshal.StructureToPtr(lvhti, ptrlvhti, true);
int z = Win32.SendMessage(this.Handle, (int)ListViewMessages.LVM_HITTEST, 0, ptrlvhti.ToInt32());
Marshal.PtrToStructure(ptrlvhti, lvhti);
return z;
}
public void ensureVisible(int index) {
Win32.SendMessage(Handle, (int)ListViewMessages.LVM_ENSUREVISIBLE, index, 1);
}
public void ensureVisible() {
ensureVisible(selectedItem);
}
public void setSelection(int index) {
clearSelection();
selection = index;
SelectItem(selection, true);
}
public int selectedItem { get { if(SelectedIndices.Count == 0) return -1; else return SelectedIndices[0]; } set { setSelection(value); } }
public void clearSelection() {
if(selection != -1)
SelectItem(selection, false);
selection = -1;
}
}
}

View File

@ -0,0 +1,574 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
namespace BizHawk
{
public static class Win32
{
public static bool Is64BitProcess { get { return (IntPtr.Size == 8); } }
public static bool Is64BitOperatingSystem { get { return Is64BitProcess || InternalCheckIsWow64(); } }
[DllImport("kernel32.dll", SetLastError = true, CallingConvention = CallingConvention.Winapi)]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool IsWow64Process(
[In] IntPtr hProcess,
[Out] out bool wow64Process
);
static bool InternalCheckIsWow64()
{
if ((Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor >= 1) ||
Environment.OSVersion.Version.Major >= 6)
{
using (var p = System.Diagnostics.Process.GetCurrentProcess())
{
bool retVal;
if (!IsWow64Process(p.Handle, out retVal))
{
return false;
}
return retVal;
}
}
else
{
return false;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct RECT
{
private int _Left;
private int _Top;
private int _Right;
private int _Bottom;
public RECT(RECT Rectangle)
: this(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom)
{
}
public RECT(int Left, int Top, int Right, int Bottom)
{
_Left = Left;
_Top = Top;
_Right = Right;
_Bottom = Bottom;
}
public int X
{
get { return _Left; }
set { _Left = value; }
}
public int Y
{
get { return _Top; }
set { _Top = value; }
}
public int Left
{
get { return _Left; }
set { _Left = value; }
}
public int Top
{
get { return _Top; }
set { _Top = value; }
}
public int Right
{
get { return _Right; }
set { _Right = value; }
}
public int Bottom
{
get { return _Bottom; }
set { _Bottom = value; }
}
public int Height
{
get { return _Bottom - _Top; }
set { _Bottom = value - _Top; }
}
public int Width
{
get { return _Right - _Left; }
set { _Right = value + _Left; }
}
public Point Location
{
get { return new Point(Left, Top); }
set
{
_Left = value.X;
_Top = value.Y;
}
}
public Size Size
{
get { return new Size(Width, Height); }
set
{
_Right = value.Width + _Left;
_Bottom = value.Height + _Top;
}
}
public static implicit operator Rectangle(RECT Rectangle)
{
return new Rectangle(Rectangle.Left, Rectangle.Top, Rectangle.Width, Rectangle.Height);
}
public static implicit operator RECT(Rectangle Rectangle)
{
return new RECT(Rectangle.Left, Rectangle.Top, Rectangle.Right, Rectangle.Bottom);
}
public static bool operator ==(RECT Rectangle1, RECT Rectangle2)
{
return Rectangle1.Equals(Rectangle2);
}
public static bool operator !=(RECT Rectangle1, RECT Rectangle2)
{
return !Rectangle1.Equals(Rectangle2);
}
public override string ToString()
{
return "{Left: " + _Left + "; " + "Top: " + _Top + "; Right: " + _Right + "; Bottom: " + _Bottom + "}";
}
public override int GetHashCode()
{
return ToString().GetHashCode();
}
public bool Equals(RECT Rectangle)
{
return Rectangle.Left == _Left && Rectangle.Top == _Top && Rectangle.Right == _Right && Rectangle.Bottom == _Bottom;
}
public override bool Equals(object Object)
{
if (Object is RECT)
{
return Equals((RECT)Object);
}
else if (Object is Rectangle)
{
return Equals(new RECT((Rectangle)Object));
}
return false;
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct AVISTREAMINFOW
{
public Int32 fccType;
public Int32 fccHandler;
public Int32 dwFlags;
public Int32 dwCaps;
public Int16 wPriority;
public Int16 wLanguage;
public Int32 dwScale;
public Int32 dwRate;
public Int32 dwStart;
public Int32 dwLength;
public Int32 dwInitialFrames;
public Int32 dwSuggestedBufferSize;
public Int32 dwQuality;
public Int32 dwSampleSize;
public RECT rcFrame;
public Int32 dwEditCount;
public Int32 dwFormatChangeCount;
[MarshalAs(UnmanagedType.LPWStr, SizeConst=64)]
public string szName;
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct BITMAPINFOHEADER
{
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
public void Init()
{
biSize = (uint)Marshal.SizeOf(this);
}
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct WAVEFORMATEX
{
public ushort wFormatTag;
public ushort nChannels;
public uint nSamplesPerSec;
public uint nAvgBytesPerSec;
public ushort nBlockAlign;
public ushort wBitsPerSample;
public ushort cbSize;
public void Init()
{
cbSize = (ushort)Marshal.SizeOf(this);
}
}
public const int WAVE_FORMAT_PCM = 1;
public const int AVIIF_KEYFRAME = 0x00000010;
[Flags]
public enum OpenFileStyle : uint
{
OF_CANCEL = 0x00000800, // Ignored. For a dialog box with a Cancel button, use OF_PROMPT.
OF_CREATE = 0x00001000, // Creates a new file. If file exists, it is truncated to zero (0) length.
OF_DELETE = 0x00000200, // Deletes a file.
OF_EXIST = 0x00004000, // Opens a file and then closes it. Used to test that a file exists
OF_PARSE = 0x00000100, // Fills the OFSTRUCT structure, but does not do anything else.
OF_PROMPT = 0x00002000, // Displays a dialog box if a requested file does not exist
OF_READ = 0x00000000, // Opens a file for reading only.
OF_READWRITE = 0x00000002, // Opens a file with read/write permissions.
OF_REOPEN = 0x00008000, // Opens a file by using information in the reopen buffer.
// For MS-DOSbased file systems, opens a file with compatibility mode, allows any process on a
// specified computer to open the file any number of times.
// Other efforts to open a file with other sharing modes fail. This flag is mapped to the
// FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.
OF_SHARE_COMPAT = 0x00000000,
// Opens a file without denying read or write access to other processes.
// On MS-DOS-based file systems, if the file has been opened in compatibility mode
// by any other process, the function fails.
// This flag is mapped to the FILE_SHARE_READ|FILE_SHARE_WRITE flags of the CreateFile function.
OF_SHARE_DENY_NONE = 0x00000040,
// Opens a file and denies read access to other processes.
// On MS-DOS-based file systems, if the file has been opened in compatibility mode,
// or for read access by any other process, the function fails.
// This flag is mapped to the FILE_SHARE_WRITE flag of the CreateFile function.
OF_SHARE_DENY_READ = 0x00000030,
// Opens a file and denies write access to other processes.
// On MS-DOS-based file systems, if a file has been opened in compatibility mode,
// or for write access by any other process, the function fails.
// This flag is mapped to the FILE_SHARE_READ flag of the CreateFile function.
OF_SHARE_DENY_WRITE = 0x00000020,
// Opens a file with exclusive mode, and denies both read/write access to other processes.
// If a file has been opened in any other mode for read/write access, even by the current process,
// the function fails.
OF_SHARE_EXCLUSIVE = 0x00000010,
// Verifies that the date and time of a file are the same as when it was opened previously.
// This is useful as an extra check for read-only files.
OF_VERIFY = 0x00000400,
// Opens a file for write access only.
OF_WRITE = 0x00000001
}
[DllImport("avifil32.dll", SetLastError = true)]
public static extern int AVIFileOpenW(ref IntPtr pAviFile, [MarshalAs(UnmanagedType.LPWStr)] string szFile, OpenFileStyle uMode, int lpHandler);
[DllImport("avifil32.dll", SetLastError = true)]
public static extern void AVIFileInit();
// Create a new stream in an existing file and creates an interface to the new stream
[DllImport("avifil32.dll")]
public static extern int AVIFileCreateStreamW(
IntPtr pfile,
out IntPtr ppavi,
ref AVISTREAMINFOW psi);
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct AVICOMPRESSOPTIONS
{
public int fccType;
public int fccHandler;
public int dwKeyFrameEvery;
public int dwQuality;
public int dwBytesPerSecond;
public int dwFlags;
public int lpFormat;
public int cbFormat;
public int lpParms;
public int cbParms;
public int dwInterleaveEvery;
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
public static extern SafeFileHandle CreateFile(
string lpFileName,
uint dwDesiredAccess,
uint dwShareMode,
IntPtr SecurityAttributes,
uint dwCreationDisposition,
uint dwFlagsAndAttributes,
IntPtr hTemplateFile
);
[DllImport("kernel32.dll")]
public static extern FileType GetFileType(IntPtr hFile);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern System.IntPtr GetCommandLine();
public enum FileType : uint
{
FileTypeChar = 0x0002,
FileTypeDisk = 0x0001,
FileTypePipe = 0x0003,
FileTypeRemote = 0x8000,
FileTypeUnknown = 0x0000,
}
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetConsoleWindow();
[DllImport("user32.dll", SetLastError = true)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr SetActiveWindow(IntPtr hWnd);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool AttachConsole(int dwProcessId);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool AllocConsole();
[DllImport("kernel32.dll", SetLastError = false)]
public static extern bool FreeConsole();
[DllImport("kernel32.dll", SetLastError = true)]
public static extern IntPtr GetStdHandle(int nStdHandle);
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool SetStdHandle(int nStdHandle, IntPtr hConsoleOutput);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr CreateFile(
string fileName,
int desiredAccess,
int shareMode,
IntPtr securityAttributes,
int creationDisposition,
int flagsAndAttributes,
IntPtr templateFile);
[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
public static extern bool CloseHandle(IntPtr handle);
[DllImport("user32.dll", SetLastError = false)]
public static extern IntPtr GetDesktopWindow();
// Retrieve the save options for a file and returns them in a buffer
[DllImport("avifil32.dll")]
public static extern int AVISaveOptions(
IntPtr hwnd,
int flags,
int streams,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] ppavi,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] IntPtr[] plpOptions);
// Free the resources allocated by the AVISaveOptions function
[DllImport("avifil32.dll")]
public static extern int AVISaveOptionsFree(
int streams,
[In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] IntPtr[] plpOptions);
// Create a compressed stream from an uncompressed stream and a
// compression filter, and returns the address of a pointer to
// the compressed stream
[DllImport("avifil32.dll")]
public static extern int AVIMakeCompressedStream(
out IntPtr ppsCompressed,
IntPtr psSource,
ref AVICOMPRESSOPTIONS lpOptions,
IntPtr pclsidHandler);
// Set the format of a stream at the specified position
[DllImport("avifil32.dll")]
public static extern int AVIStreamSetFormat(
IntPtr pavi,
int lPos,
ref BITMAPINFOHEADER lpFormat,
int cbFormat);
// Set the format of a stream at the specified position
[DllImport("avifil32.dll")]
public static extern int AVIStreamSetFormat(
IntPtr pavi,
int lPos,
ref WAVEFORMATEX lpFormat,
int cbFormat);
// Write data to a stream
[DllImport("avifil32.dll")]
public static extern int AVIStreamWrite(
IntPtr pavi,
int lStart,
int lSamples,
IntPtr lpBuffer,
int cbBuffer,
int dwFlags,
IntPtr plSampWritten,
out int plBytesWritten);
// Release an open AVI stream
[DllImport("avifil32.dll")]
public static extern int AVIStreamRelease(
IntPtr pavi);
// Release an open AVI stream
[DllImport("avifil32.dll")]
public static extern int AVIFileRelease(
IntPtr pfile);
// Replacement of mmioFOURCC macros
public static int mmioFOURCC(string str)
{
return (
((int)(byte)(str[0])) |
((int)(byte)(str[1]) << 8) |
((int)(byte)(str[2]) << 16) |
((int)(byte)(str[3]) << 24));
}
public static bool FAILED(int hr) { return hr < 0; }
// Inverse of mmioFOURCC
public static string decode_mmioFOURCC(int code)
{
char[] chs = new char[4];
for (int i = 0; i < 4; i++)
{
chs[i] = (char)(byte)((code >> (i << 3)) & 0xFF);
if (!char.IsLetterOrDigit(chs[i]))
chs[i] = ' ';
}
return new string(chs);
}
[DllImport("user32.dll", CharSet = CharSet.Auto)]
public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
[DllImport("Kernel32.dll", EntryPoint = "RtlZeroMemory", SetLastError = false)]
public static extern void ZeroMemory(IntPtr dest, uint size);
[DllImport("msvcrt.dll", EntryPoint = "memset", CallingConvention = CallingConvention.Cdecl, SetLastError = false)]
public static extern IntPtr MemSet(IntPtr dest, int c, uint count);
[DllImport("shlwapi.dll", CharSet = CharSet.Auto)]
public static extern bool PathRelativePathTo(
[Out] System.Text.StringBuilder pszPath,
[In] string pszFrom,
[In] FileAttributes dwAttrFrom,
[In] string pszTo,
[In] FileAttributes dwAttrTo
);
/// <summary>
/// File attributes are metadata values stored by the file system on disk and are used by the system and are available to developers via various file I/O APIs.
/// </summary>
[Flags]
[CLSCompliant(false)]
public enum FileAttributes : uint
{
/// <summary>
/// A file that is read-only. Applications can read the file, but cannot write to it or delete it. This attribute is not honored on directories. For more information, see "You cannot view or change the Read-only or the System attributes of folders in Windows Server 2003, in Windows XP, or in Windows Vista".
/// </summary>
Readonly = 0x00000001,
/// <summary>
/// The file or directory is hidden. It is not included in an ordinary directory listing.
/// </summary>
Hidden = 0x00000002,
/// <summary>
/// A file or directory that the operating system uses a part of, or uses exclusively.
/// </summary>
System = 0x00000004,
/// <summary>
/// The handle that identifies a directory.
/// </summary>
Directory = 0x00000010,
/// <summary>
/// A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or removal.
/// </summary>
Archive = 0x00000020,
/// <summary>
/// This value is reserved for system use.
/// </summary>
Device = 0x00000040,
/// <summary>
/// A file that does not have other attributes set. This attribute is valid only when used alone.
/// </summary>
Normal = 0x00000080,
/// <summary>
/// A file that is being used for temporary storage. File systems avoid writing data back to mass storage if sufficient cache memory is available, because typically, an application deletes a temporary file after the handle is closed. In that scenario, the system can entirely avoid writing the data. Otherwise, the data is written after the handle is closed.
/// </summary>
Temporary = 0x00000100,
/// <summary>
/// A file that is a sparse file.
/// </summary>
SparseFile = 0x00000200,
/// <summary>
/// A file or directory that has an associated reparse point, or a file that is a symbolic link.
/// </summary>
ReparsePoint = 0x00000400,
/// <summary>
/// A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories.
/// </summary>
Compressed = 0x00000800,
/// <summary>
/// The data of a file is not available immediately. This attribute indicates that the file data is physically moved to offline storage. This attribute is used by Remote Storage, which is the hierarchical storage management software. Applications should not arbitrarily change this attribute.
/// </summary>
Offline = 0x00001000,
/// <summary>
/// The file or directory is not to be indexed by the content indexing service.
/// </summary>
NotContentIndexed = 0x00002000,
/// <summary>
/// A file or directory that is encrypted. For a file, all data streams in the file are encrypted. For a directory, encryption is the default for newly created files and subdirectories.
/// </summary>
Encrypted = 0x00004000,
/// <summary>
/// This value is reserved for system use.
/// </summary>
Virtual = 0x00010000
}
}
}

View File

@ -11,6 +11,8 @@ using System.Drawing.Imaging;
//using dx=SlimDX;
//using d3d=SlimDX.Direct3D9;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
/// <summary>
@ -391,19 +393,19 @@ namespace BizHawk.MultiClient
public void AddMessage(string message)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
messages.Add(new UIMessage { Message = message, ExpireAt = DateTime.Now + TimeSpan.FromSeconds(2) });
}
public void AddGUIText(string message, int x, int y, bool alert, Color BackGround, Color ForeColor, int anchor)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
GUITextList.Add(new UIDisplay { Message = message, X = x, Y = y, BackGround = BackGround, ForeColor = ForeColor, Alert = alert, Anchor = anchor });
}
public void ClearGUIText()
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
GUITextList.Clear();
}
@ -411,7 +413,7 @@ namespace BizHawk.MultiClient
public void DrawMessages(IBlitter g)
{
if (!Global.ClientControls["MaxTurbo"])
if (!GlobalWinF.ClientControls["MaxTurbo"])
{
messages.RemoveAll(m => DateTime.Now > m.ExpireAt);
int line = 1;
@ -483,7 +485,7 @@ namespace BizHawk.MultiClient
StringBuilder s;
if (!Global.MovieSession.Movie.IsActive || Global.MovieSession.Movie.IsFinished)
{
s = new StringBuilder(Global.GetOutputControllersAsMnemonic());
s = new StringBuilder(GlobalWinF.GetOutputControllersAsMnemonic());
}
else
{
@ -584,17 +586,17 @@ namespace BizHawk.MultiClient
g.DrawString(rerec, MessageFont, FixedMessagesColor, x, y);
}
if (Global.ClientControls["Autohold"] || Global.ClientControls["Autofire"])
if (GlobalWinF.ClientControls["Autohold"] || GlobalWinF.ClientControls["Autofire"])
{
StringBuilder disp = new StringBuilder("Held: ");
foreach (string s in Global.StickyXORAdapter.CurrentStickies)
foreach (string s in GlobalWinF.StickyXORAdapter.CurrentStickies)
{
disp.Append(s);
disp.Append(' ');
}
foreach (string s in Global.AutofireStickyXORAdapter.CurrentStickies)
foreach (string s in GlobalWinF.AutofireStickyXORAdapter.CurrentStickies)
{
disp.Append("Auto-");
disp.Append(s);
@ -660,7 +662,7 @@ namespace BizHawk.MultiClient
/// <summary>update Global.RenderPanel from the passed IVideoProvider</summary>
public void UpdateSource(IVideoProvider videoProvider)
{
UpdateSourceEx(videoProvider, Global.RenderPanel);
UpdateSourceEx(videoProvider, GlobalWinF.RenderPanel);
}
/// <summary>
@ -773,10 +775,10 @@ namespace BizHawk.MultiClient
void RenderOSD(IBlitter renderPanel)
{
Global.OSD.Begin(renderPanel);
GlobalWinF.OSD.Begin(renderPanel);
renderPanel.Open();
Global.OSD.DrawScreenInfo(renderPanel);
Global.OSD.DrawMessages(renderPanel);
GlobalWinF.OSD.DrawScreenInfo(renderPanel);
GlobalWinF.OSD.DrawMessages(renderPanel);
renderPanel.Close();
}

View File

@ -1,190 +0,0 @@
using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
//IDEA: put filesizes in DB too. then scans can go real quick by only scanning filesizes that match (and then scanning filesizes that dont match, in case of an emergency)
//this would be adviseable if we end up with a very large firmware file
namespace BizHawk.MultiClient
{
public class FirmwareManager
{
//represents a file found on disk in the user's firmware directory matching a file in our database
class RealFirmwareFile
{
public FileInfo fi;
public string hash;
}
public class ResolutionInfo
{
public bool UserSpecified;
public bool Missing;
public bool KnownMismatching;
public FirmwareDatabase.FirmwareFile KnownFirmwareFile;
public string FilePath;
public string Hash;
}
Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo> ResolutionDictionary = new Dictionary<FirmwareDatabase.FirmwareRecord, ResolutionInfo>();
public ResolutionInfo Resolve(string sysId, string firmwareId)
{
return Resolve(FirmwareDatabase.LookupFirmwareRecord(sysId, firmwareId));
}
public ResolutionInfo Resolve(FirmwareDatabase.FirmwareRecord record)
{
bool first = true;
RETRY:
ResolutionInfo resolved = null;
ResolutionDictionary.TryGetValue(record, out resolved);
//couldnt find it! do a scan and resolve to try harder
if (resolved == null && first)
{
DoScanAndResolve();
first = false;
goto RETRY;
}
return resolved;
}
//Requests the spcified firmware. tries really hard to scan and resolve as necessary
public string Request(string sysId, string firmwareId)
{
var resolved = Resolve(sysId, firmwareId);
if (resolved == null) return null;
return resolved.FilePath;
}
class RealFirmwareReader
{
byte[] buffer = new byte[0];
public RealFirmwareFile Read(FileInfo fi)
{
RealFirmwareFile rff = new RealFirmwareFile();
rff.fi = fi;
long len = fi.Length;
if (len > buffer.Length) buffer = new byte[len];
using (var fs = fi.OpenRead()) fs.Read(buffer, 0, (int)len);
rff.hash = Util.Hash_SHA1(buffer, 0, (int)len);
dict[rff.hash] = rff;
files.Add(rff);
return rff;
}
public Dictionary<string, RealFirmwareFile> dict = new Dictionary<string, RealFirmwareFile>();
public List<RealFirmwareFile> files = new List<RealFirmwareFile>();
}
public void DoScanAndResolve()
{
RealFirmwareReader reader = new RealFirmwareReader();
//build a list of files under the global firmwares path, and build a hash for each of them while we're at it
var todo = new Queue<DirectoryInfo>(new[] { new DirectoryInfo(Global.Config.PathEntries.FirmwaresPath) });
while (todo.Count != 0)
{
var di = todo.Dequeue();
//we're going to allow recursing into subdirectories, now. its been verified to work OK
foreach (var disub in di.GetDirectories()) todo.Enqueue(disub);
foreach (var fi in di.GetFiles())
{
reader.Read(fi);
}
}
//now, for each firmware record, try to resolve it
foreach (var fr in FirmwareDatabase.FirmwareRecords)
{
//clear previous resolution results
ResolutionDictionary.Remove(fr);
//get all options for this firmware (in order)
var options =
from fo in FirmwareDatabase.FirmwareOptions
where fo.systemId == fr.systemId && fo.firmwareId == fr.firmwareId
select fo;
//try each option
foreach (var fo in options)
{
var hash = fo.hash;
//did we find this firmware?
if (reader.dict.ContainsKey(hash))
{
//rad! then we can use it
var ri = new ResolutionInfo();
ri.FilePath = reader.dict[hash].fi.FullName;
ri.KnownFirmwareFile = FirmwareDatabase.FirmwareFilesByHash[hash];
ri.Hash = hash;
ResolutionDictionary[fr] = ri;
goto DONE_FIRMWARE;
}
}
DONE_FIRMWARE: ;
}
//apply user overrides
foreach (var fr in FirmwareDatabase.FirmwareRecords)
{
string userSpec = null;
//do we have a user specification for this firmware record?
if (Global.Config.FirmwareUserSpecifications.TryGetValue(fr.ConfigKey, out userSpec))
{
//flag it as user specified
ResolutionInfo ri = null;
if (!ResolutionDictionary.TryGetValue(fr, out ri))
{
ri = new ResolutionInfo();
ResolutionDictionary[fr] = ri;
}
ri.UserSpecified = true;
ri.KnownFirmwareFile = null;
ri.FilePath = userSpec;
ri.Hash = null;
//check whether it exists
var fi = new FileInfo(userSpec);
if (!fi.Exists)
{
ri.Missing = true;
continue;
}
//compute its hash
var rff = reader.Read(fi);
ri.Hash = rff.hash;
//check whether it was a known file anyway, and go ahead and bind to the known file, as a perk (the firmwares config doesnt really use this information right now)
FirmwareDatabase.FirmwareFile ff = null;
if(FirmwareDatabase.FirmwareFilesByHash.TryGetValue(rff.hash,out ff))
{
ri.KnownFirmwareFile = ff;
//if the known firmware file is for a different firmware, flag it so we can show a warning
var option =
(from fo in FirmwareDatabase.FirmwareOptions
where fo.hash == rff.hash && fo.ConfigKey != fr.ConfigKey
select fr).FirstOrDefault();
if (option != null)
ri.KnownMismatching = true;
}
}
}
}
}
}

View File

@ -1,102 +0,0 @@
using BizHawk.DiscSystem;
using SlimDX.Direct3D9;
using SlimDX.DirectSound;
#if WINDOWS
#endif
namespace BizHawk.MultiClient
{
public static class Global
{
public static MainForm MainForm;
#if WINDOWS
public static DirectSound DSound;
public static Direct3D Direct3D;
#endif
public static Sound Sound;
public static IRenderer RenderPanel;
public static OSDManager OSD = new OSDManager();
public static DisplayManager DisplayManager = new DisplayManager();
public static Config Config;
public static IEmulator Emulator;
public static CoreComm CoreComm;
public static GameInfo Game;
public static CheatList CheatList;
public static Controller NullControls;
public static AutofireController AutofireNullControls;
/// <summary>
/// whether throttling is force-disabled by use of fast forward
/// </summary>
public static bool ForceNoThrottle;
//the movie will be spliced inbetween these if it is present
public static CopyControllerAdapter MovieInputSourceAdapter = new CopyControllerAdapter();
public static CopyControllerAdapter MovieOutputHardpoint = new CopyControllerAdapter();
/// <summary>
/// the global MovieSession can use this to deal with multitrack player remapping (should this be here? maybe it should be in MovieSession)
/// </summary>
public static MultitrackRewiringControllerAdapter MultitrackRewiringControllerAdapter = new MultitrackRewiringControllerAdapter();
public static MovieSession MovieSession = new MovieSession();
//dont take my word for it, since the final word is actually in RewireInputChain, but here is a guide...
//user -> Input -> ActiveController -> UDLR -> StickyXORPlayerInputAdapter -> TurboAdapter(TBD) -> Lua(?TBD?) -> ..
//.. -> MultitrackRewiringControllerAdapter -> MovieInputSourceAdapter -> (MovieSession) -> MovieOutputAdapter -> ControllerOutput(1) -> Game
//(1)->Input Display
//the original source controller, bound to the user, sort of the "input" port for the chain, i think
public static Controller ActiveController;
//rapid fire version on the user controller, has its own key bindings and is OR'ed against ActiveController
public static AutofireController AutoFireController;
//the "output" port for the controller chain.
public static CopyControllerAdapter ControllerOutput = new CopyControllerAdapter();
//input state which has been destined for game controller inputs are coalesced here
public static ControllerInputCoalescer ControllerInputCoalescer = new ControllerInputCoalescer();
//input state which has been destined for client hotkey consumption are colesced here
public static InputCoalescer HotkeyCoalescer = new InputCoalescer();
public static UD_LR_ControllerAdapter UD_LR_ControllerAdapter = new UD_LR_ControllerAdapter();
/// <summary>
/// provides an opportunity to mutate the player's input in an autohold style
/// </summary>
public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter();
public static AutoFireStickyXORAdapter AutofireStickyXORAdapter = new AutoFireStickyXORAdapter();
/// <summary>
/// Forces any controller button to Off, useful for things like Joypad.Set
/// </summary>
public static ForceOffAdaptor ForceOffAdaptor = new ForceOffAdaptor();
/// <summary>
/// will OR together two IControllers
/// </summary>
public static ORAdapter OrControllerAdapter = new ORAdapter();
/// <summary>
/// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons
/// </summary>
public static ClickyVirtualPadController ClickyVirtualPadController = new ClickyVirtualPadController();
public static SimpleController MovieOutputController = new SimpleController();
public static Controller ClientControls;
public static string GetOutputControllersAsMnemonic()
{
MnemonicsGenerator mg = new MnemonicsGenerator();
mg.SetSource(ControllerOutput);
return mg.GetControllersAsMnemonic();
}
public static DiscHopper DiscHopper = new DiscHopper();
}
}

View File

@ -1,394 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BizHawk.MultiClient
{
//todo:
//split into "bind" and "open (the bound thing)"
//scan archive to flatten interior directories down to a path (maintain our own archive item list)
public class HawkFile : IDisposable
{
public static bool ExistsAt(string path)
{
using (var file = new HawkFile(path))
{
return file.Exists;
}
}
public static byte[] ReadAllBytes(string path)
{
using (var file = new HawkFile(path))
{
if (!file.Exists) throw new FileNotFoundException(path);
using (Stream stream = file.GetStream())
{
MemoryStream ms = new MemoryStream((int)stream.Length);
stream.CopyTo(ms);
return ms.GetBuffer();
}
}
}
/// <summary>
/// returns whether a bound file exists. if there is no bound file, it can't exist
/// </summary>
public bool Exists { get { return exists; } }
/// <summary>
/// gets the directory containing the root
/// </summary>
public string Directory { get { return Path.GetDirectoryName(rootPath); } }
/// <summary>
/// returns a stream for the currently bound file
/// </summary>
public Stream GetStream()
{
if (boundStream == null)
throw new InvalidOperationException("HawkFile: Can't call GetStream() before youve successfully bound something!");
return boundStream;
}
/// <summary>
/// indicates whether this instance is bound
/// </summary>
public bool IsBound { get { return boundStream != null; } }
/// <summary>
/// returns the complete canonical full path ("c:\path\to\archive|member") of the bound file
/// </summary>
public string CanonicalFullPath { get { return MakeCanonicalName(rootPath, memberPath); } }
/// <summary>
/// returns the complete canonical name ("archive|member") of the bound file
/// </summary>
public string CanonicalName { get { return MakeCanonicalName(Path.GetFileName(rootPath), memberPath); } }
/// <summary>
/// returns the virtual name of the bound file (disregarding the archive)
/// </summary>
public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath, memberPath)); } }
/// <summary>
/// returns the extension of Name
/// </summary>
public string Extension { get { return Path.GetExtension(Name).ToUpper(); } }
/// <summary>
/// Indicates whether this file is an archive
/// </summary>
public bool IsArchive { get { return extractor != null; } }
int? BoundIndex = null;
public int? GetBoundIndex()
{
return BoundIndex;
}
public class ArchiveItem
{
public string name;
public long size;
public int index;
}
public IEnumerable<ArchiveItem> ArchiveItems
{
get
{
if (!IsArchive) throw new InvalidOperationException("Cant get archive items from non-archive");
return archiveItems;
}
}
/// <summary>
/// these extensions won't even be tried as archives (removes spurious archive detects since some of the signatures are pretty damn weak)
/// </summary>
public string[] NonArchiveExtensions = new string[] { };
//---
bool exists;
bool rootExists;
string rootPath;
string memberPath;
Stream rootStream, boundStream;
SevenZip.SevenZipExtractor extractor;
List<ArchiveItem> archiveItems;
public HawkFile()
{
}
public void Open(string path)
{
if (rootPath != null) throw new InvalidOperationException("Don't reopen a HawkFile.");
string autobind = null;
bool isArchivePath = IsCanonicalArchivePath(path);
if (isArchivePath)
{
string[] parts = path.Split('|');
path = parts[0];
autobind = parts[1];
}
var fi = new FileInfo(path);
rootExists = fi.Exists;
if (fi.Exists == false)
return;
rootPath = path;
exists = true;
AnalyzeArchive(path);
if (extractor == null)
{
rootStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
//we could autobind here, but i dont want to
//bind it later with the desired extensions.
}
if (autobind == null)
{
//non-archive files can be automatically bound this way
if (!isArchivePath)
BindRoot();
}
else
{
autobind = autobind.ToUpperInvariant();
for (int i = 0; i < extractor.ArchiveFileData.Count; i++)
{
if (FixArchiveFilename(extractor.ArchiveFileNames[i]).ToUpperInvariant() == autobind)
{
BindArchiveMember(i);
return;
}
}
exists = false;
}
}
public HawkFile(string path)
{
Open(path);
}
/// <summary>
/// is the supplied path a canonical name including an archive?
/// </summary>
bool IsCanonicalArchivePath(string path)
{
return (path.IndexOf('|') != -1);
}
/// <summary>
/// converts a canonical name to a bound name (the bound part, whether or not it is an archive)
/// </summary>
string GetBoundNameFromCanonical(string canonical)
{
string[] parts = canonical.Split('|');
return parts[parts.Length - 1];
}
/// <summary>
/// makes a canonical name from two parts
/// </summary>
string MakeCanonicalName(string root, string member)
{
if (member == null) return root;
else return string.Format("{0}|{1}", root, member);
}
string FixArchiveFilename(string fn)
{
return fn.Replace('\\', '/');
}
/// <summary>
/// binds the specified ArchiveItem which you should have gotten by interrogating an archive hawkfile
/// </summary>
public HawkFile BindArchiveMember(ArchiveItem item)
{
return BindArchiveMember(item.index);
}
/// <summary>
/// finds an ArchiveItem with the specified name (path) within the archive; returns null if it doesnt exist
/// </summary>
public ArchiveItem FindArchiveMember(string name)
{
return ArchiveItems.FirstOrDefault(ai => ai.name == name);
}
/// <summary>
/// binds a path within the archive; returns null if that path didnt exist.
/// </summary>
public HawkFile BindArchiveMember(string name)
{
var ai = FindArchiveMember(name);
if (ai == null) return null;
else return BindArchiveMember(ai);
}
/// <summary>
/// binds the selected archive index
/// </summary>
public HawkFile BindArchiveMember(int archiveIndex)
{
if (!rootExists) return this;
if (boundStream != null) throw new InvalidOperationException("stream already bound!");
boundStream = new MemoryStream();
extractor.ExtractFile(archiveIndex, boundStream);
boundStream.Position = 0;
memberPath = FixArchiveFilename(extractor.ArchiveFileNames[archiveIndex]); //TODO - maybe go through our own list of names? maybe not, its indexes dont match..
Console.WriteLine("HawkFile bound " + CanonicalFullPath);
BoundIndex = archiveIndex;
return this;
}
/// <summary>
/// Removes any existing binding
/// </summary>
public void Unbind()
{
if (boundStream != null && boundStream != rootStream) boundStream.Close();
boundStream = null;
memberPath = null;
BoundIndex = null;
}
/// <summary>
/// causes the root to be bound (in the case of non-archive files)
/// </summary>
void BindRoot()
{
boundStream = rootStream;
Console.WriteLine("HawkFile bound " + CanonicalFullPath);
}
/// <summary>
/// Binds the first item in the archive (or the file itself). Supposing that there is anything in the archive.
/// </summary>
public HawkFile BindFirst()
{
BindFirstOf();
return this;
}
/// <summary>
/// binds one of the supplied extensions if there is only one match in the archive
/// </summary>
public HawkFile BindSoleItemOf(params string[] extensions)
{
return BindByExtensionCore(false, extensions);
}
/// <summary>
/// Binds the first item in the archive (or the file itself) if the extension matches one of the supplied templates.
/// You probably should not use this. use BindSoleItemOf or the archive chooser instead
/// </summary>
public HawkFile BindFirstOf(params string[] extensions)
{
return BindByExtensionCore(true, extensions);
}
HawkFile BindByExtensionCore(bool first, params string[] extensions)
{
if (!rootExists) return this;
if (boundStream != null) throw new InvalidOperationException("stream already bound!");
if (extractor == null)
{
//open uncompressed file
string extension = Path.GetExtension(rootPath).Substring(1).ToUpperInvariant();
if (extensions.Length == 0 || extension.In(extensions))
{
BindRoot();
}
return this;
}
var candidates = new List<int>();
for (int i = 0; i < extractor.ArchiveFileData.Count; i++)
{
var e = extractor.ArchiveFileData[i];
if (e.IsDirectory) continue;
var extension = Path.GetExtension(e.FileName).ToUpperInvariant();
extension = extension.TrimStart('.');
if (extensions.Length == 0 || extension.In(extensions))
{
if (first)
{
BindArchiveMember(i);
return this;
}
candidates.Add(i);
}
}
if (candidates.Count == 1)
BindArchiveMember(candidates[0]);
return this;
}
void ScanArchive()
{
archiveItems = new List<ArchiveItem>();
for (int i = 0; i < extractor.ArchiveFileData.Count; i++)
{
var afd = extractor.ArchiveFileData[i];
if (afd.IsDirectory) continue;
var ai = new ArchiveItem {name = FixArchiveFilename(afd.FileName), size = (long) afd.Size, index = i};
archiveItems.Add(ai);
}
}
private void AnalyzeArchive(string path)
{
SevenZip.FileChecker.ThrowExceptions = false;
int offset;
bool isExecutable;
if (NonArchiveExtensions.Any(ext => Path.GetExtension(path).Substring(1).ToLower() == ext.ToLower()))
{
return;
}
if (SevenZip.FileChecker.CheckSignature(path, out offset, out isExecutable) != SevenZip.InArchiveFormat.None)
{
extractor = new SevenZip.SevenZipExtractor(path);
try
{
ScanArchive();
}
catch
{
extractor.Dispose();
extractor = null;
archiveItems = null;
}
}
}
public void Dispose()
{
Unbind();
if (extractor != null) extractor.Dispose();
if (rootStream != null) rootStream.Dispose();
extractor = null;
rootStream = null;
}
}
}

View File

@ -2,6 +2,8 @@
using System.Collections.Generic;
using System.Linq;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public class Controller : IController
@ -14,7 +16,7 @@ namespace BizHawk.MultiClient
private readonly Dictionary<string, ControllerDefinition.FloatRange> FloatRanges = new WorkingDictionary<string, ControllerDefinition.FloatRange>();
private readonly Dictionary<string, Config.AnalogBind> FloatBinds = new Dictionary<string, Config.AnalogBind>();
private readonly Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> FloatBinds = new Dictionary<string, Config.AnalogBind>();
public Controller(ControllerDefinition definition)
{
@ -153,7 +155,7 @@ namespace BizHawk.MultiClient
bindings[button].Add(control.Trim());
}
public void BindFloat(string button, Config.AnalogBind bind)
public void BindFloat(string button, BizHawk.Client.Common.Config.AnalogBind bind)
{
FloatBinds[button] = bind;
}

View File

@ -27,7 +27,7 @@ namespace BizHawk.MultiClient
continue; // Don't input XBOX 360 controllers into here; we'll process them via XInput (there are limitations in some trigger axes when xbox pads go over xinput)
var joystick = new Joystick(dinput, device.InstanceGuid);
joystick.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
joystick.SetCooperativeLevel(GlobalWinF.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
foreach (DeviceObjectInstance deviceObject in joystick.GetObjects())
{
if ((deviceObject.ObjectType & ObjectDeviceType.Axis) != 0)

View File

@ -6,6 +6,8 @@ using System.Threading;
using SlimDX.DirectInput;
#endif
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
//coalesces events back into instantaneous states
@ -337,7 +339,7 @@ namespace BizHawk.MultiClient
}
bool swallow = !Global.MainForm.AllowInput;
bool swallow = !GlobalWinF.MainForm.AllowInput;
foreach (var ie in _NewEvents)
{
@ -399,7 +401,7 @@ namespace BizHawk.MultiClient
lock (this)
{
if (InputEvents.Count == 0) return null;
if (!Global.MainForm.AllowInput) return null;
if (!GlobalWinF.MainForm.AllowInput) return null;
//we only listen to releases for input binding, because we need to distinguish releases of pure modifierkeys from modified keys
//if you just pressed ctrl, wanting to bind ctrl, we'd see: pressed:ctrl, unpressed:ctrl

View File

@ -16,7 +16,7 @@ namespace BizHawk.MultiClient
if (keyboard == null || keyboard.Disposed)
keyboard = new Keyboard(dinput);
keyboard.SetCooperativeLevel(Global.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
keyboard.SetCooperativeLevel(GlobalWinF.MainForm.Handle, CooperativeLevel.Background | CooperativeLevel.Nonexclusive);
}
public static void Update()

View File

@ -3,6 +3,8 @@ using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using BizHawk.Client.Common;
#pragma warning disable 162
//thanks! - http://sharp-developer.net/ru/CodeBank/WinForms/GuiConsole.aspx

View File

@ -4,6 +4,8 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
//todo - perks - pause, copy to clipboard, backlog length limiting
namespace BizHawk.MultiClient
@ -18,7 +20,7 @@ namespace BizHawk.MultiClient
Closing += (o, e) =>
{
Global.Config.ShowLogWindow = false;
Global.MainForm.notifyLogWindowClosing();
GlobalWinF.MainForm.notifyLogWindowClosing();
LogConsole.notifyLogWindowClosing();
SaveConfigSettings();
};

View File

@ -7,6 +7,8 @@ using BizHawk.Emulation.Consoles.Calculator;
using BizHawk.Emulation.Consoles.GB;
using BizHawk.Emulation.Consoles.Nintendo.SNES;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
partial class MainForm
@ -30,9 +32,9 @@ namespace BizHawk.MultiClient
{
string details = Global.Emulator.CoreComm.RomStatusDetails;
if (string.IsNullOrEmpty(details)) return;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
LogWindow.ShowReport("Dump Status Report", details, this);
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
}
private void saveWindowPositionToolStripMenuItem_Click(object sender, EventArgs e)
@ -62,7 +64,7 @@ namespace BizHawk.MultiClient
old = Global.Config.VSyncThrottle;
Global.Config.VSyncThrottle = false;
if (old)
Global.RenderPanel.Resized = true;
GlobalWinF.RenderPanel.Resized = true;
}
LimitFrameRateMessage();
}
@ -77,7 +79,7 @@ namespace BizHawk.MultiClient
bool old = Global.Config.VSyncThrottle;
Global.Config.VSyncThrottle = false;
if (old)
Global.RenderPanel.Resized = true;
GlobalWinF.RenderPanel.Resized = true;
}
}
@ -85,7 +87,7 @@ namespace BizHawk.MultiClient
private void miDisplayVsync_Click(object sender, EventArgs e)
{
Global.Config.VSyncThrottle ^= true;
Global.RenderPanel.Resized = true;
GlobalWinF.RenderPanel.Resized = true;
if (Global.Config.VSyncThrottle)
{
Global.Config.ClockThrottle = false;
@ -101,18 +103,18 @@ namespace BizHawk.MultiClient
{
Global.Config.VSync ^= true;
if (!Global.Config.VSyncThrottle) // when vsync throttle is on, vsync is forced to on, so no change to make here
Global.RenderPanel.Resized = true;
GlobalWinF.RenderPanel.Resized = true;
}
public void LimitFrameRateMessage()
{
if (Global.Config.ClockThrottle)
{
Global.OSD.AddMessage("Framerate limiting on");
GlobalWinF.OSD.AddMessage("Framerate limiting on");
}
else
{
Global.OSD.AddMessage("Framerate limiting off");
GlobalWinF.OSD.AddMessage("Framerate limiting off");
}
}
@ -121,11 +123,11 @@ namespace BizHawk.MultiClient
{
if (Global.Config.VSyncThrottle)
{
Global.OSD.AddMessage("Display Vsync is set to on");
GlobalWinF.OSD.AddMessage("Display Vsync is set to on");
}
else
{
Global.OSD.AddMessage("Display Vsync is set to off");
GlobalWinF.OSD.AddMessage("Display Vsync is set to off");
}
}
@ -138,11 +140,11 @@ namespace BizHawk.MultiClient
{
if (Global.Config.AutoMinimizeSkipping)
{
Global.OSD.AddMessage("Autominimizing set to on");
GlobalWinF.OSD.AddMessage("Autominimizing set to on");
}
else
{
Global.OSD.AddMessage("Autominimizing set to off");
GlobalWinF.OSD.AddMessage("Autominimizing set to off");
}
}
@ -159,7 +161,7 @@ namespace BizHawk.MultiClient
public void FrameSkipMessage()
{
Global.OSD.AddMessage("Frameskipping set to " + Global.Config.FrameSkip.ToString());
GlobalWinF.OSD.AddMessage("Frameskipping set to " + Global.Config.FrameSkip.ToString());
}
public void ClickSpeedItem(int num)
@ -466,25 +468,25 @@ namespace BizHawk.MultiClient
private void displayFPSToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
ToggleFPS();
}
private void displayFrameCounterToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
ToggleFrameCounter();
}
private void displayInputToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
ToggleInputDisplay();
}
private void displayLagCounterToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
ToggleLagCounter();
}
@ -696,7 +698,7 @@ namespace BizHawk.MultiClient
private void displayRerecordCountToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
Global.Config.DisplayRerecordCount ^= true;
}
@ -733,9 +735,9 @@ namespace BizHawk.MultiClient
Filter = "PNG File (*.png)|*.png"
};
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return;
TakeScreenshot(sfd.FileName);
@ -761,11 +763,11 @@ namespace BizHawk.MultiClient
Global.Config.AcceptBackgroundInput ^= true;
if (Global.Config.AcceptBackgroundInput)
{
Global.OSD.AddMessage("Background Input enabled");
GlobalWinF.OSD.AddMessage("Background Input enabled");
}
else
{
Global.OSD.AddMessage("Background Input disabled");
GlobalWinF.OSD.AddMessage("Background Input disabled");
}
}
@ -827,11 +829,11 @@ namespace BizHawk.MultiClient
Global.Config.ShowContextMenu ^= true;
if (Global.Config.ShowContextMenu)
{
Global.OSD.AddMessage("Context menu enabled");
GlobalWinF.OSD.AddMessage("Context menu enabled");
}
else
{
Global.OSD.AddMessage("Context menu disabled");
GlobalWinF.OSD.AddMessage("Context menu disabled");
}
}
@ -858,7 +860,7 @@ namespace BizHawk.MultiClient
Subtitle sub = new Subtitle();
for (int x = 0; x < Global.MovieSession.Movie.Subtitles.Count; x++)
{
sub = Global.MovieSession.Movie.Subtitles.GetSubtitleByIndex(x);
sub = Global.MovieSession.Movie.Subtitles[x];
if (Global.Emulator.Frame == sub.Frame)
{
index = x;
@ -874,7 +876,7 @@ namespace BizHawk.MultiClient
if (s.ShowDialog() == DialogResult.OK)
{
if (index >= 0)
Global.MovieSession.Movie.Subtitles.Remove(index);
Global.MovieSession.Movie.Subtitles.RemoveAt(index);
Global.MovieSession.Movie.Subtitles.AddSubtitle(s.sub);
}
}
@ -1042,6 +1044,7 @@ namespace BizHawk.MultiClient
private void makeMovieBackupToolStripMenuItem_Click(object sender, EventArgs e)
{
GlobalWinF.OSD.AddMessage("Backup movie saved.");
Global.MovieSession.Movie.WriteBackup();
}
@ -1072,7 +1075,7 @@ namespace BizHawk.MultiClient
private void displaySubtitlesToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
Global.Config.DisplaySubtitles ^= true;
}
@ -1181,14 +1184,14 @@ namespace BizHawk.MultiClient
private void saveConfigToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveConfig();
Global.OSD.AddMessage("Saved settings");
GlobalWinF.OSD.AddMessage("Saved settings");
}
private void loadConfigToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config = ConfigService.Load(PathManager.DefaultIniPath, Global.Config);
Global.Config.ResolveDefaults();
Global.OSD.AddMessage("Config file loaded");
GlobalWinF.OSD.AddMessage("Config file loaded");
}
private void frameSkipToolStripMenuItem_DropDownOpened(object sender, EventArgs e)
@ -1273,7 +1276,7 @@ namespace BizHawk.MultiClient
private void menuStrip1_MenuDeactivate(object sender, EventArgs e)
{
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
if (!wasPaused)
{
UnpauseEmulator();
@ -1500,11 +1503,11 @@ namespace BizHawk.MultiClient
Global.Config.BackupSavestates ^= true;
if (Global.Config.BackupSavestates)
{
Global.OSD.AddMessage("Backup savestates enabled");
GlobalWinF.OSD.AddMessage("Backup savestates enabled");
}
else
{
Global.OSD.AddMessage("Backup savestates disabled");
GlobalWinF.OSD.AddMessage("Backup savestates disabled");
}
}
@ -1513,11 +1516,11 @@ namespace BizHawk.MultiClient
Global.Config.AutoSavestates ^= true;
if (Global.Config.AutoSavestates)
{
Global.OSD.AddMessage("AutoSavestates enabled");
GlobalWinF.OSD.AddMessage("AutoSavestates enabled");
}
else
{
Global.OSD.AddMessage("AutoSavestates disabled");
GlobalWinF.OSD.AddMessage("AutoSavestates disabled");
}
}
@ -1526,11 +1529,11 @@ namespace BizHawk.MultiClient
Global.Config.SaveScreenshotWithStates ^= true;
if (Global.Config.SaveScreenshotWithStates)
{
Global.OSD.AddMessage("Screenshots will be saved in savestates");
GlobalWinF.OSD.AddMessage("Screenshots will be saved in savestates");
}
else
{
Global.OSD.AddMessage("Screenshots will not be saved in savestates");
GlobalWinF.OSD.AddMessage("Screenshots will not be saved in savestates");
}
}
@ -1538,7 +1541,7 @@ namespace BizHawk.MultiClient
{
string path = PathManager.SaveStatePrefix(Global.Game) + "." + "QuickSave" + Global.Config.SaveSlot + ".State";
SwapBackupSavestate(path);
Global.OSD.AddMessage("Save slot " + Global.Config.SaveSlot.ToString() + " restored.");
GlobalWinF.OSD.AddMessage("Save slot " + Global.Config.SaveSlot.ToString() + " restored.");
}
private void FreezeStatus_Click(object sender, EventArgs e)
@ -1602,9 +1605,9 @@ namespace BizHawk.MultiClient
Global.Config.Atari2600_BW ^= true;
((Atari2600)Global.Emulator).SetBw(Global.Config.Atari2600_BW);
if (Global.Config.Atari2600_BW)
Global.OSD.AddMessage("Setting to Black and White Switch to On");
GlobalWinF.OSD.AddMessage("Setting to Black and White Switch to On");
else
Global.OSD.AddMessage("Setting to Black and White Switch to Off");
GlobalWinF.OSD.AddMessage("Setting to Black and White Switch to Off");
}
}
@ -1615,9 +1618,9 @@ namespace BizHawk.MultiClient
Global.Config.Atari2600_LeftDifficulty ^= true;
((Atari2600)Global.Emulator).SetP0Diff(Global.Config.Atari2600_BW);
if (Global.Config.Atari2600_LeftDifficulty)
Global.OSD.AddMessage("Setting Left Difficulty to B");
GlobalWinF.OSD.AddMessage("Setting Left Difficulty to B");
else
Global.OSD.AddMessage("Setting Left Difficulty to A");
GlobalWinF.OSD.AddMessage("Setting Left Difficulty to A");
}
}
@ -1628,9 +1631,9 @@ namespace BizHawk.MultiClient
Global.Config.Atari2600_RightDifficulty ^= true;
((Atari2600)Global.Emulator).SetP1Diff(Global.Config.Atari2600_BW);
if (Global.Config.Atari2600_RightDifficulty)
Global.OSD.AddMessage("Setting Right Difficulty to B");
GlobalWinF.OSD.AddMessage("Setting Right Difficulty to B");
else
Global.OSD.AddMessage("Setting Right Difficulty to A");
GlobalWinF.OSD.AddMessage("Setting Right Difficulty to A");
}
}
@ -1698,11 +1701,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG1_1)
{
Global.OSD.AddMessage("BG 1 Layer On");
GlobalWinF.OSD.AddMessage("BG 1 Layer On");
}
else
{
Global.OSD.AddMessage("BG 1 Layer Off");
GlobalWinF.OSD.AddMessage("BG 1 Layer Off");
}
}
}
@ -1722,11 +1725,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG2_1)
{
Global.OSD.AddMessage("BG 2 Layer On");
GlobalWinF.OSD.AddMessage("BG 2 Layer On");
}
else
{
Global.OSD.AddMessage("BG 2 Layer Off");
GlobalWinF.OSD.AddMessage("BG 2 Layer Off");
}
}
}
@ -1746,11 +1749,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG3_1)
{
Global.OSD.AddMessage("BG 3 Layer On");
GlobalWinF.OSD.AddMessage("BG 3 Layer On");
}
else
{
Global.OSD.AddMessage("BG 3 Layer Off");
GlobalWinF.OSD.AddMessage("BG 3 Layer Off");
}
}
}
@ -1770,11 +1773,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowBG4_1)
{
Global.OSD.AddMessage("BG 4 Layer On");
GlobalWinF.OSD.AddMessage("BG 4 Layer On");
}
else
{
Global.OSD.AddMessage("BG 4 Layer Off");
GlobalWinF.OSD.AddMessage("BG 4 Layer Off");
}
}
}
@ -1794,11 +1797,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ1)
{
Global.OSD.AddMessage("OBJ 1 Layer On");
GlobalWinF.OSD.AddMessage("OBJ 1 Layer On");
}
else
{
Global.OSD.AddMessage("OBJ 1 Layer Off");
GlobalWinF.OSD.AddMessage("OBJ 1 Layer Off");
}
}
}
@ -1818,11 +1821,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ2)
{
Global.OSD.AddMessage("OBJ 2 Layer On");
GlobalWinF.OSD.AddMessage("OBJ 2 Layer On");
}
else
{
Global.OSD.AddMessage("OBJ 2 Layer Off");
GlobalWinF.OSD.AddMessage("OBJ 2 Layer Off");
}
}
}
@ -1842,11 +1845,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ3)
{
Global.OSD.AddMessage("OBJ 3 Layer On");
GlobalWinF.OSD.AddMessage("OBJ 3 Layer On");
}
else
{
Global.OSD.AddMessage("OBJ 3 Layer Off");
GlobalWinF.OSD.AddMessage("OBJ 3 Layer Off");
}
}
}
@ -1866,11 +1869,11 @@ namespace BizHawk.MultiClient
SyncCoreCommInputSignals();
if (Global.Config.SNES_ShowOBJ4)
{
Global.OSD.AddMessage("OBJ 4 Layer On");
GlobalWinF.OSD.AddMessage("OBJ 4 Layer On");
}
else
{
Global.OSD.AddMessage("OBJ 4 Layer Off");
GlobalWinF.OSD.AddMessage("OBJ 4 Layer Off");
}
}
}
@ -2140,9 +2143,9 @@ namespace BizHawk.MultiClient
RestoreDirectory = false
};
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = ofd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return;
@ -2177,7 +2180,7 @@ namespace BizHawk.MultiClient
}
else if (IsValidMovieExtension(ext))
{
Movie m = new Movie(filePaths[0]);
Movie m = new Movie(filePaths[0], GlobalWinF.MainForm.GetEmuVersion());
StartNewMovie(m, false);
}
@ -2189,6 +2192,7 @@ namespace BizHawk.MultiClient
{
Global.CheatList.Load(filePaths[0], false);
LoadCheatsWindow();
ToolHelpers.UpdateCheatRelatedTools();
}
else if (ext.ToUpper() == ".WCH")
{
@ -2211,7 +2215,7 @@ namespace BizHawk.MultiClient
string errorMsg;
string warningMsg;
Movie m = MovieImport.ImportFile(filePaths[0], out errorMsg, out warningMsg);
Movie m = MovieImport.ImportFile(filePaths[0], GlobalWinF.MainForm.GetEmuVersion(), out errorMsg, out warningMsg);
if (errorMsg.Length > 0)
{
MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@ -2225,7 +2229,7 @@ namespace BizHawk.MultiClient
m.WriteMovie();
StartNewMovie(m, false);
}
Global.OSD.AddMessage(warningMsg);
GlobalWinF.OSD.AddMessage(warningMsg);
}
else
LoadRom(filePaths[0]);
@ -2258,12 +2262,12 @@ namespace BizHawk.MultiClient
private void createDualGBXMLToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
using (var dlg = new GBtools.DualGBXMLCreator())
{
dlg.ShowDialog(this);
}
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
}
private void tempN64PluginControlToolStripMenuItem_Click(object sender, EventArgs e)
@ -2271,11 +2275,11 @@ namespace BizHawk.MultiClient
var result = new N64VideoPluginconfig().ShowDialog();
if (result == DialogResult.OK)
{
Global.OSD.AddMessage("Plugin settings saved");
GlobalWinF.OSD.AddMessage("Plugin settings saved");
}
else
{
Global.OSD.AddMessage("Plugin settings aborted");
GlobalWinF.OSD.AddMessage("Plugin settings aborted");
}
}
@ -2309,7 +2313,7 @@ namespace BizHawk.MultiClient
private void preferencesToolStripMenuItem_Click(object sender, EventArgs e)
{
using (var dlg = new SATTools.SaturnPrefs())
using (var dlg = new SaturnPrefs())
{
var result = dlg.ShowDialog(this);
if (result == DialogResult.OK)
@ -2412,7 +2416,7 @@ namespace BizHawk.MultiClient
private void MainForm_Resize(object sender, EventArgs e)
{
Global.RenderPanel.Resized = true;
GlobalWinF.RenderPanel.Resized = true;
}
private void backupSaveramToolStripMenuItem_Click(object sender, EventArgs e)
@ -2420,11 +2424,11 @@ namespace BizHawk.MultiClient
Global.Config.BackupSaveram ^= true;
if (Global.Config.BackupSaveram)
{
Global.OSD.AddMessage("Backup saveram enabled");
GlobalWinF.OSD.AddMessage("Backup saveram enabled");
}
else
{
Global.OSD.AddMessage("Backup saveram disabled");
GlobalWinF.OSD.AddMessage("Backup saveram disabled");
}
}
@ -2447,13 +2451,13 @@ namespace BizHawk.MultiClient
private void showClippedRegionsToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.GGShowClippedRegions ^= true;
Global.CoreComm.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
GlobalWinF.CoreComm.GG_ShowClippedRegions = Global.Config.GGShowClippedRegions;
}
private void highlightActiveDisplayRegionToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Config.GGHighlightActiveDisplayRegion ^= true;
Global.CoreComm.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
GlobalWinF.CoreComm.GG_HighlightActiveDisplayRegion = Global.Config.GGHighlightActiveDisplayRegion;
}
private void saveMovieToolStripMenuItem_Click(object sender, EventArgs e)

View File

@ -2,6 +2,8 @@
using System.IO;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
partial class MainForm
@ -13,7 +15,7 @@ namespace BizHawk.MultiClient
if (Global.MovieSession.Movie.IsPlaying)
{
Global.MovieSession.Movie.ClearFrame(Global.Emulator.Frame);
Global.OSD.AddMessage("Scrubbed input at frame " + Global.Emulator.Frame.ToString());
GlobalWinF.OSD.AddMessage("Scrubbed input at frame " + Global.Emulator.Frame.ToString());
}
}
@ -25,7 +27,7 @@ namespace BizHawk.MultiClient
Global.MovieSession.Movie.WriteMovie();
}
Global.MovieSession = new MovieSession {Movie = m};
Global.MovieSession = new MovieSession { Movie = m };
RewireInputChain();
if (!record)
@ -34,7 +36,7 @@ namespace BizHawk.MultiClient
SetSyncDependentSettings();
}
LoadRom(Global.MainForm.CurrentlyOpenRom, true, !record);
LoadRom(GlobalWinF.MainForm.CurrentlyOpenRom, true, !record);
Global.Config.RecentMovies.Add(m.Filename);
if (Global.MovieSession.Movie.StartsFromSavestate)
@ -44,17 +46,19 @@ namespace BizHawk.MultiClient
}
if (record)
{
GlobalWinF.MainForm.ClearSaveRAM();
Global.MovieSession.Movie.StartRecording();
ReadOnly = false;
}
else
{
GlobalWinF.MainForm.ClearSaveRAM();
Global.MovieSession.Movie.StartPlayback();
}
SetMainformMovieInfo();
TAStudio1.Restart();
VirtualPadForm1.Restart();
Global.DisplayManager.NeedsToPaint = true;
GlobalWinF.DisplayManager.NeedsToPaint = true;
}
public void SetMainformMovieInfo()
@ -116,10 +120,11 @@ namespace BizHawk.MultiClient
LoadStateFile(Global.MovieSession.Movie.Filename, Path.GetFileName(Global.MovieSession.Movie.Filename));
Global.Emulator.ResetFrameCounter();
}
GlobalWinF.MainForm.ClearSaveRAM();
Global.MovieSession.Movie.StartPlayback();
SetMainformMovieInfo();
Global.OSD.AddMessage("Replaying movie file in read-only mode");
Global.MainForm.ReadOnly = true;
GlobalWinF.OSD.AddMessage("Replaying movie file in read-only mode");
GlobalWinF.MainForm.ReadOnly = true;
}
}
@ -142,14 +147,22 @@ namespace BizHawk.MultiClient
Global.MovieSession.Movie.Stop(abortchanges);
if (!abortchanges)
{
Global.OSD.AddMessage(Path.GetFileName(Global.MovieSession.Movie.Filename) + " written to disk.");
GlobalWinF.OSD.AddMessage(Path.GetFileName(Global.MovieSession.Movie.Filename) + " written to disk.");
}
Global.OSD.AddMessage(message);
Global.MainForm.ReadOnly = true;
GlobalWinF.OSD.AddMessage(message);
GlobalWinF.MainForm.ReadOnly = true;
SetMainformMovieInfo();
}
}
private void ShowError(string error)
{
if (!String.IsNullOrWhiteSpace(error))
{
MessageBox.Show(error, "Loadstate Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private bool HandleMovieLoadState(string path)
{
using (var sr = new StreamReader(path))
@ -158,8 +171,10 @@ namespace BizHawk.MultiClient
}
}
//OMG this needs to be refactored!
private bool HandleMovieLoadState(StreamReader reader)
{
string ErrorMSG = String.Empty;
//Note, some of the situations in these IF's may be identical and could be combined but I intentionally separated it out for clarity
if (!Global.MovieSession.Movie.IsActive)
{
@ -168,29 +183,94 @@ namespace BizHawk.MultiClient
else if (Global.MovieSession.Movie.IsRecording)
{
if (ReadOnly)
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, false))
{
return false; //Timeline/GUID error
}
else
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: false, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result == Movie.LoadStateResult.Pass)
{
Global.MovieSession.Movie.WriteMovie();
Global.MovieSession.Movie.SwitchToPlay();
SetMainformMovieInfo();
return true;
}
else
{
if (result == Movie.LoadStateResult.GuidMismatch)
{
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: false, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
Global.MovieSession.Movie.WriteMovie();
Global.MovieSession.Movie.SwitchToPlay();
SetMainformMovieInfo();
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
ShowError(ErrorMSG);
return false;
}
}
}
else
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, true))
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: true, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result == Movie.LoadStateResult.Pass)
{
return false; //GUID Error
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
}
else
{
if (result == Movie.LoadStateResult.GuidMismatch)
{
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: false, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
ShowError(ErrorMSG);
return false;
}
}
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader);
}
}
@ -198,63 +278,195 @@ namespace BizHawk.MultiClient
{
if (ReadOnly)
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, false))
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result == Movie.LoadStateResult.Pass)
{
return false; //Timeline/GUID error
//Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here
return true;
}
else
{
if (result == Movie.LoadStateResult.GuidMismatch)
{
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
ShowError(ErrorMSG);
return false;
}
}
//Frame loop automatically handles the rewinding effect based on Global.Emulator.Frame so nothing else is needed here
}
else
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, true))
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result == Movie.LoadStateResult.Pass)
{
return false; //GUID Error
Global.MovieSession.Movie.SwitchToRecord();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
return true;
}
else
{
if (result == Movie.LoadStateResult.GuidMismatch)
{
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
Global.MovieSession.Movie.SwitchToRecord();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
ShowError(ErrorMSG);
return false;
}
}
Global.MovieSession.Movie.SwitchToRecord();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader);
}
}
else if (Global.MovieSession.Movie.IsFinished)
{
if (ReadOnly)
{
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result != Movie.LoadStateResult.Pass)
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, false))
if (result == Movie.LoadStateResult.GuidMismatch)
{
return false; //Timeline/GUID error
}
else if (Global.MovieSession.Movie.IsFinished) //TimeLine check can change a movie to finished, hence the check here (not a good design)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
Global.MovieSession.Movie.SwitchToPlay();
SetMainformMovieInfo();
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
Global.MovieSession.Movie.SwitchToPlay();
SetMainformMovieInfo();
ShowError(ErrorMSG);
return false;
}
}
else if (Global.MovieSession.Movie.IsFinished) //TimeLine check can change a movie to finished, hence the check here (not a good design)
{
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
}
else
{
Global.MovieSession.Movie.SwitchToPlay();
SetMainformMovieInfo();
}
}
else
{
var result = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: false, ErrorMessage: out ErrorMSG);
if (result == Movie.LoadStateResult.Pass)
{
if (!Global.MovieSession.Movie.CheckTimeLines(reader, true))
GlobalWinF.MainForm.ClearSaveRAM();
Global.MovieSession.Movie.StartRecording();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
return true;
}
else
{
if (result == Movie.LoadStateResult.GuidMismatch)
{
return false; //GUID Error
var dresult = MessageBox.Show("The savestate GUID does not match the current movie. Proceed anyway?",
"GUID Mismatch error",
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dresult == DialogResult.Yes)
{
var newresult = Global.MovieSession.Movie.CheckTimeLines(reader, OnlyGUID: !ReadOnly, IgnoreGuidMismatch: true, ErrorMessage: out ErrorMSG);
if (newresult == Movie.LoadStateResult.Pass)
{
GlobalWinF.MainForm.ClearSaveRAM();
Global.MovieSession.Movie.StartRecording();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive);
return true;
}
else
{
ShowError(ErrorMSG);
return false;
}
}
else
{
return false;
}
}
else
{
Global.MovieSession.Movie.StartRecording();
SetMainformMovieInfo();
reader.BaseStream.Position = 0;
reader.DiscardBufferedData();
Global.MovieSession.Movie.LoadLogFromSavestateText(reader);
ShowError(ErrorMSG);
return false;
}
}
}
}
return true;
}
@ -270,7 +482,7 @@ namespace BizHawk.MultiClient
{
if (!Global.MovieSession.Movie.IsActive)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
}
else if (Global.MovieSession.Movie.IsFinished)
@ -282,7 +494,7 @@ namespace BizHawk.MultiClient
}
else
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
}
}
@ -294,7 +506,7 @@ namespace BizHawk.MultiClient
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, GlobalWinF.MovieOutputHardpoint);
}
else
{
@ -305,19 +517,19 @@ namespace BizHawk.MultiClient
{
Global.MovieSession.Movie.CaptureState();
Global.MovieSession.LatchInputFromLog();
if (Global.ClientControls["ClearFrame"])
if (GlobalWinF.ClientControls["ClearFrame"])
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
ClearFrame();
}
else if (TAStudio1.IsHandleCreated && !TAStudio1.IsDisposed || Global.Config.MoviePlaybackPokeMode)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
MnemonicsGenerator mg = new MnemonicsGenerator();
mg.SetSource( Global.MovieOutputHardpoint);
mg.SetSource( GlobalWinF.MovieOutputHardpoint);
if (!mg.IsEmpty)
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
Global.MovieSession.Movie.PokeFrame(Global.Emulator.Frame, mg.GetControllersAsMnemonic());
}
else
@ -333,15 +545,15 @@ namespace BizHawk.MultiClient
Global.MovieSession.Movie.CaptureState();
if (Global.MovieSession.MultiTrack.IsActive)
{
Global.MovieSession.LatchMultitrackPlayerInput(Global.MovieInputSourceAdapter, Global.MultitrackRewiringControllerAdapter);
Global.MovieSession.LatchMultitrackPlayerInput(GlobalWinF.MovieInputSourceAdapter, Global.MultitrackRewiringControllerAdapter);
}
else
{
Global.MovieSession.LatchInputFromPlayer(Global.MovieInputSourceAdapter);
Global.MovieSession.LatchInputFromPlayer(GlobalWinF.MovieInputSourceAdapter);
}
//the movie session makes sure that the correct input has been read and merged to its MovieControllerAdapter;
//this has been wired to Global.MovieOutputHardpoint in RewireInputChain
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, Global.MovieOutputHardpoint);
Global.MovieSession.Movie.CommitFrame(Global.Emulator.Frame, GlobalWinF.MovieOutputHardpoint);
}
}

View File

@ -4,6 +4,8 @@ using System.Threading;
using System.Collections.Generic;
using System.Collections.Concurrent;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class MainForm
@ -399,12 +401,12 @@ namespace BizHawk.MultiClient
{
if (RewindActive != enabled)
{
Global.OSD.AddMessage("Rewind " + (enabled ? "Enabled" : "Disabled"));
GlobalWinF.OSD.AddMessage("Rewind " + (enabled ? "Enabled" : "Disabled"));
}
if (RewindFrequency != frequency && enabled)
{
Global.OSD.AddMessage("Rewind frequency set to " + frequency);
GlobalWinF.OSD.AddMessage("Rewind frequency set to " + frequency);
}
RewindActive = enabled;

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,8 @@ using Microsoft.VisualBasic.ApplicationServices;
#pragma warning disable 618
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
static class Program
@ -67,13 +69,13 @@ namespace BizHawk.MultiClient
Global.Config.ResolveDefaults();
#if WINDOWS
try { Global.DSound = SoundEnumeration.Create(); }
try { GlobalWinF.DSound = SoundEnumeration.Create(); }
catch
{
MessageBox.Show("Couldn't initialize DirectSound! Things may go poorly for you. Try changing your sound driver to 41khz instead of 48khz in mmsys.cpl.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try { Global.Direct3D = new Direct3D(); }
try { GlobalWinF.Direct3D = new Direct3D(); }
catch
{
//fallback to GDI rendering
@ -122,10 +124,10 @@ namespace BizHawk.MultiClient
#if WINDOWS
finally
{
if (Global.DSound != null && Global.DSound.Disposed == false)
Global.DSound.Dispose();
if (Global.Direct3D != null && Global.Direct3D.Disposed == false)
Global.Direct3D.Dispose();
if (GlobalWinF.DSound != null && GlobalWinF.DSound.Disposed == false)
GlobalWinF.DSound.Dispose();
if (GlobalWinF.Direct3D != null && GlobalWinF.Direct3D.Disposed == false)
GlobalWinF.Direct3D.Dispose();
GamePad.CloseAll();
}
#endif

View File

@ -1,102 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace BizHawk.MultiClient
{
public class RecentFiles : IEnumerable
{
private readonly int MAX_RECENT_FILES; //Maximum number of files
private readonly List<string> recentlist; //List of recent files
public bool AutoLoad = false;
public RecentFiles() : this(8) { }
public RecentFiles(int max)
{
recentlist = new List<string>();
MAX_RECENT_FILES = max;
}
public IEnumerator<string> GetEnumerator()
{
return recentlist.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public void Clear()
{
recentlist.Clear();
}
public bool Empty
{
get { return recentlist.Count == 0; }
}
public int Count
{
get { return recentlist.Count; }
}
public void Add(string newFile)
{
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
}
}
recentlist.Insert(0, newFile);
if (recentlist.Count > MAX_RECENT_FILES)
{
recentlist.Remove(recentlist[recentlist.Count - 1]);
}
}
public bool Remove(string newFile)
{
bool removed = false;
for (int x = 0; x < recentlist.Count; x++)
{
if (string.Compare(newFile, recentlist[x]) == 0)
{
recentlist.Remove(newFile); //intentionally keeps iterating after this to remove duplicate instances, though those should never exist in the first place
removed = true;
}
}
return removed;
}
public List<string> GetRecentListTruncated(int length)
{
return recentlist.Select(t => t.Substring(0, length)).ToList();
}
public string this[int index]
{
get
{
if (recentlist.Any())
{
return recentlist[index];
}
else
{
return "";
}
}
}
public void ToggleAutoLoad()
{
AutoLoad ^= true;
}
}
}

View File

@ -10,6 +10,8 @@ using SlimDX;
using SlimDX.Direct3D9;
using d3d9font=SlimDX.Direct3D9.Font;
#endif
using BizHawk.Client.Common;
using BizHawk.Core;
namespace BizHawk.MultiClient
@ -346,13 +348,13 @@ namespace BizHawk.MultiClient
d3d = direct3D;
backingControl = control;
control.MouseDoubleClick += (o, e) => HandleFullscreenToggle(o, e);
control.MouseClick += (o, e) => Global.MainForm.MainForm_MouseClick(o, e);
control.MouseClick += (o, e) => GlobalWinF.MainForm.MainForm_MouseClick(o, e);
}
private void HandleFullscreenToggle(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
Global.MainForm.ToggleFullscreen();
GlobalWinF.MainForm.ToggleFullscreen();
}
private void DestroyDevice()
@ -390,7 +392,7 @@ namespace BizHawk.MultiClient
{
get
{
if (Global.ForceNoThrottle)
if (GlobalWinF.ForceNoThrottle)
return false;
return Global.Config.VSyncThrottle || Global.Config.VSync;
}
@ -461,13 +463,13 @@ namespace BizHawk.MultiClient
// Wait until device is available or user gets annoyed and closes app
Result r;
// it can take a while for the device to be ready again, so avoid sound looping during the wait
if (Global.Sound != null) Global.Sound.StopSound();
if (GlobalWinF.Sound != null) GlobalWinF.Sound.StopSound();
do
{
r = _device.TestCooperativeLevel();
Thread.Sleep(100);
} while (r == ResultCode.DeviceLost);
if (Global.Sound != null) Global.Sound.StartSound();
if (GlobalWinF.Sound != null) GlobalWinF.Sound.StartSound();
// lets try recovery!
DestroyDevice();

View File

@ -1,176 +0,0 @@
using System;
using System.Globalization;
namespace BizHawk.MultiClient
{
public class RomGame
{
public byte[] RomData;
public byte[] FileData;
public GameInfo GameInfo;
public string Extension;
private const int BankSize = 1024;
public RomGame() { }
public RomGame(HawkFile file) : this(file, null) { }
public RomGame(HawkFile file, string patch)
{
if (!file.Exists)
throw new Exception("The file needs to exist, yo.");
Extension = file.Extension;
var stream = file.GetStream();
int fileLength = (int)stream.Length;
//read the entire contents of the file into memory.
//unfortunate in the case of large files, but thats what we've got to work with for now.
// if we're offset exactly 512 bytes from a 1024-byte boundary,
// assume we have a header of that size. Otherwise, assume it's just all rom.
// Other 'recognized' header sizes may need to be added.
int headerOffset = fileLength % BankSize;
if (headerOffset.In(0, 512) == false)
{
Console.WriteLine("ROM was not a multiple of 1024 bytes, and not a recognized header size: {0}. Assume it's purely ROM data.", headerOffset);
headerOffset = 0;
}
else if (headerOffset > 0)
Console.WriteLine("Assuming header of {0} bytes.", headerOffset);
//read the entire file into FileData.
FileData = new byte[fileLength];
stream.Read(FileData, 0, fileLength);
//if there was no header offset, RomData is equivalent to FileData
//(except in cases where the original interleaved file data is necessary.. in that case we'll have problems..
//but this whole architecture is not going to withstand every peculiarity and be fast as well.
if (headerOffset == 0)
{
RomData = FileData;
}
else
{
//if there was a header offset, read the whole file into FileData and then copy it into RomData (this is unfortunate, in case RomData isnt needed)
int romLength = fileLength - headerOffset;
RomData = new byte[romLength];
Buffer.BlockCopy(FileData, headerOffset, RomData, 0, romLength);
}
if (file.Extension == ".SMD")
RomData = DeInterleaveSMD(RomData);
if (file.Extension == ".Z64" || file.Extension == ".N64" || file.Extension == ".V64")
RomData = MutateSwapN64(RomData);
//note: this will be taking several hashes, of a potentially large amount of data.. yikes!
GameInfo = Database.GetGameInfo(RomData, file.Name);
CheckForPatchOptions();
if (patch != null)
{
using (var patchFile = new HawkFile(patch))
{
patchFile.BindFirstOf("IPS");
if (patchFile.IsBound)
IPS.Patch(RomData, patchFile.GetStream());
}
}
}
private static byte[] DeInterleaveSMD(byte[] source)
{
// SMD files are interleaved in pages of 16k, with the first 8k containing all
// odd bytes and the second 8k containing all even bytes.
int size = source.Length;
if (size > 0x400000) size = 0x400000;
int pages = size / 0x4000;
byte[] output = new byte[size];
for (int page = 0; page < pages; page++)
{
for (int i = 0; i < 0x2000; i++)
{
output[(page * 0x4000) + (i * 2) + 0] = source[(page * 0x4000) + 0x2000 + i];
output[(page * 0x4000) + (i * 2) + 1] = source[(page * 0x4000) + 0x0000 + i];
}
}
return output;
}
private unsafe static byte[] MutateSwapN64(byte[] source)
{
// N64 roms are in one of the following formats:
// .Z64 = No swapping
// .N64 = Word Swapped
// .V64 = Bytse Swapped
// File extension does not always match the format
int size = source.Length;
// V64 format
fixed (byte* pSource = &source[0])
{
if (pSource[0] == 0x37)
{
for (int i = 0; i < size; i += 2)
{
byte temp = pSource[i];
pSource[i] = pSource[i + 1];
pSource[i + 1] = temp;
}
}
// N64 format
else if (pSource[0] == 0x40)
{
for (int i = 0; i < size; i += 4)
{
//output[i] = source[i + 3];
//output[i + 3] = source[i];
//output[i + 1] = source[i + 2];
//output[i + 2] = source[i + 1];
byte temp = pSource[i];
pSource[i] = source[i + 3];
pSource[i + 3] = temp;
temp = pSource[i + 1];
pSource[i + 1] = pSource[i + 2];
pSource[i + 2] = temp;
}
}
// Z64 format (or some other unknown format)
else
{
}
}
return source;
}
private void CheckForPatchOptions()
{
try
{
if (GameInfo["PatchBytes"])
{
string args = GameInfo.OptionValue("PatchBytes");
foreach (var val in args.Split(','))
{
var split = val.Split(':');
int offset = int.Parse(split[0], NumberStyles.HexNumber);
byte value = byte.Parse(split[1], NumberStyles.HexNumber);
RomData[offset] = value;
}
}
}
catch (Exception) { } // No need for errors in patching to propagate.
}
}
}

View File

@ -1,5 +1,7 @@
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
class SavestateManager

View File

@ -6,6 +6,8 @@ using SlimDX.DirectSound;
using SlimDX.Multimedia;
#endif
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
#if WINDOWS
@ -135,7 +137,7 @@ namespace BizHawk.MultiClient
syncsoundProvider = null;
asyncsoundProvider = source;
semisync.BaseSoundProvider = source;
semisync.RecalculateMagic(Global.CoreComm.VsyncRate);
semisync.RecalculateMagic(GlobalWinF.CoreComm.VsyncRate);
}
static int circularDist(int from, int to, int size)
@ -206,7 +208,7 @@ namespace BizHawk.MultiClient
samplesProvided = 2 * nsampgot;
if (!Global.ForceNoThrottle)
if (!GlobalWinF.ForceNoThrottle)
while (samplesNeeded < samplesProvided)
{
System.Threading.Thread.Sleep((samplesProvided - samplesNeeded) / 88); // let audio clock control sleep time

View File

@ -2,6 +2,8 @@
using System.Runtime.InteropServices;
using System.Threading;
using BizHawk.Client.Common;
//this throttle is nitsuja's fine-tuned techniques from desmume
namespace BizHawk.MultiClient
@ -23,7 +25,7 @@ namespace BizHawk.MultiClient
{
get
{
if (Global.ClientControls["MaxTurbo"])
if (GlobalWinF.ClientControls["MaxTurbo"])
{
return 20;
}
@ -37,7 +39,7 @@ namespace BizHawk.MultiClient
{
get
{
if (Global.ClientControls["MaxTurbo"])
if (GlobalWinF.ClientControls["MaxTurbo"])
{
return false;
}
@ -52,7 +54,7 @@ namespace BizHawk.MultiClient
{
get
{
if (Global.ClientControls["MaxTurbo"])
if (GlobalWinF.ClientControls["MaxTurbo"])
{
return false;
}

View File

@ -5,6 +5,8 @@ using System.Text;
using System.IO;
using System.Xml;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public class XmlGame

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class AutofireConfig : Form
@ -37,18 +39,18 @@ namespace BizHawk.MultiClient
private void Ok_Click(object sender, EventArgs e)
{
Global.AutoFireController.On = Global.Config.AutofireOn = (int)OnNumeric.Value;
Global.AutoFireController.Off = Global.Config.AutofireOff = (int)OffNumeric.Value;
GlobalWinF.AutoFireController.On = Global.Config.AutofireOn = (int)OnNumeric.Value;
GlobalWinF.AutoFireController.Off = Global.Config.AutofireOff = (int)OffNumeric.Value;
Global.Config.AutofireLagFrames = LagFrameCheck.Checked;
Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
GlobalWinF.AutofireStickyXORAdapter.SetOnOffPatternFromConfig();
Global.OSD.AddMessage("Autofire settings saved");
GlobalWinF.OSD.AddMessage("Autofire settings saved");
this.Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Autofire config aborted");
GlobalWinF.OSD.AddMessage("Autofire config aborted");
this.Close();
}
}

View File

@ -4,6 +4,8 @@ using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class ControllerConfig : Form
@ -51,7 +53,7 @@ namespace BizHawk.MultiClient
return cp;
}
Control CreateAnalogPanel(Dictionary<string, Config.AnalogBind> settings, List<string> buttons, Size size)
Control CreateAnalogPanel(Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> settings, List<string> buttons, Size size)
{
var acp = new AnalogBindPanel(settings, buttons) { Dock = DockStyle.Fill };
return acp;
@ -153,7 +155,7 @@ namespace BizHawk.MultiClient
private void LoadPanels(Dictionary<string, Dictionary<string, string>> normal,
Dictionary<string, Dictionary<string, string>> autofire,
Dictionary<string, Dictionary<string, Config.AnalogBind>> analog)
Dictionary<string, Dictionary<string, BizHawk.Client.Common.Config.AnalogBind>> analog)
{
LoadToPanel(tabPage1, the_definition.Name, the_definition.BoolButtons, normal, "", CreateNormalPanel);
LoadToPanel(tabPage2, the_definition.Name, the_definition.BoolButtons, autofire, "", CreateNormalPanel);
@ -170,7 +172,7 @@ namespace BizHawk.MultiClient
LoadPanels(cd.AllTrollers, cd.AllTrollersAutoFire, cd.AllTrollersAnalog);
}
private void LoadPanels(Config c)
private void LoadPanels(BizHawk.Client.Common.Config c)
{
LoadPanels(c.AllTrollers, c.AllTrollersAutoFire, c.AllTrollersAnalog);
}
@ -257,14 +259,14 @@ namespace BizHawk.MultiClient
Save();
Global.OSD.AddMessage("Controller settings saved");
GlobalWinF.OSD.AddMessage("Controller settings saved");
DialogResult = DialogResult.OK;
Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Controller config aborted");
GlobalWinF.OSD.AddMessage("Controller config aborted");
Close();
}
@ -356,10 +358,10 @@ namespace BizHawk.MultiClient
{
public Dictionary<string, Dictionary<string, string>> AllTrollers = new Dictionary<string, Dictionary<string, string>>();
public Dictionary<string, Dictionary<string, string>> AllTrollersAutoFire = new Dictionary<string, Dictionary<string, string>>();
public Dictionary<string, Dictionary<string, Config.AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, Config.AnalogBind>>();
public Dictionary<string, Dictionary<string, BizHawk.Client.Common.Config.AnalogBind>> AllTrollersAnalog = new Dictionary<string, Dictionary<string, BizHawk.Client.Common.Config.AnalogBind>>();
}
public static void ConfigCheckAllControlDefaults(Config c)
public static void ConfigCheckAllControlDefaults(BizHawk.Client.Common.Config c)
{
if (c.AllTrollers.Count == 0 && c.AllTrollersAutoFire.Count == 0 && c.AllTrollersAnalog.Count == 0)
{
@ -380,7 +382,7 @@ namespace BizHawk.MultiClient
cd = ConfigService.Load(ControlDefaultPath, cd);
cd.AllTrollers[the_definition.Name] = new Dictionary<string, string>();
cd.AllTrollersAutoFire[the_definition.Name] = new Dictionary<string, string>();
cd.AllTrollersAnalog[the_definition.Name] = new Dictionary<string, Config.AnalogBind>();
cd.AllTrollersAnalog[the_definition.Name] = new Dictionary<string, BizHawk.Client.Common.Config.AnalogBind>();
SaveToDefaults(cd);

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class AnalogBindControl : UserControl
@ -17,10 +19,10 @@ namespace BizHawk.MultiClient
}
public string ButtonName;
public Config.AnalogBind Bind;
public BizHawk.Client.Common.Config.AnalogBind Bind;
bool listening = false;
public AnalogBindControl(string ButtonName, Config.AnalogBind Bind)
public AnalogBindControl(string ButtonName, BizHawk.Client.Common.Config.AnalogBind Bind)
: this()
{
this.Bind = Bind;

View File

@ -5,13 +5,15 @@ using System.Text;
using System.Windows.Forms;
using System.Drawing;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
class AnalogBindPanel : UserControl
{
Dictionary<string, Config.AnalogBind> RealConfigObject;
Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> RealConfigObject;
public AnalogBindPanel(Dictionary<string, Config.AnalogBind> RealConfigObject, List<string> RealConfigButtons = null)
public AnalogBindPanel(Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> RealConfigObject, List<string> RealConfigButtons = null)
:base()
{
this.RealConfigObject = RealConfigObject;
@ -38,7 +40,7 @@ namespace BizHawk.MultiClient
/// save to config
/// </summary>
/// <param name="SaveConfigObject">if non-null, save to possibly different config object than originally initialized from</param>
public void Save(Dictionary<string, Config.AnalogBind> SaveConfigObject = null)
public void Save(Dictionary<string, BizHawk.Client.Common.Config.AnalogBind> SaveConfigObject = null)
{
var saveto = SaveConfigObject ?? RealConfigObject;
foreach (Control c in Controls)

View File

@ -34,26 +34,28 @@
this.lvFirmwares = new System.Windows.Forms.ListView();
this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lvFirmwaresContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiSetCustomization = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiClearCustomization = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiInfo = new System.Windows.Forms.ToolStripMenuItem();
this.panel1 = new System.Windows.Forms.Panel();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.toolStrip1 = new ToolStripEx();
this.tbbGroup = new System.Windows.Forms.ToolStripButton();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.tbbScan = new System.Windows.Forms.ToolStripButton();
this.tbbOrganize = new System.Windows.Forms.ToolStripButton();
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.lvFirmwaresContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiClearCustomization = new System.Windows.Forms.ToolStripMenuItem();
this.tsmiSetCustomization = new System.Windows.Forms.ToolStripMenuItem();
this.panel1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.tsmiCopy = new System.Windows.Forms.ToolStripMenuItem();
this.lvFirmwaresContextMenuStrip.SuspendLayout();
this.panel1.SuspendLayout();
this.tableLayoutPanel1.SuspendLayout();
this.toolStrip1.SuspendLayout();
this.SuspendLayout();
//
// imageList1
@ -96,11 +98,62 @@
//
this.columnHeader1.Text = "System";
//
// columnHeader6
//
this.columnHeader6.Text = "Id";
//
// columnHeader4
//
this.columnHeader4.Text = "Description";
this.columnHeader4.Width = 165;
//
// columnHeader2
//
this.columnHeader2.Text = "Resolved With";
this.columnHeader2.Width = 116;
//
// columnHeader3
//
this.columnHeader3.Text = "Location";
this.columnHeader3.Width = 252;
//
// columnHeader7
//
this.columnHeader7.Text = "Hash";
this.columnHeader7.Width = 340;
//
// lvFirmwaresContextMenuStrip
//
this.lvFirmwaresContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiSetCustomization,
this.tsmiClearCustomization,
this.tsmiInfo,
this.tsmiCopy});
this.lvFirmwaresContextMenuStrip.Name = "lvFirmwaresContextMenuStrip";
this.lvFirmwaresContextMenuStrip.Size = new System.Drawing.Size(170, 114);
this.lvFirmwaresContextMenuStrip.Opening += new System.ComponentModel.CancelEventHandler(this.lvFirmwaresContextMenuStrip_Opening);
//
// tsmiSetCustomization
//
this.tsmiSetCustomization.Name = "tsmiSetCustomization";
this.tsmiSetCustomization.Size = new System.Drawing.Size(169, 22);
this.tsmiSetCustomization.Text = "&Set Customization";
this.tsmiSetCustomization.Click += new System.EventHandler(this.tsmiClearCustomization_Click);
//
// tsmiClearCustomization
//
this.tsmiClearCustomization.Name = "tsmiClearCustomization";
this.tsmiClearCustomization.Size = new System.Drawing.Size(169, 22);
this.tsmiClearCustomization.Text = "C&lear Customization";
this.tsmiClearCustomization.Click += new System.EventHandler(this.tsmiClearCustomization_Click);
//
// tsmiInfo
//
this.tsmiInfo.Name = "tsmiInfo";
this.tsmiInfo.Size = new System.Drawing.Size(169, 22);
this.tsmiInfo.Text = "&Info";
this.tsmiInfo.Click += new System.EventHandler(this.tsmiInfo_Click);
//
// panel1
//
this.tableLayoutPanel1.SetColumnSpan(this.panel1, 2);
@ -112,8 +165,24 @@
this.panel1.Size = new System.Drawing.Size(773, 472);
this.panel1.TabIndex = 24;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(779, 478);
this.tableLayoutPanel1.TabIndex = 25;
//
// toolStrip1
//
this.toolStrip1.ClickThrough = true;
this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tbbGroup,
this.toolStripSeparator2,
@ -163,61 +232,12 @@
this.tbbOrganize.Text = "Organize";
this.tbbOrganize.Click += new System.EventHandler(this.tbbOrganize_Click);
//
// tableLayoutPanel1
// tsmiCopy
//
this.tableLayoutPanel1.ColumnCount = 2;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tableLayoutPanel1.Controls.Add(this.panel1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 2;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(779, 478);
this.tableLayoutPanel1.TabIndex = 25;
//
// columnHeader6
//
this.columnHeader6.Text = "Id";
//
// columnHeader2
//
this.columnHeader2.Text = "Resolved With";
this.columnHeader2.Width = 116;
//
// columnHeader7
//
this.columnHeader7.Text = "Hash";
this.columnHeader7.Width = 340;
//
// columnHeader3
//
this.columnHeader3.Text = "Location";
this.columnHeader3.Width = 252;
//
// lvFirmwaresContextMenuStrip
//
this.lvFirmwaresContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiSetCustomization,
this.tsmiClearCustomization});
this.lvFirmwaresContextMenuStrip.Name = "lvFirmwaresContextMenuStrip";
this.lvFirmwaresContextMenuStrip.Size = new System.Drawing.Size(170, 48);
//
// tsmiClearCustomization
//
this.tsmiClearCustomization.Name = "tsmiClearCustomization";
this.tsmiClearCustomization.Size = new System.Drawing.Size(169, 22);
this.tsmiClearCustomization.Text = "&Clear Customization";
this.tsmiClearCustomization.Click += new System.EventHandler(this.tsmiClearCustomization_Click);
//
// tsmiSetCustomization
//
this.tsmiSetCustomization.Name = "tsmiSetCustomization";
this.tsmiSetCustomization.Size = new System.Drawing.Size(169, 22);
this.tsmiSetCustomization.Text = "&Set Customization";
this.tsmiSetCustomization.Click += new System.EventHandler(this.tsmiSetCustomization_Click);
this.tsmiCopy.Name = "tsmiCopy";
this.tsmiCopy.Size = new System.Drawing.Size(169, 22);
this.tsmiCopy.Text = "&Copy";
this.tsmiCopy.Click += new System.EventHandler(this.tsmiCopy_Click);
//
// FirmwaresConfig
//
@ -230,12 +250,12 @@
this.Text = "Firmwares";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.FirmwaresConfig_FormClosed);
this.Load += new System.EventHandler(this.FirmwaresConfig_Load);
this.lvFirmwaresContextMenuStrip.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.toolStrip1.ResumeLayout(false);
this.toolStrip1.PerformLayout();
this.tableLayoutPanel1.ResumeLayout(false);
this.lvFirmwaresContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
@ -262,5 +282,7 @@
private System.Windows.Forms.ContextMenuStrip lvFirmwaresContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem tsmiSetCustomization;
private System.Windows.Forms.ToolStripMenuItem tsmiClearCustomization;
private System.Windows.Forms.ToolStripMenuItem tsmiInfo;
private System.Windows.Forms.ToolStripMenuItem tsmiCopy;
}
}

View File

@ -9,6 +9,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
//notes: eventually, we intend to have a "firmware acquisition interface" exposed to the emulator cores.
//it will be implemented by the multiclient, and use firmware keys to fetch the firmware content.
//however, for now, the cores are using strings from the config class. so we have the `configMember` which is
@ -175,7 +177,7 @@ namespace BizHawk.MultiClient
DoScan();
}
FirmwareManager Manager { get { return Global.MainForm.FirmwareManager; } }
FirmwareManager Manager { get { return GlobalWinF.MainForm.FirmwareManager; } }
private void DoScan()
{
@ -279,11 +281,16 @@ namespace BizHawk.MultiClient
{
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{
var str = lvFirmwares.CopyItemsAsText();
if (str.Length > 0) Clipboard.SetDataObject(str);
PerformListCopy();
}
}
void PerformListCopy()
{
var str = lvFirmwares.CopyItemsAsText();
if (str.Length > 0) Clipboard.SetDataObject(str);
}
private void lvFirmwares_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right && lvFirmwares.GetItemAt(e.X, e.Y) != null)
@ -302,7 +309,7 @@ namespace BizHawk.MultiClient
//remember the location we selected this firmware from, maybe there are others
currSelectorDir = Path.GetDirectoryName(ofd.FileName);
//for each selected item, set the user choice (hey, thats the expected semantic
//for each selected item, set the user choice (even though multiple selection for this operation is no longer allowed)
foreach (ListViewItem lvi in lvFirmwares.SelectedItems)
{
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
@ -326,5 +333,52 @@ namespace BizHawk.MultiClient
DoScan();
}
private void tsmiInfo_Click(object sender, EventArgs e)
{
var lvi = lvFirmwares.SelectedItems[0];
var fr = lvi.Tag as FirmwareDatabase.FirmwareRecord;
//get all options for this firmware (in order)
var options =
from fo in FirmwareDatabase.FirmwareOptions
where fo.systemId == fr.systemId && fo.firmwareId == fr.firmwareId
select fo;
FirmwaresConfigInfo fciDialog = new FirmwaresConfigInfo();
fciDialog.lblFirmware.Text = string.Format("{0} : {1} ({2})", fr.systemId, fr.firmwareId, fr.descr);
foreach (var o in options)
{
ListViewItem olvi = new ListViewItem();
olvi.SubItems.Add(new ListViewItem.ListViewSubItem());
olvi.SubItems.Add(new ListViewItem.ListViewSubItem());
var ff = FirmwareDatabase.FirmwareFilesByHash[o.hash];
olvi.SubItems[0].Text = o.hash;
olvi.SubItems[0].Font = fixedFont;
olvi.SubItems[1].Text = ff.recommendedName;
olvi.SubItems[1].Font = this.Font; //why doesnt this work?
olvi.SubItems[2].Text = ff.descr;
olvi.SubItems[2].Font = this.Font; //why doesnt this work?
fciDialog.lvOptions.Items.Add(olvi);
}
fciDialog.lvOptions.AutoResizeColumn(0, ColumnHeaderAutoResizeStyle.ColumnContent);
fciDialog.lvOptions.AutoResizeColumn(1, ColumnHeaderAutoResizeStyle.ColumnContent);
fciDialog.lvOptions.AutoResizeColumn(2, ColumnHeaderAutoResizeStyle.ColumnContent);
fciDialog.ShowDialog();
}
private void lvFirmwaresContextMenuStrip_Opening(object sender, CancelEventArgs e)
{
//hide menu items that arent appropriate for multi-select
tsmiSetCustomization.Visible = lvFirmwares.SelectedItems.Count == 1;
tsmiInfo.Visible = lvFirmwares.SelectedItems.Count == 1;
}
private void tsmiCopy_Click(object sender, EventArgs e)
{
PerformListCopy();
}
} //class FirmwaresConfig
}

View File

@ -126,6 +126,9 @@
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>122, 17</value>
</metadata>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>221, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="tbbGroup.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
@ -172,7 +175,4 @@
TgDQASA1MVpwzwAAAABJRU5ErkJggg==
</value>
</data>
<metadata name="toolTip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>221, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,201 @@
namespace BizHawk.MultiClient
{
partial class FirmwaresConfigInfo
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.lvOptions = new System.Windows.Forms.ListView();
this.colHash = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colStandardFilename = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.colDescription = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
this.label1 = new System.Windows.Forms.Label();
this.btnClose = new System.Windows.Forms.Button();
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.label2 = new System.Windows.Forms.Label();
this.lblFirmware = new System.Windows.Forms.Label();
this.lvmiOptionsContextMenuStrip = new System.Windows.Forms.ContextMenuStrip(this.components);
this.tsmiOptionsCopy = new System.Windows.Forms.ToolStripMenuItem();
this.tableLayoutPanel1.SuspendLayout();
this.flowLayoutPanel1.SuspendLayout();
this.lvmiOptionsContextMenuStrip.SuspendLayout();
this.SuspendLayout();
//
// lvOptions
//
this.lvOptions.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.colHash,
this.colStandardFilename,
this.colDescription});
this.lvOptions.Dock = System.Windows.Forms.DockStyle.Fill;
this.lvOptions.FullRowSelect = true;
this.lvOptions.GridLines = true;
this.lvOptions.Location = new System.Drawing.Point(3, 29);
this.lvOptions.Name = "lvOptions";
this.lvOptions.Size = new System.Drawing.Size(648, 402);
this.lvOptions.TabIndex = 0;
this.lvOptions.UseCompatibleStateImageBehavior = false;
this.lvOptions.View = System.Windows.Forms.View.Details;
this.lvOptions.KeyDown += new System.Windows.Forms.KeyEventHandler(this.lvOptions_KeyDown);
this.lvOptions.MouseClick += new System.Windows.Forms.MouseEventHandler(this.lvOptions_MouseClick);
//
// colHash
//
this.colHash.Text = "Hash";
this.colHash.Width = 251;
//
// colStandardFilename
//
this.colStandardFilename.Text = "Standard Filename";
this.colStandardFilename.Width = 175;
//
// colDescription
//
this.colDescription.Text = "Description";
this.colDescription.Width = 214;
//
// tableLayoutPanel1
//
this.tableLayoutPanel1.ColumnCount = 1;
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1);
this.tableLayoutPanel1.Controls.Add(this.lvOptions, 0, 2);
this.tableLayoutPanel1.Controls.Add(this.btnClose, 0, 3);
this.tableLayoutPanel1.Controls.Add(this.flowLayoutPanel1, 0, 0);
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
this.tableLayoutPanel1.RowCount = 4;
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tableLayoutPanel1.Size = new System.Drawing.Size(654, 469);
this.tableLayoutPanel1.TabIndex = 1;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(3, 13);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(122, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Options for this firmware:";
//
// btnClose
//
this.btnClose.Anchor = System.Windows.Forms.AnchorStyles.Right;
this.btnClose.AutoSize = true;
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(595, 440);
this.btnClose.Margin = new System.Windows.Forms.Padding(6);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(53, 23);
this.btnClose.TabIndex = 2;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.flowLayoutPanel1.Controls.Add(this.label2);
this.flowLayoutPanel1.Controls.Add(this.lblFirmware);
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(99, 13);
this.flowLayoutPanel1.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(3, 0);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(52, 13);
this.label2.TabIndex = 0;
this.label2.Text = "Firmware:";
//
// lblFirmware
//
this.lblFirmware.AutoSize = true;
this.lblFirmware.Location = new System.Drawing.Point(61, 0);
this.lblFirmware.Name = "lblFirmware";
this.lblFirmware.Size = new System.Drawing.Size(35, 13);
this.lblFirmware.TabIndex = 1;
this.lblFirmware.Text = "label3";
//
// lvmiOptionsContextMenuStrip
//
this.lvmiOptionsContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.tsmiOptionsCopy});
this.lvmiOptionsContextMenuStrip.Name = "lvmiOptionsContextMenuStrip";
this.lvmiOptionsContextMenuStrip.Size = new System.Drawing.Size(100, 26);
//
// tsmiOptionsCopy
//
this.tsmiOptionsCopy.Name = "tsmiOptionsCopy";
this.tsmiOptionsCopy.Size = new System.Drawing.Size(152, 22);
this.tsmiOptionsCopy.Text = "&Copy";
this.tsmiOptionsCopy.Click += new System.EventHandler(this.tsmiOptionsCopy_Click);
//
// FirmwaresConfigInfo
//
this.AcceptButton = this.btnClose;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(654, 469);
this.Controls.Add(this.tableLayoutPanel1);
this.Name = "FirmwaresConfigInfo";
this.Text = "Firmware Info";
this.tableLayoutPanel1.ResumeLayout(false);
this.tableLayoutPanel1.PerformLayout();
this.flowLayoutPanel1.ResumeLayout(false);
this.flowLayoutPanel1.PerformLayout();
this.lvmiOptionsContextMenuStrip.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.ColumnHeader colHash;
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.ColumnHeader colStandardFilename;
private System.Windows.Forms.ColumnHeader colDescription;
public System.Windows.Forms.ListView lvOptions;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
private System.Windows.Forms.Label label2;
public System.Windows.Forms.Label lblFirmware;
private System.Windows.Forms.ContextMenuStrip lvmiOptionsContextMenuStrip;
private System.Windows.Forms.ToolStripMenuItem tsmiOptionsCopy;
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//todo - display details on the current resolution status
//todo - check(mark) the one thats selected
//todo - turn top info into textboxes i guess, labels suck
namespace BizHawk.MultiClient
{
public partial class FirmwaresConfigInfo : Form
{
public FirmwaresConfigInfo()
{
InitializeComponent();
}
private void lvOptions_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Control && !e.Alt && !e.Shift)
{
PerformListCopy();
}
}
void PerformListCopy()
{
var str = lvOptions.CopyItemsAsText();
if (str.Length > 0) Clipboard.SetDataObject(str);
}
private void tsmiOptionsCopy_Click(object sender, EventArgs e)
{
PerformListCopy();
}
private void lvOptions_MouseClick(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Right && lvOptions.GetItemAt(e.X, e.Y) != null)
lvmiOptionsContextMenuStrip.Show(lvOptions, e.Location);
}
}
}

View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="lvmiOptionsContextMenuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class GifAnimator : Form

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class HotkeyConfig : Form
@ -31,14 +33,14 @@ namespace BizHawk.MultiClient
private void IDB_CANCEL_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Hotkey config aborted");
GlobalWinF.OSD.AddMessage("Hotkey config aborted");
Close();
}
private void IDB_SAVE_Click(object sender, EventArgs e)
{
Save();
Global.OSD.AddMessage("Hotkey settings saved");
GlobalWinF.OSD.AddMessage("Hotkey settings saved");
DialogResult = DialogResult.OK;
Close();
}
@ -59,7 +61,7 @@ namespace BizHawk.MultiClient
foreach (InputWidget w in _inputWidgets)
{
Binding b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
b.Bindings = w.Text;
}
}
@ -95,14 +97,14 @@ namespace BizHawk.MultiClient
tb.Name = tab;
tb.Text = tab;
List<Binding> bindings = Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.DisplayName).ToList();
var bindings = Global.Config.HotkeyBindings.Where(x => x.TabGroup == tab).OrderBy(x => x.Ordinal).ThenBy(x => x.DisplayName).ToList();
int _x = 6;
int _y = 14;
int iw_offset_x = 110;
int iw_offset_y = -4;
int iw_width = 120;
foreach (Binding b in bindings)
foreach (var b in bindings)
{
Label l = new Label()
{
@ -139,7 +141,7 @@ namespace BizHawk.MultiClient
{
foreach (InputWidget w in _inputWidgets)
{
Binding b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == w.WidgetName);
w.Text = b.DefaultBinding;
}
}
@ -180,7 +182,7 @@ namespace BizHawk.MultiClient
{
string user_selection = SearchBox.Text;
Binding b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == SearchBox.Text);
var b = Global.Config.HotkeyBindings.FirstOrDefault(x => x.DisplayName == SearchBox.Text);
//Found
if (b != null)

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class MessageConfig : Form
@ -227,7 +229,7 @@ namespace BizHawk.MultiClient
private void OK_Click(object sender, EventArgs e)
{
SaveSettings();
Global.OSD.AddMessage("Message settings saved");
GlobalWinF.OSD.AddMessage("Message settings saved");
this.Close();
}
@ -287,7 +289,7 @@ namespace BizHawk.MultiClient
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Message config aborted");
GlobalWinF.OSD.AddMessage("Message config aborted");
this.Close();
}

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class PathConfig : Form
@ -56,13 +58,13 @@ namespace BizHawk.MultiClient
private void OK_Click(object sender, EventArgs e)
{
SaveSettings();
Global.OSD.AddMessage("Path settings saved");
GlobalWinF.OSD.AddMessage("Path settings saved");
Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Path config aborted");
GlobalWinF.OSD.AddMessage("Path config aborted");
Close();
}

View File

@ -3,6 +3,8 @@ using System.Linq;
using System.IO;
using System.Reflection;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public static class PathManager

View File

@ -2,6 +2,8 @@
using System.Windows.Forms;
using System.Drawing;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class RewindConfig : Form
@ -9,7 +11,7 @@ namespace BizHawk.MultiClient
private long StateSize;
private int MediumStateSize;
private int LargeStateSize;
private int StateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum
private int StateSizeCategory = 1; //1 = small, 2 = med, 3 = larg //TODO: enum
public RewindConfig()
{
InitializeComponent();
@ -17,10 +19,10 @@ namespace BizHawk.MultiClient
private void RewindConfig_Load(object sender, EventArgs e)
{
if (Global.MainForm.RewindBuf != null)
if (GlobalWinF.MainForm.RewindBuf != null)
{
FullnessLabel.Text = String.Format("{0:0.00}", Global.MainForm.Rewind_FullnessRatio * 100) + "%";
RewindFramesUsedLabel.Text = Global.MainForm.Rewind_Count.ToString();
FullnessLabel.Text = String.Format("{0:0.00}", GlobalWinF.MainForm.Rewind_FullnessRatio * 100) + "%";
RewindFramesUsedLabel.Text = GlobalWinF.MainForm.Rewind_Count.ToString();
}
else
{
@ -109,13 +111,13 @@ namespace BizHawk.MultiClient
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Rewind config aborted");
GlobalWinF.OSD.AddMessage("Rewind config aborted");
Close();
}
private void OK_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Rewind settings saved");
GlobalWinF.OSD.AddMessage("Rewind settings saved");
Global.Config.RewindFrequencySmall = (int)SmallSavestateNumeric.Value;
Global.Config.RewindFrequencyMedium = (int)MediumSavestateNumeric.Value;
@ -125,7 +127,7 @@ namespace BizHawk.MultiClient
Global.Config.RewindEnabledMedium = MediumStateEnabledBox.Checked;
Global.Config.RewindEnabledLarge = LargeStateEnabledBox.Checked;
Global.MainForm.DoRewindSettings();
GlobalWinF.MainForm.DoRewindSettings();
Global.Config.Rewind_UseDelta = UseDeltaCompression.Checked;
@ -135,7 +137,7 @@ namespace BizHawk.MultiClient
Global.Config.Rewind_BufferSize = (int)BufferSizeUpDown.Value;
if (Global.Config.Rewind_IsThreaded != RewindIsThreadedCheckbox.Checked)
{
Global.MainForm.FlagNeedsReboot();
GlobalWinF.MainForm.FlagNeedsReboot();
Global.Config.Rewind_IsThreaded = RewindIsThreadedCheckbox.Checked;
}
@ -258,9 +260,9 @@ namespace BizHawk.MultiClient
if (UseDeltaCompression.Checked || StateSize == 0)
{
if (Global.MainForm.Rewind_Count > 0)
if (GlobalWinF.MainForm.Rewind_Count > 0)
{
avg_state_size = (long)(Global.MainForm.Rewind_Size / Global.MainForm.Rewind_Count);
avg_state_size = (long)(GlobalWinF.MainForm.Rewind_Size / GlobalWinF.MainForm.Rewind_Count);
}
else
{

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class SoundConfig : Form
@ -47,16 +49,16 @@ namespace BizHawk.MultiClient
Global.Config.SoundVolume = SoundVolBar.Value;
Global.Config.SoundThrottle = ThrottlecheckBox.Checked;
Global.Config.SoundDevice = (string)listBoxSoundDevices.SelectedItem ?? "<default>";
Global.Sound.ChangeVolume(Global.Config.SoundVolume);
Global.Sound.UpdateSoundSettings();
Global.Sound.StartSound();
Global.OSD.AddMessage("Sound settings saved");
GlobalWinF.Sound.ChangeVolume(Global.Config.SoundVolume);
GlobalWinF.Sound.UpdateSoundSettings();
GlobalWinF.Sound.StartSound();
GlobalWinF.OSD.AddMessage("Sound settings saved");
this.Close();
}
private void Cancel_Click(object sender, EventArgs e)
{
Global.OSD.AddMessage("Sound config aborted");
GlobalWinF.OSD.AddMessage("Sound config aborted");
this.Close();
}

View File

@ -1,12 +1,14 @@
using System;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class EditCommentsForm : Form
{
public bool ReadOnly;
private Movie selectedMovie = new Movie();
private Movie selectedMovie;
public EditCommentsForm()
{

View File

@ -3,13 +3,14 @@ using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class EditSubtitlesForm : Form
{
public bool ReadOnly;
private Movie selectedMovie = new Movie();
private Movie selectedMovie;
public EditSubtitlesForm()
{
@ -53,7 +54,7 @@ namespace BizHawk.MultiClient
{
if (!ReadOnly)
{
selectedMovie.Subtitles.ClearSubtitles();
selectedMovie.Subtitles.Clear();
for (int x = 0; x < SubGrid.Rows.Count - 1; x++)
{
Subtitle s = new Subtitle();
@ -86,12 +87,12 @@ namespace BizHawk.MultiClient
public void GetMovie(Movie m)
{
selectedMovie = m;
SubtitleList subs = new SubtitleList(m);
SubtitleList subs = new SubtitleList(m.Subtitles);
if (subs.Count == 0) return;
for (int x = 0; x < subs.Count; x++)
{
Subtitle s = subs.GetSubtitleByIndex(x);
Subtitle s = subs[x];
SubGrid.Rows.Add();
DataGridViewCell c = SubGrid.Rows[x].Cells[0];
c.Value = s.Frame;

View File

@ -1,541 +0,0 @@
using System;
using System.Text;
using System.Collections.Generic;
namespace BizHawk.MultiClient
{
/// <summary>
/// will hold buttons for 1 frame and then release them. (Calling Click() from your button click is what you want to do)
/// TODO - should the duration be controllable?
/// </summary>
public class ClickyVirtualPadController : IController
{
public ControllerDefinition Type { get; set; }
public bool this[string button] { get { return IsPressed(button); } }
public float GetFloat(string name) { return 0.0f; } //TODO
public void UpdateControls(int frame) { }
public bool IsPressed(string button)
{
return Pressed.Contains(button);
}
/// <summary>
/// call this once per frame to do the timekeeping for the hold and release
/// </summary>
public void FrameTick()
{
Pressed.Clear();
}
/// <summary>
/// call this to hold the button down for one frame
/// </summary>
public void Click(string button)
{
Pressed.Add(button);
}
public void Unclick(string button)
{
Pressed.Remove(button);
}
public void Toggle(string button)
{
if (IsPressed(button))
{
Pressed.Remove(button);
}
else
{
Pressed.Add(button);
}
}
readonly HashSet<string> Pressed = new HashSet<string>();
}
//filters input for things called Up and Down while considering the client's AllowUD_LR option.
//this is a bit gross but it is unclear how to do it more nicely
public class UD_LR_ControllerAdapter : IController
{
public ControllerDefinition Type { get { return Source.Type; } }
public IController Source;
public bool this[string button] { get { return IsPressed(button); } }
// the float format implies no U+D and no L+R no matter what, so just passthru
public float GetFloat(string name) { return Source.GetFloat(name); }
public void UpdateControls(int frame) { }
public bool IsPressed(string button)
{
if (Global.Config.AllowUD_LR)
{
return Source.IsPressed(button);
}
string prefix;
if (button.Contains("Down") && !button.Contains(" C "))
{
prefix = button.GetPrecedingString("Down");
if (Source.IsPressed(prefix + "Up"))
{
return false;
}
}
if (button.Contains("Right") && !button.Contains(" C "))
{
prefix = button.GetPrecedingString("Right");
if (Source.IsPressed(prefix + "Left"))
{
return false;
}
}
return Source.IsPressed(button);
}
}
public class SimpleController : IController
{
public ControllerDefinition Type { get; set; }
protected WorkingDictionary<string, bool> Buttons = new WorkingDictionary<string, bool>();
protected WorkingDictionary<string, float> Floats = new WorkingDictionary<string, float>();
public virtual bool this[string button] { get { return Buttons[button]; } set { Buttons[button] = value; } }
public virtual bool IsPressed(string button) { return this[button]; }
public float GetFloat(string name) { return Floats[name]; }
public void UpdateControls(int frame) { }
public IEnumerable<KeyValuePair<string, bool>> BoolButtons()
{
foreach (var kvp in Buttons) yield return kvp;
}
public virtual void LatchFrom(IController source)
{
foreach (string button in source.Type.BoolButtons)
{
Buttons[button] = source[button];
}
}
public void AcceptNewFloats(IEnumerable<Tuple<string, float>> NewValues)
{
foreach (var sv in NewValues)
Floats[sv.Item1] = sv.Item2;
}
}
public class ORAdapter : IController
{
public bool IsPressed(string button) { return this[button]; }
// pass floats solely from the original source
// this works in the code because SourceOr is the autofire controller
public float GetFloat(string name) { return Source.GetFloat(name); }
public void UpdateControls(int frame) { }
public IController Source;
public IController SourceOr;
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public bool this[string button]
{
get
{
bool source = Source[button] | SourceOr[button];
return source;
}
set { throw new InvalidOperationException(); }
}
}
public class ForceOffAdaptor : IController
{
public bool IsPressed(string button) { return this[button]; }
// what exactly would we want to do here with floats?
// ForceOffAdaptor is only used by lua, and the code there looks like a big mess...
public float GetFloat(string name) { return Source.GetFloat(name); }
public void UpdateControls(int frame) { }
protected HashSet<string> stickySet = new HashSet<string>();
public IController Source;
public IController SourceOr;
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public bool this[string button]
{
get
{
if (stickySet.Contains(button))
{
return false;
}
else
{
return Source[button];
}
}
set { throw new InvalidOperationException(); }
}
public void SetSticky(string button, bool isSticky)
{
if (isSticky)
stickySet.Add(button);
else stickySet.Remove(button);
}
}
public class StickyXORAdapter : IController
{
protected HashSet<string> stickySet = new HashSet<string>();
public IController Source;
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public bool Locked = false; //Pretty much a hack,
public bool IsPressed(string button) { return this[button]; }
// if SetFloat() is called (typically virtual pads), then that float will entirely override the Source input
// otherwise, the source is passed thru.
WorkingDictionary<string,float?> FloatSet = new WorkingDictionary<string,float?>();
public void SetFloat(string name, float? value)
{
if (value.HasValue)
FloatSet[name] = value;
else FloatSet.Remove(name);
}
public float GetFloat(string name)
{
return FloatSet[name] ?? Source.GetFloat(name);
}
public void ClearStickyFloats()
{
FloatSet.Clear();
}
public void UpdateControls(int frame) { }
public bool this[string button] {
get
{
bool source = Source[button];
if (source)
{
}
source ^= stickySet.Contains(button);
return source;
}
set { throw new InvalidOperationException(); }
}
public void SetSticky(string button, bool isSticky)
{
if(isSticky)
stickySet.Add(button);
else stickySet.Remove(button);
}
public bool IsSticky(string button)
{
return stickySet.Contains(button);
}
public HashSet<string> CurrentStickies
{
get
{
return stickySet;
}
}
public void ClearStickies()
{
stickySet.Clear();
}
public void MassToggleStickyState(List<string> buttons)
{
foreach (string button in buttons)
{
if (!JustPressed.Contains(button))
{
if (stickySet.Contains(button))
{
stickySet.Remove(button);
}
else
{
stickySet.Add(button);
}
}
}
JustPressed = buttons;
}
private List<string> JustPressed = new List<string>();
}
public class AutoFireStickyXORAdapter : IController
{
public int On { get; set; }
public int Off { get; set; }
public WorkingDictionary<string, int> buttonStarts = new WorkingDictionary<string, int>();
private readonly HashSet<string> stickySet = new HashSet<string>();
public IController Source;
public void SetOnOffPatternFromConfig()
{
On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn;
Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff;
}
public AutoFireStickyXORAdapter()
{
//On = Global.Config.AutofireOn < 1 ? 0 : Global.Config.AutofireOn;
//Off = Global.Config.AutofireOff < 1 ? 0 : Global.Config.AutofireOff;
On = 1;
Off = 1;
}
public bool IsPressed(string button)
{
if (stickySet.Contains(button))
{
int a = (Global.Emulator.Frame - buttonStarts[button]) % (On + Off);
if (a < On)
return this[button];
else
return false;
}
else
{
return Source[button];
}
}
public bool this[string button]
{
get
{
bool source = Source[button];
if (source)
{
}
if (stickySet.Contains(button))
{
int a = (Global.Emulator.Frame - buttonStarts[button]) % (On + Off);
if (a < On)
{
source ^= true;
}
else
{
source ^= false;
}
}
return source;
}
set { throw new InvalidOperationException(); }
}
public ControllerDefinition Type { get { return Source.Type; } set { throw new InvalidOperationException(); } }
public bool Locked = false; //Pretty much a hack,
// dumb passthrough for floats, because autofire doesn't care about them
public float GetFloat(string name) { return Source.GetFloat(name); }
public void UpdateControls(int frame) { }
public void SetSticky(string button, bool isSticky)
{
if (isSticky)
stickySet.Add(button);
else stickySet.Remove(button);
}
public bool IsSticky(string button)
{
return stickySet.Contains(button);
}
public HashSet<string> CurrentStickies
{
get
{
return stickySet;
}
}
public void ClearStickies()
{
stickySet.Clear();
}
public void MassToggleStickyState(List<string> buttons)
{
foreach (string button in buttons)
{
if (!JustPressed.Contains(button))
{
if (stickySet.Contains(button))
{
stickySet.Remove(button);
}
else
{
stickySet.Add(button);
}
}
}
JustPressed = buttons;
}
private List<string> JustPressed = new List<string>();
}
/// <summary>
/// just copies source to sink, or returns whatever a NullController would if it is disconnected. useful for immovable hardpoints.
/// </summary>
public class CopyControllerAdapter : IController
{
public IController Source;
private readonly NullController _null = new NullController();
IController Curr
{
get
{
if (Source == null) return _null;
else return Source;
}
}
public ControllerDefinition Type { get { return Curr.Type; } }
public bool this[string button] { get { return Curr[button]; } }
public bool IsPressed(string button) { return Curr.IsPressed(button); }
public float GetFloat(string name) { return Curr.GetFloat(name); }
public void UpdateControls(int frame) { Curr.UpdateControls(frame); }
}
class ButtonNameParser
{
ButtonNameParser()
{
}
public static ButtonNameParser Parse(string button)
{
//see if we're being asked for a button that we know how to rewire
string[] parts = button.Split(' ');
if (parts.Length < 2) return null;
if (parts[0][0] != 'P') return null;
int player;
if (!int.TryParse(parts[0].Substring(1), out player))
{
return null;
}
else
{
return new ButtonNameParser { PlayerNum = player, ButtonPart = button.Substring(parts[0].Length + 1) };
}
}
public int PlayerNum;
public string ButtonPart;
public override string ToString()
{
return string.Format("P{0} {1}", PlayerNum, ButtonPart);
}
}
/// <summary>
/// rewires player1 controls to playerN
/// </summary>
public class MultitrackRewiringControllerAdapter : IController
{
public IController Source;
public int PlayerSource = 1;
public int PlayerTargetMask = 0;
public ControllerDefinition Type { get { return Source.Type; } }
public bool this[string button] { get { return IsPressed(button); } }
// floats can be player number remapped just like boolbuttons
public float GetFloat(string name) { return Source.GetFloat(RemapButtonName(name)); }
public void UpdateControls(int frame) { Source.UpdateControls(frame); }
string RemapButtonName(string button)
{
//do we even have a source?
if (PlayerSource == -1) return button;
//see if we're being asked for a button that we know how to rewire
ButtonNameParser bnp = ButtonNameParser.Parse(button);
if (bnp == null) return button;
//ok, this looks like a normal `P1 Button` type thing. we can handle it
//were we supposed to replace this one?
int foundPlayerMask = (1 << bnp.PlayerNum);
if ((PlayerTargetMask & foundPlayerMask) == 0) return button;
//ok, we were. swap out the source player and then grab his button
bnp.PlayerNum = PlayerSource;
return bnp.ToString();
}
public bool IsPressed(string button)
{
return Source.IsPressed(RemapButtonName(button));
}
}
//not being used..
///// <summary>
///// adapts an IController to force some buttons to a different state.
///// unforced button states will flow through to the adaptee
///// </summary>
//public class ForceControllerAdapter : IController
//{
// public IController Controller;
// public Dictionary<string, bool> Forces = new Dictionary<string, bool>();
// public void Clear()
// {
// Forces.Clear();
// }
// public ControllerDefinition Type { get { return Controller.Type; } }
// public bool this[string button] { get { return IsPressed(button); } }
// public bool IsPressed(string button)
// {
// if (Forces.ContainsKey(button))
// return Forces[button];
// else return Controller.IsPressed(button);
// }
// public float GetFloat(string name)
// {
// return Controller.GetFloat(name); //TODO!
// }
// public void UpdateControls(int frame)
// {
// Controller.UpdateControls(frame);
// }
//}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,297 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BizHawk.MultiClient
{
public class MovieHeader
{
//Required Header Params
//Emulation - Core version, will be 1.0.0 until there is a versioning system
//Movie - Versioning for the Movie code itself, or perhaps this could be changed client version?
//Platform - Must know what platform we are making a movie on!
//GameName - Which game
//TODO: checksum of game, other stuff
public Dictionary<string, string> HeaderParams = new Dictionary<string, string>(); //Platform specific options go here
public List<string> Comments = new List<string>();
public Dictionary<string, string> BoardProperties = new Dictionary<string, string>();
public const string EMULATIONVERSION = "emuVersion";
public const string MOVIEVERSION = "MovieVersion";
public const string PLATFORM = "Platform";
public const string GAMENAME = "GameName";
public const string AUTHOR = "Author";
public const string RERECORDS = "rerecordCount";
public const string GUID = "GUID";
public const string STARTSFROMSAVESTATE = "StartsFromSavestate";
public const string FOURSCORE = "FourScore";
public const string SHA1 = "SHA1";
public const string FIRMWARESHA1 = "FirmwareSHA1";
public const string PAL = "PAL";
public const string BOARDNAME = "BoardName";
//Gameboy Settings that affect sync
public const string GB_FORCEDMG = "Force_DMG_Mode";
public const string GB_GBA_IN_CGB = "GBA_In_CGB";
public const string SGB = "SGB"; //a snes movie will set this to indicate that it's actually SGB
//BIO skipping setting (affects sync)
public const string SKIPBIOS = "Skip_Bios";
//Plugin Settings
public const string VIDEOPLUGIN = "VideoPlugin";
//Board properties
public const string BOARDPROPERTIES = "BoardProperty";
public static string MovieVersion = "BizHawk v0.0.1";
public static string MakeGUID()
{
return System.Guid.NewGuid().ToString();
}
public MovieHeader() //All required fields will be set to default values
{
if (Global.MainForm != null)
{
HeaderParams.Add(EMULATIONVERSION, Global.MainForm.GetEmuVersion());
}
else
{
HeaderParams.Add(EMULATIONVERSION, MainForm.EMUVERSION);
}
HeaderParams.Add(MOVIEVERSION, MovieVersion);
HeaderParams.Add(PLATFORM, "");
HeaderParams.Add(GAMENAME, "");
HeaderParams.Add(AUTHOR, "");
HeaderParams.Add(RERECORDS, "0");
HeaderParams.Add(GUID, MakeGUID());
}
/// <summary>
/// Adds the key value pair to header params. If key already exists, value will be updated
/// </summary>
/// <param name="key"></param>
/// <param name="value"></param>
public void AddHeaderLine(string key, string value)
{
string temp;
if (!HeaderParams.TryGetValue(key, out temp)) //TODO: does a failed attempt mess with value?
HeaderParams.Add(key, value);
}
public void UpdateRerecordCount(int count)
{
HeaderParams[RERECORDS] = count.ToString();
}
public bool RemoveHeaderLine(string key)
{
return HeaderParams.Remove(key);
}
public void Clear()
{
HeaderParams.Clear();
}
public string GetHeaderLine(string key)
{
string value;
HeaderParams.TryGetValue(key, out value);
return value;
}
public void SetHeaderLine(string key, string value)
{
HeaderParams[key] = value;
}
public void WriteText(StreamWriter sw)
{
foreach (KeyValuePair<string, string> kvp in HeaderParams)
{
sw.WriteLine(kvp.Key + " " + kvp.Value);
}
foreach (KeyValuePair<string, string> kvp in BoardProperties)
{
sw.WriteLine(BOARDPROPERTIES + " " + kvp.Key + " " + kvp.Value);
}
foreach (string t in Comments)
{
sw.WriteLine(t);
}
}
private string ParseHeader(string line, string headerName)
{
int x = line.LastIndexOf(headerName) + headerName.Length;
string str = line.Substring(x + 1, line.Length - x - 1);
return str;
}
//TODO: replace Movie Preload & Load functions with this
/// <summary>
/// Receives a line and attempts to add as a header, returns false if not a useable header line
/// </summary>
/// <param name="line"></param>
/// <returns></returns>
public bool AddHeaderFromLine(string line)
{
if (line.Length == 0) return false;
else if (line.Contains(EMULATIONVERSION))
{
line = ParseHeader(line, EMULATIONVERSION);
AddHeaderLine(EMULATIONVERSION, line);
}
else if (line.Contains(MOVIEVERSION))
{
line = ParseHeader(line, MOVIEVERSION);
AddHeaderLine(MOVIEVERSION, line);
}
else if (line.Contains(PLATFORM))
{
line = ParseHeader(line, PLATFORM);
AddHeaderLine(PLATFORM, line);
}
else if (line.Contains(GAMENAME))
{
line = ParseHeader(line, GAMENAME);
AddHeaderLine(GAMENAME, line);
}
else if (line.Contains(RERECORDS))
{
line = ParseHeader(line, RERECORDS);
AddHeaderLine(RERECORDS, line);
}
else if (line.Contains(AUTHOR))
{
line = ParseHeader(line, AUTHOR);
AddHeaderLine(AUTHOR, line);
}
else if (line.ToUpper().Contains(GUID))
{
line = ParseHeader(line, GUID);
AddHeaderLine(GUID, line);
}
else if (line.Contains(STARTSFROMSAVESTATE))
{
line = ParseHeader(line, STARTSFROMSAVESTATE);
AddHeaderLine(STARTSFROMSAVESTATE, line);
}
else if (line.Contains(SHA1))
{
line = ParseHeader(line, SHA1);
AddHeaderLine(SHA1, line);
}
else if (line.Contains(SKIPBIOS))
{
line = ParseHeader(line, SKIPBIOS);
AddHeaderLine(SKIPBIOS, line);
}
else if (line.Contains(GB_FORCEDMG))
{
line = ParseHeader(line, GB_FORCEDMG);
AddHeaderLine(GB_FORCEDMG, line);
}
else if (line.Contains(GB_GBA_IN_CGB))
{
line = ParseHeader(line, GB_GBA_IN_CGB);
AddHeaderLine(GB_GBA_IN_CGB, line);
}
else if (line.Contains(SGB))
{
line = ParseHeader(line, SGB);
AddHeaderLine(SGB, line);
}
else if (line.Contains(PAL))
{
line = ParseHeader(line, PAL);
AddHeaderLine(PAL, line);
}
else if (line.Contains(VIDEOPLUGIN))
{
line = ParseHeader(line, VIDEOPLUGIN);
AddHeaderLine(VIDEOPLUGIN, line);
}
else if (line.Contains(BOARDPROPERTIES))
{
line = ParseHeader(line, BOARDPROPERTIES);
string[] vals = line.Split(' ');
BoardProperties.Add(vals[0], vals[1]);
}
else if (line.StartsWith("subtitle") || line.StartsWith("sub"))
{
return false;
}
else if (line.StartsWith("comment"))
{
Comments.Add(line.Substring(8, line.Length - 8));
}
else if (line[0] == '|')
{
return false;
}
else
{
if (HeaderParams[PLATFORM] == "N64")
{
if (HeaderParams.ContainsKey(VIDEOPLUGIN))
{
if (HeaderParams[VIDEOPLUGIN] == "Rice")
{
ICollection<string> settings = Global.Config.RicePlugin.GetPluginSettings().Keys;
foreach (string setting in settings)
{
if (line.Contains(setting))
{
line = ParseHeader(line, setting);
AddHeaderLine(setting, line);
break;
}
}
}
else if (HeaderParams[VIDEOPLUGIN] == "Glide64")
{
ICollection<string> settings = Global.Config.GlidePlugin.GetPluginSettings().Keys;
foreach (string setting in settings)
{
if (line.Contains(setting))
{
line = ParseHeader(line, setting);
AddHeaderLine(setting, line);
break;
}
}
}
}
}
else
{
Comments.Add(line);
}
}
return true;
}
public void ReadHeader(StreamReader reader)
{
using (reader)
{
string str;
while ((str = reader.ReadLine()) != null)
{
AddHeaderFromLine(str);
}
reader.Close();
}
}
}
}

View File

@ -4,6 +4,8 @@ using System.Linq;
using System.Text;
using System.IO;
using BizHawk.Client.Common;
#pragma warning disable 219
namespace BizHawk.MultiClient
@ -31,11 +33,11 @@ namespace BizHawk.MultiClient
public const string UNITCODE = "UnitCode";
// Attempt to import another type of movie file into a movie object.
public static Movie ImportFile(string path, out string errorMsg, out string warningMsg)
public static Movie ImportFile(string path, string bizVersion, out string errorMsg, out string warningMsg)
{
Movie m = new Movie();
errorMsg = "";
warningMsg = "";
Movie m = new Movie(bizVersion);
errorMsg = String.Empty;
warningMsg = String.Empty;
string ext = path != null ? Path.GetExtension(path).ToUpper() : "";
try
@ -82,7 +84,7 @@ namespace BizHawk.MultiClient
m = ImportZMV(path, out errorMsg, out warningMsg);
break;
}
if (errorMsg == "")
if (errorMsg == String.Empty)
{
m.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
}
@ -288,7 +290,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileInfo file = new FileInfo(path);
StreamReader sr = file.OpenText();
string emulator = "";
@ -470,7 +472,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 43 4D 1A "FCM\x1A"
@ -727,7 +729,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 46 4D 56 1A "FMV\x1A"
@ -870,7 +872,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 16-byte signature and format version: "Gens Movie TEST9"
@ -996,7 +998,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
HawkFile hf = new HawkFile(path);
// .LSMV movies are .zip files containing data files.
if (!hf.IsArchive)
@ -1229,7 +1231,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 8-byte "MDFNMOVI" signature
@ -1353,7 +1355,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 0000: 4-byte signature: "MMV\0"
@ -1470,7 +1472,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 4E 53 53 1A "NSS\x1A"
@ -1700,7 +1702,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 53 4D 56 1A "SMV\x1A"
@ -1974,7 +1976,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 4-byte signature: 56 42 4D 1A "VBM\x1A"
@ -2247,7 +2249,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 12-byte signature: "VirtuaNES MV"
@ -2468,7 +2470,7 @@ namespace BizHawk.MultiClient
{
errorMsg = "";
warningMsg = "";
Movie m = new Movie(path + "." + Global.Config.MovieExtension);
Movie m = new Movie(path + "." + Global.Config.MovieExtension, GlobalWinF.MainForm.GetEmuVersion());
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
// 000 3-byte signature: 5A 4D 56 "ZMV"

View File

@ -1,250 +0,0 @@
using System.Collections.Generic;
using System.IO;
namespace BizHawk.MultiClient
{
/// <summary>
/// Represents the controller key presses of a movie
/// </summary>
public class MovieLog
{
#region Properties
public byte[] InitState { get; private set; }
public int StateCount
{
get
{
return _state_records.Count;
}
}
public int Length
{
get
{
return _movie_records.Count;
}
}
public int StateFirstIndex
{
get
{
return (_state_records.Count == 0) ? -1 : _state_records[0].Index;
}
}
public int StateLastIndex
{
get
{
return (_state_records.Count == 0) ? -1 : _state_records[_state_records.Count - 1].Index;
}
}
public int StateSizeInBytes
{
get
{
if (_state_records.Count > 0)
{
return StateCount * _state_records[0].State.Length;
}
else
{
return 0;
}
}
}
#endregion
#region Public Methods
public void Clear()
{
_movie_records.Clear();
_state_records.Clear();
}
public void ClearStates()
{
_state_records.Clear();
}
public void AppendFrame(string frame)
{
_movie_records.Add(frame);
}
public void AddState(byte[] state)
{
if (Global.Emulator.Frame == 0)
{
InitState = state;
}
if (Global.Emulator.Frame < StateFirstIndex)
{
_state_records.Clear();
_state_records.Add(new StateRecord(Global.Emulator.Frame, state));
}
if (Global.Emulator.Frame > StateLastIndex)
{
if (StateSizeInBytes + state.Length > MAXSTATERECORDSIZE)
{
// Discard the oldest state to save space.
_state_records.RemoveAt(0);
}
_state_records.Add(new StateRecord(Global.Emulator.Frame,state));
}
}
public void SetFrameAt(int frameNum, string frame)
{
if (frameNum < StateLastIndex && (frameNum < StateFirstIndex || frame != GetFrame(frameNum)))
{
TruncateStates(frameNum+1);
}
if (_movie_records.Count > frameNum)
{
_movie_records[frameNum] = frame;
}
else
{
_movie_records.Add(frame);
}
}
public void AddFrameAt(int frame, string record)
{
_movie_records.Insert(frame, record);
if (frame <= StateLastIndex)
{
if (frame <= StateFirstIndex)
{
_state_records.Clear();
Global.MovieSession.Movie.RewindToFrame(0);
}
else
{
_state_records.RemoveRange(frame - StateFirstIndex, StateLastIndex - frame + 1);
Global.MovieSession.Movie.RewindToFrame(frame);
}
}
}
public byte[] GetState(int frame)
{
return _state_records[frame - StateFirstIndex].State;
}
public void DeleteFrame(int frame)
{
_movie_records.RemoveAt(frame);
if (frame <= StateLastIndex)
{
if (frame <= StateFirstIndex)
{
_state_records.Clear();
}
else
{
_state_records.RemoveRange(frame - StateFirstIndex, StateLastIndex - frame + 1);
}
}
}
public void TruncateStates(int frame)
{
if (frame >= 0)
{
if (frame < StateFirstIndex)
{
_state_records.Clear();
}
else if (frame <= StateLastIndex)
{
_state_records.RemoveRange(frame - StateFirstIndex, StateLastIndex - frame + 1);
}
}
}
public string GetFrame(int frame)
{
if (frame >= 0 && frame < _movie_records.Count)
{
return _movie_records[frame];
}
else
{
return ""; //TODO: throw an exception?
}
}
public void WriteText(StreamWriter sw)
{
for (int i = 0; i < _movie_records.Count; i++)
{
sw.WriteLine(GetFrame(i));
}
}
public void TruncateMovie(int frame)
{
if (frame < _movie_records.Count)
{
_movie_records.RemoveRange(frame, _movie_records.Count - frame);
TruncateStates(frame);
}
}
public bool FrameLagged(int frame)
{
if (frame >= StateFirstIndex && frame <= StateLastIndex && frame <= _state_records.Count)
{
if (frame < _state_records.Count)
{
return _state_records[frame].Lagged;
}
else
{
return false;
}
}
else
{
return false;
}
}
#endregion
#region private fields
private class StateRecord
{
public StateRecord(int index, byte[] state)
{
Index = index;
State = state;
Lagged = Global.Emulator.IsLagFrame;
}
public readonly int Index;
public readonly byte[] State;
public readonly bool Lagged;
}
private readonly List<string> _movie_records = new List<string>();
private readonly List<StateRecord> _state_records = new List<StateRecord>();
//TODO: Make this size limit configurable by the user
private const int MAXSTATERECORDSIZE = 512*1024*1024; //To limit memory usage.
#endregion
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
namespace BizHawk.MultiClient
{
public class MovieSession
{
public MultitrackRecording MultiTrack = new MultitrackRecording();
public Movie Movie;
public MovieControllerAdapter MovieControllerAdapter = new MovieControllerAdapter();
public void LatchMultitrackPlayerInput(IController playerSource, MultitrackRewiringControllerAdapter rewiredSource)
{
if (MultiTrack.IsActive)
{
rewiredSource.PlayerSource = 1;
rewiredSource.PlayerTargetMask = 1 << (MultiTrack.CurrentPlayer);
if (MultiTrack.RecordAll) rewiredSource.PlayerTargetMask = unchecked((int)0xFFFFFFFF);
}
else rewiredSource.PlayerSource = -1;
MovieControllerAdapter.LatchPlayerFromSource(rewiredSource, MultiTrack.CurrentPlayer);
}
public void LatchInputFromPlayer(IController source)
{
MovieControllerAdapter.LatchFromSource(source);
}
/// <summary>
/// latch input from the input log, if available
/// </summary>
public void LatchInputFromLog()
{
string loggedFrame = Movie.GetInput(Global.Emulator.Frame);
MovieControllerAdapter.SetControllersAsMnemonic(loggedFrame);
}
}
}

View File

@ -1,15 +0,0 @@
namespace BizHawk.MultiClient
{
public class MultitrackRecording
{
public bool IsActive;
public int CurrentPlayer;
public bool RecordAll;
public MultitrackRecording()
{
IsActive = false;
CurrentPlayer = 0;
RecordAll = false;
}
}
}

View File

@ -5,6 +5,8 @@ using System.Text;
using System.Windows.Forms;
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class PlayMovie : Form
@ -65,12 +67,12 @@ namespace BizHawk.MultiClient
//Import file if necessary
Global.MainForm.StartNewMovie(MovieList[MovieView.SelectedIndices[0]], false);
GlobalWinF.MainForm.StartNewMovie(MovieList[MovieView.SelectedIndices[0]], false);
}
private void OK_Click(object sender, EventArgs e)
{
Global.MainForm.ReadOnly = ReadOnlyCheckBox.Checked;
GlobalWinF.MainForm.ReadOnly = ReadOnlyCheckBox.Checked;
Run();
Close();
}
@ -81,9 +83,9 @@ namespace BizHawk.MultiClient
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
ofd.Filter = filter;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = ofd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result == DialogResult.OK)
{
var file = new FileInfo(ofd.FileName);
@ -93,7 +95,7 @@ namespace BizHawk.MultiClient
{
if (file.Extension.ToUpper() == "STATE")
{
Movie m = new Movie(file.FullName);
Movie m = new Movie(file.FullName, GlobalWinF.MainForm.GetEmuVersion());
m.LoadMovie(); //State files will have to load everything unfortunately
if (m.Frames == 0)
{
@ -122,7 +124,7 @@ namespace BizHawk.MultiClient
int x = IsDuplicate(filename);
if (x == 0)
{
Movie m = new Movie(file.CanonicalFullPath);
Movie m = new Movie(file.CanonicalFullPath, GlobalWinF.MainForm.GetEmuVersion());
m.LoadMovie(); //State files will have to load everything unfortunately
if (m.Frames > 0)
{
@ -174,7 +176,7 @@ namespace BizHawk.MultiClient
private void PreLoadMovieFile(HawkFile path, bool force)
{
Movie m = new Movie(path.CanonicalFullPath);
Movie m = new Movie(path.CanonicalFullPath, GlobalWinF.MainForm.GetEmuVersion());
m.PreLoadText();
if (path.Extension == ".FM2")
{
@ -387,7 +389,7 @@ namespace BizHawk.MultiClient
}
break;
case MovieHeader.EMULATIONVERSION:
if (kvp.Value != Global.MainForm.GetEmuVersion())
if (kvp.Value != GlobalWinF.MainForm.GetEmuVersion())
{
item.BackColor = Color.Yellow;
}

View File

@ -1,6 +1,8 @@
using System;
using System.Windows.Forms;
using System.IO;
using BizHawk.Client.Common;
using BizHawk.Emulation.Consoles.GB;
using BizHawk.Emulation.Consoles.Nintendo.SNES;
using BizHawk.Emulation.Consoles.Sega;
@ -56,11 +58,11 @@ namespace BizHawk.MultiClient
}
MovieToRecord = new Movie(path);
MovieToRecord = new Movie(path, GlobalWinF.MainForm.GetEmuVersion());
//Header
MovieToRecord.Header.SetHeaderLine(MovieHeader.AUTHOR, AuthorBox.Text);
MovieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, Global.MainForm.GetEmuVersion());
MovieToRecord.Header.SetHeaderLine(MovieHeader.EMULATIONVERSION, GlobalWinF.MainForm.GetEmuVersion());
MovieToRecord.Header.SetHeaderLine(MovieHeader.MOVIEVERSION, MovieHeader.MovieVersion);
MovieToRecord.Header.SetHeaderLine(MovieHeader.GUID, MovieHeader.MakeGUID());
MovieToRecord.Header.SetHeaderLine(MovieHeader.PLATFORM, Global.Game.System);
@ -160,7 +162,7 @@ namespace BizHawk.MultiClient
}
}
}
Global.MainForm.StartNewMovie(MovieToRecord, true);
GlobalWinF.MainForm.StartNewMovie(MovieToRecord, true);
Global.Config.UseDefaultAuthor = DefaultAuthorCheckBox.Checked;
if (DefaultAuthorCheckBox.Checked)
@ -194,9 +196,9 @@ namespace BizHawk.MultiClient
string filter = "Movie Files (*." + Global.Config.MovieExtension + ")|*." + Global.Config.MovieExtension + "|Savestates|*.state|All Files|*.*";
sfd.Filter = filter;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result == DialogResult.OK)
{
filename = sfd.FileName;

View File

@ -1,44 +0,0 @@
using System;
namespace BizHawk.MultiClient
{
public class Subtitle
{
public string Message;
public int Frame;
public int X;
public int Y;
public int Duration;
public uint Color;
public Subtitle()
{
Message = "";
X = 0;
Y = 0;
Duration = 120;
Frame = 0;
Color = 0xFFFFFFFF;
}
public Subtitle(string message, int x, int y, int dur, int frame, UInt32 color)
{
Message = message;
Frame = frame;
X = x;
Y = y;
Duration = dur;
Color = color;
}
public Subtitle(Subtitle s)
{
Message = s.Message;
Frame = s.Frame;
X = s.X;
Y = s.Y;
Duration = s.Duration;
Color = s.Color;
}
}
}

View File

@ -1,233 +0,0 @@
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;
namespace BizHawk.MultiClient
{
public class SubtitleList
{
private readonly List<Subtitle> subs = new List<Subtitle>();
public SubtitleList()
{
}
public SubtitleList(Movie m)
{
if (m != null && m.Subtitles.Count == 0)
{
return;
}
for (int x = 0; x < m.Subtitles.Count; x++)
{
Subtitle s = new Subtitle(m.Subtitles.GetSubtitleByIndex(x));
subs.Add(s);
}
}
public Subtitle GetSubtitleByIndex(int index)
{
if (index >= subs.Count || index < 0) return new Subtitle();
return subs[index];
}
public string GetSubtitleText(int index)
{
if (index >= subs.Count || index < 0)
{
return "";
}
StringBuilder sb = new StringBuilder("subtitle ");
sb.Append(subs[index].Frame.ToString());
sb.Append(" ");
sb.Append(subs[index].X.ToString());
sb.Append(" ");
sb.Append(subs[index].Y.ToString());
sb.Append(" ");
sb.Append(subs[index].Duration.ToString());
sb.Append(" ");
sb.Append(string.Format("{0:X8}", subs[index].Color));
sb.Append(" ");
sb.Append(subs[index].Message);
return sb.ToString();
}
/// <summary>
/// Manages the logic of what subtitle should be displayed on any given frame based on frame & duration
/// </summary>
/// <param name="frame"></param>
/// <returns></returns>
public string GetSubtitleMessage(int frame)
{
if (subs.Count == 0) return "";
foreach (Subtitle t in subs)
{
if (frame >= t.Frame && frame <= t.Frame + t.Duration)
{
return t.Message;
}
}
return "";
}
public Subtitle GetSubtitle(int frame)
{
if (subs.Count == 0) return new Subtitle();
foreach (Subtitle t in subs)
{
if (frame >= t.Frame && frame <= t.Frame + t.Duration)
{
return t;
}
}
return new Subtitle();
}
public List<Subtitle> GetSubtitles(int frame)
{
if (subs.Count == 0)
{
return null;
}
return subs.Where(t => frame >= t.Frame && frame <= t.Frame + t.Duration).ToList();
}
public int Count
{
get { return subs.Count; }
}
//TODO
public Point GetSubtitlePoint(int frame)
{
Point p = new Point(0, 0);
return p;
}
/// <summary>
/// Attempts to parse string for necessary subtitle information, required is a frame and a message, space delminated, the word subtitle assumed to be first
/// </summary>
/// <param name="subtitleStr"></param>
/// <returns></returns>
public bool AddSubtitle(string subtitleStr)
{
if (subtitleStr.Length == 0) return false;
Subtitle s = new Subtitle();
int x = subtitleStr.IndexOf(' ');
if (x <= 0) return false;
//remove "subtitle"
string str = subtitleStr.Substring(x + 1, subtitleStr.Length - x - 1);
x = str.IndexOf(' ');
if (x <= 0) return false;
string frame = str.Substring(0, x);
str = str.Substring(x + 1, str.Length - x - 1);
try
{
s.Frame = int.Parse(frame);
}
catch
{
return false;
}
x = str.IndexOf(' ');
if (x <= 0) return false;
string X = str.Substring(0, x);
str = str.Substring(x + 1, str.Length - x - 1);
try
{
s.X = int.Parse(X);
}
catch
{
return false;
}
x = str.IndexOf(' ');
if (x <= 0) return false;
string Y = str.Substring(0, x);
str = str.Substring(x + 1, str.Length - x - 1);
try
{
s.Y = int.Parse(Y);
}
catch
{
return false;
}
x = str.IndexOf(' ');
if (x <= 0) return false;
string Duration = str.Substring(0, x);
str = str.Substring(x + 1, str.Length - x - 1);
try
{
s.Duration = int.Parse(Duration);
}
catch
{
return false;
}
x = str.IndexOf(' ');
if (x <= 0) return false;
string Color = str.Substring(0, x);
str = str.Substring(x + 1, str.Length - x - 1);
try
{
s.Color = uint.Parse(Color, NumberStyles.HexNumber);
}
catch
{
return false;
}
s.Message = str;
subs.Add(s);
return true;
}
public void AddSubtitle(Subtitle s)
{
subs.Add(s);
}
public void ClearSubtitles()
{
subs.Clear();
}
public void Remove(int index)
{
if (index >= subs.Count) return;
subs.RemoveAt(index);
}
public void WriteText(StreamWriter sw)
{
int length = subs.Count;
for (int x = 0; x < length; x++)
{
sw.WriteLine(GetSubtitleText(x));
}
}
}
}

View File

@ -2,6 +2,8 @@
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class SubtitleMaker : Form

View File

@ -1,252 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BizHawk.MultiClient
{
public class Cheat
{
#region Constructors
public Cheat(Watch watch, int value, int? compare = null, bool enabled = true)
{
_enabled = enabled;
_watch = watch;
_compare = compare;
_val = value;
Pulse();
}
public Cheat(Cheat cheat)
{
if (cheat.IsSeparator)
{
_enabled = false;
_watch = SeparatorWatch.Instance;
_compare = null;
}
else
{
_enabled = cheat.Enabled;
_watch = Watch.GenerateWatch(cheat.Domain,
cheat.Address.Value,
cheat.Size,
cheat.Type,
cheat.Name,
cheat.BigEndian.Value
);
_compare = cheat.Compare;
_val = cheat.Value.Value;
Pulse();
}
}
public static Cheat Separator
{
get { return new Cheat(SeparatorWatch.Instance, 0, null, false); }
}
#endregion
#region Properties
public bool IsSeparator
{
get { return _watch.IsSeparator; }
}
public bool Enabled
{
get { if (IsSeparator) return false; else return _enabled; }
}
public int? Address
{
get { return _watch.Address; }
}
public int? Value
{
get { return _watch.Value; }
}
public bool? BigEndian
{
get { if (IsSeparator) return null; else return _watch.BigEndian; }
}
public int? Compare
{
get { if (_compare.HasValue && !IsSeparator) return _compare; else return null; }
}
public MemoryDomain Domain
{
get { return _watch.Domain; }
}
public Watch.WatchSize Size
{
get { return _watch.Size; }
}
public char SizeAsChar
{
get { return _watch.SizeAsChar; }
}
public Watch.DisplayType Type
{
get { return _watch.Type; }
}
public char TypeAsChar
{
get { return _watch.TypeAsChar; }
}
public string Name
{
get { if (IsSeparator) return String.Empty; else return _watch.Notes; }
}
public string AddressStr
{
get { return _watch.AddressString; }
}
public string ValueStr
{
get { return _watch.ValueString; }
}
public string CompareStr
{
get
{
if (_compare.HasValue)
{
switch (_watch.Size)
{
default:
case Watch.WatchSize.Separator:
return String.Empty;
case Watch.WatchSize.Byte:
return (_watch as ByteWatch).FormatValue((byte)_compare.Value);
case Watch.WatchSize.Word:
return (_watch as WordWatch).FormatValue((ushort)_compare.Value);
case Watch.WatchSize.DWord:
return (_watch as DWordWatch).FormatValue((uint)_compare.Value);
}
}
else
{
return String.Empty;
}
}
}
#endregion
#region Actions
public void Enable()
{
if (!IsSeparator)
{
_enabled = true;
}
}
public void Disable()
{
if (!IsSeparator)
{
_enabled = false;
}
}
public void Toggle()
{
if (!IsSeparator)
{
_enabled ^= true;
}
}
public void Pulse()
{
if (!IsSeparator && _enabled)
{
if (_compare.HasValue)
{
if (_compare.Value == _watch.Value)
{
_watch.Poke(_val.ToString());
}
}
else
{
_watch.Poke(_val.ToString());
}
}
}
public bool Contains(int addr)
{
switch (_watch.Size)
{
default:
case Watch.WatchSize.Separator:
return false;
case Watch.WatchSize.Byte:
return _watch.Address.Value == addr;
case Watch.WatchSize.Word:
return (addr == _watch.Address.Value) || (addr == _watch.Address + 1);
case Watch.WatchSize.DWord:
return (addr == _watch.Address.Value) || (addr == _watch.Address + 1) ||
(addr == _watch.Address.Value + 2) || (addr == _watch.Address + 3);
}
}
public void Increment()
{
if (!IsSeparator)
{
_val++;
Pulse();
}
}
public void Decrement()
{
if (!IsSeparator)
{
_val--;
Pulse();
}
}
public void SetType(Watch.DisplayType type)
{
if (Watch.AvailableTypes(_watch.Size).Contains(type))
{
_watch.Type = type;
}
}
#endregion
#region private parts
private Watch _watch;
private int? _compare;
private int _val;
private bool _enabled;
#endregion
}
}

View File

@ -231,7 +231,7 @@
//
// CompareBox
//
this.CompareBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte;
this.CompareBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte;
this.CompareBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.CompareBox.Location = new System.Drawing.Point(113, 91);
this.CompareBox.MaxLength = 2;
@ -240,11 +240,11 @@
this.CompareBox.Size = new System.Drawing.Size(65, 20);
this.CompareBox.TabIndex = 15;
this.CompareBox.Text = "00";
this.CompareBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex;
this.CompareBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex;
//
// ValueBox
//
this.ValueBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte;
this.ValueBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte;
this.ValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper;
this.ValueBox.Location = new System.Drawing.Point(113, 65);
this.ValueBox.MaxLength = 2;
@ -253,7 +253,7 @@
this.ValueBox.Size = new System.Drawing.Size(65, 20);
this.ValueBox.TabIndex = 12;
this.ValueBox.Text = "00";
this.ValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex;
this.ValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex;
//
// CheatEdit
//

View File

@ -8,6 +8,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class CheatEdit : UserControl

View File

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using BizHawk.Client.Common;
using BizHawk.Emulation.Consoles.Nintendo.SNES;
using BizHawk.Emulation.Consoles.Nintendo;
using BizHawk.Emulation.Consoles.Sega;
@ -111,6 +112,7 @@ namespace BizHawk.MultiClient
Global.Config.RecentWatches.Add(path);
UpdateListView();
UpdateMessageLabel();
ToolHelpers.UpdateCheatRelatedTools();
}
}
}
@ -140,9 +142,9 @@ namespace BizHawk.MultiClient
if (Global.CheatList.Changes)
{
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
DialogResult result = MessageBox.Show("Save Changes?", "Cheats", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result == DialogResult.Yes)
{
Global.CheatList.Save();
@ -176,10 +178,24 @@ namespace BizHawk.MultiClient
UpdateListView();
UpdateMessageLabel();
Global.Config.RecentCheats.Add(Global.CheatList.CurrentFileName);
ToolHelpers.UpdateCheatRelatedTools();
}
}
}
private bool SaveAs()
{
var file = ToolHelpers.GetCheatSaveFileFromUser(Global.CheatList.CurrentFileName);
if (file != null)
{
return Global.CheatList.SaveFile(file.FullName);
}
else
{
return false;
}
}
private void NewCheatForm_Load(object sender, EventArgs e)
{
LoadConfigSettings();
@ -215,6 +231,7 @@ namespace BizHawk.MultiClient
Global.CheatList.Add(CheatEditor.Cheat);
UpdateListView();
UpdateMessageLabel();
ToolHelpers.UpdateCheatRelatedTools();
}
private void EditCheat()
@ -403,6 +420,7 @@ namespace BizHawk.MultiClient
}
UpdateListView();
ToolHelpers.UpdateCheatRelatedTools();
}
private void MoveDown()
@ -439,6 +457,7 @@ namespace BizHawk.MultiClient
}
UpdateListView();
ToolHelpers.UpdateCheatRelatedTools();
}
private void Remove()
@ -551,9 +570,10 @@ namespace BizHawk.MultiClient
if (result)
{
Global.CheatList.NewList();
Global.CheatList.NewList(GlobalWinF.MainForm.GenerateDefaultCheatFilename());
UpdateListView();
UpdateMessageLabel();
ToolHelpers.UpdateCheatRelatedTools();
}
}
@ -582,7 +602,7 @@ namespace BizHawk.MultiClient
private void OpenMenuItem_Click(object sender, EventArgs e)
{
bool append = sender == AppendMenuItem;
LoadFile(CheatList.GetFileFromUser(Global.CheatList.CurrentFileName), append);
LoadFile(ToolHelpers.GetCheatFileFromUser(Global.CheatList.CurrentFileName), append);
}
private void SaveMenuItem_Click(object sender, EventArgs e)
@ -602,7 +622,7 @@ namespace BizHawk.MultiClient
private void SaveAsMenuItem_Click(object sender, EventArgs e)
{
if (Global.CheatList.SaveAs())
if (SaveAs())
{
UpdateMessageLabel(saved: true);
}
@ -654,6 +674,7 @@ namespace BizHawk.MultiClient
UpdateListView();
UpdateMessageLabel();
ToolHelpers.UpdateCheatRelatedTools();
}
private void InsertSeparatorMenuItem_Click(object sender, EventArgs e)
@ -669,6 +690,7 @@ namespace BizHawk.MultiClient
UpdateListView();
UpdateMessageLabel();
ToolHelpers.UpdateCheatRelatedTools();
}
private void MoveUpMenuItem_Click(object sender, EventArgs e)
@ -697,11 +719,12 @@ namespace BizHawk.MultiClient
private void DisableAllCheatsMenuItem_Click(object sender, EventArgs e)
{
Global.CheatList.DisableAll();
ToolHelpers.UpdateCheatRelatedTools();
}
private void OpenGameGenieEncoderDecoderMenuItem_Click(object sender, EventArgs e)
{
Global.MainForm.LoadGameGenieEC();
GlobalWinF.MainForm.LoadGameGenieEC();
}
#endregion

View File

@ -1,631 +0,0 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace BizHawk.MultiClient
{
public class CheatList : IEnumerable<Cheat>
{
private List<Cheat> _cheatList = new List<Cheat>();
private string _currentFileName = String.Empty;
private bool _changes = false;
public CheatList() { }
public IEnumerator<Cheat> GetEnumerator()
{
return _cheatList.GetEnumerator();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
public Cheat this[int index]
{
get { return _cheatList[index]; }
}
public void Pulse()
{
foreach(var cheat in _cheatList)
{
cheat.Pulse();
}
}
/// <summary>
/// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM
/// </summary>
/// <returns></returns>
public bool AttemptToLoadCheatFile()
{
var file = new FileInfo(GenerateDefaultFilename());
if (file.Exists)
{
return Load(file.FullName, false);
}
else
{
return false;
}
}
public void FlagChanges()
{
_changes = true;
}
public int Count
{
get { return _cheatList.Count; }
}
public int CheatCount
{
get { return _cheatList.Count(x => !x.IsSeparator); }
}
public int ActiveCount
{
get { return _cheatList.Count(x => x.Enabled); }
}
public void NewList()
{
_cheatList.Clear();
_currentFileName = String.Empty;
_changes = false;
ToolHelpers.UpdateCheatRelatedTools();
}
public void Update()
{
_cheatList.ForEach(x => x.Pulse());
}
public void Add(Cheat c)
{
if (_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address))
{
_cheatList.FirstOrDefault(x => x.Domain == c.Domain && x.Address == c.Address).Enable();
}
else
{
_cheatList.Add(c);
}
_changes = true;
ToolHelpers.UpdateCheatRelatedTools();
}
public void Insert(int index, Cheat c)
{
if (_cheatList.Any(x => x.Domain == c.Domain && x.Address == c.Address))
{
_cheatList.FirstOrDefault(x => x.Domain == c.Domain && x.Address == c.Address).Enable();
}
else
{
_cheatList.Insert(index, c);
}
_changes = true;
ToolHelpers.UpdateCheatRelatedTools();
}
public void Remove(Cheat c)
{
_changes = true;
_cheatList.Remove(c);
ToolHelpers.UpdateCheatRelatedTools();
}
public void Remove(Watch w)
{
var cheat = _cheatList.FirstOrDefault(x => x.Domain == w.Domain && x.Address == w.Address);
if (cheat != null)
{
_changes = true;
_cheatList.Remove(cheat);
ToolHelpers.UpdateCheatRelatedTools();
}
}
public void RemoveRange(IEnumerable<Cheat> cheats)
{
_changes = true;
foreach (var cheat in cheats)
{
_cheatList.Remove(cheat);
}
ToolHelpers.UpdateCheatRelatedTools();
}
public bool Changes
{
get { return _changes; }
}
public void Clear()
{
_changes = true;
_cheatList.Clear();
ToolHelpers.UpdateCheatRelatedTools();
}
public void DisableAll()
{
_changes = true;
_cheatList.ForEach(x => x.Disable());
ToolHelpers.UpdateCheatRelatedTools();
}
public void EnableAll()
{
_changes = true;
_cheatList.ForEach(x => x.Enable());
ToolHelpers.UpdateCheatRelatedTools();
}
public bool IsActive(MemoryDomain domain, int address)
{
foreach (var cheat in _cheatList)
{
if (cheat.IsSeparator)
{
continue;
}
else if (cheat.Domain == domain && cheat.Contains(address) && cheat.Enabled)
{
return true;
}
}
return false;
}
public void SaveOnClose()
{
if (Global.Config.CheatsAutoSaveOnClose)
{
if (_changes && _cheatList.Any())
{
if (String.IsNullOrWhiteSpace(_currentFileName))
{
_currentFileName = GenerateDefaultFilename();
}
SaveFile(_currentFileName);
}
else if (!_cheatList.Any() && !String.IsNullOrWhiteSpace(_currentFileName))
{
new FileInfo(_currentFileName).Delete();
}
}
}
public bool Save()
{
if (String.IsNullOrWhiteSpace(_currentFileName))
{
_currentFileName = GenerateDefaultFilename();
}
return SaveFile(_currentFileName);
}
public bool SaveAs()
{
var file = GetSaveFileFromUser();
if (file != null)
{
return SaveFile(file.FullName);
}
else
{
return false;
}
}
public bool Load(string path, bool append)
{
var file = new FileInfo(path);
if (file.Exists == false)
{
return false;
}
if (!append)
{
_currentFileName = path;
}
using (StreamReader sr = file.OpenText())
{
if (append)
{
_changes = true;
}
else
{
Clear();
_changes = false;
}
string s;
while ((s = sr.ReadLine()) != null)
{
try
{
if (s == "----")
{
_cheatList.Add(Cheat.Separator);
}
else
{
int ADDR, VALUE;
int? COMPARE;
MemoryDomain DOMAIN;
bool ENABLED;
string NAME;
Watch.WatchSize SIZE = Watch.WatchSize.Byte;
Watch.DisplayType TYPE = Watch.DisplayType.Hex;
bool BIGENDIAN = false;
if (s.Length < 6) continue;
//NewCheat c = new NewCheat(
string[] vals = s.Split('\t');
ADDR = Int32.Parse(vals[0], NumberStyles.HexNumber);
VALUE = Int32.Parse(vals[1], NumberStyles.HexNumber);
if (vals[2] == "N")
{
COMPARE = null;
}
else
{
COMPARE = Int32.Parse(vals[2], NumberStyles.HexNumber);
}
DOMAIN = ToolHelpers.DomainByName(vals[3]);
ENABLED = vals[4] == "1";
NAME = vals[5];
//For backwards compatibility, don't assume these values exist
if (vals.Length > 6)
{
SIZE = Watch.SizeFromChar(vals[6][0]);
TYPE = Watch.DisplayTypeFromChar(vals[7][0]);
BIGENDIAN = vals[8] == "1";
}
Watch w = Watch.GenerateWatch(
DOMAIN,
ADDR,
SIZE,
TYPE,
NAME,
BIGENDIAN
);
Cheat c = new Cheat(w, VALUE, COMPARE, Global.Config.DisableCheatsOnLoad ? false : ENABLED);
_cheatList.Add(c);
}
}
catch
{
continue;
}
}
}
Global.MainForm.UpdateCheatStatus();
return true;
}
public string CurrentFileName
{
get { return _currentFileName; }
}
public void Sort(string column, bool reverse)
{
switch (column)
{
case Cheats.NAME:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Name)
.ThenBy(x => x.Address ?? 0)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Name)
.ThenBy(x => x.Address ?? 0)
.ToList();
}
break;
case Cheats.ADDRESS:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Address ?? 0)
.ThenBy(x => x.Name)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Address ?? 0)
.ThenBy(x => x.Name)
.ToList();
}
break;
case Cheats.VALUE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Value ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Value ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.COMPARE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Compare ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Compare ?? 0)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.ON:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Enabled)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Enabled)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.DOMAIN:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Domain)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Domain)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.SIZE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => ((int)x.Size))
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => ((int)x.Size))
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.ENDIAN:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.BigEndian)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.BigEndian)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
case Cheats.TYPE:
if (reverse)
{
_cheatList = _cheatList
.OrderByDescending(x => x.Type)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
else
{
_cheatList = _cheatList
.OrderBy(x => x.Type)
.ThenBy(x => x.Name)
.ThenBy(x => x.Address.Value)
.ToList();
}
break;
}
}
#region privates
private string GenerateDefaultFilename()
{
PathEntry pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Cheats"];
if (pathEntry == null)
{
pathEntry = Global.Config.PathEntries[Global.Emulator.SystemId, "Base"];
}
string path = PathManager.MakeAbsolutePath(pathEntry.Path, Global.Emulator.SystemId);
var f = new FileInfo(path);
if (f.Directory != null && f.Directory.Exists == false)
{
f.Directory.Create();
}
return Path.Combine(path, PathManager.FilesystemSafeName(Global.Game) + ".cht");
}
private bool SaveFile(string path)
{
try
{
FileInfo file = new FileInfo(path);
if (file.Directory != null && !file.Directory.Exists)
{
file.Directory.Create();
}
using (StreamWriter sw = new StreamWriter(path))
{
StringBuilder sb = new StringBuilder();
foreach (var cheat in _cheatList)
{
if (cheat.IsSeparator)
{
sb.AppendLine("----");
}
else
{
//Set to hex for saving
Watch.DisplayType type = cheat.Type;
cheat.SetType(Watch.DisplayType.Hex);
sb
.Append(cheat.AddressStr).Append('\t')
.Append(cheat.ValueStr).Append('\t')
.Append(cheat.Compare.HasValue ? cheat.Compare.Value.ToString() : "N").Append('\t')
.Append(cheat.Domain != null ? cheat.Domain.Name : String.Empty).Append('\t')
.Append(cheat.Enabled ? '1' : '0').Append('\t')
.Append(cheat.Name).Append('\t')
.Append(cheat.SizeAsChar).Append('\t')
.Append(cheat.TypeAsChar).Append('\t')
.Append(cheat.BigEndian.Value ? '1' : '0').Append('\t')
.AppendLine();
}
}
sw.WriteLine(sb.ToString());
}
_changes = false;
_currentFileName = path;
Global.Config.RecentCheats.Add(_currentFileName);
return true;
}
catch
{
return false;
}
}
#endregion
#region File Handling
public static FileInfo GetFileFromUser(string currentFile)
{
var ofd = new OpenFileDialog();
if (!String.IsNullOrWhiteSpace(currentFile))
{
ofd.FileName = Path.GetFileNameWithoutExtension(currentFile);
}
ofd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
ofd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
ofd.RestoreDirectory = true;
Global.Sound.StopSound();
var result = ofd.ShowDialog();
Global.Sound.StartSound();
if (result != DialogResult.OK)
return null;
var file = new FileInfo(ofd.FileName);
return file;
}
private FileInfo GetSaveFileFromUser()
{
var sfd = new SaveFileDialog();
if (!String.IsNullOrWhiteSpace(_currentFileName))
{
sfd.FileName = Path.GetFileNameWithoutExtension(_currentFileName);
}
else if (!(Global.Emulator is NullEmulator))
{
sfd.FileName = PathManager.FilesystemSafeName(Global.Game);
}
sfd.InitialDirectory = PathManager.GetCheatsPath(Global.Game);
sfd.Filter = "Cheat Files (*.cht)|*.cht|All Files|*.*";
sfd.RestoreDirectory = true;
Global.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
if (result != DialogResult.OK)
{
return null;
}
var file = new FileInfo(sfd.FileName);
Global.Config.LastRomPath = file.DirectoryName;
return file;
}
#endregion
}
}

View File

@ -3,6 +3,8 @@ using System.Drawing;
using System.Windows.Forms;
using BizHawk.Emulation.Consoles.GB;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.GBtools
{
public partial class CGBColorChooserForm : Form

View File

@ -4,6 +4,8 @@ using System.Drawing;
using System.Windows.Forms;
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.GBtools
{
public partial class ColorChooserForm : Form

View File

@ -7,6 +7,8 @@ using System.Linq;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.GBtools
{
public partial class DualGBFileSelector : UserControl

View File

@ -3,6 +3,8 @@ using System.Drawing;
using System.Text;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.GBtools
{
public partial class GBGPUView : Form
@ -955,9 +957,9 @@ namespace BizHawk.MultiClient.GBtools
dlg.FullOpen = true;
dlg.Color = spriteback;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = dlg.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result == DialogResult.OK)
{
// force full opaque

View File

@ -5,6 +5,8 @@ using System.Windows.Forms;
using System.Globalization;
using System.Text.RegularExpressions;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class GBGameGenie : Form
@ -411,6 +413,8 @@ namespace BizHawk.MultiClient
VALUE,
COMPARE,
enabled: true));
ToolHelpers.UpdateCheatRelatedTools();
}
}

View File

@ -3,6 +3,8 @@ using System.Drawing;
using System.Windows.Forms;
using BizHawk.MultiClient.GBtools;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient.GBAtools
{
public partial class GBAGPUView : Form

View File

@ -4,6 +4,8 @@ using System.Drawing;
using System.Windows.Forms;
using System.Globalization;
using System.Text.RegularExpressions;
using BizHawk.Client.Common;
using BizHawk.Emulation.Consoles.Sega;
#pragma warning disable 675 //TOOD: fix the potential problem this is masking
@ -276,6 +278,8 @@ namespace BizHawk.MultiClient
compare: null,
enabled: true
));
ToolHelpers.UpdateCheatRelatedTools();
}
}

View File

@ -1,6 +1,8 @@
using System;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class HexColors_Form : Form
@ -25,8 +27,8 @@ namespace BizHawk.MultiClient
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexBackgrndColor = colorDialog1.Color;
Global.MainForm.HexEditor1.Header.BackColor = colorDialog1.Color;
Global.MainForm.HexEditor1.MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor;
GlobalWinF.MainForm.HexEditor1.Header.BackColor = colorDialog1.Color;
GlobalWinF.MainForm.HexEditor1.MemoryViewerBox.BackColor = Global.Config.HexBackgrndColor;
HexBackgrnd.BackColor = colorDialog1.Color;
}
}
@ -36,8 +38,8 @@ namespace BizHawk.MultiClient
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexForegrndColor = colorDialog1.Color;
Global.MainForm.HexEditor1.Header.ForeColor = colorDialog1.Color;
Global.MainForm.HexEditor1.MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor;
GlobalWinF.MainForm.HexEditor1.Header.ForeColor = colorDialog1.Color;
GlobalWinF.MainForm.HexEditor1.MemoryViewerBox.ForeColor = Global.Config.HexForegrndColor;
HexForegrnd.BackColor = colorDialog1.Color;
}
@ -48,7 +50,7 @@ namespace BizHawk.MultiClient
if (colorDialog1.ShowDialog() == DialogResult.OK)
{
Global.Config.HexMenubarColor = colorDialog1.Color;
Global.MainForm.HexEditor1.menuStrip1.BackColor = Global.Config.HexMenubarColor;
GlobalWinF.MainForm.HexEditor1.menuStrip1.BackColor = Global.Config.HexMenubarColor;
HexMenubar.BackColor = colorDialog1.Color;
}
}

View File

@ -8,6 +8,8 @@ using System.Windows.Forms;
using System.Globalization;
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class HexEditor : Form
@ -384,7 +386,7 @@ namespace BizHawk.MultiClient
private bool CurrentROMIsArchive()
{
string path = Global.MainForm.CurrentlyOpenRom;
string path = GlobalWinF.MainForm.CurrentlyOpenRom;
if (path == null)
{
return false;
@ -412,7 +414,7 @@ namespace BizHawk.MultiClient
private byte[] GetRomBytes()
{
string path = Global.MainForm.CurrentlyOpenRom;
string path = GlobalWinF.MainForm.CurrentlyOpenRom;
if (path == null)
{
return null;
@ -534,9 +536,9 @@ namespace BizHawk.MultiClient
InputPrompt i = new InputPrompt { Text = "Go to Address" };
i._Location = GetPromptPoint();
i.SetMessage("Enter a hexadecimal value");
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
i.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (i.UserOK)
{
@ -704,16 +706,16 @@ namespace BizHawk.MultiClient
{
if (HighlightedAddress.HasValue || SecondaryHighlightedAddresses.Count > 0)
{
Global.MainForm.LoadRamWatch(true);
GlobalWinF.MainForm.LoadRamWatch(true);
}
if (HighlightedAddress.HasValue)
{
Global.MainForm.RamWatch1.AddWatch(MakeWatch(HighlightedAddress.Value));
GlobalWinF.MainForm.RamWatch1.AddWatch(MakeWatch(HighlightedAddress.Value));
}
foreach (int i in SecondaryHighlightedAddresses)
{
Global.MainForm.RamWatch1.AddWatch(MakeWatch(i));
GlobalWinF.MainForm.RamWatch1.AddWatch(MakeWatch(i));
}
}
@ -751,10 +753,10 @@ namespace BizHawk.MultiClient
poke.SetWatch(Watches);
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = poke.ShowDialog();
UpdateValues();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
}
}
@ -870,6 +872,7 @@ namespace BizHawk.MultiClient
Global.CheatList.RemoveRange(cheats);
}
MemoryViewerBox.Refresh();
ToolHelpers.UpdateCheatRelatedTools();
}
private Watch.WatchSize WatchSize
@ -891,10 +894,10 @@ namespace BizHawk.MultiClient
private void UpdateRelatedDialogs()
{
Global.MainForm.UpdateCheatStatus();
Global.MainForm.RamSearch1.UpdateValues();
Global.MainForm.RamWatch1.UpdateValues();
Global.MainForm.Cheats_UpdateValues();
GlobalWinF.MainForm.UpdateCheatStatus();
GlobalWinF.MainForm.RamSearch1.UpdateValues();
GlobalWinF.MainForm.RamWatch1.UpdateValues();
GlobalWinF.MainForm.Cheats_UpdateValues();
UpdateValues();
}
@ -1007,9 +1010,9 @@ namespace BizHawk.MultiClient
sfd.Filter = "Text (*.txt)|*.txt|All Files|*.*";
sfd.RestoreDirectory = true;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return null;
var file = new FileInfo(sfd.FileName);
@ -1020,7 +1023,7 @@ namespace BizHawk.MultiClient
{
if (Domain.Name == "ROM File")
{
string extension = Path.GetExtension(Global.MainForm.CurrentlyOpenRom);
string extension = Path.GetExtension(GlobalWinF.MainForm.CurrentlyOpenRom);
return "Binary (*" + extension + ")|*" + extension + "|All Files|*.*";
}
@ -1044,9 +1047,9 @@ namespace BizHawk.MultiClient
sfd.Filter = GetSaveFileFilter();
sfd.RestoreDirectory = true;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return null;
var file = new FileInfo(sfd.FileName);
@ -2059,9 +2062,9 @@ namespace BizHawk.MultiClient
private void setColorsToolStripMenuItem1_Click(object sender, EventArgs e)
{
HexColors_Form h = new HexColors_Form();
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
h.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
}
private void resetToDefaultToolStripMenuItem1_Click(object sender, EventArgs e)
@ -2121,7 +2124,7 @@ namespace BizHawk.MultiClient
}
else
{
FileInfo file = new FileInfo(Global.MainForm.CurrentlyOpenRom);
FileInfo file = new FileInfo(GlobalWinF.MainForm.CurrentlyOpenRom);
SaveFileBinary(file);
}
}

View File

@ -60,12 +60,12 @@ namespace BizHawk.MultiClient
private void Find_Prev_Click(object sender, EventArgs e)
{
Global.MainForm.HexEditor1.FindPrev(GetFindBoxChars(), false);
GlobalWinF.MainForm.HexEditor1.FindPrev(GetFindBoxChars(), false);
}
private void Find_Next_Click(object sender, EventArgs e)
{
Global.MainForm.HexEditor1.FindNext(GetFindBoxChars(), false);
GlobalWinF.MainForm.HexEditor1.FindNext(GetFindBoxChars(), false);
}
private void ChangeCasing()
@ -94,7 +94,7 @@ namespace BizHawk.MultiClient
{
if (e.KeyData == Keys.Enter)
{
Global.MainForm.HexEditor1.FindNext(GetFindBoxChars(), false);
GlobalWinF.MainForm.HexEditor1.FindNext(GetFindBoxChars(), false);
}
}
}

View File

@ -4,6 +4,7 @@ using System.Windows.Forms;
using System.Text;
using System.Globalization;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
@ -517,9 +518,9 @@ namespace BizHawk.MultiClient
{
InputPrompt i = new InputPrompt {Text = "Go to Address"};
i.SetMessage("Enter a hexadecimal value");
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
i.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (i.UserOK)
{

View File

@ -2,6 +2,8 @@
using System.Drawing;
using System.Windows.Forms;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
/// <summary>

View File

@ -6,6 +6,8 @@ using System.Linq;
using System.Windows.Forms;
using System.IO;
using BizHawk.Client.Common;
namespace BizHawk.MultiClient
{
public partial class LuaConsole : Form
@ -178,9 +180,9 @@ namespace BizHawk.MultiClient
if (!Directory.Exists(ofd.InitialDirectory))
Directory.CreateDirectory(ofd.InitialDirectory);
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = ofd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return null;
var file = new FileInfo(ofd.FileName);
@ -708,9 +710,9 @@ namespace BizHawk.MultiClient
private void luaFunctionsListToolStripMenuItem_Click(object sender, EventArgs e)
{
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
new LuaFunctionList().Show();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
}
public bool LoadLuaSession(string path)
@ -920,9 +922,9 @@ namespace BizHawk.MultiClient
}
sfd.Filter = "Lua Session Files (*.luases)|*.luases|All Files|*.*";
sfd.RestoreDirectory = true;
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
var result = sfd.ShowDialog();
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result != DialogResult.OK)
return null;
var file = new FileInfo(sfd.FileName);
@ -1017,9 +1019,9 @@ namespace BizHawk.MultiClient
if (changes)
{
Global.Sound.StopSound();
GlobalWinF.Sound.StopSound();
DialogResult result = MessageBox.Show("Save changes to session?", "Lua Console", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
Global.Sound.StartSound();
GlobalWinF.Sound.StartSound();
if (result == DialogResult.Yes)
{
if (string.Compare(currentSessionFile, "") == 0)
@ -1099,7 +1101,7 @@ namespace BizHawk.MultiClient
turnOffAllScriptsToolStripMenuItem.Enabled = luaRunning;
showRegisteredFunctionsToolStripMenuItem.Enabled = Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any();
showRegisteredFunctionsToolStripMenuItem.Enabled = GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any();
}
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e)
@ -1245,7 +1247,7 @@ namespace BizHawk.MultiClient
private void showRegisteredFunctionsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any())
if (GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any())
{
LuaRegisteredFunctionsList dialog = new LuaRegisteredFunctionsList();
dialog.ShowDialog();
@ -1254,7 +1256,7 @@ namespace BizHawk.MultiClient
private void contextMenuStrip2_Opening(object sender, CancelEventArgs e)
{
registeredFunctionsToolStripMenuItem.Enabled = Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any();
registeredFunctionsToolStripMenuItem.Enabled = GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Any();
}
}
}

View File

@ -3,7 +3,7 @@ using System.Linq;
using System.Text;
namespace BizHawk.MultiClient.tools
namespace BizHawk.MultiClient
{
public class LuaDocumentation
{

View File

@ -23,7 +23,7 @@ namespace BizHawk.MultiClient
private void PopulateListView()
{
FunctionView.Items.Clear();
foreach (LuaDocumentation.LibraryFunction l in Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList)
foreach (LuaDocumentation.LibraryFunction l in GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList)
{
ListViewItem item = new ListViewItem {Text = l.ReturnType};
item.SubItems.Add(l.library + ".");
@ -41,16 +41,16 @@ namespace BizHawk.MultiClient
switch (column)
{
case 0: //Return
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ReturnType).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ReturnType).ToList();
break;
case 1: //Library
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.library).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.library).ToList();
break;
case 2: //Name
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.name).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.name).ToList();
break;
case 3: //Parameters
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ParameterList).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderByDescending(x => x.ParameterList).ToList();
break;
}
}
@ -59,16 +59,16 @@ namespace BizHawk.MultiClient
switch (column)
{
case 0: //Return
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ReturnType).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ReturnType).ToList();
break;
case 1: //Library
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.library).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.library).ToList();
break;
case 2: //Name
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.name).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.name).ToList();
break;
case 3: //Parameters
Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ParameterList).ToList();
GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList.OrderBy(x => x.ParameterList).ToList();
break;
}
}
@ -132,7 +132,7 @@ namespace BizHawk.MultiClient
foreach (int index in indexes)
{
var library_function = Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList[index];
var library_function = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList[index];
sb.Append(library_function.library).Append('.').Append(library_function.name).Append("()\n");
}

Some files were not shown because too many files have changed in this diff Show More