# HG changeset patch # User Santeri Piippo # Date 1363740261 -7200 # Node ID 499c25af03030db3fe96e533a7fee65d44547182 # Parent 4ca63da5546b1f58507165688190acfadd42a806 Added code for parsing vertices diff -r 4ca63da5546b -r 499c25af0303 file.cpp --- 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; } diff -r 4ca63da5546b -r 499c25af0303 gui.cpp --- 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 (); } diff -r 4ca63da5546b -r 499c25af0303 main.cpp --- 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 (); } diff -r 4ca63da5546b -r 499c25af0303 zz_addObjectDialog.cpp --- 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 ())); } // =============================================================================