Added code for parsing vertices

Wed, 20 Mar 2013 02:44:21 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 20 Mar 2013 02:44:21 +0200
changeset 42
499c25af0303
parent 41
4ca63da5546b
child 43
85b24285a8c7

Added code for parsing vertices

file.cpp file | annotate | diff | comparison | revisions
gui.cpp file | annotate | diff | comparison | revisions
main.cpp file | annotate | diff | comparison | revisions
zz_addObjectDialog.cpp file | annotate | diff | comparison | revisions
--- a/file.cpp	Wed Mar 20 02:31:36 2013 +0200
+++ b/file.cpp	Wed Mar 20 02:44:21 2013 +0200
@@ -237,8 +237,29 @@
 	case 0:
 		{
 			// Comment
+			str zComment = zLine.substr (2, -1);
+			
+			if (tokens[1] == "!LDFORGE") {
+				// Handle LDForge-specific types, they're embedded into comments
+				
+				if (tokens[2] == "VERTEX") {
+					// Vertex (0 !LDFORGE VERTEX)
+					CHECK_TOKEN_COUNT (7)
+					CHECK_TOKEN_NUMBERS (3, 6)
+					
+					LDVertex* obj = new LDVertex;
+					obj->dColor = atol (tokens[3]);
+					obj->vPosition.x = atof (tokens[4]);
+					obj->vPosition.y = atof (tokens[5]);
+					obj->vPosition.z = atof (tokens[6]);
+					
+					return obj;
+				}
+			}
+				
+			
 			LDComment* obj = new LDComment;
-			obj->zText = zLine.substr (2, -1);
+			obj->zText = zComment;
 			return obj;
 		}
 	
--- a/gui.cpp	Wed Mar 20 02:31:36 2013 +0200
+++ b/gui.cpp	Wed Mar 20 02:44:21 2013 +0200
@@ -249,6 +249,14 @@
 }
 
 void ForgeWindow::slot_save () {
+	if (!~g_CurrentFile->zFileName) {
+		// If we don't have a file name, this is an anonymous file created
+		// with the new file command. We cannot save without a name so ask
+		// the user for one.
+		slot_saveAs ();
+		return;
+	}
+	
 	g_CurrentFile->save ();
 }
 
--- a/main.cpp	Wed Mar 20 02:31:36 2013 +0200
+++ b/main.cpp	Wed Mar 20 02:44:21 2013 +0200
@@ -45,6 +45,8 @@
 	g_qMainApp = &app;
 	g_qWindow = win;
 	
+	newFile ();
+	
 	win->show ();
 	return app.exec ();
 }
--- a/zz_addObjectDialog.cpp	Wed Mar 20 02:31:36 2013 +0200
+++ b/zz_addObjectDialog.cpp	Wed Mar 20 02:44:21 2013 +0200
@@ -35,9 +35,10 @@
 	QDialog (parent)
 {
 	short dCoordCount = 0;
+	str zIconName = str::mkfmt ("icons/add-%s.png", g_saObjTypeIcons[type]);
 	
 	qTypeIcon = new QLabel;
-	qTypeIcon->setPixmap (QPixmap (g_saObjTypeIcons[type]));
+	qTypeIcon->setPixmap (QPixmap (zIconName.chars ()));
 	
 	switch (type) {
 	case OBJ_Comment:
@@ -93,7 +94,7 @@
 	setWindowTitle (str::mkfmt (APPNAME_DISPLAY " - new %s",
 		g_saObjTypeNames[type]).chars());
 	
-	setWindowIcon (QIcon (str::mkfmt ("icons/add-%s.png", g_saObjTypeIcons[type]).chars ()));
+	setWindowIcon (QIcon (zIconName.chars ()));
 }
 
 // =============================================================================

mercurial