Skip to content

Commit

Permalink
-Added CubeBlock functionality into CubeGrid interface
Browse files Browse the repository at this point in the history
-Expanded sector object tree for saved game data to include sub-items on sector objects

update #27
  • Loading branch information
chessmaster42 committed Jun 11, 2014
1 parent 6b6393c commit 374ec88
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 14 deletions.
7 changes: 4 additions & 3 deletions SEConfigTool/SEConfigTool.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 50 additions & 5 deletions SEConfigTool/SEConfigTool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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<MyObjectBuilder_EntityBase> unknown in save.UnknownObjects)
{
float x = unknown.PositionAndOrientation.Position.x;
Expand All @@ -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()
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
Expand Down
68 changes: 65 additions & 3 deletions SEModAPI/API/SaveData/CubeBlock.cs
Original file line number Diff line number Diff line change
@@ -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<MyObjectBuilder_CubeBlock>
{
#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
}
}
19 changes: 16 additions & 3 deletions SEModAPI/API/SaveData/CubeGrid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ namespace SEModAPI.API.SaveData
{
public class CubeGrid : SectorObject<MyObjectBuilder_CubeGrid>
{
#region "Attributes"

private List<CubeBlock> 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<CubeBlock>();
foreach (MyObjectBuilder_CubeBlock cubeBlock in definition.CubeBlocks)
{
m_cubeBlocks.Add(new CubeBlock(cubeBlock));
}
}

#endregion

Expand Down Expand Up @@ -64,9 +77,9 @@ public VRageMath.Vector3 AngularVelocity
}
}

public List<MyObjectBuilder_CubeBlock> CubeBlocks
public List<CubeBlock> CubeBlocks
{
get { return m_baseDefinition.CubeBlocks; }
get { return m_cubeBlocks; }
}

public List<BoneInfo> Skeleton
Expand Down

0 comments on commit 374ec88

Please sign in to comment.