internal void CheckAndLoadNew() { Ogl.MakeCurrent(); bool loadAreaIDs = false; if (Main.CArea is null) { loadAreaIDs = true; } if (Main.CLevel.Areas.Count != Main.ComboBoxItem_Area.Items.Count) { loadAreaIDs = true; } else { foreach (ComboItem ci in Main.ComboBoxItem_Area.Items) { if (!Main.CLevel.Areas.Contains((LevelArea)ci.Tag)) { loadAreaIDs = true; } } } if (loadAreaIDs) { Main.LoadAreaIDs(); } else { bool loadAreaMdl = false; if (hashCollisionMap != Main.CArea.AreaModel.Collision.GetHashCode()) { hashCollisionMap = 0; cCollisionMap = null; if (Ogl.CurrentModelDrawMod == ModelDrawMod.Collision) { loadAreaMdl = true; } } if (hashVisualMap != Main.CArea.AreaModel.Fast3DBuffer.GetBuffer().GetHashCode()) { hashVisualMap = 0; cVisualMap = null; if (Ogl.CurrentModelDrawMod == ModelDrawMod.VisualMap) { loadAreaMdl = true; } } if (loadAreaMdl) { Maps.LoadAreaModel(); } else { Ogl.Invalidate(); } } }
public void ImportAreaModel(bool convertModel, bool convertCollision, string inputKey) { var res = PublicFunctions.GetModelViaModelConverter(loadVisualMapAsDefault: convertModel, loadCollisionAsDefault: convertCollision, inputsKey: inputKey); if (res is object) { Ogl.MakeCurrent(); Main.SuspendLayout(); { var withBlock = Main.CArea; HistoryPoint hp = null; var OldAreaModel = withBlock.AreaModel; if (res.Value.hasCollision && res.Value.hasVisualMap == true) { hp = HistoryPoint.FromObject(this, ObjectValueType.Field, new MemberWhiteList(new[] { "rndrVisualMap", "cVisualMap", "rndrCollisionMap", "cCollisionMap" }), BindingFlags.Instance | BindingFlags.NonPublic); var os = new ObjectState(); os.Object = Main.CArea; os.ValueToPatch = withBlock.AreaModel; os.MemberFlags = BindingFlags.Instance | BindingFlags.Public; os.MemberType = ObjectValueType.Property; os.MemberName = "AreaModel"; hp.Entries.Add(os); withBlock.AreaModel = res?.mdl; withBlock.AreaModel.Collision.SpecialBoxes = OldAreaModel.Collision.SpecialBoxes; cVisualMap = null; cCollisionMap = null; } else if (res.Value.hasCollision == true) { hp = HistoryPoint.FromObject(this, ObjectValueType.Field, new MemberWhiteList(new[] { "rndrCollisionMap", "cCollisionMap" }), BindingFlags.Instance | BindingFlags.NonPublic); var os = new ObjectState(); os.Object = Main.CArea.AreaModel; os.ValueToPatch = withBlock.AreaModel.Collision; os.MemberFlags = BindingFlags.Instance | BindingFlags.Public; os.MemberType = ObjectValueType.Property; os.MemberName = "Collision"; hp.Entries.Add(os); withBlock.AreaModel.Collision = res?.mdl.Collision; withBlock.AreaModel.Collision.SpecialBoxes = OldAreaModel.Collision.SpecialBoxes; cCollisionMap = null; } else if (res.Value.hasVisualMap == true) { hp = HistoryPoint.FromObject(this, ObjectValueType.Field, new MemberWhiteList(new[] { "rndrVisualMap", "cVisualMap" }), BindingFlags.Instance | BindingFlags.NonPublic); var os = new ObjectState(); os.Object = Main.CArea.AreaModel; os.ValueToPatch = withBlock.AreaModel.Fast3DBuffer; os.MemberFlags = BindingFlags.Instance | BindingFlags.Public; os.MemberType = ObjectValueType.Property; os.MemberName = "Fast3DBuffer"; hp.Entries.Add(os); withBlock.AreaModel = res?.mdl; withBlock.AreaModel.Collision = OldAreaModel.Collision; cVisualMap = null; } if (res.Value.hasVisualMap == true) { withBlock.ScrollingTextures.Clear(); withBlock.ScrollingTextures.AddRange(withBlock.AreaModel.Fast3DBuffer.ConvertResult.ScrollingCommands.ToArray()); Main.Rommgr.RomConfig.GetLevelConfig(Main.CLevel.LevelID).GetLevelAreaConfig(withBlock.AreaID).ScrollingNames = res?.mdl.Fast3DBuffer.ConvertResult.ScrollingNames; } if (hp != null && hp.Entries.Any()) { Main.history.Store(hp); } } Main.CArea.SetSegmentedBanks(Main.Rommgr); LoadAreaModel(); Main.ResumeLayout(); } else { Ogl.MakeCurrent(); } }