diff --git a/SEConfigTool/SEConfigTool.Designer.cs b/SEConfigTool/SEConfigTool.Designer.cs index d7b52630..4b49716f 100644 --- a/SEConfigTool/SEConfigTool.Designer.cs +++ b/SEConfigTool/SEConfigTool.Designer.cs @@ -3205,9 +3205,9 @@ private void InitializeComponent() // splitContainer33.Panel1 // this.splitContainer33.Panel1.Controls.Add(this.TRV_SavedGame_Objects); - this.splitContainer33.Panel1MinSize = 200; + this.splitContainer33.Panel1MinSize = 300; this.splitContainer33.Size = new System.Drawing.Size(776, 349); - this.splitContainer33.SplitterDistance = 200; + this.splitContainer33.SplitterDistance = 300; this.splitContainer33.TabIndex = 1; // // splitContainer34 @@ -3294,8 +3294,9 @@ private void InitializeComponent() this.TRV_SavedGame_Objects.Dock = System.Windows.Forms.DockStyle.Fill; this.TRV_SavedGame_Objects.Location = new System.Drawing.Point(0, 0); this.TRV_SavedGame_Objects.Name = "TRV_SavedGame_Objects"; - this.TRV_SavedGame_Objects.Size = new System.Drawing.Size(200, 349); + this.TRV_SavedGame_Objects.Size = new System.Drawing.Size(300, 349); this.TRV_SavedGame_Objects.TabIndex = 0; + this.TRV_SavedGame_Objects.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.TRV_SavedGame_Objects_AfterSelect); // // SEConfigTool // diff --git a/SEConfigTool/SEConfigTool.cs b/SEConfigTool/SEConfigTool.cs index 9885748c..df7eb617 100644 --- a/SEConfigTool/SEConfigTool.cs +++ b/SEConfigTool/SEConfigTool.cs @@ -70,13 +70,16 @@ private void LoadSaveFile(FileInfo saveFileInfo) } TRV_SavedGame_Objects.BeginUpdate(); + TRV_SavedGame_Objects.Nodes.Clear(); + + //Add the sector object categories TRV_SavedGame_Objects.Nodes.Add("Cube Grids"); TRV_SavedGame_Objects.Nodes.Add("Voxel Maps"); TRV_SavedGame_Objects.Nodes.Add("Floating Objects"); TRV_SavedGame_Objects.Nodes.Add("Meteors"); TRV_SavedGame_Objects.Nodes.Add("Unknown"); - TRV_SavedGame_Objects.EndUpdate(); + //Add the cube grids foreach (CubeGrid cubeGrid in save.CubeGrids) { float x = cubeGrid.PositionAndOrientation.Position.x; @@ -85,8 +88,21 @@ private void LoadSaveFile(FileInfo saveFileInfo) float dist = (float)Math.Sqrt(x * x + y * y + z * z); - TRV_SavedGame_Objects.Nodes[0].Nodes.Add(cubeGrid.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); + TreeNode newNode = TRV_SavedGame_Objects.Nodes[0].Nodes.Add(cubeGrid.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); + + //Create the cube grid sub-item categories + newNode.Nodes.Add("Cube Blocks"); + newNode.Nodes.Add("Conveyor Lines"); + newNode.Nodes.Add("Block Groups"); + + //Add the cube blocks + foreach (CubeBlock cubeBlock in cubeGrid.CubeBlocks) + { + newNode.Nodes[0].Nodes.Add(cubeBlock.Name); + } } + + //Add the voxel maps foreach (VoxelMap voxelMap in save.VoxelMaps) { float x = voxelMap.PositionAndOrientation.Position.x; @@ -97,6 +113,8 @@ private void LoadSaveFile(FileInfo saveFileInfo) TRV_SavedGame_Objects.Nodes[1].Nodes.Add(voxelMap.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); } + + //Add the floating objects foreach (FloatingObject floatingObject in save.FloatingObjects) { float x = floatingObject.PositionAndOrientation.Position.x; @@ -107,6 +125,8 @@ private void LoadSaveFile(FileInfo saveFileInfo) TRV_SavedGame_Objects.Nodes[2].Nodes.Add(floatingObject.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); } + + //Add the meteors foreach (Meteor meteor in save.Meteors) { float x = meteor.PositionAndOrientation.Position.x; @@ -117,6 +137,8 @@ private void LoadSaveFile(FileInfo saveFileInfo) TRV_SavedGame_Objects.Nodes[3].Nodes.Add(meteor.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); } + + //Add any unknown objects foreach (SectorObject unknown in save.UnknownObjects) { float x = unknown.PositionAndOrientation.Position.x; @@ -127,6 +149,8 @@ private void LoadSaveFile(FileInfo saveFileInfo) TRV_SavedGame_Objects.Nodes[4].Nodes.Add(unknown.Name + " | " + "Dist: " + dist.ToString("F2") + "m | " + x + ";" + z + ";" + y); } + + TRV_SavedGame_Objects.EndUpdate(); } private void FillBlocksConfigurationListBox() @@ -279,7 +303,9 @@ private void SEConfigTool_Load(object sender, EventArgs e) FillVoxelMaterialConfigurationListBox(); } - private void BTN_LoadSaveGame_Click(object sender, EventArgs e) + #region SavedGame + + private void BTN_LoadSaveGame_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog { @@ -304,9 +330,28 @@ private void BTN_LoadSaveGame_Click(object sender, EventArgs e) } } - #region CubeBlock + private void TRV_SavedGame_Objects_AfterSelect(object sender, TreeViewEventArgs e) + { + //Ignore top-level nodes + if (e.Node.Level == 0) + return; + + //Sector object nodes + if (e.Node.Level == 1) + { + } + + //Sector object parts nodes + if (e.Node.Level == 2) + { + } + } + + #endregion + + #region CubeBlock - private void LBX_BlocksConfiguration_SelectedIndexChanged(object sender, EventArgs e) + private void LBX_BlocksConfiguration_SelectedIndexChanged(object sender, EventArgs e) { m_currentlySelecting = true; int index = LBX_BlocksConfiguration.SelectedIndex; diff --git a/SEModAPI/API/SaveData/CubeBlock.cs b/SEModAPI/API/SaveData/CubeBlock.cs index 9d197c90..9eb12858 100644 --- a/SEModAPI/API/SaveData/CubeBlock.cs +++ b/SEModAPI/API/SaveData/CubeBlock.cs @@ -1,11 +1,73 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; + +using Sandbox.Common.ObjectBuilders; +using Sandbox.Common.ObjectBuilders.Definitions; +using Sandbox.Common.ObjectBuilders.VRageData; + +using SEModAPI.API.Definitions; namespace SEModAPI.API.SaveData { - class CubeBlock + public class CubeBlock : OverLayerDefinition { + #region "Constructors and Initializers" + + public CubeBlock(MyObjectBuilder_CubeBlock definition) + : base(definition) + {} + + #endregion + + #region "Properties" + + new public string Name + { + get { return this.GetNameFrom(m_baseDefinition); } + } + + public SerializableVector3I Min + { + get { return m_baseDefinition.Min; } + set + { + if (m_baseDefinition.Min.Equals(value)) return; + m_baseDefinition.Min = value; + Changed = true; + } + } + + public SerializableBlockOrientation BlockOrientation + { + get { return m_baseDefinition.BlockOrientation; } + set + { + if (m_baseDefinition.BlockOrientation.Equals(value)) return; + m_baseDefinition.BlockOrientation = value; + Changed = true; + } + } + + public SerializableVector3 ColorMaskHSV + { + get { return m_baseDefinition.ColorMaskHSV; } + set + { + if (m_baseDefinition.ColorMaskHSV.Equals(value)) return; + m_baseDefinition.ColorMaskHSV = value; + Changed = true; + } + } + + #endregion + + #region "Methods" + + protected override string GetNameFrom(MyObjectBuilder_CubeBlock definition) + { + return m_baseDefinition.SubtypeName; + } + + #endregion } } diff --git a/SEModAPI/API/SaveData/CubeGrid.cs b/SEModAPI/API/SaveData/CubeGrid.cs index fbf9a951..360edf00 100644 --- a/SEModAPI/API/SaveData/CubeGrid.cs +++ b/SEModAPI/API/SaveData/CubeGrid.cs @@ -10,11 +10,24 @@ namespace SEModAPI.API.SaveData { public class CubeGrid : SectorObject { + #region "Attributes" + + private List m_cubeBlocks; + + #endregion + #region "Constructors and Initializers" public CubeGrid(MyObjectBuilder_CubeGrid definition) : base(definition) - {} + { + //TODO - Change this to use a manager rather than a flat list + m_cubeBlocks = new List(); + foreach (MyObjectBuilder_CubeBlock cubeBlock in definition.CubeBlocks) + { + m_cubeBlocks.Add(new CubeBlock(cubeBlock)); + } + } #endregion @@ -64,9 +77,9 @@ public VRageMath.Vector3 AngularVelocity } } - public List CubeBlocks + public List CubeBlocks { - get { return m_baseDefinition.CubeBlocks; } + get { return m_cubeBlocks; } } public List Skeleton