diff --git a/BizHawk.MultiClient/AVOut/AviWriter.cs b/BizHawk.MultiClient/AVOut/AviWriter.cs index b74cc553bc..c0b1ebd79f 100644 --- a/BizHawk.MultiClient/AVOut/AviWriter.cs +++ b/BizHawk.MultiClient/AVOut/AviWriter.cs @@ -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 diff --git a/BizHawk.MultiClient/AVOut/FFmpegWriterForm.cs b/BizHawk.MultiClient/AVOut/FFmpegWriterForm.cs index 92a56088bb..8e18f84052 100644 --- a/BizHawk.MultiClient/AVOut/FFmpegWriterForm.cs +++ b/BizHawk.MultiClient/AVOut/FFmpegWriterForm.cs @@ -7,6 +7,8 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { /// diff --git a/BizHawk.MultiClient/AVOut/GifWriter.cs b/BizHawk.MultiClient/AVOut/GifWriter.cs index 981c77a813..2029977ed2 100644 --- a/BizHawk.MultiClient/AVOut/GifWriter.cs +++ b/BizHawk.MultiClient/AVOut/GifWriter.cs @@ -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 diff --git a/BizHawk.MultiClient/AVOut/GifWriterForm.cs b/BizHawk.MultiClient/AVOut/GifWriterForm.cs index 39fb9725d6..76eb79e0d8 100644 --- a/BizHawk.MultiClient/AVOut/GifWriterForm.cs +++ b/BizHawk.MultiClient/AVOut/GifWriterForm.cs @@ -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 diff --git a/BizHawk.MultiClient/AVOut/JMDWriter.cs b/BizHawk.MultiClient/AVOut/JMDWriter.cs index 3ea8f754e8..fd154f2719 100644 --- a/BizHawk.MultiClient/AVOut/JMDWriter.cs +++ b/BizHawk.MultiClient/AVOut/JMDWriter.cs @@ -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 { /// diff --git a/BizHawk.MultiClient/AVOut/VideoWriterChooserForm.cs b/BizHawk.MultiClient/AVOut/VideoWriterChooserForm.cs index 80cbdc0a9f..1632ac359e 100644 --- a/BizHawk.MultiClient/AVOut/VideoWriterChooserForm.cs +++ b/BizHawk.MultiClient/AVOut/VideoWriterChooserForm.cs @@ -7,6 +7,8 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { /// diff --git a/BizHawk.MultiClient/ArchiveChooser.cs b/BizHawk.MultiClient/ArchiveChooser.cs index 47dfa6458a..232c49b823 100644 --- a/BizHawk.MultiClient/ArchiveChooser.cs +++ b/BizHawk.MultiClient/ArchiveChooser.cs @@ -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 diff --git a/BizHawk.MultiClient/BizHawk.MultiClient.csproj b/BizHawk.MultiClient/BizHawk.MultiClient.csproj index 5aeadbc718..aa7275b8e6 100644 --- a/BizHawk.MultiClient/BizHawk.MultiClient.csproj +++ b/BizHawk.MultiClient/BizHawk.MultiClient.csproj @@ -60,6 +60,7 @@ true false AllRules.ruleset + WINDOWS true @@ -159,8 +160,6 @@ BizBox.cs - - Form @@ -194,6 +193,12 @@ FirmwaresConfig.cs + + Form + + + FirmwaresConfigInfo.cs + Form @@ -240,12 +245,44 @@ SoundConfig.cs - + + Component + + + Component + + + Form + + + Component + + + Form + + + QuickProgressPopup.cs + + + Component + + + Component + + + Component + + + + Component + + + Component + + - - - + @@ -271,7 +308,6 @@ EditCommentsForm.cs - Form @@ -289,13 +325,7 @@ EditSubtitlesForm.cs - - - - - - Form @@ -308,8 +338,6 @@ RecordMovie.cs - - Form @@ -325,7 +353,6 @@ - UserControl @@ -338,7 +365,6 @@ CheatForm.cs - Form @@ -708,7 +734,6 @@ RamWatch.cs - Form @@ -745,6 +770,9 @@ FirmwaresConfig.cs + + FirmwaresConfigInfo.cs + GifAnimator.cs @@ -760,6 +788,12 @@ RewindConfig.cs + + InputConfigBase.cs + + + QuickProgressPopup.cs + MainForm.cs Designer @@ -955,9 +989,7 @@ InputPrompt.cs - - @@ -974,14 +1006,14 @@ + + {24A0AA3C-B25F-4197-B23D-476D6462DBA0} + BizHawk.Client.Common + {197D4314-8A9F-49BA-977D-54ACEFAEB6BA} BizHawk.Emulation - - {EE135301-08B3-4EFC-A61C-1C53E1C65CB9} - BizHawk.Util - diff --git a/BizHawk.MultiClient/Config.cs b/BizHawk.MultiClient/Config.cs deleted file mode 100644 index a848a65c14..0000000000 --- a/BizHawk.MultiClient/Config.cs +++ /dev/null @@ -1,1467 +0,0 @@ -using System.IO; -using System.Linq; -using System.Drawing; -using System.Collections.Generic; -using System.Collections; - -namespace BizHawk.MultiClient -{ - public class Config - { - public Config() - { - ControllerConfig.ConfigCheckAllControlDefaults(this); - } - - public void ResolveDefaults() - { - PathEntries.ResolveWithDefaults(); - HotkeyBindings.ResolveWithDefaults(); - } - - //Path Settings ************************************/ - public bool UseRecentForROMs = false; - public string LastRomPath = "."; - public PathEntryCollection PathEntries = new PathEntryCollection(); - - //BIOS Paths - public Dictionary FirmwareUserSpecifications = new Dictionary(); //key: sysid+firmwareId; value: absolute path - - public string FFMpegPath = "%exe%/dll/ffmpeg.exe"; - - //N64 Config Settings - public string N64VidPlugin = "Rice"; - public int N64VideoSizeX = 320; - public int N64VideoSizeY = 240; - - public N64RicePluginSettings RicePlugin = new N64RicePluginSettings(); - public N64GlidePluginSettings GlidePlugin = new N64GlidePluginSettings(); - public N64Glide64mk2PluginSettings Glide64mk2Plugin = new N64Glide64mk2PluginSettings(); - - // General Client Settings - public int Input_Hotkey_OverrideOptions = 0; - public bool StackOSDMessages = true; - public int TargetZoomFactor = 2; - public int TargetDisplayFilter = 0; - public RecentFiles RecentRoms = new RecentFiles(8); - public bool PauseWhenMenuActivated = true; - public bool SaveWindowPosition = true; - public bool StartPaused = false; - public int MainWndx = -1; //Negative numbers will be ignored - public int MainWndy = -1; - public bool RunInBackground = true; - public bool AcceptBackgroundInput = false; - public bool SingleInstanceMode = false; - public bool AllowUD_LR = false; - public bool ShowContextMenu = true; - public bool EnableBackupMovies = true; - public bool HotkeyConfigAutoTab = true; - public bool InputConfigAutoTab = true; - public bool ShowLogWindow = false; - public bool BackupSavestates = true; - public bool BackupSaveram = true; - public bool AutoSavestates = false; - public bool SaveScreenshotWithStates = true; - public int AutofireOn = 1; - public int AutofireOff = 1; - public bool AutofireLagFrames = true; - public int SaveSlot = 0; //currently selected savestate slot - public bool AutoLoadLastSaveSlot = false; - public bool WIN32_CONSOLE = true; - public bool SkipLagFrame = false; - public string MovieExtension = "bkm"; - public bool SupressAskSave = false; - public bool AVI_CaptureOSD = false; - public bool Screenshot_CaptureOSD = false; - - public enum SaveStateTypeE { Default, Binary, Text }; - public SaveStateTypeE SaveStateType = SaveStateTypeE.Default; - - // Run-Control settings - public int FrameProgressDelayMs = 500; //how long until a frame advance hold turns into a frame progress? - public int FrameSkip = 4; - public int SpeedPercent = 100; - public int SpeedPercentAlternate = 400; - public bool ClockThrottle = true; - public bool AutoMinimizeSkipping = true; - public bool VSyncThrottle = false; - - //Rewind settings - public bool Rewind_UseDelta = true; - public bool RewindEnabledSmall = true; - public bool RewindEnabledMedium = true; - public bool RewindEnabledLarge = false; - public int RewindFrequencySmall = 1; - public int RewindFrequencyMedium = 2; - public int RewindFrequencyLarge = 60; - public int Rewind_MediumStateSize = 262144; //256kb - public int Rewind_LargeStateSize = 1048576; //1mb - public int Rewind_BufferSize = 128; //in mb - public bool Rewind_OnDisk = false; - public bool Rewind_IsThreaded = false; - - /// use vsync. if VSyncThrottle = false, this will try to use vsync without throttling to it - public bool VSync = false; - - // Display options - public int MessagesColor = -1; - public int AlertMessageColor = -65536; - public int LastInputColor = -23296; - public int MovieInput = -8355712; - public bool DisplayFPS = false; - public int DispFPSx = 0; - public int DispFPSy = 0; - public int DispFPSanchor = 0; //0 = UL, 1 = UR, 2 = DL, 3 = DR - public bool DisplayFrameCounter = false; - public int DispFrameCx = 0; - public int DispFrameCy = 14; - public int DispFrameanchor = 0; - public bool DisplayLagCounter = false; - public int DispLagx = 0; - public int DispLagy = 42; - public int DispLaganchor = 0; - public bool DisplayInput = false; - public int DispInpx = 0; - public int DispInpy = 28; - public int DispInpanchor = 0; - public bool DisplayRerecordCount = false; - public int DispRecx = 0; - public int DispRecy = 56; - public int DispRecanchor = 0; - public int DispMultix = 0; - public int DispMultiy = 14; - public int DispMultianchor = 1; - public bool DisplayGDI = false; - public bool SuppressGui = false; - public bool DisplayStatusBar = true; - public int DispRamWatchx = 0; - public int DispRamWatchy = 70; - public bool DisplayRamWatch = false; - public bool ShowMenuInFullscreen = false; - public int DispMessagex = 3; - public int DispMessagey = 0; - public int DispMessageanchor = 2; - public int DispAutoholdx = 0; - public int DispAutoholdy = 0; - public int DispAutoholdanchor = 1; - public bool DispBlurry = false; // make display look ugly - - // Sound options - public bool SoundEnabled = true; - public bool MuteFrameAdvance = true; - public int SoundVolume = 100; //Range 0-100 - public bool SoundThrottle = false; - public string SoundDevice = ""; - - // Log Window - public bool LogWindowSaveWindowPosition = true; - public int LogWindowWndx = -1; - public int LogWindowWndy = -1; - public int LogWindowWidth = -1; - public int LogWindowHeight = -1; - - // Lua Console - public RecentFiles RecentLua = new RecentFiles(8); - public RecentFiles RecentLuaSession = new RecentFiles(8); - public bool AutoLoadLuaConsole = false; - public bool LuaConsoleSaveWindowPosition = true; - public int LuaConsoleWndx = -1; //Negative numbers will be ignored even with save window position set - public int LuaConsoleWndy = -1; - public int LuaConsoleWidth = -1; - public int LuaConsoleHeight = -1; - public bool DisableLuaScriptsOnLoad = false; - - // RamWatch Settings - public RecentFiles RecentWatches = new RecentFiles(8); - public bool RamWatchSaveWindowPosition = true; - public bool RamWatchAlwaysOnTop = false; - public int RamWatchWndx = -1; //Negative numbers will be ignored even with save window position set - public int RamWatchWndy = -1; - public int RamWatchWidth = -1; - public int RamWatchHeight = -1; - public bool RamWatchShowChangeColumn = true; - public bool RamWatchShowPrevColumn = false; - public bool RamWatchShowDiffColumn = false; - public bool RamWatchShowDomainColumn = true; - - public Dictionary RamWatchColumnWidths = new Dictionary() - { - { "AddressColumn", -1 }, - { "ValueColumn", -1 }, - { "PrevColumn", -1 }, - { "ChangesColumn", -1 }, - { "DiffColumn", -1 }, - { "DomainColumn", -1 }, - { "NotesColumn",-1 }, - }; - - public Dictionary RamWatchColumnIndexes = new Dictionary() - { - { "AddressColumn", 0 }, - { "ValueColumn", 1 }, - { "PrevColumn", 2 }, - { "ChangesColumn", 3 }, - { "DiffColumn", 4 }, - { "DomainColumn", 5 }, - { "NotesColumn", 6 }, - }; - - public Watch.PreviousType RamWatchDefinePrevious = Watch.PreviousType.LastFrame; - - // RamSearch Settings - public int RamSearchPrev_Type = 1; - public bool RamSearchSaveWindowPosition = true; - public RecentFiles RecentSearches = new RecentFiles(8); - public int RamSearchWndx = -1; //Negative numbers will be ignored even with save window position set - public int RamSearchWndy = -1; - public int RamSearchWidth = -1; //Negative numbers will be ignored - public int RamSearchHeight = -1; - public int RamSearchPreviousAs = 0; - public bool RamSearchPreviewMode = true; - public bool RamSearchAlwaysExcludeRamWatch = false; - public int RamSearchAddressWidth = -1; - public int RamSearchValueWidth = -1; - public int RamSearchPrevWidth = -1; - public int RamSearchChangesWidth = -1; - public int RamSearchAddressIndex = 0; - public int RamSearchValueIndex = 1; - public int RamSearchPrevIndex = 2; - public int RamSearchChangesIndex = 3; - public bool RamSearchFastMode = false; - public bool RamSearchAlwaysOnTop = false; - - public Dictionary RamSearchColumnWidths = new Dictionary() - { - { "AddressColumn", -1 }, - { "ValueColumn", -1 }, - { "PrevColumn", -1 }, - { "ChangesColumn", -1 }, - { "DiffColumn", -1 }, - }; - - public Dictionary RamSearchColumnIndexes = new Dictionary() - { - { "AddressColumn", 0 }, - { "ValueColumn", 1 }, - { "PrevColumn", 2 }, - { "ChangesColumn", 3 }, - { "DiffColumn", 4 }, - }; - - public bool RamSearchShowPrevColumn = true; - public bool RamSearchShowChangeColumn = true; - public bool RamSearchShowDiffColumn = false; - - // HexEditor Settings - public bool AutoLoadHexEditor = false; - public bool HexEditorSaveWindowPosition = true; - public int HexEditorWndx = -1; //Negative numbers will be ignored even with save window position set - public int HexEditorWndy = -1; - public int HexEditorWidth = -1; - public int HexEditorHeight = -1; - public bool HexEditorBigEndian = false; - public int HexEditorDataSize = 1; - //Hex Editor Colors - public Color HexBackgrndColor = Color.FromName("Control"); - public Color HexForegrndColor = Color.FromName("ControlText"); - public Color HexMenubarColor = Color.FromName("Control"); - public Color HexFreezeColor = Color.LightBlue; - public Color HexHighlightColor = Color.Pink; - public Color HexHighlightFreezeColor = Color.Violet; - - //Trace Logger Settings - public bool TraceLoggerAutoLoad = false; - public bool TraceLoggerSaveWindowPosition = true; - public int TraceLoggerMaxLines = 100000; - public int TraceLoggerWndx = -1; - public int TraceLoggerWndy = -1; - public int TraceLoggerWidth = -1; - public int TraceLoggerHeight = -1; - - // Video dumping settings - public string VideoWriter = ""; - public int JMDCompression = 3; - public int JMDThreads = 3; - public string FFmpegFormat = ""; - public string FFmpegCustomCommand = "-c:a foo -c:v bar -f baz"; - public string AVICodecToken = ""; - public int GifWriterFrameskip = 3; - public int GifWriterDelay = -1; - - // NESPPU Settings - public bool AutoLoadNESPPU = false; - public bool NESPPUSaveWindowPosition = true; - public int NESPPUWndx = -1; - public int NESPPUWndy = -1; - public int NESPPURefreshRate = 4; - - // NESDebuger Settings - public bool AutoLoadNESDebugger = false; - public bool NESDebuggerSaveWindowPosition = true; - public int NESDebuggerWndx = -1; - public int NESDebuggerWndy = -1; - public int NESDebuggerWidth = -1; - public int NESDebuggerHeight = -1; - - // NESNameTableViewer Settings - public bool AutoLoadNESNameTable = false; - public bool NESNameTableSaveWindowPosition = true; - public int NESNameTableWndx = -1; - public int NESNameTableWndy = -1; - public int NESNameTableRefreshRate = 4; - - // NES Graphics settings - public bool NESAllowMoreThanEightSprites = false; - public bool NESClipLeftAndRight = false; - public bool NESAutoLoadPalette = true; - public bool NESDispBackground = true; - public bool NESDispSprites = true; - public int NESBackgroundColor = 0; - public string NESPaletteFile = ""; - public int NTSC_NESTopLine = 8; - public int NTSC_NESBottomLine = 231; - public int PAL_NESTopLine = 8; - public int PAL_NESBottomLine = 231; - - // gb gpu view settings - public bool AutoLoadGBGPUView = false; - public bool GBGPUViewSaveWindowPosition = true; - public int GBGPUViewWndx = -1; - public int GBGPUViewWndy = -1; - public Color GBGPUSpriteBack = Color.Lime; - - // SNES Graphics Debugger Dialog Settings - public bool AutoLoadSNESGraphicsDebugger = false; - public bool SNESGraphicsDebuggerSaveWindowPosition = true; - public int SNESGraphicsDebuggerWndx = -1; - public int SNESGraphicsDebuggerWndy = -1; - public int SNESGraphicsDebuggerRefreshRate = 4; - public bool SNESGraphicsUseUserBackdropColor = false; - public int SNESGraphicsUserBackdropColor = -1; - public string SNESPalette = "BizHawk"; - - // SNES Graphics settings - //bsnes allows the layers to be enabled for each priority level. - //this may not be important for the bg (there are two priority levels) - //but it may be useful for OBJ, so we might want to control them separately - public bool SNES_ShowBG1_0 = true; - public bool SNES_ShowBG2_0 = true; - public bool SNES_ShowBG3_0 = true; - public bool SNES_ShowBG4_0 = true; - public bool SNES_ShowBG1_1 = true; - public bool SNES_ShowBG2_1 = true; - public bool SNES_ShowBG3_1 = true; - public bool SNES_ShowBG4_1 = true; - public bool SNES_ShowOBJ1 = true; - public bool SNES_ShowOBJ2 = true; - public bool SNES_ShowOBJ3 = true; - public bool SNES_ShowOBJ4 = true; - - // SATURN GRAPHICS SETTINGS - public bool SaturnUseGL = false; - public int SaturnDispFactor = 1; - public bool SaturnDispFree = false; - public int SaturnGLW = 640; - public int SaturnGLH = 480; - - // PCE Graphics settings - public bool PCEDispBG1 = true; - public bool PCEDispOBJ1 = true; - public bool PCEDispBG2 = true; - public bool PCEDispOBJ2 = true; - - // PCE BG Viewer settings - public bool PCEBGViewerSaveWIndowPosition = true; - public bool PCEBGViewerAutoload = false; - public int PCEBGViewerWndx = -1; - public int PCEBGViewerWndy = -1; - public int PCEBGViewerRefreshRate = 16; - - // SMS Graphics settings - public bool SMSDispBG = true; - public bool SMSDispOBJ = true; - - // Coleco Settings - public bool ColecoSkipBiosIntro = false; - - //GB Debugger settings - public bool AutoloadGBDebugger = false; - public bool GBDebuggerSaveWindowPosition = true; - public bool GameBoySkipBIOS = true; - - // Cheats Dialog - public bool Cheats_ValuesAsHex = true; - public bool CheatsSaveWindowPosition = true; - public bool DisableCheatsOnLoad = false; - public bool LoadCheatFileByGame = true; - public bool CheatsAutoSaveOnClose = true; - public RecentFiles RecentCheats = new RecentFiles(8); - public int CheatsWndx = -1; - public int CheatsWndy = -1; - public int CheatsWidth = -1; - public int CheatsHeight = -1; - public int CheatsNameWidth = -1; - public int CheatsAddressWidth = -1; - public int CheatsValueWidth = -1; - public int CheatsCompareWidth = -1; - public int CheatsDomainWidth = -1; - public int CheatsOnWidth = -1; - public int CheatsNameIndex = 0; - public int CheatsAddressIndex = 1; - public int CheatsValueIndex = 2; - public int CheatsCompareIndex = 3; - public int CheatsOnIndex = 4; - public int CheatsDomainIndex = 5; - public bool CheatsAlwaysOnTop = false; - - public Dictionary CheatsColumnWidths = new Dictionary() - { - { "NamesColumn", -1 }, - { "AddressColumn", -1 }, - { "ValueColumn", -1 }, - { "CompareColumn", -1 }, - { "OnColumn", -1 }, - { "DomainColumn", -1 }, - { "SizeColumn", -1 }, - { "EndianColumn", -1 }, - { "DisplayTypeColumn", -1 }, - }; - - public Dictionary CheatsColumnIndices = new Dictionary() - { - { "NamesColumn", 0 }, - { "AddressColumn", 1 }, - { "ValueColumn", 2 }, - { "CompareColumn", 3 }, - { "OnColumn", 4 }, - { "DomainColumn", 5 }, - { "SizeColumn", 6 }, - { "EndianColumn", 7 }, - { "DisplayTypeColumn", 8 }, - }; - - public Dictionary CheatsColumnShow = new Dictionary() - { - { "NamesColumn", true }, - { "AddressColumn", true }, - { "ValueColumn", true }, - { "CompareColumn", true }, - { "OnColumn", false }, - { "DomainColumn", true }, - { "SizeColumn", true }, - { "EndianColumn", false }, - { "DisplayTypeColumn", false }, - }; - - // TAStudio Dialog - public bool TAStudioSaveWindowPosition = true; - public bool AutoloadTAStudio = false; - public int TASWndx = -1; - public int TASWndy = -1; - public int TASWidth = -1; - public int TASHeight = -1; - public bool TASUpdatePads = true; - - // VirtualPad Dialog - public bool VirtualPadSaveWindowPosition = true; - public bool AutoloadVirtualPad = false; - public bool VirtualPadSticky = true; - public int VPadWndx = -1; - public int VPadWndy = -1; - public int VPadWidth = -1; - public int VPadHeight = -1; - - // NES Game Genie Encoder/Decoder - public bool NESGGAutoload = false; - public bool NESGGSaveWindowPosition = true; - public int NESGGWndx = -1; - public int NESGGWndy = -1; - - // SNES Game Genie Encoder/Decoder - public bool SNESGGAutoload = false; - public bool SNESGGSaveWindowPosition = true; - public int SNESGGWndx = -1; - public int SNESGGWndy = -1; - - // GB/GG Game Genie Encoder/Decoder - public bool GBGGAutoload = false; - public bool GBGGSaveWindowPosition = true; - public int GBGGWndx = -1; - public int GBGGWndy = -1; - - // GEN Game Genie Encoder/Decoder - public bool GENGGAutoload = false; - public bool GENGGSaveWindowPosition = true; - public int GENGGWndx = -1; - public int GENGGWndy = -1; - - //Movie Settings - public RecentFiles RecentMovies = new RecentFiles(8); - public bool BindSavestatesToMovies = true; - public string DefaultAuthor = "default user"; - public bool UseDefaultAuthor = true; - public bool DisplaySubtitles = true; - public bool VBAStyleMovieLoadState = false; - public bool MoviePlaybackPokeMode = false; - - //Play Movie Dialog - public bool PlayMovie_IncludeSubdir = true; - public bool PlayMovie_ShowStateFiles = false; - public bool PlayMovie_MatchGameName = false; - - //TI83 - public bool TI83autoloadKeyPad = true; - public bool TI83KeypadSaveWindowPosition = true; - public int TI83KeyPadWndx = -1; - public int TI83KeyPadWndy = -1; - public bool TI83ToolTips = true; - - public BindingCollection HotkeyBindings = new BindingCollection(); - - //Analog Hotkey values - public int Analog_LargeChange = 10; - public int Analog_SmallChange = 1; - - // NES Sound settings - public int NESSquare1 = 376; - public int NESSquare2 = 376; - public int NESTriangle = 426; - public int NESNoise = 247; - public int NESDMC = 167; - - public const int NESSquare1Max = 376; - public const int NESSquare2Max = 376; - public const int NESTriangleMax = 426; - public const int NESNoiseMax = 247; - public const int NESDMCMax = 167; - - public struct AnalogBind - { - /// the physical stick that we're bound to - public string Value; - /// sensitivity and flip - public float Mult; - /// portion of axis to ignore - public float Deadzone; - public AnalogBind(string Value, float Mult, float Deadzone) - { - this.Value = Value; - this.Mult = Mult; - this.Deadzone = Deadzone; - } - } - - // [ControllerType][ButtonName] => Physical Bind - public Dictionary> AllTrollers = new Dictionary>(); - public Dictionary> AllTrollersAutoFire = new Dictionary>(); - public Dictionary> AllTrollersAnalog = new Dictionary>(); - - // SMS / GameGear Settings - public bool SmsEnableFM = true; - public bool SmsAllowOverlock = false; - public bool SmsForceStereoSeparation = false; - public bool SmsSpriteLimit = false; - public bool GGShowClippedRegions = false; - public bool GGHighlightActiveDisplayRegion = false; - - // PCEngine Settings - public bool PceSpriteLimit = false; - public bool PceEqualizeVolume = false; - public bool PceArcadeCardRewindHack = true; - - // Genesis Settings - - //Atari 2600 Settings - public bool Atari2600_BW = false; - public bool Atari2600_LeftDifficulty = true; - public bool Atari2600_RightDifficulty = true; - - //Atari 7800 Settings - - //ColecoVision - - //Intellivision - - //NES settings - - //SNES settings - public string SNESProfile = "Compatibility"; - public bool SNESUseRingBuffer = true; - public bool SNESAlwaysDoubleSize = false; - - //N64 settings - - //TI 83 settings - - //GB settings - public bool GB_ForceDMG = false; - public bool GB_GBACGB = false; - public bool GB_MulticartCompat = false; - public string GB_PaletteFile = ""; - public bool GB_AsSGB = false; - public Emulation.Consoles.GB.GBColors.ColorType CGBColors = Emulation.Consoles.GB.GBColors.ColorType.gambatte; - - //Dual Gb - - //GBA settings - - //Saturn - - //Commodore 64 Settings - - //GIF Animator Settings - public int GifAnimatorNumFrames; - public int GifAnimatorFrameSkip; - public int GifAnimatorSpeed; - public bool GifAnimatorReversable; - - //LuaWriter Settings - public int LuaDefaultTextColor = -16777216; - public bool LuaDefaultTextBold = false; - public int LuaWriterBackColor = -1; - - public int LuaKeyWordColor = -16776961; - public bool LuaKeyWordBold = false; - public int LuaCommentColor = -16744448; - public bool LuaCommentBold = false; - public int LuaStringColor = -8355712; - public bool LuaStringBold = false; - public int LuaSymbolColor = -16777216; - public bool LuaSymbolBold = false; - public int LuaLibraryColor = -16711681; - public bool LuaLibraryBold = false; - public int LuaDecimalColor = -23296; - public bool LuaDecimalBold = false; - public float LuaWriterFontSize = 11; - public string LuaWriterFont = "Courier New"; - public float LuaWriterZoom = 1; - public bool LuaWriterStartEmpty = false; - - //Atari 2600 Settings - public bool Atari2600_ShowBG = true; - public bool Atari2600_ShowPlayer1 = true; - public bool Atari2600_ShowPlayer2 = true; - public bool Atari2600_ShowMissle1 = true; - public bool Atari2600_ShowMissle2 = true; - public bool Atari2600_ShowBall = true; - public bool Atari2600_ShowPlayfield = true; - } - - #region Sub-classes TODO - it is about time to port these to separate files - - public class BindingCollection : IEnumerable - { - public List Bindings { get; private set; } - - public BindingCollection() - { - Bindings = new List(); - Bindings.AddRange(DefaultValues); - } - - public void Add(Binding b) - { - Bindings.Add(b); - } - - public IEnumerator GetEnumerator() - { - return Bindings.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public Binding this[string index] - { - get - { - return Bindings.FirstOrDefault(x => x.DisplayName == index) ?? new Binding(); - } - } - - public void ResolveWithDefaults() - { - //Add missing entries - foreach (Binding default_binding in DefaultValues) - { - var binding = Bindings.FirstOrDefault(x => x.DisplayName == default_binding.DisplayName); - if (binding == null) - { - Bindings.Add(default_binding); - } - } - - List entriesToRemove = new List(); - - //Remove entries that no longer exist in defaults - foreach (Binding entry in Bindings) - { - var binding = DefaultValues.FirstOrDefault(x => x.DisplayName == entry.DisplayName); - if (binding == null) - { - entriesToRemove.Add(entry); - } - } - - foreach (Binding entry in entriesToRemove) - { - Bindings.Remove(entry); - } - } - - public static List DefaultValues - { - get - { - return new List() - { - //General - new Binding() { DisplayName = "Frame Advance", Bindings = "F", TabGroup = "General", DefaultBinding = "F", Ordinal = 0 }, - new Binding() { DisplayName = "Rewind", Bindings = "Shift+R, J1 B7, X1 Left Trigger", TabGroup = "General", DefaultBinding = "Shift+R, J1 B7, X1 Left Trigger", Ordinal = 1 }, - new Binding() { DisplayName = "Pause", Bindings = "Pause", TabGroup = "General", DefaultBinding = "Pause", Ordinal = 2 }, - new Binding() { DisplayName = "Fast Forward", Bindings = "Tab, J1 B8, X1 Right Trigger", TabGroup = "General", DefaultBinding = "Tab, J1 B8, X1 Right Trigger", Ordinal = 3 }, - new Binding() { DisplayName = "Turbo", Bindings = "Shift+Tab", TabGroup = "General", DefaultBinding = "Shift+Tab", Ordinal = 4 }, - new Binding() { DisplayName = "Toggle Throttle", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 5 }, - new Binding() { DisplayName = "Soft Reset", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 6 }, - new Binding() { DisplayName = "Hard Reset", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 7 }, - new Binding() { DisplayName = "Quick Load", Bindings = "P", TabGroup = "General", DefaultBinding = "P", Ordinal = 8 }, - new Binding() { DisplayName = "Quick Save", Bindings = "I", TabGroup = "General", DefaultBinding = "I", Ordinal = 9 }, - new Binding() { DisplayName = "Autohold", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 10 }, - new Binding() { DisplayName = "Clear Autohold", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 11 }, - new Binding() { DisplayName = "Screenshot", Bindings = "F12", TabGroup = "General", DefaultBinding = "F12", Ordinal = 12 }, - new Binding() { DisplayName = "Full Screen", Bindings = "Alt+Return", TabGroup = "General", DefaultBinding = "Alt+Return", Ordinal = 13 }, - new Binding() { DisplayName = "Open ROM", Bindings = "Ctrl+O", TabGroup = "General", DefaultBinding = "Ctrl+O", Ordinal = 14 }, - new Binding() { DisplayName = "Close ROM", Bindings = "Ctrl+W", TabGroup = "General", DefaultBinding = "Ctrl+W", Ordinal = 15 }, - new Binding() { DisplayName = "Display FPS", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 16 }, - new Binding() { DisplayName = "Frame Counter", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 17 }, - new Binding() { DisplayName = "Lag Counter", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 18 }, - new Binding() { DisplayName = "Input Display", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 19 }, - new Binding() { DisplayName = "Toggle BG Input", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 20 }, - new Binding() { DisplayName = "Toggle Menu", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 21 }, - new Binding() { DisplayName = "Volume Up", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 22 }, - new Binding() { DisplayName = "Volume Down", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 23 }, - new Binding() { DisplayName = "Record A/V", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 24 }, - new Binding() { DisplayName = "Stop A/V", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 25 }, - new Binding() { DisplayName = "Larger Window", Bindings = "Alt+UpArrow", TabGroup = "General", DefaultBinding = "Alt+UpArrow", Ordinal = 26 }, - new Binding() { DisplayName = "Smaller Window", Bindings = "Alt+DownArrow", TabGroup = "General", DefaultBinding = "Alt+DownArrow", Ordinal = 27 }, - new Binding() { DisplayName = "Increase Speed", Bindings = "Equals", TabGroup = "General", DefaultBinding = "Equals", Ordinal = 28 }, - new Binding() { DisplayName = "Decrease Speed", Bindings = "Minus", TabGroup = "General", DefaultBinding = "Minus", Ordinal = 29 }, - new Binding() { DisplayName = "Reboot Core", Bindings = "Ctrl+R", TabGroup = "General", DefaultBinding = "Ctrl+R", Ordinal = 30 }, - new Binding() { DisplayName = "Autofire", Bindings = "", TabGroup = "General", DefaultBinding = "", Ordinal = 31 }, - - //Save States - new Binding() { DisplayName = "Save State 0", Bindings = "Shift+F10", TabGroup = "Save States", DefaultBinding = "Shift+F10", Ordinal = 1 }, - new Binding() { DisplayName = "Save State 1", Bindings = "Shift+F1", TabGroup = "Save States", DefaultBinding = "Shift+F1", Ordinal = 2 }, - new Binding() { DisplayName = "Save State 2", Bindings = "Shift+F2", TabGroup = "Save States", DefaultBinding = "Shift+F2", Ordinal = 3 }, - new Binding() { DisplayName = "Save State 3", Bindings = "Shift+F3", TabGroup = "Save States", DefaultBinding = "Shift+F3", Ordinal = 4 }, - new Binding() { DisplayName = "Save State 4", Bindings = "Shift+F4", TabGroup = "Save States", DefaultBinding = "Shift+F4", Ordinal = 5 }, - new Binding() { DisplayName = "Save State 5", Bindings = "Shift+F5", TabGroup = "Save States", DefaultBinding = "Shift+F5", Ordinal = 6 }, - new Binding() { DisplayName = "Save State 6", Bindings = "Shift+F6", TabGroup = "Save States", DefaultBinding = "Shift+F6", Ordinal = 7 }, - new Binding() { DisplayName = "Save State 7", Bindings = "Shift+F7", TabGroup = "Save States", DefaultBinding = "Shift+F7", Ordinal = 8 }, - new Binding() { DisplayName = "Save State 8", Bindings = "Shift+F8", TabGroup = "Save States", DefaultBinding = "Shift+F8", Ordinal = 9 }, - new Binding() { DisplayName = "Save State 9", Bindings = "Shift+F9", TabGroup = "Save States", DefaultBinding = "Shift+F9", Ordinal = 10 }, - new Binding() { DisplayName = "Load State 0", Bindings = "F10", TabGroup = "Save States", DefaultBinding = "F10", Ordinal = 11 }, - new Binding() { DisplayName = "Load State 1", Bindings = "F1", TabGroup = "Save States", DefaultBinding = "F1", Ordinal = 12 }, - new Binding() { DisplayName = "Load State 2", Bindings = "F2", TabGroup = "Save States", DefaultBinding = "F2", Ordinal = 13 }, - new Binding() { DisplayName = "Load State 3", Bindings = "F3", TabGroup = "Save States", DefaultBinding = "F3", Ordinal = 14 }, - new Binding() { DisplayName = "Load State 4", Bindings = "F4", TabGroup = "Save States", DefaultBinding = "F4", Ordinal = 15 }, - new Binding() { DisplayName = "Load State 5", Bindings = "F5", TabGroup = "Save States", DefaultBinding = "F5", Ordinal = 16 }, - new Binding() { DisplayName = "Load State 6", Bindings = "F6", TabGroup = "Save States", DefaultBinding = "F6", Ordinal = 17 }, - new Binding() { DisplayName = "Load State 7", Bindings = "F7", TabGroup = "Save States", DefaultBinding = "F7", Ordinal = 18 }, - new Binding() { DisplayName = "Load State 8", Bindings = "F8", TabGroup = "Save States", DefaultBinding = "F8", Ordinal = 19 }, - new Binding() { DisplayName = "Load State 9", Bindings = "F9", TabGroup = "Save States", DefaultBinding = "F9", Ordinal = 20 }, - new Binding() { DisplayName = "Select State 0", Bindings = "D0", TabGroup = "Save States", DefaultBinding = "D0", Ordinal = 21 }, - new Binding() { DisplayName = "Select State 1", Bindings = "D1", TabGroup = "Save States", DefaultBinding = "D1", Ordinal = 22 }, - new Binding() { DisplayName = "Select State 2", Bindings = "D2", TabGroup = "Save States", DefaultBinding = "D2", Ordinal = 23 }, - new Binding() { DisplayName = "Select State 3", Bindings = "D3", TabGroup = "Save States", DefaultBinding = "D3", Ordinal = 24 }, - new Binding() { DisplayName = "Select State 4", Bindings = "D4", TabGroup = "Save States", DefaultBinding = "D4", Ordinal = 25 }, - new Binding() { DisplayName = "Select State 5", Bindings = "D5", TabGroup = "Save States", DefaultBinding = "D5", Ordinal = 26 }, - new Binding() { DisplayName = "Select State 6", Bindings = "D6", TabGroup = "Save States", DefaultBinding = "D6", Ordinal = 27 }, - new Binding() { DisplayName = "Select State 7", Bindings = "D7", TabGroup = "Save States", DefaultBinding = "D7", Ordinal = 28 }, - new Binding() { DisplayName = "Select State 8", Bindings = "D8", TabGroup = "Save States", DefaultBinding = "D8", Ordinal = 29 }, - new Binding() { DisplayName = "Select State 9", Bindings = "D9", TabGroup = "Save States", DefaultBinding = "D9", Ordinal = 30 }, - new Binding() { DisplayName = "Save Named State", Bindings = "", TabGroup = "Save States", DefaultBinding = "", Ordinal = 31 }, - new Binding() { DisplayName = "Load Named State", Bindings = "", TabGroup = "Save States", DefaultBinding = "", Ordinal = 32 }, - new Binding() { DisplayName = "Previous Slot", Bindings = "", TabGroup = "Save States", DefaultBinding = "", Ordinal = 33 }, - new Binding() { DisplayName = "Next Slot", Bindings = "", TabGroup = "Save States", DefaultBinding = "", Ordinal = 34 }, - - //Movie - new Binding() { DisplayName = "Toggle read-only", Bindings = "Q", TabGroup = "Movie", DefaultBinding = "Q", Ordinal = 0 }, - new Binding() { DisplayName = "Play Movie", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 1 }, - new Binding() { DisplayName = "Record Movie", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 2 }, - new Binding() { DisplayName = "Stop Movie", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 3 }, - new Binding() { DisplayName = "Play from beginning", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 4 }, - new Binding() { DisplayName = "Save Movie", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 5 }, - new Binding() { DisplayName = "Toggle MultiTrack", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 6 }, - new Binding() { DisplayName = "MT Select All", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 7 }, - new Binding() { DisplayName = "MT Select None", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 8 }, - new Binding() { DisplayName = "MT Increment Player", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 9 }, - new Binding() { DisplayName = "MT Decrement Player", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 10 }, - new Binding() { DisplayName = "Movie Poke", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 11 }, - new Binding() { DisplayName = "Scrub Input", Bindings = "", TabGroup = "Movie", DefaultBinding = "", Ordinal = 12 }, - - //Tools - new Binding() { DisplayName = "Ram Watch", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 0 }, - new Binding() { DisplayName = "Ram Search", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 1 }, - new Binding() { DisplayName = "Hex Editor", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 3 }, - new Binding() { DisplayName = "Trace Logger", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 4 }, - new Binding() { DisplayName = "Lua Console", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 5 }, - new Binding() { DisplayName = "Cheats", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 6 }, - new Binding() { DisplayName = "TAStudio", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 7 }, - new Binding() { DisplayName = "ToolBox", Bindings = "T", TabGroup = "Tools", DefaultBinding = "", Ordinal = 8 }, - new Binding() { DisplayName = "Virtual Pad", Bindings = "", TabGroup = "Tools", DefaultBinding = "", Ordinal = 9 }, - - new Binding() { DisplayName = "New Search", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 10 }, - new Binding() { DisplayName = "Do Search", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 11 }, - new Binding() { DisplayName = "Previous Compare To", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 12 }, - new Binding() { DisplayName = "Next Compare To", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 13 }, - new Binding() { DisplayName = "Previous Operator", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 14 }, - new Binding() { DisplayName = "Next Operator", Bindings = "", TabGroup = "Ram Search", DefaultBinding = "", Ordinal = 15 }, - - //SNES - new Binding() { DisplayName = "Toggle BG 1", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 0 }, - new Binding() { DisplayName = "Toggle BG 2", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 1 }, - new Binding() { DisplayName = "Toggle BG 3", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 2 }, - new Binding() { DisplayName = "Toggle BG 4", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 3 }, - new Binding() { DisplayName = "Toggle OBJ 1", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 4 }, - new Binding() { DisplayName = "Toggle OBJ 2", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 5 }, - new Binding() { DisplayName = "Toggle OBJ 3", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 6 }, - new Binding() { DisplayName = "Toggle OBJ 4", Bindings = "", TabGroup = "SNES", DefaultBinding = "", Ordinal = 7 }, - - //Analog - new Binding() { DisplayName = "Y Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 0 }, - new Binding() { DisplayName = "Y Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 1 }, - new Binding() { DisplayName = "Y Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 2 }, - new Binding() { DisplayName = "Y Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 3 }, - new Binding() { DisplayName = "X Up Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 4 }, - new Binding() { DisplayName = "X Up Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 5 }, - new Binding() { DisplayName = "X Down Small", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 6 }, - new Binding() { DisplayName = "X Down Large", Bindings = "", TabGroup = "Analog", DefaultBinding = "", Ordinal = 7 }, - - }; - } - } - } - - public class Binding - { - //TODO: how about a delegate, that would be called by the mainform? Thereby putting all the action logic in one place - public string DisplayName; - public string Bindings; - public string DefaultBinding; - public string TabGroup; - public int Ordinal = 0; - public Binding() { } - } - - public class PathEntryCollection : IEnumerable - { - public List Paths { get; private set; } - - public PathEntryCollection() - { - Paths = new List(); - Paths.AddRange(DefaultValues); - } - - public void Add(PathEntry p) - { - Paths.Add(p); - } - - public IEnumerator GetEnumerator() - { - return Paths.GetEnumerator(); - } - - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public PathEntry this[string system, string type] - { - get - { - return Paths.FirstOrDefault(x => x.HasSystem(system) && x.Type == type); - } - } - - public void ResolveWithDefaults() - { - //Add missing entries - foreach (PathEntry defaultpath in DefaultValues) - { - var path = Paths.FirstOrDefault(x => x.System == defaultpath.System && x.Type == defaultpath.Type); - if (path == null) - { - Paths.Add(defaultpath); - } - } - - List entriesToRemove = new List(); - - //Remove entries that no longer exist in defaults - foreach (PathEntry pathEntry in Paths) - { - var path = DefaultValues.FirstOrDefault(x => x.System == pathEntry.System && x.Type == pathEntry.Type); - if (path == null) - { - entriesToRemove.Add(pathEntry); - } - } - - foreach (PathEntry entry in entriesToRemove) - { - Paths.Remove(entry); - } - - //Add missing displaynames - var missingDisplayPaths = Paths.Where(x => x.SystemDisplayName == null).ToList(); - foreach (PathEntry path in missingDisplayPaths) - { - path.SystemDisplayName = DefaultValues.FirstOrDefault(x => x.System == path.System).SystemDisplayName; - - } - } - - //Some frequently requested paths, made into a property for convenience - public string WatchPath { get { return Global.Config.PathEntries["Global", "Watch (.wch)"].Path; } } - public string MoviesPath { get { return Global.Config.PathEntries["Global", "Movies"].Path; } } - public string LuaPath { get { return Global.Config.PathEntries["Global", "Lua"].Path; } } - public string LogPath { get { return Global.Config.PathEntries["Global", "Debug Logs"].Path; } } - public string FirmwaresPath { get { return Global.Config.PathEntries["Global", "Firmware"].Path; } } - public string AVPath { get { return Global.Config.PathEntries["Global", "A/V Dumps"].Path; } } - public string GlobalBase { get { return Global.Config.PathEntries["Global", "Base"].Path; } } - - public static List DefaultValues - { - get - { - return new List() - { - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Movies", Path = Path.Combine(".", "Movies"), Ordinal = 0 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Movie backups", Path = Path.Combine(".", "Movies", "backup"), Ordinal = 1 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Lua", Path = Path.Combine(".", "Lua"), Ordinal = 2 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Watch (.wch)", Path = ".", Ordinal = 3 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "A/V Dumps", Path = ".", Ordinal = 4 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Debug Logs", Path = ".", Ordinal = 5 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Firmware", Path = Path.Combine(".", "Firmware"), Ordinal = 6 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Base ROM", Path = ".", Ordinal = 6 }, - new PathEntry() { System = "Global_NULL", SystemDisplayName="Global", Type = "Base", Path = ".", Ordinal = 6 }, - - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Base", Path = Path.Combine(".", "Intellivision"), Ordinal = 0 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry() { System = "INTV", SystemDisplayName="Intellivision", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Base", Path = Path.Combine(".", "NES"), Ordinal = 0 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry() { System = "NES", SystemDisplayName="NES", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Base", Path= Path.Combine(".", "SNES"), Ordinal = 0 }, - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "SNES_SGB", SystemDisplayName="SNES", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "Base", Path= Path.Combine(".", "GBA"), Ordinal = 0 }, - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "GBA", SystemDisplayName="GBA", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "Base", Path= Path.Combine(".", "SMS"), Ordinal = 0 }, - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "SMS", SystemDisplayName="SMS", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "Base", Path= Path.Combine(".", "Game Gear"), Ordinal = 0 }, - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "GG", SystemDisplayName="GG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "Base", Path= Path.Combine(".", "SG-1000"), Ordinal = 0 }, - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "SG", SystemDisplayName="SG", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "Base", Path= Path.Combine(".", "Genesis"), Ordinal = 0 }, - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "GEN", SystemDisplayName="Genesis", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Base", Path= Path.Combine(".", "PC Engine"), Ordinal = 0 }, - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "PCE_PCECD_SGX", SystemDisplayName="PC Engine", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Base", Path= Path.Combine(".", "Gameboy"), Ordinal = 0 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry() { System = "GB_GBC", SystemDisplayName="Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Base", Path= Path.Combine(".", "Dual Gameboy"), Ordinal = 0 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - new PathEntry() { System = "DGB", SystemDisplayName="Dual Gameboy", Type = "Palettes", Path = Path.Combine(".", "Palettes"), Ordinal = 6 }, - - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "Base", Path= Path.Combine(".", "TI83"), Ordinal = 0 }, - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "TI83", SystemDisplayName="TI83", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "A26", SystemDisplayName="Atari 2600", Type = "Base", Path= Path.Combine(".", "Atari 2600"), Ordinal = 0 }, - new PathEntry() { System = "A26", SystemDisplayName="Atari 2600", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "A26", SystemDisplayName="Atari 2600", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "A26", SystemDisplayName="Atari 2600", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "A26", SystemDisplayName="Atari 2600", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "Base", Path= Path.Combine(".", "Atari 7800"), Ordinal = 0 }, - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "A78", SystemDisplayName="Atari 7800", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "C64", SystemDisplayName="Commodore 64", Type = "Base", Path= Path.Combine(".", "C64"), Ordinal = 0 }, - new PathEntry() { System = "C64", SystemDisplayName="Commodore 64", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "C64", SystemDisplayName="Commodore 64", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "C64", SystemDisplayName="Commodore 64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "C64", SystemDisplayName="Commodore 64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "Base", Path= Path.Combine(".", "PSX"), Ordinal = 0 }, - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "PSX", SystemDisplayName="Playstation", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "Coleco", SystemDisplayName = "Coleco", Type = "Base", Path= Path.Combine(".", "Coleco"), Ordinal = 0 }, - new PathEntry() { System = "Coleco", SystemDisplayName = "Coleco", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "Coleco", SystemDisplayName = "Coleco", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "Coleco", SystemDisplayName = "Coleco", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "Coleco", SystemDisplayName = "Coleco", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "Base", Path= Path.Combine(".", "N64"), Ordinal = 0 }, - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "N64", SystemDisplayName = "N64", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "Base", Path= Path.Combine(".", "Saturn"), Ordinal = 0 }, - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "ROM", Path = ".", Ordinal = 1 }, - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "Savestates", Path= Path.Combine(".", "State"), Ordinal = 2 }, - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "Save RAM", Path = Path.Combine(".", "SaveRAM"), Ordinal = 3 }, - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "Screenshots", Path = Path.Combine(".", "Screenshots"), Ordinal = 4 }, - new PathEntry() { System = "SAT", SystemDisplayName = "Saturn", Type = "Cheats", Path = Path.Combine(".", "Cheats"), Ordinal = 5 }, - }; - } - } - } - - public class PathEntry - { - public string SystemDisplayName; - public string Type; - public string Path; - public string System; - public int Ordinal; - public PathEntry() { } - public bool HasSystem(string systemID) - { - string[] ids = System.Split('_'); - return ids.Contains(systemID); - } - } - - public enum PLUGINTYPE { RICE, GLIDE, GLIDE64MK2 }; - - public interface iPluginSettings - { - PLUGINTYPE PluginType { get; } - Dictionary GetPluginSettings(); - } - - public class N64RicePluginSettings : iPluginSettings - { - public PLUGINTYPE PluginType - { - get { return PLUGINTYPE.RICE; } - } - - public void FillPerGameHacks(GameInfo game) - { - if (Global.Config.RicePlugin.UseDefaultHacks) - { - DisableTextureCRC = game.GetBool("RiceDisableTextureCRC", false); - DisableCulling = game.GetBool("RiceDisableCulling", false); - IncTexRectEdge = game.GetBool("RiceIncTexRectEdge", false); - ZHack = game.GetBool("RiceZHack", false); - TextureScaleHack = game.GetBool("RiceTextureScaleHack", false); - PrimaryDepthHack = game.GetBool("RicePrimaryDepthHack", false); - Texture1Hack = game.GetBool("RiceTexture1Hack", false); - FastLoadTile = game.GetBool("RiceFastLoadTile", false); - UseSmallerTexture = game.GetBool("RiceUseSmallerTexture", false); - VIWidth = game.GetInt("RiceVIWidth", -1); - VIHeight = game.GetInt("RiceVIHeight", -1); - UseCIWidthAndRatio = game.GetInt("RiceUseCIWidthAndRatio", 0); - FullTMEM = game.GetInt("RiceFullTMEM", 0); - TxtSizeMethod2 = game.GetBool("RiceTxtSizeMethod2", false); - EnableTxtLOD = game.GetBool("RiceEnableTxtLOD", false); - FastTextureCRC = game.GetInt("RiceFastTextureCRC", 0); - EmulateClear = game.GetBool("RiceEmulateClear", false); - ForceScreenClear = game.GetBool("RiceForceScreenClear", false); - AccurateTextureMappingHack = game.GetInt("RiceAccurateTextureMappingHack", 0); - NormalBlender = game.GetInt("RiceNormalBlender", 0); - DisableBlender = game.GetBool("RiceDisableBlender", false); - ForceDepthBuffer = game.GetBool("RiceForceDepthBuffer", false); - DisableObjBG = game.GetBool("RiceDisableObjBG", false); - FrameBufferOption = game.GetInt("RiceFrameBufferOption", 0); - RenderToTextureOption = game.GetInt("RiceRenderToTextureOption", 0); - ScreenUpdateSettingHack = game.GetInt("RiceScreenUpdateSettingHack", 0); - EnableHacksForGame = game.GetInt("RiceEnableHacksForGame", 0); - } - } - - public Dictionary GetPluginSettings() - { - //TODO: deal witn the game depedent settings - Dictionary dictionary = new Dictionary(); - System.Reflection.FieldInfo[] members = Global.Config.RicePlugin.GetType().GetFields(); - foreach (System.Reflection.FieldInfo member in members) - { - object field = Global.Config.RicePlugin.GetType().GetField(member.Name).GetValue(Global.Config.RicePlugin); - dictionary.Add(member.Name, field); - } - - return dictionary; - } - - public int FrameBufferSetting = 0; - public int FrameBufferWriteBackControl = 0; - public int RenderToTexture = 0; - public int ScreenUpdateSetting = 4; - public int Mipmapping = 2; - public int FogMethod = 0; - public int ForceTextureFilter = 0; - public int TextureEnhancement = 0; - public int TextureEnhancementControl = 0; - public int TextureQuality = 0; - public int OpenGLDepthBufferSetting = 16; - public int MultiSampling = 0; - public int ColorQuality = 0; - public int OpenGLRenderSetting = 0; - public int AnisotropicFiltering = 0; - - - public bool NormalAlphaBlender = false; - public bool FastTextureLoading = false; - public bool AccurateTextureMapping = true; - public bool InN64Resolution = false; - public bool SaveVRAM = false; - public bool DoubleSizeForSmallTxtrBuf = false; - public bool DefaultCombinerDisable = false; - public bool EnableHacks = true; - public bool WinFrameMode = false; - public bool FullTMEMEmulation = false; - public bool OpenGLVertexClipper = false; - public bool EnableSSE = true; - public bool EnableVertexShader = false; - public bool SkipFrame = false; - public bool TexRectOnly = false; - public bool SmallTextureOnly = false; - public bool LoadHiResCRCOnly = true; - public bool LoadHiResTextures = false; - public bool DumpTexturesToFiles = false; - - public bool UseDefaultHacks = true; - public bool DisableTextureCRC = false; - public bool DisableCulling = false; - public bool IncTexRectEdge = false; - public bool ZHack = false; - public bool TextureScaleHack = false; - public bool PrimaryDepthHack = false; - public bool Texture1Hack = false; - public bool FastLoadTile = false; - public bool UseSmallerTexture = false; - public int VIWidth = -1; - public int VIHeight = -1; - public int UseCIWidthAndRatio = 0; - public int FullTMEM = 0; - public bool TxtSizeMethod2 = false; - public bool EnableTxtLOD = false; - public int FastTextureCRC = 0; - public bool EmulateClear = false; - public bool ForceScreenClear = false; - public int AccurateTextureMappingHack = 0; - public int NormalBlender = 0; - public bool DisableBlender = false; - public bool ForceDepthBuffer = false; - public bool DisableObjBG = false; - public int FrameBufferOption = 0; - public int RenderToTextureOption = 0; - public int ScreenUpdateSettingHack = 0; - public int EnableHacksForGame = 0; - } - - public class N64GlidePluginSettings : iPluginSettings - { - public PLUGINTYPE PluginType - { - get { return PLUGINTYPE.GLIDE; } - } - - public void FillPerGameHacks(GameInfo game) - { - if (Global.Config.GlidePlugin.UseDefaultHacks) - { - alt_tex_size = Global.Game.GetBool("Glide_alt_tex_size", false); - buff_clear = Global.Game.GetBool("Glide_buff_clear", true); - decrease_fillrect_edge = Global.Game.GetBool("Glide_decrease_fillrect_edge", false); - detect_cpu_write = Global.Game.GetBool("Glide_detect_cpu_write", false); - fb_clear = Global.Game.GetBool("Glide_fb_clear", false); - fb_hires = Global.Game.GetBool("Glide_fb_clear", true); - fb_read_alpha = Global.Game.GetBool("Glide_fb_read_alpha", false); - fb_smart = Global.Game.GetBool("Glide_fb_smart", false); - fillcolor_fix = Global.Game.GetBool("Glide_fillcolor_fix", false); - fog = Global.Game.GetBool("Glide_fog", true); - force_depth_compare = Global.Game.GetBool("Glide_force_depth_compare", false); - force_microcheck = Global.Game.GetBool("Glide_force_microcheck", false); - fb_hires_buf_clear = Global.Game.GetBool("Glide_fb_hires_buf_clear", true); - fb_ignore_aux_copy = Global.Game.GetBool("Glide_fb_ignore_aux_copy", false); - fb_ignore_previous = Global.Game.GetBool("Glide_fb_ignore_previous", false); - increase_primdepth = Global.Game.GetBool("Glide_increase_primdepth", false); - increase_texrect_edge = Global.Game.GetBool("Glide_increase_texrect_edge", false); - fb_optimize_texrect = Global.Game.GetBool("Glide_fb_optimize_texrect", true); - fb_optimize_write = Global.Game.GetBool("Glide_fb_optimize_write", false); - PPL = Global.Game.GetBool("Glide_PPL", false); - soft_depth_compare = Global.Game.GetBool("Glide_soft_depth_compare", false); - use_sts1_only = Global.Game.GetBool("Glide_use_sts1_only", false); - wrap_big_tex = Global.Game.GetBool("Glide_wrap_big_tex", false); - - depth_bias = Global.Game.GetInt("Glide_depth_bias", 20); - filtering = Global.Game.GetInt("Glide_filtering", 1); - fix_tex_coord = Global.Game.GetInt("Glide_fix_tex_coord", 0); - lodmode = Global.Game.GetInt("Glide_lodmode", 0); - - stipple_mode = Global.Game.GetInt("Glide_stipple_mode", 2); - stipple_pattern = Global.Game.GetInt("Glide_stipple_pattern", 1041204192); - swapmode = Global.Game.GetInt("Glide_swapmode", 1); - enable_hacks_for_game = Global.Game.GetInt("Glide_enable_hacks_for_game", 0); - } - } - - public Dictionary GetPluginSettings() - { - //TODO: deal witn the game depedent settings - Dictionary dictionary = new Dictionary(); - System.Reflection.FieldInfo[] members = Global.Config.GlidePlugin.GetType().GetFields(); - foreach (System.Reflection.FieldInfo member in members) - { - object field = Global.Config.GlidePlugin.GetType().GetField(member.Name).GetValue(Global.Config.GlidePlugin); - dictionary.Add(member.Name, field); - } - - return dictionary; - } - - public int wfmode = 1; - public bool wireframe = false; - public int card_id = 0; - public bool flame_corona = false; - public int ucode = 2; - public bool autodetect_ucode = true; - public bool motionblur = false; - public bool fb_read_always = false; - public bool unk_as_red = false; - public bool filter_cache = false; - public bool fast_crc = false; - public bool disable_auxbuf = false; - public bool fbo = false; - public bool noglsl = true; - public bool noditheredalpha = true; - public int tex_filter = 0; - public bool fb_render = false; - public bool wrap_big_tex = false; - public bool use_sts1_only = false; - public bool soft_depth_compare = false; - public bool PPL = false; - public bool fb_optimize_write = false; - public bool fb_optimize_texrect = true; - public bool increase_texrect_edge = false; - public bool increase_primdepth = false; - public bool fb_ignore_previous = false; - public bool fb_ignore_aux_copy = false; - public bool fb_hires_buf_clear = true; - public bool force_microcheck = false; - public bool force_depth_compare = false; - public bool fog = true; - public bool fillcolor_fix = false; - public bool fb_smart = false; - public bool fb_read_alpha = false; - public bool fb_get_info = false; - public bool fb_hires = true; - public bool fb_clear = false; - public bool detect_cpu_write = false; - public bool decrease_fillrect_edge = false; - public bool buff_clear = true; - public bool alt_tex_size = false; - public bool UseDefaultHacks = true; - public int enable_hacks_for_game = 0; - public int swapmode = 1; - public int stipple_pattern = 1041204192; - public int stipple_mode = 2; - public int scale_y = 100000; - public int scale_x = 100000; - public int offset_y = 0; - public int offset_x = 0; - public int lodmode = 0; - public int fix_tex_coord = 0; - public int filtering = 1; - public int depth_bias = 20; - } - - public class N64Glide64mk2PluginSettings : iPluginSettings - { - public PLUGINTYPE PluginType - { - get { return PLUGINTYPE.GLIDE64MK2; } - } - - public void FillPerGameHacks(GameInfo game) - { - if (Global.Config.Glide64mk2Plugin.UseDefaultHacks) - { - use_sts1_only = Global.Game.GetBool("Glide64mk2_use_sts1_only", false); - optimize_texrect = Global.Game.GetBool("Glide64mk2_optimize_texrect", true); - increase_texrect_edge = Global.Game.GetBool("Glide64mk2_increase_texrect_edge", false); - ignore_aux_copy = Global.Game.GetBool("Glide64mk2_ignore_aux_copy", false); - hires_buf_clear = Global.Game.GetBool("Glide64mk2_hires_buf_clear", true); - force_microcheck = Global.Game.GetBool("Glide64mk2_force_microcheck", false); - fog = Global.Game.GetBool("Glide64mk2_fog", true); - fb_smart = Global.Game.GetBool("Glide64mk2_fb_smart", false); - fb_read_alpha = Global.Game.GetBool("Glide64mk2_fb_read_alpha", false); - fb_hires = Global.Game.GetBool("Glide64mk2_fb_hires", true); - detect_cpu_write = Global.Game.GetBool("Glide64mk2_detect_cpu_write", false); - decrease_fillrect_edge = Global.Game.GetBool("Glide64mk2_decrease_fillrect_edge", false); - buff_clear = Global.Game.GetBool("Glide64mk2_buff_clear", true); - alt_tex_size = Global.Game.GetBool("Glide64mk2_alt_tex_size", true); - swapmode = Global.Game.GetInt("Glide64mk2_swapmode", 1); - stipple_pattern = Global.Game.GetInt("Glide64mk2_stipple_pattern", 1041204192); - stipple_mode = Global.Game.GetInt("Glide64mk2_stipple_mode", 2); - lodmode = Global.Game.GetInt("Glide64mk2_lodmode", 0); - filtering = Global.Game.GetInt("Glide64mk2_filtering", 0); - correct_viewport = Global.Game.GetBool("Glide64mk2_correct_viewport", false); - force_calc_sphere = Global.Game.GetBool("Glide64mk2_force_calc_sphere", false); - pal230 = Global.Game.GetBool("Glide64mk2_pal230", false); - texture_correction = Global.Game.GetBool("Glide64mk2_texture_correction", true); - n64_z_scale = Global.Game.GetBool("Glide64mk2_n64_z_scale", false); - old_style_adither = Global.Game.GetBool("Glide64mk2_old_style_adither", false); - zmode_compare_less = Global.Game.GetBool("Glide64mk2_zmode_compare_less", false); - adjust_aspect = Global.Game.GetBool("Glide64mk2_adjust_aspect", true); - clip_zmax = Global.Game.GetBool("Glide64mk2_clip_zmax", true); - clip_zmin = Global.Game.GetBool("Glide64mk2_clip_zmin", false); - force_quad3d = Global.Game.GetBool("Glide64mk2_force_quad3d", false); - useless_is_useless = Global.Game.GetBool("Glide64mk2_useless_is_useless", false); - fb_read_always = Global.Game.GetBool("Glide64mk2_fb_read_always", false); - aspectmode = Global.Game.GetInt("Glide64mk2_aspectmode", 0); - fb_crc_mode = Global.Game.GetInt("Glide64mk2_fb_crc_mode", 1); - enable_hacks_for_game = Global.Game.GetInt("Glide64mk2_enable_hacks_for_game", 0); - read_back_to_screen = Global.Game.GetInt("Glide64mk2_read_back_to_screen", 0); - fast_crc = Global.Game.GetBool("Glide64mk2_fast_crc", true); - } - } - - public Dictionary GetPluginSettings() - { - //TODO: deal witn the game depedent settings - Dictionary dictionary = new Dictionary(); - System.Reflection.FieldInfo[] members = Global.Config.Glide64mk2Plugin.GetType().GetFields(); - foreach (System.Reflection.FieldInfo member in members) - { - object field = Global.Config.Glide64mk2Plugin.GetType().GetField(member.Name).GetValue(Global.Config.Glide64mk2Plugin); - dictionary.Add(member.Name, field); - } - - return dictionary; - } - - public bool wrpFBO = true; - public int card_id = 0; - public bool use_sts1_only = false; - public bool optimize_texrect = true; - public bool increase_texrect_edge = false; - public bool ignore_aux_copy = false; - public bool hires_buf_clear = true; - public bool force_microcheck = false; - public bool fog = true; - public bool fb_smart = false; - public bool fb_read_alpha = false; - public bool fb_hires = true; - public bool detect_cpu_write = false; - public bool decrease_fillrect_edge = false; - public bool buff_clear = true; - public bool alt_tex_size = false; - public int swapmode = 1; - public int stipple_pattern = 1041204192; - public int stipple_mode = 2; - public int lodmode = 0; - public int filtering = 0; - public bool wrpAnisotropic = false; - public bool correct_viewport = false; - public bool force_calc_sphere = false; - public bool pal230 = false; - public bool texture_correction = true; - public bool n64_z_scale = false; - public bool old_style_adither = false; - public bool zmode_compare_less = false; - public bool adjust_aspect = true; - public bool clip_zmax = true; - public bool clip_zmin = false; - public bool force_quad3d = false; - public bool useless_is_useless = false; - public bool fb_read_always = false; - public bool fb_get_info = false; - public bool fb_render = true; - public int aspectmode = 0; - public int fb_crc_mode = 1; - public bool fast_crc = true; - public bool UseDefaultHacks = true; - public int enable_hacks_for_game = 0; - public int read_back_to_screen = 0; - } - - #endregion -} \ No newline at end of file diff --git a/BizHawk.MultiClient/ConfigService.cs b/BizHawk.MultiClient/ConfigService.cs deleted file mode 100644 index bdf9f850ef..0000000000 --- a/BizHawk.MultiClient/ConfigService.cs +++ /dev/null @@ -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(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); - } - } - } -} \ No newline at end of file diff --git a/BizHawk.MultiClient/CoreFileProvider.cs b/BizHawk.MultiClient/CoreFileProvider.cs deleted file mode 100644 index 43536dc876..0000000000 --- a/BizHawk.MultiClient/CoreFileProvider.cs +++ /dev/null @@ -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); - } - } -} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/FolderBrowserDialogEx.cs b/BizHawk.MultiClient/CustomControls/FolderBrowserDialogEx.cs new file mode 100644 index 0000000000..bbd6179fff --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/FolderBrowserDialogEx.cs @@ -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 +{ + + /// + /// Component wrapping access to the Browse For Folder common dialog box. + /// Call the ShowDialog() method to bring the dialog box up. + /// + 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:"; + + /// + /// Enum of CSIDLs identifying standard shell folders. + /// + 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, + } + + /// + /// Helper function that returns the IMalloc interface used by the shell. + /// + private static Win32API.IMalloc GetSHMalloc() + { + Win32API.IMalloc malloc; + Win32API.Shell32.SHGetMalloc(out malloc); + return malloc; + } + + /// + /// Shows the folder browser dialog box. + /// + 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; + } + + + /// + /// Shows the folder browser dialog box with the specified owner window. + /// + 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; + } + + /// + /// Helper function used to set and reset bits in the publicOptions bitfield. + /// + private void SetOptionField(int mask, bool turnOn) + { + if (turnOn) + publicOptions |= mask; + else + publicOptions &= ~mask; + } + + /// + /// Only return file system directories. If the user selects folders + /// that are not part of the file system, the OK button is unavailable. + /// + [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); } + } + + /// + /// 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. + /// + [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); + } + } + + + +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/HexTextBox.cs b/BizHawk.MultiClient/CustomControls/HexTextBox.cs new file mode 100644 index 0000000000..9313865bf1 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/HexTextBox.cs @@ -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(); + } + } +} diff --git a/BizHawk.MultiClient/CustomControls/InputConfigBase.cs b/BizHawk.MultiClient/CustomControls/InputConfigBase.cs new file mode 100644 index 0000000000..d8627a56f7 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/InputConfigBase.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.Windows.Forms; + +namespace BizHawk +{ + public class InputConfigBase : Form + { + public void CheckDups() + { + Dictionary dups = new Dictionary(); + 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; + } + } + + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/InputConfigBase.resx b/BizHawk.MultiClient/CustomControls/InputConfigBase.resx new file mode 100644 index 0000000000..ff31a6db56 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/InputConfigBase.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/MiscControls.cs b/BizHawk.MultiClient/CustomControls/MiscControls.cs new file mode 100644 index 0000000000..4ea75770b7 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/MiscControls.cs @@ -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); + } + } + +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/QuickProgressPopup.Designer.cs b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.Designer.cs new file mode 100644 index 0000000000..7094caf040 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.Designer.cs @@ -0,0 +1,77 @@ +namespace BizHawk +{ + partial class QuickProgressPopup + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/QuickProgressPopup.cs b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.cs new file mode 100644 index 0000000000..c3ac041523 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.cs @@ -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(); + } + } +} diff --git a/BizHawk.MultiClient/CustomControls/QuickProgressPopup.resx b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.resx new file mode 100644 index 0000000000..29dcb1b3a3 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/QuickProgressPopup.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/SmartTextBoxControl.cs b/BizHawk.MultiClient/CustomControls/SmartTextBoxControl.cs new file mode 100644 index 0000000000..34d8b7b35a --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/SmartTextBoxControl.cs @@ -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 { } + } + + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/TextDebugView.cs b/BizHawk.MultiClient/CustomControls/TextDebugView.cs new file mode 100644 index 0000000000..1c061cbe88 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/TextDebugView.cs @@ -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; + } + } + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/ToolStripEx.cs b/BizHawk.MultiClient/CustomControls/ToolStripEx.cs new file mode 100644 index 0000000000..fe7a40bf41 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/ToolStripEx.cs @@ -0,0 +1,84 @@ +//credit: http://blogs.msdn.com/b/rickbrew/archive/2006/01/09/511003.aspx + +using System; +using System.Windows.Forms; + +/// +/// This class adds on to the functionality provided in System.Windows.Forms.ToolStrip. +/// +public class ToolStripEx : ToolStrip +{ + private bool clickThrough = true; + + /// + /// Gets or sets whether the ToolStripEx honors item clicks when its containing form does + /// not have input focus. + /// + 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; + } + } +} + +/// +/// This class adds on to the functionality provided in System.Windows.Forms.MenuStrip. +/// +public class MenuStripEx : MenuStrip +{ + private bool clickThrough = true; + + /// + /// Gets or sets whether the ToolStripEx honors item clicks when its containing form does + /// not have input focus. + /// + 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; +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/Util.cs b/BizHawk.MultiClient/CustomControls/Util.cs new file mode 100644 index 0000000000..d3a7f8acf0 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/Util.cs @@ -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); + + /// + /// Dumps the contents of the ListView into a tab separated list of lines + /// + 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(); + } + } + } + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/ViewportPanel.cs b/BizHawk.MultiClient/CustomControls/ViewportPanel.cs new file mode 100644 index 0000000000..12e47dcbac --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/ViewportPanel.cs @@ -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 +{ + /// + /// A programmatic PictureBox, really, which will paint itself using the last bitmap that was provided + /// + public class RetainedViewportPanel : Control + { + Thread threadPaint; + EventWaitHandle ewh; + volatile bool killSignal; + + public Func ReleaseCallback; + + /// + /// Turns this panel into multi-threaded mode. + /// This will sort of glitch out other gdi things on the system, but at least its fast... + /// + 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 DisposeQueue = new Queue(); + + 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); + //} + + /// + /// Takes ownership of the provided bitmap and will use it for future painting + /// + public void SetBitmap(Bitmap newbmp) + { + lock (this) + { + if(bmp != null) DisposeQueue.Enqueue(bmp); + bmp = newbmp; + } + SignalPaint(); + } + + Bitmap bmp; + + /// bit of a hack; use at your own risk + /// you probably shouldn't modify this? + public Bitmap GetBitmap() + { + return bmp; + } + + protected override void OnPaintBackground(PaintEventArgs pevent) + { + + } + + + protected override void OnPaint(PaintEventArgs e) + { + SignalPaint(); + base.OnPaint(e); + } + + } + + /// + /// A dumb panel which functions as a placeholder for framebuffer painting + /// + 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); + } + } + + /// + /// A ViewportPanel with a vertical scroll bar + /// + 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); + } + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/CustomControls/VirtualListView.cs b/BizHawk.MultiClient/CustomControls/VirtualListView.cs new file mode 100644 index 0000000000..9cdbb42481 --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/VirtualListView.cs @@ -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 + /// + /// Retrieve the background color for a Listview cell (item and subitem). + /// + /// Listview item (row). + /// Listview subitem (column). + /// Background color to use + public delegate void QueryItemBkColorHandler(int item, int subItem, ref Color color); + + + /// + /// Retrieve the text for a Listview cell (item and subitem). + /// + /// Listview item (row). + /// Listview subitem (column). + /// Text to display. + public delegate void QueryItemTextHandler(int item, int subItem, out string text); + + /// + /// Retrieve the image index for a Listview item. + /// + /// Listview item (row). + /// Listview subitem (column) - should always be zero. + /// Index of associated ImageList. + public delegate void QueryItemImageHandler(int item, int subItem, out int imageIndex); + + /// + /// 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. + /// + /// Listview item (row). + /// The amount to indent the Listview item. + public delegate void QueryItemIndentHandler(int item, out int itemIndent); + + public delegate void QueryItemHandler(int idx, out ListViewItem item); + #endregion + + /// + /// 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. + /// + public class VirtualListView : ListView { + // store the item count to prevent the call to SendMessage(LVM_GETITEMCOUNT) + private int itemCount = 0; + + #region Display query callbacks + /// + /// Fire the QueryItemBkColor event which requests the background color for the passed Listview cell + /// + public event QueryItemBkColorHandler QueryItemBkColor; + + /// + /// Fire the QueryItemText event which requests the text for the passed Listview cell. + /// + [Category("Data")] + public event QueryItemTextHandler QueryItemText; + /// + /// Fire the QueryItemImage event which requests the ImageIndex for the passed Listview item. + /// + [Category("Data")] + public event QueryItemImageHandler QueryItemImage; + /// + /// Fire the QueryItemIndent event which requests the indent for the passed Listview item. + /// + [Category("Data")] + public event QueryItemIndentHandler QueryItemIndent; + [Category("Data")] + public event QueryItemHandler QueryItem; + #endregion + + #region Properties + /// + /// Gets/sets the sets the virtual number of items to be displayed. + /// + [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(); + } + } + + /// + /// Gets/sets how list items are to be displayed. + /// + /// Hide the ListView.View property. + /// Virtual Listviews only allow Details or List. + /// + 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; + } + } + + /// + /// Gets the required creation parameters when the control handle is created. + /// + /// Use LVS_OWNERDATA to set this as a virtual Listview. + /// + 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 + /// + /// Create a new instance of this control. + /// + 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 + /// + /// Set the state of the passed Listview item's index. + /// + /// Listview item's index. + /// Select the passed item? + 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; + } + } + + /// + /// Event to be fired whenever the control scrolls + /// + 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; + } + } +} diff --git a/BizHawk.MultiClient/CustomControls/Win32.cs b/BizHawk.MultiClient/CustomControls/Win32.cs new file mode 100644 index 0000000000..ccefefb97a --- /dev/null +++ b/BizHawk.MultiClient/CustomControls/Win32.cs @@ -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-DOS–based 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 + ); + + /// + /// 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. + /// + [Flags] + [CLSCompliant(false)] + public enum FileAttributes : uint + { + /// + /// 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". + /// + Readonly = 0x00000001, + + /// + /// The file or directory is hidden. It is not included in an ordinary directory listing. + /// + Hidden = 0x00000002, + + /// + /// A file or directory that the operating system uses a part of, or uses exclusively. + /// + System = 0x00000004, + + /// + /// The handle that identifies a directory. + /// + Directory = 0x00000010, + + /// + /// A file or directory that is an archive file or directory. Applications typically use this attribute to mark files for backup or removal. + /// + Archive = 0x00000020, + + /// + /// This value is reserved for system use. + /// + Device = 0x00000040, + + /// + /// A file that does not have other attributes set. This attribute is valid only when used alone. + /// + Normal = 0x00000080, + + /// + /// 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. + /// + Temporary = 0x00000100, + + /// + /// A file that is a sparse file. + /// + SparseFile = 0x00000200, + + /// + /// A file or directory that has an associated reparse point, or a file that is a symbolic link. + /// + ReparsePoint = 0x00000400, + + /// + /// 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. + /// + Compressed = 0x00000800, + + /// + /// 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. + /// + Offline = 0x00001000, + + /// + /// The file or directory is not to be indexed by the content indexing service. + /// + NotContentIndexed = 0x00002000, + + /// + /// 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. + /// + Encrypted = 0x00004000, + + /// + /// This value is reserved for system use. + /// + Virtual = 0x00010000 + } + } + +} \ No newline at end of file diff --git a/BizHawk.MultiClient/DisplayManager/DisplayManager.cs b/BizHawk.MultiClient/DisplayManager/DisplayManager.cs index c9e1ed0d0a..d97ca491d9 100644 --- a/BizHawk.MultiClient/DisplayManager/DisplayManager.cs +++ b/BizHawk.MultiClient/DisplayManager/DisplayManager.cs @@ -11,6 +11,8 @@ using System.Drawing.Imaging; //using dx=SlimDX; //using d3d=SlimDX.Direct3D9; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { /// @@ -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 /// update Global.RenderPanel from the passed IVideoProvider public void UpdateSource(IVideoProvider videoProvider) { - UpdateSourceEx(videoProvider, Global.RenderPanel); + UpdateSourceEx(videoProvider, GlobalWinF.RenderPanel); } /// @@ -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(); } diff --git a/BizHawk.MultiClient/FirmwareManager.cs b/BizHawk.MultiClient/FirmwareManager.cs deleted file mode 100644 index 6e120a3163..0000000000 --- a/BizHawk.MultiClient/FirmwareManager.cs +++ /dev/null @@ -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 ResolutionDictionary = new Dictionary(); - - - 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 dict = new Dictionary(); - public List files = new List(); - } - - 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(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; - } - } - } - } - - } - -} \ No newline at end of file diff --git a/BizHawk.MultiClient/Global.cs b/BizHawk.MultiClient/Global.cs deleted file mode 100644 index bd79a38c24..0000000000 --- a/BizHawk.MultiClient/Global.cs +++ /dev/null @@ -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; - - /// - /// whether throttling is force-disabled by use of fast forward - /// - 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(); - - /// - /// the global MovieSession can use this to deal with multitrack player remapping (should this be here? maybe it should be in MovieSession) - /// - 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(); - - /// - /// provides an opportunity to mutate the player's input in an autohold style - /// - public static StickyXORAdapter StickyXORAdapter = new StickyXORAdapter(); - - public static AutoFireStickyXORAdapter AutofireStickyXORAdapter = new AutoFireStickyXORAdapter(); - - /// - /// Forces any controller button to Off, useful for things like Joypad.Set - /// - public static ForceOffAdaptor ForceOffAdaptor = new ForceOffAdaptor(); - - /// - /// will OR together two IControllers - /// - public static ORAdapter OrControllerAdapter = new ORAdapter(); - - /// - /// fire off one-frame logical button clicks here. useful for things like ti-83 virtual pad and reset buttons - /// - 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(); - } -} diff --git a/BizHawk.MultiClient/HawkFile.cs b/BizHawk.MultiClient/HawkFile.cs deleted file mode 100644 index cb865b4d76..0000000000 --- a/BizHawk.MultiClient/HawkFile.cs +++ /dev/null @@ -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(); - } - } - } - - - /// - /// returns whether a bound file exists. if there is no bound file, it can't exist - /// - public bool Exists { get { return exists; } } - - /// - /// gets the directory containing the root - /// - public string Directory { get { return Path.GetDirectoryName(rootPath); } } - - /// - /// returns a stream for the currently bound file - /// - public Stream GetStream() - { - if (boundStream == null) - throw new InvalidOperationException("HawkFile: Can't call GetStream() before youve successfully bound something!"); - return boundStream; - } - - /// - /// indicates whether this instance is bound - /// - public bool IsBound { get { return boundStream != null; } } - - /// - /// returns the complete canonical full path ("c:\path\to\archive|member") of the bound file - /// - public string CanonicalFullPath { get { return MakeCanonicalName(rootPath, memberPath); } } - - /// - /// returns the complete canonical name ("archive|member") of the bound file - /// - public string CanonicalName { get { return MakeCanonicalName(Path.GetFileName(rootPath), memberPath); } } - - /// - /// returns the virtual name of the bound file (disregarding the archive) - /// - public string Name { get { return GetBoundNameFromCanonical(MakeCanonicalName(rootPath, memberPath)); } } - - /// - /// returns the extension of Name - /// - public string Extension { get { return Path.GetExtension(Name).ToUpper(); } } - - /// - /// Indicates whether this file is an archive - /// - 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 ArchiveItems - { - get - { - if (!IsArchive) throw new InvalidOperationException("Cant get archive items from non-archive"); - return archiveItems; - } - } - - /// - /// these extensions won't even be tried as archives (removes spurious archive detects since some of the signatures are pretty damn weak) - /// - public string[] NonArchiveExtensions = new string[] { }; - - //--- - bool exists; - bool rootExists; - string rootPath; - string memberPath; - Stream rootStream, boundStream; - SevenZip.SevenZipExtractor extractor; - List 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); - } - - /// - /// is the supplied path a canonical name including an archive? - /// - bool IsCanonicalArchivePath(string path) - { - return (path.IndexOf('|') != -1); - } - - /// - /// converts a canonical name to a bound name (the bound part, whether or not it is an archive) - /// - string GetBoundNameFromCanonical(string canonical) - { - string[] parts = canonical.Split('|'); - return parts[parts.Length - 1]; - } - - /// - /// makes a canonical name from two parts - /// - 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('\\', '/'); - } - - /// - /// binds the specified ArchiveItem which you should have gotten by interrogating an archive hawkfile - /// - public HawkFile BindArchiveMember(ArchiveItem item) - { - return BindArchiveMember(item.index); - } - - /// - /// finds an ArchiveItem with the specified name (path) within the archive; returns null if it doesnt exist - /// - public ArchiveItem FindArchiveMember(string name) - { - return ArchiveItems.FirstOrDefault(ai => ai.name == name); - } - - /// - /// binds a path within the archive; returns null if that path didnt exist. - /// - public HawkFile BindArchiveMember(string name) - { - var ai = FindArchiveMember(name); - if (ai == null) return null; - else return BindArchiveMember(ai); - } - - /// - /// binds the selected archive index - /// - 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; - } - - /// - /// Removes any existing binding - /// - public void Unbind() - { - if (boundStream != null && boundStream != rootStream) boundStream.Close(); - boundStream = null; - memberPath = null; - BoundIndex = null; - } - - /// - /// causes the root to be bound (in the case of non-archive files) - /// - void BindRoot() - { - boundStream = rootStream; - Console.WriteLine("HawkFile bound " + CanonicalFullPath); - } - - /// - /// Binds the first item in the archive (or the file itself). Supposing that there is anything in the archive. - /// - public HawkFile BindFirst() - { - BindFirstOf(); - return this; - } - - /// - /// binds one of the supplied extensions if there is only one match in the archive - /// - public HawkFile BindSoleItemOf(params string[] extensions) - { - return BindByExtensionCore(false, extensions); - } - - /// - /// 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 - /// - 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(); - 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(); - 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; - } - } -} diff --git a/BizHawk.MultiClient/Input/ControllerBinding.cs b/BizHawk.MultiClient/Input/ControllerBinding.cs index c8dd7ddbd3..80a11ea5be 100644 --- a/BizHawk.MultiClient/Input/ControllerBinding.cs +++ b/BizHawk.MultiClient/Input/ControllerBinding.cs @@ -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 FloatRanges = new WorkingDictionary(); - private readonly Dictionary FloatBinds = new Dictionary(); + private readonly Dictionary FloatBinds = new Dictionary(); 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; } diff --git a/BizHawk.MultiClient/Input/GamePad.cs b/BizHawk.MultiClient/Input/GamePad.cs index 5179db9e56..d3d8550fc1 100644 --- a/BizHawk.MultiClient/Input/GamePad.cs +++ b/BizHawk.MultiClient/Input/GamePad.cs @@ -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) diff --git a/BizHawk.MultiClient/Input/Input.cs b/BizHawk.MultiClient/Input/Input.cs index 986da8097f..b2c61dbb68 100644 --- a/BizHawk.MultiClient/Input/Input.cs +++ b/BizHawk.MultiClient/Input/Input.cs @@ -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 diff --git a/BizHawk.MultiClient/Input/Keyboard.cs b/BizHawk.MultiClient/Input/Keyboard.cs index a1d3f569a0..a8bf4210cd 100644 --- a/BizHawk.MultiClient/Input/Keyboard.cs +++ b/BizHawk.MultiClient/Input/Keyboard.cs @@ -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() diff --git a/BizHawk.MultiClient/LogConsole.cs b/BizHawk.MultiClient/LogConsole.cs index 2a93106993..f9de1c7591 100644 --- a/BizHawk.MultiClient/LogConsole.cs +++ b/BizHawk.MultiClient/LogConsole.cs @@ -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 diff --git a/BizHawk.MultiClient/LogWindow.cs b/BizHawk.MultiClient/LogWindow.cs index 79a9644619..b0ad3b4908 100644 --- a/BizHawk.MultiClient/LogWindow.cs +++ b/BizHawk.MultiClient/LogWindow.cs @@ -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(); }; diff --git a/BizHawk.MultiClient/MainForm.MenuItems.cs b/BizHawk.MultiClient/MainForm.MenuItems.cs index e8cdf4c021..5bf2f5e6f5 100644 --- a/BizHawk.MultiClient/MainForm.MenuItems.cs +++ b/BizHawk.MultiClient/MainForm.MenuItems.cs @@ -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) diff --git a/BizHawk.MultiClient/MainForm.Movie.cs b/BizHawk.MultiClient/MainForm.Movie.cs index cab9360910..d189b54941 100644 --- a/BizHawk.MultiClient/MainForm.Movie.cs +++ b/BizHawk.MultiClient/MainForm.Movie.cs @@ -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); } } diff --git a/BizHawk.MultiClient/MainForm.Rewind.cs b/BizHawk.MultiClient/MainForm.Rewind.cs index 78192592fb..d34d61023e 100644 --- a/BizHawk.MultiClient/MainForm.Rewind.cs +++ b/BizHawk.MultiClient/MainForm.Rewind.cs @@ -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; diff --git a/BizHawk.MultiClient/MainForm.cs b/BizHawk.MultiClient/MainForm.cs index dc730ac94f..445826a724 100644 --- a/BizHawk.MultiClient/MainForm.cs +++ b/BizHawk.MultiClient/MainForm.cs @@ -22,6 +22,8 @@ using BizHawk.Emulation.Consoles.Nintendo.SNES; using BizHawk.Emulation.Consoles.Sega; using BizHawk.Emulation.Consoles.TurboGrafx; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class MainForm : Form @@ -136,7 +138,26 @@ namespace BizHawk.MultiClient public void Cheats_Restart() { if (_cheats != null) _cheats.Restart(); - else Global.CheatList.NewList(); + else Global.CheatList.NewList(GenerateDefaultCheatFilename()); + ToolHelpers.UpdateCheatRelatedTools(); + } + + public string GenerateDefaultCheatFilename() + { + 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"); } #if WINDOWS @@ -158,7 +179,8 @@ namespace BizHawk.MultiClient public MainForm(string[] args) { - Global.MovieSession = new MovieSession { Movie = new Movie() }; + GlobalWinF.MainForm = this; + Global.MovieSession = new MovieSession { Movie = new Movie(GlobalWinF.MainForm.GetEmuVersion()) }; MainWait = new AutoResetEvent(false); Icon = Properties.Resources.logo; InitializeComponent(); @@ -185,7 +207,7 @@ namespace BizHawk.MultiClient using (HawkFile NesCartFile = new HawkFile(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "NesCarts.7z")).BindFirst()) return Util.ReadAllBytes(NesCartFile.GetStream()); }; - Global.MainForm = this; + //Global.CoreComm = new CoreComm(); //SyncCoreCommInputSignals(); @@ -211,29 +233,29 @@ namespace BizHawk.MultiClient ResizeBegin += (o, e) => { - if (Global.Sound != null) Global.Sound.StopSound(); + if (GlobalWinF.Sound != null) GlobalWinF.Sound.StopSound(); }; ResizeEnd += (o, e) => { - if (Global.RenderPanel != null) Global.RenderPanel.Resized = true; - if (Global.Sound != null) Global.Sound.StartSound(); + if (GlobalWinF.RenderPanel != null) GlobalWinF.RenderPanel.Resized = true; + if (GlobalWinF.Sound != null) GlobalWinF.Sound.StartSound(); }; Input.Initialize(); InitControls(); - Global.CoreComm = new CoreComm(); + GlobalWinF.CoreComm = new CoreComm(); SyncCoreCommInputSignals(); - Global.Emulator = new NullEmulator(Global.CoreComm); - Global.ActiveController = Global.NullControls; - Global.AutoFireController = Global.AutofireNullControls; - Global.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); + Global.Emulator = new NullEmulator(GlobalWinF.CoreComm); + GlobalWinF.ActiveController = GlobalWinF.NullControls; + GlobalWinF.AutoFireController = GlobalWinF.AutofireNullControls; + GlobalWinF.AutofireStickyXORAdapter.SetOnOffPatternFromConfig(); #if WINDOWS - Global.Sound = new Sound(Handle, Global.DSound); + GlobalWinF.Sound = new Sound(Handle, GlobalWinF.DSound); #else Global.Sound = new Sound(); #endif - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); RewireInputChain(); //TODO - replace this with some kind of standard dictionary-yielding parser in a separate component string cmdRom = null; @@ -292,7 +314,7 @@ namespace BizHawk.MultiClient } else { - Movie m = new Movie(cmdMovie); + Movie m = new Movie(cmdMovie, GlobalWinF.MainForm.GetEmuVersion()); ReadOnly = true; // if user is dumping and didnt supply dump length, make it as long as the loaded movie if (autoDumpLength == 0) @@ -311,7 +333,7 @@ namespace BizHawk.MultiClient } else { - Movie m = new Movie(Global.Config.RecentMovies[0]); + Movie m = new Movie(Global.Config.RecentMovies[0], GlobalWinF.MainForm.GetEmuVersion()); StartNewMovie(m, false); } } @@ -390,7 +412,7 @@ namespace BizHawk.MultiClient } if (Global.Config.TraceLoggerAutoLoad) { - if (Global.CoreComm.CpuTraceAvailable) + if (GlobalWinF.CoreComm.CpuTraceAvailable) { LoadTraceLogger(); } @@ -431,7 +453,7 @@ namespace BizHawk.MultiClient renderTarget.Paint += (o, e) => { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; }; } @@ -441,8 +463,8 @@ namespace BizHawk.MultiClient /// true if managed resources should be disposed; otherwise, false. protected override void Dispose(bool disposing) { - if (Global.DisplayManager != null) Global.DisplayManager.Dispose(); - Global.DisplayManager = null; + if (GlobalWinF.DisplayManager != null) GlobalWinF.DisplayManager.Dispose(); + GlobalWinF.DisplayManager = null; if (disposing && (components != null)) { @@ -538,15 +560,15 @@ namespace BizHawk.MultiClient public void SyncCoreCommInputSignals() { - SyncCoreCommInputSignals(Global.CoreComm); + SyncCoreCommInputSignals(GlobalWinF.CoreComm); } void SyncPresentationMode() { - Global.DisplayManager.Suspend(); + GlobalWinF.DisplayManager.Suspend(); #if WINDOWS - bool gdi = Global.Config.DisplayGDI || Global.Direct3D == null; + bool gdi = Global.Config.DisplayGDI || GlobalWinF.Direct3D == null; #endif if (renderTarget != null) { @@ -555,7 +577,7 @@ namespace BizHawk.MultiClient } if (retainedPanel != null) retainedPanel.Dispose(); - if (Global.RenderPanel != null) Global.RenderPanel.Dispose(); + if (GlobalWinF.RenderPanel != null) GlobalWinF.RenderPanel.Dispose(); #if WINDOWS if (gdi) @@ -574,7 +596,7 @@ namespace BizHawk.MultiClient if (gdi) { #endif - Global.RenderPanel = new SysdrawingRenderPanel(retainedPanel); + GlobalWinF.RenderPanel = new SysdrawingRenderPanel(retainedPanel); retainedPanel.ActivateThreaded(); #if WINDOWS } @@ -582,28 +604,28 @@ namespace BizHawk.MultiClient { try { - var d3dPanel = new Direct3DRenderPanel(Global.Direct3D, renderTarget); + var d3dPanel = new Direct3DRenderPanel(GlobalWinF.Direct3D, renderTarget); d3dPanel.CreateDevice(); - Global.RenderPanel = d3dPanel; + GlobalWinF.RenderPanel = d3dPanel; } catch { Program.DisplayDirect3DError(); - Global.Direct3D.Dispose(); - Global.Direct3D = null; + GlobalWinF.Direct3D.Dispose(); + GlobalWinF.Direct3D = null; SyncPresentationMode(); } } #endif - Global.DisplayManager.Resume(); + GlobalWinF.DisplayManager.Resume(); } void SyncThrottle() { - bool fastforward = Global.ClientControls["Fast Forward"] || FastForward; - bool superfastforward = Global.ClientControls["Turbo"]; - Global.ForceNoThrottle = unthrottled || fastforward; + bool fastforward = GlobalWinF.ClientControls["Fast Forward"] || FastForward; + bool superfastforward = GlobalWinF.ClientControls["Turbo"]; + GlobalWinF.ForceNoThrottle = unthrottled || fastforward; // realtime throttle is never going to be so exact that using a double here is wrong throttle.SetCoreFps(Global.Emulator.CoreComm.VsyncRate); @@ -626,14 +648,14 @@ namespace BizHawk.MultiClient { Global.Config.SpeedPercentAlternate = value; SyncThrottle(); - Global.OSD.AddMessage("Alternate Speed: " + value + "%"); + GlobalWinF.OSD.AddMessage("Alternate Speed: " + value + "%"); } void SetSpeedPercent(int value) { Global.Config.SpeedPercent = value; SyncThrottle(); - Global.OSD.AddMessage("Speed: " + value + "%"); + GlobalWinF.OSD.AddMessage("Speed: " + value + "%"); } public void ProgramRunLoop() @@ -646,20 +668,20 @@ namespace BizHawk.MultiClient Input.Instance.Update(); //handle events and dispatch as a hotkey action, or a hotkey button, or an input button ProcessInput(); - Global.ClientControls.LatchFromPhysical(Global.HotkeyCoalescer); - Global.ActiveController.LatchFromPhysical(Global.ControllerInputCoalescer); + GlobalWinF.ClientControls.LatchFromPhysical(GlobalWinF.HotkeyCoalescer); + GlobalWinF.ActiveController.LatchFromPhysical(GlobalWinF.ControllerInputCoalescer); - Global.ActiveController.OR_FromLogical(Global.ClickyVirtualPadController); - Global.AutoFireController.LatchFromPhysical(Global.ControllerInputCoalescer); + GlobalWinF.ActiveController.OR_FromLogical(GlobalWinF.ClickyVirtualPadController); + GlobalWinF.AutoFireController.LatchFromPhysical(GlobalWinF.ControllerInputCoalescer); - if (Global.ClientControls["Autohold"]) + if (GlobalWinF.ClientControls["Autohold"]) { - Global.StickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); - Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.AutoFireController.PressedButtons); + GlobalWinF.StickyXORAdapter.MassToggleStickyState(GlobalWinF.ActiveController.PressedButtons); + GlobalWinF.AutofireStickyXORAdapter.MassToggleStickyState(GlobalWinF.AutoFireController.PressedButtons); } - else if (Global.ClientControls["Autofire"]) + else if (GlobalWinF.ClientControls["Autofire"]) { - Global.AutofireStickyXORAdapter.MassToggleStickyState(Global.ActiveController.PressedButtons); + GlobalWinF.AutofireStickyXORAdapter.MassToggleStickyState(GlobalWinF.ActiveController.PressedButtons); } //if (!EmulatorPaused) @@ -673,7 +695,7 @@ namespace BizHawk.MultiClient //if(!IsNullEmulator()) StepRunLoop_Throttle(); - if (Global.DisplayManager.NeedsToPaint) { Render(); } + if (GlobalWinF.DisplayManager.NeedsToPaint) { Render(); } CheckMessages(); if (exit) @@ -744,7 +766,7 @@ namespace BizHawk.MultiClient private void LoadMoviesFromRecent(string path) { - Movie m = new Movie(path); + Movie m = new Movie(path, GetEmuVersion()); if (!m.Loaded) { @@ -766,14 +788,14 @@ namespace BizHawk.MultiClient BoolButtons = Global.Config.HotkeyBindings.Select(x => x.DisplayName).ToList() }); - foreach (Binding b in Global.Config.HotkeyBindings) + foreach (var b in Global.Config.HotkeyBindings) { controls.BindMulti(b.DisplayName, b.Bindings); } - Global.ClientControls = controls; - Global.NullControls = new Controller(NullEmulator.NullController); - Global.AutofireNullControls = new AutofireController(NullEmulator.NullController); + GlobalWinF.ClientControls = controls; + GlobalWinF.NullControls = new Controller(NullEmulator.NullController); + GlobalWinF.AutofireNullControls = new AutofireController(NullEmulator.NullController); } @@ -918,8 +940,8 @@ namespace BizHawk.MultiClient { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { - Global.ClickyVirtualPadController.Click(button); - Global.OSD.AddMessage(msg); + GlobalWinF.ClickyVirtualPadController.Click(button); + GlobalWinF.OSD.AddMessage(msg); } } }); @@ -965,7 +987,7 @@ namespace BizHawk.MultiClient } } - static Controller BindToDefinition(ControllerDefinition def, Dictionary> allbinds, Dictionary> analogbinds) + static Controller BindToDefinition(ControllerDefinition def, Dictionary> allbinds, Dictionary> analogbinds) { var ret = new Controller(def); Dictionary binds; @@ -1014,42 +1036,42 @@ namespace BizHawk.MultiClient { var def = Global.Emulator.ControllerDefinition; - Global.ActiveController = BindToDefinition(def, Global.Config.AllTrollers, Global.Config.AllTrollersAnalog); - Global.AutoFireController = BindToDefinitionAF(def, Global.Config.AllTrollersAutoFire); + GlobalWinF.ActiveController = BindToDefinition(def, Global.Config.AllTrollers, Global.Config.AllTrollersAnalog); + GlobalWinF.AutoFireController = BindToDefinitionAF(def, Global.Config.AllTrollersAutoFire); // allow propogating controls that are in the current controller definition but not in the prebaked one // these two lines shouldn't be required anymore under the new system? - Global.ActiveController.ForceType(new ControllerDefinition(Global.Emulator.ControllerDefinition)); - Global.ClickyVirtualPadController.Type = new ControllerDefinition(Global.Emulator.ControllerDefinition); + GlobalWinF.ActiveController.ForceType(new ControllerDefinition(Global.Emulator.ControllerDefinition)); + GlobalWinF.ClickyVirtualPadController.Type = new ControllerDefinition(Global.Emulator.ControllerDefinition); RewireInputChain(); } void RewireInputChain() { - Global.ControllerInputCoalescer = new ControllerInputCoalescer { Type = Global.ActiveController.Type }; + GlobalWinF.ControllerInputCoalescer = new ControllerInputCoalescer { Type = GlobalWinF.ActiveController.Type }; - Global.OrControllerAdapter.Source = Global.ActiveController; - Global.OrControllerAdapter.SourceOr = Global.AutoFireController; - Global.UD_LR_ControllerAdapter.Source = Global.OrControllerAdapter; + GlobalWinF.OrControllerAdapter.Source = GlobalWinF.ActiveController; + GlobalWinF.OrControllerAdapter.SourceOr = GlobalWinF.AutoFireController; + GlobalWinF.UD_LR_ControllerAdapter.Source = GlobalWinF.OrControllerAdapter; - Global.StickyXORAdapter.Source = Global.UD_LR_ControllerAdapter; - Global.AutofireStickyXORAdapter.Source = Global.StickyXORAdapter; + GlobalWinF.StickyXORAdapter.Source = GlobalWinF.UD_LR_ControllerAdapter; + GlobalWinF.AutofireStickyXORAdapter.Source = GlobalWinF.StickyXORAdapter; - Global.MultitrackRewiringControllerAdapter.Source = Global.AutofireStickyXORAdapter; - Global.ForceOffAdaptor.Source = Global.MultitrackRewiringControllerAdapter; + Global.MultitrackRewiringControllerAdapter.Source = GlobalWinF.AutofireStickyXORAdapter; + GlobalWinF.ForceOffAdaptor.Source = Global.MultitrackRewiringControllerAdapter; - Global.MovieInputSourceAdapter.Source = Global.ForceOffAdaptor; - Global.ControllerOutput.Source = Global.MovieOutputHardpoint; + GlobalWinF.MovieInputSourceAdapter.Source = GlobalWinF.ForceOffAdaptor; + GlobalWinF.ControllerOutput.Source = GlobalWinF.MovieOutputHardpoint; - Global.Emulator.Controller = Global.ControllerOutput; - Global.MovieSession.MovieControllerAdapter.Type = Global.MovieInputSourceAdapter.Type; + Global.Emulator.Controller = GlobalWinF.ControllerOutput; + Global.MovieSession.MovieControllerAdapter.Type = GlobalWinF.MovieInputSourceAdapter.Type; //connect the movie session before MovieOutputHardpoint if it is doing anything //otherwise connect the MovieInputSourceAdapter to it, effectively bypassing the movie session if (Global.MovieSession.Movie != null) - Global.MovieOutputHardpoint.Source = Global.MovieSession.MovieControllerAdapter; + GlobalWinF.MovieOutputHardpoint.Source = Global.MovieSession.MovieControllerAdapter; else - Global.MovieOutputHardpoint.Source = Global.MovieInputSourceAdapter; + GlobalWinF.MovieOutputHardpoint.Source = GlobalWinF.MovieInputSourceAdapter; } public bool LoadRom(string path, bool deterministicemulation = false, bool hasmovie = false) @@ -1538,7 +1560,7 @@ namespace BizHawk.MultiClient CloseGame(); Global.Emulator.Dispose(); Global.Emulator = nextEmulator; - Global.CoreComm = nextComm; + GlobalWinF.CoreComm = nextComm; Global.Game = game; SyncCoreCommInputSignals(); SyncControls(); @@ -1617,7 +1639,7 @@ namespace BizHawk.MultiClient if (Global.CheatList.AttemptToLoadCheatFile()) { ToolHelpers.UpdateCheatRelatedTools(); - Global.OSD.AddMessage("Cheats file loaded"); + GlobalWinF.OSD.AddMessage("Cheats file loaded"); } } @@ -1631,9 +1653,9 @@ namespace BizHawk.MultiClient CaptureRewindState(); - Global.StickyXORAdapter.ClearStickies(); - Global.StickyXORAdapter.ClearStickyFloats(); - Global.AutofireStickyXORAdapter.ClearStickies(); + GlobalWinF.StickyXORAdapter.ClearStickies(); + GlobalWinF.StickyXORAdapter.ClearStickyFloats(); + GlobalWinF.AutofireStickyXORAdapter.ClearStickies(); RewireSound(); @@ -1647,13 +1669,13 @@ namespace BizHawk.MultiClient { // we're video dumping, so async mode only and use the DumpProxy. // note that the avi dumper has already rewired the emulator itself in this case. - Global.Sound.SetAsyncInputPin(DumpProxy); + GlobalWinF.Sound.SetAsyncInputPin(DumpProxy); } else if (Global.Config.SoundThrottle) { // for sound throttle, use sync mode Global.Emulator.EndAsyncSound(); - Global.Sound.SetSyncInputPin(Global.Emulator.SyncSoundProvider); + GlobalWinF.Sound.SetSyncInputPin(Global.Emulator.SyncSoundProvider); } else { @@ -1661,11 +1683,11 @@ namespace BizHawk.MultiClient if (!Global.Emulator.StartAsyncSound()) { // if the core doesn't support async mode, use a standard vecna wrapper - Global.Sound.SetAsyncInputPin(new Emulation.Sound.MetaspuAsync(Global.Emulator.SyncSoundProvider, Emulation.Sound.ESynchMethod.ESynchMethod_V)); + GlobalWinF.Sound.SetAsyncInputPin(new Emulation.Sound.MetaspuAsync(Global.Emulator.SyncSoundProvider, Emulation.Sound.ESynchMethod.ESynchMethod_V)); } else { - Global.Sound.SetAsyncInputPin(Global.Emulator.SoundProvider); + GlobalWinF.Sound.SetAsyncInputPin(Global.Emulator.SoundProvider); } } } @@ -1824,7 +1846,7 @@ namespace BizHawk.MultiClient //TODO - wonder what happens if we pop up something interactive as a response to one of these hotkeys? may need to purge further processing //look for hotkey bindings for this key - var triggers = Global.ClientControls.SearchBindings(ie.LogicalButton.ToString()); + var triggers = GlobalWinF.ClientControls.SearchBindings(ie.LogicalButton.ToString()); if (triggers.Count == 0) { //bool sys_hotkey = false; @@ -1871,7 +1893,7 @@ namespace BizHawk.MultiClient { default: case 0: //Both allowed - Global.ControllerInputCoalescer.Receive(ie); + GlobalWinF.ControllerInputCoalescer.Receive(ie); handled = false; if (ie.EventType == Input.InputEventType.Press) @@ -1882,12 +1904,12 @@ namespace BizHawk.MultiClient //hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - Global.HotkeyCoalescer.Receive(ie); + GlobalWinF.HotkeyCoalescer.Receive(ie); } break; case 1: //Input overrides Hokeys - Global.ControllerInputCoalescer.Receive(ie); - bool inputisbound = Global.ActiveController.HasBinding(ie.LogicalButton.ToString()); + GlobalWinF.ControllerInputCoalescer.Receive(ie); + bool inputisbound = GlobalWinF.ActiveController.HasBinding(ie.LogicalButton.ToString()); if (!inputisbound) { handled = false; @@ -1899,7 +1921,7 @@ namespace BizHawk.MultiClient //hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - Global.HotkeyCoalescer.Receive(ie); + GlobalWinF.HotkeyCoalescer.Receive(ie); } } break; @@ -1913,8 +1935,8 @@ namespace BizHawk.MultiClient //hotkeys which arent handled as actions get coalesced as pollable virtual client buttons if (!handled) { - Global.HotkeyCoalescer.Receive(ie); - Global.ControllerInputCoalescer.Receive(ie); + GlobalWinF.HotkeyCoalescer.Receive(ie); + GlobalWinF.ControllerInputCoalescer.Receive(ie); } break; } @@ -1922,15 +1944,15 @@ namespace BizHawk.MultiClient } //foreach event // also handle floats - Global.ControllerInputCoalescer.AcceptNewFloats(Input.Instance.GetFloats()); + GlobalWinF.ControllerInputCoalescer.AcceptNewFloats(Input.Instance.GetFloats()); } private void ClearAutohold() { - Global.StickyXORAdapter.ClearStickies(); - Global.AutofireStickyXORAdapter.ClearStickies(); + GlobalWinF.StickyXORAdapter.ClearStickies(); + GlobalWinF.AutofireStickyXORAdapter.ClearStickies(); VirtualPadForm1.ClearVirtualPadHolds(); - Global.OSD.AddMessage("Autohold keys cleared"); + GlobalWinF.OSD.AddMessage("Autohold keys cleared"); } bool CheckHotkey(string trigger) @@ -1943,7 +1965,7 @@ namespace BizHawk.MultiClient case "Pause": TogglePause(); break; case "Toggle Throttle": unthrottled ^= true; - Global.OSD.AddMessage("Unthrottled: " + unthrottled); + GlobalWinF.OSD.AddMessage("Unthrottled: " + unthrottled); break; case "Soft Reset": SoftReset(); break; case "Hard Reset": HardReset(); break; @@ -2029,19 +2051,19 @@ namespace BizHawk.MultiClient if (Global.Config.VBAStyleMovieLoadState) { - Global.OSD.AddMessage("Multi-track can not be used in Full Movie Loadstates mode"); + GlobalWinF.OSD.AddMessage("Multi-track can not be used in Full Movie Loadstates mode"); } else { Global.MovieSession.MultiTrack.IsActive = !Global.MovieSession.MultiTrack.IsActive; if (Global.MovieSession.MultiTrack.IsActive) { - Global.OSD.AddMessage("MultiTrack Enabled"); - Global.OSD.MT = "Recording None"; + GlobalWinF.OSD.AddMessage("MultiTrack Enabled"); + GlobalWinF.OSD.MT = "Recording None"; } else { - Global.OSD.AddMessage("MultiTrack Disabled"); + GlobalWinF.OSD.AddMessage("MultiTrack Disabled"); } Global.MovieSession.MultiTrack.RecordAll = false; Global.MovieSession.MultiTrack.CurrentPlayer = 0; @@ -2049,21 +2071,21 @@ namespace BizHawk.MultiClient } else { - Global.OSD.AddMessage("MultiTrack cannot be enabled while not recording."); + GlobalWinF.OSD.AddMessage("MultiTrack cannot be enabled while not recording."); } - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; break; case "MT Select All": Global.MovieSession.MultiTrack.CurrentPlayer = 0; Global.MovieSession.MultiTrack.RecordAll = true; - Global.OSD.MT = "Recording All"; - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.OSD.MT = "Recording All"; + GlobalWinF.DisplayManager.NeedsToPaint = true; break; case "MT Select None": Global.MovieSession.MultiTrack.CurrentPlayer = 0; Global.MovieSession.MultiTrack.RecordAll = false; - Global.OSD.MT = "Recording None"; - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.OSD.MT = "Recording None"; + GlobalWinF.DisplayManager.NeedsToPaint = true; break; case "MT Increment Player": Global.MovieSession.MultiTrack.CurrentPlayer++; @@ -2072,8 +2094,8 @@ namespace BizHawk.MultiClient { Global.MovieSession.MultiTrack.CurrentPlayer = 1; } - Global.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString(); - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString(); + GlobalWinF.DisplayManager.NeedsToPaint = true; break; case "MT Decrement Player": Global.MovieSession.MultiTrack.CurrentPlayer--; @@ -2082,8 +2104,8 @@ namespace BizHawk.MultiClient { Global.MovieSession.MultiTrack.CurrentPlayer = 5;//TODO: Replace with console's maximum or current maximum players??! } - Global.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString(); - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.OSD.MT = "Recording Player " + Global.MovieSession.MultiTrack.CurrentPlayer.ToString(); + GlobalWinF.DisplayManager.NeedsToPaint = true; break; case "Movie Poke": ToggleModePokeMode(); break; @@ -2152,7 +2174,7 @@ namespace BizHawk.MultiClient runFrame = true; } - if (Global.ClientControls["Frame Advance"] || PressFrameAdvance) + if (GlobalWinF.ClientControls["Frame Advance"] || PressFrameAdvance) { //handle the initial trigger of a frame advance if (FrameAdvanceTimestamp == DateTime.MinValue) @@ -2190,7 +2212,7 @@ namespace BizHawk.MultiClient } bool ReturnToRecording = Global.MovieSession.Movie.IsRecording; - if (RewindActive && (Global.ClientControls["Rewind"] || PressRewind)) + if (RewindActive && (GlobalWinF.ClientControls["Rewind"] || PressRewind)) { Rewind(1); suppressCaptureRewind = true; @@ -2221,8 +2243,8 @@ namespace BizHawk.MultiClient bool coreskipaudio = false; if (runFrame) { - bool ff = Global.ClientControls["Fast Forward"] || Global.ClientControls["Turbo"]; - bool fff = Global.ClientControls["Turbo"]; + bool ff = GlobalWinF.ClientControls["Fast Forward"] || GlobalWinF.ClientControls["Turbo"]; + bool fff = GlobalWinF.ClientControls["Turbo"]; bool updateFpsString = (runloop_last_ff != ff); runloop_last_ff = ff; @@ -2231,11 +2253,11 @@ namespace BizHawk.MultiClient UpdateToolsBefore(); } - Global.ClickyVirtualPadController.FrameTick(); + GlobalWinF.ClickyVirtualPadController.FrameTick(); runloop_fps++; //client input-related duties - Global.OSD.ClearGUIText(); + GlobalWinF.OSD.ClearGUIText(); if ((DateTime.Now - runloop_second).TotalSeconds > 1) { @@ -2256,7 +2278,7 @@ namespace BizHawk.MultiClient { fps_string += " >>"; } - Global.OSD.FPS = fps_string; + GlobalWinF.OSD.FPS = fps_string; } if (!suppressCaptureRewind && RewindActive) CaptureRewindState(); @@ -2267,11 +2289,11 @@ namespace BizHawk.MultiClient HandleMovieOnFrameLoop(); - coreskipaudio = Global.ClientControls["Turbo"] && CurrAviWriter == null; + coreskipaudio = GlobalWinF.ClientControls["Turbo"] && CurrAviWriter == null; //======================================= Global.CheatList.Pulse(); Global.Emulator.FrameAdvance(!throttle.skipnextframe || CurrAviWriter != null, !coreskipaudio); - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; Global.CheatList.Pulse(); //======================================= @@ -2282,7 +2304,7 @@ namespace BizHawk.MultiClient if (Global.Emulator.IsLagFrame && Global.Config.AutofireLagFrames) { - Global.AutoFireController.IncrementStarts(); + GlobalWinF.AutoFireController.IncrementStarts(); } PressFrameAdvance = false; @@ -2292,7 +2314,7 @@ namespace BizHawk.MultiClient } } - if (Global.ClientControls["Rewind"] || PressRewind) + if (GlobalWinF.ClientControls["Rewind"] || PressRewind) { UpdateToolsAfter(); if (ReturnToRecording) @@ -2312,10 +2334,10 @@ namespace BizHawk.MultiClient if (genSound && !coreskipaudio) { - Global.Sound.UpdateSound(); + GlobalWinF.Sound.UpdateSound(); } else - Global.Sound.UpdateSilence(); + GlobalWinF.Sound.UpdateSilence(); } /// @@ -2371,7 +2393,7 @@ namespace BizHawk.MultiClient LuaConsole1.LuaImp.FrameRegisterAfter(); if (!fromLua) { - Global.DisplayManager.PreFrameUpdateLuaSource(); + GlobalWinF.DisplayManager.PreFrameUpdateLuaSource(); LuaConsole1.EndLuaDrawing(); } } @@ -2416,7 +2438,7 @@ namespace BizHawk.MultiClient { Clipboard.SetImage(img); } - Global.OSD.AddMessage("Screenshot saved to clipboard."); + GlobalWinF.OSD.AddMessage("Screenshot saved to clipboard."); } public void TakeScreenshot() @@ -2441,7 +2463,7 @@ namespace BizHawk.MultiClient { img.Save(fi.FullName, ImageFormat.Png); } - Global.OSD.AddMessage(fi.Name + " saved."); + GlobalWinF.OSD.AddMessage(fi.Name + " saved."); } public void SaveState(string name) @@ -2529,7 +2551,7 @@ namespace BizHawk.MultiClient //DateTime end = DateTime.UtcNow; //Console.WriteLine("n64 savestate TEXT time: {0}", (end - start).TotalMilliseconds); } - Global.OSD.AddMessage("Saved state: " + name); + GlobalWinF.OSD.AddMessage("Saved state: " + name); if (!fromLua) UpdateStatusSlots(); @@ -2546,9 +2568,9 @@ namespace BizHawk.MultiClient if (file.Directory != null && file.Directory.Exists == false) file.Directory.Create(); - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; @@ -2558,7 +2580,7 @@ namespace BizHawk.MultiClient public void LoadStateFile(string path, string name, bool fromLua = false) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; // try to detect binary first BinaryStateLoader bw = BinaryStateLoader.LoadAndDetect(path); if (bw != null) @@ -2639,15 +2661,15 @@ namespace BizHawk.MultiClient } } else - Global.OSD.AddMessage("Loadstate error!"); + GlobalWinF.OSD.AddMessage("Loadstate error!"); } cleanup: - Global.OSD.ClearGUIText(); + GlobalWinF.OSD.ClearGUIText(); UpdateToolsBefore(fromLua); UpdateToolsAfter(fromLua); UpdateToolsLoadstate(); - Global.OSD.AddMessage("Loaded state: " + name); + GlobalWinF.OSD.AddMessage("Loaded state: " + name); LuaConsole1.LuaImp.SavestateRegisterLoad(name); } @@ -2661,7 +2683,7 @@ namespace BizHawk.MultiClient string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State"; if (File.Exists(path) == false) { - Global.OSD.AddMessage("Unable to load " + name + ".State"); + GlobalWinF.OSD.AddMessage("Unable to load " + name + ".State"); return; } @@ -2678,9 +2700,9 @@ namespace BizHawk.MultiClient RestoreDirectory = true }; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = ofd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; @@ -2693,7 +2715,7 @@ namespace BizHawk.MultiClient private void SaveSlotSelectedMessage() { - Global.OSD.AddMessage("Slot " + Global.Config.SaveSlot + " selected."); + GlobalWinF.OSD.AddMessage("Slot " + Global.Config.SaveSlot + " selected."); } public void LoadRamSearch() @@ -3087,7 +3109,7 @@ namespace BizHawk.MultiClient FrameBufferResized(); } - Global.DisplayManager.UpdateSource(Global.Emulator.VideoProvider); + GlobalWinF.DisplayManager.UpdateSource(Global.Emulator.VideoProvider); } public void FrameBufferResized() @@ -3112,7 +3134,7 @@ namespace BizHawk.MultiClient // Change size Size = new Size((video.BufferWidth * zoom) + borderWidth, (video.BufferHeight * zoom + borderHeight)); PerformLayout(); - Global.RenderPanel.Resized = true; + GlobalWinF.RenderPanel.Resized = true; // Is window off the screen at this size? if (area.Contains(Bounds) == false) @@ -3139,7 +3161,7 @@ namespace BizHawk.MultiClient MainMenuStrip.Visible = false; StatusSlot0.Visible = false; PerformLayout(); - Global.RenderPanel.Resized = true; + GlobalWinF.RenderPanel.Resized = true; InFullscreen = true; } else @@ -3260,9 +3282,9 @@ namespace BizHawk.MultiClient ofd.RestoreDirectory = false; ofd.FilterIndex = LastOpenRomFilter; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = ofd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; var file = new FileInfo(ofd.FileName); @@ -3288,7 +3310,7 @@ namespace BizHawk.MultiClient if (File.Exists(path)) { File.Delete(path); - Global.OSD.AddMessage("SRAM cleared."); + GlobalWinF.OSD.AddMessage("SRAM cleared."); } } else if (Global.Emulator.SaveRamModified) @@ -3298,11 +3320,11 @@ namespace BizHawk.MultiClient StopAVI(); Global.Emulator.Dispose(); - Global.CoreComm = new CoreComm(); + GlobalWinF.CoreComm = new CoreComm(); SyncCoreCommInputSignals(); - Global.Emulator = new NullEmulator(Global.CoreComm); - Global.ActiveController = Global.NullControls; - Global.AutoFireController = Global.AutofireNullControls; + Global.Emulator = new NullEmulator(GlobalWinF.CoreComm); + GlobalWinF.ActiveController = GlobalWinF.NullControls; + GlobalWinF.AutoFireController = GlobalWinF.AutofireNullControls; Global.MovieSession.Movie.Stop(); NeedsReboot = false; SetRebootIconStatus(); @@ -3311,9 +3333,9 @@ namespace BizHawk.MultiClient public void CloseROM(bool clearSRAM = false) { CloseGame(clearSRAM); - Global.CoreComm = new CoreComm(); + GlobalWinF.CoreComm = new CoreComm(); SyncCoreCommInputSignals(); - Global.Emulator = new NullEmulator(Global.CoreComm); + Global.Emulator = new NullEmulator(GlobalWinF.CoreComm); Global.Game = GameInfo.GetNullGame(); RewireSound(); @@ -3433,16 +3455,16 @@ namespace BizHawk.MultiClient ReadOnly ^= true; if (ReadOnly) { - Global.OSD.AddMessage("Movie read-only mode"); + GlobalWinF.OSD.AddMessage("Movie read-only mode"); } else { - Global.OSD.AddMessage("Movie read+write mode"); + GlobalWinF.OSD.AddMessage("Movie read+write mode"); } } else { - Global.OSD.AddMessage("No movie active"); + GlobalWinF.OSD.AddMessage("No movie active"); } } @@ -3452,11 +3474,11 @@ namespace BizHawk.MultiClient ReadOnly = read_only; if (ReadOnly) { - Global.OSD.AddMessage("Movie read-only mode"); + GlobalWinF.OSD.AddMessage("Movie read-only mode"); } else { - Global.OSD.AddMessage("Movie read+write mode"); + GlobalWinF.OSD.AddMessage("Movie read+write mode"); } } @@ -3487,8 +3509,8 @@ namespace BizHawk.MultiClient Global.Config.SoundVolume += 10; if (Global.Config.SoundVolume > 100) Global.Config.SoundVolume = 100; - Global.Sound.ChangeVolume(Global.Config.SoundVolume); - Global.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString()); + GlobalWinF.Sound.ChangeVolume(Global.Config.SoundVolume); + GlobalWinF.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString()); } private void VolumeDown() @@ -3496,8 +3518,8 @@ namespace BizHawk.MultiClient Global.Config.SoundVolume -= 10; if (Global.Config.SoundVolume < 0) Global.Config.SoundVolume = 0; - Global.Sound.ChangeVolume(Global.Config.SoundVolume); - Global.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString()); + GlobalWinF.Sound.ChangeVolume(Global.Config.SoundVolume); + GlobalWinF.OSD.AddMessage("Volume " + Global.Config.SoundVolume.ToString()); } private void SoftReset() @@ -3507,8 +3529,8 @@ namespace BizHawk.MultiClient { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { - Global.ClickyVirtualPadController.Click("Reset"); - Global.OSD.AddMessage("Reset button pressed."); + GlobalWinF.ClickyVirtualPadController.Click("Reset"); + GlobalWinF.OSD.AddMessage("Reset button pressed."); } } } @@ -3520,8 +3542,8 @@ namespace BizHawk.MultiClient { if (!Global.MovieSession.Movie.IsPlaying || Global.MovieSession.Movie.IsFinished) { - Global.ClickyVirtualPadController.Click("Power"); - Global.OSD.AddMessage("Power button pressed."); + GlobalWinF.ClickyVirtualPadController.Click("Power"); + GlobalWinF.OSD.AddMessage("Power button pressed."); } } } @@ -3700,7 +3722,7 @@ namespace BizHawk.MultiClient } else { - aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(video_writers, Global.MainForm, out avwriter_resizew, out avwriter_resizeh); + aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(video_writers, GlobalWinF.MainForm, out avwriter_resizew, out avwriter_resizeh); } foreach (var w in video_writers) @@ -3712,9 +3734,9 @@ namespace BizHawk.MultiClient if (aw == null) { if (unattended) - Global.OSD.AddMessage(string.Format("Couldn't start video writer \"{0}\"", videowritername)); + GlobalWinF.OSD.AddMessage(string.Format("Couldn't start video writer \"{0}\"", videowritername)); else - Global.OSD.AddMessage("A/V capture canceled."); + GlobalWinF.OSD.AddMessage("A/V capture canceled."); return; } @@ -3735,10 +3757,10 @@ namespace BizHawk.MultiClient } else { - var token = aw.AcquireVideoCodecToken(Global.MainForm); + var token = aw.AcquireVideoCodecToken(GlobalWinF.MainForm); if (token == null) { - Global.OSD.AddMessage("A/V capture canceled."); + GlobalWinF.OSD.AddMessage("A/V capture canceled."); aw.Dispose(); return; } @@ -3765,9 +3787,9 @@ namespace BizHawk.MultiClient } sfd.Filter = String.Format("{0} (*.{0})|*.{0}|All Files|*.*", aw.DesiredExtension()); - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result == DialogResult.Cancel) { @@ -3779,7 +3801,7 @@ namespace BizHawk.MultiClient //commit the avi writing last, in case there were any errors earlier CurrAviWriter = aw; - Global.OSD.AddMessage("A/V capture started"); + GlobalWinF.OSD.AddMessage("A/V capture started"); AVIStatusLabel.Image = Properties.Resources.AVI; AVIStatusLabel.ToolTipText = "A/V capture in progress"; AVIStatusLabel.Visible = true; @@ -3787,7 +3809,7 @@ namespace BizHawk.MultiClient } catch { - Global.OSD.AddMessage("A/V capture failed!"); + GlobalWinF.OSD.AddMessage("A/V capture failed!"); aw.Dispose(); throw; } @@ -3812,7 +3834,7 @@ namespace BizHawk.MultiClient } CurrAviWriter.Dispose(); CurrAviWriter = null; - Global.OSD.AddMessage("A/V capture aborted"); + GlobalWinF.OSD.AddMessage("A/V capture aborted"); AVIStatusLabel.Image = Properties.Resources.Blank; AVIStatusLabel.ToolTipText = ""; AVIStatusLabel.Visible = false; @@ -3833,7 +3855,7 @@ namespace BizHawk.MultiClient CurrAviWriter.CloseFile(); CurrAviWriter.Dispose(); CurrAviWriter = null; - Global.OSD.AddMessage("A/V capture stopped"); + GlobalWinF.OSD.AddMessage("A/V capture stopped"); AVIStatusLabel.Image = Properties.Resources.Blank; AVIStatusLabel.ToolTipText = ""; AVIStatusLabel.Visible = false; @@ -3960,13 +3982,13 @@ namespace BizHawk.MultiClient string d = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null); string errorMsg; string warningMsg; - Movie m = MovieImport.ImportFile(fn, out errorMsg, out warningMsg); + Movie m = MovieImport.ImportFile(fn, GlobalWinF.MainForm.GetEmuVersion(), out errorMsg, out warningMsg); if (errorMsg.Length > 0) MessageBox.Show(errorMsg, "Conversion error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (warningMsg.Length > 0) - Global.OSD.AddMessage(warningMsg); + GlobalWinF.OSD.AddMessage(warningMsg); else - Global.OSD.AddMessage(Path.GetFileName(fn) + " imported as " + "Movies\\" + + GlobalWinF.OSD.AddMessage(Path.GetFileName(fn) + " imported as " + "Movies\\" + Path.GetFileName(fn) + "." + Global.Config.MovieExtension); if (!Directory.Exists(d)) Directory.CreateDirectory(d); @@ -4000,7 +4022,7 @@ namespace BizHawk.MultiClient captureosd_rvp.Height = Global.Emulator.VideoProvider.BufferHeight; - Global.DisplayManager.UpdateSourceEx(Global.Emulator.VideoProvider, captureosd_srp); + GlobalWinF.DisplayManager.UpdateSourceEx(Global.Emulator.VideoProvider, captureosd_srp); Bitmap ret = (Bitmap)captureosd_rvp.GetBitmap().Clone(); @@ -4175,7 +4197,7 @@ namespace BizHawk.MultiClient { NeedsReboot = true; SetRebootIconStatus(); - Global.OSD.AddMessage("Core reboot needed for this setting"); + GlobalWinF.OSD.AddMessage("Core reboot needed for this setting"); } private void SaveMovie() @@ -4183,7 +4205,7 @@ namespace BizHawk.MultiClient if (Global.MovieSession.Movie.IsActive) { Global.MovieSession.Movie.WriteMovie(); - Global.OSD.AddMessage(Global.MovieSession.Movie.Filename + " saved."); + GlobalWinF.OSD.AddMessage(Global.MovieSession.Movie.Filename + " saved."); } } @@ -4241,11 +4263,11 @@ namespace BizHawk.MultiClient Global.Config.MoviePlaybackPokeMode ^= true; if (Global.Config.MoviePlaybackPokeMode) { - Global.OSD.AddMessage("Movie Poke mode enabled"); + GlobalWinF.OSD.AddMessage("Movie Poke mode enabled"); } else { - Global.OSD.AddMessage("Movie Poke mode disabled"); + GlobalWinF.OSD.AddMessage("Movie Poke mode disabled"); } } @@ -4273,12 +4295,12 @@ namespace BizHawk.MultiClient private void menuStrip1_Leave(object sender, EventArgs e) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; } private void MainForm_Enter(object sender, EventArgs e) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; } public void LoadRamWatch(bool load_dialog) diff --git a/BizHawk.MultiClient/Program.cs b/BizHawk.MultiClient/Program.cs index 96d2a38ae0..b8bcf452cc 100644 --- a/BizHawk.MultiClient/Program.cs +++ b/BizHawk.MultiClient/Program.cs @@ -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 diff --git a/BizHawk.MultiClient/RecentFiles.cs b/BizHawk.MultiClient/RecentFiles.cs deleted file mode 100644 index f7f016b4f2..0000000000 --- a/BizHawk.MultiClient/RecentFiles.cs +++ /dev/null @@ -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 recentlist; //List of recent files - - public bool AutoLoad = false; - - public RecentFiles() : this(8) { } - public RecentFiles(int max) - { - recentlist = new List(); - MAX_RECENT_FILES = max; - } - - public IEnumerator 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 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; - } - } -} diff --git a/BizHawk.MultiClient/RenderPanel.cs b/BizHawk.MultiClient/RenderPanel.cs index b1c888d534..bdec14fb5c 100644 --- a/BizHawk.MultiClient/RenderPanel.cs +++ b/BizHawk.MultiClient/RenderPanel.cs @@ -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(); diff --git a/BizHawk.MultiClient/RomGame.cs b/BizHawk.MultiClient/RomGame.cs deleted file mode 100644 index f823f8e458..0000000000 --- a/BizHawk.MultiClient/RomGame.cs +++ /dev/null @@ -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. - } - } -} diff --git a/BizHawk.MultiClient/SavestateManager.cs b/BizHawk.MultiClient/SavestateManager.cs index faca48799b..c4ac71c5a6 100644 --- a/BizHawk.MultiClient/SavestateManager.cs +++ b/BizHawk.MultiClient/SavestateManager.cs @@ -1,5 +1,7 @@ using System.IO; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class SavestateManager diff --git a/BizHawk.MultiClient/Sound.cs b/BizHawk.MultiClient/Sound.cs index e1b17d38aa..a481e17934 100644 --- a/BizHawk.MultiClient/Sound.cs +++ b/BizHawk.MultiClient/Sound.cs @@ -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 diff --git a/BizHawk.MultiClient/Throttle.cs b/BizHawk.MultiClient/Throttle.cs index f491688361..20ea680b93 100644 --- a/BizHawk.MultiClient/Throttle.cs +++ b/BizHawk.MultiClient/Throttle.cs @@ -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; } diff --git a/BizHawk.MultiClient/XmlGame.cs b/BizHawk.MultiClient/XmlGame.cs index d274cb9fd8..c429a94aec 100644 --- a/BizHawk.MultiClient/XmlGame.cs +++ b/BizHawk.MultiClient/XmlGame.cs @@ -5,6 +5,8 @@ using System.Text; using System.IO; using System.Xml; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class XmlGame diff --git a/BizHawk.MultiClient/config/AutofireConfig.cs b/BizHawk.MultiClient/config/AutofireConfig.cs index 385d03c4d0..a5a53d4400 100644 --- a/BizHawk.MultiClient/config/AutofireConfig.cs +++ b/BizHawk.MultiClient/config/AutofireConfig.cs @@ -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(); } } diff --git a/BizHawk.MultiClient/config/ControllerConfig.cs b/BizHawk.MultiClient/config/ControllerConfig.cs index 0139b8ce94..fade25cc58 100644 --- a/BizHawk.MultiClient/config/ControllerConfig.cs +++ b/BizHawk.MultiClient/config/ControllerConfig.cs @@ -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 settings, List buttons, Size size) + Control CreateAnalogPanel(Dictionary settings, List 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> normal, Dictionary> autofire, - Dictionary> analog) + Dictionary> 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> AllTrollers = new Dictionary>(); public Dictionary> AllTrollersAutoFire = new Dictionary>(); - public Dictionary> AllTrollersAnalog = new Dictionary>(); + public Dictionary> AllTrollersAnalog = new Dictionary>(); } - 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(); cd.AllTrollersAutoFire[the_definition.Name] = new Dictionary(); - cd.AllTrollersAnalog[the_definition.Name] = new Dictionary(); + cd.AllTrollersAnalog[the_definition.Name] = new Dictionary(); SaveToDefaults(cd); diff --git a/BizHawk.MultiClient/config/ControllerConfig/AnalogBindControl.cs b/BizHawk.MultiClient/config/ControllerConfig/AnalogBindControl.cs index 4395016bac..61d2797747 100644 --- a/BizHawk.MultiClient/config/ControllerConfig/AnalogBindControl.cs +++ b/BizHawk.MultiClient/config/ControllerConfig/AnalogBindControl.cs @@ -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; diff --git a/BizHawk.MultiClient/config/ControllerConfig/AnalogBindPanel.cs b/BizHawk.MultiClient/config/ControllerConfig/AnalogBindPanel.cs index 2be74fbf40..ea9bafc8bc 100644 --- a/BizHawk.MultiClient/config/ControllerConfig/AnalogBindPanel.cs +++ b/BizHawk.MultiClient/config/ControllerConfig/AnalogBindPanel.cs @@ -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 RealConfigObject; + Dictionary RealConfigObject; - public AnalogBindPanel(Dictionary RealConfigObject, List RealConfigButtons = null) + public AnalogBindPanel(Dictionary RealConfigObject, List RealConfigButtons = null) :base() { this.RealConfigObject = RealConfigObject; @@ -38,7 +40,7 @@ namespace BizHawk.MultiClient /// save to config /// /// if non-null, save to possibly different config object than originally initialized from - public void Save(Dictionary SaveConfigObject = null) + public void Save(Dictionary SaveConfigObject = null) { var saveto = SaveConfigObject ?? RealConfigObject; foreach (Control c in Controls) diff --git a/BizHawk.MultiClient/config/FirmwaresConfig.Designer.cs b/BizHawk.MultiClient/config/FirmwaresConfig.Designer.cs index 6613caeea8..46fd2fe017 100644 --- a/BizHawk.MultiClient/config/FirmwaresConfig.Designer.cs +++ b/BizHawk.MultiClient/config/FirmwaresConfig.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/BizHawk.MultiClient/config/FirmwaresConfig.cs b/BizHawk.MultiClient/config/FirmwaresConfig.cs index 69de8be2ca..98757b424f 100644 --- a/BizHawk.MultiClient/config/FirmwaresConfig.cs +++ b/BizHawk.MultiClient/config/FirmwaresConfig.cs @@ -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 } diff --git a/BizHawk.MultiClient/config/FirmwaresConfig.resx b/BizHawk.MultiClient/config/FirmwaresConfig.resx index cb8e4f87cc..55a8eccb82 100644 --- a/BizHawk.MultiClient/config/FirmwaresConfig.resx +++ b/BizHawk.MultiClient/config/FirmwaresConfig.resx @@ -126,6 +126,9 @@ 122, 17 + + 221, 17 + @@ -172,7 +175,4 @@ TgDQASA1MVpwzwAAAABJRU5ErkJggg== - - 221, 17 - \ No newline at end of file diff --git a/BizHawk.MultiClient/config/FirmwaresConfigInfo.Designer.cs b/BizHawk.MultiClient/config/FirmwaresConfigInfo.Designer.cs new file mode 100644 index 0000000000..e65bff5dbe --- /dev/null +++ b/BizHawk.MultiClient/config/FirmwaresConfigInfo.Designer.cs @@ -0,0 +1,201 @@ +namespace BizHawk.MultiClient +{ + partial class FirmwaresConfigInfo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/BizHawk.MultiClient/config/FirmwaresConfigInfo.cs b/BizHawk.MultiClient/config/FirmwaresConfigInfo.cs new file mode 100644 index 0000000000..b0a5abf213 --- /dev/null +++ b/BizHawk.MultiClient/config/FirmwaresConfigInfo.cs @@ -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); + } + } +} diff --git a/BizHawk.MultiClient/config/FirmwaresConfigInfo.resx b/BizHawk.MultiClient/config/FirmwaresConfigInfo.resx new file mode 100644 index 0000000000..1a712589cd --- /dev/null +++ b/BizHawk.MultiClient/config/FirmwaresConfigInfo.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/BizHawk.MultiClient/config/GifAnimator.cs b/BizHawk.MultiClient/config/GifAnimator.cs index 6238107c5d..82a6ba4cfe 100644 --- a/BizHawk.MultiClient/config/GifAnimator.cs +++ b/BizHawk.MultiClient/config/GifAnimator.cs @@ -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 diff --git a/BizHawk.MultiClient/config/HotkeyConfig.cs b/BizHawk.MultiClient/config/HotkeyConfig.cs index 9c6816df2c..7e88f32686 100644 --- a/BizHawk.MultiClient/config/HotkeyConfig.cs +++ b/BizHawk.MultiClient/config/HotkeyConfig.cs @@ -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 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) diff --git a/BizHawk.MultiClient/config/MessageConfig.cs b/BizHawk.MultiClient/config/MessageConfig.cs index 0590e1e7f0..9fe98f2d81 100644 --- a/BizHawk.MultiClient/config/MessageConfig.cs +++ b/BizHawk.MultiClient/config/MessageConfig.cs @@ -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(); } diff --git a/BizHawk.MultiClient/config/PathConfig.cs b/BizHawk.MultiClient/config/PathConfig.cs index bbd55dc642..d5b0bb0806 100644 --- a/BizHawk.MultiClient/config/PathConfig.cs +++ b/BizHawk.MultiClient/config/PathConfig.cs @@ -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(); } diff --git a/BizHawk.MultiClient/config/PathManager.cs b/BizHawk.MultiClient/config/PathManager.cs index 2650adea30..16c47670bf 100644 --- a/BizHawk.MultiClient/config/PathManager.cs +++ b/BizHawk.MultiClient/config/PathManager.cs @@ -3,6 +3,8 @@ using System.Linq; using System.IO; using System.Reflection; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public static class PathManager diff --git a/BizHawk.MultiClient/config/RewindConfig.cs b/BizHawk.MultiClient/config/RewindConfig.cs index e208676578..ed4f1dd474 100644 --- a/BizHawk.MultiClient/config/RewindConfig.cs +++ b/BizHawk.MultiClient/config/RewindConfig.cs @@ -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 { diff --git a/BizHawk.MultiClient/config/SoundConfig.cs b/BizHawk.MultiClient/config/SoundConfig.cs index c99e1af3df..6ebb714f08 100644 --- a/BizHawk.MultiClient/config/SoundConfig.cs +++ b/BizHawk.MultiClient/config/SoundConfig.cs @@ -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 ?? ""; - 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(); } diff --git a/BizHawk.MultiClient/movie/EditCommentsForm.cs b/BizHawk.MultiClient/movie/EditCommentsForm.cs index b071f5e57e..d5b563a911 100644 --- a/BizHawk.MultiClient/movie/EditCommentsForm.cs +++ b/BizHawk.MultiClient/movie/EditCommentsForm.cs @@ -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() { diff --git a/BizHawk.MultiClient/movie/EditSubtitlesForm.cs b/BizHawk.MultiClient/movie/EditSubtitlesForm.cs index c1648748b9..30d229a7af 100644 --- a/BizHawk.MultiClient/movie/EditSubtitlesForm.cs +++ b/BizHawk.MultiClient/movie/EditSubtitlesForm.cs @@ -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; diff --git a/BizHawk.MultiClient/movie/InputAdapters.cs b/BizHawk.MultiClient/movie/InputAdapters.cs deleted file mode 100644 index 20fe124929..0000000000 --- a/BizHawk.MultiClient/movie/InputAdapters.cs +++ /dev/null @@ -1,541 +0,0 @@ -using System; -using System.Text; -using System.Collections.Generic; - -namespace BizHawk.MultiClient -{ - /// - /// 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? - /// - 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); - } - /// - /// call this once per frame to do the timekeeping for the hold and release - /// - public void FrameTick() - { - Pressed.Clear(); - } - - /// - /// call this to hold the button down for one frame - /// - 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 Pressed = new HashSet(); - } - - //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 Buttons = new WorkingDictionary(); - protected WorkingDictionary Floats = new WorkingDictionary(); - 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> 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> 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 stickySet = new HashSet(); - 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 stickySet = new HashSet(); - 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 FloatSet = new WorkingDictionary(); - 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 CurrentStickies - { - get - { - return stickySet; - } - } - - public void ClearStickies() - { - stickySet.Clear(); - } - - public void MassToggleStickyState(List 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 JustPressed = new List(); - } - - public class AutoFireStickyXORAdapter : IController - { - public int On { get; set; } - public int Off { get; set; } - public WorkingDictionary buttonStarts = new WorkingDictionary(); - - private readonly HashSet stickySet = new HashSet(); - - 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 CurrentStickies - { - get - { - return stickySet; - } - } - - public void ClearStickies() - { - stickySet.Clear(); - } - - public void MassToggleStickyState(List 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 JustPressed = new List(); - } - - /// - /// just copies source to sink, or returns whatever a NullController would if it is disconnected. useful for immovable hardpoints. - /// - 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); - } - } - - /// - /// rewires player1 controls to playerN - /// - 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.. - - ///// - ///// adapts an IController to force some buttons to a different state. - ///// unforced button states will flow through to the adaptee - ///// - //public class ForceControllerAdapter : IController - //{ - // public IController Controller; - - // public Dictionary Forces = new Dictionary(); - // 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); - // } - //} -} \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/Movie.cs b/BizHawk.MultiClient/movie/Movie.cs deleted file mode 100644 index f7f224c035..0000000000 --- a/BizHawk.MultiClient/movie/Movie.cs +++ /dev/null @@ -1,1286 +0,0 @@ -using System; -using System.IO; -using System.Windows.Forms; -using System.Globalization; - -namespace BizHawk.MultiClient -{ - public class Movie - { - #region Constructors - - public Movie(string filename) - { - Mode = MOVIEMODE.INACTIVE; - Rerecords = 0; - Filename = filename; - IsText = true; - preload_framecount = 0; - IsCountingRerecords = true; - StartsFromSavestate = false; - if (filename.Length > 0) - Loaded = true; - } - - public Movie() - { - Filename = ""; - Mode = MOVIEMODE.INACTIVE; - IsText = true; - preload_framecount = 0; - StartsFromSavestate = false; - Loaded = false; - IsCountingRerecords = true; - } - - #endregion - - #region Properties - public MovieHeader Header = new MovieHeader(); - public SubtitleList Subtitles = new SubtitleList(); - - public bool MakeBackup = true; //make backup before altering movie - public string Filename; - public bool IsCountingRerecords; - - public bool Loaded { get; private set; } - public bool IsText { get; private set; } - public int LoopOffset = -1; - public bool Loop - { - get - { - if (LoopOffset >= 0) - { - return true; - } - else - { - return false; - } - } - } - - public int Rerecords - { - get { return rerecords; } - set - { - rerecords = value; - Header.SetHeaderLine(MovieHeader.RERECORDS, Rerecords.ToString()); - } - } - - public string SysID - { - get { return Header.GetHeaderLine(MovieHeader.PLATFORM); } - } - - public string GUID - { - get { return Header.GetHeaderLine(MovieHeader.GUID); } - } - - public string GameName - { - get { return Header.GetHeaderLine(MovieHeader.GAMENAME); } - } - - public int RawFrames - { - get - { - if (Loaded) - { - return Log.Length; - } - else - { - return preload_framecount; - } - } - } - - public int? Frames - { - get - { - if (Loaded) - { - if (Loop) - { - return null; - } - else - { - return Log.Length; - } - } - else - { - return preload_framecount; - } - } - } - - public bool StartsFromSavestate - { - get { return startsfromsavestate; } - set - { - startsfromsavestate = value; - if (value) - { - Header.AddHeaderLine(MovieHeader.STARTSFROMSAVESTATE, "1"); - } - else - { - Header.RemoveHeaderLine(MovieHeader.STARTSFROMSAVESTATE); - } - } - } - - public int StateFirstIndex - { - get { return Log.StateFirstIndex; } - } - - public int StateLastIndex - { - get { return Log.StateLastIndex; } - } - - public bool StateCapturing - { - get { return statecapturing; } - set - { - statecapturing = value; - if (value == false) - { - Log.ClearStates(); - } - - } - } - - #endregion - - #region Public Mode Methods - - public bool IsPlaying - { - get - { - if (Mode == MOVIEMODE.PLAY || Mode == MOVIEMODE.FINISHED) - { - return true; - } - else - { - return false; - } - } - } - - public bool IsRecording - { - get - { - if (Mode == MOVIEMODE.RECORD) - { - return true; - } - else - { - return false; - } - } - } - - public bool IsActive - { - get - { - if (Mode == MOVIEMODE.INACTIVE) - { - return false; - } - else - { - return true; - } - } - } - - public bool IsFinished - { - get - { - if (Mode == MOVIEMODE.FINISHED) - { - return true; - } - else - { - return false; - } - } - } - - public bool HasChanges - { - get { return changes; } - } - - /// - /// Tells the movie to start recording from the beginning, this will clear sram, and the movie log - /// - /// - public void StartRecording(bool truncate = true) - { - Global.MainForm.ClearSaveRAM(); - Mode = MOVIEMODE.RECORD; - if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length > 0) - { - WriteBackup(); - MakeBackup = false; - } - if (truncate) - { - Log.Clear(); - } - } - - public void StartPlayback() - { - Global.MainForm.ClearSaveRAM(); - Mode = MOVIEMODE.PLAY; - } - - /// - /// Tells the movie to recording mode - /// - public void SwitchToRecord() - { - Mode = MOVIEMODE.RECORD; - } - - /// - /// Tells the movie to go into playback mode - /// - public void SwitchToPlay() - { - Mode = MOVIEMODE.PLAY; - WriteMovie(); - } - - public void Stop(bool abortchanges = false) - { - if (!abortchanges) - { - if (Mode == MOVIEMODE.RECORD || changes) - { - WriteMovie(); - } - } - changes = false; - Mode = MOVIEMODE.INACTIVE; - } - - public void Finish() - { - if (Mode == MOVIEMODE.PLAY) - { - Mode = MOVIEMODE.FINISHED; - } - } - - #endregion - - #region Public File Handling - - public void WriteMovie(Stream stream) - { - if (!Loaded) - { - return; - } - - var directory_info = new FileInfo(Filename).Directory; - if (directory_info != null) Directory.CreateDirectory(directory_info.FullName); - - if (IsText) - { - WriteText(stream); - } - else - { - WriteBinary(stream); - } - } - - public void WriteMovie(string path) - { - if (!Loaded) - { - return; - } - var directory_info = new FileInfo(Filename).Directory; - if (directory_info != null) Directory.CreateDirectory(directory_info.FullName); - - if (IsText) - { - WriteText(Filename); - } - else - { - WriteBinary(Filename); - } - } - - public void WriteMovie() - { - if (!Loaded) - { - return; - } - else if (Filename == "") - { - return; - } - - WriteMovie(Filename); - changes = false; - } - - public void WriteBackup() - { - if (!Loaded) - { - return; - } - else if (Filename == "") - { - return; - } - - string BackupName = Filename; - BackupName = BackupName.Insert(Filename.LastIndexOf("."), String.Format(".{0:yyyy-MM-dd HH.mm.ss}", DateTime.Now)); - BackupName = Path.Combine(Global.Config.PathEntries["Global", "Movie backups"].Path, Path.GetFileName(BackupName)); - - var directory_info = new FileInfo(BackupName).Directory; - if (directory_info != null) Directory.CreateDirectory(directory_info.FullName); - - Global.OSD.AddMessage("Backup movie saved to " + BackupName); - if (IsText) - { - WriteText(BackupName); - } - else - { - WriteBinary(BackupName); - } - } - - /// - /// Load Header information only for displaying file information in dialogs such as play movie - /// - /// - public bool PreLoadText() - { - Loaded = false; - var file = new FileInfo(Filename); - - if (file.Exists == false) - return false; - else - { - Header.Clear(); - Log.Clear(); - } - - using (StreamReader sr = file.OpenText()) - { - string str; - while ((str = sr.ReadLine()) != null) - { - if (str == "" || Header.AddHeaderFromLine(str)) - { - continue; - } - - if (str.StartsWith("subtitle") || str.StartsWith("sub")) - { - Subtitles.AddSubtitle(str); - } - else if (str[0] == '|') - { - string frames = sr.ReadToEnd(); - int length = str.Length; - // Account for line breaks of either size. - if (frames.IndexOf("\r\n") != -1) - { - length++; - } - - length++; - // Count the remaining frames and the current one. - preload_framecount = (frames.Length/length) + 1; - break; - } - else - { - Header.Comments.Add(str); - } - } - sr.Close(); - } - - return true; - } - - public bool LoadMovie() - { - var file = new FileInfo(Filename); - if (file.Exists == false) - { - Loaded = false; - return false; - } - - return LoadText(); - } - - #endregion - - #region Public Log Editing - - public string GetInput(int frame) - { - int getframe; - - if (Loop) - { - if (frame < Log.Length) - { - getframe = frame; - } - else - { - getframe = ((frame - LoopOffset) % (Log.Length - LoopOffset)) + LoopOffset; - } - } - else - { - getframe = frame; - } - - if (getframe < Log.Length) - { - return Log.GetFrame(getframe); - } - else - { - return ""; - } - } - - public void ModifyFrame(string record, int frame) - { - Log.SetFrameAt(frame, record); - changes = true; - } - - public void ClearFrame(int frame) - { - MnemonicsGenerator mg = new MnemonicsGenerator(); - Log.SetFrameAt(frame, mg.GetEmptyMnemonic); - changes = true; - } - - public void AppendFrame(string record) - { - Log.AppendFrame(record); - changes = true; - } - - public void InsertFrame(string record, int frame) - { - Log.AddFrameAt(frame, record); - changes = true; - } - - public void InsertBlankFrame(int frame) - { - MnemonicsGenerator mg = new MnemonicsGenerator(); - Log.AddFrameAt(frame, mg.GetEmptyMnemonic); - changes = true; - } - - public void DeleteFrame(int frame) - { - if (frame <= StateLastIndex) - { - if (frame <= StateFirstIndex) - { - RewindToFrame(0); - } - else - { - RewindToFrame(frame); - } - } - Log.DeleteFrame(frame); - changes = true; - } - - public void TruncateMovie(int frame) - { - Log.TruncateMovie(frame); - Log.TruncateStates(frame); - changes = true; - } - - #endregion - - #region Public Misc Methods - - public MovieLog LogDump - { - get - { - return Log; - } - } - - public bool FrameLagged(int frame) - { - return Log.FrameLagged(frame); - } - - public void CaptureState() - { - if (StateCapturing) - { - byte[] state = Global.Emulator.SaveStateBinary(); - Log.AddState(state); - GC.Collect(); - } - } - - public void RewindToFrame(int frame) - { - if (Mode == MOVIEMODE.INACTIVE || Mode == MOVIEMODE.FINISHED) - { - return; - } - if (frame <= Global.Emulator.Frame) - { - if (frame <= Log.StateFirstIndex) - { - Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.InitState))); - if (Global.MainForm.EmulatorPaused && frame > 0) - { - Global.MainForm.UnpauseEmulator(); - } - if (MOVIEMODE.RECORD == Mode) - { - Mode = MOVIEMODE.PLAY; - Global.MainForm.RestoreReadWriteOnStop = true; - } - } - else - { - if (frame == 0) - { - Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.InitState))); - } - else - { - //frame-1 because we need to go back an extra frame and then run a frame, otherwise the display doesn't get updated. - Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetState(frame - 1)))); - Global.MainForm.UpdateFrame = true; - } - } - } - else if (frame <= Log.StateLastIndex) - { - Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Log.GetState(frame - 1)))); - Global.MainForm.UpdateFrame = true; - } - else - { - Global.MainForm.UnpauseEmulator(); - } - } - - public void PokeFrame(int frameNum, string input) - { - changes = true; - Log.SetFrameAt(frameNum, input); - } - - public void CommitFrame(int frameNum, IController source) - { - //Note: Truncation here instead of loadstate will make VBA style loadstates - //(Where an entire movie is loaded then truncated on the next frame - //this allows users to restore a movie with any savestate from that "timeline" - if (Global.Config.VBAStyleMovieLoadState) - { - if (Global.Emulator.Frame < Log.Length) - { - Log.TruncateMovie(Global.Emulator.Frame); - Log .TruncateStates(Global.Emulator.Frame); - } - } - changes = true; - MnemonicsGenerator mg = new MnemonicsGenerator(); - mg.SetSource(source); - Log.SetFrameAt(frameNum, mg.GetControllersAsMnemonic()); - } - - public void DumpLogIntoSavestateText(TextWriter writer) - { - writer.WriteLine("[Input]"); - string s = MovieHeader.GUID + " " + Header.GetHeaderLine(MovieHeader.GUID); - writer.WriteLine(s); - for (int x = 0; x < Log.Length; x++) - { - writer.WriteLine(Log.GetFrame(x)); - } - writer.WriteLine("[/Input]"); - } - - public void LoadLogFromSavestateText(string path) - { - using (var reader = new StreamReader(path)) - { - LoadLogFromSavestateText(reader); - } - } - - public void LoadLogFromSavestateText(TextReader reader) - { - int? stateFrame = null; - //We are in record mode so replace the movie log with the one from the savestate - if (!Global.MovieSession.MultiTrack.IsActive) - { - if (Global.Config.EnableBackupMovies && MakeBackup && Log.Length > 0) - { - WriteBackup(); - MakeBackup = false; - } - Log.Clear(); - while (true) - { - string line = reader.ReadLine(); - if (line == null) break; - else if (line.Trim() == "") continue; - else if (line == "[Input]") continue; - else if (line == "[/Input]") break; - else if (line.Contains("Frame 0x")) //NES stores frame count in hex, yay - { - string[] strs = line.Split('x'); - try - { - stateFrame = int.Parse(strs[1], NumberStyles.HexNumber); - } - catch { Global.OSD.AddMessage("Savestate Frame failed to parse"); } //TODO: message? - } - else if (line.Contains("Frame ")) - { - string[] strs = line.Split(' '); - try - { - stateFrame = int.Parse(strs[1]); - } - catch { Global.OSD.AddMessage("Savestate Frame failed to parse"); } //TODO: message? - } - if (line[0] == '|') - { - Log.AppendFrame(line); - } - } - } - else - { - int i = 0; - while (true) - { - string line = reader.ReadLine(); - if (line == null) break; - else if (line.Trim() == "") continue; - else if (line == "[Input]") continue; - else if (line == "[/Input]") break; - else if (line.Contains("Frame 0x")) //NES stores frame count in hex, yay - { - string[] strs = line.Split('x'); - try - { - stateFrame = int.Parse(strs[1], NumberStyles.HexNumber); - } - catch { Global.OSD.AddMessage("Savestate Frame failed to parse"); } //TODO: message? - } - else if (line.Contains("Frame ")) - { - string[] strs = line.Split(' '); - try - { - stateFrame = int.Parse(strs[1]); - } - catch { } //TODO: message? - } - if (line[0] == '|') - { - Log.SetFrameAt(i, line); - i++; - } - } - } - if (stateFrame == null) - throw new Exception("Couldn't find stateFrame"); - int stateFramei = (int)stateFrame; - - if (stateFramei > 0 && stateFramei < Log.Length) - { - if (!Global.Config.VBAStyleMovieLoadState) - { - Log.TruncateStates(stateFramei); - Log.TruncateMovie(stateFramei); - } - } - else if (stateFramei > Log.Length) //Post movie savestate - { - if (!Global.Config.VBAStyleMovieLoadState) - { - Log.TruncateStates(Log.Length); - Log.TruncateMovie(Log.Length); - } - Mode = MOVIEMODE.FINISHED; - } - if (IsCountingRerecords) - Rerecords++; - } - - public string GetTime(bool preLoad) - { - string time = ""; - - double seconds; - if (preLoad) - { - seconds = GetSeconds(preload_framecount); - } - else - { - seconds = GetSeconds(Log.Length); - } - - int hours = ((int)seconds) / 3600; - int minutes = (((int)seconds) / 60) % 60; - double sec = seconds % 60; - if (hours > 0) - { - time += MakeDigits(hours) + ":"; - } - - time += MakeDigits(minutes) + ":"; - - if (sec < 10) //Kludge - { - time += "0"; - } - - time += Math.Round((decimal)sec, 2).ToString(); - - return time; - } - - public bool CheckTimeLines(TextReader reader, bool OnlyGUID) - { - //This function will compare the movie data to the savestate movie data to see if they match - - MovieLog l = new MovieLog(); - int stateFrame = 0; - while (true) - { - string line = reader.ReadLine(); - if (line == null) - { - return false; - } - else if (line.Trim() == "") - { - continue; - } - else if (line.Contains("GUID")) - { - string guid = ParseHeader(line, MovieHeader.GUID); - if (Header.GetHeaderLine(MovieHeader.GUID) != guid) - { - //GUID Mismatch error - var result = MessageBox.Show(guid + " : " + Header.GetHeaderLine(MovieHeader.GUID) + "\n" + - "The savestate GUID does not match the current movie. Proceed anyway?", "GUID Mismatch error", - MessageBoxButtons.YesNo, MessageBoxIcon.Question); - - if (result == DialogResult.No) - { - //reader.Close(); - return false; - } - } - else if (OnlyGUID) - { - //reader.Close(); - return true; - } - } - else if (line.Contains("Frame 0x")) //NES stores frame count in hex, yay - { - string[] strs = line.Split('x'); - try - { - stateFrame = int.Parse(strs[1], NumberStyles.HexNumber); - } - catch { Global.OSD.AddMessage("Savestate Frame number failed to parse"); } - } - else if (line.Contains("Frame ")) - { - string[] strs = line.Split(' '); - try - { - stateFrame = int.Parse(strs[1]); - } - catch { Global.OSD.AddMessage("Savestate Frame number failed to parse"); } - } - else if (line == "[Input]") continue; - else if (line == "[/Input]") break; - else if (line[0] == '|') - l.AppendFrame(line); - } - - //reader.BaseStream.Position = 0; //Reset position because this stream may be read again by other code - - if (OnlyGUID) - { - //reader.Close(); - return true; - } - - - - if (stateFrame == 0) - { - stateFrame = l.Length; //In case the frame count failed to parse, revert to using the entire state input log - } - if (Log.Length < stateFrame) - { - //Future event error - MessageBox.Show("The savestate is from frame " + l.Length.ToString() + " which is greater than the current movie length of " + - Log.Length.ToString() + ".\nCan not load this savestate.", "Future event Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - //reader.Close(); - return false; - } - for (int x = 0; x < stateFrame; x++) - { - string xs = Log.GetFrame(x); - string ys = l.GetFrame(x); - if (xs != ys) - { - //TimeLine Error - MessageBox.Show("The savestate input does not match the movie input at frame " + (x + 1).ToString() + ".", - "Timeline Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - //reader.Close(); - return false; - } - } - - - - if (stateFrame > l.Length) //stateFrame is greater than state input log, so movie finished mode - { - if (Mode == MOVIEMODE.PLAY || Mode == MOVIEMODE.FINISHED) - { - Mode = MOVIEMODE.FINISHED; - return true; - } - else - return false; //For now throw an error if recording, ideally what should happen is that the state gets loaded, and the movie set to movie finished, the movie at its current state is preserved and the state is loaded just fine. This should probably also only happen if checktimelines passes - } - else if (Mode == MOVIEMODE.FINISHED) - { - Mode = MOVIEMODE.PLAY; - } - - //reader.Close(); - return true; - } - - #endregion - - #region Private Fields - - private readonly MovieLog Log = new MovieLog(); - private enum MOVIEMODE { INACTIVE, PLAY, RECORD, FINISHED }; - private MOVIEMODE Mode = MOVIEMODE.INACTIVE; - private bool statecapturing; - private bool startsfromsavestate; - private int preload_framecount; //Not a a reliable number, used for preloading (when no log has yet been loaded), this is only for quick stat compilation for dialogs such as play movie - private int rerecords; - private bool changes; - #endregion - - #region Helpers - - private void WriteText(string fn) - { - using (var fs = new FileStream(fn, FileMode.Create, FileAccess.Write, FileShare.Read)) - WriteText(fs); - } - - private void WriteBinary(string fn) - { - using (var fs = new FileStream(fn, FileMode.Create, FileAccess.Write, FileShare.Read)) - WriteBinary(fs); - } - - - private void WriteText(Stream stream) - { - using (StreamWriter sw = new StreamWriter(stream)) - { - Header.WriteText(sw); - - //TODO: clean this up - if (LoopOffset >= 0) - { - sw.WriteLine("LoopOffset " + LoopOffset.ToString()); - } - - Subtitles.WriteText(sw); - Log.WriteText(sw); - } - } - - private void WriteBinary(Stream stream) - { - } - - private bool LoadText() - { - var file = new FileInfo(Filename); - - if (file.Exists == false) - { - Loaded = false; - return false; - } - else - { - Header.Clear(); - Log.Clear(); - } - - using (StreamReader sr = file.OpenText()) - { - string str; - - while ((str = sr.ReadLine()) != null) - { - if (str == "") - { - continue; - } - - if (str.Contains(MovieHeader.RERECORDS)) - { - string rerecordStr = ParseHeader(str, MovieHeader.RERECORDS); - try - { - Rerecords = int.Parse(rerecordStr); - } - catch - { - Rerecords = 0; - } - } - else if (str.Contains(MovieHeader.STARTSFROMSAVESTATE)) - { - str = ParseHeader(str, MovieHeader.STARTSFROMSAVESTATE); - if (str == "1") - StartsFromSavestate = true; - } - - else if (str.Contains("LoopOffset")) - { - str = ParseHeader(str, "LoopOffset"); - try - { - LoopOffset = int.Parse(str); - } - catch - { - //Do nothing - } - } - else if (str.StartsWith("subtitle") || str.StartsWith("sub")) - { - Subtitles.AddSubtitle(str); - } - else if (Header.AddHeaderFromLine(str)) - { - continue; - } - else if (str[0] == '|') - { - Log.AppendFrame(str); - } - else - { - Header.Comments.Add(str); - } - } - } - Loaded = true; - return true; - - } - - private bool LoadBinary() - { - return true; - } - - private string MakeDigits(int num) - { - if (num < 10) - { - return "0" + num.ToString(); - } - else - { - return num.ToString(); - } - } - - private double GetSeconds(int frameCount) - { - const double NES_PAL = 50.006977968268290849; - const double NES_NTSC = 60.098813897440515532; - const double SNES_NTSC = (double)21477272 / (4 * 341 * 262); - const double SNES_PAL = (double)21281370 / (4 * 341 * 312); - const double PCE = (7159090.90909090 / 455 / 263); //~59.826 - const double SMS_NTSC = (3579545 / 262.0 / 228.0); - const double SMS_PAL = (3546893 / 313.0 / 228.0); - const double NGP = (6144000.0 / (515 * 198)); - const double VBOY = (20000000 / (259 * 384 * 4)); //~50.273 - const double LYNX = 59.8; - const double WSWAN = (3072000.0 / (159 * 256)); - const double GB = 262144.0 / 4389.0; - const double A26 = 59.9227510135505; - - double frames = frameCount; - - if (frames < 1) - { - return 0; - } - - bool pal = false; - if (Header.HeaderParams.ContainsKey(MovieHeader.PAL)) - if (Header.HeaderParams[MovieHeader.PAL] == "1") - pal = true; - - switch (Header.GetHeaderLine(MovieHeader.PLATFORM)) - { - case "GG": - case "SG": - case "SMS": - if (pal) - return frames / SMS_PAL; - else - return frames / SMS_NTSC; - case "FDS": - case "NES": - if (pal) - return frames / NES_PAL; - else - return frames / NES_NTSC; - case "SNES": - case "SGB": - if (pal) - return frames / SNES_PAL; - else - return frames / SNES_NTSC; - case "PCE": - case "PCECD": - return frames / PCE; - case "GB": - case "GBC": - case "GBA": - return frames / GB; - case "A26": - case "A78": - case "Coleco": - return frames / A26; - - //One Day! - case "VBOY": - return frames / VBOY; - case "NGP": - return frames / NGP; - case "LYNX": - return frames / LYNX; - case "WSWAN": - return frames / WSWAN; - //******** - - case "": - default: - if (pal) - return frames / 50.0; - else - return frames / 60.0; - } - } - - private static string ParseHeader(string line, string headerName) - { - int x = line.LastIndexOf(headerName) + headerName.Length; - return line.Substring(x + 1, line.Length - x - 1); - } - - #endregion - - #region ComparisonLogic - - public int CompareTo(Movie Other, string parameter) - { - int compare = 0; - if (parameter == "File") - { - compare = CompareFileName(Other); - if (compare == 0) - { - compare = CompareSysID(Other); - if (compare == 0) - { - compare = CompareGameName(Other); - if (compare == 0) - compare = CompareLength(Other); - } - } - } - else if (parameter == "SysID") - { - compare = CompareSysID(Other); - if (compare == 0) - { - compare = CompareFileName(Other); - if (compare == 0) - { - compare = CompareGameName(Other); - if (compare == 0) - compare = CompareLength(Other); - } - } - } - else if (parameter == "Game") - { - compare = CompareGameName(Other); - if (compare == 0) - { - compare = CompareFileName(Other); - if (compare == 0) - { - compare = CompareSysID(Other); - if (compare == 0) - compare = CompareLength(Other); - } - } - } - else if (parameter == "Length") - { - compare = CompareLength(Other); - if (compare == 0) - { - compare = CompareFileName(Other); - if (compare == 0) - { - compare = CompareSysID(Other); - if (compare == 0) - compare = CompareGameName(Other); - } - } - } - return compare; - } - - private int CompareFileName(Movie Other) - { - string otherName = Path.GetFileName(Other.Filename); - string thisName = Path.GetFileName(Filename); - - if (thisName != null) - { - return thisName.CompareTo(otherName); - } - else - { - return 0; - } - } - - private int CompareSysID(Movie Other) - { - string otherSysID = Other.SysID; - string thisSysID = SysID; - - if (thisSysID == null && otherSysID == null) - return 0; - else if (thisSysID == null) - return -1; - else if (otherSysID == null) - return 1; - else - return thisSysID.CompareTo(otherSysID); - } - - private int CompareGameName(Movie Other) - { - string otherGameName = Other.GameName; - string thisGameName = GameName; - - if (thisGameName == null && otherGameName == null) - return 0; - else if (thisGameName == null) - return -1; - else if (otherGameName == null) - return 1; - else - return thisGameName.CompareTo(otherGameName); - } - - private int CompareLength(Movie Other) - { - int otherLength = Other.preload_framecount; - int thisLength = preload_framecount; - - if (thisLength < otherLength) - { - return -1; - } - else if (thisLength > otherLength) - { - return 1; - } - else - { - return 0; - } - } - - #endregion - } -} \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/MovieHeader.cs b/BizHawk.MultiClient/movie/MovieHeader.cs deleted file mode 100644 index b5ba4674b7..0000000000 --- a/BizHawk.MultiClient/movie/MovieHeader.cs +++ /dev/null @@ -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 HeaderParams = new Dictionary(); //Platform specific options go here - public List Comments = new List(); - - public Dictionary BoardProperties = new Dictionary(); - - 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()); - } - - /// - /// Adds the key value pair to header params. If key already exists, value will be updated - /// - /// - /// - 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 kvp in HeaderParams) - { - sw.WriteLine(kvp.Key + " " + kvp.Value); - } - - foreach (KeyValuePair 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 - /// - /// Receives a line and attempts to add as a header, returns false if not a useable header line - /// - /// - /// - 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 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 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(); - } - } - } -} diff --git a/BizHawk.MultiClient/movie/MovieImport.cs b/BizHawk.MultiClient/movie/MovieImport.cs index 0b36faac26..cd4f4a8424 100644 --- a/BizHawk.MultiClient/movie/MovieImport.cs +++ b/BizHawk.MultiClient/movie/MovieImport.cs @@ -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" diff --git a/BizHawk.MultiClient/movie/MovieLog.cs b/BizHawk.MultiClient/movie/MovieLog.cs deleted file mode 100644 index 4888c26111..0000000000 --- a/BizHawk.MultiClient/movie/MovieLog.cs +++ /dev/null @@ -1,250 +0,0 @@ -using System.Collections.Generic; -using System.IO; - -namespace BizHawk.MultiClient -{ - /// - /// Represents the controller key presses of a movie - /// - 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 _movie_records = new List(); - private readonly List _state_records = new List(); - - //TODO: Make this size limit configurable by the user - private const int MAXSTATERECORDSIZE = 512*1024*1024; //To limit memory usage. - - #endregion - } -} diff --git a/BizHawk.MultiClient/movie/MovieMnemonics.cs b/BizHawk.MultiClient/movie/MovieMnemonics.cs deleted file mode 100644 index c4c9873584..0000000000 --- a/BizHawk.MultiClient/movie/MovieMnemonics.cs +++ /dev/null @@ -1,1096 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace BizHawk.MultiClient -{ - public static class MnemonicConstants - { - public static readonly Dictionary> BUTTONS = new Dictionary> - { - { - "Gameboy Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"} - } - }, - { - "GBA Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"}, {"L", "L"}, {"R", "R"} - } - }, - { - "Genesis 3-Button Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Start", "S"}, {"A", "A"}, {"B", "B"}, - {"C", "C"} - } - }, - { - "NES Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"} - } - }, - { - "SNES Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Start", "S"}, {"B", "B"}, - {"A", "A"}, {"X", "X"}, {"Y", "Y"}, {"L", "L"}, {"R", "R"} - } - }, - { - "PC Engine Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Select", "s"}, {"Run", "r"}, {"B2", "2"}, - {"B1", "1"} - } - }, - { - "SMS Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"B1", "1"}, {"B2", "2"} - } - }, - { - "TI83 Controller", new Dictionary - { - {"0", "0"}, {"1", "1"}, {"2", "2"}, {"3", "3"}, {"4", "4"}, {"5", "5"}, {"6", "6"}, {"7", "7"}, - {"8", "8"}, {"9", "9"}, {"DOT", "`"}, {"ON", "O"}, {"ENTER", "="}, {"UP", "U"}, {"DOWN", "D"}, - {"LEFT", "L"}, {"RIGHT", "R"}, {"PLUS", "+"}, {"MINUS", "_"}, {"MULTIPLY", "*"}, {"DIVIDE", "/"}, - {"CLEAR", "c"}, {"EXP", "^"}, {"DASH", "-"}, {"PARAOPEN", "("}, {"PARACLOSE", ")"}, {"TAN", "T"}, - {"VARS", "V"}, {"COS", "C"}, {"PRGM", "P"}, {"STAT", "s"}, {"MATRIX", "m"}, {"X", "X"}, {"STO", ">"}, - {"LN", "n"}, {"LOG", "L"}, {"SQUARED", "2"}, {"NEG1", "1"}, {"MATH", "H"}, {"ALPHA", "A"}, - {"GRAPH", "G"}, {"TRACE", "t"}, {"ZOOM", "Z"}, {"WINDOW", "W"}, {"Y", "Y"}, {"2ND", "&"}, {"MODE", "O"}, - {"DEL", "D"}, {"COMMA", ","}, {"SIN", "S"} - } - }, - { - "Atari 2600 Basic Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"} - } - }, - { - "Atari 7800 ProLine Joystick Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Trigger", "1"}, {"Trigger 2", "2"} - } - }, - { - "Commodore 64 Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"Button", "B"} - } - }, - { - "Commodore 64 Keyboard", new Dictionary - { - {"Key F1", "1"}, {"Key F3", "3"}, {"Key F5", "5"}, {"Key F7", "7"}, - {"Key Left Arrow", "l"}, {"Key 1", "1"}, {"Key 2", "2"}, {"Key 3", "3"}, {"Key 4", "4"}, {"Key 5", "5"}, {"Key 6", "6"}, {"Key 7", "7"}, {"Key 8", "8"}, {"Key 9", "9"}, {"Key 0", "0"}, {"Key Plus", "+"}, {"Key Minus", "-"}, {"Key Pound", "l"}, {"Key Clear/Home", "c"}, {"Key Insert/Delete", "i"}, - {"Key Control", "c"}, {"Key Q", "Q"}, {"Key W", "W"}, {"Key E", "E"}, {"Key R", "R"}, {"Key T", "T"}, {"Key Y", "Y"}, {"Key U", "U"}, {"Key I", "I"}, {"Key O", "O"}, {"Key P", "P"}, {"Key At", "@"}, {"Key Asterisk", "*"}, {"Key Up Arrow", "u"}, {"Key Restore", "r"}, - {"Key Run/Stop", "s"}, {"Key Lck", "k"}, {"Key A", "A"}, {"Key S", "S"}, {"Key D", "D"}, {"Key F", "F"}, {"Key G", "G"}, {"Key H", "H"}, {"Key J", "J"}, {"Key K", "K"}, {"Key L", "L"}, {"Key Colon", ":"}, {"Key Semicolon", ";"}, {"Key Equal", "="}, {"Key Return", "e"}, - {"Key Commodore", "o"}, {"Key Left Shift", "s"}, {"Key Z", "Z"}, {"Key X", "X"}, {"Key C", "C"}, {"Key V", "V"}, {"Key B", "B"}, {"Key N", "N"}, {"Key M", "M"}, {"Key Comma", ","}, {"Key Period", ">"}, {"Key Slash", "/"}, {"Key Right Shift", "s"}, {"Key Cursor Up/Down", "u"}, {"Key Cursor Left/Right", "l"}, - {"Key Space", "_"} - } - }, - { - "ColecoVision Basic Controller", new Dictionary - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, {"L", "l"}, {"R", "r"}, - {"Key1", "1"}, {"Key2", "2"}, {"Key3", "3"}, {"Key4", "4"}, {"Key5", "5"}, {"Key6", "6"}, - {"Key7", "7"}, {"Key8", "8"}, {"Key9", "9"}, {"Star", "*"}, {"Key0", "0"}, {"Pound", "#"} - } - }, - { - "Nintento 64 Controller", new Dictionary() - { - {"DPad U", "U"}, {"DPad D", "D"}, {"DPad L", "L"}, {"DPad R", "R"}, - {"B", "B"}, {"A", "A"}, {"Z", "Z"}, {"Start", "S"}, {"L", "L"}, {"R", "R"}, - {"C Up", "u"}, {"C Down", "d"}, {"C Left", "l"}, {"C Right", "r"} - } - }, - { - "Saturn Controller", new Dictionary() - { - {"Up", "U"}, {"Down", "D"}, {"Left", "L"}, {"Right", "R"}, - {"Start", "S"}, {"X", "X"}, {"Y", "Y"}, {"Z", "Z"}, {"A", "A"}, {"B", "B"}, {"C", "C"}, - {"L", "l"}, {"R", "r"}, - } - } - }; - - public static readonly Dictionary> ANALOGS = new Dictionary> - { - {"Nintento 64 Controller", new Dictionary {{"X Axis", "X"}, {"Y Axis", "Y"}}} - }; - - public static readonly Dictionary> COMMANDS = new Dictionary> - { - {"Atari 2600 Basic Controller", new Dictionary {{"Reset", "r"}, {"Select", "s"}}}, - {"Atari 7800 ProLine Joystick Controller", new Dictionary {{"Reset", "r"}, {"Select", "s"}}}, - {"Gameboy Controller", new Dictionary {{"Power", "P"}}}, - {"GBA Controller", new Dictionary {{"Power", "P"}}}, - {"Genesis 3-Button Controller", new Dictionary {{"Reset", "r"}}}, - {"NES Controller", new Dictionary {{"Reset", "r"}, {"Power", "P"}, {"FDS Eject", "E"}, {"FDS Insert 0", "0"}, {"FDS Insert 1", "1"}, {"VS Coin 1", "c"}, {"VS Coin 2", "C"}}}, - {"SNES Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"PC Engine Controller", new Dictionary {}}, - {"SMS Controller", new Dictionary {{"Pause", "p"}, {"Reset", "r"}}}, - {"TI83 Controller", new Dictionary {}}, - {"Nintento 64 Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - {"Saturn Controller", new Dictionary {{"Power", "P"}, {"Reset", "r"}}}, - }; - - public static readonly Dictionary PLAYERS = new Dictionary - { - {"Gameboy Controller", 1}, {"GBA Controller", 1}, {"Genesis 3-Button Controller", 2}, {"NES Controller", 4}, - {"SNES Controller", 4}, {"PC Engine Controller", 5}, {"SMS Controller", 2}, {"TI83 Controller", 1}, {"Atari 2600 Basic Controller", 2}, {"Atari 7800 ProLine Joystick Controller", 2}, - {"ColecoVision Basic Controller", 2}, {"Commodore 64 Controller", 2}, {"Nintento 64 Controller", 4}, {"Saturn Controller", 2} - }; - - // just experimenting with different possibly more painful ways to handle mnemonics - // |P|UDLRsSBA| - public static Tuple[] DGBMnemonic = new Tuple[] - { - new Tuple(null, '|'), - new Tuple("P1 Power", 'P'), - new Tuple(null, '|'), - new Tuple("P1 Up", 'U'), - new Tuple("P1 Down", 'D'), - new Tuple("P1 Left", 'L'), - new Tuple("P1 Right", 'R'), - new Tuple("P1 Select", 's'), - new Tuple("P1 Start", 'S'), - new Tuple("P1 B", 'B'), - new Tuple("P1 A", 'A'), - new Tuple(null, '|'), - new Tuple("P2 Power", 'P'), - new Tuple(null, '|'), - new Tuple("P2 Up", 'U'), - new Tuple("P2 Down", 'D'), - new Tuple("P2 Left", 'L'), - new Tuple("P2 Right", 'R'), - new Tuple("P2 Select", 's'), - new Tuple("P2 Start", 'S'), - new Tuple("P2 B", 'B'), - new Tuple("P2 A", 'A'), - new Tuple(null, '|') - }; - } - - public class MnemonicsGenerator - { - IController Source; - public void SetSource(IController source) - { - Source = source; - ControlType = source.Type.Name; - } - string ControlType; - - bool IsBasePressed(string name) - { - bool ret = Source.IsPressed(name); - return ret; - } - - float GetBaseFloat(string name) - { - return Source.GetFloat(name); - } - - public bool IsEmpty - { - get - { - string empty = GetEmptyMnemonic; - string input = GetControllersAsMnemonic(); - if (empty == input) - { - return true; - } - else - { - return false; - } - } - } - - public string GetEmptyMnemonic - { - get - { - switch (Global.Emulator.SystemId) - { - default: - case "NULL": - return "|.|"; - case "A26": - return "|..|.....|.....|"; - case "A78": - return "|....|......|......|"; - case "TI83": - return "|..................................................|.|"; - case "NES": - return "|.|........|........|........|........|"; - case "SNES": - return "|.|............|............|............|............|"; - case "SMS": - case "GG": - case "SG": - return "|......|......|..|"; - case "GEN": - return "|.|........|........|"; - case "GB": - return "|.|........|"; - case "DGB": - return "|.|........|.|........|"; - case "PCE": - case "PCECD": - case "SGX": - return "|.|........|........|........|........|........|"; - case "Coleco": - return "|..................|..................|"; - case "C64": - return "|.....|.....|..................................................................|"; - case "GBA": - return "|.|..........|"; - case "N64": - return "|.|............|............|............|............|"; - case "SAT": - return "|.|.............|.............|"; - } - } - } - - private string GetGBAControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - if (IsBasePressed("Power")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Power"]); - } - else - { - input.Append("."); - } - input.Append("|"); - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed(button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append("|"); - return input.ToString(); - } - - //adelikat: I"m going to do all controllers like this, so what if it is redundant! It is better than reducing lines of code with convoluted logic that is difficult to expand to support new platforms - private string GetSNESControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - - if (IsBasePressed("Power")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Power"]); - } - else if (IsBasePressed("Reset")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Reset"]); - } - else - { - input.Append('.'); - } - - input.Append("|"); - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed("P" + player + " " + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append("|"); - } - - return input.ToString(); - } - - private string GetC64ControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed("P" + player + " " + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append('|'); - } - - foreach (string button in MnemonicConstants.BUTTONS["Commodore 64 Keyboard"].Keys) - { - input.Append(IsBasePressed(button) ? MnemonicConstants.BUTTONS["Commodore 64 Keyboard"][button] : "."); - } - input.Append('|'); - - input.Append('|'); - return input.ToString(); - } - - private string GetDualGameBoyControllerAsMnemonic() - { - // |.|........|.|........| - StringBuilder input = new StringBuilder(); - - foreach (var t in MnemonicConstants.DGBMnemonic) - { - if (t.Item1 != null) - input.Append(IsBasePressed(t.Item1) ? t.Item2 : '.'); - else - input.Append(t.Item2); // seperator - } - return input.ToString(); - } - - - private string GetA78ControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - input.Append(IsBasePressed("Power") ? 'P' : '.'); - input.Append(IsBasePressed("Reset") ? 'r' : '.'); - input.Append(IsBasePressed("Select") ? 's' : '.'); - input.Append(IsBasePressed("Pause") ? 'p' : '.'); - input.Append('|'); - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed("P" + player + " " + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append('|'); - } - - return input.ToString(); - } - - private string GetN64ControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - if (IsBasePressed("Power")) - { - input.Append('P'); - } - else if (IsBasePressed("Reset")) - { - input.Append('r'); - } - else - { - input.Append('.'); - } - input.Append('|'); - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed("P" + player + " " + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - - if (MnemonicConstants.ANALOGS[ControlType].Keys.Count > 0) - { - foreach (string name in MnemonicConstants.ANALOGS[ControlType].Keys) - { - int val = 0; - - //Nasty hackery - if (name == "Y Axis") - { - if (IsBasePressed("P" + player + " A Up")) - { - val = 127; - } - else if (IsBasePressed("P" + player + " A Down")) - { - val = -127; - } - else - { - val = (int)GetBaseFloat("P" + player + " " + name); - } - } - else if (name == "X Axis") - { - if (IsBasePressed("P" + player + " A Left")) - { - val = -127; - } - else if (IsBasePressed("P" + player + " A Right")) - { - val = 127; - } - else - { - val = (int)GetBaseFloat("P" + player + " " + name); - } - } - else - { - val = (int)GetBaseFloat("P" + player + " " + name); - } - - if (val >= 0) - { - input.Append(' '); - } - - input.Append(String.Format("{0:000}", val)).Append(','); - } - input.Remove(input.Length - 1, 1); - } - - input.Append('|'); - } - - return input.ToString(); - } - - private string GetSaturnControllersAsMnemonic() - { - StringBuilder input = new StringBuilder("|"); - if (IsBasePressed("Power")) - { - input.Append('P'); - } - else if (IsBasePressed("Reset")) - { - input.Append('r'); - } - else - { - input.Append('.'); - } - input.Append('|'); - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed("P" + player + " " + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append('|'); - } - - return input.ToString(); - } - - public string GetControllersAsMnemonic() - { - if (ControlType == "Null Controller") - { - return "|.|"; - } - else if (ControlType == "Atari 7800 ProLine Joystick Controller") - { - return GetA78ControllersAsMnemonic(); - } - else if (ControlType == "SNES Controller") - { - return GetSNESControllersAsMnemonic(); - } - else if (ControlType == "Commodore 64 Controller") - { - return GetC64ControllersAsMnemonic(); - } - else if (ControlType == "GBA Controller") - { - return GetGBAControllersAsMnemonic(); - } - else if (ControlType == "Dual Gameboy Controller") - { - return GetDualGameBoyControllerAsMnemonic(); - } - else if (ControlType == "Nintento 64 Controller") - { - return GetN64ControllersAsMnemonic(); - } - else if (ControlType == "Saturn Controller") - { - return GetSaturnControllersAsMnemonic(); - } - else if (ControlType == "PSP Controller") - { - return "|.|"; // TODO - } - - StringBuilder input = new StringBuilder("|"); - - if (ControlType == "PC Engine Controller") - { - input.Append("."); - } - else if (ControlType == "Atari 2600 Basic Controller") - { - input.Append(IsBasePressed("Reset") ? "r" : "."); - input.Append(IsBasePressed("Select") ? "s" : "."); - } - else if (ControlType == "NES Controller") - { - if (IsBasePressed("Power")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Power"]); - } - else if (IsBasePressed("Reset")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Reset"]); - } - else if (IsBasePressed("FDS Eject")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["FDS Eject"]); - } - else if (IsBasePressed("FDS Insert 0")) - { - input.Append("0"); - } - else if (IsBasePressed("FDS Insert 1")) - { - input.Append("1"); - } - else if (IsBasePressed("FDS Insert 2")) - { - input.Append("2"); - } - else if (IsBasePressed("FDS Insert 3")) - { - input.Append("3"); - } - else if (IsBasePressed("VS Coin 1")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["VS Coin 1"]); - } - else if (IsBasePressed("VS Coin 2")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["VS Coin 2"]); - } - else - { - input.Append('.'); - } - } - else if (ControlType == "Genesis 3-Button Controller") - { - if (IsBasePressed("Power")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Power"]); - } - else if (IsBasePressed("Reset")) - { - input.Append(MnemonicConstants.COMMANDS[ControlType]["Reset"]); - } - else - { - input.Append('.'); - } - } - else if (ControlType == "Gameboy Controller") - { - input.Append(IsBasePressed("Power") ? MnemonicConstants.COMMANDS[ControlType]["Power"] : "."); - } - - if (ControlType != "SMS Controller" && ControlType != "TI83 Controller" && ControlType != "ColecoVision Basic Controller") - { - input.Append("|"); - } - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - string prefix = ""; - if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") - { - prefix = "P" + player.ToString() + " "; - } - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - input.Append(IsBasePressed(prefix + button) ? MnemonicConstants.BUTTONS[ControlType][button] : "."); - } - input.Append("|"); - } - if (ControlType == "SMS Controller") - { - foreach (string command in MnemonicConstants.COMMANDS[ControlType].Keys) - { - input.Append(IsBasePressed(command) ? MnemonicConstants.COMMANDS[ControlType][command] : "."); - } - input.Append("|"); - } - if (ControlType == "TI83 Controller") - { - input.Append(".|"); //TODO: perhaps ON should go here? - } - return input.ToString(); - } - } - - - public class MovieControllerAdapter : IController - { - //IController implementation: - public ControllerDefinition Type { get; set; } - public bool this[string button] { get { return MyBoolButtons[button]; } } - public bool IsPressed(string button) { return MyBoolButtons[button]; } - public float GetFloat(string name) { return MyFloatControls[name]; } - public void UpdateControls(int frame) { } - //-------- - - private readonly WorkingDictionary MyBoolButtons = new WorkingDictionary(); - private readonly WorkingDictionary MyFloatControls = new WorkingDictionary(); - - void Force(string button, bool state) - { - MyBoolButtons[button] = state; - } - - void Force(string name, float state) - { - MyFloatControls[name] = state; - } - - string ControlType { get { return Type.Name; } } - - class MnemonicChecker - { - private readonly string m; - - public MnemonicChecker(string _m) - { - m = _m; - } - - public bool this[int c] - { - get - { - if (m[c] == '.') - { - return false; - } - else if (m[c] == '?') - { - return new Random((int)DateTime.Now.Ticks).Next(0, 10) > 5; - } - else - { - return true; - } - } - } - } - - /// - /// latches one player from the source - /// - public void LatchPlayerFromSource(IController playerSource, int playerNum) - { - foreach (string button in playerSource.Type.BoolButtons) - { - ButtonNameParser bnp = ButtonNameParser.Parse(button); - if (bnp == null) continue; - if (bnp.PlayerNum != playerNum) continue; - bool val = playerSource[button]; - MyBoolButtons[button] = val; - } - } - - /// - /// latches all buttons from the provided source - /// - public void LatchFromSource(IController source) - { - foreach (string button in Type.BoolButtons) - { - MyBoolButtons[button] = source[button]; - } - - foreach (string name in Type.FloatControls) - { - MyFloatControls[name] = source.GetFloat(name); - } - } - - //Redundancy beats crazy if logic that makes new consoles annoying to add - - private void SetGBAControllersAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - if (mnemonic.Length < 2) - { - return; - } - if (mnemonic[1] == 'P') - { - Force("Power", true); - } - int start = 3; - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force(button, c[start++]); - } - } - - private void SetSNESControllersAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - - if (mnemonic.Length < 2) - { - return; - } - - if (mnemonic[1] == 'P') - { - Force("Power", true); - } - else if (mnemonic[1] != '.' && mnemonic[1] != '0') - { - Force("Reset", true); - } - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - - if (mnemonic.Length < srcindex + 3 + MnemonicConstants.BUTTONS[ControlType].Count - 1) - { - return; - } - - int start = 3; - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force("P" + player + " " + button, c[srcindex + start++]); - } - } - } - - private void SetN64ControllersAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - - if (mnemonic.Length < 2) - { - return; - } - - if (mnemonic[1] == 'P') - { - Force("Power", true); - } - else if (mnemonic[1] != '.' && mnemonic[1] != '0') - { - Force("Reset", true); - } - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + MnemonicConstants.ANALOGS[ControlType].Count * 4 + 1 + 1); - - if (mnemonic.Length < srcindex + 3 + MnemonicConstants.BUTTONS[ControlType].Count - 1) - { - return; - } - - int start = 3; - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force("P" + player + " " + button, c[srcindex + start++]); - } - - foreach (string name in MnemonicConstants.ANALOGS[ControlType].Keys) - { - if (InputValidate.IsValidSignedNumber(mnemonic.Substring(srcindex + start, 4))) - { - Force("P" + player + " " + name, Int32.Parse(mnemonic.Substring(srcindex + start, 4))); - } - - start += 5; - } - } - } - - private void SetSaturnControllersAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - - if (mnemonic.Length < 2) - { - return; - } - - if (mnemonic[1] == 'P') - { - Force("Power", true); - } - else if (mnemonic[1] != '.' && mnemonic[1] != '0') - { - Force("Reset", true); - } - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - - if (mnemonic.Length < srcindex + 3 + MnemonicConstants.BUTTONS[ControlType].Count - 1) - { - return; - } - - int start = 3; - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force("P" + player + " " + button, c[srcindex + start++]); - } - } - } - - private void SetAtari7800AsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - - if (mnemonic.Length < 5) - { - return; - } - if (mnemonic[1] == 'P') - { - Force("Power", true); - } - if (mnemonic[2] == 'r') - { - Force("Reset", true); - } - if (mnemonic[3] == 's') - { - Force("Select", true); - } - if (mnemonic[4] == 'p') - { - Force("Pause", true); - } - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - int start = 6; - if (mnemonic.Length < srcindex + start + MnemonicConstants.BUTTONS[ControlType].Count) - { - return; - } - - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force("P" + player + " " + button, c[srcindex + start++]); - } - } - } - - private void SetDualGameBoyControllerAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - for (int i = 0; i < MnemonicConstants.DGBMnemonic.Length; i++) - { - var t = MnemonicConstants.DGBMnemonic[i]; - if (t.Item1 != null) - Force(t.Item1, c[i]); - } - } - - private void SetC64ControllersAsMnemonic(string mnemonic) - { - MnemonicChecker c = new MnemonicChecker(mnemonic); - MyBoolButtons.Clear(); - - - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - - if (mnemonic.Length < srcindex + 1 + MnemonicConstants.BUTTONS[ControlType].Count - 1) - { - return; - } - - int start = 1; - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force("P" + player + " " + button, c[srcindex + start++]); - } - } - - int startk = 13; - foreach (string button in MnemonicConstants.BUTTONS["Commodore 64 Keyboard"].Keys) - { - Force(button, c[startk++]); - } - } - - /// - /// latches all buttons from the supplied mnemonic string - /// - public void SetControllersAsMnemonic(string mnemonic) - { - if (ControlType == "Null Controller") - { - return; - } - else if (ControlType == "SNES Controller") - { - SetSNESControllersAsMnemonic(mnemonic); - return; - } - else if (ControlType == "Commodore 64 Controller") - { - SetC64ControllersAsMnemonic(mnemonic); - return; - } - else if (ControlType == "GBA Controller") - { - SetGBAControllersAsMnemonic(mnemonic); - return; - } - else if (ControlType == "Atari 7800 ProLine Joystick Controller") - { - SetAtari7800AsMnemonic(mnemonic); - return; - } - else if (ControlType == "Dual Gameboy Controller") - { - SetDualGameBoyControllerAsMnemonic(mnemonic); - return; - } - else if (ControlType == "Nintento 64 Controller") - { - SetN64ControllersAsMnemonic(mnemonic); - return; - } - else if (ControlType == "Saturn Controller") - { - SetSaturnControllersAsMnemonic(mnemonic); - return; - } - else if (ControlType == "PSP Controller") - { - // TODO - return; - } - - MnemonicChecker c = new MnemonicChecker(mnemonic); - - MyBoolButtons.Clear(); - - int start = 3; - if (ControlType == "NES Controller") - { - if (mnemonic.Length < 2) - { - return; - } - else if (mnemonic[1] == 'P') - { - Force("Power", true); - } - else if (mnemonic[1] == 'E') - { - Force("FDS Eject", true); - } - else if (mnemonic[1] == '0') - { - Force("FDS Insert 0", true); - } - else if (mnemonic[1] == '1') - { - Force("FDS Insert 1", true); - } - else if (mnemonic[1] == '2') - { - Force("FDS Insert 2", true); - } - else if (mnemonic[1] == '3') - { - Force("FDS Insert 3", true); - } - else if (mnemonic[1] == 'c') - { - Force("VS Coin 1", true); - } - else if (mnemonic[1] == 'C') - { - Force("VS Coin 2", true); - } - else if (mnemonic[1] != '.') - { - Force("Reset", true); - } - } - if (ControlType == "Gameboy Controller") - { - if (mnemonic.Length < 2) return; - Force("Power", mnemonic[1] != '.'); - } - if (ControlType == "Genesis 3-Button Controller") - { - if (mnemonic.Length < 2) return; - Force("Reset", mnemonic[1] != '.'); - } - if (ControlType == "SMS Controller" || ControlType == "TI83 Controller" || ControlType == "ColecoVision Basic Controller") - { - start = 1; - } - if (ControlType == "Atari 2600 Basic Controller") - { - if (mnemonic.Length < 2) return; - Force("Reset", mnemonic[1] != '.' && mnemonic[1] != '0'); - Force("Select", mnemonic[2] != '.' && mnemonic[2] != '0'); - start = 4; - } - for (int player = 1; player <= MnemonicConstants.PLAYERS[ControlType]; player++) - { - int srcindex = (player - 1) * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - int ctr = start; - if (mnemonic.Length < srcindex + ctr + MnemonicConstants.BUTTONS[ControlType].Count - 1) - { - return; - } - string prefix = ""; - if (ControlType != "Gameboy Controller" && ControlType != "TI83 Controller") - { - prefix = "P" + player + " "; - } - foreach (string button in MnemonicConstants.BUTTONS[ControlType].Keys) - { - Force(prefix + button, c[srcindex + ctr++]); - } - } - if (ControlType == "SMS Controller") - { - int srcindex = MnemonicConstants.PLAYERS[ControlType] * (MnemonicConstants.BUTTONS[ControlType].Count + 1); - int ctr = start; - foreach (string command in MnemonicConstants.COMMANDS[ControlType].Keys) - { - Force(command, c[srcindex + ctr++]); - } - } - } - } - -} diff --git a/BizHawk.MultiClient/movie/MovieSession.cs b/BizHawk.MultiClient/movie/MovieSession.cs deleted file mode 100644 index 14e264263e..0000000000 --- a/BizHawk.MultiClient/movie/MovieSession.cs +++ /dev/null @@ -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); - } - - /// - /// latch input from the input log, if available - /// - public void LatchInputFromLog() - { - string loggedFrame = Movie.GetInput(Global.Emulator.Frame); - MovieControllerAdapter.SetControllersAsMnemonic(loggedFrame); - } - } - -} \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/MultitrackRecording.cs b/BizHawk.MultiClient/movie/MultitrackRecording.cs deleted file mode 100644 index af5d9e236e..0000000000 --- a/BizHawk.MultiClient/movie/MultitrackRecording.cs +++ /dev/null @@ -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; - } - } -} diff --git a/BizHawk.MultiClient/movie/PlayMovie.cs b/BizHawk.MultiClient/movie/PlayMovie.cs index f14c7dc1a0..acfde6c7cb 100644 --- a/BizHawk.MultiClient/movie/PlayMovie.cs +++ b/BizHawk.MultiClient/movie/PlayMovie.cs @@ -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; } diff --git a/BizHawk.MultiClient/movie/RecordMovie.cs b/BizHawk.MultiClient/movie/RecordMovie.cs index 19ca6bd754..c11eeacf13 100644 --- a/BizHawk.MultiClient/movie/RecordMovie.cs +++ b/BizHawk.MultiClient/movie/RecordMovie.cs @@ -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; diff --git a/BizHawk.MultiClient/movie/Subtitle.cs b/BizHawk.MultiClient/movie/Subtitle.cs deleted file mode 100644 index f9dc8e5501..0000000000 --- a/BizHawk.MultiClient/movie/Subtitle.cs +++ /dev/null @@ -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; - } - } -} diff --git a/BizHawk.MultiClient/movie/SubtitleList.cs b/BizHawk.MultiClient/movie/SubtitleList.cs deleted file mode 100644 index 45e00ab02e..0000000000 --- a/BizHawk.MultiClient/movie/SubtitleList.cs +++ /dev/null @@ -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 subs = new List(); - - 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(); - } - - /// - /// Manages the logic of what subtitle should be displayed on any given frame based on frame & duration - /// - /// - /// - 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 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; - } - - /// - /// Attempts to parse string for necessary subtitle information, required is a frame and a message, space delminated, the word subtitle assumed to be first - /// - /// - /// - 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)); - } - } - } -} \ No newline at end of file diff --git a/BizHawk.MultiClient/movie/SubtitleMaker.cs b/BizHawk.MultiClient/movie/SubtitleMaker.cs index 538512381b..0c6fa50f96 100644 --- a/BizHawk.MultiClient/movie/SubtitleMaker.cs +++ b/BizHawk.MultiClient/movie/SubtitleMaker.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class SubtitleMaker : Form diff --git a/BizHawk.MultiClient/tools/Cheats/Cheat.cs b/BizHawk.MultiClient/tools/Cheats/Cheat.cs deleted file mode 100644 index c085ebdfbf..0000000000 --- a/BizHawk.MultiClient/tools/Cheats/Cheat.cs +++ /dev/null @@ -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 - } -} diff --git a/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs b/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs index 03d8dc5899..06664f11eb 100644 --- a/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs +++ b/BizHawk.MultiClient/tools/Cheats/CheatEdit.Designer.cs @@ -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 // diff --git a/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs b/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs index 71b49948c1..018d31b8c8 100644 --- a/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs +++ b/BizHawk.MultiClient/tools/Cheats/CheatEdit.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/Cheats/CheatForm.cs b/BizHawk.MultiClient/tools/Cheats/CheatForm.cs index 4ec8e63958..245961f760 100644 --- a/BizHawk.MultiClient/tools/Cheats/CheatForm.cs +++ b/BizHawk.MultiClient/tools/Cheats/CheatForm.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/Cheats/CheatList.cs b/BizHawk.MultiClient/tools/Cheats/CheatList.cs deleted file mode 100644 index 595004ecd0..0000000000 --- a/BizHawk.MultiClient/tools/Cheats/CheatList.cs +++ /dev/null @@ -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 - { - private List _cheatList = new List(); - private string _currentFileName = String.Empty; - private bool _changes = false; - - public CheatList() { } - - public IEnumerator 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(); - } - } - - /// - /// Looks for a .cht file that matches the ROM loaded based on the default filename for a given ROM - /// - /// - 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 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 - } -} diff --git a/BizHawk.MultiClient/tools/GB/CGBColorChooserForm.cs b/BizHawk.MultiClient/tools/GB/CGBColorChooserForm.cs index e974c7798b..26bb9e794f 100644 --- a/BizHawk.MultiClient/tools/GB/CGBColorChooserForm.cs +++ b/BizHawk.MultiClient/tools/GB/CGBColorChooserForm.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/GB/ColorChooserForm.cs b/BizHawk.MultiClient/tools/GB/ColorChooserForm.cs index 337b031e1e..f9abe99ca1 100644 --- a/BizHawk.MultiClient/tools/GB/ColorChooserForm.cs +++ b/BizHawk.MultiClient/tools/GB/ColorChooserForm.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/GB/DualGBFileSelector.cs b/BizHawk.MultiClient/tools/GB/DualGBFileSelector.cs index e58461da12..2f5cf11e6e 100644 --- a/BizHawk.MultiClient/tools/GB/DualGBFileSelector.cs +++ b/BizHawk.MultiClient/tools/GB/DualGBFileSelector.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/GB/GBGPUView.cs b/BizHawk.MultiClient/tools/GB/GBGPUView.cs index 9e51701ff4..730728d38b 100644 --- a/BizHawk.MultiClient/tools/GB/GBGPUView.cs +++ b/BizHawk.MultiClient/tools/GB/GBGPUView.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/GB/GBGameGenie.cs b/BizHawk.MultiClient/tools/GB/GBGameGenie.cs index 60dc69c8b5..cff5f946b6 100644 --- a/BizHawk.MultiClient/tools/GB/GBGameGenie.cs +++ b/BizHawk.MultiClient/tools/GB/GBGameGenie.cs @@ -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(); } } diff --git a/BizHawk.MultiClient/tools/GBA/GBAGPUView.cs b/BizHawk.MultiClient/tools/GBA/GBAGPUView.cs index 2d78f33b40..33b8bc6718 100644 --- a/BizHawk.MultiClient/tools/GBA/GBAGPUView.cs +++ b/BizHawk.MultiClient/tools/GBA/GBAGPUView.cs @@ -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 diff --git a/BizHawk.MultiClient/tools/Genesis/GenGameGenie.cs b/BizHawk.MultiClient/tools/Genesis/GenGameGenie.cs index afcb3b0c23..324244530e 100644 --- a/BizHawk.MultiClient/tools/Genesis/GenGameGenie.cs +++ b/BizHawk.MultiClient/tools/Genesis/GenGameGenie.cs @@ -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(); } } diff --git a/BizHawk.MultiClient/tools/HexEditor/HexColor.cs b/BizHawk.MultiClient/tools/HexEditor/HexColor.cs index e82ee085ea..ac606925ed 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexColor.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexColor.cs @@ -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; } } diff --git a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs index 3d611be67f..077b7a035c 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexEditor.cs @@ -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); } } diff --git a/BizHawk.MultiClient/tools/HexEditor/HexFind.cs b/BizHawk.MultiClient/tools/HexEditor/HexFind.cs index 2f8ecf8108..c0a0d3427e 100644 --- a/BizHawk.MultiClient/tools/HexEditor/HexFind.cs +++ b/BizHawk.MultiClient/tools/HexEditor/HexFind.cs @@ -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); } } } diff --git a/BizHawk.MultiClient/tools/HexEditor/MemoryViewer.cs b/BizHawk.MultiClient/tools/HexEditor/MemoryViewer.cs index 0eeb7b5cd5..61ba8ff484 100644 --- a/BizHawk.MultiClient/tools/HexEditor/MemoryViewer.cs +++ b/BizHawk.MultiClient/tools/HexEditor/MemoryViewer.cs @@ -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) { diff --git a/BizHawk.MultiClient/tools/InputPrompt.cs b/BizHawk.MultiClient/tools/InputPrompt.cs index dcbe39807a..ec438f67df 100644 --- a/BizHawk.MultiClient/tools/InputPrompt.cs +++ b/BizHawk.MultiClient/tools/InputPrompt.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { /// diff --git a/BizHawk.MultiClient/tools/Lua/LuaConsole.cs b/BizHawk.MultiClient/tools/Lua/LuaConsole.cs index fa02cbf57e..551de905f2 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaConsole.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaConsole.cs @@ -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(); } } } diff --git a/BizHawk.MultiClient/tools/Lua/LuaDocumentation.cs b/BizHawk.MultiClient/tools/Lua/LuaDocumentation.cs index 4a74ff96dc..8397789852 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaDocumentation.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaDocumentation.cs @@ -3,7 +3,7 @@ using System.Linq; using System.Text; -namespace BizHawk.MultiClient.tools +namespace BizHawk.MultiClient { public class LuaDocumentation { diff --git a/BizHawk.MultiClient/tools/Lua/LuaFunctionList.cs b/BizHawk.MultiClient/tools/Lua/LuaFunctionList.cs index 0d5a7f65f8..63cd5b5a3f 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaFunctionList.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaFunctionList.cs @@ -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"); } diff --git a/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs b/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs index 495ef0f0f8..e8c887a42a 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaImplementation.cs @@ -8,10 +8,12 @@ using System.Drawing; using System.Threading; using System.Globalization; +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.Nintendo; -using BizHawk.MultiClient.tools; using System.Text; +using BizHawk.MultiClient.tools; //TODO: remove me, this is not an intended namespace + namespace BizHawk.MultiClient { public class LuaImplementation @@ -561,7 +563,7 @@ namespace BizHawk.MultiClient public void client_closerom() { - Global.MainForm.CloseROM(); + GlobalWinF.MainForm.CloseROM(); } public int client_getwindowsize() @@ -571,74 +573,74 @@ namespace BizHawk.MultiClient public void client_opencheats() { - Global.MainForm.LoadCheatsWindow(); + GlobalWinF.MainForm.LoadCheatsWindow(); } public void client_openhexeditor() { - Global.MainForm.LoadHexEditor(); + GlobalWinF.MainForm.LoadHexEditor(); } public void client_openramwatch() { - Global.MainForm.LoadRamWatch(true); + GlobalWinF.MainForm.LoadRamWatch(true); } public void client_openramsearch() { - Global.MainForm.LoadRamSearch(); + GlobalWinF.MainForm.LoadRamSearch(); } public void client_openrom(object lua_input) { - Global.MainForm.LoadRom(lua_input.ToString()); + GlobalWinF.MainForm.LoadRom(lua_input.ToString()); } public void client_opentasstudio() { - Global.MainForm.LoadTAStudio(); + GlobalWinF.MainForm.LoadTAStudio(); } public void client_opentoolbox() { - Global.MainForm.LoadToolBox(); + GlobalWinF.MainForm.LoadToolBox(); } public void client_opentracelogger() { - Global.MainForm.LoadTraceLogger(); + GlobalWinF.MainForm.LoadTraceLogger(); } public void client_pause_av() { - Global.MainForm.PauseAVI = true; + GlobalWinF.MainForm.PauseAVI = true; } public void client_reboot_core() { - Global.MainForm.RebootCore(); + GlobalWinF.MainForm.RebootCore(); } public int client_screenheight() { - return Global.RenderPanel.NativeSize.Height; + return GlobalWinF.RenderPanel.NativeSize.Height; } public void client_screenshot(object path = null) { if (path == null) { - Global.MainForm.TakeScreenshot(); + GlobalWinF.MainForm.TakeScreenshot(); } else { - Global.MainForm.TakeScreenshot(path.ToString()); + GlobalWinF.MainForm.TakeScreenshot(path.ToString()); } } public void client_screenshottoclipboard() { - Global.MainForm.TakeScreenshotToClipboard(); + GlobalWinF.MainForm.TakeScreenshotToClipboard(); } public void client_setscreenshotosd(bool value) @@ -648,7 +650,7 @@ namespace BizHawk.MultiClient public int client_screenwidth() { - return Global.RenderPanel.NativeSize.Width; + return GlobalWinF.RenderPanel.NativeSize.Width; } public void client_setwindowsize(object window_size) @@ -660,8 +662,8 @@ namespace BizHawk.MultiClient if (size == 1 || size == 2 || size == 3 || size == 4 || size == 5 || size == 10) { Global.Config.TargetZoomFactor = size; - Global.MainForm.FrameBufferResized(); - Global.OSD.AddMessage("Window size set to " + size.ToString() + "x"); + GlobalWinF.MainForm.FrameBufferResized(); + GlobalWinF.OSD.AddMessage("Window size set to " + size.ToString() + "x"); } else { @@ -677,17 +679,17 @@ namespace BizHawk.MultiClient public void client_unpause_av() { - Global.MainForm.PauseAVI = false; + GlobalWinF.MainForm.PauseAVI = false; } public int client_xpos() { - return Global.MainForm.DesktopLocation.X; + return GlobalWinF.MainForm.DesktopLocation.X; } public int client_ypos() { - return Global.MainForm.DesktopLocation.Y; + return GlobalWinF.MainForm.DesktopLocation.Y; } #endregion @@ -696,13 +698,13 @@ namespace BizHawk.MultiClient public void console_clear() { - Global.MainForm.LuaConsole1.ClearOutputWindow(); + GlobalWinF.MainForm.LuaConsole1.ClearOutputWindow(); } public string console_getluafunctionslist() { string list = ""; - foreach (LuaDocumentation.LibraryFunction l in Global.MainForm.LuaConsole1.LuaImp.docs.FunctionList) + foreach (LuaDocumentation.LibraryFunction l in GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.FunctionList) { list += l.name + "\n"; } @@ -719,7 +721,7 @@ namespace BizHawk.MultiClient { if (lua_input == null) { - Global.MainForm.LuaConsole1.WriteToOutputWindow("NULL"); + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow("NULL"); } else { @@ -754,11 +756,11 @@ namespace BizHawk.MultiClient .AppendLine(); } - Global.MainForm.LuaConsole1.WriteToOutputWindow(sb.ToString()); + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow(sb.ToString()); } else { - Global.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString()); + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow(lua_input.ToString()); } } } @@ -810,7 +812,7 @@ namespace BizHawk.MultiClient public void gui_clearGraphics() { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; luaSurface.Clear(); } @@ -823,12 +825,12 @@ namespace BizHawk.MultiClient /// public void gui_drawNew() { - luaSurface = Global.DisplayManager.GetLuaSurfaceNative(); + luaSurface = GlobalWinF.DisplayManager.GetLuaSurfaceNative(); } public void gui_drawNewEmu() { - luaSurface = Global.DisplayManager.GetLuaEmuSurfaceEmu(); + luaSurface = GlobalWinF.DisplayManager.GetLuaEmuSurfaceEmu(); } /// @@ -838,13 +840,13 @@ namespace BizHawk.MultiClient /// public void gui_drawFinish() { - Global.DisplayManager.SetLuaSurfaceNativePreOSD(luaSurface); + GlobalWinF.DisplayManager.SetLuaSurfaceNativePreOSD(luaSurface); luaSurface = null; } public void gui_drawFinishEmu() { - Global.DisplayManager.SetLuaSurfaceEmu(luaSurface); + GlobalWinF.DisplayManager.SetLuaSurfaceEmu(luaSurface); luaSurface = null; } @@ -905,14 +907,14 @@ namespace BizHawk.MultiClient dx *= client_getwindowsize(); dy *= client_getwindowsize(); - Global.OSD.AddGUIText(luaStr.ToString(), dx, dy, alert, GetColor(background), GetColor(forecolor), a); + GlobalWinF.OSD.AddGUIText(luaStr.ToString(), dx, dy, alert, GetColor(background), GetColor(forecolor), a); } #endregion public void gui_addmessage(object luaStr) { - Global.OSD.AddMessage(luaStr.ToString()); + GlobalWinF.OSD.AddMessage(luaStr.ToString()); } public void gui_alert(object luaX, object luaY, object luaStr, object anchor = null) @@ -922,12 +924,12 @@ namespace BizHawk.MultiClient public void gui_cleartext() { - Global.OSD.ClearGUIText(); + GlobalWinF.OSD.ClearGUIText(); } public void gui_drawBezier(LuaTable points, object color) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -998,7 +1000,7 @@ namespace BizHawk.MultiClient public void gui_drawEllipse(object X, object Y, object width, object height, object line, object background = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1020,7 +1022,7 @@ namespace BizHawk.MultiClient public void gui_drawIcon(object Path, object x, object y, object width = null, object height = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1046,7 +1048,7 @@ namespace BizHawk.MultiClient public void gui_drawImage(object Path, object x, object y, object width = null, object height = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1069,7 +1071,7 @@ namespace BizHawk.MultiClient public void gui_drawLine(object x1, object y1, object x2, object y2, object color = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1086,7 +1088,7 @@ namespace BizHawk.MultiClient public void gui_drawPie(object X, object Y, object width, object height, object startangle, object sweepangle, object line, object background = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1109,7 +1111,7 @@ namespace BizHawk.MultiClient public void gui_drawPixel(object X, object Y, object color = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { float x = LuaInt(X) + 0.1F; @@ -1126,7 +1128,7 @@ namespace BizHawk.MultiClient public void gui_drawPolygon(LuaTable points, object line, object background = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; //this is a test using (var g = GetGraphics()) { @@ -1181,13 +1183,13 @@ namespace BizHawk.MultiClient public void gui_drawString(object X, object Y, object message, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; gui_drawText(X, Y, message, color, fontsize, fontfamily, fontstyle); } public void gui_drawText(object X, object Y, object message, object color = null, object fontsize = null, object fontfamily = null, object fontstyle = null) { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; using (var g = GetGraphics()) { try @@ -1255,23 +1257,23 @@ namespace BizHawk.MultiClient { if (Global.Emulator is NES) { - Global.CoreComm.NES_ShowOBJ = Global.Config.NESDispSprites = (bool)lua_p[0]; - Global.CoreComm.NES_ShowBG = Global.Config.NESDispBackground = (bool)lua_p[1]; + GlobalWinF.CoreComm.NES_ShowOBJ = Global.Config.NESDispSprites = (bool)lua_p[0]; + GlobalWinF.CoreComm.NES_ShowBG = Global.Config.NESDispBackground = (bool)lua_p[1]; } else if (Global.Emulator is Emulation.Consoles.TurboGrafx.PCEngine) { - Global.CoreComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1 = (bool)lua_p[0]; - Global.CoreComm.PCE_ShowBG1 = Global.Config.PCEDispBG1 = (bool)lua_p[1]; + GlobalWinF.CoreComm.PCE_ShowOBJ1 = Global.Config.PCEDispOBJ1 = (bool)lua_p[0]; + GlobalWinF.CoreComm.PCE_ShowBG1 = Global.Config.PCEDispBG1 = (bool)lua_p[1]; if (lua_p.Length > 2) { - Global.CoreComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2 = (bool)lua_p[2]; - Global.CoreComm.PCE_ShowBG2 = Global.Config.PCEDispBG2 = (bool)lua_p[3]; + GlobalWinF.CoreComm.PCE_ShowOBJ2 = Global.Config.PCEDispOBJ2 = (bool)lua_p[2]; + GlobalWinF.CoreComm.PCE_ShowBG2 = Global.Config.PCEDispBG2 = (bool)lua_p[3]; } } else if (Global.Emulator is Emulation.Consoles.Sega.SMS) { - Global.CoreComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ = (bool)lua_p[0]; - Global.CoreComm.SMS_ShowBG = Global.Config.SMSDispBG = (bool)lua_p[1]; + GlobalWinF.CoreComm.SMS_ShowOBJ = Global.Config.SMSDispOBJ = (bool)lua_p[0]; + GlobalWinF.CoreComm.SMS_ShowBG = Global.Config.SMSDispBG = (bool)lua_p[1]; } } @@ -1290,7 +1292,7 @@ namespace BizHawk.MultiClient { Global.Config.VSyncThrottle = true; } - Global.MainForm.VsyncMessage(); + GlobalWinF.MainForm.VsyncMessage(); } } @@ -1301,13 +1303,13 @@ namespace BizHawk.MultiClient { if (temp == "0" || temp.ToLower() == "false") { - Global.MainForm.RewindActive = false; - Global.OSD.AddMessage("Rewind suspended"); + GlobalWinF.MainForm.RewindActive = false; + GlobalWinF.OSD.AddMessage("Rewind suspended"); } else { - Global.MainForm.RewindActive = true; - Global.OSD.AddMessage("Rewind enabled"); + GlobalWinF.MainForm.RewindActive = true; + GlobalWinF.OSD.AddMessage("Rewind enabled"); } } } @@ -1332,7 +1334,7 @@ namespace BizHawk.MultiClient if (frames > 0) { Global.Config.FrameSkip = frames; - Global.MainForm.FrameSkipMessage(); + GlobalWinF.MainForm.FrameSkipMessage(); } else { @@ -1357,7 +1359,7 @@ namespace BizHawk.MultiClient public bool emu_ispaused() { - return Global.MainForm.EmulatorPaused; + return GlobalWinF.MainForm.EmulatorPaused; } public int emu_lagcount() @@ -1378,7 +1380,7 @@ namespace BizHawk.MultiClient { Global.Config.ClockThrottle = true; } - Global.MainForm.LimitFrameRateMessage(); + GlobalWinF.MainForm.LimitFrameRateMessage(); } } @@ -1395,7 +1397,7 @@ namespace BizHawk.MultiClient { Global.Config.AutoMinimizeSkipping = true; } - Global.MainForm.MinimizeFrameskipMessage(); + GlobalWinF.MainForm.MinimizeFrameskipMessage(); } } @@ -1411,7 +1413,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function emu.on_snoop" + "\nError message: " + e.Message); } @@ -1423,7 +1425,7 @@ namespace BizHawk.MultiClient public void emu_pause() { - Global.MainForm.PauseEmulator(); + GlobalWinF.MainForm.PauseEmulator(); } public void emu_setrenderplanes( // For now, it accepts arguments up to 5. @@ -1441,7 +1443,7 @@ namespace BizHawk.MultiClient int speed = Convert.ToInt32(temp); if (speed > 0 && speed < 1000) //arbituarily capping it at 1000% { - Global.MainForm.ClickSpeedItem(speed); + GlobalWinF.MainForm.ClickSpeedItem(speed); } else { @@ -1456,17 +1458,17 @@ namespace BizHawk.MultiClient public void emu_togglepause() { - Global.MainForm.TogglePause(); + GlobalWinF.MainForm.TogglePause(); } public void emu_unpause() { - Global.MainForm.UnpauseEmulator(); + GlobalWinF.MainForm.UnpauseEmulator(); } public void emu_yield() { - Global.DisplayManager.NeedsToPaint = true; + GlobalWinF.DisplayManager.NeedsToPaint = true; currThread.Yield(0); } @@ -1494,7 +1496,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function savestate.registersave" + "\nError message: " + e.Message); } @@ -1515,7 +1517,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function savestate.registerload" + "\nError message: " + e.Message); } @@ -1536,7 +1538,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function emu.registerbefore" + "\nError message: " + e.Message); } @@ -1557,7 +1559,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function emu.registerafter" + "\nError message: " + e.Message); } @@ -1614,7 +1616,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function event.onmemoryread" + "\nError message: " + e.Message); } @@ -1651,7 +1653,7 @@ namespace BizHawk.MultiClient } catch (SystemException e) { - Global.MainForm.LuaConsole1.WriteToOutputWindow( + GlobalWinF.MainForm.LuaConsole1.WriteToOutputWindow( "error running function attached by lua function event.onmemoryread" + "\nError message: " + e.Message); } @@ -2108,7 +2110,7 @@ namespace BizHawk.MultiClient public LuaTable input_get() { LuaTable buttons = _lua.NewTable(); - foreach (var kvp in Global.ControllerInputCoalescer.BoolButtons()) + foreach (var kvp in GlobalWinF.ControllerInputCoalescer.BoolButtons()) if (kvp.Value) buttons[kvp.Key] = true; return buttons; @@ -2117,7 +2119,7 @@ namespace BizHawk.MultiClient public LuaTable input_getmouse() { LuaTable buttons = _lua.NewTable(); - Point p = Global.RenderPanel.ScreenToScreen(Control.MousePosition); + Point p = GlobalWinF.RenderPanel.ScreenToScreen(Control.MousePosition); buttons["X"] = p.X; buttons["Y"] = p.Y; buttons[MouseButtons.Left.ToString()] = (Control.MouseButtons & MouseButtons.Left) != 0; @@ -2136,27 +2138,27 @@ namespace BizHawk.MultiClient public LuaTable joypad_get(object controller = null) { LuaTable buttons = _lua.NewTable(); - foreach (string button in Global.ControllerOutput.Source.Type.BoolButtons) + foreach (string button in GlobalWinF.ControllerOutput.Source.Type.BoolButtons) { if (controller == null) { - buttons[button] = Global.ControllerOutput[button]; + buttons[button] = GlobalWinF.ControllerOutput[button]; } else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString()) { - buttons[button.Substring(3)] = Global.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)]; + buttons[button.Substring(3)] = GlobalWinF.ControllerOutput["P" + LuaInt(controller) + " " + button.Substring(3)]; } } - foreach (string button in Global.ControllerOutput.Source.Type.FloatControls) + foreach (string button in GlobalWinF.ControllerOutput.Source.Type.FloatControls) { if (controller == null) { - buttons[button] = Global.ControllerOutput.GetFloat(button); + buttons[button] = GlobalWinF.ControllerOutput.GetFloat(button); } else if (button.Length >= 3 && button.Substring(0, 2) == "P" + LuaInt(controller).ToString()) { - buttons[button.Substring(3)] = Global.ControllerOutput.GetFloat("P" + LuaInt(controller) + " " + button.Substring(3)); + buttons[button.Substring(3)] = GlobalWinF.ControllerOutput.GetFloat("P" + LuaInt(controller) + " " + button.Substring(3)); } } @@ -2170,8 +2172,8 @@ namespace BizHawk.MultiClient public LuaTable joypad_getimmediate() { LuaTable buttons = _lua.NewTable(); - foreach (string button in Global.ActiveController.Type.BoolButtons) - buttons[button] = Global.ActiveController[button]; + foreach (string button in GlobalWinF.ActiveController.Type.BoolButtons) + buttons[button] = GlobalWinF.ActiveController[button]; return buttons; } @@ -2213,24 +2215,24 @@ namespace BizHawk.MultiClient { if (controller == null) //Force On { - Global.ClickyVirtualPadController.Click(button.ToString()); - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); + GlobalWinF.ClickyVirtualPadController.Click(button.ToString()); + GlobalWinF.ForceOffAdaptor.SetSticky(button.ToString(), false); } else { - Global.ClickyVirtualPadController.Click("P" + controller + " " + button); - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); + GlobalWinF.ClickyVirtualPadController.Click("P" + controller + " " + button); + GlobalWinF.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); } } else if (theValue == false) //Force off { if (controller == null) { - Global.ForceOffAdaptor.SetSticky(button.ToString(), true); + GlobalWinF.ForceOffAdaptor.SetSticky(button.ToString(), true); } else { - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, true); + GlobalWinF.ForceOffAdaptor.SetSticky("P" + controller + " " + button, true); } } else @@ -2238,11 +2240,11 @@ namespace BizHawk.MultiClient //Turn everything off if (controller == null) { - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); + GlobalWinF.ForceOffAdaptor.SetSticky(button.ToString(), false); } else { - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); + GlobalWinF.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); } } } @@ -2250,13 +2252,13 @@ namespace BizHawk.MultiClient { if (controller == null) { - Global.StickyXORAdapter.SetSticky(button.ToString(), true); - Global.ForceOffAdaptor.SetSticky(button.ToString(), false); + GlobalWinF.StickyXORAdapter.SetSticky(button.ToString(), true); + GlobalWinF.ForceOffAdaptor.SetSticky(button.ToString(), false); } else { - Global.StickyXORAdapter.SetSticky("P" + controller + " " + button, true); - Global.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); + GlobalWinF.StickyXORAdapter.SetSticky("P" + controller + " " + button, true); + GlobalWinF.ForceOffAdaptor.SetSticky("P" + controller + " " + button, false); } } } @@ -2279,11 +2281,11 @@ namespace BizHawk.MultiClient float theValue = float.Parse(theValueStr); if (controller == null) { - Global.StickyXORAdapter.SetFloat(name.ToString(), theValue); + GlobalWinF.StickyXORAdapter.SetFloat(name.ToString(), theValue); } else { - Global.StickyXORAdapter.SetFloat("P" + controller + " " + name, theValue); + GlobalWinF.StickyXORAdapter.SetFloat("P" + controller + " " + name, theValue); } } catch { } @@ -2951,7 +2953,7 @@ namespace BizHawk.MultiClient public bool movie_getreadonly() { - return Global.MainForm.ReadOnly; + return GlobalWinF.MainForm.ReadOnly; } public bool movie_getrerecordcounting() @@ -3011,9 +3013,9 @@ namespace BizHawk.MultiClient public void movie_setreadonly(object lua_input) { if (lua_input.ToString().ToUpper() == "TRUE" || lua_input.ToString() == "1") - Global.MainForm.SetReadOnly(true); + GlobalWinF.MainForm.SetReadOnly(true); else - Global.MainForm.SetReadOnly(false); + GlobalWinF.MainForm.SetReadOnly(false); } public void movie_setrerecordcounting(object lua_input) @@ -3055,6 +3057,8 @@ namespace BizHawk.MultiClient gg.Compare, enabled: true)); } + + ToolHelpers.UpdateCheatRelatedTools(); } } @@ -3113,6 +3117,8 @@ namespace BizHawk.MultiClient var cheats = Global.CheatList.Where(x => x.Address == gg.Address); Global.CheatList.RemoveRange(cheats); } + + ToolHelpers.UpdateCheatRelatedTools(); } } @@ -3137,13 +3143,13 @@ namespace BizHawk.MultiClient public void nes_setdispbackground(bool show) { Global.Config.NESDispBackground = show; - Global.MainForm.SyncCoreCommInputSignals(); + GlobalWinF.MainForm.SyncCoreCommInputSignals(); } public void nes_setdispsprites(bool show) { Global.Config.NESDispSprites = show; - Global.MainForm.SyncCoreCommInputSignals(); + GlobalWinF.MainForm.SyncCoreCommInputSignals(); } public void nes_setscanlines(object top, object bottom, bool pal = false) @@ -3203,7 +3209,7 @@ namespace BizHawk.MultiClient { if (lua_input is string) { - Global.MainForm.LoadStateFile(lua_input.ToString(), Path.GetFileName(lua_input.ToString()), true); + GlobalWinF.MainForm.LoadStateFile(lua_input.ToString(), Path.GetFileName(lua_input.ToString()), true); } } @@ -3223,7 +3229,7 @@ namespace BizHawk.MultiClient if (x < 0 || x > 9) return; - Global.MainForm.LoadState("QuickSave" + x.ToString(), true); + GlobalWinF.MainForm.LoadState("QuickSave" + x.ToString(), true); } public string savestate_registerload(LuaFunction luaf, object name) @@ -3245,7 +3251,7 @@ namespace BizHawk.MultiClient if (lua_input is string) { string path = lua_input.ToString(); - Global.MainForm.SaveStateFile(path, path, true); + GlobalWinF.MainForm.SaveStateFile(path, path, true); } } @@ -3265,7 +3271,7 @@ namespace BizHawk.MultiClient if (x < 0 || x > 9) return; - Global.MainForm.SaveState("QuickSave" + x.ToString()); + GlobalWinF.MainForm.SaveState("QuickSave" + x.ToString()); } #endregion @@ -3314,42 +3320,42 @@ namespace BizHawk.MultiClient public void snes_setlayer_bg_1(bool value) { - Global.MainForm.SNES_ToggleBG1(value); + GlobalWinF.MainForm.SNES_ToggleBG1(value); } public void snes_setlayer_bg_2(bool value) { - Global.MainForm.SNES_ToggleBG2(value); + GlobalWinF.MainForm.SNES_ToggleBG2(value); } public void snes_setlayer_bg_3(bool value) { - Global.MainForm.SNES_ToggleBG3(value); + GlobalWinF.MainForm.SNES_ToggleBG3(value); } public void snes_setlayer_bg_4(bool value) { - Global.MainForm.SNES_ToggleBG4(value); + GlobalWinF.MainForm.SNES_ToggleBG4(value); } public void snes_setlayer_obj_1(bool value) { - Global.MainForm.SNES_ToggleOBJ1(value); + GlobalWinF.MainForm.SNES_ToggleOBJ1(value); } public void snes_setlayer_obj_2(bool value) { - Global.MainForm.SNES_ToggleOBJ2(value); + GlobalWinF.MainForm.SNES_ToggleOBJ2(value); } public void snes_setlayer_obj_3(bool value) { - Global.MainForm.SNES_ToggleOBJ3(value); + GlobalWinF.MainForm.SNES_ToggleOBJ3(value); } public void snes_setlayer_obj_4(bool value) { - Global.MainForm.SNES_ToggleOBJ4(value); + GlobalWinF.MainForm.SNES_ToggleOBJ4(value); } #endregion diff --git a/BizHawk.MultiClient/tools/Lua/LuaRegisteredFunctionsList.cs b/BizHawk.MultiClient/tools/Lua/LuaRegisteredFunctionsList.cs index 7a55302702..74ba8dbff4 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaRegisteredFunctionsList.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaRegisteredFunctionsList.cs @@ -30,7 +30,7 @@ namespace BizHawk.MultiClient { FunctionView.Items.Clear(); - List nlfs = Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name).ToList(); + List nlfs = GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.OrderBy(x => x.Event).ThenBy(x => x.Name).ToList(); foreach (NamedLuaFunction nlf in nlfs) { ListViewItem item = new ListViewItem { Text = nlf.Event }; @@ -55,7 +55,7 @@ namespace BizHawk.MultiClient ListView.SelectedIndexCollection indexes = FunctionView.SelectedIndices; if (indexes.Count > 0) { - Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions[indexes[0]].Call(); + GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions[indexes[0]].Call(); } } @@ -64,8 +64,8 @@ namespace BizHawk.MultiClient ListView.SelectedIndexCollection indexes = FunctionView.SelectedIndices; if (indexes.Count > 0) { - NamedLuaFunction nlf = Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions[indexes[0]]; - Global.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Remove(nlf); + NamedLuaFunction nlf = GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions[indexes[0]]; + GlobalWinF.MainForm.LuaConsole1.LuaImp.RegisteredFunctions.Remove(nlf); PopulateListView(); } } diff --git a/BizHawk.MultiClient/tools/Lua/LuaTextBox.cs b/BizHawk.MultiClient/tools/Lua/LuaTextBox.cs index 9dae008d77..234b33c50b 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaTextBox.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaTextBox.cs @@ -1,5 +1,7 @@ using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient.tools { enum BoxType { ALL, SIGNED, UNSIGNED, HEX }; diff --git a/BizHawk.MultiClient/tools/Lua/LuaWinform.Designer.cs b/BizHawk.MultiClient/tools/Lua/LuaWinform.Designer.cs index 97924bcf96..3f4725fb72 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaWinform.Designer.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaWinform.Designer.cs @@ -1,4 +1,4 @@ -namespace BizHawk.MultiClient.tools +namespace BizHawk.MultiClient { partial class LuaWinform { diff --git a/BizHawk.MultiClient/tools/Lua/LuaWinform.cs b/BizHawk.MultiClient/tools/Lua/LuaWinform.cs index 0274036160..31ef3c08db 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaWinform.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaWinform.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Windows.Forms; using LuaInterface; -namespace BizHawk.MultiClient.tools +namespace BizHawk.MultiClient { public partial class LuaWinform : Form { @@ -22,7 +22,7 @@ namespace BizHawk.MultiClient.tools public void CloseThis() { - Global.MainForm.LuaConsole1.LuaImp.WindowClosed(Handle); + GlobalWinF.MainForm.LuaConsole1.LuaImp.WindowClosed(Handle); } public void DoLuaEvent(IntPtr handle) diff --git a/BizHawk.MultiClient/tools/Lua/LuaWriter.cs b/BizHawk.MultiClient/tools/Lua/LuaWriter.cs index a7b6ce86de..9543a4acea 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaWriter.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaWriter.cs @@ -6,7 +6,8 @@ using System.Text; using System.Windows.Forms; using System.Text.RegularExpressions; using System.IO; -using BizHawk.MultiClient.tools; + +using BizHawk.Client.Common; namespace BizHawk.MultiClient { @@ -433,7 +434,7 @@ namespace BizHawk.MultiClient private void GenerateLibraryRegex() { StringBuilder list = new StringBuilder(); - List Libs = Global.MainForm.LuaConsole1.LuaImp.docs.GetLibraryList(); + List Libs = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.GetLibraryList(); for (int i = 0; i < Libs.Count; i++) { list.Append(Libs[i]); @@ -576,9 +577,9 @@ namespace BizHawk.MultiClient } sfd.Filter = "Watch Files (*.lua)|*.lua|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); @@ -658,7 +659,7 @@ namespace BizHawk.MultiClient string currentword = CurrentWord(); if (IsLibraryWord(currentword)) { - List libfunctions = Global.MainForm.LuaConsole1.LuaImp.docs.GetFunctionsByLibrary(currentword); + List libfunctions = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.GetFunctionsByLibrary(currentword); // Position autocomplete box near the cursor's current position int x = LuaText.GetPositionFromCharIndex(LuaText.SelectionStart).X + LuaText.Location.X + 5; @@ -782,7 +783,7 @@ namespace BizHawk.MultiClient private bool IsLibraryWord(string word) { - List Libs = Global.MainForm.LuaConsole1.LuaImp.docs.GetLibraryList(); + List Libs = GlobalWinF.MainForm.LuaConsole1.LuaImp.docs.GetLibraryList(); if (Libs.Contains(word)) { return true; diff --git a/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.Designer.cs b/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.Designer.cs index 470e28603a..6ac03000b9 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.Designer.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.Designer.cs @@ -1,4 +1,4 @@ -namespace BizHawk.MultiClient.tools +namespace BizHawk.MultiClient { partial class LuaWriterColorConfig { diff --git a/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.cs b/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.cs index 0af412f0d5..850ce6b138 100644 --- a/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.cs +++ b/BizHawk.MultiClient/tools/Lua/LuaWriterColorConfig.cs @@ -2,40 +2,42 @@ using System.Drawing; using System.Windows.Forms; -namespace BizHawk.MultiClient.tools +using BizHawk.Client.Common; + +namespace BizHawk.MultiClient { public partial class LuaWriterColorConfig : Form { - //Get existing global Lua color settings + //Get existing global Lua color settings int TextColor = Global.Config.LuaDefaultTextColor; - int KeyWordColor = Global.Config.LuaKeyWordColor; - int CommentColor = Global.Config.LuaCommentColor; - int StringColor = Global.Config.LuaStringColor; - int SymbolColor = Global.Config.LuaSymbolColor; - int LibraryColor = Global.Config.LuaLibraryColor; + int KeyWordColor = Global.Config.LuaKeyWordColor; + int CommentColor = Global.Config.LuaCommentColor; + int StringColor = Global.Config.LuaStringColor; + int SymbolColor = Global.Config.LuaSymbolColor; + int LibraryColor = Global.Config.LuaLibraryColor; public LuaWriterColorConfig() { InitializeComponent(); } - private void LuaWriterColorConfig_Load(object sender, EventArgs e) - { - //Set the initial colors into the panels + private void LuaWriterColorConfig_Load(object sender, EventArgs e) + { + //Set the initial colors into the panels SetTextColor(TextColor); - SetKeyWordColor(KeyWordColor); - SetCommentColor(CommentColor); - SetStringColor(StringColor); - SetSymbolColor(SymbolColor); - SetLibraryColor(LibraryColor); + SetKeyWordColor(KeyWordColor); + SetCommentColor(CommentColor); + SetStringColor(StringColor); + SetSymbolColor(SymbolColor); + SetLibraryColor(LibraryColor); BoldText.Checked = Global.Config.LuaDefaultTextBold; - BoldKeyWords.Checked = Global.Config.LuaKeyWordBold; - BoldComments.Checked = Global.Config.LuaCommentBold; - BoldStrings.Checked = Global.Config.LuaStringBold; - BoldSymbols.Checked = Global.Config.LuaSymbolBold; - BoldLibraries.Checked = Global.Config.LuaLibraryBold; - } + BoldKeyWords.Checked = Global.Config.LuaKeyWordBold; + BoldComments.Checked = Global.Config.LuaCommentBold; + BoldStrings.Checked = Global.Config.LuaStringBold; + BoldSymbols.Checked = Global.Config.LuaSymbolBold; + BoldLibraries.Checked = Global.Config.LuaLibraryBold; + } private void SetTextColor(int color) { @@ -43,35 +45,35 @@ namespace BizHawk.MultiClient.tools panelText.BackColor = Color.FromArgb(color); //Update panel color with new selection } - private void SetKeyWordColor(int color) - { - KeyWordColor = color; //Set new color - panelKeyWord.BackColor = Color.FromArgb(color); //Update panel color with new selection - } + private void SetKeyWordColor(int color) + { + KeyWordColor = color; //Set new color + panelKeyWord.BackColor = Color.FromArgb(color); //Update panel color with new selection + } - private void SetCommentColor(int color) - { - CommentColor = color; //Set new color - panelComment.BackColor = Color.FromArgb(color); //Update panel color with new selection - } + private void SetCommentColor(int color) + { + CommentColor = color; //Set new color + panelComment.BackColor = Color.FromArgb(color); //Update panel color with new selection + } - private void SetStringColor(int color) - { - StringColor = color; //Set new color - panelString.BackColor = Color.FromArgb(color); //Update panel color with new selection - } + private void SetStringColor(int color) + { + StringColor = color; //Set new color + panelString.BackColor = Color.FromArgb(color); //Update panel color with new selection + } - private void SetSymbolColor(int color) - { - SymbolColor = color; //Set new color - panelSymbol.BackColor = Color.FromArgb(color); //Update panel color with new selection - } + private void SetSymbolColor(int color) + { + SymbolColor = color; //Set new color + panelSymbol.BackColor = Color.FromArgb(color); //Update panel color with new selection + } - private void SetLibraryColor(int color) - { - LibraryColor = color; //Set new color + private void SetLibraryColor(int color) + { + LibraryColor = color; //Set new color panelLibrary.BackColor = Color.FromArgb(color); //Update panel color with new selection - } + } //Pop up color dialog when double-clicked private void panelText_DoubleClick(object sender, EventArgs e) @@ -82,93 +84,93 @@ namespace BizHawk.MultiClient.tools } } - //Pop up color dialog when double-clicked - private void panelKeyWord_DoubleClick(object sender, EventArgs e) - { - if (KeyWordColorDialog.ShowDialog() == DialogResult.OK) - { - SetKeyWordColor(KeyWordColorDialog.Color.ToArgb()); - } - } - - //Pop up color dialog when double-clicked - private void panelComment_DoubleClick(object sender, EventArgs e) - { - if (CommentColorDialog.ShowDialog() == DialogResult.OK) - { - SetCommentColor(CommentColorDialog.Color.ToArgb()); - } - } - - //Pop up color dialog when double-clicked - private void panelString_DoubleClick(object sender, EventArgs e) - { - if (StringColorDialog.ShowDialog() == DialogResult.OK) - { - SetStringColor(StringColorDialog.Color.ToArgb()); - } - } - - //Pop up color dialog when double-clicked - private void panelSymbol_DoubleClick(object sender, EventArgs e) - { - if (SymbolColorDialog.ShowDialog() == DialogResult.OK) - { - SetSymbolColor(SymbolColorDialog.Color.ToArgb()); - } - } - - //Pop up color dialog when double-clicked - private void panelLibrary_DoubleClick(object sender, EventArgs e) - { - if (LibraryColorDialog.ShowDialog() == DialogResult.OK) - { - SetLibraryColor(LibraryColorDialog.Color.ToArgb()); - LibraryColorDialog.Color = Color.FromArgb(10349567); - } - } - - private void OK_Click(object sender, EventArgs e) + //Pop up color dialog when double-clicked + private void panelKeyWord_DoubleClick(object sender, EventArgs e) { - SaveData(); //Save the chosen settings - DialogResult = DialogResult.OK; - Close(); + if (KeyWordColorDialog.ShowDialog() == DialogResult.OK) + { + SetKeyWordColor(KeyWordColorDialog.Color.ToArgb()); + } } - private void SaveData() - { - //Colors - Global.Config.LuaDefaultTextColor = TextColor; - Global.Config.LuaKeyWordColor = KeyWordColor; - Global.Config.LuaCommentColor = CommentColor; - Global.Config.LuaStringColor = StringColor; - Global.Config.LuaSymbolColor = SymbolColor; - Global.Config.LuaLibraryColor = LibraryColor; - - //Bold - Global.Config.LuaDefaultTextBold = BoldText.Checked; - Global.Config.LuaKeyWordBold = BoldKeyWords.Checked; - Global.Config.LuaCommentBold = BoldComments.Checked; - Global.Config.LuaStringBold = BoldStrings.Checked; - Global.Config.LuaSymbolBold = BoldSymbols.Checked; - Global.Config.LuaLibraryBold = BoldLibraries.Checked; - } + //Pop up color dialog when double-clicked + private void panelComment_DoubleClick(object sender, EventArgs e) + { + if (CommentColorDialog.ShowDialog() == DialogResult.OK) + { + SetCommentColor(CommentColorDialog.Color.ToArgb()); + } + } - private void buttonDefaults_Click(object sender, EventArgs e) - { + //Pop up color dialog when double-clicked + private void panelString_DoubleClick(object sender, EventArgs e) + { + if (StringColorDialog.ShowDialog() == DialogResult.OK) + { + SetStringColor(StringColorDialog.Color.ToArgb()); + } + } + + //Pop up color dialog when double-clicked + private void panelSymbol_DoubleClick(object sender, EventArgs e) + { + if (SymbolColorDialog.ShowDialog() == DialogResult.OK) + { + SetSymbolColor(SymbolColorDialog.Color.ToArgb()); + } + } + + //Pop up color dialog when double-clicked + private void panelLibrary_DoubleClick(object sender, EventArgs e) + { + if (LibraryColorDialog.ShowDialog() == DialogResult.OK) + { + SetLibraryColor(LibraryColorDialog.Color.ToArgb()); + LibraryColorDialog.Color = Color.FromArgb(10349567); + } + } + + private void OK_Click(object sender, EventArgs e) + { + SaveData(); //Save the chosen settings + DialogResult = DialogResult.OK; + Close(); + } + + private void SaveData() + { + //Colors + Global.Config.LuaDefaultTextColor = TextColor; + Global.Config.LuaKeyWordColor = KeyWordColor; + Global.Config.LuaCommentColor = CommentColor; + Global.Config.LuaStringColor = StringColor; + Global.Config.LuaSymbolColor = SymbolColor; + Global.Config.LuaLibraryColor = LibraryColor; + + //Bold + Global.Config.LuaDefaultTextBold = BoldText.Checked; + Global.Config.LuaKeyWordBold = BoldKeyWords.Checked; + Global.Config.LuaCommentBold = BoldComments.Checked; + Global.Config.LuaStringBold = BoldStrings.Checked; + Global.Config.LuaSymbolBold = BoldSymbols.Checked; + Global.Config.LuaLibraryBold = BoldLibraries.Checked; + } + + private void buttonDefaults_Click(object sender, EventArgs e) + { SetTextColor(-16777216); - SetKeyWordColor(-16776961); - SetCommentColor(-16744448); - SetStringColor(-8355712); - SetSymbolColor(-16777216); + SetKeyWordColor(-16776961); + SetCommentColor(-16744448); + SetStringColor(-8355712); + SetSymbolColor(-16777216); SetLibraryColor(-16711681); BoldText.Checked = false; - BoldKeyWords.Checked = false; - BoldComments.Checked = false; - BoldStrings.Checked = false; - BoldSymbols.Checked = false; - BoldLibraries.Checked = false; - } - } + BoldKeyWords.Checked = false; + BoldComments.Checked = false; + BoldStrings.Checked = false; + BoldSymbols.Checked = false; + BoldLibraries.Checked = false; + } + } } diff --git a/BizHawk.MultiClient/tools/N64/N64VideoPluginconfig.cs b/BizHawk.MultiClient/tools/N64/N64VideoPluginconfig.cs index 9248d55f48..7a3c6bfab2 100644 --- a/BizHawk.MultiClient/tools/N64/N64VideoPluginconfig.cs +++ b/BizHawk.MultiClient/tools/N64/N64VideoPluginconfig.cs @@ -7,6 +7,8 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class N64VideoPluginconfig : Form @@ -38,7 +40,7 @@ namespace BizHawk.MultiClient Global.Config.N64VideoSizeX = Int32.Parse(strArr[0].Trim()); Global.Config.N64VideoSizeY = Int32.Parse(strArr[1].Trim()); Global.Config.N64VidPlugin = PluginComboBox.Text; - Global.MainForm.FlagNeedsReboot(); //TODO: this won't always be necessary, keep that in mind + GlobalWinF.MainForm.FlagNeedsReboot(); //TODO: this won't always be necessary, keep that in mind //Rice Global.Config.RicePlugin.NormalAlphaBlender = RiceNormalAlphaBlender_CB.Checked; diff --git a/BizHawk.MultiClient/tools/NES/NESDebugger.cs b/BizHawk.MultiClient/tools/NES/NESDebugger.cs index 94f9cd1482..5933fb2d9b 100644 --- a/BizHawk.MultiClient/tools/NES/NESDebugger.cs +++ b/BizHawk.MultiClient/tools/NES/NESDebugger.cs @@ -4,6 +4,8 @@ using System.Drawing; using System.Windows.Forms; using BizHawk.Emulation.Consoles.Nintendo; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class NESDebugger : Form diff --git a/BizHawk.MultiClient/tools/NES/NESGameGenie.cs b/BizHawk.MultiClient/tools/NES/NESGameGenie.cs index 2776e2b83b..8d21a50ae1 100644 --- a/BizHawk.MultiClient/tools/NES/NESGameGenie.cs +++ b/BizHawk.MultiClient/tools/NES/NESGameGenie.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; using System.Globalization; + +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.Nintendo; namespace BizHawk.MultiClient @@ -378,7 +380,7 @@ namespace BizHawk.MultiClient compare, enabled: true)); - Global.MainForm.Cheats_UpdateValues(); + GlobalWinF.MainForm.Cheats_UpdateValues(); } } diff --git a/BizHawk.MultiClient/tools/NES/NESGraphicsConfig.cs b/BizHawk.MultiClient/tools/NES/NESGraphicsConfig.cs index 828d3842d9..e80fc0405d 100644 --- a/BizHawk.MultiClient/tools/NES/NESGraphicsConfig.cs +++ b/BizHawk.MultiClient/tools/NES/NESGraphicsConfig.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using BizHawk.Emulation.Consoles.Nintendo; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class NESGraphicsConfig : Form @@ -73,7 +75,7 @@ namespace BizHawk.MultiClient { Global.Config.NESPaletteFile = palette.Name; nes.SetPalette(NES.Palettes.Load_FCEUX_Palette(HawkFile.ReadAllBytes(palette.Name))); - Global.OSD.AddMessage("Palette file loaded: " + palette.Name); + GlobalWinF.OSD.AddMessage("Palette file loaded: " + palette.Name); } } } @@ -81,7 +83,7 @@ namespace BizHawk.MultiClient { Global.Config.NESPaletteFile = ""; nes.SetPalette(NES.Palettes.FCEUX_Standard); - Global.OSD.AddMessage("Standard Palette set"); + GlobalWinF.OSD.AddMessage("Standard Palette set"); } Global.Config.NTSC_NESTopLine = (int)NTSC_FirstLineNumeric.Value; diff --git a/BizHawk.MultiClient/tools/NES/NESNameTableViewer.cs b/BizHawk.MultiClient/tools/NES/NESNameTableViewer.cs index d985921586..7e5347fdfb 100644 --- a/BizHawk.MultiClient/tools/NES/NESNameTableViewer.cs +++ b/BizHawk.MultiClient/tools/NES/NESNameTableViewer.cs @@ -4,6 +4,8 @@ using System.Drawing.Imaging; using System.Windows.Forms; using BizHawk.Emulation.Consoles.Nintendo; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class NESNameTableViewer : Form diff --git a/BizHawk.MultiClient/tools/NES/NESPPU.cs b/BizHawk.MultiClient/tools/NES/NESPPU.cs index 5d22c8be2d..561b3a3b96 100644 --- a/BizHawk.MultiClient/tools/NES/NESPPU.cs +++ b/BizHawk.MultiClient/tools/NES/NESPPU.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; using System.Globalization; + +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.Nintendo; namespace BizHawk.MultiClient diff --git a/BizHawk.MultiClient/tools/NES/NESSoundConfig.cs b/BizHawk.MultiClient/tools/NES/NESSoundConfig.cs index 572054e1ae..e6000f8ca2 100644 --- a/BizHawk.MultiClient/tools/NES/NESSoundConfig.cs +++ b/BizHawk.MultiClient/tools/NES/NESSoundConfig.cs @@ -1,6 +1,8 @@ using System; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class NESSoundConfig : Form @@ -45,7 +47,7 @@ namespace BizHawk.MultiClient Global.Config.NESTriangle = tr; Global.Config.NESNoise = no; Global.Config.NESDMC = dmc; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); Close(); } @@ -75,35 +77,35 @@ namespace BizHawk.MultiClient { label6.Text = trackBar1.Value.ToString(); Global.Config.NESSquare1 = trackBar1.Value; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); } private void trackBar2_ValueChanged(object sender, EventArgs e) { label7.Text = trackBar2.Value.ToString(); Global.Config.NESSquare2 = trackBar2.Value; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); } private void trackBar3_ValueChanged(object sender, EventArgs e) { label8.Text = trackBar3.Value.ToString(); Global.Config.NESTriangle = trackBar3.Value; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); } private void trackBar4_ValueChanged(object sender, EventArgs e) { label9.Text = trackBar4.Value.ToString(); Global.Config.NESNoise = trackBar4.Value; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); } private void trackBar5_ValueChanged(object sender, EventArgs e) { label10.Text = trackBar5.Value.ToString(); Global.Config.NESDMC = trackBar5.Value; - Global.MainForm.SetNESSoundChannels(); + GlobalWinF.MainForm.SetNESSoundChannels(); } } } diff --git a/BizHawk.MultiClient/tools/NES/NameTableViewer.cs b/BizHawk.MultiClient/tools/NES/NameTableViewer.cs index 916d2f0ef9..4815187a33 100644 --- a/BizHawk.MultiClient/tools/NES/NameTableViewer.cs +++ b/BizHawk.MultiClient/tools/NES/NameTableViewer.cs @@ -3,6 +3,8 @@ using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public sealed class NameTableViewer : Control @@ -74,9 +76,9 @@ namespace BizHawk.MultiClient RestoreDirectory = true }; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) { return; diff --git a/BizHawk.MultiClient/tools/NES/PaletteViewer.cs b/BizHawk.MultiClient/tools/NES/PaletteViewer.cs index 66da77995c..c0e9b2c542 100644 --- a/BizHawk.MultiClient/tools/NES/PaletteViewer.cs +++ b/BizHawk.MultiClient/tools/NES/PaletteViewer.cs @@ -3,6 +3,8 @@ using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public sealed class PaletteViewer : Control @@ -81,9 +83,9 @@ namespace BizHawk.MultiClient RestoreDirectory = true }; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; diff --git a/BizHawk.MultiClient/tools/NES/PatternViewer.cs b/BizHawk.MultiClient/tools/NES/PatternViewer.cs index 181d18dabd..6553719bae 100644 --- a/BizHawk.MultiClient/tools/NES/PatternViewer.cs +++ b/BizHawk.MultiClient/tools/NES/PatternViewer.cs @@ -3,6 +3,8 @@ using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public sealed class PatternViewer : Control @@ -42,9 +44,9 @@ namespace BizHawk.MultiClient RestoreDirectory = true }; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; diff --git a/BizHawk.MultiClient/tools/NES/SpriteViewer.cs b/BizHawk.MultiClient/tools/NES/SpriteViewer.cs index 973dc11252..0224b717de 100644 --- a/BizHawk.MultiClient/tools/NES/SpriteViewer.cs +++ b/BizHawk.MultiClient/tools/NES/SpriteViewer.cs @@ -3,6 +3,8 @@ using System.Windows.Forms; using System.IO; using System.Drawing.Imaging; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public sealed class SpriteViewer : Control @@ -47,9 +49,9 @@ namespace BizHawk.MultiClient RestoreDirectory = true }; - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = sfd.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result != DialogResult.OK) return; diff --git a/BizHawk.MultiClient/tools/PCE/PCEBGViewer.cs b/BizHawk.MultiClient/tools/PCE/PCEBGViewer.cs index c63caafad7..8e204e400a 100644 --- a/BizHawk.MultiClient/tools/PCE/PCEBGViewer.cs +++ b/BizHawk.MultiClient/tools/PCE/PCEBGViewer.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Windows.Forms; using System.Drawing.Imaging; + +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.TurboGrafx; namespace BizHawk.MultiClient diff --git a/BizHawk.MultiClient/tools/PCE/PCEGraphicsConfig.cs b/BizHawk.MultiClient/tools/PCE/PCEGraphicsConfig.cs index 7c94bb52eb..f004263f41 100644 --- a/BizHawk.MultiClient/tools/PCE/PCEGraphicsConfig.cs +++ b/BizHawk.MultiClient/tools/PCE/PCEGraphicsConfig.cs @@ -1,6 +1,8 @@ using System; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class PCEGraphicsConfig : Form diff --git a/BizHawk.MultiClient/tools/SMS/SMSGraphicsConfig.cs b/BizHawk.MultiClient/tools/SMS/SMSGraphicsConfig.cs index 980c85ae08..5ee17fd91a 100644 --- a/BizHawk.MultiClient/tools/SMS/SMSGraphicsConfig.cs +++ b/BizHawk.MultiClient/tools/SMS/SMSGraphicsConfig.cs @@ -1,6 +1,8 @@ using System; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class SMSGraphicsConfig : Form diff --git a/BizHawk.MultiClient/tools/SNES/SNESGameGenie.cs b/BizHawk.MultiClient/tools/SNES/SNESGameGenie.cs index dbb198e149..43dc1edaeb 100644 --- a/BizHawk.MultiClient/tools/SNES/SNESGameGenie.cs +++ b/BizHawk.MultiClient/tools/SNES/SNESGameGenie.cs @@ -6,6 +6,8 @@ using System.Globalization; using System.Text.RegularExpressions; using BizHawk.Emulation.Consoles.Nintendo.SNES; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class SNESGameGenie : Form @@ -13,7 +15,7 @@ namespace BizHawk.MultiClient private readonly Dictionary GameGenieTable = new Dictionary(); private bool Processing = false; - public SNESGameGenie() + public SNESGameGenie() { InitializeComponent(); Closing += (o, e) => SaveConfigSettings(); @@ -345,6 +347,8 @@ namespace BizHawk.MultiClient compare: null, enabled: true )); + + ToolHelpers.UpdateCheatRelatedTools(); } } diff --git a/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs b/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs index 60e924b63d..2245f8dbfe 100644 --- a/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs +++ b/BizHawk.MultiClient/tools/SNES/SNESGraphicsDebugger.cs @@ -28,6 +28,8 @@ using System.Collections.Generic; using System.Drawing; using System.Reflection; using System.Windows.Forms; + +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.Nintendo.SNES; using BizHawk.Core; @@ -1384,7 +1386,7 @@ namespace BizHawk.MultiClient suppression = false; } - Global.MainForm.SyncCoreCommInputSignals(); + GlobalWinF.MainForm.SyncCoreCommInputSignals(); } private void lblEnPrio0_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.Designer.cs b/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.Designer.cs index 14482f5486..0224ae2a20 100644 --- a/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.Designer.cs +++ b/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.Designer.cs @@ -1,4 +1,4 @@ -namespace BizHawk.MultiClient.SATTools +namespace BizHawk.MultiClient { partial class SaturnPrefs { diff --git a/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.cs b/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.cs index c33d9a2dee..13469d1357 100644 --- a/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.cs +++ b/BizHawk.MultiClient/tools/Saturn/SaturnPrefs.cs @@ -7,7 +7,9 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace BizHawk.MultiClient.SATTools +using BizHawk.Client.Common; + +namespace BizHawk.MultiClient { public partial class SaturnPrefs : Form { diff --git a/BizHawk.MultiClient/tools/StateVisualizer.cs b/BizHawk.MultiClient/tools/StateVisualizer.cs index 827004f2df..07694371fe 100644 --- a/BizHawk.MultiClient/tools/StateVisualizer.cs +++ b/BizHawk.MultiClient/tools/StateVisualizer.cs @@ -2,6 +2,8 @@ using System.Linq; using System.IO; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class StateVisualizer @@ -19,13 +21,21 @@ namespace BizHawk.MultiClient string path = PathManager.SaveStatePrefix(Global.Game) + "." + name + ".State"; if (File.Exists(path)) { - Movie m = new Movie(); - m.LoadLogFromSavestateText(path); + Movie m = new Movie(GlobalWinF.MainForm.GetEmuVersion()); + LoadLogFromSavestateText(m, path); AddLog(m.LogDump, i); } } } + private void LoadLogFromSavestateText(Movie movie, string path) + { + using (var reader = new StreamReader(path)) + { + movie.LoadLogFromSavestateText(reader, Global.MovieSession.MultiTrack.IsActive); + } + } + public int TimeLineCount { get diff --git a/BizHawk.MultiClient/tools/TAStudio.Designer.cs b/BizHawk.MultiClient/tools/TAStudio.Designer.cs index 5d41ba3b02..88152ad8b0 100644 --- a/BizHawk.MultiClient/tools/TAStudio.Designer.cs +++ b/BizHawk.MultiClient/tools/TAStudio.Designer.cs @@ -1,128 +1,130 @@ -namespace BizHawk.MultiClient +using BizHawk.Client.Common; + +namespace BizHawk.MultiClient { - partial class TAStudio - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; + partial class TAStudio + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } - Global.MovieSession.Movie.StateCapturing = false; + Global.MovieSession.Movie.StateCapturing = false; //TODO: This doesn't go here, extend this method in the .cs file base.Dispose(disposing); - } + } - #region Windows Form Designer generated code + #region Windows Form Designer generated code - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TAStudio)); - this.menuStrip1 = new MenuStripEx(); - this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.newProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.openProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveProjectAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.nToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); - this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); - this.importTASFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); - this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.clearToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); - this.deleteFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.insertNumFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); - this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.pasteInsertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); - this.truncateMovieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.clearVirtualPadsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.updatePadsOnMovePlaybackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); - this.restoreWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox(); - this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); - this.clearToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); - this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem(); - this.cloneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.ContextMenu_Insert = new System.Windows.Forms.ToolStripMenuItem(); - this.insertFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); - this.toolStripItem_SelectAll = new System.Windows.Forms.ToolStripMenuItem(); - this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); - this.truncateMovieToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.ClipboardDisplay = new System.Windows.Forms.Label(); - this.SelectionDisplay = new System.Windows.Forms.Label(); - this.label2 = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); - this.toolStrip1 = new ToolStripEx(); - this.RewindToBeginning = new System.Windows.Forms.ToolStripButton(); - this.RewindButton = new System.Windows.Forms.ToolStripButton(); - this.PauseButton = new System.Windows.Forms.ToolStripButton(); - this.FrameAdvanceButton = new System.Windows.Forms.ToolStripButton(); - this.FastForward = new System.Windows.Forms.ToolStripButton(); - this.TurboFastForward = new System.Windows.Forms.ToolStripButton(); - this.FastFowardToEnd = new System.Windows.Forms.ToolStripButton(); - this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); - this.StopButton = new System.Windows.Forms.ToolStripButton(); - this.TASView = new BizHawk.VirtualListView(); - this.Frame = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.Log = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.VisualizerBox = new System.Windows.Forms.GroupBox(); - this.button1 = new System.Windows.Forms.Button(); - this.alwaysOnTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.menuStrip1.SuspendLayout(); - this.contextMenuStrip1.SuspendLayout(); - this.groupBox1.SuspendLayout(); - this.toolStrip1.SuspendLayout(); - this.VisualizerBox.SuspendLayout(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TAStudio)); + this.menuStrip1 = new MenuStripEx(); + this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.newProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.openProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveProjectToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveProjectAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.recentToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.nToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); + this.clearToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.importTASFileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.editToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.clearToolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); + this.deleteFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cloneToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertFrameToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.insertNumFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator7 = new System.Windows.Forms.ToolStripSeparator(); + this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.pasteInsertToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.selectAllToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); + this.truncateMovieToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.clearVirtualPadsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.saveWindowPositionToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.autoloadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.updatePadsOnMovePlaybackToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); + this.restoreWindowToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ReadOnlyCheckBox = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components); + this.clearToolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); + this.ContextMenu_Delete = new System.Windows.Forms.ToolStripMenuItem(); + this.cloneToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.ContextMenu_Insert = new System.Windows.Forms.ToolStripMenuItem(); + this.insertFramesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripItem_SelectAll = new System.Windows.Forms.ToolStripMenuItem(); + this.toolStripSeparator9 = new System.Windows.Forms.ToolStripSeparator(); + this.truncateMovieToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.ClipboardDisplay = new System.Windows.Forms.Label(); + this.SelectionDisplay = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.toolStrip1 = new ToolStripEx(); + this.RewindToBeginning = new System.Windows.Forms.ToolStripButton(); + this.RewindButton = new System.Windows.Forms.ToolStripButton(); + this.PauseButton = new System.Windows.Forms.ToolStripButton(); + this.FrameAdvanceButton = new System.Windows.Forms.ToolStripButton(); + this.FastForward = new System.Windows.Forms.ToolStripButton(); + this.TurboFastForward = new System.Windows.Forms.ToolStripButton(); + this.FastFowardToEnd = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator(); + this.StopButton = new System.Windows.Forms.ToolStripButton(); + this.TASView = new BizHawk.VirtualListView(); + this.Frame = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.Log = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.VisualizerBox = new System.Windows.Forms.GroupBox(); + this.button1 = new System.Windows.Forms.Button(); + this.alwaysOnTopToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.menuStrip1.SuspendLayout(); + this.contextMenuStrip1.SuspendLayout(); + this.groupBox1.SuspendLayout(); + this.toolStrip1.SuspendLayout(); + this.VisualizerBox.SuspendLayout(); + this.SuspendLayout(); + // + // menuStrip1 + // + this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.fileToolStripMenuItem, this.editToolStripMenuItem, this.settingsToolStripMenuItem}); - this.menuStrip1.Location = new System.Drawing.Point(0, 0); - this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(586, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; - // - // fileToolStripMenuItem - // - this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Size = new System.Drawing.Size(586, 24); + this.menuStrip1.TabIndex = 0; + this.menuStrip1.Text = "menuStrip1"; + // + // fileToolStripMenuItem + // + this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.newProjectToolStripMenuItem, this.openProjectToolStripMenuItem, this.saveProjectToolStripMenuItem, @@ -132,95 +134,95 @@ this.importTASFileToolStripMenuItem, this.toolStripSeparator2, this.exitToolStripMenuItem}); - this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; - this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); - this.fileToolStripMenuItem.Text = "&File"; - // - // newProjectToolStripMenuItem - // - this.newProjectToolStripMenuItem.Name = "newProjectToolStripMenuItem"; - this.newProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); - this.newProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.newProjectToolStripMenuItem.Text = "New Project"; - this.newProjectToolStripMenuItem.Click += new System.EventHandler(this.newProjectToolStripMenuItem_Click); - // - // openProjectToolStripMenuItem - // - this.openProjectToolStripMenuItem.Name = "openProjectToolStripMenuItem"; - this.openProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); - this.openProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.openProjectToolStripMenuItem.Text = "&Open Project"; - this.openProjectToolStripMenuItem.Click += new System.EventHandler(this.openProjectToolStripMenuItem_Click); - // - // saveProjectToolStripMenuItem - // - this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; - this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.saveProjectToolStripMenuItem.Text = "&Save Project"; - this.saveProjectToolStripMenuItem.Click += new System.EventHandler(this.saveProjectToolStripMenuItem_Click); - // - // saveProjectAsToolStripMenuItem - // - this.saveProjectAsToolStripMenuItem.Name = "saveProjectAsToolStripMenuItem"; - this.saveProjectAsToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.saveProjectAsToolStripMenuItem.Text = "Save Project As"; - this.saveProjectAsToolStripMenuItem.Click += new System.EventHandler(this.saveProjectAsToolStripMenuItem_Click); - // - // recentToolStripMenuItem - // - this.recentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.fileToolStripMenuItem.Name = "fileToolStripMenuItem"; + this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20); + this.fileToolStripMenuItem.Text = "&File"; + // + // newProjectToolStripMenuItem + // + this.newProjectToolStripMenuItem.Name = "newProjectToolStripMenuItem"; + this.newProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.N))); + this.newProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.newProjectToolStripMenuItem.Text = "New Project"; + this.newProjectToolStripMenuItem.Click += new System.EventHandler(this.newProjectToolStripMenuItem_Click); + // + // openProjectToolStripMenuItem + // + this.openProjectToolStripMenuItem.Name = "openProjectToolStripMenuItem"; + this.openProjectToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O))); + this.openProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.openProjectToolStripMenuItem.Text = "&Open Project"; + this.openProjectToolStripMenuItem.Click += new System.EventHandler(this.openProjectToolStripMenuItem_Click); + // + // saveProjectToolStripMenuItem + // + this.saveProjectToolStripMenuItem.Name = "saveProjectToolStripMenuItem"; + this.saveProjectToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.saveProjectToolStripMenuItem.Text = "&Save Project"; + this.saveProjectToolStripMenuItem.Click += new System.EventHandler(this.saveProjectToolStripMenuItem_Click); + // + // saveProjectAsToolStripMenuItem + // + this.saveProjectAsToolStripMenuItem.Name = "saveProjectAsToolStripMenuItem"; + this.saveProjectAsToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.saveProjectAsToolStripMenuItem.Text = "Save Project As"; + this.saveProjectAsToolStripMenuItem.Click += new System.EventHandler(this.saveProjectAsToolStripMenuItem_Click); + // + // recentToolStripMenuItem + // + this.recentToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.nToolStripMenuItem, this.toolStripSeparator3, this.clearToolStripMenuItem}); - this.recentToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Recent; - this.recentToolStripMenuItem.Name = "recentToolStripMenuItem"; - this.recentToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.recentToolStripMenuItem.Text = "Recent"; - // - // nToolStripMenuItem - // - this.nToolStripMenuItem.Name = "nToolStripMenuItem"; - this.nToolStripMenuItem.Size = new System.Drawing.Size(103, 22); - this.nToolStripMenuItem.Text = "None"; - // - // toolStripSeparator3 - // - this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(100, 6); - // - // clearToolStripMenuItem - // - this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; - this.clearToolStripMenuItem.Size = new System.Drawing.Size(103, 22); - this.clearToolStripMenuItem.Text = "Clear"; - // - // toolStripSeparator1 - // - this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(183, 6); - // - // importTASFileToolStripMenuItem - // - this.importTASFileToolStripMenuItem.Name = "importTASFileToolStripMenuItem"; - this.importTASFileToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.importTASFileToolStripMenuItem.Text = "Import TAS file"; - // - // toolStripSeparator2 - // - this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(183, 6); - // - // exitToolStripMenuItem - // - this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; - this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); - this.exitToolStripMenuItem.Size = new System.Drawing.Size(186, 22); - this.exitToolStripMenuItem.Text = "E&xit"; - this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); - // - // editToolStripMenuItem - // - this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.recentToolStripMenuItem.Image = global::BizHawk.MultiClient.Properties.Resources.Recent; + this.recentToolStripMenuItem.Name = "recentToolStripMenuItem"; + this.recentToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.recentToolStripMenuItem.Text = "Recent"; + // + // nToolStripMenuItem + // + this.nToolStripMenuItem.Name = "nToolStripMenuItem"; + this.nToolStripMenuItem.Size = new System.Drawing.Size(103, 22); + this.nToolStripMenuItem.Text = "None"; + // + // toolStripSeparator3 + // + this.toolStripSeparator3.Name = "toolStripSeparator3"; + this.toolStripSeparator3.Size = new System.Drawing.Size(100, 6); + // + // clearToolStripMenuItem + // + this.clearToolStripMenuItem.Name = "clearToolStripMenuItem"; + this.clearToolStripMenuItem.Size = new System.Drawing.Size(103, 22); + this.clearToolStripMenuItem.Text = "Clear"; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(183, 6); + // + // importTASFileToolStripMenuItem + // + this.importTASFileToolStripMenuItem.Name = "importTASFileToolStripMenuItem"; + this.importTASFileToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.importTASFileToolStripMenuItem.Text = "Import TAS file"; + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(183, 6); + // + // exitToolStripMenuItem + // + this.exitToolStripMenuItem.Name = "exitToolStripMenuItem"; + this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4))); + this.exitToolStripMenuItem.Size = new System.Drawing.Size(186, 22); + this.exitToolStripMenuItem.Text = "E&xit"; + this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click); + // + // editToolStripMenuItem + // + this.editToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.clearToolStripMenuItem2, this.deleteFramesToolStripMenuItem, this.cloneToolStripMenuItem, @@ -235,181 +237,181 @@ this.toolStripSeparator8, this.truncateMovieToolStripMenuItem, this.clearVirtualPadsToolStripMenuItem}); - this.editToolStripMenuItem.Name = "editToolStripMenuItem"; - this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); - this.editToolStripMenuItem.Text = "&Edit"; - this.editToolStripMenuItem.DropDownOpened += new System.EventHandler(this.editToolStripMenuItem_DropDownOpened); - // - // clearToolStripMenuItem2 - // - this.clearToolStripMenuItem2.Name = "clearToolStripMenuItem2"; - this.clearToolStripMenuItem2.ShortcutKeyDisplayString = "Del"; - this.clearToolStripMenuItem2.Size = new System.Drawing.Size(207, 22); - this.clearToolStripMenuItem2.Text = "Clear"; - this.clearToolStripMenuItem2.Click += new System.EventHandler(this.clearToolStripMenuItem2_Click); - // - // deleteFramesToolStripMenuItem - // - this.deleteFramesToolStripMenuItem.Name = "deleteFramesToolStripMenuItem"; - this.deleteFramesToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Delete))); - this.deleteFramesToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.deleteFramesToolStripMenuItem.Text = "&Delete"; - this.deleteFramesToolStripMenuItem.Click += new System.EventHandler(this.deleteFramesToolStripMenuItem_Click); - // - // cloneToolStripMenuItem - // - this.cloneToolStripMenuItem.Name = "cloneToolStripMenuItem"; - this.cloneToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Insert))); - this.cloneToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.cloneToolStripMenuItem.Text = "&Clone"; - this.cloneToolStripMenuItem.Click += new System.EventHandler(this.cloneToolStripMenuItem_Click); - // - // insertFrameToolStripMenuItem - // - this.insertFrameToolStripMenuItem.Name = "insertFrameToolStripMenuItem"; - this.insertFrameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.Insert))); - this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.insertFrameToolStripMenuItem.Text = "&Insert"; - this.insertFrameToolStripMenuItem.Click += new System.EventHandler(this.insertFrameToolStripMenuItem_Click); - // - // insertNumFramesToolStripMenuItem - // - this.insertNumFramesToolStripMenuItem.Name = "insertNumFramesToolStripMenuItem"; - this.insertNumFramesToolStripMenuItem.ShortcutKeyDisplayString = "Ins"; - this.insertNumFramesToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.insertNumFramesToolStripMenuItem.Text = "Insert # of Frames"; - this.insertNumFramesToolStripMenuItem.Click += new System.EventHandler(this.insertNumFramesToolStripMenuItem_Click); - // - // toolStripSeparator7 - // - this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(204, 6); - // - // copyToolStripMenuItem - // - this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; - this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); - this.copyToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.copyToolStripMenuItem.Text = "Copy"; - this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); - // - // pasteToolStripMenuItem - // - this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; - this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); - this.pasteToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.pasteToolStripMenuItem.Text = "&Paste"; - this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click); - // - // pasteInsertToolStripMenuItem - // - this.pasteInsertToolStripMenuItem.Name = "pasteInsertToolStripMenuItem"; - this.pasteInsertToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) - | System.Windows.Forms.Keys.V))); - this.pasteInsertToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.pasteInsertToolStripMenuItem.Text = "&Paste Insert"; - this.pasteInsertToolStripMenuItem.Click += new System.EventHandler(this.pasteInsertToolStripMenuItem_Click); - // - // cutToolStripMenuItem - // - this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; - this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); - this.cutToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.cutToolStripMenuItem.Text = "&Cut"; - this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); - // - // selectAllToolStripMenuItem - // - this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; - this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); - this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.selectAllToolStripMenuItem.Text = "Select &All"; - this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); - // - // toolStripSeparator8 - // - this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(204, 6); - // - // truncateMovieToolStripMenuItem - // - this.truncateMovieToolStripMenuItem.Name = "truncateMovieToolStripMenuItem"; - this.truncateMovieToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.truncateMovieToolStripMenuItem.Text = "&Truncate Movie"; - this.truncateMovieToolStripMenuItem.Click += new System.EventHandler(this.truncateMovieToolStripMenuItem_Click); - // - // clearVirtualPadsToolStripMenuItem - // - this.clearVirtualPadsToolStripMenuItem.Name = "clearVirtualPadsToolStripMenuItem"; - this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(207, 22); - this.clearVirtualPadsToolStripMenuItem.Text = "Clear controller &holds"; - // - // settingsToolStripMenuItem - // - this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.editToolStripMenuItem.Name = "editToolStripMenuItem"; + this.editToolStripMenuItem.Size = new System.Drawing.Size(39, 20); + this.editToolStripMenuItem.Text = "&Edit"; + this.editToolStripMenuItem.DropDownOpened += new System.EventHandler(this.editToolStripMenuItem_DropDownOpened); + // + // clearToolStripMenuItem2 + // + this.clearToolStripMenuItem2.Name = "clearToolStripMenuItem2"; + this.clearToolStripMenuItem2.ShortcutKeyDisplayString = "Del"; + this.clearToolStripMenuItem2.Size = new System.Drawing.Size(207, 22); + this.clearToolStripMenuItem2.Text = "Clear"; + this.clearToolStripMenuItem2.Click += new System.EventHandler(this.clearToolStripMenuItem2_Click); + // + // deleteFramesToolStripMenuItem + // + this.deleteFramesToolStripMenuItem.Name = "deleteFramesToolStripMenuItem"; + this.deleteFramesToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Delete))); + this.deleteFramesToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.deleteFramesToolStripMenuItem.Text = "&Delete"; + this.deleteFramesToolStripMenuItem.Click += new System.EventHandler(this.deleteFramesToolStripMenuItem_Click); + // + // cloneToolStripMenuItem + // + this.cloneToolStripMenuItem.Name = "cloneToolStripMenuItem"; + this.cloneToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Insert))); + this.cloneToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.cloneToolStripMenuItem.Text = "&Clone"; + this.cloneToolStripMenuItem.Click += new System.EventHandler(this.cloneToolStripMenuItem_Click); + // + // insertFrameToolStripMenuItem + // + this.insertFrameToolStripMenuItem.Name = "insertFrameToolStripMenuItem"; + this.insertFrameToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.Insert))); + this.insertFrameToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.insertFrameToolStripMenuItem.Text = "&Insert"; + this.insertFrameToolStripMenuItem.Click += new System.EventHandler(this.insertFrameToolStripMenuItem_Click); + // + // insertNumFramesToolStripMenuItem + // + this.insertNumFramesToolStripMenuItem.Name = "insertNumFramesToolStripMenuItem"; + this.insertNumFramesToolStripMenuItem.ShortcutKeyDisplayString = "Ins"; + this.insertNumFramesToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.insertNumFramesToolStripMenuItem.Text = "Insert # of Frames"; + this.insertNumFramesToolStripMenuItem.Click += new System.EventHandler(this.insertNumFramesToolStripMenuItem_Click); + // + // toolStripSeparator7 + // + this.toolStripSeparator7.Name = "toolStripSeparator7"; + this.toolStripSeparator7.Size = new System.Drawing.Size(204, 6); + // + // copyToolStripMenuItem + // + this.copyToolStripMenuItem.Name = "copyToolStripMenuItem"; + this.copyToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.C))); + this.copyToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.copyToolStripMenuItem.Text = "Copy"; + this.copyToolStripMenuItem.Click += new System.EventHandler(this.copyToolStripMenuItem_Click); + // + // pasteToolStripMenuItem + // + this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem"; + this.pasteToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); + this.pasteToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.pasteToolStripMenuItem.Text = "&Paste"; + this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Click); + // + // pasteInsertToolStripMenuItem + // + this.pasteInsertToolStripMenuItem.Name = "pasteInsertToolStripMenuItem"; + this.pasteInsertToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift) + | System.Windows.Forms.Keys.V))); + this.pasteInsertToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.pasteInsertToolStripMenuItem.Text = "&Paste Insert"; + this.pasteInsertToolStripMenuItem.Click += new System.EventHandler(this.pasteInsertToolStripMenuItem_Click); + // + // cutToolStripMenuItem + // + this.cutToolStripMenuItem.Name = "cutToolStripMenuItem"; + this.cutToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.X))); + this.cutToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.cutToolStripMenuItem.Text = "&Cut"; + this.cutToolStripMenuItem.Click += new System.EventHandler(this.cutToolStripMenuItem_Click); + // + // selectAllToolStripMenuItem + // + this.selectAllToolStripMenuItem.Name = "selectAllToolStripMenuItem"; + this.selectAllToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.A))); + this.selectAllToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.selectAllToolStripMenuItem.Text = "Select &All"; + this.selectAllToolStripMenuItem.Click += new System.EventHandler(this.selectAllToolStripMenuItem_Click); + // + // toolStripSeparator8 + // + this.toolStripSeparator8.Name = "toolStripSeparator8"; + this.toolStripSeparator8.Size = new System.Drawing.Size(204, 6); + // + // truncateMovieToolStripMenuItem + // + this.truncateMovieToolStripMenuItem.Name = "truncateMovieToolStripMenuItem"; + this.truncateMovieToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.truncateMovieToolStripMenuItem.Text = "&Truncate Movie"; + this.truncateMovieToolStripMenuItem.Click += new System.EventHandler(this.truncateMovieToolStripMenuItem_Click); + // + // clearVirtualPadsToolStripMenuItem + // + this.clearVirtualPadsToolStripMenuItem.Name = "clearVirtualPadsToolStripMenuItem"; + this.clearVirtualPadsToolStripMenuItem.Size = new System.Drawing.Size(207, 22); + this.clearVirtualPadsToolStripMenuItem.Text = "Clear controller &holds"; + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.saveWindowPositionToolStripMenuItem, this.autoloadToolStripMenuItem, this.updatePadsOnMovePlaybackToolStripMenuItem, this.toolStripSeparator4, this.alwaysOnTopToolStripMenuItem, this.restoreWindowToolStripMenuItem}); - this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; - this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); - this.settingsToolStripMenuItem.Text = "&Settings"; - this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened); - // - // saveWindowPositionToolStripMenuItem - // - this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; - this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position"; - this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click); - // - // autoloadToolStripMenuItem - // - this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; - this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.autoloadToolStripMenuItem.Text = "Autoload"; - this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); - // - // updatePadsOnMovePlaybackToolStripMenuItem - // - this.updatePadsOnMovePlaybackToolStripMenuItem.Name = "updatePadsOnMovePlaybackToolStripMenuItem"; - this.updatePadsOnMovePlaybackToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.updatePadsOnMovePlaybackToolStripMenuItem.Text = "Update Pads on Move playback"; - this.updatePadsOnMovePlaybackToolStripMenuItem.Click += new System.EventHandler(this.updatePadsOnMovePlaybackToolStripMenuItem_Click); - // - // toolStripSeparator4 - // - this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(237, 6); - // - // restoreWindowToolStripMenuItem - // - this.restoreWindowToolStripMenuItem.Name = "restoreWindowToolStripMenuItem"; - this.restoreWindowToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.restoreWindowToolStripMenuItem.Text = "Restore Default Settings"; - this.restoreWindowToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowToolStripMenuItem_Click); - // - // ReadOnlyCheckBox - // - this.ReadOnlyCheckBox.Appearance = System.Windows.Forms.Appearance.Button; - this.ReadOnlyCheckBox.AutoSize = true; - this.ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control; - this.ReadOnlyCheckBox.Image = global::BizHawk.MultiClient.Properties.Resources.ReadOnly; - this.ReadOnlyCheckBox.ImageAlign = System.Drawing.ContentAlignment.BottomRight; - this.ReadOnlyCheckBox.Location = new System.Drawing.Point(12, 27); - this.ReadOnlyCheckBox.Name = "ReadOnlyCheckBox"; - this.ReadOnlyCheckBox.Size = new System.Drawing.Size(22, 22); - this.ReadOnlyCheckBox.TabIndex = 3; - this.toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Read-only"); - this.ReadOnlyCheckBox.UseVisualStyleBackColor = false; - this.ReadOnlyCheckBox.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); - // - // contextMenuStrip1 - // - this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20); + this.settingsToolStripMenuItem.Text = "&Settings"; + this.settingsToolStripMenuItem.DropDownOpened += new System.EventHandler(this.settingsToolStripMenuItem_DropDownOpened); + // + // saveWindowPositionToolStripMenuItem + // + this.saveWindowPositionToolStripMenuItem.Name = "saveWindowPositionToolStripMenuItem"; + this.saveWindowPositionToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.saveWindowPositionToolStripMenuItem.Text = "Save Window Position"; + this.saveWindowPositionToolStripMenuItem.Click += new System.EventHandler(this.saveWindowPositionToolStripMenuItem_Click); + // + // autoloadToolStripMenuItem + // + this.autoloadToolStripMenuItem.Name = "autoloadToolStripMenuItem"; + this.autoloadToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.autoloadToolStripMenuItem.Text = "Autoload"; + this.autoloadToolStripMenuItem.Click += new System.EventHandler(this.autoloadToolStripMenuItem_Click); + // + // updatePadsOnMovePlaybackToolStripMenuItem + // + this.updatePadsOnMovePlaybackToolStripMenuItem.Name = "updatePadsOnMovePlaybackToolStripMenuItem"; + this.updatePadsOnMovePlaybackToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.updatePadsOnMovePlaybackToolStripMenuItem.Text = "Update Pads on Move playback"; + this.updatePadsOnMovePlaybackToolStripMenuItem.Click += new System.EventHandler(this.updatePadsOnMovePlaybackToolStripMenuItem_Click); + // + // toolStripSeparator4 + // + this.toolStripSeparator4.Name = "toolStripSeparator4"; + this.toolStripSeparator4.Size = new System.Drawing.Size(237, 6); + // + // restoreWindowToolStripMenuItem + // + this.restoreWindowToolStripMenuItem.Name = "restoreWindowToolStripMenuItem"; + this.restoreWindowToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.restoreWindowToolStripMenuItem.Text = "Restore Default Settings"; + this.restoreWindowToolStripMenuItem.Click += new System.EventHandler(this.restoreWindowToolStripMenuItem_Click); + // + // ReadOnlyCheckBox + // + this.ReadOnlyCheckBox.Appearance = System.Windows.Forms.Appearance.Button; + this.ReadOnlyCheckBox.AutoSize = true; + this.ReadOnlyCheckBox.BackColor = System.Drawing.SystemColors.Control; + this.ReadOnlyCheckBox.Image = global::BizHawk.MultiClient.Properties.Resources.ReadOnly; + this.ReadOnlyCheckBox.ImageAlign = System.Drawing.ContentAlignment.BottomRight; + this.ReadOnlyCheckBox.Location = new System.Drawing.Point(12, 27); + this.ReadOnlyCheckBox.Name = "ReadOnlyCheckBox"; + this.ReadOnlyCheckBox.Size = new System.Drawing.Size(22, 22); + this.ReadOnlyCheckBox.TabIndex = 3; + this.toolTip1.SetToolTip(this.ReadOnlyCheckBox, "Read-only"); + this.ReadOnlyCheckBox.UseVisualStyleBackColor = false; + this.ReadOnlyCheckBox.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // + // contextMenuStrip1 + // + this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.clearToolStripMenuItem3, this.ContextMenu_Delete, this.cloneToolStripMenuItem1, @@ -419,126 +421,126 @@ this.toolStripItem_SelectAll, this.toolStripSeparator9, this.truncateMovieToolStripMenuItem1}); - this.contextMenuStrip1.Name = "contextMenuStrip1"; - this.contextMenuStrip1.Size = new System.Drawing.Size(185, 170); - this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); - // - // clearToolStripMenuItem3 - // - this.clearToolStripMenuItem3.Name = "clearToolStripMenuItem3"; - this.clearToolStripMenuItem3.Size = new System.Drawing.Size(184, 22); - this.clearToolStripMenuItem3.Text = "Clear"; - // - // ContextMenu_Delete - // - this.ContextMenu_Delete.Name = "ContextMenu_Delete"; - this.ContextMenu_Delete.ShortcutKeyDisplayString = "Ctrl+Del"; - this.ContextMenu_Delete.Size = new System.Drawing.Size(184, 22); - this.ContextMenu_Delete.Text = "Delete"; - this.ContextMenu_Delete.Click += new System.EventHandler(this.Delete_Click); - // - // cloneToolStripMenuItem1 - // - this.cloneToolStripMenuItem1.Name = "cloneToolStripMenuItem1"; - this.cloneToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+Ins"; - this.cloneToolStripMenuItem1.Size = new System.Drawing.Size(184, 22); - this.cloneToolStripMenuItem1.Text = "Clone"; - this.cloneToolStripMenuItem1.Click += new System.EventHandler(this.cloneToolStripMenuItem1_Click); - // - // ContextMenu_Insert - // - this.ContextMenu_Insert.Name = "ContextMenu_Insert"; - this.ContextMenu_Insert.ShortcutKeyDisplayString = "Ctrl+Shift+Ins"; - this.ContextMenu_Insert.Size = new System.Drawing.Size(184, 22); - this.ContextMenu_Insert.Text = "Insert"; - this.ContextMenu_Insert.Click += new System.EventHandler(this.Insert_Click); - // - // insertFramesToolStripMenuItem - // - this.insertFramesToolStripMenuItem.Name = "insertFramesToolStripMenuItem"; - this.insertFramesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); - this.insertFramesToolStripMenuItem.Text = "Insert # Frames"; - this.insertFramesToolStripMenuItem.Click += new System.EventHandler(this.insertFramesToolStripMenuItem_Click); - // - // toolStripSeparator5 - // - this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(181, 6); - // - // toolStripItem_SelectAll - // - this.toolStripItem_SelectAll.Name = "toolStripItem_SelectAll"; - this.toolStripItem_SelectAll.Size = new System.Drawing.Size(184, 22); - this.toolStripItem_SelectAll.Text = "Select All"; - this.toolStripItem_SelectAll.Click += new System.EventHandler(this.SelectAll_Click); - // - // toolStripSeparator9 - // - this.toolStripSeparator9.Name = "toolStripSeparator9"; - this.toolStripSeparator9.Size = new System.Drawing.Size(181, 6); - // - // truncateMovieToolStripMenuItem1 - // - this.truncateMovieToolStripMenuItem1.Name = "truncateMovieToolStripMenuItem1"; - this.truncateMovieToolStripMenuItem1.Size = new System.Drawing.Size(184, 22); - this.truncateMovieToolStripMenuItem1.Text = "&Truncate Movie"; - this.truncateMovieToolStripMenuItem1.Click += new System.EventHandler(this.truncateMovieToolStripMenuItem1_Click); - // - // groupBox1 - // - this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.groupBox1.Controls.Add(this.ClipboardDisplay); - this.groupBox1.Controls.Add(this.SelectionDisplay); - this.groupBox1.Controls.Add(this.label2); - this.groupBox1.Controls.Add(this.label1); - this.groupBox1.Location = new System.Drawing.Point(300, 55); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(274, 83); - this.groupBox1.TabIndex = 5; - this.groupBox1.TabStop = false; - this.groupBox1.Text = "Slicer"; - // - // ClipboardDisplay - // - this.ClipboardDisplay.AutoSize = true; - this.ClipboardDisplay.Location = new System.Drawing.Point(68, 36); - this.ClipboardDisplay.Name = "ClipboardDisplay"; - this.ClipboardDisplay.Size = new System.Drawing.Size(31, 13); - this.ClipboardDisplay.TabIndex = 3; - this.ClipboardDisplay.Text = "none"; - // - // SelectionDisplay - // - this.SelectionDisplay.AutoSize = true; - this.SelectionDisplay.Location = new System.Drawing.Point(68, 19); - this.SelectionDisplay.Name = "SelectionDisplay"; - this.SelectionDisplay.Size = new System.Drawing.Size(31, 13); - this.SelectionDisplay.TabIndex = 2; - this.SelectionDisplay.Text = "none"; - // - // label2 - // - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(8, 36); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(54, 13); - this.label2.TabIndex = 1; - this.label2.Text = "Clipboard:"; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(8, 19); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(54, 13); - this.label1.TabIndex = 0; - this.label1.Text = "Selection:"; - // - // toolStrip1 - // - this.toolStrip1.ClickThrough = true; - this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; - this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.contextMenuStrip1.Name = "contextMenuStrip1"; + this.contextMenuStrip1.Size = new System.Drawing.Size(185, 170); + this.contextMenuStrip1.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuStrip1_Opening); + // + // clearToolStripMenuItem3 + // + this.clearToolStripMenuItem3.Name = "clearToolStripMenuItem3"; + this.clearToolStripMenuItem3.Size = new System.Drawing.Size(184, 22); + this.clearToolStripMenuItem3.Text = "Clear"; + // + // ContextMenu_Delete + // + this.ContextMenu_Delete.Name = "ContextMenu_Delete"; + this.ContextMenu_Delete.ShortcutKeyDisplayString = "Ctrl+Del"; + this.ContextMenu_Delete.Size = new System.Drawing.Size(184, 22); + this.ContextMenu_Delete.Text = "Delete"; + this.ContextMenu_Delete.Click += new System.EventHandler(this.Delete_Click); + // + // cloneToolStripMenuItem1 + // + this.cloneToolStripMenuItem1.Name = "cloneToolStripMenuItem1"; + this.cloneToolStripMenuItem1.ShortcutKeyDisplayString = "Ctrl+Ins"; + this.cloneToolStripMenuItem1.Size = new System.Drawing.Size(184, 22); + this.cloneToolStripMenuItem1.Text = "Clone"; + this.cloneToolStripMenuItem1.Click += new System.EventHandler(this.cloneToolStripMenuItem1_Click); + // + // ContextMenu_Insert + // + this.ContextMenu_Insert.Name = "ContextMenu_Insert"; + this.ContextMenu_Insert.ShortcutKeyDisplayString = "Ctrl+Shift+Ins"; + this.ContextMenu_Insert.Size = new System.Drawing.Size(184, 22); + this.ContextMenu_Insert.Text = "Insert"; + this.ContextMenu_Insert.Click += new System.EventHandler(this.Insert_Click); + // + // insertFramesToolStripMenuItem + // + this.insertFramesToolStripMenuItem.Name = "insertFramesToolStripMenuItem"; + this.insertFramesToolStripMenuItem.Size = new System.Drawing.Size(184, 22); + this.insertFramesToolStripMenuItem.Text = "Insert # Frames"; + this.insertFramesToolStripMenuItem.Click += new System.EventHandler(this.insertFramesToolStripMenuItem_Click); + // + // toolStripSeparator5 + // + this.toolStripSeparator5.Name = "toolStripSeparator5"; + this.toolStripSeparator5.Size = new System.Drawing.Size(181, 6); + // + // toolStripItem_SelectAll + // + this.toolStripItem_SelectAll.Name = "toolStripItem_SelectAll"; + this.toolStripItem_SelectAll.Size = new System.Drawing.Size(184, 22); + this.toolStripItem_SelectAll.Text = "Select All"; + this.toolStripItem_SelectAll.Click += new System.EventHandler(this.SelectAll_Click); + // + // toolStripSeparator9 + // + this.toolStripSeparator9.Name = "toolStripSeparator9"; + this.toolStripSeparator9.Size = new System.Drawing.Size(181, 6); + // + // truncateMovieToolStripMenuItem1 + // + this.truncateMovieToolStripMenuItem1.Name = "truncateMovieToolStripMenuItem1"; + this.truncateMovieToolStripMenuItem1.Size = new System.Drawing.Size(184, 22); + this.truncateMovieToolStripMenuItem1.Text = "&Truncate Movie"; + this.truncateMovieToolStripMenuItem1.Click += new System.EventHandler(this.truncateMovieToolStripMenuItem1_Click); + // + // groupBox1 + // + this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.groupBox1.Controls.Add(this.ClipboardDisplay); + this.groupBox1.Controls.Add(this.SelectionDisplay); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Location = new System.Drawing.Point(300, 55); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(274, 83); + this.groupBox1.TabIndex = 5; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Slicer"; + // + // ClipboardDisplay + // + this.ClipboardDisplay.AutoSize = true; + this.ClipboardDisplay.Location = new System.Drawing.Point(68, 36); + this.ClipboardDisplay.Name = "ClipboardDisplay"; + this.ClipboardDisplay.Size = new System.Drawing.Size(31, 13); + this.ClipboardDisplay.TabIndex = 3; + this.ClipboardDisplay.Text = "none"; + // + // SelectionDisplay + // + this.SelectionDisplay.AutoSize = true; + this.SelectionDisplay.Location = new System.Drawing.Point(68, 19); + this.SelectionDisplay.Name = "SelectionDisplay"; + this.SelectionDisplay.Size = new System.Drawing.Size(31, 13); + this.SelectionDisplay.TabIndex = 2; + this.SelectionDisplay.Text = "none"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(8, 36); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(54, 13); + this.label2.TabIndex = 1; + this.label2.Text = "Clipboard:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(8, 19); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(54, 13); + this.label1.TabIndex = 0; + this.label1.Text = "Selection:"; + // + // toolStrip1 + // + this.toolStrip1.ClickThrough = true; + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.RewindToBeginning, this.RewindButton, this.PauseButton, @@ -548,225 +550,225 @@ this.FastFowardToEnd, this.toolStripSeparator6, this.StopButton}); - this.toolStrip1.Location = new System.Drawing.Point(37, 27); - this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(202, 25); - this.toolStrip1.TabIndex = 0; - // - // RewindToBeginning - // - this.RewindToBeginning.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.RewindToBeginning.Image = global::BizHawk.MultiClient.Properties.Resources.BackMore; - this.RewindToBeginning.ImageTransparentColor = System.Drawing.Color.Magenta; - this.RewindToBeginning.Name = "RewindToBeginning"; - this.RewindToBeginning.Size = new System.Drawing.Size(23, 22); - this.RewindToBeginning.Text = "<<"; - this.RewindToBeginning.ToolTipText = "Rewind to Beginning"; - this.RewindToBeginning.Click += new System.EventHandler(this.RewindToBeginning_Click); - // - // RewindButton - // - this.RewindButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.RewindButton.Image = global::BizHawk.MultiClient.Properties.Resources.Back; - this.RewindButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.RewindButton.Name = "RewindButton"; - this.RewindButton.Size = new System.Drawing.Size(23, 22); - this.RewindButton.Text = "<"; - this.RewindButton.ToolTipText = "Rewind"; - this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click); - // - // PauseButton - // - this.PauseButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.PauseButton.Image = global::BizHawk.MultiClient.Properties.Resources.Pause; - this.PauseButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.PauseButton.Name = "PauseButton"; - this.PauseButton.Size = new System.Drawing.Size(23, 22); - this.PauseButton.Text = "Pause Button"; - this.PauseButton.ToolTipText = "Pause"; - this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click); - // - // FrameAdvanceButton - // - this.FrameAdvanceButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.FrameAdvanceButton.Image = global::BizHawk.MultiClient.Properties.Resources.Forward; - this.FrameAdvanceButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.FrameAdvanceButton.Name = "FrameAdvanceButton"; - this.FrameAdvanceButton.Size = new System.Drawing.Size(23, 22); - this.FrameAdvanceButton.Text = ">"; - this.FrameAdvanceButton.ToolTipText = "Frame Advance"; - this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click); - // - // FastForward - // - this.FastForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.FastForward.Image = global::BizHawk.MultiClient.Properties.Resources.FastForward; - this.FastForward.ImageTransparentColor = System.Drawing.Color.Magenta; - this.FastForward.Name = "FastForward"; - this.FastForward.Size = new System.Drawing.Size(23, 22); - this.FastForward.Text = ">>"; - this.FastForward.ToolTipText = "Fast Forward"; - this.FastForward.Click += new System.EventHandler(this.FastForward_Click); - // - // TurboFastForward - // - this.TurboFastForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.TurboFastForward.Enabled = false; - this.TurboFastForward.Image = global::BizHawk.MultiClient.Properties.Resources.TurboFastForward; - this.TurboFastForward.ImageTransparentColor = System.Drawing.Color.Magenta; - this.TurboFastForward.Name = "TurboFastForward"; - this.TurboFastForward.Size = new System.Drawing.Size(23, 22); - this.TurboFastForward.Text = ">>>"; - this.TurboFastForward.ToolTipText = "Turbo Fast Forward"; - this.TurboFastForward.Click += new System.EventHandler(this.TurboFastForward_Click); - // - // FastFowardToEnd - // - this.FastFowardToEnd.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.FastFowardToEnd.Image = global::BizHawk.MultiClient.Properties.Resources.ForwardMore; - this.FastFowardToEnd.ImageTransparentColor = System.Drawing.Color.Magenta; - this.FastFowardToEnd.Name = "FastFowardToEnd"; - this.FastFowardToEnd.Size = new System.Drawing.Size(23, 22); - this.FastFowardToEnd.Text = ">>"; - this.FastFowardToEnd.ToolTipText = "Fast Foward To End"; - this.FastFowardToEnd.Click += new System.EventHandler(this.FastForwardToEnd_Click); - // - // toolStripSeparator6 - // - this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(6, 25); - // - // StopButton - // - this.StopButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; - this.StopButton.Image = global::BizHawk.MultiClient.Properties.Resources.Stop; - this.StopButton.ImageTransparentColor = System.Drawing.Color.Magenta; - this.StopButton.Name = "StopButton"; - this.StopButton.Size = new System.Drawing.Size(23, 22); - this.StopButton.Text = "Stop Movie"; - this.StopButton.Click += new System.EventHandler(this.StopButton_Click); - // - // TASView - // - this.TASView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left))); - this.TASView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.toolStrip1.Location = new System.Drawing.Point(37, 27); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(202, 25); + this.toolStrip1.TabIndex = 0; + // + // RewindToBeginning + // + this.RewindToBeginning.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.RewindToBeginning.Image = global::BizHawk.MultiClient.Properties.Resources.BackMore; + this.RewindToBeginning.ImageTransparentColor = System.Drawing.Color.Magenta; + this.RewindToBeginning.Name = "RewindToBeginning"; + this.RewindToBeginning.Size = new System.Drawing.Size(23, 22); + this.RewindToBeginning.Text = "<<"; + this.RewindToBeginning.ToolTipText = "Rewind to Beginning"; + this.RewindToBeginning.Click += new System.EventHandler(this.RewindToBeginning_Click); + // + // RewindButton + // + this.RewindButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.RewindButton.Image = global::BizHawk.MultiClient.Properties.Resources.Back; + this.RewindButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.RewindButton.Name = "RewindButton"; + this.RewindButton.Size = new System.Drawing.Size(23, 22); + this.RewindButton.Text = "<"; + this.RewindButton.ToolTipText = "Rewind"; + this.RewindButton.Click += new System.EventHandler(this.RewindButton_Click); + // + // PauseButton + // + this.PauseButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.PauseButton.Image = global::BizHawk.MultiClient.Properties.Resources.Pause; + this.PauseButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.PauseButton.Name = "PauseButton"; + this.PauseButton.Size = new System.Drawing.Size(23, 22); + this.PauseButton.Text = "Pause Button"; + this.PauseButton.ToolTipText = "Pause"; + this.PauseButton.Click += new System.EventHandler(this.PauseButton_Click); + // + // FrameAdvanceButton + // + this.FrameAdvanceButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.FrameAdvanceButton.Image = global::BizHawk.MultiClient.Properties.Resources.Forward; + this.FrameAdvanceButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.FrameAdvanceButton.Name = "FrameAdvanceButton"; + this.FrameAdvanceButton.Size = new System.Drawing.Size(23, 22); + this.FrameAdvanceButton.Text = ">"; + this.FrameAdvanceButton.ToolTipText = "Frame Advance"; + this.FrameAdvanceButton.Click += new System.EventHandler(this.FrameAdvanceButton_Click); + // + // FastForward + // + this.FastForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.FastForward.Image = global::BizHawk.MultiClient.Properties.Resources.FastForward; + this.FastForward.ImageTransparentColor = System.Drawing.Color.Magenta; + this.FastForward.Name = "FastForward"; + this.FastForward.Size = new System.Drawing.Size(23, 22); + this.FastForward.Text = ">>"; + this.FastForward.ToolTipText = "Fast Forward"; + this.FastForward.Click += new System.EventHandler(this.FastForward_Click); + // + // TurboFastForward + // + this.TurboFastForward.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.TurboFastForward.Enabled = false; + this.TurboFastForward.Image = global::BizHawk.MultiClient.Properties.Resources.TurboFastForward; + this.TurboFastForward.ImageTransparentColor = System.Drawing.Color.Magenta; + this.TurboFastForward.Name = "TurboFastForward"; + this.TurboFastForward.Size = new System.Drawing.Size(23, 22); + this.TurboFastForward.Text = ">>>"; + this.TurboFastForward.ToolTipText = "Turbo Fast Forward"; + this.TurboFastForward.Click += new System.EventHandler(this.TurboFastForward_Click); + // + // FastFowardToEnd + // + this.FastFowardToEnd.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.FastFowardToEnd.Image = global::BizHawk.MultiClient.Properties.Resources.ForwardMore; + this.FastFowardToEnd.ImageTransparentColor = System.Drawing.Color.Magenta; + this.FastFowardToEnd.Name = "FastFowardToEnd"; + this.FastFowardToEnd.Size = new System.Drawing.Size(23, 22); + this.FastFowardToEnd.Text = ">>"; + this.FastFowardToEnd.ToolTipText = "Fast Foward To End"; + this.FastFowardToEnd.Click += new System.EventHandler(this.FastForwardToEnd_Click); + // + // toolStripSeparator6 + // + this.toolStripSeparator6.Name = "toolStripSeparator6"; + this.toolStripSeparator6.Size = new System.Drawing.Size(6, 25); + // + // StopButton + // + this.StopButton.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.StopButton.Image = global::BizHawk.MultiClient.Properties.Resources.Stop; + this.StopButton.ImageTransparentColor = System.Drawing.Color.Magenta; + this.StopButton.Name = "StopButton"; + this.StopButton.Size = new System.Drawing.Size(23, 22); + this.StopButton.Text = "Stop Movie"; + this.StopButton.Click += new System.EventHandler(this.StopButton_Click); + // + // TASView + // + this.TASView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left))); + this.TASView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.Frame, this.Log}); - this.TASView.ContextMenuStrip = this.contextMenuStrip1; - this.TASView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.TASView.FullRowSelect = true; - this.TASView.GridLines = true; - this.TASView.ItemCount = 0; - this.TASView.Location = new System.Drawing.Point(12, 55); - this.TASView.Name = "TASView"; - this.TASView.selectedItem = -1; - this.TASView.Size = new System.Drawing.Size(282, 452); - this.TASView.TabIndex = 1; - this.TASView.UseCompatibleStateImageBehavior = false; - this.TASView.View = System.Windows.Forms.View.Details; - this.TASView.SelectedIndexChanged += new System.EventHandler(this.TASView_SelectedIndexChanged); - this.TASView.Click += new System.EventHandler(this.TASView_Click); - this.TASView.DoubleClick += new System.EventHandler(this.TASView_DoubleClick); - this.TASView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TASView_KeyDown); - this.TASView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TASView_MouseUp); - this.TASView.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TASView_MouseWheel); - // - // Frame - // - this.Frame.Text = "Frame"; - // - // Log - // - this.Log.Text = "Log"; - this.Log.Width = 201; - // - // VisualizerBox - // - this.VisualizerBox.Controls.Add(this.button1); - this.VisualizerBox.Location = new System.Drawing.Point(300, 144); - this.VisualizerBox.Name = "VisualizerBox"; - this.VisualizerBox.Size = new System.Drawing.Size(274, 166); - this.VisualizerBox.TabIndex = 6; - this.VisualizerBox.TabStop = false; - this.VisualizerBox.Text = "Visualize Savestates"; - this.VisualizerBox.Visible = false; - this.VisualizerBox.Paint += new System.Windows.Forms.PaintEventHandler(this.VisualizerBox_Paint); - this.VisualizerBox.Enter += new System.EventHandler(this.VisualizerBox_Enter); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(211, 137); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(57, 23); - this.button1.TabIndex = 0; - this.button1.Text = "Scan"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // alwaysOnTopToolStripMenuItem - // - this.alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; - this.alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(240, 22); - this.alwaysOnTopToolStripMenuItem.Text = "Always On Top"; - this.alwaysOnTopToolStripMenuItem.Click += new System.EventHandler(this.alwaysOnTopToolStripMenuItem_Click); - // - // TAStudio - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(586, 519); - this.Controls.Add(this.VisualizerBox); - this.Controls.Add(this.toolStrip1); - this.Controls.Add(this.menuStrip1); - this.Controls.Add(this.groupBox1); - this.Controls.Add(this.ReadOnlyCheckBox); - this.Controls.Add(this.TASView); - this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); - this.MainMenuStrip = this.menuStrip1; - this.MinimumSize = new System.Drawing.Size(437, 148); - this.Name = "TAStudio"; - this.Text = "TAStudio"; - this.Load += new System.EventHandler(this.TAStudio_Load); - this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TAStudio_KeyPress); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - this.contextMenuStrip1.ResumeLayout(false); - this.groupBox1.ResumeLayout(false); - this.groupBox1.PerformLayout(); - this.toolStrip1.ResumeLayout(false); - this.toolStrip1.PerformLayout(); - this.VisualizerBox.ResumeLayout(false); - this.ResumeLayout(false); - this.PerformLayout(); + this.TASView.ContextMenuStrip = this.contextMenuStrip1; + this.TASView.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.TASView.FullRowSelect = true; + this.TASView.GridLines = true; + this.TASView.ItemCount = 0; + this.TASView.Location = new System.Drawing.Point(12, 55); + this.TASView.Name = "TASView"; + this.TASView.selectedItem = -1; + this.TASView.Size = new System.Drawing.Size(282, 452); + this.TASView.TabIndex = 1; + this.TASView.UseCompatibleStateImageBehavior = false; + this.TASView.View = System.Windows.Forms.View.Details; + this.TASView.SelectedIndexChanged += new System.EventHandler(this.TASView_SelectedIndexChanged); + this.TASView.Click += new System.EventHandler(this.TASView_Click); + this.TASView.DoubleClick += new System.EventHandler(this.TASView_DoubleClick); + this.TASView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TASView_KeyDown); + this.TASView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.TASView_MouseUp); + this.TASView.MouseWheel += new System.Windows.Forms.MouseEventHandler(this.TASView_MouseWheel); + // + // Frame + // + this.Frame.Text = "Frame"; + // + // Log + // + this.Log.Text = "Log"; + this.Log.Width = 201; + // + // VisualizerBox + // + this.VisualizerBox.Controls.Add(this.button1); + this.VisualizerBox.Location = new System.Drawing.Point(300, 144); + this.VisualizerBox.Name = "VisualizerBox"; + this.VisualizerBox.Size = new System.Drawing.Size(274, 166); + this.VisualizerBox.TabIndex = 6; + this.VisualizerBox.TabStop = false; + this.VisualizerBox.Text = "Visualize Savestates"; + this.VisualizerBox.Visible = false; + this.VisualizerBox.Paint += new System.Windows.Forms.PaintEventHandler(this.VisualizerBox_Paint); + this.VisualizerBox.Enter += new System.EventHandler(this.VisualizerBox_Enter); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(211, 137); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(57, 23); + this.button1.TabIndex = 0; + this.button1.Text = "Scan"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // alwaysOnTopToolStripMenuItem + // + this.alwaysOnTopToolStripMenuItem.Name = "alwaysOnTopToolStripMenuItem"; + this.alwaysOnTopToolStripMenuItem.Size = new System.Drawing.Size(240, 22); + this.alwaysOnTopToolStripMenuItem.Text = "Always On Top"; + this.alwaysOnTopToolStripMenuItem.Click += new System.EventHandler(this.alwaysOnTopToolStripMenuItem_Click); + // + // TAStudio + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(586, 519); + this.Controls.Add(this.VisualizerBox); + this.Controls.Add(this.toolStrip1); + this.Controls.Add(this.menuStrip1); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.ReadOnlyCheckBox); + this.Controls.Add(this.TASView); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MainMenuStrip = this.menuStrip1; + this.MinimumSize = new System.Drawing.Size(437, 148); + this.Name = "TAStudio"; + this.Text = "TAStudio"; + this.Load += new System.EventHandler(this.TAStudio_Load); + this.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TAStudio_KeyPress); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + this.contextMenuStrip1.ResumeLayout(false); + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.VisualizerBox.ResumeLayout(false); + this.ResumeLayout(false); + this.PerformLayout(); - } + } - #endregion + #endregion - private MenuStripEx menuStrip1; - private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem newProjectToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem openProjectToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveProjectToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveProjectAsToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.ToolStripMenuItem importTASFileToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem restoreWindowToolStripMenuItem; - private VirtualListView TASView; + private MenuStripEx menuStrip1; + private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem newProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem openProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveProjectToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveProjectAsToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripMenuItem importTASFileToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem editToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem saveWindowPositionToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem restoreWindowToolStripMenuItem; + private VirtualListView TASView; private System.Windows.Forms.ColumnHeader Log; - private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolStripMenuItem nToolStripMenuItem; - private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; + private System.Windows.Forms.ToolStripMenuItem recentToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripMenuItem nToolStripMenuItem; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator3; private System.Windows.Forms.ToolStripMenuItem clearToolStripMenuItem; private ToolStripEx toolStrip1; - private System.Windows.Forms.ToolStripButton FrameAdvanceButton; - private System.Windows.Forms.ToolStripButton RewindButton; + private System.Windows.Forms.ToolStripButton FrameAdvanceButton; + private System.Windows.Forms.ToolStripButton RewindButton; private System.Windows.Forms.ToolStripButton PauseButton; private System.Windows.Forms.ToolStripMenuItem autoloadToolStripMenuItem; private System.Windows.Forms.CheckBox ReadOnlyCheckBox; @@ -784,8 +786,8 @@ private System.Windows.Forms.ToolStripSeparator toolStripSeparator4; private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripMenuItem clearVirtualPadsToolStripMenuItem; - private System.Windows.Forms.ToolStripButton FastForward; - private System.Windows.Forms.ToolStripButton TurboFastForward; + private System.Windows.Forms.ToolStripButton FastForward; + private System.Windows.Forms.ToolStripButton TurboFastForward; private System.Windows.Forms.ToolStripMenuItem ContextMenu_Delete; private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem cloneToolStripMenuItem1; @@ -811,6 +813,6 @@ private System.Windows.Forms.ToolStripMenuItem cutToolStripMenuItem; private System.Windows.Forms.GroupBox VisualizerBox; private System.Windows.Forms.Button button1; - private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; - } + private System.Windows.Forms.ToolStripMenuItem alwaysOnTopToolStripMenuItem; + } } \ No newline at end of file diff --git a/BizHawk.MultiClient/tools/TAStudio.cs b/BizHawk.MultiClient/tools/TAStudio.cs index 9e0c436c39..251563dfd7 100644 --- a/BizHawk.MultiClient/tools/TAStudio.cs +++ b/BizHawk.MultiClient/tools/TAStudio.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.ComponentModel; using System.Drawing; +using System.IO; using System.Windows.Forms; +using BizHawk.Client.Common; namespace BizHawk.MultiClient { @@ -76,7 +78,7 @@ namespace BizHawk.MultiClient if (Global.Emulator.Frame < stopOnFrame) { - Global.MainForm.PressFrameAdvance = true; + GlobalWinF.MainForm.PressFrameAdvance = true; } } @@ -163,13 +165,13 @@ namespace BizHawk.MultiClient { //TODO: don't engage until new/open project // - Global.MainForm.PauseEmulator(); + GlobalWinF.MainForm.PauseEmulator(); Engaged = true; - Global.OSD.AddMessage("TAStudio engaged"); + GlobalWinF.OSD.AddMessage("TAStudio engaged"); if (Global.MovieSession.Movie.IsActive) { Global.MovieSession.Movie.StateCapturing = true; - ReadOnlyCheckBox.Checked = Global.MainForm.ReadOnly; + ReadOnlyCheckBox.Checked = GlobalWinF.MainForm.ReadOnly; } else { @@ -245,13 +247,13 @@ namespace BizHawk.MultiClient private void StopButton_Click(object sender, EventArgs e) { - Global.MainForm.StopMovie(); + GlobalWinF.MainForm.StopMovie(); Restart(); } private void FrameAdvanceButton_Click(object sender, EventArgs e) { - Global.MainForm.PressFrameAdvance = true; + GlobalWinF.MainForm.PressFrameAdvance = true; } private void RewindButton_Click(object sender, EventArgs e) @@ -259,7 +261,7 @@ namespace BizHawk.MultiClient stopOnFrame = 0; if (Global.MovieSession.Movie.IsFinished || !Global.MovieSession.Movie.IsActive) { - Global.MainForm.Rewind(1); + GlobalWinF.MainForm.Rewind(1); if (Global.Emulator.Frame <= Global.MovieSession.Movie.Frames) { Global.MovieSession.Movie.SwitchToPlay(); @@ -267,14 +269,14 @@ namespace BizHawk.MultiClient } else { - Global.MovieSession.Movie.RewindToFrame(Global.Emulator.Frame - 1); + RewindToFrame(Global.Emulator.Frame - 1); } UpdateValues(); } private void PauseButton_Click(object sender, EventArgs e) { - Global.MainForm.TogglePause(); + GlobalWinF.MainForm.TogglePause(); } private void autoloadToolStripMenuItem_Click(object sender, EventArgs e) @@ -286,7 +288,7 @@ namespace BizHawk.MultiClient { if (ReadOnlyCheckBox.Checked) { - Global.MainForm.SetReadOnly(true); + GlobalWinF.MainForm.SetReadOnly(true); ReadOnlyCheckBox.BackColor = SystemColors.Control; if (Global.MovieSession.Movie.IsActive) @@ -297,7 +299,7 @@ namespace BizHawk.MultiClient } else { - Global.MainForm.SetReadOnly(false); + GlobalWinF.MainForm.SetReadOnly(false); ReadOnlyCheckBox.BackColor = Color.LightCoral; if (Global.MovieSession.Movie.IsActive) { @@ -309,7 +311,7 @@ namespace BizHawk.MultiClient private void RewindToBeginning_Click(object sender, EventArgs e) { - Global.MainForm.Rewind(Global.Emulator.Frame); + GlobalWinF.MainForm.Rewind(Global.Emulator.Frame); DisplayList(); } @@ -318,7 +320,7 @@ namespace BizHawk.MultiClient //TODO: adelikat: I removed the stop on frame feature, so this will keep playing into movie finished mode, need to rebuild that functionality FastFowardToEnd.Checked ^= true; - Global.MainForm.FastForward = FastFowardToEnd.Checked; + GlobalWinF.MainForm.FastForward = FastFowardToEnd.Checked; if (FastFowardToEnd.Checked) { FastForward.Checked = false; @@ -369,12 +371,12 @@ namespace BizHawk.MultiClient private void newProjectToolStripMenuItem_Click(object sender, EventArgs e) { - Global.MainForm.RecordMovie(); + GlobalWinF.MainForm.RecordMovie(); } private void openProjectToolStripMenuItem_Click(object sender, EventArgs e) { - Global.MainForm.PlayMovie(); + GlobalWinF.MainForm.PlayMovie(); } private void saveProjectToolStripMenuItem_Click(object sender, EventArgs e) @@ -396,7 +398,7 @@ namespace BizHawk.MultiClient private void FastForward_Click(object sender, EventArgs e) { FastForward.Checked ^= true; - Global.MainForm.FastForward = FastForward.Checked; + GlobalWinF.MainForm.FastForward = FastForward.Checked; if (FastForward.Checked) { TurboFastForward.Checked = false; @@ -406,7 +408,7 @@ namespace BizHawk.MultiClient private void TurboFastForward_Click(object sender, EventArgs e) { - Global.MainForm.TurboFastForward ^= true; + GlobalWinF.MainForm.TurboFastForward ^= true; TurboFastForward.Checked ^= true; if (TurboFastForward.Checked) { @@ -425,13 +427,13 @@ namespace BizHawk.MultiClient if (TASView.selectedItem <= Global.MovieSession.Movie.StateLastIndex) { stopOnFrame = 0; - Global.MovieSession.Movie.RewindToFrame(TASView.selectedItem); + RewindToFrame(TASView.selectedItem); } else { - Global.MovieSession.Movie.RewindToFrame(Global.MovieSession.Movie.StateLastIndex); + RewindToFrame(Global.MovieSession.Movie.StateLastIndex); stopOnFrame = TASView.selectedItem; - Global.MainForm.PressFrameAdvance = true; + GlobalWinF.MainForm.PressFrameAdvance = true; } UpdateValues(); @@ -458,9 +460,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) { return sfd.FileName; @@ -478,11 +480,11 @@ namespace BizHawk.MultiClient if (e.Delta > 0) //Scroll up { - Global.MovieSession.Movie.RewindToFrame(Global.Emulator.Frame - 1); + RewindToFrame(Global.Emulator.Frame - 1); } else if (e.Delta < 0) //Scroll down { - Global.MainForm.PressFrameAdvance = true; + GlobalWinF.MainForm.PressFrameAdvance = true; } UpdateValues(); @@ -541,6 +543,64 @@ namespace BizHawk.MultiClient UpdateValues(); } + private void RewindToFrame(int frame) + { + if (!Global.MovieSession.Movie.IsActive || Global.MovieSession.Movie.IsFinished) + { + return; + } + else if (frame <= Global.Emulator.Frame) + { + if (frame <= Global.MovieSession.Movie.StateFirstIndex) + { + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Global.MovieSession.Movie.InitState))); + if (Global.MovieSession.Movie.IsRecording) + { + Global.MovieSession.Movie.StartPlayback(); + GlobalWinF.MainForm.RestoreReadWriteOnStop = true; + } + } + else + { + if (frame == 0) + { + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Global.MovieSession.Movie.InitState))); + } + else + { + //frame-1 because we need to go back an extra frame and then run a frame, otherwise the display doesn't get updated. + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Global.MovieSession.Movie.GetState(frame - 1)))); + GlobalWinF.MainForm.UpdateFrame = true; + } + } + } + else if (frame <= Global.MovieSession.Movie.StateLastIndex) + { + Global.Emulator.LoadStateBinary(new BinaryReader(new MemoryStream(Global.MovieSession.Movie.GetState(frame - 1)))); + GlobalWinF.MainForm.UpdateFrame = true; + } + else + { + GlobalWinF.MainForm.UnpauseEmulator(); + } + } + + public void DeleteFrame(int frame) + { + if (frame <= Global.MovieSession.Movie.StateLastIndex) + { + if (frame <= Global.MovieSession.Movie.StateFirstIndex) + { + RewindToFrame(0); + } + else + { + RewindToFrame(frame); + } + } + Global.MovieSession.Movie.DeleteFrame(frame); + } + private void DeleteFrames() { ListView.SelectedIndexCollection list = TASView.SelectedIndices; @@ -739,7 +799,7 @@ namespace BizHawk.MultiClient { ClipboardEntry entry = new ClipboardEntry {Frame = list[i], Inputstr = Global.MovieSession.Movie.GetInput(list[i])}; Clipboard.Add(entry); - Global.MovieSession.Movie.DeleteFrame(list[0]); + DeleteFrame(list[0]); } UpdateValues(); @@ -768,13 +828,13 @@ namespace BizHawk.MultiClient { if (e.Button == MouseButtons.Middle) { - Global.MainForm.TogglePause(); + GlobalWinF.MainForm.TogglePause(); } } private void TAStudio_KeyPress(object sender, KeyPressEventArgs e) { - Global.MainForm.ProcessInput(); + GlobalWinF.MainForm.ProcessInput(); } private void button1_Click(object sender, EventArgs e) diff --git a/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs b/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs index b8844c399e..7673f8d4e1 100644 --- a/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs +++ b/BizHawk.MultiClient/tools/TI83/TI83KeyPad.cs @@ -1,7 +1,9 @@ using System; using System.Drawing; using System.Windows.Forms; + using BizHawk.Emulation.Consoles.Calculator; +using BizHawk.Client.Common; namespace BizHawk.MultiClient { @@ -122,247 +124,247 @@ namespace BizHawk.MultiClient private void button42_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("ENTER"); + GlobalWinF.ClickyVirtualPadController.Click("ENTER"); } private void button43_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("DASH"); + GlobalWinF.ClickyVirtualPadController.Click("DASH"); } private void button39_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("2"); + GlobalWinF.ClickyVirtualPadController.Click("2"); } private void ONE_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("1"); + GlobalWinF.ClickyVirtualPadController.Click("1"); } private void THREE_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("3"); + GlobalWinF.ClickyVirtualPadController.Click("3"); } private void FOUR_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("4"); + GlobalWinF.ClickyVirtualPadController.Click("4"); } private void FIVE_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("5"); + GlobalWinF.ClickyVirtualPadController.Click("5"); } private void SIX_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("6"); + GlobalWinF.ClickyVirtualPadController.Click("6"); } private void SEVEN_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("7"); + GlobalWinF.ClickyVirtualPadController.Click("7"); } private void EIGHT_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("8"); + GlobalWinF.ClickyVirtualPadController.Click("8"); } private void NINE_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("9"); + GlobalWinF.ClickyVirtualPadController.Click("9"); } private void ON_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("ON"); + GlobalWinF.ClickyVirtualPadController.Click("ON"); } private void STO_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("STO"); + GlobalWinF.ClickyVirtualPadController.Click("STO"); } private void PLUS_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("PLUS"); + GlobalWinF.ClickyVirtualPadController.Click("PLUS"); } private void LN_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("LN"); + GlobalWinF.ClickyVirtualPadController.Click("LN"); } private void MINUS_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("MINUS"); + GlobalWinF.ClickyVirtualPadController.Click("MINUS"); } private void LOG_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("LOG"); + GlobalWinF.ClickyVirtualPadController.Click("LOG"); } private void MULTIPLY_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("MULTIPLY"); + GlobalWinF.ClickyVirtualPadController.Click("MULTIPLY"); } private void button26_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("SQUARED"); + GlobalWinF.ClickyVirtualPadController.Click("SQUARED"); } private void button25_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("COMMA"); + GlobalWinF.ClickyVirtualPadController.Click("COMMA"); } private void button24_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("PARAOPEN"); + GlobalWinF.ClickyVirtualPadController.Click("PARAOPEN"); } private void button23_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("PARACLOSE"); + GlobalWinF.ClickyVirtualPadController.Click("PARACLOSE"); } private void button22_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("DIVIDE"); + GlobalWinF.ClickyVirtualPadController.Click("DIVIDE"); } private void button17_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("NEG1"); + GlobalWinF.ClickyVirtualPadController.Click("NEG1"); } private void button18_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("SIN"); + GlobalWinF.ClickyVirtualPadController.Click("SIN"); } private void button19_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("COS"); + GlobalWinF.ClickyVirtualPadController.Click("COS"); } private void button20_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("TAN"); + GlobalWinF.ClickyVirtualPadController.Click("TAN"); } private void button21_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("EXP"); + GlobalWinF.ClickyVirtualPadController.Click("EXP"); } private void button12_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("MATH"); + GlobalWinF.ClickyVirtualPadController.Click("MATH"); } private void button13_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("MATRIX"); + GlobalWinF.ClickyVirtualPadController.Click("MATRIX"); } private void button14_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("PRGM"); + GlobalWinF.ClickyVirtualPadController.Click("PRGM"); } private void button15_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("VARS"); + GlobalWinF.ClickyVirtualPadController.Click("VARS"); } private void button16_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("CLEAR"); + GlobalWinF.ClickyVirtualPadController.Click("CLEAR"); } private void button11_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("ALPHA"); + GlobalWinF.ClickyVirtualPadController.Click("ALPHA"); } private void button4_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("X"); + GlobalWinF.ClickyVirtualPadController.Click("X"); } private void button10_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("STAT"); + GlobalWinF.ClickyVirtualPadController.Click("STAT"); } private void button5_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("2ND"); + GlobalWinF.ClickyVirtualPadController.Click("2ND"); } private void button2_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("MODE"); + GlobalWinF.ClickyVirtualPadController.Click("MODE"); } private void button3_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("DEL"); + GlobalWinF.ClickyVirtualPadController.Click("DEL"); } private void button47_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("LEFT"); + GlobalWinF.ClickyVirtualPadController.Click("LEFT"); } private void button49_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("DOWN"); + GlobalWinF.ClickyVirtualPadController.Click("DOWN"); } private void button48_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("RIGHT"); + GlobalWinF.ClickyVirtualPadController.Click("RIGHT"); } private void button50_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("UP"); + GlobalWinF.ClickyVirtualPadController.Click("UP"); } private void button1_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("Y"); + GlobalWinF.ClickyVirtualPadController.Click("Y"); } private void button6_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("WINDOW"); + GlobalWinF.ClickyVirtualPadController.Click("WINDOW"); } private void button7_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("ZOOM"); + GlobalWinF.ClickyVirtualPadController.Click("ZOOM"); } private void button8_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("TRACE"); + GlobalWinF.ClickyVirtualPadController.Click("TRACE"); } private void button9_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("GRAPH"); + GlobalWinF.ClickyVirtualPadController.Click("GRAPH"); } private void PERIOD_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("DOT"); + GlobalWinF.ClickyVirtualPadController.Click("DOT"); } private void showHotkToolStripMenuItem_Click(object sender, EventArgs e) @@ -381,7 +383,7 @@ namespace BizHawk.MultiClient private void ZERO_Click(object sender, EventArgs e) { - Global.ClickyVirtualPadController.Click("0"); + GlobalWinF.ClickyVirtualPadController.Click("0"); } } } diff --git a/BizHawk.MultiClient/tools/ToolBox.cs b/BizHawk.MultiClient/tools/ToolBox.cs index 87ef09d7d7..4c4c9a8452 100644 --- a/BizHawk.MultiClient/tools/ToolBox.cs +++ b/BizHawk.MultiClient/tools/ToolBox.cs @@ -1,6 +1,8 @@ using System; using System.Drawing; using System.Windows.Forms; + +using BizHawk.Client.Common; using BizHawk.Emulation.Consoles.Nintendo; using BizHawk.Emulation.Consoles.Calculator; using BizHawk.Emulation.Consoles.Nintendo.SNES; @@ -17,8 +19,8 @@ namespace BizHawk.MultiClient private void ToolBox_Load(object sender, EventArgs e) { - int x = Global.MainForm.Location.X + Global.MainForm.Size.Width; - int y = Global.MainForm.Location.Y; + int x = GlobalWinF.MainForm.Location.X + GlobalWinF.MainForm.Size.Width; + int y = GlobalWinF.MainForm.Location.Y; Location = new Point(x, y); HideShowIcons(); } @@ -86,88 +88,88 @@ namespace BizHawk.MultiClient private void toolStripButton1_Click(object sender, EventArgs e) { - Global.MainForm.LoadCheatsWindow(); + GlobalWinF.MainForm.LoadCheatsWindow(); } private void toolStripButton2_Click(object sender, EventArgs e) { - Global.MainForm.LoadRamWatch(true); + GlobalWinF.MainForm.LoadRamWatch(true); } private void toolStripButton3_Click(object sender, EventArgs e) { - Global.MainForm.LoadRamSearch(); + GlobalWinF.MainForm.LoadRamSearch(); } private void HexEditor_Click(object sender, EventArgs e) { - Global.MainForm.LoadHexEditor(); + GlobalWinF.MainForm.LoadHexEditor(); } private void toolStripButton5_Click(object sender, EventArgs e) { - Global.MainForm.OpenLuaConsole(); + GlobalWinF.MainForm.OpenLuaConsole(); } private void NESPPU_Click(object sender, EventArgs e) { - Global.MainForm.LoadNESPPU(); + GlobalWinF.MainForm.LoadNESPPU(); } private void NESDebugger_Click(object sender, EventArgs e) { - Global.MainForm.LoadNESDebugger(); + GlobalWinF.MainForm.LoadNESDebugger(); } private void NESGameGenie_Click(object sender, EventArgs e) { - Global.MainForm.LoadGameGenieEC(); + GlobalWinF.MainForm.LoadGameGenieEC(); } private void NESNameTable_Click(object sender, EventArgs e) { - Global.MainForm.LoadNESNameTable(); + GlobalWinF.MainForm.LoadNESNameTable(); } private void KeyPadTool_Click(object sender, EventArgs e) { if (Global.Emulator is TI83) { - Global.MainForm.LoadTI83KeyPad(); + GlobalWinF.MainForm.LoadTI83KeyPad(); } } private void TAStudioButton_Click(object sender, EventArgs e) { - Global.MainForm.LoadTAStudio(); + GlobalWinF.MainForm.LoadTAStudio(); } private void SNESGraphicsDebuggerButton_Click(object sender, EventArgs e) { if (Global.Emulator is LibsnesCore) { - Global.MainForm.LoadSNESGraphicsDebugger(); + GlobalWinF.MainForm.LoadSNESGraphicsDebugger(); } } private void TAStudioButton_Click_1(object sender, EventArgs e) { - Global.MainForm.LoadVirtualPads(); + GlobalWinF.MainForm.LoadVirtualPads(); } private void SNESGameGenie_Click(object sender, EventArgs e) { - Global.MainForm.LoadGameGenieEC(); + GlobalWinF.MainForm.LoadGameGenieEC(); } private void GGGameGenie_Click(object sender, EventArgs e) { - Global.MainForm.LoadGameGenieEC(); + GlobalWinF.MainForm.LoadGameGenieEC(); } private void GBGameGenie_Click(object sender, EventArgs e) { - Global.MainForm.LoadGameGenieEC(); + GlobalWinF.MainForm.LoadGameGenieEC(); } diff --git a/BizHawk.MultiClient/tools/ToolHelpers.cs b/BizHawk.MultiClient/tools/ToolHelpers.cs index 0061f18092..705c39cbdc 100644 --- a/BizHawk.MultiClient/tools/ToolHelpers.cs +++ b/BizHawk.MultiClient/tools/ToolHelpers.cs @@ -1,13 +1,63 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class ToolHelpers { + public static FileInfo GetCheatFileFromUser(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; + + GlobalWinF.Sound.StopSound(); + var result = ofd.ShowDialog(); + GlobalWinF.Sound.StartSound(); + if (result != DialogResult.OK) + return null; + var file = new FileInfo(ofd.FileName); + return file; + } + + public static FileInfo GetCheatSaveFileFromUser(string currentFile) + { + var sfd = new SaveFileDialog(); + if (!String.IsNullOrWhiteSpace(currentFile)) + { + sfd.FileName = Path.GetFileNameWithoutExtension(currentFile); + } + 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; + GlobalWinF.Sound.StopSound(); + var result = sfd.ShowDialog(); + GlobalWinF.Sound.StartSound(); + if (result != DialogResult.OK) + { + return null; + } + + var file = new FileInfo(sfd.FileName); + Global.Config.LastRomPath = file.DirectoryName; + return file; + } + public static ToolStripMenuItem GenerateAutoLoadItem(RecentFiles recent) { var auto = new ToolStripMenuItem { Text = "&Auto-Load", Checked = recent.AutoLoad }; @@ -46,14 +96,14 @@ namespace BizHawk.MultiClient public static void HandleLoadError(RecentFiles recent, string path) { - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); DialogResult result = MessageBox.Show("Could not open " + path + "\nRemove from list?", "File not found", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (result == DialogResult.Yes) { recent.Remove(path); } - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); } public static ToolStripMenuItem[] GenerateMemoryDomainMenuItems(Action SetCallback, string SelectedDomain = "", int? maxSize = null) @@ -107,11 +157,11 @@ namespace BizHawk.MultiClient public static void UpdateCheatRelatedTools() { - Global.MainForm.RamWatch1.UpdateValues(); - Global.MainForm.HexEditor1.UpdateValues(); - Global.MainForm.Cheats_UpdateValues(); - Global.MainForm.RamSearch1.UpdateValues(); - Global.MainForm.UpdateCheatStatus(); + GlobalWinF.MainForm.RamWatch1.UpdateValues(); + GlobalWinF.MainForm.HexEditor1.UpdateValues(); + GlobalWinF.MainForm.Cheats_UpdateValues(); + GlobalWinF.MainForm.RamSearch1.UpdateValues(); + GlobalWinF.MainForm.UpdateCheatStatus(); } public static void UnfreezeAll() @@ -150,9 +200,9 @@ namespace BizHawk.MultiClient public static void ViewInHexEditor(MemoryDomain domain, IEnumerable addresses) { - Global.MainForm.LoadHexEditor(); - Global.MainForm.HexEditor1.SetDomain(domain); - Global.MainForm.HexEditor1.SetToAddresses(addresses.ToList()); + GlobalWinF.MainForm.LoadHexEditor(); + GlobalWinF.MainForm.HexEditor1.SetDomain(domain); + GlobalWinF.MainForm.HexEditor1.SetToAddresses(addresses.ToList()); } public static MemoryDomain DomainByName(string name) diff --git a/BizHawk.MultiClient/tools/TraceLogger.cs b/BizHawk.MultiClient/tools/TraceLogger.cs index 9041628845..4ecb5670f5 100644 --- a/BizHawk.MultiClient/tools/TraceLogger.cs +++ b/BizHawk.MultiClient/tools/TraceLogger.cs @@ -5,6 +5,8 @@ using System.Text; using System.Windows.Forms; using System.IO; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class TraceLogger : Form @@ -29,7 +31,7 @@ namespace BizHawk.MultiClient public void SaveConfigSettings() { - Global.CoreComm.Tracer.Enabled = false; + GlobalWinF.CoreComm.Tracer.Enabled = false; Global.Config.TraceLoggerWndx = Location.X; Global.Config.TraceLoggerWndy = Location.Y; } @@ -60,7 +62,7 @@ namespace BizHawk.MultiClient ClearList(); LoggingEnabled.Checked = true; - Global.CoreComm.Tracer.Enabled = true; + GlobalWinF.CoreComm.Tracer.Enabled = true; SetTracerBoxTitle(); Restart(); } @@ -104,7 +106,7 @@ namespace BizHawk.MultiClient private void LoggingEnabled_CheckedChanged(object sender, EventArgs e) { - Global.CoreComm.Tracer.Enabled = LoggingEnabled.Checked; + GlobalWinF.CoreComm.Tracer.Enabled = LoggingEnabled.Checked; SetTracerBoxTitle(); } @@ -130,13 +132,13 @@ namespace BizHawk.MultiClient { using (StreamWriter sw = new StreamWriter(LogFile.FullName, true)) { - sw.Write(Global.CoreComm.Tracer.TakeContents()); + sw.Write(GlobalWinF.CoreComm.Tracer.TakeContents()); } } private void LogToWindow() { - string[] instructions = Global.CoreComm.Tracer.TakeContents().Split('\n'); + string[] instructions = GlobalWinF.CoreComm.Tracer.TakeContents().Split('\n'); if (!String.IsNullOrWhiteSpace(instructions[0])) { foreach (string s in instructions) @@ -197,7 +199,7 @@ namespace BizHawk.MultiClient private void SetTracerBoxTitle() { - if (Global.CoreComm.Tracer.Enabled) + if (GlobalWinF.CoreComm.Tracer.Enabled) { if (ToFileRadio.Checked) { @@ -318,10 +320,10 @@ namespace BizHawk.MultiClient sfd.Filter = "Text Files (*.txt)|*.txt|Log Files (*.log)|*.log|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; @@ -339,7 +341,7 @@ namespace BizHawk.MultiClient if (file != null) { DumpListToDisk(file); - Global.OSD.AddMessage("Log dumped to " + file.FullName); + GlobalWinF.OSD.AddMessage("Log dumped to " + file.FullName); } } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26.cs index de0455624e..d01cf7e09a 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class VirtualPadA26 : VirtualPad @@ -146,15 +148,15 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "A26" && Global.Emulator.SystemId != "C64") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky(Controller + " Button", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Button", B1.Checked); } public override void Clear() @@ -162,11 +164,11 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "A26" && Global.Emulator.SystemId != "C64") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26Control.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26Control.cs index ec10b6dbce..425ef20c2f 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26Control.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA26Control.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class VirtualPadA26Control : VirtualPad @@ -101,7 +103,7 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "A26") return; else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Reset", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B1.Checked); if (B1.Checked) { B1.BackColor = Color.Pink; @@ -113,7 +115,7 @@ namespace BizHawk.MultiClient } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Select", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Select", B2.Checked); if (B2.Checked) { B2.BackColor = Color.Pink; @@ -129,8 +131,8 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "A26") return; - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Reset", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Pause", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Pause", false); B1.Checked = false; B2.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78.cs index 1cdaeb27b4..aa26454a71 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadA78 : UserControl, IVirtualPad @@ -77,27 +79,27 @@ namespace BizHawk.MultiClient } else if (sender == PU) { - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); } else if (sender == PD) { - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); } else if (sender == PL) { - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); } else if (sender == PR) { - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky(Controller + " Trigger", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Trigger", B1.Checked); } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky(Controller + " Trigger 2", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Trigger 2", B2.Checked); } } @@ -106,12 +108,12 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "A78") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Trigger", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Trigger 2", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Trigger", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Trigger 2", false); PU.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78Control.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78Control.cs index 03474c0124..119e780a99 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78Control.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadA78Control.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadA78Control : UserControl, IVirtualPad @@ -76,19 +78,19 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); } else if (sender == B3) { - Global.StickyXORAdapter.SetSticky("Select", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Select", B3.Checked); } else if (sender == B4) { - Global.StickyXORAdapter.SetSticky("Pause", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Pause", B4.Checked); } } @@ -96,10 +98,10 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "A78") return; - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Power", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Reset", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky("Select", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky("Pause", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Power", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Select", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Pause", false); B1.Checked = false; B2.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadButton.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadButton.cs index 4c57f6d612..35f6b4ffbb 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadButton.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadButton.cs @@ -45,7 +45,7 @@ namespace BizHawk.MultiClient protected void SetSticky() { - Global.StickyXORAdapter.SetSticky(ControllerButton, Checked); + GlobalWinF.StickyXORAdapter.SetSticky(ControllerButton, Checked); if (Checked == false) { @@ -55,7 +55,7 @@ namespace BizHawk.MultiClient protected void SetAutofireSticky() { - Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, Checked); + GlobalWinF.AutofireStickyXORAdapter.SetSticky(ControllerButton, Checked); if (Checked == false) { @@ -92,8 +92,8 @@ namespace BizHawk.MultiClient _rightClicked = false; ForeColor = Color.Black; Checked = false; - Global.AutofireStickyXORAdapter.SetSticky(ControllerButton, false); - Global.StickyXORAdapter.SetSticky(ControllerButton, false); + GlobalWinF.AutofireStickyXORAdapter.SetSticky(ControllerButton, false); + GlobalWinF.StickyXORAdapter.SetSticky(ControllerButton, false); } } } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadC64Keyboard.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadC64Keyboard.cs index cef468a18d..e6f3e5b5cf 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadC64Keyboard.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadC64Keyboard.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadC64Keyboard : UserControl , IVirtualPad @@ -19,319 +21,319 @@ namespace BizHawk.MultiClient } else if (sender == KF1) { - Global.StickyXORAdapter.SetSticky("Key F1", KF1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key F1", KF1.Checked); } else if (sender == KF3) { - Global.StickyXORAdapter.SetSticky("Key F3", KF3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key F3", KF3.Checked); } else if (sender == KF5) { - Global.StickyXORAdapter.SetSticky("Key F5", KF5.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key F5", KF5.Checked); } else if (sender == KF7) { - Global.StickyXORAdapter.SetSticky("Key F7", KF7.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key F7", KF7.Checked); } else if (sender == KLeftArrow) { - Global.StickyXORAdapter.SetSticky("Key Left Arrow", KLeftArrow.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Left Arrow", KLeftArrow.Checked); } else if (sender == K1) { - Global.StickyXORAdapter.SetSticky("Key 1", K1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 1", K1.Checked); } else if (sender == K2) { - Global.StickyXORAdapter.SetSticky("Key 2", K2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 2", K2.Checked); } else if (sender == K3) { - Global.StickyXORAdapter.SetSticky("Key 3", K3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 3", K3.Checked); } else if (sender == K4) { - Global.StickyXORAdapter.SetSticky("Key 4", K4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 4", K4.Checked); } else if (sender == K5) { - Global.StickyXORAdapter.SetSticky("Key 5", K5.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 5", K5.Checked); } else if (sender == K6) { - Global.StickyXORAdapter.SetSticky("Key 6", K6.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 6", K6.Checked); } else if (sender == K7) { - Global.StickyXORAdapter.SetSticky("Key 7", K7.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 7", K7.Checked); } else if (sender == K8) { - Global.StickyXORAdapter.SetSticky("Key 8", K8.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 8", K8.Checked); } else if (sender == K9) { - Global.StickyXORAdapter.SetSticky("Key 9", K9.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 9", K9.Checked); } else if (sender == K0) { - Global.StickyXORAdapter.SetSticky("Key 0", K0.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key 0", K0.Checked); } else if (sender == KPlus) { - Global.StickyXORAdapter.SetSticky("Key Plus", KPlus.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Plus", KPlus.Checked); } else if (sender == KMinus) { - Global.StickyXORAdapter.SetSticky("Key Minus", KMinus.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Minus", KMinus.Checked); } else if (sender == KPound) { - Global.StickyXORAdapter.SetSticky("Key Pound", KPound.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Pound", KPound.Checked); } else if (sender == KClear) { - Global.StickyXORAdapter.SetSticky("Key Clear/Home", KClear.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Clear/Home", KClear.Checked); } else if (sender == KInsert) { - Global.StickyXORAdapter.SetSticky("Key Insert/Delete", KInsert.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Insert/Delete", KInsert.Checked); } else if (sender == KCtrl) { - Global.StickyXORAdapter.SetSticky("Key Control", KCtrl.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Control", KCtrl.Checked); } else if (sender == KQ) { - Global.StickyXORAdapter.SetSticky("Key Q", KQ.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Q", KQ.Checked); } else if (sender == KW) { - Global.StickyXORAdapter.SetSticky("Key W", KW.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key W", KW.Checked); } else if (sender == KE) { - Global.StickyXORAdapter.SetSticky("Key E", KE.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key E", KE.Checked); } else if (sender == KR) { - Global.StickyXORAdapter.SetSticky("Key R", KR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key R", KR.Checked); } else if (sender == KT) { - Global.StickyXORAdapter.SetSticky("Key T", KT.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key T", KT.Checked); } else if (sender == KY) { - Global.StickyXORAdapter.SetSticky("Key Y", KY.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Y", KY.Checked); } else if (sender == KU) { - Global.StickyXORAdapter.SetSticky("Key U", KU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key U", KU.Checked); } else if (sender == KI) { - Global.StickyXORAdapter.SetSticky("Key I", KI.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key I", KI.Checked); } else if (sender == KO) { - Global.StickyXORAdapter.SetSticky("Key O", KO.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key O", KO.Checked); } else if (sender == KP) { - Global.StickyXORAdapter.SetSticky("Key P", KP.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key P", KP.Checked); } else if (sender == KAt) { - Global.StickyXORAdapter.SetSticky("Key At", KAt.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key At", KAt.Checked); } else if (sender == KAsterisk) { - Global.StickyXORAdapter.SetSticky("Key Asterisk", KAsterisk.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Asterisk", KAsterisk.Checked); } else if (sender == KUpArrow) { - Global.StickyXORAdapter.SetSticky("Key Up Arrow", KUpArrow.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Up Arrow", KUpArrow.Checked); } else if (sender == KRST) { - Global.StickyXORAdapter.SetSticky("Key Restore", KRST.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Restore", KRST.Checked); } else if (sender == KRun) { - Global.StickyXORAdapter.SetSticky("Key Run/Stop", KRun.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Run/Stop", KRun.Checked); } else if (sender == KLck) { - Global.StickyXORAdapter.SetSticky("Key Lck", KLck.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Lck", KLck.Checked); } else if (sender == KA) { - Global.StickyXORAdapter.SetSticky("Key A", KA.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key A", KA.Checked); } else if (sender == KS) { - Global.StickyXORAdapter.SetSticky("Key S", KS.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key S", KS.Checked); } else if (sender == KD) { - Global.StickyXORAdapter.SetSticky("Key D", KD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key D", KD.Checked); } else if (sender == KF) { - Global.StickyXORAdapter.SetSticky("Key F", KF.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key F", KF.Checked); } else if (sender == KG) { - Global.StickyXORAdapter.SetSticky("Key G", KG.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key G", KG.Checked); } else if (sender == KH) { - Global.StickyXORAdapter.SetSticky("Key H", KH.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key H", KH.Checked); } else if (sender == KJ) { - Global.StickyXORAdapter.SetSticky("Key J", KJ.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key J", KJ.Checked); } else if (sender == KK) { - Global.StickyXORAdapter.SetSticky("Key K", KK.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key K", KK.Checked); } else if (sender == KL) { - Global.StickyXORAdapter.SetSticky("Key L", KL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key L", KL.Checked); } else if (sender == KColon) { - Global.StickyXORAdapter.SetSticky("Key Colon", KColon.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Colon", KColon.Checked); } else if (sender == KSemicolon) { - Global.StickyXORAdapter.SetSticky("Key Semicolon", KSemicolon.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Semicolon", KSemicolon.Checked); } else if (sender == KEquals) { - Global.StickyXORAdapter.SetSticky("Key Equal", KEquals.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Equal", KEquals.Checked); } else if (sender == KReturn) { - Global.StickyXORAdapter.SetSticky("Key Return", KReturn.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Return", KReturn.Checked); } else if (sender == KCommodore) { - Global.StickyXORAdapter.SetSticky("Key Commodore", KCommodore.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Commodore", KCommodore.Checked); } else if (sender == KLeftShift) { - Global.StickyXORAdapter.SetSticky("Key Left Shift", KLeftShift.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Left Shift", KLeftShift.Checked); } else if (sender == KZ) { - Global.StickyXORAdapter.SetSticky("Key Z", KZ.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Z", KZ.Checked); } else if (sender == KX) { - Global.StickyXORAdapter.SetSticky("Key X", KX.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key X", KX.Checked); } else if (sender == KC) { - Global.StickyXORAdapter.SetSticky("Key C", KC.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key C", KC.Checked); } else if (sender == KV) { - Global.StickyXORAdapter.SetSticky("Key V", KV.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key V", KV.Checked); } else if (sender == KB) { - Global.StickyXORAdapter.SetSticky("Key B", KB.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key B", KB.Checked); } else if (sender == KN) { - Global.StickyXORAdapter.SetSticky("Key N", KN.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key N", KN.Checked); } else if (sender == KM) { - Global.StickyXORAdapter.SetSticky("Key M", KM.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key M", KM.Checked); } else if (sender == KComma) { - Global.StickyXORAdapter.SetSticky("Key Comma", KComma.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Comma", KComma.Checked); } else if (sender == KSemicolon) { - Global.StickyXORAdapter.SetSticky("Key Semicolon", KSemicolon.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Semicolon", KSemicolon.Checked); } else if (sender == KEquals) { - Global.StickyXORAdapter.SetSticky("Key Equal", KEquals.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Equal", KEquals.Checked); } else if (sender == KReturn) { - Global.StickyXORAdapter.SetSticky("Key Return", KReturn.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Return", KReturn.Checked); } else if (sender == KCommodore) { - Global.StickyXORAdapter.SetSticky("Key Commodore", KCommodore.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Commodore", KCommodore.Checked); } else if (sender == KLeftShift) { - Global.StickyXORAdapter.SetSticky("Key Left Shift", KLeftShift.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Left Shift", KLeftShift.Checked); } else if (sender == KZ) { - Global.StickyXORAdapter.SetSticky("Key Z", KZ.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Z", KZ.Checked); } else if (sender == KX) { - Global.StickyXORAdapter.SetSticky("Key X", KX.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key X", KX.Checked); } else if (sender == KC) { - Global.StickyXORAdapter.SetSticky("Key C", KC.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key C", KC.Checked); } else if (sender == KV) { - Global.StickyXORAdapter.SetSticky("Key V", KV.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key V", KV.Checked); } else if (sender == KB) { - Global.StickyXORAdapter.SetSticky("Key B", KB.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key B", KB.Checked); } else if (sender == KN) { - Global.StickyXORAdapter.SetSticky("Key N", KN.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key N", KN.Checked); } else if (sender == KM) { - Global.StickyXORAdapter.SetSticky("Key M", KM.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key M", KM.Checked); } else if (sender == KComma) { - Global.StickyXORAdapter.SetSticky("Key Comma", KComma.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Comma", KComma.Checked); } else if (sender == KPeriod) { - Global.StickyXORAdapter.SetSticky("Key Period", KPeriod.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Period", KPeriod.Checked); } else if (sender == KSlash) { - Global.StickyXORAdapter.SetSticky("Key Slash", KSlash.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Slash", KSlash.Checked); } else if (sender == KRightShift) { - Global.StickyXORAdapter.SetSticky("Key Right Shift", KRightShift.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Right Shift", KRightShift.Checked); } else if (sender == KCursorUp) { - Global.StickyXORAdapter.SetSticky("Key Cursor Up/Down", KCursorUp.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Cursor Up/Down", KCursorUp.Checked); } else if (sender == KCursorLeft) { - Global.StickyXORAdapter.SetSticky("Key Cursor Left/Right", KCursorLeft.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Cursor Left/Right", KCursorLeft.Checked); } else if (sender == KSpace) { - Global.StickyXORAdapter.SetSticky("Key Space", KSpace.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Key Space", KSpace.Checked); } } @@ -343,71 +345,71 @@ namespace BizHawk.MultiClient } else { - if (KF1.Checked) Global.StickyXORAdapter.SetSticky("Key F1", false); - if (KF3.Checked) Global.StickyXORAdapter.SetSticky("Key F3", false); - if (KF5.Checked) Global.StickyXORAdapter.SetSticky("Key F5", false); - if (KF7.Checked) Global.StickyXORAdapter.SetSticky("Key F7", false); - if (KLeftArrow.Checked) Global.StickyXORAdapter.SetSticky("Key Left Arrow", false); - if (K1.Checked) Global.StickyXORAdapter.SetSticky("Key 1", false); - if (K2.Checked) Global.StickyXORAdapter.SetSticky("Key 2", false); - if (K3.Checked) Global.StickyXORAdapter.SetSticky("Key 3", false); - if (K4.Checked) Global.StickyXORAdapter.SetSticky("Key 4", false); - if (K5.Checked) Global.StickyXORAdapter.SetSticky("Key 5", false); - if (K6.Checked) Global.StickyXORAdapter.SetSticky("Key 6", false); - if (K7.Checked) Global.StickyXORAdapter.SetSticky("Key 7", false); - if (K8.Checked) Global.StickyXORAdapter.SetSticky("Key 8", false); - if (K9.Checked) Global.StickyXORAdapter.SetSticky("Key 9", false); - if (K0.Checked) Global.StickyXORAdapter.SetSticky("Key Plus", false); - if (KPlus.Checked) Global.StickyXORAdapter.SetSticky("Key Minus", false); - if (KMinus.Checked) Global.StickyXORAdapter.SetSticky("Key Pound", false); - if (KPound.Checked) Global.StickyXORAdapter.SetSticky("Key Clear/Home", false); - if (KClear.Checked) Global.StickyXORAdapter.SetSticky("Key Insert/Delete", false); - if (KInsert.Checked) Global.StickyXORAdapter.SetSticky("Key Control", false); - if (KCtrl.Checked) Global.StickyXORAdapter.SetSticky("Key Q", false); - if (KQ.Checked) Global.StickyXORAdapter.SetSticky("Key W", false); - if (KW.Checked) Global.StickyXORAdapter.SetSticky("Key E", false); - if (KE.Checked) Global.StickyXORAdapter.SetSticky("Key R", false); - if (KR.Checked) Global.StickyXORAdapter.SetSticky("Key T", false); - if (KT.Checked) Global.StickyXORAdapter.SetSticky("Key Y", false); - if (KY.Checked) Global.StickyXORAdapter.SetSticky("Key U", false); - if (KU.Checked) Global.StickyXORAdapter.SetSticky("Key I", false); - if (KI.Checked) Global.StickyXORAdapter.SetSticky("Key O", false); - if (KO.Checked) Global.StickyXORAdapter.SetSticky("Key P", false); - if (KP.Checked) Global.StickyXORAdapter.SetSticky("Key At", false); - if (KAt.Checked) Global.StickyXORAdapter.SetSticky("Key Asterisk", false); - if (KAsterisk.Checked) Global.StickyXORAdapter.SetSticky("Key Up Arrow", false); - if (KUpArrow.Checked) Global.StickyXORAdapter.SetSticky("Key Restore", false); - if (KRST.Checked) Global.StickyXORAdapter.SetSticky("Key Run/Stop", false); - if (KRun.Checked) Global.StickyXORAdapter.SetSticky("Key Lck", false); - if (KLck.Checked) Global.StickyXORAdapter.SetSticky("Key A", false); - if (KA.Checked) Global.StickyXORAdapter.SetSticky("Key S", false); - if (KS.Checked) Global.StickyXORAdapter.SetSticky("Key D", false); - if (KD.Checked) Global.StickyXORAdapter.SetSticky("Key F", false); - if (KF.Checked) Global.StickyXORAdapter.SetSticky("Key G", false); - if (KG.Checked) Global.StickyXORAdapter.SetSticky("Key H", false); - if (KH.Checked) Global.StickyXORAdapter.SetSticky("Key J", false); - if (KJ.Checked) Global.StickyXORAdapter.SetSticky("Key K", false); - if (KK.Checked) Global.StickyXORAdapter.SetSticky("Key L", false); - if (KL.Checked) Global.StickyXORAdapter.SetSticky("Key Colon", false); - if (KColon.Checked) Global.StickyXORAdapter.SetSticky("Key Semicolon", false); - if (KSemicolon.Checked) Global.StickyXORAdapter.SetSticky("Key Equal", false); - if (KEquals.Checked) Global.StickyXORAdapter.SetSticky("Key Return", false); - if (KReturn.Checked) Global.StickyXORAdapter.SetSticky("Key Commodore", false); - if (KCommodore.Checked) Global.StickyXORAdapter.SetSticky("Key Left Shift", false); - if (KLeftShift.Checked) Global.StickyXORAdapter.SetSticky("Key Z", false); - if (KZ.Checked) Global.StickyXORAdapter.SetSticky("Key X", false); - if (KX.Checked) Global.StickyXORAdapter.SetSticky("Key C", false); - if (KC.Checked) Global.StickyXORAdapter.SetSticky("Key V", false); - if (KV.Checked) Global.StickyXORAdapter.SetSticky("Key B", false); - if (KB.Checked) Global.StickyXORAdapter.SetSticky("Key N", false); - if (KN.Checked) Global.StickyXORAdapter.SetSticky("Key M", false); - if (KM.Checked) Global.StickyXORAdapter.SetSticky("Key Comma", false); - if (KComma.Checked) Global.StickyXORAdapter.SetSticky("Key Period", false); - if (KPeriod.Checked) Global.StickyXORAdapter.SetSticky("Key Slash", false); - if (KSlash.Checked) Global.StickyXORAdapter.SetSticky("Key Right Shift", false); - if (KRightShift.Checked) Global.StickyXORAdapter.SetSticky("Key Cursor Up/Down", false); - if (KCursorUp.Checked) Global.StickyXORAdapter.SetSticky("Key Cursor Left/Right", false); - if (KCursorLeft.Checked) Global.StickyXORAdapter.SetSticky("Key Space", false); + if (KF1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key F1", false); + if (KF3.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key F3", false); + if (KF5.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key F5", false); + if (KF7.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key F7", false); + if (KLeftArrow.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Left Arrow", false); + if (K1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 1", false); + if (K2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 2", false); + if (K3.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 3", false); + if (K4.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 4", false); + if (K5.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 5", false); + if (K6.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 6", false); + if (K7.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 7", false); + if (K8.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 8", false); + if (K9.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key 9", false); + if (K0.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Plus", false); + if (KPlus.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Minus", false); + if (KMinus.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Pound", false); + if (KPound.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Clear/Home", false); + if (KClear.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Insert/Delete", false); + if (KInsert.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Control", false); + if (KCtrl.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Q", false); + if (KQ.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key W", false); + if (KW.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key E", false); + if (KE.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key R", false); + if (KR.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key T", false); + if (KT.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Y", false); + if (KY.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key U", false); + if (KU.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key I", false); + if (KI.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key O", false); + if (KO.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key P", false); + if (KP.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key At", false); + if (KAt.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Asterisk", false); + if (KAsterisk.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Up Arrow", false); + if (KUpArrow.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Restore", false); + if (KRST.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Run/Stop", false); + if (KRun.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Lck", false); + if (KLck.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key A", false); + if (KA.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key S", false); + if (KS.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key D", false); + if (KD.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key F", false); + if (KF.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key G", false); + if (KG.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key H", false); + if (KH.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key J", false); + if (KJ.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key K", false); + if (KK.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key L", false); + if (KL.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Colon", false); + if (KColon.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Semicolon", false); + if (KSemicolon.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Equal", false); + if (KEquals.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Return", false); + if (KReturn.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Commodore", false); + if (KCommodore.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Left Shift", false); + if (KLeftShift.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Z", false); + if (KZ.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key X", false); + if (KX.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key C", false); + if (KC.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key V", false); + if (KV.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key B", false); + if (KB.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key N", false); + if (KN.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key M", false); + if (KM.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Comma", false); + if (KComma.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Period", false); + if (KPeriod.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Slash", false); + if (KSlash.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Right Shift", false); + if (KRightShift.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Cursor Up/Down", false); + if (KCursorUp.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Cursor Left/Right", false); + if (KCursorLeft.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Key Space", false); KF1.Checked = false; KF3.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadColeco.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadColeco.cs index a7c08c3955..79cb8a15f7 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadColeco.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadColeco.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadColeco : UserControl , IVirtualPad @@ -107,42 +109,42 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "Coleco") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == KeyLeft) - Global.StickyXORAdapter.SetSticky(Controller + " L", KeyLeft.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", KeyLeft.Checked); else if (sender == KeyRight) - Global.StickyXORAdapter.SetSticky(Controller + " R", KeyRight.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", KeyRight.Checked); else if (sender == KP1) - Global.StickyXORAdapter.SetSticky(Controller + " Key1", KP1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key1", KP1.Checked); else if (sender == KP2) - Global.StickyXORAdapter.SetSticky(Controller + " Key2", KP2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key2", KP2.Checked); else if (sender == KP3) - Global.StickyXORAdapter.SetSticky(Controller + " Key3", KP3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key3", KP3.Checked); else if (sender == KP4) - Global.StickyXORAdapter.SetSticky(Controller + " Key4", KP4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key4", KP4.Checked); else if (sender == KP5) - Global.StickyXORAdapter.SetSticky(Controller + " Key5", KP5.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key5", KP5.Checked); else if (sender == KP6) - Global.StickyXORAdapter.SetSticky(Controller + " Key6", KP6.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key6", KP6.Checked); else if (sender == KP7) - Global.StickyXORAdapter.SetSticky(Controller + " Key7", KP7.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key7", KP7.Checked); else if (sender == KP8) - Global.StickyXORAdapter.SetSticky(Controller + " Key8", KP8.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key8", KP8.Checked); else if (sender == KP9) - Global.StickyXORAdapter.SetSticky(Controller + " Key9", KP9.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key9", KP9.Checked); else if (sender == KPStar) - Global.StickyXORAdapter.SetSticky(Controller + " Star", KPStar.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Star", KPStar.Checked); else if (sender == KP0) - Global.StickyXORAdapter.SetSticky(Controller + " Key0", KP0.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key0", KP0.Checked); else if (sender == KPPound) - Global.StickyXORAdapter.SetSticky(Controller + " Pound", KPPound.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Pound", KPPound.Checked); } public void Clear() @@ -150,24 +152,24 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "Coleco") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (KeyLeft.Checked) Global.StickyXORAdapter.SetSticky(Controller + " L", false); - if (KeyRight.Checked) Global.StickyXORAdapter.SetSticky(Controller + " R", false); - if (KP1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key0", false); - if (KP2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key1", false); - if (KP3.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key2", false); - if (KP4.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key3", false); - if (KP5.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key4", false); - if (KP6.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key5", false); - if (KP7.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key6", false); - if (KP8.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key7", false); - if (KP9.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key8", false); - if (KPStar.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Key9", false); - if (KP0.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Star", false); - if (KPPound.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Pound", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (KeyLeft.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", false); + if (KeyRight.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", false); + if (KP1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key0", false); + if (KP2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key1", false); + if (KP3.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key2", false); + if (KP4.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key3", false); + if (KP5.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key4", false); + if (KP6.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key5", false); + if (KP7.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key6", false); + if (KP8.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key7", false); + if (KP9.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key8", false); + if (KPStar.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Key9", false); + if (KP0.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Star", false); + if (KPPound.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Pound", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs index d69442b706..a4c460a397 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadForm.cs @@ -2,7 +2,9 @@ using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; + using BizHawk.Emulation.Consoles.Nintendo.N64; +using BizHawk.Client.Common; namespace BizHawk.MultiClient { @@ -224,8 +226,8 @@ namespace BizHawk.MultiClient protected override void OnClosed(EventArgs e) { //is this a good idea? - Global.StickyXORAdapter.ClearStickies(); - Global.StickyXORAdapter.ClearStickyFloats(); + GlobalWinF.StickyXORAdapter.ClearStickies(); + GlobalWinF.StickyXORAdapter.ClearStickyFloats(); } public void ClearVirtualPadHolds() diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGB.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGB.cs index e06bfdd701..24a07def1f 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGB.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGB.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadGB : VirtualPad @@ -201,35 +203,35 @@ namespace BizHawk.MultiClient } else if (sender == PU) { - Global.StickyXORAdapter.SetSticky("Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Up", PU.Checked); } else if (sender == PD) { - Global.StickyXORAdapter.SetSticky("Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Down", PD.Checked); } else if (sender == PL) { - Global.StickyXORAdapter.SetSticky("Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Left", PL.Checked); } else if (sender == PR) { - Global.StickyXORAdapter.SetSticky("Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Right", PR.Checked); } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Select", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Select", B1.Checked); } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Start", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Start", B2.Checked); } else if (sender == B3) { - Global.StickyXORAdapter.SetSticky("B", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("B", B3.Checked); } else if (sender == B4) { - Global.StickyXORAdapter.SetSticky("A", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("A", B4.Checked); } } @@ -238,14 +240,14 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "GB") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky("Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky("Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky("Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky("Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Select", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Start", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky("B", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky("A", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Select", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Start", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky("B", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky("A", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBA.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBA.cs index 85f879f876..59fcd03203 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBA.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBA.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class VirtualPadGBA : VirtualPad @@ -229,41 +231,41 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "GBA") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky("Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky("Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky("Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky("Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky("Select", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Select", B1.Checked); else if (sender == B2) - Global.StickyXORAdapter.SetSticky("Start", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Start", B2.Checked); else if (sender == B3) - Global.StickyXORAdapter.SetSticky("B", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("B", B3.Checked); else if (sender == B4) - Global.StickyXORAdapter.SetSticky("A", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("A", B4.Checked); else if (sender == B5) - Global.StickyXORAdapter.SetSticky("L", B5.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("L", B5.Checked); else if (sender == B6) - Global.StickyXORAdapter.SetSticky("R", B6.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("R", B6.Checked); } public override void Clear() { if (Global.Emulator.SystemId != "GBA") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky("Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky("Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky("Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky("Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Select", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Start", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky("B", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky("A", false); - if (B5.Checked) Global.StickyXORAdapter.SetSticky("L", false); - if (B6.Checked) Global.StickyXORAdapter.SetSticky("R", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Select", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Start", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky("B", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky("A", false); + if (B5.Checked) GlobalWinF.StickyXORAdapter.SetSticky("L", false); + if (B6.Checked) GlobalWinF.StickyXORAdapter.SetSticky("R", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBControl.cs index 334ff952cc..fa36b8898e 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGBControl.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadGBControl : VirtualPad @@ -93,7 +95,7 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); if (B1.Checked) { B1.BackColor = Color.Pink; @@ -112,7 +114,7 @@ namespace BizHawk.MultiClient return; } - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Power", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Power", false); B1.Checked = false; } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGen3Button.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGen3Button.cs index 35be775bfe..79fbf44c51 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGen3Button.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadGen3Button.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class VirtualPadGen3Button : VirtualPad @@ -193,35 +195,35 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "GEN") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky(Controller + " C", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " C", B1.Checked); else if (sender == B2) - Global.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); else if (sender == B3) - Global.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); else if (sender == B4) - Global.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); } public override void Clear() { if (Global.Emulator.SystemId != "GEN") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " C", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64.cs index e3a617d588..5805c8c5f7 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64.cs @@ -4,6 +4,8 @@ using System.Windows.Forms; using System.Collections.Generic; using System.Linq; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadN64 : UserControl, IVirtualPad @@ -165,8 +167,8 @@ namespace BizHawk.MultiClient { int? x = hasValue ? X : (int?)null; int? y = hasValue ? Y : (int?)null; - Global.StickyXORAdapter.SetFloat(Controller + " X Axis", x); - Global.StickyXORAdapter.SetFloat(Controller + " Y Axis", y); + GlobalWinF.StickyXORAdapter.SetFloat(Controller + " X Axis", x); + GlobalWinF.StickyXORAdapter.SetFloat(Controller + " Y Axis", y); AnalogControl1.X = X; AnalogControl1.Y = Y; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs index aae6868bac..0eb52d1f39 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadN64Control.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadN64Control : VirtualPad @@ -116,7 +118,7 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); if (B1.Checked) B1.BackColor = Color.Pink; else @@ -124,7 +126,7 @@ namespace BizHawk.MultiClient } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); if (B2.Checked) B2.BackColor = Color.Pink; else @@ -139,7 +141,7 @@ namespace BizHawk.MultiClient B1.Checked = false; B2.Checked = false; - Global.StickyXORAdapter.SetSticky("Reset", false); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); } } } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNES.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNES.cs index e08dbde346..046f3bcc5f 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNES.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNES.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadNES : VirtualPad @@ -196,35 +198,35 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "NES") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); else if (sender == B2) - Global.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); else if (sender == B3) - Global.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); else if (sender == B4) - Global.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); } public override void Clear() { if (Global.Emulator.SystemId != "NES") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Select", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs index 9bab96025e..373d71b123 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadNESControl.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadNESControl : VirtualPad @@ -116,7 +118,7 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); if (B1.Checked) B1.BackColor = Color.Pink; else @@ -124,7 +126,7 @@ namespace BizHawk.MultiClient } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); if (B2.Checked) B2.BackColor = Color.Pink; else @@ -139,7 +141,7 @@ namespace BizHawk.MultiClient B1.Checked = false; B2.Checked = false; - Global.StickyXORAdapter.SetSticky("Reset", false); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); } } } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadPCE.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadPCE.cs index 02f2e8a2f8..3d09dff019 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadPCE.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadPCE.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadPCE : VirtualPad @@ -196,35 +198,35 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "PCE") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); else if (sender == B2) - Global.StickyXORAdapter.SetSticky(Controller + " Run", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Run", B2.Checked); else if (sender == B3) - Global.StickyXORAdapter.SetSticky(Controller + " B2", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B2", B3.Checked); else if (sender == B4) - Global.StickyXORAdapter.SetSticky(Controller + " B1", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B1", B4.Checked); } public override void Clear() { if (Global.Emulator.SystemId != "PCE" && Global.Emulator.SystemId != "PCECD" && Global.Emulator.SystemId != "SGX") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Select", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Run", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B2", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B1", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Run", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B2", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B1", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMS.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMS.cs index ef49fe0b0e..5d1bf9baf0 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMS.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMS.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadSMS : VirtualPad @@ -167,29 +169,29 @@ namespace BizHawk.MultiClient if (Global.Emulator.SystemId != "SMS" && Global.Emulator.SystemId != "GG" && Global.Emulator.SystemId != "SG") return; if (sender == PU) - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); else if (sender == PD) - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); else if (sender == PL) - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); else if (sender == PR) - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); else if (sender == B1) - Global.StickyXORAdapter.SetSticky(Controller + " B1", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B1", B1.Checked); else if (sender == B2) - Global.StickyXORAdapter.SetSticky(Controller + " B2", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B2", B2.Checked); } public override void Clear() { if (Global.Emulator.SystemId != "SMS" && Global.Emulator.SystemId != "GG" && Global.Emulator.SystemId != "SG") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B1", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B2", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B1", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B2", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMSControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMSControl.cs index b3fb55a9f5..e71e651fa9 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMSControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSMSControl.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadSMSControl : VirtualPad @@ -102,7 +104,7 @@ namespace BizHawk.MultiClient else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Pause", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Pause", B1.Checked); if (B1.Checked) B1.BackColor = Color.Pink; else @@ -110,7 +112,7 @@ namespace BizHawk.MultiClient } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); if (B2.Checked) B2.BackColor = Color.Pink; else @@ -122,8 +124,8 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "SMS" && Global.Emulator.SystemId != "GG" && Global.Emulator.SystemId != "SG") return; - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Pause", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Reset", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Pause", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); B1.Checked = false; B2.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNES.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNES.cs index 910fbf72df..2274b3c9c4 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNES.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNES.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadSNES : VirtualPad @@ -265,52 +267,52 @@ namespace BizHawk.MultiClient } else if (sender == PU) { - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); } else if (sender == PD) { - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); } else if (sender == PL) { - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); } else if (sender == PR) { - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", B1.Checked); } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", B2.Checked); } else if (sender == B3) { - Global.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", B3.Checked); } else if (sender == B4) { - Global.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", B4.Checked); } else if (sender == B5) { - Global.StickyXORAdapter.SetSticky(Controller + " X", B5.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " X", B5.Checked); } else if (sender == B6) { - Global.StickyXORAdapter.SetSticky(Controller + " Y", B6.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Y", B6.Checked); } else if (sender == B7) { - Global.StickyXORAdapter.SetSticky(Controller + " L", B7.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", B7.Checked); } else if (sender == B8) { - Global.StickyXORAdapter.SetSticky(Controller + " R", B8.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", B8.Checked); } } @@ -322,18 +324,18 @@ namespace BizHawk.MultiClient } else { - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (B1.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Select", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false); - if (B3.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false); - if (B4.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false); - if (B5.Checked) Global.StickyXORAdapter.SetSticky(Controller + " X", false); - if (B6.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Y", false); - if (B7.Checked) Global.StickyXORAdapter.SetSticky(Controller + " L", false); - if (B8.Checked) Global.StickyXORAdapter.SetSticky(Controller + " R", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Select", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", false); + if (B3.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", false); + if (B4.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", false); + if (B5.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " X", false); + if (B6.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Y", false); + if (B7.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", false); + if (B8.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", false); PU.Checked = false; PD.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNESControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNESControl.cs index 94ce4bd05c..d9a2cf1669 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNESControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSNESControl.cs @@ -3,6 +3,8 @@ using System.Drawing; using System.Windows.Forms; using System.Text; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class VirtualPadSNESControl : VirtualPad @@ -126,7 +128,7 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); if (B1.Checked) { B1.BackColor = Color.Pink; @@ -138,7 +140,7 @@ namespace BizHawk.MultiClient } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); if (B2.Checked) { B2.BackColor = Color.Pink; @@ -158,8 +160,8 @@ namespace BizHawk.MultiClient } else { - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Reset", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Power", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Power", false); B1.Checked = false; B2.Checked = false; diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturn.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturn.cs index 999ef7fe6e..1209c28405 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturn.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturn.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadSaturn : UserControl, IVirtualPad @@ -81,23 +83,23 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "SAT") return; - if (PU.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Up", false); - if (PD.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Down", false); - if (PL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Left", false); - if (PR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Right", false); + if (PU.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", false); + if (PD.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", false); + if (PL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", false); + if (PR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", false); - if (BStart.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Start", false); + if (BStart.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", false); - if (BX.Checked) Global.StickyXORAdapter.SetSticky(Controller + " X", false); - if (BY.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Y", false); - if (BZ.Checked) Global.StickyXORAdapter.SetSticky(Controller + " Z", false); + if (BX.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " X", false); + if (BY.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Y", false); + if (BZ.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Z", false); - if (BA.Checked) Global.StickyXORAdapter.SetSticky(Controller + " A", false); - if (BB.Checked) Global.StickyXORAdapter.SetSticky(Controller + " B", false); - if (BC.Checked) Global.StickyXORAdapter.SetSticky(Controller + " C", false); + if (BA.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", false); + if (BB.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", false); + if (BC.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " C", false); - if (BL.Checked) Global.StickyXORAdapter.SetSticky(Controller + " L", false); - if (BR.Checked) Global.StickyXORAdapter.SetSticky(Controller + " R", false); + if (BL.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", false); + if (BR.Checked) GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", false); PU.Checked = false; PD.Checked = false; @@ -143,55 +145,55 @@ namespace BizHawk.MultiClient } else if (sender == PU) { - Global.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Up", PU.Checked); } else if (sender == PD) { - Global.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Down", PD.Checked); } else if (sender == PL) { - Global.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Left", PL.Checked); } else if (sender == PR) { - Global.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Right", PR.Checked); } else if (sender == BStart) { - Global.StickyXORAdapter.SetSticky(Controller + " Start", BStart.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Start", BStart.Checked); } else if (sender == BX) { - Global.StickyXORAdapter.SetSticky(Controller + " X", BX.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " X", BX.Checked); } else if (sender == BY) { - Global.StickyXORAdapter.SetSticky(Controller + " Y", BY.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Y", BY.Checked); } else if (sender == BZ) { - Global.StickyXORAdapter.SetSticky(Controller + " Z", BZ.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " Z", BZ.Checked); } else if (sender == BA) { - Global.StickyXORAdapter.SetSticky(Controller + " A", BA.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " A", BA.Checked); } else if (sender == BB) { - Global.StickyXORAdapter.SetSticky(Controller + " B", BB.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " B", BB.Checked); } else if (sender == BC) { - Global.StickyXORAdapter.SetSticky(Controller + " C", BC.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " C", BC.Checked); } else if (sender == BL) { - Global.StickyXORAdapter.SetSticky(Controller + " L", BL.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " L", BL.Checked); } else if (sender == BR) { - Global.StickyXORAdapter.SetSticky(Controller + " R", BR.Checked); + GlobalWinF.StickyXORAdapter.SetSticky(Controller + " R", BR.Checked); } } } diff --git a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturnControl.cs b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturnControl.cs index 25c866a2a8..c21ef2882a 100644 --- a/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturnControl.cs +++ b/BizHawk.MultiClient/tools/VirtualPads/VirtualPadSaturnControl.cs @@ -2,6 +2,8 @@ using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class VirtualPadSaturnControl : UserControl, IVirtualPad @@ -77,11 +79,11 @@ namespace BizHawk.MultiClient } else if (sender == B1) { - Global.StickyXORAdapter.SetSticky("Power", B1.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Power", B1.Checked); } else if (sender == B2) { - Global.StickyXORAdapter.SetSticky("Reset", B2.Checked); + GlobalWinF.StickyXORAdapter.SetSticky("Reset", B2.Checked); } } @@ -89,8 +91,8 @@ namespace BizHawk.MultiClient { if (Global.Emulator.SystemId != "SAT") return; - if (B1.Checked) Global.StickyXORAdapter.SetSticky("Power", false); - if (B2.Checked) Global.StickyXORAdapter.SetSticky("Reset", false); + if (B1.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Power", false); + if (B2.Checked) GlobalWinF.StickyXORAdapter.SetSticky("Reset", false); B1.Checked = false; B2.Checked = false; diff --git a/BizHawk.MultiClient/tools/Watch/RamPoke.Designer.cs b/BizHawk.MultiClient/tools/Watch/RamPoke.Designer.cs index 4032035dfd..723c2da48c 100644 --- a/BizHawk.MultiClient/tools/Watch/RamPoke.Designer.cs +++ b/BizHawk.MultiClient/tools/Watch/RamPoke.Designer.cs @@ -99,7 +99,7 @@ // // 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(82, 57); this.ValueBox.MaxLength = 9; @@ -108,7 +108,7 @@ this.ValueBox.Size = new System.Drawing.Size(116, 20); this.ValueBox.TabIndex = 10; this.ValueBox.Text = "0000"; - this.ValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex; + this.ValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; // // ValueHexLabel // diff --git a/BizHawk.MultiClient/tools/Watch/RamPoke.cs b/BizHawk.MultiClient/tools/Watch/RamPoke.cs index 755a99768c..e0f9f77b39 100644 --- a/BizHawk.MultiClient/tools/Watch/RamPoke.cs +++ b/BizHawk.MultiClient/tools/Watch/RamPoke.cs @@ -4,6 +4,8 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class RamPoke : Form diff --git a/BizHawk.MultiClient/tools/Watch/RamSearch.Designer.cs b/BizHawk.MultiClient/tools/Watch/RamSearch.Designer.cs index 0cc7a03582..7d068caff9 100644 --- a/BizHawk.MultiClient/tools/Watch/RamSearch.Designer.cs +++ b/BizHawk.MultiClient/tools/Watch/RamSearch.Designer.cs @@ -1352,7 +1352,7 @@ // this.SpecificValueBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.SpecificValueBox.ByteSize = BizHawk.MultiClient.Watch.WatchSize.Byte; + this.SpecificValueBox.ByteSize = BizHawk.Client.Common.Watch.WatchSize.Byte; this.SpecificValueBox.CharacterCasing = System.Windows.Forms.CharacterCasing.Upper; this.SpecificValueBox.Enabled = false; this.SpecificValueBox.Location = new System.Drawing.Point(114, 38); @@ -1362,7 +1362,7 @@ this.SpecificValueBox.Size = new System.Drawing.Size(72, 20); this.SpecificValueBox.TabIndex = 15; this.SpecificValueBox.Text = "00"; - this.SpecificValueBox.Type = BizHawk.MultiClient.Watch.DisplayType.Hex; + this.SpecificValueBox.Type = BizHawk.Client.Common.Watch.DisplayType.Hex; this.SpecificValueBox.TextChanged += new System.EventHandler(this.CompareToValue_TextChanged); // // RamSearch diff --git a/BizHawk.MultiClient/tools/Watch/RamSearch.cs b/BizHawk.MultiClient/tools/Watch/RamSearch.cs index e1cc60c573..626dd6f03b 100644 --- a/BizHawk.MultiClient/tools/Watch/RamSearch.cs +++ b/BizHawk.MultiClient/tools/Watch/RamSearch.cs @@ -10,6 +10,8 @@ using System.Windows.Forms; using System.IO; using System.Globalization; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { /// @@ -786,10 +788,10 @@ namespace BizHawk.MultiClient { if (SelectedIndices.Count > 0) { - Global.MainForm.LoadRamWatch(true); + GlobalWinF.MainForm.LoadRamWatch(true); for (int x = 0; x < SelectedIndices.Count; x++) { - Global.MainForm.RamWatch1.AddWatch(Searches[SelectedIndices[x]]); + GlobalWinF.MainForm.RamWatch1.AddWatch(Searches[SelectedIndices[x]]); } if (Global.Config.RamSearchAlwaysExcludeRamWatch) @@ -808,7 +810,7 @@ namespace BizHawk.MultiClient { if (SelectedIndices.Count > 0) { - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var poke = new RamPoke(); var watches = new List(); @@ -821,13 +823,13 @@ namespace BizHawk.MultiClient poke.InitialLocation = GetPromptPoint(); poke.ShowDialog(); UpdateValues(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); } } private void RemoveRamWatchesFromList() { - Searches.RemoveRange(Global.MainForm.RamWatch1.AddressList); + Searches.RemoveRange(GlobalWinF.MainForm.RamWatch1.AddressList); WatchListView.ItemCount = Searches.Count; SetTotal(); } @@ -872,9 +874,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) { diff --git a/BizHawk.MultiClient/tools/Watch/RamSearchEngine.cs b/BizHawk.MultiClient/tools/Watch/RamSearchEngine.cs index 0407d36599..3133daa029 100644 --- a/BizHawk.MultiClient/tools/Watch/RamSearchEngine.cs +++ b/BizHawk.MultiClient/tools/Watch/RamSearchEngine.cs @@ -6,6 +6,8 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { //TODO: move me diff --git a/BizHawk.MultiClient/tools/Watch/RamWatch.cs b/BizHawk.MultiClient/tools/Watch/RamWatch.cs index 7c937e2189..8393964d2c 100644 --- a/BizHawk.MultiClient/tools/Watch/RamWatch.cs +++ b/BizHawk.MultiClient/tools/Watch/RamWatch.cs @@ -7,6 +7,8 @@ using System.Text; using System.Windows.Forms; using System.IO; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class RamWatch : Form @@ -65,7 +67,7 @@ namespace BizHawk.MultiClient for (int x = 0; x < Watches.Count; x++) { bool alert = Watches[x].IsSeparator ? false : Global.CheatList.IsActive(Watches[x].Domain, Watches[x].Address.Value); - Global.OSD.AddGUIText( + GlobalWinF.OSD.AddGUIText( Watches[x].ToString(), Global.Config.DispRamWatchx, (Global.Config.DispRamWatchy + (x * 14)), @@ -164,9 +166,9 @@ namespace BizHawk.MultiClient if (Watches.Changes) { - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); DialogResult result = MessageBox.Show("Save Changes?", "Ram Watch", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (result == DialogResult.Yes) { Watches.Save(); @@ -518,9 +520,9 @@ namespace BizHawk.MultiClient InitialLocation = GetPromptPoint() }; we.SetWatch(Watches.Domain); - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); we.ShowDialog(); - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); if (we.DialogResult == DialogResult.OK) { @@ -548,7 +550,7 @@ namespace BizHawk.MultiClient } we.SetWatch(Watches.Domain, SelectedWatches, duplicate ? WatchEditor.Mode.Duplicate : WatchEditor.Mode.Edit); - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = we.ShowDialog(); if (result == DialogResult.OK) { @@ -567,7 +569,7 @@ namespace BizHawk.MultiClient } } - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); UpdateValues(); } } @@ -586,13 +588,13 @@ namespace BizHawk.MultiClient poke.SetWatch(SelectedWatches); } - Global.Sound.StopSound(); + GlobalWinF.Sound.StopSound(); var result = poke.ShowDialog(); if (result == DialogResult.OK) { UpdateValues(); } - Global.Sound.StartSound(); + GlobalWinF.Sound.StartSound(); } } @@ -1029,7 +1031,7 @@ namespace BizHawk.MultiClient if (!Global.Config.DisplayRamWatch) { - Global.OSD.ClearGUIText(); + GlobalWinF.OSD.ClearGUIText(); } else { @@ -1146,7 +1148,7 @@ namespace BizHawk.MultiClient var selected = SelectedWatches; if (selected.Any()) { - Global.MainForm.LoadHexEditor(); + GlobalWinF.MainForm.LoadHexEditor(); if (selected.Select(x => x.Domain).Distinct().Count() > 1) { diff --git a/BizHawk.MultiClient/tools/Watch/Watch.cs b/BizHawk.MultiClient/tools/Watch/Watch.cs deleted file mode 100644 index 93f04961b1..0000000000 --- a/BizHawk.MultiClient/tools/Watch/Watch.cs +++ /dev/null @@ -1,930 +0,0 @@ -using System; -using System.Globalization; -using System.Collections.Generic; - -namespace BizHawk.MultiClient -{ - public abstract class Watch - { - public enum WatchSize { Byte = 1, Word = 2, DWord = 4, Separator = 0 }; - public enum DisplayType { Separator, Signed, Unsigned, Hex, Binary, FixedPoint_12_4, FixedPoint_20_12, Float }; - public enum PreviousType { Original = 0, LastSearch = 1, LastFrame = 2, LastChange = 3 }; - - public static string DisplayTypeToString(DisplayType type) - { - switch (type) - { - default: - return type.ToString(); - case DisplayType.FixedPoint_12_4: - return "Fixed Point 12.4"; - case DisplayType.FixedPoint_20_12: - return "Fixed Point 20.12"; - } - } - - public static DisplayType StringToDisplayType(string name) - { - switch (name) - { - default: - return (DisplayType)Enum.Parse(typeof(DisplayType), name); - case "Fixed Point 12.4": - return DisplayType.FixedPoint_12_4; - case "Fixed Point 20.12": - return DisplayType.FixedPoint_20_12; - } - } - - protected int _address; - protected MemoryDomain _domain; - protected DisplayType _type; - protected bool _bigEndian; - protected int _changecount; - protected string _notes = String.Empty; - - public abstract int? Value { get; } - public abstract string ValueString { get; } - public abstract WatchSize Size { get; } - - public abstract int? Previous { get; } - public abstract string PreviousStr { get; } - public abstract void ResetPrevious(); - - public abstract bool Poke(string value); - - public virtual DisplayType Type { get { return _type; } set { _type = value; } } - public virtual bool BigEndian { get { return _bigEndian; } set { _bigEndian = value; } } - - public MemoryDomain Domain { get { return _domain; } } - - public string DomainName { get { return _domain != null ? _domain.Name : String.Empty; } } - - public virtual int? Address { get { return _address; } } - - public virtual string AddressString { get { return _address.ToString(AddressFormatStr); } } - - public virtual bool IsSeparator { get { return false; } } - - public char SizeAsChar - { - get - { - switch (Size) - { - default: - case WatchSize.Separator: - return 'S'; - case WatchSize.Byte: - return 'b'; - case WatchSize.Word: - return 'w'; - case WatchSize.DWord: - return 'd'; - } - } - } - - public static WatchSize SizeFromChar(char c) - { - switch (c) - { - default: - case 'S': - return WatchSize.Separator; - case 'b': - return WatchSize.Byte; - case 'w': - return WatchSize.Word; - case 'd': - return WatchSize.DWord; - } - } - - public char TypeAsChar - { - get - { - switch (Type) - { - default: - case DisplayType.Separator: - return '_'; - case DisplayType.Unsigned: - return 's'; - case DisplayType.Signed: - return 'u'; - case DisplayType.Hex: - return 'h'; - case DisplayType.Binary: - return 'b'; - case DisplayType.FixedPoint_12_4: - return '1'; - case DisplayType.FixedPoint_20_12: - return '2'; - case DisplayType.Float: - return 'f'; - } - } - } - - public static DisplayType DisplayTypeFromChar(char c) - { - switch (c) - { - default: - case '_': - return DisplayType.Separator; - case 'u': - return DisplayType.Unsigned; - case 's': - return DisplayType.Signed; - case 'h': - return DisplayType.Hex; - case 'b': - return DisplayType.Binary; - case '1': - return DisplayType.FixedPoint_12_4; - case '2': - return DisplayType.FixedPoint_20_12; - case 'f': - return DisplayType.Float; - } - } - - public string AddressFormatStr - { - get - { - if (_domain != null) - { - return "X" + IntHelpers.GetNumDigits(_domain.Size - 1).ToString(); - } - else - { - return ""; - } - } - } - - protected byte GetByte() - { - return _domain.PeekByte(_address); - } - - protected ushort GetWord() - { - return _domain.PeekWord(_address, _bigEndian ? Endian.Big : Endian.Little); - } - - protected uint GetDWord() - { - return _domain.PeekDWord(_address, _bigEndian ? Endian.Big : Endian.Little); - } - - protected void PokeByte(byte val) - { - _domain.PokeByte(_address, val); - } - - protected void PokeWord(ushort val) - { - _domain.PokeWord(_address, val, _bigEndian ? Endian.Big : Endian.Little); - } - - protected void PokeDWord(uint val) - { - _domain.PokeDWord(_address, val, _bigEndian ? Endian.Big : Endian.Little); - } - - public void ClearChangeCount() { _changecount = 0; } - - public string Notes { get { return _notes; } set { _notes = value; } } - - public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, string notes, bool bigEndian) - { - switch (size) - { - default: - case WatchSize.Separator: - return SeparatorWatch.Instance; - case WatchSize.Byte: - return new ByteWatch(domain, address, type, bigEndian, notes); - case WatchSize.Word: - return new WordWatch(domain, address, type, bigEndian, notes); - case WatchSize.DWord: - return new DWordWatch(domain, address, type, bigEndian, notes); - } - } - - public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, bool bigendian, int prev, int changecount) - { - switch (size) - { - default: - case WatchSize.Separator: - return SeparatorWatch.Instance; - case WatchSize.Byte: - return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount); - case WatchSize.Word: - return new WordWatch(domain, address, type, bigendian, (ushort)prev, changecount); - case WatchSize.DWord: - return new DWordWatch(domain, address, type, bigendian, (uint)prev, changecount); - } - } - - public static List AvailableTypes(WatchSize size) - { - switch (size) - { - default: - case WatchSize.Separator: - return SeparatorWatch.ValidTypes; - case WatchSize.Byte: - return ByteWatch.ValidTypes; - case WatchSize.Word: - return WordWatch.ValidTypes; - case WatchSize.DWord: - return DWordWatch.ValidTypes; - } - } - - public int ChangeCount { get { return _changecount; } } - - public abstract string Diff { get; } - - public abstract void Update(); - } - - public sealed class SeparatorWatch : Watch - { - public static SeparatorWatch Instance - { - get { return new SeparatorWatch(); } - } - - public override int? Address - { - get { return null; } - } - - public override int? Value - { - get { return null; } - } - - public override int? Previous - { - get { return null; } - } - - public override string AddressString - { - get { return String.Empty; } - } - - public override string ValueString - { - get { return String.Empty; } - } - - public override string PreviousStr - { - get { return String.Empty; } - } - - public override string ToString() - { - return "----"; - } - - public override bool IsSeparator - { - get { return true; } - } - - public override WatchSize Size - { - get { return WatchSize.Separator; } - } - - public static List ValidTypes - { - get { return new List { DisplayType.Separator }; } - } - - public override DisplayType Type - { - get { return DisplayType.Separator; } - } - - public override bool Poke(string value) - { - return false; - } - - public override void ResetPrevious() - { - return; - } - - public override string Diff { get { return String.Empty; } } - - public override void Update() { return; } - } - - public sealed class ByteWatch : Watch - { - private byte _previous; - private byte _value; - - public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) - { - _address = address; - _domain = domain; - _value = _previous = GetByte(); - if (Watch.AvailableTypes(WatchSize.Byte).Contains(type)) - { - _type = type; - } - _bigEndian = bigEndian; - if (notes != null) - { - Notes = notes; - } - } - - public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) - { - _previous = prev; - _changecount = changeCount; - } - - public override int? Address - { - get { return _address; } - } - - public override int? Value - { - get { return GetByte(); } - } - - public override string ValueString - { - get { return FormatValue(GetByte()); } - } - - public override int? Previous - { - get { return _previous; } - } - - public override string PreviousStr - { - get { return FormatValue(_previous); } - } - - public override void ResetPrevious() - { - _previous = GetByte(); - } - - public override string ToString() - { - return Notes + ": " + ValueString; - } - - public override bool IsSeparator - { - get { return false; } - } - - public override WatchSize Size - { - get { return WatchSize.Byte; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.Binary - }; - } - } - - public string FormatValue(byte val) - { - switch (Type) - { - default: - case DisplayType.Unsigned: - return val.ToString(); - case DisplayType.Signed: - return ((sbyte)val).ToString(); - case DisplayType.Hex: - return String.Format("{0:X2}", val); - case DisplayType.Binary: - return Convert.ToString(val, 2).PadLeft(8, '0').Insert(4, " "); - } - } - - public override bool Poke(string value) - { - try - { - byte val = 0; - switch (Type) - { - case DisplayType.Unsigned: - if (InputValidate.IsValidUnsignedNumber(value)) - { - val = (byte)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Signed: - if (InputValidate.IsValidSignedNumber(value)) - { - val = (byte)(sbyte)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Hex: - if (InputValidate.IsValidHexNumber(value)) - { - val = (byte)int.Parse(value, NumberStyles.HexNumber); - } - else - { - return false; - } - break; - case DisplayType.Binary: - if (InputValidate.IsValidBinaryNumber(value)) - { - val = (byte)Convert.ToInt32(value, 2); - } - else - { - return false; - } - break; - } - - PokeByte(val); - return true; - } - catch - { - return false; - } - } - - public override string Diff - { - get - { - string diff = String.Empty; - int diffVal = _value - _previous; - if (diffVal > 0) - { - diff = "+"; - } - else if (diffVal < 0) - { - diff = "-"; - } - return diff + FormatValue((byte)(_previous - _value)); - } - } - - public override void Update() - { - switch (Global.Config.RamWatchDefinePrevious) - { - case PreviousType.Original: - return; - case PreviousType.LastChange: - var temp = _value; - _value = GetByte(); - if (_value != temp) - { - _previous = _value; - _changecount++; - } - break; - case PreviousType.LastFrame: - _previous = _value; - _value = GetByte(); - if (_value != Previous) - { - _changecount++; - } - break; - } - } - } - - public sealed class WordWatch : Watch - { - private ushort _previous; - private ushort _value; - - public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) - { - _domain = domain; - _address = address; - _value = _previous = GetWord(); - - if (Watch.AvailableTypes(WatchSize.Word).Contains(type)) - { - _type = type; - } - _bigEndian = bigEndian; - - if (notes != null) - { - Notes = notes; - } - } - - public WordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) - { - _previous = prev; - _changecount = changeCount; - } - - public override int? Value - { - get { return GetWord(); } - } - - public override int? Previous - { - get { return _previous; } - } - - public override string PreviousStr - { - get { return FormatValue(_previous); } - } - - public override void ResetPrevious() - { - _previous = GetWord(); - } - - public override WatchSize Size - { - get { return WatchSize.Word; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_12_4, DisplayType.Binary - }; - } - } - - public override string ValueString - { - get { return FormatValue(GetWord()); } - } - - public override string ToString() - { - return Notes + ": " + ValueString; - } - - public string FormatValue(ushort val) - { - switch (Type) - { - default: - case DisplayType.Unsigned: - return val.ToString(); - case DisplayType.Signed: - return ((short)val).ToString(); - case DisplayType.Hex: - return String.Format("{0:X4}", val); - case DisplayType.FixedPoint_12_4: - return String.Format("{0:F4}", (val / 16.0)); - case DisplayType.Binary: - return Convert.ToString(val, 2).PadLeft(16, '0').Insert(8, " ").Insert(4, " ").Insert(14, " "); - } - } - - public override bool Poke(string value) - { - try - { - ushort val = 0; - switch (Type) - { - case DisplayType.Unsigned: - if (InputValidate.IsValidUnsignedNumber(value)) - { - val = (ushort)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Signed: - if (InputValidate.IsValidSignedNumber(value)) - { - val = (ushort)(short)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Hex: - if (InputValidate.IsValidHexNumber(value)) - { - val = (ushort)int.Parse(value, NumberStyles.HexNumber); - } - else - { - return false; - } - break; - case DisplayType.Binary: - if (InputValidate.IsValidBinaryNumber(value)) - { - val = (ushort)Convert.ToInt32(value, 2); - } - else - { - return false; - } - break; - case DisplayType.FixedPoint_12_4: - if (InputValidate.IsValidFixedPointNumber(value)) - { - val = (ushort)(double.Parse(value) * 16.0); - } - else - { - return false; - } - break; - } - PokeWord(val); - return true; - } - catch - { - return false; - } - } - - public override string Diff - { - get { return FormatValue((ushort)(_previous - _value)); } - } - - public override void Update() - { - switch (Global.Config.RamWatchDefinePrevious) - { - case PreviousType.Original: - return; - case PreviousType.LastChange: - var temp = _value; - _value = GetWord(); - - if (_value != temp) - { - _previous = temp; - _changecount++; - } - break; - case PreviousType.LastFrame: - _previous = _value; - _value = GetWord(); - if (_value != Previous) - { - _changecount++; - } - break; - } - } - } - - public sealed class DWordWatch : Watch - { - private uint _value; - private uint _previous; - - public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, string notes) - { - _domain = domain; - _address = address; - _value = _previous = GetDWord(); - - if (Watch.AvailableTypes(WatchSize.DWord).Contains(type)) - { - _type = type; - } - _bigEndian = bigEndian; - - if (notes != null) - { - Notes = notes; - } - } - - public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null) - : this(domain, address, type, bigEndian, notes) - { - _previous = prev; - _changecount = changeCount; - _type = type; - _bigEndian = bigEndian; - } - - public override int? Value - { - get { return (int)GetDWord(); } - } - - public override int? Previous - { - get { return (int)_previous; } - } - - public override string PreviousStr - { - get { return FormatValue(_previous); } - } - - public override void ResetPrevious() - { - _previous = GetWord(); - } - - public override WatchSize Size - { - get { return WatchSize.DWord; } - } - - public static List ValidTypes - { - get - { - return new List - { - DisplayType.Unsigned, DisplayType.Signed, DisplayType.Hex, DisplayType.FixedPoint_20_12, DisplayType.Float - }; - } - } - - public override string ValueString - { - get { return FormatValue(GetDWord()); } - } - - public override string ToString() - { - return Notes + ": " + ValueString; - } - - public string FormatValue(uint val) - { - switch (Type) - { - default: - case DisplayType.Unsigned: - return val.ToString(); - case DisplayType.Signed: - return ((int)val).ToString(); - case DisplayType.Hex: - return String.Format("{0:X8}", val); - case DisplayType.FixedPoint_20_12: - return String.Format("{0:0.######}", (val / 4096.0)); - case DisplayType.Float: - byte[] bytes = BitConverter.GetBytes(val); - float _float = BitConverter.ToSingle(bytes, 0); - return String.Format("{0:0.######}", _float); - } - } - - public override bool Poke(string value) - { - try - { - uint val = 0; - switch (Type) - { - case DisplayType.Unsigned: - if (InputValidate.IsValidUnsignedNumber(value)) - { - val = (uint)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Signed: - if (InputValidate.IsValidSignedNumber(value)) - { - val = (uint)int.Parse(value); - } - else - { - return false; - } - break; - case DisplayType.Hex: - if (InputValidate.IsValidHexNumber(value)) - { - val = (uint)int.Parse(value, NumberStyles.HexNumber); - } - else - { - return false; - } - break; - case DisplayType.FixedPoint_20_12: - if (InputValidate.IsValidFixedPointNumber(value)) - { - val = (uint)(int)(double.Parse(value) * 4096.0); - } - else - { - return false; - } - break; - case DisplayType.Float: - if (InputValidate.IsValidDecimalNumber(value)) - { - byte[] bytes = BitConverter.GetBytes(float.Parse(value)); - val = BitConverter.ToUInt32(bytes, 0); - } - else - { - return false; - } - break; - } - PokeDWord(val); - return true; - } - catch - { - return false; - } - } - - public override string Diff - { - get { return FormatValue(_previous - _value); } - } - - public override void Update() - { - switch (Global.Config.RamWatchDefinePrevious) - { - case PreviousType.Original: - return; - case PreviousType.LastChange: - var temp = _value; - _value = GetDWord(); - if (_value != temp) - { - _previous = _value; - _changecount++; - } - break; - case PreviousType.LastFrame: - _previous = _value; - _value = GetDWord(); - if (_value != Previous) - { - _changecount++; - } - break; - } - } - } -} diff --git a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs index 2a20dd13fa..17dea3265f 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchEditor.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchEditor.cs @@ -4,6 +4,8 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public partial class WatchEditor : Form diff --git a/BizHawk.MultiClient/tools/Watch/WatchList.cs b/BizHawk.MultiClient/tools/Watch/WatchList.cs index 6d785d758c..e5d05834ef 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchList.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchList.cs @@ -6,6 +6,8 @@ using System.Linq; using System.Text; using System.Windows.Forms; +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { public class WatchList : IEnumerable @@ -544,9 +546,9 @@ namespace BizHawk.MultiClient ofd.Filter = "Watch Files (*.wch)|*.wch|All Files|*.*"; ofd.RestoreDirectory = true; - 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); @@ -573,9 +575,9 @@ namespace BizHawk.MultiClient } sfd.Filter = "Watch Files (*.wch)|*.wch|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); diff --git a/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs b/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs index fdbb5f1750..83d2e832b8 100644 --- a/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs +++ b/BizHawk.MultiClient/tools/Watch/WatchValueBox.cs @@ -1,6 +1,9 @@ using System; using System.Globalization; using System.Windows.Forms; + +using BizHawk.Client.Common; + namespace BizHawk.MultiClient { class WatchValueBox : TextBox, INumberBox