Added new subfile dialog

Fri, 26 Apr 2013 03:27:56 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Fri, 26 Apr 2013 03:27:56 +0300
changeset 138
d22d5c1d9e8a
parent 137
2b8b63be67fb
child 139
5e31a96adaa2

Added new subfile dialog

colors.cpp file | annotate | diff | comparison | revisions
colors.h file | annotate | diff | comparison | revisions
file.h file | annotate | diff | comparison | revisions
gui.cpp file | annotate | diff | comparison | revisions
gui_actions.cpp file | annotate | diff | comparison | revisions
ldtypes.cpp file | annotate | diff | comparison | revisions
ldtypes.h file | annotate | diff | comparison | revisions
misc.cpp file | annotate | diff | comparison | revisions
misc.h file | annotate | diff | comparison | revisions
zz_addObjectDialog.cpp file | annotate | diff | comparison | revisions
zz_addObjectDialog.h file | annotate | diff | comparison | revisions
--- a/colors.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/colors.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -85,6 +85,13 @@
 }
 
 // =============================================================================
+uchar luma (QColor& col) {
+	return (0.2126f * col.red ()) +
+		(0.7152f * col.green ()) +
+		(0.0722f * col.blue ());
+}
+
+// =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 void parseLDConfig () {
--- a/colors.h	Thu Apr 25 04:12:28 2013 +0300
+++ b/colors.h	Fri Apr 26 03:27:56 2013 +0300
@@ -40,6 +40,7 @@
 
 void initColors ();
 void parseLDConfig ();
+uchar luma (QColor& col);
 
 // Safely gets a color with the given number or null if no such color.
 color* getColor (short dColorNum);
--- a/file.h	Thu Apr 25 04:12:28 2013 +0300
+++ b/file.h	Fri Apr 26 03:27:56 2013 +0300
@@ -100,5 +100,6 @@
 void initPartList ();
 
 extern vector<OpenFile*> g_LoadedFiles;
+extern vector<partListEntry> g_PartList;
 
 #endif // FILE_H
\ No newline at end of file
--- a/gui.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/gui.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -164,7 +164,6 @@
 	
 	// things not implemented yet
 	QAction* const qaDisabledActions[] = {
-		ACTION (newSubfile),
 		ACTION (help),
 	};
 	
--- a/gui_actions.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/gui_actions.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -119,7 +119,7 @@
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 MAKE_ACTION (newSubfile, "New Subfile", "add-subfile", "Creates a new subfile reference.", 0) {
-	
+	AddObjectDialog::staticDialog (OBJ_Subfile, g_ForgeWindow);
 }
 
 MAKE_ACTION (newLine, "New Line",  "add-line", "Creates a new line.", 0) {
--- a/ldtypes.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/ldtypes.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -705,4 +705,26 @@
 	
 	// Stick them all together and return the result.
 	return format ("%s%s%s%s", zPrefix.chars(), zFrac.chars (), zRoot.chars (), zRingNum.chars ());
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
+#define CHECK_FOR_OBJ(N) \
+	if (type == OBJ_##N) \
+		return new LD##N;
+LDObject* LDObject::getDefault (const LDObjectType_e type) {
+	CHECK_FOR_OBJ (Comment)
+	CHECK_FOR_OBJ (BFC)
+	CHECK_FOR_OBJ (Line)
+	CHECK_FOR_OBJ (CondLine)
+	CHECK_FOR_OBJ (Radial)
+	CHECK_FOR_OBJ (Subfile)
+	CHECK_FOR_OBJ (Triangle)
+	CHECK_FOR_OBJ (Quad)
+	CHECK_FOR_OBJ (Empty)
+	CHECK_FOR_OBJ (BFC)
+	CHECK_FOR_OBJ (Gibberish)
+	CHECK_FOR_OBJ (Vertex)
+	return null;
 }
\ No newline at end of file
--- a/ldtypes.h	Thu Apr 25 04:12:28 2013 +0300
+++ b/ldtypes.h	Fri Apr 26 03:27:56 2013 +0300
@@ -33,7 +33,9 @@
 		return new LD##T (*this); \
 	} \
 	virtual void move (vertex vVector); \
-	virtual short vertices () const { return NUMVERTS; }
+	virtual short vertices () const { return NUMVERTS; } \
+
+#define LDOBJ_COLORED(V) virtual bool isColored () const { return V; }
 
 class QTreeWidgetItem;
 class LDSubfile;
@@ -117,7 +119,17 @@
 	LDObject* topLevelParent ();
 	
 	// Number of vertices this object has
-	virtual short vertices () const { return 0; }
+	virtual short vertices () const {
+		return 0;
+	}
+	
+	// Is this object colored?
+	virtual bool isColored () const {
+		return false;
+	}
+	
+	// Returns a sample object by the given value
+	static LDObject* getDefault (const LDObjectType_e type);
 	
 	static void moveObjects (std::vector<LDObject*> objs, const bool bUp);
 	static str objectListContents (const std::vector<LDObject*>& objs);
@@ -136,6 +148,7 @@
 class LDGibberish : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Gibberish, 0)
+	LDOBJ_COLORED (false)
 	
 	LDGibberish (str _zContent, str _zReason);
 	
@@ -154,6 +167,7 @@
 class LDEmpty : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Empty, 0)
+	LDOBJ_COLORED (false)
 };
 
 // =============================================================================
@@ -165,6 +179,8 @@
 class LDComment : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Comment, 0)
+	LDOBJ_COLORED (false)
+	
 	LDComment (str zText) : zText (zText) {}
 	
 	str zText; // The text of this comment
@@ -189,6 +205,8 @@
 	};
 	
 	IMPLEMENT_LDTYPE (BFC, 0)
+	LDOBJ_COLORED (false)
+	
 	LDBFC (const LDBFC::Type eType) : eStatement (eType) {}
 	
 	// Statement strings
@@ -205,6 +223,7 @@
 class LDSubfile : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Subfile, 0)
+	LDOBJ_COLORED (true)
 	
 	vertex vPosition; // Position of the subpart
 	matrix mMatrix; // Transformation matrix for the subpart
@@ -225,6 +244,8 @@
 class LDLine : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Line, 2)
+	LDOBJ_COLORED (true)
+	
 	LDLine (vertex v1, vertex v2);
 };
 
@@ -237,6 +258,7 @@
 class LDCondLine : public LDLine {
 public:
 	IMPLEMENT_LDTYPE (CondLine, 4)
+	LDOBJ_COLORED (true)
 };
 
 // =============================================================================
@@ -249,6 +271,7 @@
 class LDTriangle : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Triangle, 3)
+	LDOBJ_COLORED (true)
 	
 	LDTriangle (vertex _v0, vertex _v1, vertex _v2) {
 		vaCoords[0] = _v0;
@@ -266,6 +289,7 @@
 class LDQuad : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Quad, 4)
+	LDOBJ_COLORED (true)
 	
 	// Split this quad into two triangles
 	vector<LDTriangle*> splitToTriangles ();
@@ -282,6 +306,7 @@
 class LDVertex : public LDObject {
 public:
 	IMPLEMENT_LDTYPE (Vertex, 0) // TODO: move vPosition to vaCoords[0]
+	LDOBJ_COLORED (true)
 	
 	vertex vPosition;
 };
@@ -308,6 +333,7 @@
 	};
 	
 	IMPLEMENT_LDTYPE (Radial, 0)
+	LDOBJ_COLORED (true)
 	
 	LDRadial::Type eRadialType;
 	vertex vPosition;
--- a/misc.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/misc.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -182,13 +182,6 @@
 }
 
 // =============================================================================
-uchar luma (QColor& col) {
-	return (0.2126f * col.red ()) +
-		(0.7152f * col.green ()) +
-		(0.0722f * col.blue ());
-}
-
-// =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 StringParser::StringParser (str zInText, char cSeparator) {
--- a/misc.h	Thu Apr 25 04:12:28 2013 +0300
+++ b/misc.h	Fri Apr 26 03:27:56 2013 +0300
@@ -72,8 +72,6 @@
 	b = c;
 }
 
-uchar luma (QColor& col);
-
 // =============================================================================
 // StringParser
 //
--- a/zz_addObjectDialog.cpp	Thu Apr 25 04:12:28 2013 +0300
+++ b/zz_addObjectDialog.cpp	Fri Apr 26 03:27:56 2013 +0300
@@ -28,46 +28,105 @@
 
 #define APPLY_COORDS(OBJ, N) \
 	for (short i = 0; i < N; ++i) { \
-		OBJ->vaCoords[i].x = dlg.qaCoordinates[(i * 3) + 0]->value (); \
-		OBJ->vaCoords[i].y = dlg.qaCoordinates[(i * 3) + 1]->value (); \
-		OBJ->vaCoords[i].z = dlg.qaCoordinates[(i * 3) + 2]->value (); \
+		OBJ->vaCoords[i].x = dlg.dsb_coords[(i * 3) + 0]->value (); \
+		OBJ->vaCoords[i].y = dlg.dsb_coords[(i * 3) + 1]->value (); \
+		OBJ->vaCoords[i].z = dlg.dsb_coords[(i * 3) + 2]->value (); \
 	}
 
 // =============================================================================
+class SubfileListItem : public QTreeWidgetItem {
+public:
+	SubfileListItem (QTreeWidgetItem* parent, int subfileID) :
+		QTreeWidgetItem (parent), subfileID (subfileID) {}
+	SubfileListItem (QTreeWidget* parent, int subfileID) :
+		QTreeWidgetItem (parent), subfileID (subfileID) {}
+	
+	int subfileID;
+};
+
+// =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
 AddObjectDialog::AddObjectDialog (const LDObjectType_e type, QWidget* parent) :
 	QDialog (parent)
 {
-	short dCoordCount = 0;
-	str zIconName = format ("icons/add-%s.png", g_saObjTypeIcons[type]);
+	short coordCount = 0;
+	str iconName = format ("icons/add-%s.png", g_saObjTypeIcons[type]);
+	LDObject* defaults = LDObject::getDefault (type);
 	
-	qTypeIcon = new QLabel;
-	qTypeIcon->setPixmap (QPixmap (zIconName.chars ()));
+	lb_typeIcon = new QLabel;
+	lb_typeIcon->setPixmap (QPixmap (iconName.chars ()));
 	
 	switch (type) {
 	case OBJ_Comment:
-		qCommentLine = new QLineEdit;
+		le_comment = new QLineEdit;
 		break;
 	
 	case OBJ_Line:
-		dCoordCount = 6;
+		coordCount = 6;
 		break;
 	
 	case OBJ_Triangle:
-		dCoordCount = 9;
+		coordCount = 9;
 		break;
 	
 	case OBJ_Quad:
 	case OBJ_CondLine:
-		dCoordCount = 12;
+		coordCount = 12;
 		break;
 	
 	case OBJ_Vertex:
-		dCoordCount = 3;
+		coordCount = 3;
+	
+	case OBJ_Subfile:
+		coordCount = 3;
+		
+		enum {
+			Parts,
+			Subparts,
+			Primitives,
+			HiRes,
+		};
+		
+		tw_subfileList = new QTreeWidget ();
+		for (int i : vector<int> ({Parts, Subparts, Primitives, HiRes})) {
+			SubfileListItem* parentItem = new SubfileListItem (tw_subfileList, -1);
+			parentItem->setText (0, (i == Parts) ? "Parts" :
+				(i == Subparts) ? "Subparts" :
+				(i == Primitives) ? "Primitives" :
+				"Hi-Res");
+			
+			ulong j = 0;
+			for (partListEntry& part : g_PartList) {
+				QList<QTreeWidgetItem*> subfileItems;
+				
+				str fileName = part.sName;
+				const bool isSubpart = fileName.substr (0, 2) == "s\\";
+				const bool isPrimitive = str (part.sTitle).substr (0, 9) == "Primitive";
+				const bool isHiRes = fileName.substr (0, 3) == "48\\";
+				
+				if ((i == Subparts && isSubpart) ||
+					(i == Primitives && isPrimitive) ||
+					(i == HiRes && isHiRes) ||
+					(i == Parts && !isSubpart && !isPrimitive && !isHiRes))
+				{
+					SubfileListItem* item = new SubfileListItem (parentItem, j);
+					item->setText (0, format ("%s - %s", part.sName, part.sTitle));
+					subfileItems.append (item);
+				}
+				
+				j++;
+			}
+			
+			tw_subfileList->addTopLevelItem (parentItem);
+		}
+		
+		connect (tw_subfileList, SIGNAL (itemSelectionChanged ()), this, SLOT (slot_subfileTypeChanged ()));
+		le_subfileName = new QLineEdit ();
+		break;
 	
 	case OBJ_Radial:
-		dCoordCount = 3;
+		coordCount = 3;
 		
 		lb_radType = new QLabel ("Type:");
 		lb_radResolution = new QLabel ("Resolution:");
@@ -77,10 +136,10 @@
 		bb_radType = new ButtonBox<QRadioButton> ("Type", {}, 0, Qt::Vertical);
 		
 		for (int i = 0; i < LDRadial::NumTypes; ++i) {
-			bb_radType->addButton (new QRadioButton (LDRadial::radialTypeName ((LDRadial::Type) i)));
+			if (i % (LDRadial::NumTypes / 2) == 0)
+				bb_radType->rowBreak ();
 			
-			if (i % (LDRadial::NumTypes / 2) == ((LDRadial::NumTypes / 2) - 1))
-				bb_radType->rowBreak ();
+			bb_radType->addButton (new QRadioButton (LDRadial::radialTypeName ((LDRadial::Type) i)));
 		}
 		
 		connect (bb_radType->buttonGroup, SIGNAL (buttonPressed (int)), this, SLOT (slot_radialTypeChanged (int)));
@@ -99,77 +158,66 @@
 	}
 	
 	// Show a color edit dialog for the types that actually use the color
-	bool bUsesColor = false;
-	switch (type) {
-	case OBJ_CondLine:
-	case OBJ_Line:
-	case OBJ_Quad:
-	case OBJ_Triangle:
-	case OBJ_Vertex:
-	case OBJ_Subfile:
-	case OBJ_Radial:
-		bUsesColor = true;
-		break;
-	default:
-		break;
+	if (defaults->isColored ()) {
+		dColor = (type == OBJ_CondLine || type == OBJ_Line) ? dEdgeColor : dMainColor;
+		
+		pb_color = new QPushButton;
+		setButtonBackground (pb_color, dColor);
+		connect (pb_color, SIGNAL (clicked ()), this, SLOT (slot_colorButtonClicked ()));
 	}
 	
-	if (bUsesColor) {
-		dColor = (type == OBJ_CondLine || type == OBJ_Line) ? dEdgeColor : dMainColor;
-		
-		qColorButton = new QPushButton;
-		setButtonBackground (qColorButton, dColor);
-		connect (qColorButton, SIGNAL (clicked ()), this, SLOT (slot_colorButtonClicked ()));
-	}
-	
-	for (short i = 0; i < dCoordCount; ++i) {
-		qaCoordinates[i] = new QDoubleSpinBox;
-		qaCoordinates[i]->setMaximumWidth (96);
-		qaCoordinates[i]->setMinimum (-fMaxCoord);
-		qaCoordinates[i]->setMaximum (fMaxCoord);
+	for (short i = 0; i < coordCount; ++i) {
+		dsb_coords[i] = new QDoubleSpinBox;
+		dsb_coords[i]->setMinimum (-fMaxCoord);
+		dsb_coords[i]->setMaximum (fMaxCoord);
 	}
 	
 	IMPLEMENT_DIALOG_BUTTONS
 	
-	QGridLayout* const qLayout = new QGridLayout;
-	qLayout->addWidget (qTypeIcon, 0, 0);
+	QGridLayout* const layout = new QGridLayout;
+	layout->addWidget (lb_typeIcon, 0, 0);
 	
 	switch (type) {
 	case OBJ_Comment:
-		qLayout->addWidget (qCommentLine, 0, 1);
+		layout->addWidget (le_comment, 0, 1);
 		break;
 	
 	case OBJ_Radial:
-		qLayout->addWidget (bb_radType, 1, 1, 3, 1);
-		qLayout->addWidget (cb_radHiRes, 1, 2);
-		qLayout->addWidget (lb_radSegments, 2, 2);
-		qLayout->addWidget (sb_radSegments, 2, 3);
-		qLayout->addWidget (lb_radRingNum, 3, 2);
-		qLayout->addWidget (sb_radRingNum, 3, 3);
+		layout->addWidget (bb_radType, 1, 1, 3, 1);
+		layout->addWidget (cb_radHiRes, 1, 2);
+		layout->addWidget (lb_radSegments, 2, 2);
+		layout->addWidget (sb_radSegments, 2, 3);
+		layout->addWidget (lb_radRingNum, 3, 2);
+		layout->addWidget (sb_radRingNum, 3, 3);
 		break;
 	
+	case OBJ_Subfile:
+		layout->addWidget (tw_subfileList, 1, 1);
+		layout->addWidget (le_subfileName, 2, 1);
+	
 	default:
 		break;
 	}
 	
-	if (bUsesColor)
-		qLayout->addWidget (qColorButton, 1, 0);
+	if (defaults->isColored ())
+		layout->addWidget (pb_color, 1, 0);
 	
-	if (dCoordCount > 0) {
+	if (coordCount > 0) {
 		QGridLayout* const qCoordLayout = new QGridLayout;
 		
-		for (short i = 0; i < dCoordCount; ++i)
-			qCoordLayout->addWidget (qaCoordinates[i], (i / 3), (i % 3));
+		for (short i = 0; i < coordCount; ++i)
+			qCoordLayout->addWidget (dsb_coords[i], (i / 3), (i % 3));
 		
-		qLayout->addLayout (qCoordLayout, 0, 1, (dCoordCount / 3), 3);
+		layout->addLayout (qCoordLayout, 0, 1, (coordCount / 3), 3);
 	}
 	
-	qLayout->addWidget (bbx_buttons, 5, 0, 1, 4);
-	setLayout (qLayout);
+	layout->addWidget (bbx_buttons, 5, 0, 1, 4);
+	setLayout (layout);
 	setWindowTitle (format (APPNAME_DISPLAY " - new %s",
 		g_saObjTypeNames[type]).chars());
 	
-	setWindowIcon (QIcon (zIconName.chars ()));
+	setWindowIcon (QIcon (iconName.chars ()));
+	delete defaults;
 }
 
 // =============================================================================
@@ -186,9 +234,21 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
+char* AddObjectDialog::currentSubfileName() {
+	SubfileListItem* item = static_cast<SubfileListItem*> (tw_subfileList->currentItem ());
+	
+	if (item->subfileID == -1)
+		return null; // selected a heading
+	
+	return g_PartList[item->subfileID].sName;
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
 void AddObjectDialog::slot_colorButtonClicked () {
 	ColorSelectDialog::staticDialog (dColor, dColor, this);
-	setButtonBackground (qColorButton, dColor);
+	setButtonBackground (pb_color, dColor);
 }
 
 // =============================================================================
@@ -202,86 +262,116 @@
 // =============================================================================
 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
 // =============================================================================
+void AddObjectDialog::slot_subfileTypeChanged () {
+	char* name = currentSubfileName ();
+	
+	if (name)
+		le_subfileName->setText (name);
+}
+
+// =============================================================================
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+// =============================================================================
 void AddObjectDialog::staticDialog (const LDObjectType_e type, ForgeWindow* window) {
 	AddObjectDialog dlg (type, window);
 	LDObject* obj = null;
 	
-	if (dlg.exec ()) {
-		switch (type) {
-		case OBJ_Comment:
-			obj = new LDComment (dlg.qCommentLine->text ());
-			break;
-		
-		case OBJ_Line:
-			{
-				LDLine* line = new LDLine;
-				line->dColor = dlg.dColor;
-				APPLY_COORDS (line, 2)
-				obj = line;
-			}
-			break;
-		
-		case OBJ_Triangle:
-			{
-				LDTriangle* tri = new LDTriangle;
-				tri->dColor = dlg.dColor;
-				APPLY_COORDS (tri, 3)
-				obj = tri;
-			}
-			break;
-		
-		case OBJ_Quad:
-			{
-				LDQuad* quad = new LDQuad;
-				quad->dColor = dlg.dColor;
-				APPLY_COORDS (quad, 4)
-				obj = quad;
-			}
-			break;
-		
-		case OBJ_CondLine:
-			{
-				LDCondLine* line = new LDCondLine;
-				line->dColor = dlg.dColor;
-				APPLY_COORDS (line, 4)
-				obj = line;
-			}
-			break;
-		
-		case OBJ_Vertex:
-			{
-				LDVertex* vert = new LDVertex;
-				vert->dColor = dlg.dColor;
-				vert->vPosition.x = dlg.qaCoordinates[0]->value ();
-				vert->vPosition.y = dlg.qaCoordinates[1]->value ();
-				vert->vPosition.z = dlg.qaCoordinates[2]->value ();
-				obj = vert;
-			}
-			break;
-		
-		case OBJ_Radial:
-			{
-				LDRadial* pRad = new LDRadial;
-				pRad->dColor = dlg.dColor;
-				pRad->vPosition.x = dlg.qaCoordinates[0]->value ();
-				pRad->vPosition.y = dlg.qaCoordinates[1]->value ();
-				pRad->vPosition.z = dlg.qaCoordinates[2]->value ();
-				pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48;
-				pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions);
-				pRad->eRadialType = (LDRadial::Type) dlg.bb_radType->value ();
-				pRad->dRingNum = dlg.sb_radRingNum->value ();
-				pRad->mMatrix = g_mIdentity;
-				
-				obj = pRad;
-			}
-			break;
-		
-		default:
-			break;
+	if (dlg.exec () == false)
+		return;
+	
+	switch (type) {
+	case OBJ_Comment:
+		obj = new LDComment (dlg.le_comment->text ());
+		break;
+	
+	case OBJ_Line:
+		{
+			LDLine* line = new LDLine;
+			line->dColor = dlg.dColor;
+			APPLY_COORDS (line, 2)
+			obj = line;
+		}
+		break;
+	
+	case OBJ_Triangle:
+		{
+			LDTriangle* tri = new LDTriangle;
+			tri->dColor = dlg.dColor;
+			APPLY_COORDS (tri, 3)
+			obj = tri;
+		}
+		break;
+	
+	case OBJ_Quad:
+		{
+			LDQuad* quad = new LDQuad;
+			quad->dColor = dlg.dColor;
+			APPLY_COORDS (quad, 4)
+			obj = quad;
+		}
+		break;
+	
+	case OBJ_CondLine:
+		{
+			LDCondLine* line = new LDCondLine;
+			line->dColor = dlg.dColor;
+			APPLY_COORDS (line, 4)
+			obj = line;
 		}
-		
-		ulong idx = g_CurrentFile->addObject (obj);
-		History::addEntry (new AddHistory ({idx}, {obj->clone ()}));
-		window->refresh ();
+		break;
+	
+	case OBJ_Vertex:
+		{
+			LDVertex* vert = new LDVertex;
+			vert->dColor = dlg.dColor;
+			vert->vPosition.x = dlg.dsb_coords[0]->value ();
+			vert->vPosition.y = dlg.dsb_coords[1]->value ();
+			vert->vPosition.z = dlg.dsb_coords[2]->value ();
+			obj = vert;
+		}
+		break;
+	
+	case OBJ_Radial:
+		{
+			LDRadial* pRad = new LDRadial;
+			pRad->dColor = dlg.dColor;
+			pRad->vPosition.x = dlg.dsb_coords[0]->value ();
+			pRad->vPosition.y = dlg.dsb_coords[1]->value ();
+			pRad->vPosition.z = dlg.dsb_coords[2]->value ();
+			pRad->dDivisions = (dlg.cb_radHiRes->checkState () != Qt::Checked) ? 16 : 48;
+			pRad->dSegments = min<short> (dlg.sb_radSegments->value (), pRad->dDivisions);
+			pRad->eRadialType = (LDRadial::Type) dlg.bb_radType->value ();
+			pRad->dRingNum = dlg.sb_radRingNum->value ();
+			pRad->mMatrix = g_mIdentity;
+			
+			obj = pRad;
+		}
+		break;
+	
+	case OBJ_Subfile:
+		{
+			str name = dlg.le_subfileName->text ();
+			if (~name == 0)
+				return; // no subfile filename
+			
+			LDSubfile* ref = new LDSubfile;
+			ref->dColor = dlg.dColor;
+			ref->vPosition.x = dlg.dsb_coords[0]->value ();
+			ref->vPosition.y = dlg.dsb_coords[1]->value ();
+			ref->vPosition.z = dlg.dsb_coords[2]->value ();
+			ref->zFileName = name;
+			ref->mMatrix = g_mIdentity;
+			ref->pFile = loadSubfile (name);
+			
+			obj = ref;
+		}
+		break;
+	
+	default:
+		break;
 	}
+	
+	ulong idx = g_CurrentFile->addObject (obj);
+	History::addEntry (new AddHistory ({idx}, {obj->clone ()}));
+	window->refresh ();
 }
\ No newline at end of file
--- a/zz_addObjectDialog.h	Thu Apr 25 04:12:28 2013 +0300
+++ b/zz_addObjectDialog.h	Fri Apr 26 03:27:56 2013 +0300
@@ -28,6 +28,7 @@
 #include <qspinbox.h>
 #include <qlabel.h>
 #include <qradiobutton.h>
+#include <qlistwidget.h>
 
 class AddObjectDialog : public QDialog {
 	Q_OBJECT
@@ -36,16 +37,20 @@
     AddObjectDialog (const LDObjectType_e type, QWidget* parent = null);
 	static void staticDialog (const LDObjectType_e type, ForgeWindow* window);
 	
-	QLabel* qTypeIcon;
+	QLabel* lb_typeIcon;
 	
 	// -- COMMENT --
-	QLineEdit* qCommentLine;
+	QLineEdit* le_comment;
 	
 	// Coordinate edits for.. anything with coordinates, really.
-	QDoubleSpinBox* qaCoordinates[12];
+	QDoubleSpinBox* dsb_coords[12];
 	
 	// Color selection dialog button
-	QPushButton* qColorButton;
+	QPushButton* pb_color;
+	
+	// Subfile stuff
+	QTreeWidget* tw_subfileList;
+	QLineEdit* le_subfileName;
 	
 	// Radial stuff
 	QCheckBox* cb_radHiRes;
@@ -58,12 +63,14 @@
 	
 private:
 	void setButtonBackground (QPushButton* qButton, short dColor);
+	char* currentSubfileName ();
 	
 	short dColor;
 	
 private slots:
 	void slot_colorButtonClicked ();
 	void slot_radialTypeChanged (int dType);
+	void slot_subfileTypeChanged ();
 };
 
 #endif // ZZ_ADDOBJECTDIALOG_H
\ No newline at end of file

mercurial