private void ButtonX_ConvertMdl_Click(object sender, EventArgs e) { var resMdl = PublicFunctions.GetModelViaModelConverter(forceDisplaylist: Conversions.ToSByte(((ComboItem)ComboBoxEx1.SelectedItem).Tag), inputsKey: Conversions.ToString(SelectedProfile().FileName.GetHashCode())); if (resMdl is object) { mdl = resMdl?.mdl; ButtonX_ConvertMdl.Image = My.Resources.Resources.icons8_checkmark_16px_1; ButtonX_ImportMdl.Enabled = true; } }
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(); } }