diff --git a/DS_Map/BuildingEditor.cs b/DS_Map/BuildingEditor.cs
index 3988b65..fcdfef9 100644
--- a/DS_Map/BuildingEditor.cs
+++ b/DS_Map/BuildingEditor.cs
@@ -45,7 +45,7 @@ namespace DSPRE {
buildingOpenGLControl.MouseWheel += new MouseEventHandler(buildingOpenGLControl_MouseWheel);
Gl.glEnable(Gl.GL_TEXTURE_2D);
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
interiorCheckBox.Enabled = true;
}
diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj
index edd7cf7..4c82d6f 100644
--- a/DS_Map/DSPRE.csproj
+++ b/DS_Map/DSPRE.csproj
@@ -125,7 +125,9 @@
EvolutionsEditor.cs
+
+
Component
diff --git a/DS_Map/DSUtils.cs b/DS_Map/DSUtils.cs
index 6bf2848..3313457 100644
--- a/DS_Map/DSUtils.cs
+++ b/DS_Map/DSUtils.cs
@@ -70,7 +70,7 @@ namespace DSPRE {
return new FileInfo(RomInfo.arm9Path).Length <= 0xBC000;
}
public static bool CheckCompressionMark() {
- return BitConverter.ToInt32(DSUtils.ARM9.ReadBytes((uint)(RomInfo.gameFamily == gFamEnum.DP ? 0xB7C : 0xBB4), 4), 0) != 0;
+ return BitConverter.ToInt32(DSUtils.ARM9.ReadBytes((uint)(RomInfo.gameFamily == GameFamilies.DP ? 0xB7C : 0xBB4), 4), 0) != 0;
}
public static byte[] ReadBytes(uint startOffset, long numberOfBytes = 0) {
return ReadFromFile(RomInfo.arm9Path, startOffset, numberOfBytes);
diff --git a/DS_Map/Filesystem.cs b/DS_Map/Filesystem.cs
new file mode 100644
index 0000000..3d503ab
--- /dev/null
+++ b/DS_Map/Filesystem.cs
@@ -0,0 +1,245 @@
+using System.IO;
+
+namespace DSPRE {
+ public static class Filesystem {
+ public static string eventFiles { get { return RomInfo.gameDirs[RomInfo.DirNames.eventFiles].unpackedDir; } }
+ public static string OWSprites { get { return RomInfo.gameDirs[RomInfo.DirNames.OWSprites].unpackedDir; } }
+ public static string mapTextures { get { return RomInfo.gameDirs[RomInfo.DirNames.mapTextures].unpackedDir; } }
+ public static string buildingTextures { get { return RomInfo.gameDirs[RomInfo.DirNames.buildingTextures].unpackedDir; } }
+ public static string dynamicHeaders { get { return RomInfo.gameDirs[RomInfo.DirNames.dynamicHeaders].unpackedDir; } }
+ public static string dynamicHeadersPacked { get { return RomInfo.gameDirs[RomInfo.DirNames.dynamicHeaders].packedDir; } }
+ public static string scripts { get { return RomInfo.gameDirs[RomInfo.DirNames.scripts].unpackedDir; } }
+ public static string maps { get { return RomInfo.gameDirs[RomInfo.DirNames.maps].unpackedDir; } }
+ public static string matrices { get { return RomInfo.gameDirs[RomInfo.DirNames.matrices].unpackedDir; } }
+ public static string buildingConfigFiles { get { return RomInfo.gameDirs[RomInfo.DirNames.buildingConfigFiles].unpackedDir; } }
+ public static string areaData { get { return RomInfo.gameDirs[RomInfo.DirNames.areaData].unpackedDir; } }
+ public static string textArchives { get { return RomInfo.gameDirs[RomInfo.DirNames.textArchives].unpackedDir; } }
+ public static string trainerProperties { get { return RomInfo.gameDirs[RomInfo.DirNames.trainerProperties].unpackedDir; } }
+ public static string trainerParty { get { return RomInfo.gameDirs[RomInfo.DirNames.trainerParty].unpackedDir; } }
+ public static string trainerGraphics { get { return RomInfo.gameDirs[RomInfo.DirNames.trainerGraphics].unpackedDir; } }
+ public static string encounters { get { return RomInfo.gameDirs[RomInfo.DirNames.encounters].unpackedDir; } }
+ public static string headbutt { get { return RomInfo.gameDirs[RomInfo.DirNames.headbutt].unpackedDir; } }
+ public static string safariZone { get { return RomInfo.gameDirs[RomInfo.DirNames.safariZone].unpackedDir; } }
+ public static string monIcons { get { return RomInfo.gameDirs[RomInfo.DirNames.monIcons].unpackedDir; } }
+ public static string synthOverlay { get { return RomInfo.gameDirs[RomInfo.DirNames.synthOverlay].unpackedDir; } }
+ public static string interiorBuildingModels { get { return RomInfo.gameDirs[RomInfo.DirNames.interiorBuildingModels].unpackedDir; } }
+ public static string exteriorBuildingModels { get { return RomInfo.gameDirs[RomInfo.DirNames.exteriorBuildingModels].unpackedDir; } }
+
+ public static string GetBuildingModelsDirPath(bool interior) {
+ if (interior) {
+ return interiorBuildingModels;
+ } else {
+ return exteriorBuildingModels;
+ }
+ }
+
+ public static string expArmPath { get { return Path.Combine(synthOverlay, ROMToolboxDialog.expandedARMfileID.ToString("D4")); } }
+
+ public static string GetPath(string path, int id, string format = "D4") {
+ return Path.Combine(path, id.ToString(format));
+ }
+
+ public static string GetPath(string path, string prefix, int id, string ext, string format = "D4") {
+ return Path.Combine(path, prefix + id.ToString(format) + "." + ext);
+ }
+
+ static string[] GetBuildingModelFiles(bool interior) {
+ return Directory.GetFiles(Filesystem.GetBuildingModelsDirPath(interior));
+ }
+
+ public static string GetBuildingModelPath(bool interior, int id) {
+ return GetPath(Filesystem.GetBuildingModelsDirPath(interior), id);
+ }
+
+ public static int GetBuildingCount(bool interior) {
+ return GetBuildingModelFiles(interior).Length;
+ }
+
+ public static string[] GetAreaDataFiles() {
+ return Directory.GetFiles(Filesystem.areaData);
+ }
+
+ public static string GetAreaDataPath(int id) {
+ return GetPath(Filesystem.areaData, id);
+ }
+
+ public static int GetAreaDataCount() {
+ return GetAreaDataFiles().Length;
+ }
+
+ public static string GetTexturePath(bool useMapTiles, int textureID) {
+ string path = Filesystem.GetMapTexturePath(textureID);
+ string path2 = Filesystem.GetBuildingTexturePath(textureID);
+ string tilesetPath = useMapTiles ? path : path2;
+ return tilesetPath;
+ }
+
+ static string[] GetMapTextureFiles() {
+ return Directory.GetFiles(Filesystem.mapTextures);
+ }
+
+ public static string GetMapTexturePath(int id) {
+ return GetPath(Filesystem.mapTextures, id);
+ }
+
+ public static int GetMapTexturesCount() {
+ return GetMapTextureFiles().Length;
+ }
+
+ static string[] GetBuildingTextureFiles() {
+ return Directory.GetFiles(Filesystem.buildingTextures);
+ }
+
+ public static string GetBuildingTexturePath(int id) {
+ return GetPath(Filesystem.buildingTextures, id);
+ }
+
+ public static int GetBuildingTexturesCount() {
+ return GetBuildingTextureFiles().Length;
+ }
+
+ static string[] GetMatrixFiles() {
+ return Directory.GetFiles(Filesystem.matrices);
+ }
+
+ public static string GetMatrixPath(int id) {
+ return GetPath(Filesystem.matrices, id);
+ }
+
+ public static int GetMatrixCount() {
+ return GetMatrixFiles().Length;
+ }
+
+ static string[] GetTextArchiveFiles() {
+ return Directory.GetFiles(Filesystem.textArchives);
+ }
+
+ public static string GetTextArchivePath(int id) {
+ return GetPath(Filesystem.textArchives, id);
+ }
+
+ public static int GetTextArchivesCount() {
+ return GetTextArchiveFiles().Length;
+ }
+
+ static string[] GetMapFiles() {
+ return Directory.GetFiles(Filesystem.maps);
+ }
+
+ public static string GetMapPath(int id) {
+ return GetPath(Filesystem.maps, id);
+ }
+
+ public static int GetMapCount() {
+ return GetMapFiles().Length;
+ }
+
+ static string[] GetScriptFiles() {
+ return Directory.GetFiles(Filesystem.scripts);
+ }
+
+ public static string GetScriptPath(int id) {
+ return GetPath(Filesystem.scripts, id);
+ }
+
+ public static int GetScriptCount() {
+ return GetScriptFiles().Length;
+ }
+
+ static string[] GetEventFiles() {
+ return Directory.GetFiles(Filesystem.eventFiles);
+ }
+
+ public static string GetEventPath(int id) {
+ return GetPath(Filesystem.eventFiles, id);
+ }
+
+ public static int GetEventFileCount() {
+ return GetEventFiles().Length;
+ }
+
+ static string[] GetTrainerPropertiesFiles() {
+ return Directory.GetFiles(Filesystem.trainerProperties);
+ }
+
+ public static string GetTrainerPropertiesPath(int id) {
+ return GetPath(Filesystem.trainerProperties, id);
+ }
+
+ public static int GetTrainerPropertiesCount() {
+ return GetTrainerPropertiesFiles().Length;
+ }
+
+ static string[] GetDynamicHeaderFiles() {
+ return Directory.GetFiles(Filesystem.dynamicHeaders);
+ }
+
+ public static string GetDynamicHeaderPath(int id) {
+ return GetPath(Filesystem.dynamicHeaders, id);
+ }
+
+ public static int GetDynamicHeadersCount() {
+ return GetDynamicHeaderFiles().Length;
+ }
+
+ static string[] GetEncounterFiles() {
+ return Directory.GetFiles(Filesystem.encounters);
+ }
+
+ public static string GetEncounterPath(int id) {
+ return GetPath(Filesystem.encounters, id);
+ }
+
+ public static int GetEncountersCount() {
+ return GetEncounterFiles().Length;
+ }
+
+ static string[] GetSafariZoneFiles() {
+ return Directory.GetFiles(Filesystem.safariZone);
+ }
+
+ public static string GetSafariZonePath(int id) {
+ return GetPath(Filesystem.safariZone, id);
+ }
+
+ public static int GetSafariZoneCount() {
+ return GetSafariZoneFiles().Length;
+ }
+
+ static string[] GetHeadbuttFiles() {
+ return Directory.GetFiles(Filesystem.headbutt);
+ }
+
+ public static string GetHeadbuttPath(int id) {
+ return GetPath(Filesystem.headbutt, id);
+ }
+
+ public static int GetHeadbuttCount() {
+ return GetHeadbuttFiles().Length;
+ }
+
+ public static string GetOWSpritePath(int id) {
+ return GetPath(Filesystem.OWSprites, id);
+ }
+
+ public static string GetBuildingConfigPath(int id) {
+ return GetPath(Filesystem.buildingConfigFiles, id);
+ }
+
+ public static string GetTrainerPartyPath(int id) {
+ return GetPath(Filesystem.trainerParty, id);
+ }
+
+ public static string GetTrainerGraphicsPath(int id) {
+ return GetPath(Filesystem.trainerGraphics, id);
+ }
+
+ public static string GetMonIconPath(int id, string format = "D4") {
+ return GetPath(Filesystem.monIcons, id, format);
+ }
+
+ public static string GetSynthOerlayPath(int id) {
+ return GetPath(Filesystem.synthOverlay, id);
+ }
+ }
+}
diff --git a/DS_Map/GameCamera.cs b/DS_Map/GameCamera.cs
index 8aefe8e..f006233 100644
--- a/DS_Map/GameCamera.cs
+++ b/DS_Map/GameCamera.cs
@@ -146,7 +146,7 @@ public class GameCamera {
nearClip = b.ReadUInt32();
farClip = b.ReadUInt32();
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
xOffset = b.ReadInt32();
yOffset = b.ReadInt32();
zOffset = b.ReadInt32();
diff --git a/DS_Map/Helpers.cs b/DS_Map/Helpers.cs
new file mode 100644
index 0000000..81d1b9a
--- /dev/null
+++ b/DS_Map/Helpers.cs
@@ -0,0 +1,397 @@
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Drawing;
+using System.IO;
+using System.Text;
+using System.Windows.Forms;
+using Tao.OpenGl;
+using LibNDSFormats.NSBMD;
+using LibNDSFormats.NSBTX;
+using DSPRE.ROMFiles;
+using Images;
+using Ekona.Images;
+using ScintillaNET;
+using ScintillaNET.Utils;
+using Tao.Platform.Windows;
+using NSMBe4.DSFileSystem;
+
+namespace DSPRE {
+ public static class Helpers {
+ static MainProgram MainProgram;
+
+ public static RomInfo romInfo;
+ public static bool hideBuildings = new bool();
+
+ public static NSBMDGlRenderer mapRenderer;
+
+ public static ToolStripProgressBar toolStripProgressBar { get { return MainProgram.toolStripProgressBar; } }
+
+ public static void Initialize(MainProgram mainProgram) {
+ MainProgram = mainProgram;
+ mapRenderer = new NSBMDGlRenderer();
+ }
+
+ static bool disableHandlersOld;
+ static bool disableHandlers;
+
+ public static bool HandlersDisabled { get { return disableHandlers == true; } }
+ public static bool HandlersEnabled { get { return disableHandlers == false; } }
+
+ public static void BackUpDisableHandler() {
+ disableHandlersOld = disableHandlers;
+ }
+
+ public static void RestoreDisableHandler() {
+ disableHandlers = disableHandlersOld;
+ }
+
+ public static void DisableHandlers() {
+ disableHandlers = true;
+ }
+
+ public static void EnableHandlers() {
+ disableHandlers = false;
+ }
+
+ public static void statusLabelMessage(string msg = "Ready") {
+ ToolStripStatusLabel statusLabel = MainProgram.statusLabel;
+ statusLabel.Text = msg;
+ statusLabel.Font = new Font(statusLabel.Font, FontStyle.Regular);
+ statusLabel.ForeColor = Color.Black;
+ statusLabel.Invalidate();
+ }
+
+ public static void statusLabelError(string errorMsg, bool severe = true) {
+ ToolStripStatusLabel statusLabel = MainProgram.statusLabel;
+ statusLabel.Text = errorMsg;
+ statusLabel.Font = new Font(statusLabel.Font, FontStyle.Bold);
+ statusLabel.ForeColor = severe ? Color.Red : Color.DarkOrange;
+ statusLabel.Invalidate();
+ }
+
+ //Locate File - buttons
+ public static void ExplorerSelect(string path) {
+ if (System.IO.File.Exists(path)) {
+ Process.Start("explorer.exe", "/select" + "," + "\"" + path + "\"");
+ }
+ }
+
+ public static string[] GetTrainerNames() {
+ List trainerList = new List();
+
+ /* Store all trainer names and classes */
+ TextArchive trainerClasses = new TextArchive(RomInfo.trainerClassMessageNumber);
+ TextArchive trainerNames = new TextArchive(RomInfo.trainerNamesMessageNumber);
+
+ int trainerCount = Filesystem.GetTrainerPropertiesCount();
+ for (int i = 0; i < trainerCount; i++) {
+ string path = Filesystem.GetTrainerPropertiesPath(i);
+ int classMessageID = BitConverter.ToUInt16(DSUtils.ReadFromFile(path, startOffset: 1, 2), 0);
+ string currentTrainerName;
+
+ if (i < trainerNames.messages.Count) {
+ currentTrainerName = trainerNames.messages[i];
+ } else {
+ currentTrainerName = TrainerFile.NAME_NOT_FOUND;
+ }
+
+ trainerList.Add("[" + i.ToString("D2") + "] " + trainerClasses.messages[classMessageID] + " " + currentTrainerName);
+ }
+
+ return trainerList.ToArray();
+ }
+
+ public static void MW_LoadModelTextures(NSBMD model, string textureFolder, int fileID) {
+ if (fileID < 0) {
+ return;
+ }
+
+ string texturePath = Filesystem.GetPath(textureFolder, fileID);
+ model.materials = NSBTXLoader.LoadNsbtx(new MemoryStream(System.IO.File.ReadAllBytes(texturePath)), out model.Textures, out model.Palettes);
+ try {
+ model.MatchTextures();
+ } catch {
+ }
+ }
+
+ public static void MW_LoadModelTextures(MapFile mapFile, int fileID) {
+ MW_LoadModelTextures(mapFile.mapModel, Filesystem.mapTextures, fileID);
+ }
+
+ public static void MW_LoadModelTextures(Building building, int fileID) {
+ MW_LoadModelTextures(building.NSBMDFile, Filesystem.buildingTextures, fileID);
+ }
+
+ public static void SetupRenderer(float ang, float dist, float elev, float perspective, int width, int height) {
+ //TODO: improve this
+ Gl.glEnable(Gl.GL_RESCALE_NORMAL);
+ Gl.glEnable(Gl.GL_COLOR_MATERIAL);
+ Gl.glEnable(Gl.GL_DEPTH_TEST);
+ Gl.glEnable(Gl.GL_NORMALIZE);
+ Gl.glDisable(Gl.GL_CULL_FACE);
+ Gl.glFrontFace(Gl.GL_CCW);
+ Gl.glClearDepth(1);
+ Gl.glEnable(Gl.GL_ALPHA_TEST);
+ Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);
+ Gl.glEnable(Gl.GL_BLEND);
+ Gl.glAlphaFunc(Gl.GL_GREATER, 0f);
+ Gl.glClearColor(51f / 255f, 51f / 255f, 51f / 255f, 1f);
+ Gl.glViewport(0, 0, width, height);
+ float aspect = width / height; //(vp[2] - vp[0]) / (vp[3] - vp[1]);
+ Gl.glMatrixMode(Gl.GL_PROJECTION);
+ Gl.glLoadIdentity();
+ Glu.gluPerspective(perspective, aspect, 0.2f, 500.0f); //0.02f, 32.0f);
+ Gl.glTranslatef(0, 0, -dist);
+ Gl.glRotatef(elev, 1, 0, 0);
+ Gl.glRotatef(ang, 0, 1, 0);
+ Gl.glMatrixMode(Gl.GL_MODELVIEW);
+ Gl.glLoadIdentity();
+ Gl.glTranslatef(0, 0, -dist);
+ Gl.glRotatef(elev, 1, 0, 0);
+ Gl.glRotatef(-ang, 0, 1, 0);
+ Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, new float[] { 1, 1, 1, 0 });
+ Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_POSITION, new float[] { 1, 1, 1, 0 });
+ Gl.glLightfv(Gl.GL_LIGHT2, Gl.GL_POSITION, new float[] { 1, 1, 1, 0 });
+ Gl.glLightfv(Gl.GL_LIGHT3, Gl.GL_POSITION, new float[] { 1, 1, 1, 0 });
+ Gl.glLoadIdentity();
+ Gl.glBindTexture(Gl.GL_TEXTURE_2D, 0);
+ Gl.glColor3f(1.0f, 1.0f, 1.0f);
+ Gl.glDepthMask(Gl.GL_TRUE);
+ Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
+ }
+
+ public static void RenderMap(ref MapFile mapFile, int width, int height, float ang, float dist, float elev, float perspective, bool mapTexturesON = true, bool buildingTexturesON = true) {
+ #region Useless variables that the rendering API still needs
+
+ MKDS_Course_Editor.NSBTA.NSBTA.NSBTA_File ani = new MKDS_Course_Editor.NSBTA.NSBTA.NSBTA_File();
+ MKDS_Course_Editor.NSBTP.NSBTP.NSBTP_File tp = new MKDS_Course_Editor.NSBTP.NSBTP.NSBTP_File();
+ MKDS_Course_Editor.NSBCA.NSBCA.NSBCA_File ca = new MKDS_Course_Editor.NSBCA.NSBCA.NSBCA_File();
+ int[] aniframeS = new int[0];
+
+ #endregion
+
+ /* Adjust rendering settings */
+ SetupRenderer(ang, dist, elev, perspective, width, height);
+
+ /* Render the map model */
+ NSBMD model = mapFile.mapModel;
+ mapRenderer.Model = model.models[0];
+
+ // int scale = 64;
+ float scale = 0.015625f;
+ Gl.glScalef(mapRenderer.Model.modelScale * scale, mapRenderer.Model.modelScale * scale, mapRenderer.Model.modelScale * scale);
+
+ /* Determine if map textures must be rendered */
+ if (mapTexturesON) {
+ Gl.glEnable(Gl.GL_TEXTURE_2D);
+ } else {
+ Gl.glDisable(Gl.GL_TEXTURE_2D);
+ }
+
+ // Render map model
+ mapRenderer.RenderModel("", ani, aniframeS, aniframeS, aniframeS, aniframeS, aniframeS, ca, false, -1, 0.0f, 0.0f, dist, elev, ang, true, tp, model);
+
+ if (hideBuildings) {
+ return;
+ }
+
+ if (buildingTexturesON) {
+ Gl.glEnable(Gl.GL_TEXTURE_2D);
+ } else {
+ Gl.glDisable(Gl.GL_TEXTURE_2D);
+ }
+
+ for (int i = 0; i < mapFile.buildings.Count; i++) {
+ Building building = mapFile.buildings[i];
+ model = building.NSBMDFile;
+ if (model is null) {
+ Console.WriteLine("Null building can't be rendered");
+ } else {
+ mapRenderer.Model = model.models[0];
+ ScaleTranslateRotateBuilding(building);
+ mapRenderer.RenderModel("", ani, aniframeS, aniframeS, aniframeS, aniframeS, aniframeS, ca, false, -1, 0.0f, 0.0f, dist, elev, ang, true, tp, model);
+ }
+ }
+ }
+
+ public static Bitmap GrabMapScreenshot(int width, int height) {
+ Bitmap bmp = new Bitmap(width, height);
+ System.Drawing.Imaging.BitmapData data = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
+ Gl.glReadPixels(0, 0, width, height, Gl.GL_BGR, Gl.GL_UNSIGNED_BYTE, data.Scan0);
+ bmp.UnlockBits(data);
+ bmp.RotateFlip(RotateFlipType.RotateNoneFlipY);
+ return bmp;
+ }
+
+ private static void ScaleTranslateRotateBuilding(Building building) {
+ float fullXcoord = building.xPosition + building.xFraction / 65536f;
+ float fullYcoord = building.yPosition + building.yFraction / 65536f;
+ float fullZcoord = building.zPosition + building.zFraction / 65536f;
+
+ float scaleFactor = building.NSBMDFile.models[0].modelScale / 1024;
+ float translateFactor = 256 / building.NSBMDFile.models[0].modelScale;
+
+ Gl.glScalef(scaleFactor * building.width, scaleFactor * building.height, scaleFactor * building.length);
+ Gl.glTranslatef(fullXcoord * translateFactor / building.width, fullYcoord * translateFactor / building.height, fullZcoord * translateFactor / building.length);
+ Gl.glRotatef(Building.U16ToDeg(building.xRotation), 1, 0, 0);
+ Gl.glRotatef(Building.U16ToDeg(building.yRotation), 0, 1, 0);
+ Gl.glRotatef(Building.U16ToDeg(building.zRotation), 0, 0, 1);
+ }
+
+ public static Image GetPokePic(int species, int w, int h, PaletteBase paletteBase, ImageBase imageBase, SpriteBase spriteBase) {
+ bool fiveDigits = false; // some extreme future proofing
+ try {
+ string path = Filesystem.GetMonIconPath(0);
+ paletteBase = new NCLR(path, 0, Path.GetFileName(path));
+ } catch (FileNotFoundException) {
+ string path = Filesystem.GetMonIconPath(0, "D5");
+ paletteBase = new NCLR(path, 0, Path.GetFileName(path));
+ fiveDigits = true;
+ }
+
+ // read arm9 table to grab pal ID
+ int paletteId = 0;
+ byte[] iconPalTableBuf;
+
+ switch (RomInfo.gameFamily) {
+ case RomInfo.GameFamilies.DP:
+ iconPalTableBuf = DSUtils.ARM9.ReadBytes(0x6B838, 4);
+ break;
+ case RomInfo.GameFamilies.Plat:
+ iconPalTableBuf = DSUtils.ARM9.ReadBytes(0x79F80, 4);
+ break;
+ case RomInfo.GameFamilies.HGSS:
+ default:
+ iconPalTableBuf = DSUtils.ARM9.ReadBytes(0x74408, 4);
+ break;
+ }
+
+ int iconPalTableAddress = (iconPalTableBuf[3] & 0xFF) << 24 | (iconPalTableBuf[2] & 0xFF) << 16 | (iconPalTableBuf[1] & 0xFF) << 8 | (iconPalTableBuf[0] & 0xFF) /* << 0 */;
+ string iconTablePath;
+
+ int iconPalTableOffsetFromFileStart;
+ if (iconPalTableAddress >= RomInfo.synthOverlayLoadAddress) {
+ // if the pointer shows the table was moved to the synthetic overlay
+ iconPalTableOffsetFromFileStart = iconPalTableAddress - (int)RomInfo.synthOverlayLoadAddress;
+ iconTablePath = Filesystem.expArmPath;
+ } else {
+ iconPalTableOffsetFromFileStart = iconPalTableAddress - 0x02000000;
+ iconTablePath = RomInfo.arm9Path;
+ }
+
+ using (DSUtils.EasyReader idReader = new DSUtils.EasyReader(iconTablePath, iconPalTableOffsetFromFileStart + species)) {
+ paletteId = idReader.ReadByte();
+ }
+
+ if (paletteId != 0) {
+ paletteBase.Palette[0] = paletteBase.Palette[paletteId]; // update pal 0 to be the new pal
+ }
+
+ // grab tiles
+ int spriteFileID = species + 7;
+ if (fiveDigits) {
+ string path = Filesystem.GetMonIconPath(spriteFileID, "D5");
+ imageBase = new NCGR(path, spriteFileID, Path.GetFileName(path));
+ } else {
+ string path = Filesystem.GetMonIconPath(spriteFileID);
+ imageBase = new NCGR(path, spriteFileID, Path.GetFileName(path));
+ }
+
+ // grab sprite
+ const int ncerFileId = 2;
+ if (fiveDigits) {
+ string path = Filesystem.GetMonIconPath(ncerFileId, "D5");
+ spriteBase = new NCER(path, ncerFileId, Path.GetFileName(path));
+ } else {
+ string path = Filesystem.GetMonIconPath(ncerFileId);
+ spriteBase = new NCER(path, ncerFileId, Path.GetFileName(path));
+ }
+
+ // copy this from the trainer
+ int bank0OAMcount = spriteBase.Banks[0].oams.Length;
+ int[] OAMenabled = new int[bank0OAMcount];
+ for (int i = 0; i < OAMenabled.Length; i++) {
+ OAMenabled[i] = i;
+ }
+
+ // finally compose image
+ try {
+ return spriteBase.Get_Image(imageBase, paletteBase, 0, w, h, false, false, false, true, true, -1, OAMenabled);
+ } catch (FormatException) {
+ return Properties.Resources.IconPokeball;
+ }
+ // default:
+ //partyPokemonPictureBoxList[partyPos].Image = cb.SelectedIndex > 0 ? (Image)Properties.PokePics.ResourceManager.GetObject(FixPokenameString(PokeDatabase.System.pokeNames[(ushort)cb.SelectedIndex])) : global::DSPRE.Properties.Resources.IconPokeball;
+ }
+
+ public static void GenerateKeystrokes(string keys, Scintilla textArea) {
+ //Example
+ //GenerateKeystrokes("+{TAB}");
+ HotKeyManager.Enable = false;
+ textArea.Focus();
+ SendKeys.Send(keys);
+ HotKeyManager.Enable = true;
+ }
+
+ public static void PictureBoxDisable(object sender, PaintEventArgs e) {
+ if (sender is PictureBox pict && pict.Image != null && (!pict.Enabled)) {
+ using (Bitmap img = new Bitmap(pict.Image, pict.ClientSize)) {
+ ControlPaint.DrawImageDisabled(e.Graphics, img, 0, 0, pict.BackColor);
+ }
+ }
+ }
+
+ public static List getHeaderListBoxNames() {
+ List headerListBoxNames = new List();
+
+ using (DSUtils.EasyReader reader = new DSUtils.EasyReader(RomInfo.internalNamesPath)) {
+ int headerCount = RomInfo.GetHeaderCount();
+ for (int i = 0; i < headerCount; i++) {
+ byte[] row = reader.ReadBytes(RomInfo.internalNameLength);
+ string internalName = Encoding.ASCII.GetString(row); //.TrimEnd();
+ headerListBoxNames.Add(MapHeader.BuildName(i, internalName));
+ }
+ }
+
+ return headerListBoxNames;
+ }
+
+ public static List getInternalNames() {
+ List internalNames = new List();
+
+ using (DSUtils.EasyReader reader = new DSUtils.EasyReader(RomInfo.internalNamesPath)) {
+ int headerCount = RomInfo.GetHeaderCount();
+ for (int i = 0; i < headerCount; i++) {
+ byte[] row = reader.ReadBytes(RomInfo.internalNameLength);
+ string internalName = Encoding.ASCII.GetString(row); //.TrimEnd();
+ internalNames.Add(internalName.TrimEnd('\0'));
+ }
+ }
+
+ return internalNames;
+ }
+
+ public static void OpenWildEditor(int encToOpen = 0) {
+ Helpers.statusLabelMessage("Attempting to extract Wild Encounters NARC...");
+
+ DSUtils.TryUnpackNarcs(new List() { RomInfo.DirNames.encounters, RomInfo.DirNames.monIcons });
+
+ Helpers.statusLabelMessage("Passing control to Wild Pokémon Editor...");
+
+ switch (RomInfo.gameFamily) {
+ case RomInfo.GameFamilies.DP:
+ case RomInfo.GameFamilies.Plat:
+ using (WildEditorDPPt editor = new WildEditorDPPt(encToOpen))
+ editor.ShowDialog();
+ break;
+ default:
+ using (WildEditorHGSS editor = new WildEditorHGSS(encToOpen))
+ editor.ShowDialog();
+ break;
+ }
+
+ Helpers.statusLabelMessage();
+ }
+ }
+}
\ No newline at end of file
diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs
index a8d37f9..47fcadb 100644
--- a/DS_Map/Main Window.Designer.cs
+++ b/DS_Map/Main Window.Designer.cs
@@ -11167,14 +11167,14 @@
// personalDataEditorToolStripMenuItem
//
this.personalDataEditorToolStripMenuItem.Name = "personalDataEditorToolStripMenuItem";
- this.personalDataEditorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.personalDataEditorToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.personalDataEditorToolStripMenuItem.Text = "Pokemon Editor";
this.personalDataEditorToolStripMenuItem.Click += new System.EventHandler(this.personalDataEditorToolStripMenuItem_Click);
//
// learnsetsEditorToolStripMenuItem
//
this.learnsetsEditorToolStripMenuItem.Name = "learnsetsEditorToolStripMenuItem";
- this.learnsetsEditorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.learnsetsEditorToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.learnsetsEditorToolStripMenuItem.Text = "Learnsets Editor";
this.learnsetsEditorToolStripMenuItem.Visible = false;
this.learnsetsEditorToolStripMenuItem.Click += new System.EventHandler(this.learnsetsEditorToolStripMenuItem_Click);
@@ -11182,7 +11182,7 @@
// evolutionsEditorToolStripMenuItem
//
this.evolutionsEditorToolStripMenuItem.Name = "evolutionsEditorToolStripMenuItem";
- this.evolutionsEditorToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
+ this.evolutionsEditorToolStripMenuItem.Size = new System.Drawing.Size(163, 22);
this.evolutionsEditorToolStripMenuItem.Text = "Evolutions Editor";
this.evolutionsEditorToolStripMenuItem.Visible = false;
this.evolutionsEditorToolStripMenuItem.Click += new System.EventHandler(this.evolutionsEditorToolStripMenuItem_Click);
@@ -11241,16 +11241,16 @@
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.statusLabel,
this.toolStripProgressBar});
- this.statusStrip1.Location = new System.Drawing.Point(0, 739);
+ this.statusStrip1.Location = new System.Drawing.Point(0, 737);
this.statusStrip1.Name = "statusStrip1";
- this.statusStrip1.Size = new System.Drawing.Size(1214, 22);
+ this.statusStrip1.Size = new System.Drawing.Size(1214, 24);
this.statusStrip1.TabIndex = 13;
this.statusStrip1.Text = "statusStrip1";
//
// statusLabel
//
this.statusLabel.Name = "statusLabel";
- this.statusLabel.Size = new System.Drawing.Size(39, 17);
+ this.statusLabel.Size = new System.Drawing.Size(39, 19);
this.statusLabel.Text = "Ready";
//
// toolStripProgressBar
@@ -12016,7 +12016,6 @@
private System.Windows.Forms.RadioButton radio2D;
private System.Windows.Forms.CheckBox wireframeCheckBox;
private System.Windows.Forms.StatusStrip statusStrip1;
- private System.Windows.Forms.ToolStripStatusLabel statusLabel;
private System.Windows.Forms.PictureBox collisionPictureBox;
private System.Windows.Forms.PictureBox typePictureBox;
private System.Windows.Forms.Label typeLabel;
@@ -12332,7 +12331,6 @@
private System.Windows.Forms.PictureBox rightClickPicture;
private System.Windows.Forms.Label WheelClickLabel;
private System.Windows.Forms.Label LeftClickLabel;
- private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;
private System.Windows.Forms.ToolStripButton unpackAllButton;
private System.Windows.Forms.Button pasteHeaderButton;
private System.Windows.Forms.Button copyHeaderButton;
diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs
index 087f718..23b3a27 100644
--- a/DS_Map/Main Window.cs
+++ b/DS_Map/Main Window.cs
@@ -506,13 +506,13 @@ namespace DSPRE {
if (forceUnpack) {
DSUtils.ForceUnpackNarcs(toUnpack);
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
DSUtils.ForceUnpackNarcs(new List { DirNames.interiorBuildingModels });// Last = interior buildings dir
}
} else {
DSUtils.TryUnpackNarcs(toUnpack);
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
DSUtils.TryUnpackNarcs(new List { DirNames.interiorBuildingModels });
}
}
@@ -594,7 +594,11 @@ namespace DSPRE {
gameIcon.Refresh(); // Paint game icon
statusLabelMessage("Attempting to unpack NARCs from folder...");
Update();
-
+ for (int i = 0; i < 128; i++) {
+ if (DSUtils.OverlayIsCompressed(i)) {
+ DSUtils.DecompressOverlay(i);
+ }
+ }
ReadROMInitData();
}
@@ -605,7 +609,7 @@ namespace DSPRE {
versionLabel.Text = RomInfo.gameVersion.ToString() + " " + "[" + RomInfo.romID + "]";
languageLabel.Text = "Lang: " + RomInfo.gameLanguage;
- if (RomInfo.gameLanguage == gLangEnum.English) {
+ if (RomInfo.gameLanguage == GameLanguages.English) {
if (europeByte == 0x0A) {
languageLabel.Text += " [Europe]";
} else {
@@ -654,7 +658,7 @@ namespace DSPRE {
private void ReadROMInitData() {
if (DSUtils.ARM9.CheckCompressionMark()) {
- if (!RomInfo.gameFamily.Equals(gFamEnum.HGSS)) {
+ if (!RomInfo.gameFamily.Equals(GameFamilies.HGSS)) {
MessageBox.Show("Unexpected compressed ARM9. It is advised that you double check the ARM9.");
}
if (!DSUtils.ARM9.Decompress(RomInfo.arm9Path)) {
@@ -724,7 +728,7 @@ namespace DSPRE {
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (d == DialogResult.Yes) {
- DSUtils.ARM9.WriteBytes(new byte[4] { 0, 0, 0, 0 }, (uint)(RomInfo.gameFamily == gFamEnum.DP ? 0xB7C : 0xBB4));
+ DSUtils.ARM9.WriteBytes(new byte[4] { 0, 0, 0, 0 }, (uint)(RomInfo.gameFamily == GameFamilies.DP ? 0xB7C : 0xBB4));
}
}
@@ -749,9 +753,15 @@ namespace DSPRE {
Update();
+ for (int i = 0; i < 128; i++) {
+ if (!DSUtils.OverlayIsCompressed(i)) {
+ DSUtils.CompressOverlay(i);
+ }
+ }
+
DSUtils.RepackROM(saveRom.FileName);
- if (RomInfo.gameFamily != gFamEnum.DP && RomInfo.gameFamily != gFamEnum.Plat) {
+ if (RomInfo.gameFamily != GameFamilies.DP && RomInfo.gameFamily != GameFamilies.Plat) {
if (eventEditorIsReady) {
if (DSUtils.OverlayIsCompressed(1)) {
DSUtils.DecompressOverlay(1);
@@ -819,16 +829,16 @@ namespace DSPRE {
}
}
private void diamondAndPearlToolStripMenuItem_Click(object sender, EventArgs e) {
- OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(gFamEnum.DP), RomInfo.BuildCommandParametersDatabase(gFamEnum.DP),
- RomInfo.BuildActionNamesDatabase(gFamEnum.DP), RomInfo.BuildComparisonOperatorsDatabase(gFamEnum.DP));
+ OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(GameFamilies.DP), RomInfo.BuildCommandParametersDatabase(GameFamilies.DP),
+ RomInfo.BuildActionNamesDatabase(GameFamilies.DP), RomInfo.BuildComparisonOperatorsDatabase(GameFamilies.DP));
}
private void platinumToolStripMenuItem_Click(object sender, EventArgs e) {
- OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(gFamEnum.Plat), RomInfo.BuildCommandParametersDatabase(gFamEnum.Plat),
- RomInfo.BuildActionNamesDatabase(gFamEnum.Plat), RomInfo.BuildComparisonOperatorsDatabase(gFamEnum.Plat));
+ OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(GameFamilies.Plat), RomInfo.BuildCommandParametersDatabase(GameFamilies.Plat),
+ RomInfo.BuildActionNamesDatabase(GameFamilies.Plat), RomInfo.BuildComparisonOperatorsDatabase(GameFamilies.Plat));
}
private void heartGoldAndSoulSilverToolStripMenuItem_Click(object sender, EventArgs e) {
- OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(gFamEnum.HGSS), RomInfo.BuildCommandParametersDatabase(gFamEnum.HGSS),
- RomInfo.BuildActionNamesDatabase(gFamEnum.HGSS), RomInfo.BuildComparisonOperatorsDatabase(gFamEnum.HGSS));
+ OpenCommandsDatabase(RomInfo.BuildCommandNamesDatabase(GameFamilies.HGSS), RomInfo.BuildCommandParametersDatabase(GameFamilies.HGSS),
+ RomInfo.BuildActionNamesDatabase(GameFamilies.HGSS), RomInfo.BuildComparisonOperatorsDatabase(GameFamilies.HGSS));
}
private void mainTabControl_SelectedIndexChanged(object sender, EventArgs e) {
if (mainTabControl.SelectedTab == headerEditorTabPage) {
@@ -915,8 +925,8 @@ namespace DSPRE {
string wildPokeUnpackedPath = gameDirs[DirNames.encounters].unpackedDir;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
using (WildEditorDPPt editor = new WildEditorDPPt(wildPokeUnpackedPath, RomInfo.GetPokemonNames(), encToOpen, internalNames.Count))
editor.ShowDialog();
break;
@@ -996,7 +1006,7 @@ namespace DSPRE {
ReloadHeaderEditorLocationsList(currentTextArchive.messages);
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
areaIconComboBox.Enabled = false;
areaIconPictureBox.Image = (Image)Properties.Resources.ResourceManager.GetObject("dpareaicon");
areaSettingsLabel.Text = "Show nametag:";
@@ -1014,7 +1024,7 @@ namespace DSPRE {
battleBackgroundLabel.Location = new Point(battleBackgroundLabel.Location.X - 25, battleBackgroundLabel.Location.Y - 8);
battleBackgroundUpDown.Location = new Point(battleBackgroundUpDown.Location.X - 25, battleBackgroundUpDown.Location.Y - 8);
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
areaSettingsLabel.Text = "Show nametag:";
areaIconComboBox.Items.Clear();
cameraComboBox.Items.Clear();
@@ -1134,9 +1144,9 @@ namespace DSPRE {
string imageName;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
((HeaderPt)currentHeader).areaIcon = (byte)areaIconComboBox.SelectedIndex;
imageName = "areaicon0" + areaIconComboBox.SelectedIndex.ToString();
areaIconPictureBox.Image = (Image)Properties.Resources.ResourceManager.GetObject(imageName);
@@ -1162,7 +1172,7 @@ namespace DSPRE {
return;
}
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
HeaderHGSS currentHeaderHGSS = (HeaderHGSS)currentHeader;
currentHeaderHGSS.followMode = (byte)followModeComboBox.SelectedIndex;
}
@@ -1172,7 +1182,7 @@ namespace DSPRE {
if (disableHandlers) {
return;
}
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
HeaderHGSS currentHeaderHGSS = (HeaderHGSS)currentHeader;
currentHeaderHGSS.kantoFlag = kantoRadioButton.Checked;
}
@@ -1195,7 +1205,7 @@ namespace DSPRE {
if (flag3CheckBox.Checked)
flagVal += (byte)Math.Pow(2, 3);
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
if (flag4CheckBox.Checked)
flagVal += (byte)Math.Pow(2, 4);
if (flag5CheckBox.Checked)
@@ -1243,7 +1253,7 @@ namespace DSPRE {
cameraUpDown.Value = currentHeader.cameraAngleID;
battleBackgroundUpDown.Value = currentHeader.battleBackground;
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
areaSettingsComboBox.SelectedIndex = ((HeaderHGSS)currentHeader).locationType;
}
@@ -1252,7 +1262,7 @@ namespace DSPRE {
/* Setup controls for fields with version-specific differences */
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP: {
+ case GameFamilies.DP: {
HeaderDP h = (HeaderDP)currentHeader;
locationNameComboBox.SelectedIndex = h.locationName;
@@ -1261,7 +1271,7 @@ namespace DSPRE {
areaSettingsComboBox.SelectedIndex = areaSettingsComboBox.FindString("[" + $"{currentHeader.locationSpecifier:D3}");
break;
}
- case gFamEnum.Plat: {
+ case GameFamilies.Plat: {
HeaderPt h = (HeaderPt)currentHeader;
areaIconComboBox.SelectedIndex = h.areaIcon;
@@ -1301,7 +1311,7 @@ namespace DSPRE {
flag2CheckBox.Checked = ba[2];
flag3CheckBox.Checked = ba[3];
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
flag4CheckBox.Checked = ba[4];
flag5CheckBox.Checked = ba[5];
flag6CheckBox.Checked = ba[6];
@@ -1360,10 +1370,10 @@ namespace DSPRE {
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
((HeaderDP)currentHeader).locationName = (ushort)locationNameComboBox.SelectedIndex;
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
((HeaderPt)currentHeader).locationName = (byte)locationNameComboBox.SelectedIndex;
break;
default:
@@ -1382,10 +1392,10 @@ namespace DSPRE {
return;
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
currentHeader.musicDayID = (ushort)(musicDayUpDown.Value = PokeDatabase.MusicDB.DPMusicDict.Keys.ElementAt(musicDayComboBox.SelectedIndex));
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
currentHeader.musicDayID = (ushort)(musicDayUpDown.Value = PokeDatabase.MusicDB.PtMusicDict.Keys.ElementAt(musicDayComboBox.SelectedIndex));
break;
default:
@@ -1399,10 +1409,10 @@ namespace DSPRE {
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
currentHeader.musicNightID = (ushort)(musicNightUpDown.Value = PokeDatabase.MusicDB.DPMusicDict.Keys.ElementAt(musicNightComboBox.SelectedIndex));
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
currentHeader.musicNightID = (ushort)(musicNightUpDown.Value = PokeDatabase.MusicDB.PtMusicDict.Keys.ElementAt(musicNightComboBox.SelectedIndex));
break;
default:
@@ -1420,10 +1430,10 @@ namespace DSPRE {
currentHeader.musicDayID = updValue;
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
musicDayComboBox.SelectedItem = PokeDatabase.MusicDB.DPMusicDict[updValue];
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
musicDayComboBox.SelectedItem = PokeDatabase.MusicDB.PtMusicDict[updValue];
break;
default:
@@ -1445,10 +1455,10 @@ namespace DSPRE {
currentHeader.musicNightID = updValue;
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
musicNightComboBox.SelectedItem = PokeDatabase.MusicDB.DPMusicDict[updValue];
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
musicNightComboBox.SelectedItem = PokeDatabase.MusicDB.PtMusicDict[updValue];
break;
default:
@@ -1475,10 +1485,10 @@ namespace DSPRE {
disableHandlers = true;
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
weatherComboBox.SelectedItem = PokeDatabase.Weather.DPWeatherDict[currentHeader.weatherID];
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
weatherComboBox.SelectedItem = PokeDatabase.Weather.PtWeatherDict[currentHeader.weatherID];
break;
default:
@@ -1494,10 +1504,10 @@ namespace DSPRE {
try {
Dictionary dict;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
dict = PokeDatabase.System.WeatherPics.dpWeatherImageDict;
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
dict = PokeDatabase.System.WeatherPics.ptWeatherImageDict;
break;
default:
@@ -1528,10 +1538,10 @@ namespace DSPRE {
disableHandlers = true;
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
cameraComboBox.SelectedItem = PokeDatabase.CameraAngles.DPPtCameraDict[currentHeader.cameraAngleID];
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
cameraComboBox.SelectedItem = PokeDatabase.CameraAngles.DPPtCameraDict[currentHeader.cameraAngleID];
break;
default:
@@ -1547,11 +1557,11 @@ namespace DSPRE {
string imageName;
try {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
currentHeader.cameraAngleID = (byte)cameraComboBox.SelectedIndex;
imageName = "dpcamera" + cameraUpDown.Value.ToString();
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
currentHeader.cameraAngleID = (byte)cameraComboBox.SelectedIndex;
imageName = "ptcamera" + cameraUpDown.Value.ToString();
break;
@@ -1572,10 +1582,10 @@ namespace DSPRE {
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
weatherUpDown.Value = PokeDatabase.Weather.DPWeatherDict.Keys.ElementAt(weatherComboBox.SelectedIndex);
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
weatherUpDown.Value = PokeDatabase.Weather.PtWeatherDict.Keys.ElementAt(weatherComboBox.SelectedIndex);
break;
default:
@@ -1594,10 +1604,10 @@ namespace DSPRE {
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
cameraUpDown.Value = PokeDatabase.CameraAngles.DPPtCameraDict.Keys.ElementAt(cameraComboBox.SelectedIndex);
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
cameraUpDown.Value = PokeDatabase.CameraAngles.DPPtCameraDict.Keys.ElementAt(cameraComboBox.SelectedIndex);
break;
default:
@@ -1751,13 +1761,13 @@ namespace DSPRE {
string locationName = "";
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
locationName = locationNameComboBox.Items[((HeaderDP)h).locationName].ToString();
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
locationName = locationNameComboBox.Items[((HeaderPt)h).locationName].ToString();
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
locationName = locationNameComboBox.Items[((HeaderHGSS)h).locationName].ToString();
break;
}
@@ -1792,13 +1802,13 @@ namespace DSPRE {
string[] locBuff = new string[2];
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
locBuff[1] = locationNameComboBox.Items[((HeaderDP)hBuff[1]).locationName].ToString();
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
locBuff[1] = locationNameComboBox.Items[((HeaderPt)hBuff[1]).locationName].ToString();
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
locBuff[1] = locationNameComboBox.Items[((HeaderHGSS)hBuff[1]).locationName].ToString();
break;
}
@@ -1810,13 +1820,13 @@ namespace DSPRE {
string lastName = locBuff[0]; //Kind of a locBuff[-1]
locBuff[0] = locBuff[1];
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
+ case GameFamilies.DP:
locBuff[1] = locationNameComboBox.Items[((HeaderDP)hBuff[1]).locationName].ToString();
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
locBuff[1] = locationNameComboBox.Items[((HeaderPt)hBuff[1]).locationName].ToString();
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
locBuff[1] = locationNameComboBox.Items[((HeaderHGSS)hBuff[1]).locationName].ToString();
break;
}
@@ -1854,11 +1864,11 @@ namespace DSPRE {
}
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
currentHeader.locationSpecifier = Byte.Parse(areaSettingsComboBox.SelectedItem.ToString().Substring(1, 3));
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
HeaderHGSS ch = (HeaderHGSS)currentHeader;
ch.locationType = (byte)areaSettingsComboBox.SelectedIndex;
break;
@@ -2124,11 +2134,11 @@ namespace DSPRE {
wildPokeUpDown.Value = encountersIDCopy;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
areaSettingsComboBox.SelectedIndex = shownameCopy;
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
areaSettingsComboBox.SelectedIndex = areaSettingsCopy;
break;
}
@@ -2614,7 +2624,7 @@ namespace DSPRE {
statusLabelMessage("Multiple Headers are associated to this Matrix, including the last selected one [Header " + headerID + "]. Now using its textures.");
} else {
- if (gameFamily.Equals(gFamEnum.DP)) {
+ if (gameFamily.Equals(GameFamilies.DP)) {
foreach (ushort r in result) {
HeaderDP hdp;
hdp = (HeaderDP)MapHeader.LoadFromARM9(r);
@@ -2624,7 +2634,7 @@ namespace DSPRE {
break;
}
}
- } else if (gameFamily.Equals(gFamEnum.Plat)) {
+ } else if (gameFamily.Equals(GameFamilies.Plat)) {
foreach (ushort r in result) {
HeaderPt hpt;
if (ROMToolboxDialog.flag_DynamicHeadersPatchApplied || ROMToolboxDialog.CheckFilesDynamicHeadersPatchApplied()) {
@@ -3195,7 +3205,7 @@ namespace DSPRE {
DirNames.areaData,
});
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
DSUtils.TryUnpackNarcs(new List { DirNames.interiorBuildingModels });
}
@@ -3204,8 +3214,8 @@ namespace DSPRE {
collisionPainterPictureBox.Image = new Bitmap(100, 100);
typePainterPictureBox.Image = new Bitmap(100, 100);
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
mapPartsTabControl.TabPages.Remove(bgsTabPage);
break;
default:
@@ -3222,8 +3232,8 @@ namespace DSPRE {
for (int i = 0; i < mapCount; i++) {
using (DSUtils.EasyReader reader = new DSUtils.EasyReader(RomInfo.gameDirs[DirNames.maps].unpackedDir + "\\" + i.ToString("D4"))) {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
reader.BaseStream.Position = 0x10 + reader.ReadUInt32() + reader.ReadUInt32();
break;
default:
@@ -3288,12 +3298,12 @@ namespace DSPRE {
selectMapComboBox.SelectedIndex = 0;
exteriorbldRadioButton.Checked = true;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
mapTextureComboBox.SelectedIndex = 7;
buildTextureComboBox.SelectedIndex = 1;
break;
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
mapTextureComboBox.SelectedIndex = 3;
buildTextureComboBox.SelectedIndex = 1;
break;
@@ -3328,12 +3338,12 @@ namespace DSPRE {
UpdateMapBinAndRefresh(temp, "Map BIN imported successfully!");
return;
} else {
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
//If HGSS didn't work try reading as Platinum Map
- temp = new MapFile(of.FileName, gFamEnum.Plat, false);
+ temp = new MapFile(of.FileName, GameFamilies.Plat, false);
} else {
//If Plat didn't work try reading as HGSS Map
- temp = new MapFile(of.FileName, gFamEnum.HGSS, false);
+ temp = new MapFile(of.FileName, GameFamilies.HGSS, false);
}
if (temp.correctnessFlag) {
@@ -3723,7 +3733,7 @@ namespace DSPRE {
modelSizeLBL.Text = currentMapFile.mapModelData.Length.ToString() + " B";
terrainSizeLBL.Text = currentMapFile.bdhc.Length.ToString() + " B";
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
BGSSizeLBL.Text = currentMapFile.bgs.Length.ToString() + " B";
}
}
@@ -4715,7 +4725,7 @@ namespace DSPRE {
#region BDHC I/O
private void bdhcImportButton_Click(object sender, EventArgs e) {
OpenFileDialog it = new OpenFileDialog() {
- Filter = RomInfo.gameFamily == gFamEnum.DP ? MapFile.BDHCFilter : MapFile.BDHCamFilter
+ Filter = RomInfo.gameFamily == GameFamilies.DP ? MapFile.BDHCFilter : MapFile.BDHCamFilter
};
if (it.ShowDialog(this) != DialogResult.OK) {
@@ -4729,7 +4739,7 @@ namespace DSPRE {
private void bdhcExportButton_Click(object sender, EventArgs e) {
SaveFileDialog sf = new SaveFileDialog {
FileName = selectMapComboBox.SelectedItem.ToString(),
- Filter = RomInfo.gameFamily == gFamEnum.DP ? MapFile.BDHCFilter : MapFile.BDHCamFilter
+ Filter = RomInfo.gameFamily == GameFamilies.DP ? MapFile.BDHCFilter : MapFile.BDHCamFilter
};
if (sf.ShowDialog(this) != DialogResult.OK) {
@@ -4852,7 +4862,7 @@ namespace DSPRE {
Dictionary dict = new Dictionary();
- if (gameFamily.Equals(gFamEnum.DP)) {
+ if (gameFamily.Equals(GameFamilies.DP)) {
foreach (ushort headerID in result) {
HeaderDP hdp = (HeaderDP)MapHeader.LoadFromARM9(headerID);
@@ -5082,7 +5092,7 @@ namespace DSPRE {
MW_LoadModelTextures(eventMapFile.mapModel, RomInfo.gameDirs[DirNames.mapTextures].unpackedDir, areaData.mapTileset);
bool isInteriorMap = false;
- if ((RomInfo.gameVersion == gVerEnum.HeartGold || RomInfo.gameVersion == gVerEnum.SoulSilver) && areaData.areaType == 0x0)
+ if ((RomInfo.gameVersion == GameVersions.HeartGold || RomInfo.gameVersion == GameVersions.SoulSilver) && areaData.areaType == 0x0)
isInteriorMap = true;
for (int i = 0; i < eventMapFile.buildings.Count; i++) {
@@ -5303,15 +5313,15 @@ namespace DSPRE {
RomInfo.SetOWtable();
RomInfo.Set3DOverworldsDict();
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
DSUtils.TryUnpackNarcs(new List { DirNames.interiorBuildingModels });
}
disableHandlers = true;
if (File.Exists(RomInfo.OWtablePath)) {
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
break;
default:
// HGSS Overlay 1 must be decompressed in order to read the overworld table
@@ -6381,13 +6391,13 @@ namespace DSPRE {
int locNum;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP: {
+ case GameFamilies.DP: {
HeaderDP h = (HeaderDP)destHeader;
locNum = h.locationName;
break;
}
- case gFamEnum.Plat: {
+ case GameFamilies.Plat: {
HeaderPt h = (HeaderPt)destHeader;
locNum = h.locationName;
@@ -8134,8 +8144,8 @@ namespace DSPRE {
string[] lightTypes;
switch (RomInfo.gameFamily) {
- case gFamEnum.DP:
- case gFamEnum.Plat:
+ case GameFamilies.DP:
+ case GameFamilies.Plat:
lightTypes = new string[3] { "Day/Night Light", "Model's light", "Unknown Light" };
break;
default:
@@ -8363,7 +8373,7 @@ namespace DSPRE {
areaDataLightTypeComboBox.SelectedIndex = currentAreaData.lightType;
disableHandlers = true;
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
areaDataDynamicTexturesNumericUpDown.Value = currentAreaData.dynamicTextureType;
bool interior = currentAreaData.areaType == 0;
@@ -8540,7 +8550,7 @@ namespace DSPRE {
overlayCameraTblOffset = RAMaddresses[0] - DSUtils.GetOverlayRAMAddress(RomInfo.cameraTblOverlayNumber);
using (DSUtils.EasyReader br = new DSUtils.EasyReader(camOverlayPath, overlayCameraTblOffset)) {
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
currentCameraTable = new GameCamera[17];
for (int i = 0; i < currentCameraTable.Length; i++) {
currentCameraTable[i] = new GameCamera(br.ReadUInt32(), br.ReadInt16(), br.ReadInt16(), br.ReadInt16(),
@@ -8690,7 +8700,7 @@ namespace DSPRE {
uint entrySize = 4;
uint tableSizeOffset = 10;
- if (gameFamily == gFamEnum.HGSS) {
+ if (gameFamily == GameFamilies.HGSS) {
entrySize += 2;
tableSizeOffset += 2;
encounterSSEQAltUpDown.Enabled = true;
@@ -8702,7 +8712,7 @@ namespace DSPRE {
uint entryOffset = (uint)ar.BaseStream.Position;
byte tclass = (byte)ar.ReadUInt16();
ushort musicD = ar.ReadUInt16();
- ushort? musicN = gameFamily == gFamEnum.HGSS ? ar.ReadUInt16() : (ushort?)null;
+ ushort? musicN = gameFamily == GameFamilies.HGSS ? ar.ReadUInt16() : (ushort?)null;
trainerClassEncounterMusicDict[tclass] = (entryOffset, musicD, musicN);
}
}
@@ -8846,7 +8856,7 @@ namespace DSPRE {
pokemonSpecies[i] = new SpeciesFile(new FileStream(RomInfo.gameDirs[DirNames.personalPokeData].unpackedDir + "\\" + i.ToString("D4"), FileMode.Open));
}
- if (gameFamily == gFamEnum.HGSS) {
+ if (gameFamily == GameFamilies.HGSS) {
foreach (ComboBox partyGenderComboBox in partyGenderComboBoxList) {
partyGenderComboBox.Visible = true;
partyGenderComboBox.Items.Add("Default Gender");
@@ -8858,7 +8868,7 @@ namespace DSPRE {
partyGenderComboBox.Visible = false;
}
- if (gameFamily == gFamEnum.DP) {
+ if (gameFamily == GameFamilies.DP) {
foreach (ComboBox partyFormComboBox in partyFormComboBoxList)
partyFormComboBox.Visible = false;
@@ -9165,7 +9175,7 @@ namespace DSPRE {
currentTrainerFile.party[i].difficulty = (byte)partyIVUpdownList[i].Value;
- if (hasMoreThanOneGender((int)currentTrainerFile.party[i].pokeID, pokemonSpecies) && gameFamily == gFamEnum.HGSS) {
+ if (hasMoreThanOneGender((int)currentTrainerFile.party[i].pokeID, pokemonSpecies) && gameFamily == GameFamilies.HGSS) {
switch (partyGenderComboBoxList[i].SelectedIndex) {
case TRAINER_PARTY_POKEMON_GENDER_DEFAULT_INDEX:
currentTrainerFile.party[i].genderAndAbilityFlags = PartyPokemon.GenderAndAbilityFlags.NO_FLAGS;
@@ -9280,7 +9290,7 @@ namespace DSPRE {
encounterSSEQMainUpDown.Value = 0;
}
- eyeContactMusicAltLabel.Enabled = encounterSSEQAltUpDown.Enabled = (encounterSSEQMainUpDown.Enabled && gameFamily == gFamEnum.HGSS);
+ eyeContactMusicAltLabel.Enabled = encounterSSEQAltUpDown.Enabled = (encounterSSEQMainUpDown.Enabled && gameFamily == GameFamilies.HGSS);
encounterSSEQAltUpDown.Value = output.musicN != null ? (ushort)output.musicN : 0;
currentTrainerFile.trp.trainerClass = (byte)selection;
}
@@ -9294,7 +9304,7 @@ namespace DSPRE {
string tilesFilename = tilesFileID.ToString("D4");
trainerTile = new NCGR(gameDirs[DirNames.trainerGraphics].unpackedDir + "\\" + tilesFilename, tilesFileID, tilesFilename);
- if (gameFamily == gFamEnum.DP) {
+ if (gameFamily == GameFamilies.DP) {
return 0;
}
@@ -9447,7 +9457,7 @@ namespace DSPRE {
}
disableHandlers = false;
- if (gameFamily.Equals(gFamEnum.HGSS) && tableEditorIsReady) {
+ if (gameFamily.Equals(GameFamilies.HGSS) && tableEditorIsReady) {
pbEffectsTrainerCombobox.Items[selectedTrClass] = trainerClassListBox.Items[selectedTrClass];
for (int i = 0; i < vsTrainerEffectsList.Count; i++) {
if (vsTrainerEffectsList[i].trainerClass == selectedTrClass) {
@@ -9483,7 +9493,7 @@ namespace DSPRE {
partyAbilityComboBoxList[partyPokemonPosition].Items.Add(ability1);
//if the name " -" is returned for ability 2 then there is no ability 2
- if (ability2.Equals(" -") || ability2.Equals(ability1) || gameFamily != gFamEnum.HGSS) {
+ if (ability2.Equals(" -") || ability2.Equals(ability1) || gameFamily != GameFamilies.HGSS) {
partyAbilityComboBoxList[partyPokemonPosition].Enabled = false;
} else {
partyAbilityComboBoxList[partyPokemonPosition].Items.Add(ability2);
@@ -9497,7 +9507,7 @@ namespace DSPRE {
int currentPokemonGenderRatio = pokemonSpecies[partyPokemonComboboxList[partyPokemonPosition].SelectedIndex].GenderRatioMaleToFemale;
PartyPokemon.GenderAndAbilityFlags currentPokemonGenderAndAbilityFlags = currentTrainerFile.party[partyPokemonPosition].genderAndAbilityFlags;
- if (gameFamily == gFamEnum.HGSS) {
+ if (gameFamily == GameFamilies.HGSS) {
switch (currentPokemonGenderRatio) {
case GENDER_RATIO_MALE:
partyGenderComboBoxList[partyPokemonPosition].SelectedIndex = TRAINER_PARTY_POKEMON_GENDER_MALE_INDEX;
@@ -9530,7 +9540,7 @@ namespace DSPRE {
switch (pokemonID) {
case PICHU_ID_NUM:
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
pokemonFormNames.Add("Non-Spiky-Eared");
pokemonFormNames.Add("Spiky-Eared");
} else {
@@ -9588,7 +9598,7 @@ namespace DSPRE {
}
private void setTrainerPartyPokemonForm(int partyPokemonPosition) {
- if (gameFamily != gFamEnum.DP) {
+ if (gameFamily != GameFamilies.DP) {
partyFormComboBoxList[partyPokemonPosition].Items.Clear();
List currentPokemonFormName = getPokemonFormNames(partyPokemonComboboxList[partyPokemonPosition].SelectedIndex);
foreach (string formName in currentPokemonFormName)
@@ -9627,7 +9637,7 @@ namespace DSPRE {
private void SetupConditionalMusicTable() {
switch (RomInfo.gameFamily) {
- case gFamEnum.HGSS:
+ case GameFamilies.HGSS:
RomInfo.SetConditionalMusicTableOffsetToRAMAddress();
conditionalMusicTable = new List<(ushort, ushort, ushort)>();
@@ -9656,7 +9666,7 @@ namespace DSPRE {
}
break;
- case gFamEnum.Plat:
+ case GameFamilies.Plat:
pbEffectsMonGroupBox.Enabled = false;
pbEffectsTrainerGroupBox.Enabled = false;
conditionalMusicGroupBox.Enabled = false;
@@ -9671,7 +9681,7 @@ namespace DSPRE {
}
}
private void SetupBattleEffectsTables() {
- if (RomInfo.gameFamily == gFamEnum.HGSS || RomInfo.gameFamily == gFamEnum.Plat) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS || RomInfo.gameFamily == GameFamilies.Plat) {
DSUtils.TryUnpackNarcs(new List {
DirNames.trainerGraphics,
DirNames.textArchives,
@@ -9688,7 +9698,7 @@ namespace DSPRE {
byte comboTableEntriesCount;
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
comboTableEntriesCount = DSUtils.ARM9.ReadByte(RomInfo.effectsComboTableOffsetToSizeLimiter);
vsPokemonEffectsList = new List<(int pokemonID, int comboID)>();
@@ -9721,7 +9731,7 @@ namespace DSPRE {
String expArmPath = RomInfo.gameDirs[DirNames.synthOverlay].unpackedDir + '\\' + ROMToolboxDialog.expandedARMfileID.ToString("D4");
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
using (DSUtils.EasyReader ar = new DSUtils.EasyReader(ROMToolboxDialog.flag_TrainerClassBattleTableRepointed ? expArmPath : RomInfo.arm9Path, vsTrainerTableStartAddress)) {
byte trainerTableEntriesCount = DSUtils.ARM9.ReadByte(RomInfo.vsTrainerEntryTableOffsetToSizeLimiter);
@@ -9763,7 +9773,7 @@ namespace DSPRE {
}
}
- if (RomInfo.gameFamily == gFamEnum.HGSS) {
+ if (RomInfo.gameFamily == GameFamilies.HGSS) {
var items = pbEffectsCombosListbox.Items.Cast