Skip to content

Commit

Permalink
Changed lists of level entries to a new class called ListCollection. …
Browse files Browse the repository at this point in the history
…Added error handling of pak files which have been renamed or are not level packs.
  • Loading branch information
IntelOrca committed Aug 8, 2011
1 parent 1eff4ae commit 42bde4c
Show file tree
Hide file tree
Showing 13 changed files with 182 additions and 707 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;
using IntelOrca.PeggleEdit.Designer.Properties;
using IntelOrca.PeggleEdit.Tools.Levels;
using IntelOrca.PeggleEdit.Tools.Levels.Children;

namespace IntelOrca.PeggleEdit.Designer
Expand All @@ -32,8 +33,8 @@ class EntryListToolWindow : Form
ListBox mList;
bool mSuspendChangeEvent;

List<LevelEntry> mEntries = new List<LevelEntry>();
List<LevelEntry> mSelectedEntries = new List<LevelEntry>();
LevelEntryCollection mEntries = new LevelEntryCollection();
LevelEntryCollection mSelectedEntries = new LevelEntryCollection();

public EntryListToolWindow(MainMDIForm parent)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ private void duplicateAndPhaseRibbonButton_Click(object sender, EventArgs e)
return;

//Check if there is only one peg selected
List<LevelEntry> objs = LevelEditor.GetSelectedObjects();
LevelEntryCollection objs = LevelEditor.GetSelectedObjects();
if (objs.Count != 1) {
MessageBox.Show("You must have only one movement peg selected.");
return;
Expand Down Expand Up @@ -991,7 +991,7 @@ private void duplicateAndPhaseRibbonButton_Click(object sender, EventArgs e)
return;
}

List<LevelEntry> entries = new List<LevelEntry>();
LevelEntryCollection entries = new LevelEntryCollection();
entries.Add((LevelEntry)objs[0]);

//Duplicate the peg
Expand Down
48 changes: 24 additions & 24 deletions src/IntelOrca.PeggleEdit.Designer/Level Editor/LevelEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class LevelEditor : Control

private Stack<LevelEntry[]> mHistory = new Stack<LevelEntry[]>();

private List<LevelEntry> mOldSelectedEntries = new List<LevelEntry>();
private List<LevelEntry> mSelectedEntries = new List<LevelEntry>();
private LevelEntryCollection mOldSelectedEntries = new LevelEntryCollection();
private LevelEntryCollection mSelectedEntries = new LevelEntryCollection();
private List<PointF> mObjectPoints = new List<PointF>();

private List<LevelEntry> mCopiedEntries = new List<LevelEntry>();
private LevelEntryCollection mCopiedEntries = new LevelEntryCollection();

public event EventHandler UpdatedRedrawed;
public event EventHandler SelectionChanged;
Expand All @@ -53,9 +53,9 @@ public LevelEditor()

#region Editing and Selecting

public List<LevelEntry> GetSelectedObjectsInZOrder()
public LevelEntryCollection GetSelectedObjectsInZOrder()
{
List<LevelEntry> objects = new List<LevelEntry>();
LevelEntryCollection objects = new LevelEntryCollection();
foreach (LevelEntry le in Level.Entries) {
if (!mSelectedEntries.Contains(le))
continue;
Expand All @@ -66,9 +66,9 @@ public List<LevelEntry> GetSelectedObjectsInZOrder()
return objects;
}

public List<LevelEntry> GetSelectedObjects()
public LevelEntryCollection GetSelectedObjects()
{
List<LevelEntry> objects = new List<LevelEntry>();
LevelEntryCollection objects = new LevelEntryCollection();
foreach (LevelEntry le in mSelectedEntries) {
objects.Add(le);
}
Expand All @@ -78,7 +78,7 @@ public List<LevelEntry> GetSelectedObjects()

public void CreateUndoPoint()
{
List<LevelEntry> copies = new List<LevelEntry>();
LevelEntryCollection copies = new LevelEntryCollection();
foreach (LevelEntry le in mLevel.Entries) {
copies.Add((LevelEntry)le.Clone());
}
Expand Down Expand Up @@ -278,7 +278,7 @@ public void PasteObjects()
public void MoveObjects(float x, float y)
{
if (x != 0 || y != 0) {
List<LevelEntry> LevelObjects = GetSelectedObjects();
LevelEntryCollection LevelObjects = GetSelectedObjects();

if (LevelObjects.Count == 0)
return;
Expand All @@ -302,7 +302,7 @@ public bool AreSelectedObjectsBricksWithSameGeometry()
RectangleF threshold = RectangleF.Empty;
float threshold_value = 4.0f;

List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();
foreach (LevelEntry le in objects) {
Brick b = le as Brick;
if (b == null)
Expand All @@ -324,7 +324,7 @@ public bool AreSelectedObjectsBricksWithSameGeometry()

public void RotateBricks(float angle)
{
List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();
if (objects.Count == 0)
return;

Expand Down Expand Up @@ -362,7 +362,7 @@ public void RotateObjects(float angle)
return;
}

List<LevelEntry> objects = new List<LevelEntry>(GetSelectedObjects());
LevelEntryCollection objects = new LevelEntryCollection(GetSelectedObjects());
if (objects.Count == 1) {
if (objects[0] is Brick) {
CreateUndoPoint();
Expand Down Expand Up @@ -422,7 +422,7 @@ public void FlipObjectsHorizontally()
{
CreateUndoPoint();

List<LevelEntry> objects = new List<LevelEntry>(GetSelectedObjects());
LevelEntryCollection objects = new LevelEntryCollection(GetSelectedObjects());
if (objects.Count < 2)
return;

Expand Down Expand Up @@ -452,7 +452,7 @@ public void FlipPegsVertically()
{
CreateUndoPoint();

List<LevelEntry> objects = new List<LevelEntry>(GetSelectedObjects());
LevelEntryCollection objects = new LevelEntryCollection(GetSelectedObjects());
if (objects.Count < 2)
return;

Expand All @@ -476,7 +476,7 @@ public void FlipPegsVertically()

public void AlignObjectXs()
{
List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();

if (objects.Count < 2)
return;
Expand All @@ -493,7 +493,7 @@ public void AlignObjectXs()

public void AlignObjectYs()
{
List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();

if (objects.Count < 2)
return;
Expand All @@ -510,7 +510,7 @@ public void AlignObjectYs()

public void SpaceObjectXsEqually()
{
List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();

if (objects.Count < 3)
return;
Expand All @@ -532,7 +532,7 @@ public void SpaceObjectXsEqually()

public void SpaceObjectYsEqually()
{
List<LevelEntry> objects = GetSelectedObjects();
LevelEntryCollection objects = GetSelectedObjects();

if (objects.Count < 3)
return;
Expand All @@ -554,7 +554,7 @@ public void SpaceObjectYsEqually()

public void BringObjectsForward()
{
List<LevelEntry> objs = GetSelectedObjectsInZOrder();
LevelEntryCollection objs = GetSelectedObjectsInZOrder();

foreach (LevelEntry obj in objs) {
int index = mLevel.Entries.IndexOf(obj);
Expand All @@ -579,7 +579,7 @@ public void BringObjectsForward()

public void SendObjectsBackward()
{
List<LevelEntry> objs = GetSelectedObjectsInZOrder();
LevelEntryCollection objs = GetSelectedObjectsInZOrder();

foreach (LevelEntry obj in objs) {
int index = mLevel.Entries.IndexOf(obj);
Expand All @@ -604,7 +604,7 @@ public void SendObjectsBackward()

public void BringObjectsToFront()
{
List<LevelEntry> objs = GetSelectedObjectsInZOrder();
LevelEntryCollection objs = GetSelectedObjectsInZOrder();
//objs.Reverse();

foreach (LevelEntry obj in objs) {
Expand All @@ -621,7 +621,7 @@ public void BringObjectsToFront()
public void SendObjectsToBack()
{
//Reverse the order so that selected objects maintain their inner z order
List<LevelEntry> objs = GetSelectedObjectsInZOrder();
LevelEntryCollection objs = GetSelectedObjectsInZOrder();
objs.Reverse();

foreach (LevelEntry obj in objs) {
Expand Down Expand Up @@ -675,7 +675,7 @@ public void RemoveDuplicateObjects()
public void RemoveOffscreenObjects()
{
bool firstOne = true;
List<LevelEntry> removes = new List<LevelEntry>();
LevelEntryCollection removes = new LevelEntryCollection();
RectangleF insideRect = RectangleF.FromLTRB(-Level.DrawAdjustX, -Level.DrawAdjustY, 800 - Level.DrawAdjustX, 600 - Level.DrawAdjustY);
foreach (LevelEntry o in mLevel.Entries) {
PointF pegPnt = new PointF(o.X, o.Y);
Expand Down Expand Up @@ -929,7 +929,7 @@ public EditorTool SelectedTool

[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public List<LevelEntry> SelectedEntries
public LevelEntryCollection SelectedEntries
{
get
{
Expand Down
Binary file not shown.
Binary file modified src/IntelOrca.PeggleEdit.Designer/Resources/Icons/32/Thumbs.db
Binary file not shown.
Binary file modified src/IntelOrca.PeggleEdit.Designer/Resources/Thumbs.db
Binary file not shown.
148 changes: 0 additions & 148 deletions src/IntelOrca.PeggleEdit.Tools/Files/LevelEditor.cfg

This file was deleted.

Loading

0 comments on commit 42bde4c

Please sign in to comment.