ldtypes.cpp

changeset 96
2f175b3d8211
parent 91
b4dda6348e7e
child 102
cacd4681ccb4
--- a/ldtypes.cpp	Wed Apr 10 16:17:22 2013 +0300
+++ b/ldtypes.cpp	Wed Apr 10 19:26:14 2013 +0300
@@ -22,31 +22,32 @@
 #include "misc.h"
 
 char const* g_saObjTypeNames[] = {
-	"unidentified",
+	"subfile",
+	"quadrilateral",
+	"triangle",
+	"line",
+	"condline",
+	"vertex",
+	"bfc",
+	"comment",
 	"unknown",
 	"empty",
-	"comment",
-	"subfile",
-	"line",
-	"triangle",
-	"quadrilateral",
-	"condline",
-	"bfc",
-	"vertex",
+	"unidentified",
 };
 
+// Should probably get rid of this array sometime
 char const* g_saObjTypeIcons[] = {
-	"error",
+	"subfile",
+	"quad",
+	"triangle",
+	"line",
+	"condline",
+	"vertex",
+	"bfc",
+	"comment",
 	"error",
 	"empty",
-	"comment",
-	"subfile",
-	"line",
-	"triangle",
-	"quad",
-	"condline",
-	"bfc",
-	"vertex",
+	"error",
 };
 
 // =============================================================================
@@ -395,6 +396,9 @@
 	return -1;
 }
 
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
 void LDObject::moveObjects (std::vector<LDObject*> objs, const bool bUp) {
 	// If we move down, we need to iterate the array in reverse order.
 	const long start = bUp ? 0 : (objs.size() - 1);
@@ -419,4 +423,34 @@
 		
 		obj->swap (g_CurrentFile->objects[lTarget]);
 	}
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
+str LDObject::objectListContents (std::vector<LDObject*>& objs) {
+	bool bFirstDetails = true;
+	str zText = "";
+	
+	if (objs.size() == 0)
+		return "nothing"; // :)
+	
+	for (long i = 0; i < NUM_ObjectTypes; ++i) {
+		LDObjectType_e eType = (LDObjectType_e) i;
+		ulong ulCount = 0;
+		
+		for (LDObject* obj : objs)
+			if (obj->getType() == eType)
+				ulCount++;
+		
+		if (ulCount > 0) {
+			if (!bFirstDetails)
+				zText += ", ";
+			
+			zText.appendformat ("%lu %s%s", ulCount, g_saObjTypeNames[eType], PLURAL (ulCount));
+			bFirstDetails = false;
+		}
+	}
+	
+	return zText;
 }
\ No newline at end of file

mercurial