Add additional CurrentOS checks

This commit is contained in:
YoshiRulz 2019-05-18 20:25:33 +10:00
parent 35056ae2d9
commit df232e6184
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
9 changed files with 74 additions and 8 deletions

View File

@ -342,8 +342,13 @@ namespace BizHawk.Client.Common
public int DispPrescale = 1;
// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
public EDispMethod DispMethod = EDispMethod.SlimDX9;
/// <remarks>
/// warning: we dont even want to deal with changing this at runtime. but we want it changed here for config purposes. so dont check this variable. check in GlobalWin or something like that.
/// force DX for Windows and GDI+ for Unix when a new config is generated
/// </remarks>
public EDispMethod DispMethod = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
? EDispMethod.SlimDX9
: EDispMethod.GdiPlus;
public int DispChrome_FrameWindowed = 2;
public bool DispChrome_StatusBarWindowed = true;

View File

@ -25,6 +25,7 @@ using BizHawk.Client.EmuHawk.WinFormExtensions;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Emulation.Cores.Computers.AppleII;
using BizHawk.Client.ApiHawk;
using BizHawk.Common;
using BizHawk.Emulation.Cores.Computers.Commodore64;
using BizHawk.Emulation.Cores.Nintendo.Gameboy;
using BizHawk.Emulation.Cores.Computers.SinclairSpectrum;
@ -1469,7 +1470,14 @@ namespace BizHawk.Client.EmuHawk
private void RamSearchMenuItem_Click(object sender, EventArgs e)
{
GlobalWin.Tools.Load<RamSearch>();
var ramSearch = GlobalWin.Tools.Load<RamSearch>();
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
{
// this is apparently needed for weird mono-forms-on-different-thread issues
// dont do .Show() within Load<T>() for RamSearch - instead put an instance of it here on MainForm, then show here
// the mono winforms implementation is.... weird and buggy
ramSearch.Show();
}
}
private void LuaConsoleMenuItem_Click(object sender, EventArgs e)

View File

@ -161,7 +161,9 @@ namespace BizHawk.Client.EmuHawk
Database.LoadDatabase(Path.Combine(PathManager.GetExeDirectoryAbsolute(), "gamedb", "gamedb.txt"));
// TODO GL - a lot of disorganized wiring-up here
CGC.CGCBinPath = Path.Combine(PathManager.GetDllDirectory(), "cgc.exe");
CGC.CGCBinPath = OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows
? Path.Combine(PathManager.GetDllDirectory(), "cgc.exe")
: "cgc"; // installed separately (via package manager or from https://developer.nvidia.com/cg-toolkit-download), look in $PATH
PresentationPanel = new PresentationPanel();
PresentationPanel.GraphicsControl.MainWindow = true;
GlobalWin.DisplayManager = new DisplayManager(PresentationPanel);
@ -2069,7 +2071,22 @@ namespace BizHawk.Client.EmuHawk
// sends an alt+mnemonic combination
private void SendAltKeyChar(char c)
{
typeof(ToolStrip).InvokeMember("ProcessMnemonicInternal", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance, null, MainformMenu, new object[] { c });
switch (OSTailoredCode.CurrentOS)
{
case OSTailoredCode.DistinctOS.Linux:
case OSTailoredCode.DistinctOS.macOS:
// no mnemonics for you
break;
case OSTailoredCode.DistinctOS.Windows:
//HACK
var _ = typeof(ToolStrip).InvokeMember(
"ProcessMnemonicInternal",
System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance,
null,
MainformMenu,
new object[] { c });
break;
}
}
public static string FormatFilter(params string[] args)

View File

@ -80,7 +80,13 @@ namespace BizHawk.Client.EmuHawk
[STAThread]
private static int Main(string[] args)
{
return SubMain(args);
var exitCode = SubMain(args);
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Linux)
{
Console.WriteLine("BizHawk has completed its shutdown routines, killing process...");
Process.GetCurrentProcess().Kill();
}
return exitCode;
}
//NoInlining should keep this code from getting jammed into Main() which would create dependencies on types which havent been setup by the resolver yet... or something like that
@ -309,7 +315,8 @@ REDO_DISPMETHOD:
//so.. we're going to resort to something really bad.
//avert your eyes.
var configPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.ini");
if (File.Exists(configPath)
if (EXE_PROJECT.OSTailoredCode.CurrentOS == EXE_PROJECT.OSTailoredCode.DistinctOS.Windows // LuaInterface is not currently working on Mono
&& File.Exists(configPath)
&& (Array.Find(File.ReadAllLines(configPath), line => line.Contains(" \"UseNLua\": ")) ?? string.Empty)
.Contains("false"))
{

View File

@ -3,6 +3,7 @@ using System.IO;
using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
@ -91,6 +92,16 @@ namespace BizHawk.Client.EmuHawk
txtCropBottom.Text = Global.Config.DispCropBottom.ToString();
RefreshAspectRatioOptions();
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
{
// Disable SlimDX on Unix
rbD3D9.Enabled = false;
rbD3D9.AutoCheck = false;
cbAlternateVsync.Enabled = false;
label13.Enabled = false;
label8.Enabled = false;
}
}
private void btnOk_Click(object sender, EventArgs e)

View File

@ -358,6 +358,8 @@ namespace BizHawk.Client.EmuHawk
private void tbbOpenFolder_Click(object sender, EventArgs e)
{
var frmWares = PathManager.MakeAbsolutePath(Global.Config.PathEntries.FirmwaresPathFragment, null);
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows && !Directory.Exists(frmWares))
Directory.CreateDirectory(frmWares);
System.Diagnostics.Process.Start(frmWares);
}

View File

@ -7,6 +7,7 @@ using BizHawk.Emulation.Common;
using BizHawk.Client.Common;
using BizHawk.Client.EmuHawk.ToolExtensions;
using BizHawk.Common;
//TODO - select which memorydomains go out to the CDL file. will this cause a problem when re-importing it?
//perhaps missing domains shouldnt fail a check
@ -98,7 +99,16 @@ namespace BizHawk.Client.EmuHawk
if (_cdl == null)
{
lvCDL.BeginUpdate();
lvCDL.Items.Clear();
if (OSTailoredCode.CurrentOS == OSTailoredCode.DistinctOS.Windows)
{
lvCDL.Items.Clear();
}
else
{
// this is a winforms implementation problem for mono
// see https://github.com/mono/mono/issues/11070
// until this is resolved in mono we should just skip this call
}
lvCDL.EndUpdate();
return;
}

View File

@ -7,6 +7,7 @@ using System.Windows.Forms;
using BizHawk.Emulation.Common;
using BizHawk.Client.ApiHawk;
using BizHawk.Common;
namespace BizHawk.Client.EmuHawk
{
@ -68,6 +69,8 @@ namespace BizHawk.Client.EmuHawk
continue;
// if (!ApiInjector.IsAvailable(, t))
// continue;
if (t == typeof(HexView) && OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
continue; // Skip this tool on Unix. It isn't finished and only causes exceptions
var instance = Activator.CreateInstance(t);

View File

@ -79,6 +79,9 @@ namespace BizHawk.Common.BizInvoke
/// <param name="size"></param>
public MemoryBlock(ulong start, ulong size)
{
if (OSTailoredCode.CurrentOS != OSTailoredCode.DistinctOS.Windows)
throw new InvalidOperationException("MemoryBlock ctor called on Unix");
if (!WaterboxUtils.Aligned(start))
throw new ArgumentOutOfRangeException();
if (size == 0)