diff --git a/DS_Map/DSUtils/DSUtils.cs b/DS_Map/DSUtils/DSUtils.cs index d1eadd7..636064f 100644 --- a/DS_Map/DSUtils/DSUtils.cs +++ b/DS_Map/DSUtils/DSUtils.cs @@ -297,11 +297,10 @@ namespace DSPRE { string iconTablePath; int iconPalTableOffsetFromFileStart; - string ov129path = OverlayUtils.GetPath(129); - if (File.Exists(ov129path)) { + if (RomInfo.isHGE) { // if overlay 129 exists, read it from there iconPalTableOffsetFromFileStart = (int)(RomInfo.monIconPalTableAddress - OverlayUtils.OverlayTable.GetRAMAddress(129)); - iconTablePath = ov129path; + iconTablePath = OverlayUtils.GetPath(129); } else if ((int)(RomInfo.monIconPalTableAddress - RomInfo.synthOverlayLoadAddress) >= 0) { // if there is a synthetic overlay, read it from there iconPalTableOffsetFromFileStart = (int)(RomInfo.monIconPalTableAddress - RomInfo.synthOverlayLoadAddress); diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index fc88236..9194d6e 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -93,7 +93,7 @@ namespace DSPRE else { AppLogger.Debug("No stored ROM folder found on startup."); - } + } } @@ -980,6 +980,21 @@ namespace DSPRE overlayEditorToolStripMenuItem.Enabled = true; } + if (RomInfo.isHGE) + { + AppLogger.Info("HGE ROM detected, disabling unsupported editors."); + EditorPanels.trainerEditorTabPage.Parent = null; // Hide Trainer Editor for HGE + EditorPanels.tabPageEncountersEditor.Parent = null; // Hide Encounters Editor for HGE + wildEditorButton.Visible = false; // Hide Wild Editor button for HGE + personalDataEditorToolStripMenuItem.Visible = false; // Hide Personal Data Editor menu item for HGE + itemEditorToolStripMenuItem.Visible = false; // Hide Item Editor menu item for HGE + MessageBox.Show("HGE ROM detected.\nCertain editors have been disabled as they are not compatible with HGE ROMs.\nAdditionally the following information is important:"+ + "\n\n- Certain editors such as Move Data or Trade Editor seem to work without crashing but it is no gaurantee, use at your own peril. Also, move data will always get overwritten by hg-engine."+ + "\n\n- Certain text files or script files that HGE edits will be overwritten, please make sure you are aware which are the ones you have to manage with hg-engine."+ + "\n\n- After making edits in DSPRE and want to use as the new base rom for hg-engine make sure to run 'make clean' or otherwise hg-engine will just grab your old rom.nds data.", + "HGE Detected", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + Helpers.statusLabelMessage(); this.Text += " - " + RomInfo.projectName; } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 2281f93..e64d9e7 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; +using System.Text; using System.Windows.Forms; using Path = System.IO.Path; @@ -20,6 +21,7 @@ namespace DSPRE public const string folderSuffix = "_DSPRE_contents"; // changed back to public static string private const string dataFolderName = @"data"; + public static bool isHGE { get; private set; } public static string romID { get; private set; } public static string projectName { get; private set; } public static string workDir { get; private set; } @@ -212,6 +214,28 @@ namespace DSPRE } romID = id; + if (gameVersion == GameVersions.HeartGold && gameLanguage == GameLanguages.English) + { + string ov129path = OverlayUtils.GetPath(129); + if (File.Exists(ov129path)) + { + using (DSUtils.EasyReader br = new DSUtils.EasyReader(ov129path)) + { + string gameCode = Encoding.UTF8.GetString(br.ReadBytes(16)); + if (gameCode == "hg-engine rocks!") + { + isHGE = true; + } + else + { + isHGE = false; + } + } + } else + { + isHGE = false; + } + } projectName = Path.GetFileNameWithoutExtension(romFolderName); LoadGameFamily();