src/main.cpp

changeset 493
16766ac1bbd9
parent 469
f2faed654633
child 497
c51941e590b6
--- a/src/main.cpp	Thu Oct 03 18:07:06 2013 +0300
+++ b/src/main.cpp	Thu Oct 03 20:56:20 2013 +0300
@@ -32,92 +32,96 @@
 #include "configDialog.h"
 
 List<LDFile*> g_loadedFiles;
-ForgeWindow* g_win = null; 
+ForgeWindow* g_win = null;
 const QApplication* g_app = null;
 File g_file_stdout (stdout, File::Write);
 File g_file_stderr (stderr, File::Write);
 static str g_versionString, g_fullVersionString;
 
 const vertex g_origin (0.0f, 0.0f, 0.0f);
-const matrix g_identity ({1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
+const matrix g_identity ( {1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f});
 
 cfg (Bool, firststart, true);
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-int main (int argc, char* argv[]) {
-	QApplication app (argc, argv);
+int main (int argc, char* argv[])
+{	QApplication app (argc, argv);
 	app.setOrganizationName (APPNAME);
 	app.setApplicationName (APPNAME);
-	
+
 	g_app = &app;
 	LDFile::setCurrent (null);
-	
+
 	// Load or create the configuration
-	if (!Config::load()) {
-		print ("Creating configuration file...\n");
+	if (!Config::load())
+	{	print ("Creating configuration file...\n");
+
 		if (Config::save())
 			print ("Configuration file successfully created.\n");
 		else
 			print ("failed to create configuration file!\n");
 	}
-	
+
 	LDPaths::initPaths();
 	initColors();
 	loadLogoedStuds();
-	
+
 	ForgeWindow* win = new ForgeWindow;
 	newFile();
 	win->show();
-	
+
 	// If this is the first start, get the user to configuration. Especially point
 	// them to the profile tab, it's the most important form to fill in.
-	if (firststart) {
-		(new ConfigDialog (ConfigDialog::ProfileTab))->exec();
+	if (firststart)
+	{	(new ConfigDialog (ConfigDialog::ProfileTab))->exec();
 		firststart = false;
 		Config::save();
 	}
-	
+
 	loadPrimitives();
 	return app.exec();
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void doPrint (File& f, initlist<StringFormatArg> args) {
-	str msg = DoFormat (args);
+void doPrint (File& f, initlist<StringFormatArg> args)
+{	str msg = DoFormat (args);
 	f.write (msg.toUtf8());
 	f.flush();
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void doPrint (FILE* fp, initlist<StringFormatArg> args) {
-	if (fp == stdout)
+void doPrint (FILE* fp, initlist<StringFormatArg> args)
+{	if (fp == stdout)
 		doPrint (g_file_stdout, args);
+
 	elif (fp == stderr)
-		doPrint (g_file_stderr, args);
+	doPrint (g_file_stderr, args);
 	else
 		fatal ("unknown FILE* argument");
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-str versionString() {
-	if (g_versionString.length() == 0) {
+str versionString()
+{	if (g_versionString.length() == 0)
+	{
 #if VERSION_PATCH == 0
 		g_versionString = fmt ("%1.%2", VERSION_MAJOR, VERSION_MINOR);
 #else
 		g_versionString = fmt ("%1.%2.%3", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
 #endif // VERSION_PATCH
 	}
-	
+
 	return g_versionString;
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-str versionMoniker() {
+str versionMoniker()
+{
 #if BUILD_ID == BUILD_INTERNAL
 	return "Internal";
 #elif BUILD_ID == BUILD_ALPHA
@@ -133,15 +137,15 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-str fullVersionString() {
-	return fmt ("v%1 %2", versionString(), versionMoniker());
+str fullVersionString()
+{	return fmt ("v%1 %2", versionString(), versionMoniker());
 }
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-static void bombBox (str msg) {
-	msg.replace ("\n", "<br />");
-	
+static void bombBox (str msg)
+{	msg.replace ("\n", "<br />");
+
 	QMessageBox box (null);
 	const QMessageBox::StandardButton btn = QMessageBox::Close;
 	box.setWindowTitle ("Fatal Error");
@@ -156,22 +160,23 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr) {
-	str errmsg = fmt ("File: %1\nLine: %2:\nFunction %3:\n\nAssertion `%4' failed",
-		file, line, funcname, expr);
-	
+void assertionFailure (const char* file, const ulong line, const char* funcname, const char* expr)
+{	str errmsg = fmt ("File: %1\nLine: %2:\nFunction %3:\n\nAssertion `%4' failed",
+					  file, line, funcname, expr);
+
 #if BUILD_ID == BUILD_INTERNAL
 	errmsg += ", aborting.";
 #else
 	errmsg += ".";
 #endif
-	
+
 	printf ("%s\n", errmsg.toStdString().c_str());
-	
+
 #if BUILD_ID == BUILD_INTERNAL
+
 	if (g_win)
 		g_win->deleteLater();
-	
+
 	bombBox (errmsg);
 	abort();
 #endif
@@ -179,15 +184,15 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
-void fatalError (const char* file, const ulong line, const char* funcname, str msg) {
-	str errmsg = fmt ("Aborting over a call to fatal():\nFile: %1\nLine: %2\nFunction: %3\n\n%4",
-		file, line, funcname, msg);
-	
+void fatalError (const char* file, const ulong line, const char* funcname, str msg)
+{	str errmsg = fmt ("Aborting over a call to fatal():\nFile: %1\nLine: %2\nFunction: %3\n\n%4",
+					  file, line, funcname, msg);
+
 	print ("%1\n", errmsg);
-	
+
 	if (g_win)
 		g_win->deleteLater();
-	
+
 	bombBox (errmsg);
 	abort();
-}
\ No newline at end of file
+}

mercurial