private void buttonAddSolid_Click(object sender, EventArgs e) { Option currentOption = optionsBox.SelectedItem as Option; if (currentOption != null) { if (currentOption.SolidMeshes.Count < 4) { this.SuspendLayout(); MeshSlot solidMesh = new MeshSlot(); currentOption.SolidMeshes.Add(solidMesh); MeshBuilder meshBuilder = new MeshBuilder(); meshBuilder.Dock = DockStyle.Top; meshBuilder.SetMeshSlot(solidMesh); meshBuilder.meshSlotType = MeshBuilder.MeshSlotType.Solid; meshBuilder.MeshSlotUpdated = this.UpdatedMeshSlot; meshBuilder.RemoveClicked = this.buttonRemoveMeshSlot; meshBuilder.SetMeshSlotTitle("Solid Slot"); this.tableLayoutPanel1.RowCount++; this.tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize)); this.tableLayoutPanel1.Controls.Add(meshBuilder); meshBuilder.Invalidate(false); this.ResumeLayout(); } else { MessageBox.Show("Cannot have more than 4 Solid Mesh Pieces.", "CC Mod Pack Generator", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } } }
public static void CacheMeshSlot(MeshSlot meshSlot) { if (meshSlot != null) { CacheMesh(meshSlot.NormalMesh, ref ibList, ref vbList, ref formatList); CacheMesh(meshSlot.ShadowMesh, ref ibList, ref vbList, ref formatList); CacheString(meshSlot.PS0Texture, ref textureList); CacheString(meshSlot.PS1Texture, ref textureList); CacheString(meshSlot.PS2Texture, ref textureList); CacheString(meshSlot.PSCB2Buffer, ref constantBufferList); } }
public void SetMeshSlot(MeshSlot meshSlot) { this.ibResource.SetValue(meshSlot.NormalMesh.IndexBuffer); SetNormalFormatText(meshSlot.NormalMesh.Format); this.vbResource.SetValue(meshSlot.NormalMesh.VertexBuffer); this.normalStride.Text = meshSlot.NormalMesh.Stride.ToString(); if (meshSlot.ShadowMesh.IsDefault) { this.enableShadows.Checked = true; } else if (meshSlot.ShadowMesh.IsNull) { this.disableShadows.Checked = true; } else { this.customShadows.Checked = true; this.sibResource.SetValue(meshSlot.ShadowMesh.IndexBuffer); SetShadowFormatText(meshSlot.ShadowMesh.Format); this.svbResource.SetValue(meshSlot.ShadowMesh.VertexBuffer); this.ShadowStride.Text = meshSlot.ShadowMesh.Stride.ToString(); } this.ps0Resource.SetValue(meshSlot.PS0Texture); this.ps1Resource.SetValue(meshSlot.PS1Texture); this.ps2Resource.SetValue(meshSlot.PS2Texture); this.pscb2Resource.SetValue(meshSlot.PSCB2Buffer); BindingSource bNFSource = new BindingSource(); bNFSource.DataSource = ModPackGui.formatList; bNFSource.ListChanged += BNFSource_NormalListChanged; BindingSource bSFSource = new BindingSource(); bSFSource.DataSource = ModPackGui.formatList; bSFSource.ListChanged += BNFSource_ShadowListChanged; this.vbResource.SetBindingList(ref ModPackGui.vbList); this.svbResource.SetBindingList(ref ModPackGui.vbList); this.ibResource.SetBindingList(ref ModPackGui.ibList); this.sibResource.SetBindingList(ref ModPackGui.ibList); this.ps0Resource.SetBindingList(ref ModPackGui.textureList); this.ps1Resource.SetBindingList(ref ModPackGui.textureList); this.ps2Resource.SetBindingList(ref ModPackGui.textureList); this.pscb2Resource.SetBindingList(ref ModPackGui.constantBufferList); }
private void UpdatedMeshSlot(object sender, MeshBuilder.MeshSlotParameterEventArgs e) { MeshBuilder meshBuilder = sender as MeshBuilder; if (meshBuilder != null) { MeshBuilder.MeshSlotType slotType = meshBuilder.meshSlotType; int currentIndex = 0; int i = 0; for (i = 0; i < this.tableLayoutPanel1.Controls.Count; i++) { MeshBuilder testMeshBuilder = this.tableLayoutPanel1.Controls[i] as MeshBuilder; if (testMeshBuilder != null) { if (testMeshBuilder == meshBuilder) { break; } if (testMeshBuilder.meshSlotType == meshBuilder.meshSlotType) { currentIndex++; } } } Option currentOption = this.optionsBox.SelectedItem as Option; MeshSlot targetMeshSlot = null; if (slotType == MeshBuilder.MeshSlotType.Alpha) { targetMeshSlot = currentOption.AlphaMeshes[currentIndex]; } else { targetMeshSlot = currentOption.SolidMeshes[currentIndex]; } if (targetMeshSlot != null) { switch (e.meshSlotParam) { case MeshBuilder.MeshSlotParameter.IB: targetMeshSlot.NormalMesh.IndexBuffer = e.value; break; case MeshBuilder.MeshSlotParameter.IB_FORMAT: targetMeshSlot.NormalMesh.Format = e.value; break; case MeshBuilder.MeshSlotParameter.VB: targetMeshSlot.NormalMesh.VertexBuffer = e.value; break; case MeshBuilder.MeshSlotParameter.VB_STRIDE: try { if (String.IsNullOrEmpty(e.value)) { targetMeshSlot.NormalMesh.Stride = null; } else { targetMeshSlot.NormalMesh.Stride = UInt32.Parse(e.value); } } catch (Exception ex) { MessageBox.Show("Invalid number for Stride", "CC Mod Pack Generator", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; case MeshBuilder.MeshSlotParameter.SHADOW: if (String.IsNullOrEmpty(e.value)) { // NO Shadow targetMeshSlot.ShadowMesh.IsNull = true; targetMeshSlot.ShadowMesh.IsDefault = false; targetMeshSlot.ShadowMesh.VertexBuffer = null; targetMeshSlot.ShadowMesh.Stride = null; targetMeshSlot.ShadowMesh.IndexBuffer = null; targetMeshSlot.ShadowMesh.Format = null; } else if ("DEFAULT".Equals(e.value, StringComparison.OrdinalIgnoreCase)) { // DEFAULT SHADOW targetMeshSlot.ShadowMesh.IsNull = false; targetMeshSlot.ShadowMesh.IsDefault = true; targetMeshSlot.ShadowMesh.VertexBuffer = null; targetMeshSlot.ShadowMesh.Stride = null; targetMeshSlot.ShadowMesh.IndexBuffer = null; targetMeshSlot.ShadowMesh.Format = null; } else { targetMeshSlot.ShadowMesh.IsNull = false; targetMeshSlot.ShadowMesh.IsDefault = false; } break; case MeshBuilder.MeshSlotParameter.SIB: targetMeshSlot.ShadowMesh.IndexBuffer = e.value; break; case MeshBuilder.MeshSlotParameter.SIB_FORMAT: targetMeshSlot.ShadowMesh.Format = e.value; break; case MeshBuilder.MeshSlotParameter.SVB: targetMeshSlot.ShadowMesh.VertexBuffer = e.value; break; case MeshBuilder.MeshSlotParameter.SVB_STRIDE: try { if (String.IsNullOrEmpty(e.value)) { targetMeshSlot.ShadowMesh.Stride = null; } else { targetMeshSlot.ShadowMesh.Stride = UInt32.Parse(e.value); } } catch (Exception ex) { MessageBox.Show("Invalid number for Stride", "CC Mod Pack Generator", MessageBoxButtons.OK, MessageBoxIcon.Error); } break; case MeshBuilder.MeshSlotParameter.PS0: targetMeshSlot.PS0Texture = e.value; break; case MeshBuilder.MeshSlotParameter.PS1: targetMeshSlot.PS1Texture = e.value; break; case MeshBuilder.MeshSlotParameter.PS2: targetMeshSlot.PS2Texture = e.value; break; case MeshBuilder.MeshSlotParameter.PSCB2: targetMeshSlot.PSCB2Buffer = e.value; break; } } } }