Skip to content

Commit c3b4a68

Browse files
Further changes to the Chunk Model Data Editor and the RingGroup SA2 Object Definition.
-Chunk Model Data Editor: Minor adjustments made to potentially address resizing issues that can occur with certain setups. --Chunk Model Vertex Data Editor: Adjusted the window's presentation to separate the data sets contained in each vertex, improving visibility. --Chunk Model Material Data Editor: Fixed a bug that would cause Ambient and Specular values to save incorrectly when their default values are set to 0, 0, 0. -SA2 Object Definition: Fixed the rotations of all Ring objects for real this time.
1 parent 3f7dc03 commit c3b4a68

File tree

7 files changed

+182
-171
lines changed

7 files changed

+182
-171
lines changed

Libraries/SAEditorCommon/UI/ChunkModelDataEditor.Designer.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Libraries/SAEditorCommon/UI/ChunkModelDataEditor.cs

Lines changed: 50 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ public ChunkModelDataEditor(NJS_OBJECT objectOriginal, BMPInfo[] textures, int i
3232
if (objectOriginal == null)
3333
return;
3434
InitializeComponent();
35+
freeze = true;
3536
this.Resize += ChunkModelDataEditor_Resize;
3637
OriginalSize = this.Size;
37-
freeze = true;
3838
comboBoxNode.Items.Clear();
3939
editedHierarchy = objectOriginal.Clone();
4040
editedHierarchy.FixParents();
@@ -56,6 +56,55 @@ public ChunkModelDataEditor(NJS_OBJECT objectOriginal, BMPInfo[] textures, int i
5656
freeze = false;
5757
}
5858

59+
private void resize_Control(Control c, Rectangle r, int type = 0)
60+
{
61+
float xRatio = (float)this.Width / (float)OriginalSize.Width;
62+
float yRatio = (float)this.Height / (float)OriginalSize.Height;
63+
var xSize = this.Width - OriginalSize.Width;
64+
var ySize = this.Height - OriginalSize.Height;
65+
66+
int newX = (int)(r.X * xRatio);
67+
int newY = (int)(r.Y * yRatio);
68+
69+
var newXLoc = r.X + xSize;
70+
var newYLoc = r.Y + ySize;
71+
72+
int newWidth = (int)(r.Width * xRatio);
73+
int newHeight = (int)(r.Height * yRatio);
74+
75+
var newXSize = r.Width + xSize;
76+
var newYSize = r.Height + ySize;
77+
78+
switch (type)
79+
{
80+
case 0: // Buttons beside list (Moving poly sets up/down)
81+
default:
82+
c.Location = new Point(newXLoc, r.Y);
83+
break;
84+
case 1: // Vertex List and Group
85+
c.Size = new Size(r.Width, newYSize);
86+
break;
87+
case 2: // Poly Data List
88+
c.Size = new Size(newXSize, newYSize);
89+
break;
90+
case 3: // Buttons below list
91+
c.Location = new Point(r.X, newYLoc);
92+
break;
93+
}
94+
}
95+
private void ChunkModelDataEditor_Resize(object sender, EventArgs e)
96+
{
97+
resize_Control(listViewMeshes, polydatalistdyn, 2);
98+
resize_Control(listViewVertices, vertdatalistdyn, 1);
99+
resize_Control(groupBoxVertList, vertdatagroupdyn, 1);
100+
resize_Control(groupBoxMeshList, polydatagroupdyn, 2);
101+
resize_Control(buttonCloneMesh, polyclonebutton, 3);
102+
resize_Control(buttonResetMeshes, polyresetbutton, 3);
103+
resize_Control(buttonDeleteMesh, polydeletebutton, 3);
104+
resize_Control(buttonMoveMeshUp, polyupbutton, 0);
105+
resize_Control(buttonMoveMeshDown, polydownbutton, 0);
106+
}
107+
59108
#region Vertex management
60109

61110
#endregion
@@ -1031,43 +1080,6 @@ private void contextMenuStrip2_Opening(object sender, System.ComponentModel.Canc
10311080
{
10321081

10331082
}
1034-
1035-
private void resize_Control(Control c, Rectangle r, int type = 0)
1036-
{
1037-
float xRatio = (float)this.Width / (float)OriginalSize.Width;
1038-
float yRatio = (float)this.Height / (float)OriginalSize.Height;
1039-
float xSize = (float)(this.Width - OriginalSize.Width);
1040-
float ySize = (float)(this.Height - OriginalSize.Height);
1041-
1042-
int newX = (int)(r.X * xRatio);
1043-
int newY = (int)(r.Y * yRatio);
1044-
1045-
int newXLoc = (int)(r.X + xSize);
1046-
int newYLoc = (int)(r.Y + ySize);
1047-
1048-
int newWidth = (int)(r.Width * xRatio);
1049-
int newHeight = (int)(r.Height * yRatio);
1050-
1051-
int newXSize = (int)(r.Width + xSize);
1052-
int newYSize = (int)(r.Height + ySize);
1053-
1054-
switch (type)
1055-
{
1056-
case 0: // Buttons beside list (Moving poly sets up/down)
1057-
default:
1058-
c.Location = new Point(newXLoc, r.Y);
1059-
break;
1060-
case 1: // Vertex List and Group
1061-
c.Size = new Size(r.Width, newYSize);
1062-
break;
1063-
case 2: // Poly Data List
1064-
c.Size = new Size(newXSize, newYSize);
1065-
break;
1066-
case 3: // Buttons below list
1067-
c.Location = new Point(r.X, newYLoc);
1068-
break;
1069-
}
1070-
}
10711083
private void listViewVertices_SelectedIndexChanged(object sender, EventArgs e)
10721084
{
10731085
if (listViewVertices.SelectedIndices.Count == 0)
@@ -1097,18 +1109,5 @@ private void listViewVertices_SelectedIndexChanged(object sender, EventArgs e)
10971109
sb.Append(vcount);
10981110
toolStripStatusLabelInfo.Text = sb.ToString();
10991111
}
1100-
1101-
private void ChunkModelDataEditor_Resize(object sender, EventArgs e)
1102-
{
1103-
resize_Control(listViewMeshes, polydatalistdyn, 2);
1104-
resize_Control(listViewVertices, vertdatalistdyn, 1);
1105-
resize_Control(groupBoxVertList, vertdatagroupdyn, 1);
1106-
resize_Control(groupBoxMeshList, polydatagroupdyn, 2);
1107-
resize_Control(buttonCloneMesh, polyclonebutton, 3);
1108-
resize_Control(buttonResetMeshes, polyresetbutton, 3);
1109-
resize_Control(buttonDeleteMesh, polydeletebutton, 3);
1110-
resize_Control(buttonMoveMeshUp, polyupbutton);
1111-
resize_Control(buttonMoveMeshDown, polydownbutton);
1112-
}
11131112
}
11141113
}

Libraries/SAEditorCommon/UI/ChunkModelMaterialDataEditor.Designer.cs

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Libraries/SAEditorCommon/UI/ChunkModelMaterialDataEditor.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.Drawing;
43
using System.Windows.Forms;
5-
using SAModel.Direct3D.TextureSystem;
64

75
namespace SAModel.SAEditorCommon.UI
86
{
@@ -60,13 +58,15 @@ private void SetControls(PolyChunk poly)
6058
ambientRUpDown.Value = pcm.Ambient.Value.R;
6159
ambientGUpDown.Value = pcm.Ambient.Value.G;
6260
ambientBUpDown.Value = pcm.Ambient.Value.B;
61+
ambientColorBox.BackColor = Color.FromArgb(255, (int)ambientRUpDown.Value, (int)ambientGUpDown.Value, (int)ambientBUpDown.Value);
6362
}
6463
if (pcm.Specular.HasValue)
6564
{
6665
specularRUpDown.Value = pcm.Specular.Value.R;
6766
specularGUpDown.Value = pcm.Specular.Value.G;
6867
specularBUpDown.Value = pcm.Specular.Value.B;
6968
exponentTextBox.Text = pcm.SpecularExponent.ToString();
69+
specColorBox.BackColor = Color.FromArgb(255, (int)specularRUpDown.Value, (int)specularGUpDown.Value, (int)specularBUpDown.Value);
7070
}
7171
//DisplayFlags(index);
7272

@@ -185,11 +185,6 @@ private void alphaDiffuseNumeric_ValueChanged(object sender, EventArgs e)
185185
SetDiffuseFromNumerics();
186186
}
187187

188-
private void alphaSpecularNumeric_ValueChanged(object sender, EventArgs e)
189-
{
190-
SetSpecularFromNumerics();
191-
}
192-
193188
#endregion
194189
#region Flag Check Event Methods
195190

@@ -228,29 +223,19 @@ private void generalSettingBox_Enter(object sender, EventArgs e)
228223

229224
}
230225

231-
private void label1_Click(object sender, EventArgs e)
232-
{
233-
234-
}
235-
236226
void SetDiffuseFromNumerics()
237227
{
238228
diffuseColorBox.BackColor = Color.FromArgb((int)alphaDiffuseNumeric.Value, (int)diffuseRUpDown.Value, (int)diffuseGUpDown.Value, (int)diffuseBUpDown.Value);
239-
//diffuseColorBox.BackColor = pcm.Diffuse.Value;
240229
RaiseFormUpdated();
241230
}
242231
void SetAmbientFromNumerics()
243232
{
244-
PolyChunkMaterial pcm = (PolyChunkMaterial)PolyData;
245-
ambientColorBox.BackColor = Color.FromArgb(0xFF, (int)ambientRUpDown.Value, (int)ambientGUpDown.Value, (int)ambientBUpDown.Value);
246-
//ambientColorBox.BackColor = pcm.Ambient.Value;
233+
ambientColorBox.BackColor = Color.FromArgb(255, (int)ambientRUpDown.Value, (int)ambientGUpDown.Value, (int)ambientBUpDown.Value);
247234
RaiseFormUpdated();
248235
}
249236
void SetSpecularFromNumerics()
250237
{
251-
PolyChunkMaterial pcm = (PolyChunkMaterial)PolyData;
252-
specColorBox.BackColor = Color.FromArgb(0xFF, (int)specularRUpDown.Value, (int)specularGUpDown.Value, (int)specularBUpDown.Value);
253-
//specColorBox.BackColor = pcm.Specular.Value;
238+
specColorBox.BackColor = Color.FromArgb(255, (int)specularRUpDown.Value, (int)specularGUpDown.Value, (int)specularBUpDown.Value);
254239
RaiseFormUpdated();
255240
}
256241

0 commit comments

Comments
 (0)