From 2be76a405a19d459504d0602e6553b458fc068ce Mon Sep 17 00:00:00 2001
From: Asnvior <coding@asnitech.co.uk>
Date: Thu, 22 Mar 2018 14:41:21 +0000
Subject: [PATCH] Fix: rom status icon

---
 BizHawk.Client.EmuHawk/MainForm.cs | 50 +++++++++++++++++++++++++++---
 1 file changed, 46 insertions(+), 4 deletions(-)

diff --git a/BizHawk.Client.EmuHawk/MainForm.cs b/BizHawk.Client.EmuHawk/MainForm.cs
index 3f7a9ea1df..bb0e9a20af 100644
--- a/BizHawk.Client.EmuHawk/MainForm.cs
+++ b/BizHawk.Client.EmuHawk/MainForm.cs
@@ -1559,6 +1559,11 @@ namespace BizHawk.Client.EmuHawk
 			if (!string.IsNullOrEmpty(Emulator.CoreComm.RomStatusAnnotation))
 			{
 				annotation = Emulator.CoreComm.RomStatusAnnotation;
+
+                if (annotation == "Multi-disk bundler")
+                {
+                    DumpStatusButton.Image = Properties.Resources.RetroQuestion;
+                }
 			}
 
 			DumpStatusButton.ToolTipText = annotation;
@@ -3620,6 +3625,38 @@ namespace BizHawk.Client.EmuHawk
 					CoreFileProvider.SyncCoreCommInputSignals(nextComm);
 					InputManager.SyncControls();
 
+                    if (Path.GetExtension(loaderName).ToLower() == ".xml")
+                    {
+                        // this is a multi-disk bundler file
+                        // determine the xml assets and create RomStatusDetails for all of them
+                        var xmlGame = XmlGame.Create(new HawkFile(loaderName.Replace("*OpenRom*", "")));
+
+                        StringWriter xSw = new StringWriter();
+
+                        for (int xg = 0; xg < xmlGame.Assets.Count; xg++)
+                        {
+                            var ext = Path.GetExtension(xmlGame.AssetFullPaths[xg]).ToLower();
+
+                            if (ext == ".cue" || ext == ".ccd" || ext == ".toc" || ext == ".mds")
+                            {
+                                xSw.WriteLine(Path.GetFileNameWithoutExtension(xmlGame.Assets[xg].Key));
+                                xSw.WriteLine("SHA1:N/A");
+                                xSw.WriteLine("MD5:N/A");
+                                xSw.WriteLine();
+                            }
+                            else
+                            {
+                                xSw.WriteLine(xmlGame.Assets[xg].Key);
+                                xSw.WriteLine("SHA1:" + xmlGame.Assets[xg].Value.HashSHA1());
+                                xSw.WriteLine("MD5:" + xmlGame.Assets[xg].Value.HashMD5());
+                                xSw.WriteLine();
+                            }
+                        }
+
+                        Emulator.CoreComm.RomStatusDetails = xSw.ToString();
+                        Emulator.CoreComm.RomStatusAnnotation = "Multi-disk bundler";
+                    }
+
 					if (Emulator is TI83 && Global.Config.TI83autoloadKeyPad)
 					{
 						GlobalWin.Tools.Load<TI83KeyPad>();
@@ -3649,10 +3686,15 @@ namespace BizHawk.Client.EmuHawk
 						}
 					}
 
-					if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
-					{
-						Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:{loader.Rom.RomData.HashSHA1()}\r\nMD5:{loader.Rom.RomData.HashMD5()}\r\n";
-					}
+                    if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom != null)
+                    {
+                        Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:{loader.Rom.RomData.HashSHA1()}\r\nMD5:{loader.Rom.RomData.HashMD5()}\r\n";
+                    }
+                    else if (Emulator.CoreComm.RomStatusDetails == null && loader.Rom == null)
+                    {
+                        // single disc game
+                        Emulator.CoreComm.RomStatusDetails = $"{loader.Game.Name}\r\nSHA1:N/A\r\nMD5:N/A\r\n";
+                    }
 
 					if (Emulator.HasBoardInfo())
 					{