Merge pull request #34 from DS-Pokemon-Rom-Editor/hgEngineCompat

Hg engine compatability
This commit is contained in:
Miguel 2025-10-22 22:13:21 +02:00 committed by GitHub
commit ad658e663e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 42 additions and 4 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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();