main.cpp

Wed, 20 Mar 2013 13:27:43 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Wed, 20 Mar 2013 13:27:43 +0200
changeset 46
69962c85f717
parent 42
499c25af0303
child 48
113eb6446c61
permissions
-rw-r--r--

Finally got the renderer to actually draw something! Still needs a lot of work but at least it doesn't show garbage or blank anymore.

30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
1 /*
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
2 * LDForge: LDraw parts authoring CAD
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
3 * Copyright (C) 2013 Santeri `arezey` Piippo
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
4 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
5 * This program is free software: you can redistribute it and/or modify
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
6 * it under the terms of the GNU General Public License as published by
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
7 * the Free Software Foundation, either version 3 of the License, or
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
8 * (at your option) any later version.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
9 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
10 * This program is distributed in the hope that it will be useful,
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
13 * GNU General Public License for more details.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
14 *
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
15 * You should have received a copy of the GNU General Public License
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
17 */
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
18
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <QApplication>
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
20 #include "gui.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents: 25
diff changeset
21 #include "file.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
22 #include "bbox.h"
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
23 #include "misc.h"
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
24 #include "config.h"
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 vector<OpenFile*> g_LoadedFiles;
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
27 OpenFile* g_CurrentFile = nullptr;
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
28 ForgeWindow* g_qWindow = nullptr;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
29 bbox g_BBox;
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
30 QApplication* g_qMainApp = nullptr;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
32 int main (int dArgC, char* saArgV[]) {
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
33 // Load or create the configuration
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
34 if (!config::load()) {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
35 printf ("Creating configuration file...\n");
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
36 if (config::save ())
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
37 printf ("Configuration file successfully created.\n");
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
38 else
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
39 printf ("failed to create configuration file!\n");
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
40 }
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
25
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
42 QApplication app (dArgC, saArgV);
c74bb88f537d Deleted scanner.cpp (don't need it), merged model.cpp into io.cpp. Renamed LDForgeWindow to just ForgeWindow since I want the LD* prefix only be given to LDObject derivatives.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 23
diff changeset
43 ForgeWindow* win = new ForgeWindow;
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
44
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
45 g_qMainApp = &app;
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
46 g_qWindow = win;
30
31ff9aabd506 Licensed LDForge GPL3, added some more icons
Santeri Piippo <crimsondusk64@gmail.com>
parents: 29
diff changeset
47
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
48 newFile ();
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
49
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
50 win->show ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
51 return app.exec ();
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
52 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
53
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
54 vertex vertex::midpoint (vertex& other) {
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
55 vertex mid;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
56 mid.x = (x + other.x);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
57 mid.y = (y + other.y);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
58 mid.z = (z + other.z);
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
59 return mid;
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
60 }
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
61
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
62 str vertex::getStringRep (const bool bMangled) {
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
63 const char* sFormat = (bMangled) ? "(%s, %s, %s)" : "%s %s %s";
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
64
18
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
65 return str::mkfmt (sFormat,
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
66 ftoa (x).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
67 ftoa (y).chars(),
a6732098fed8 Convert the static getCoordinateRep to a common ftoa, use this function to get proper coordinate representation when converting objects to LDraw code
Santeri Piippo <crimsondusk64@gmail.com>
parents: 13
diff changeset
68 ftoa (z).chars());
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
69 }
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
70
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
71 // =============================================================================
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
72 // void logVA (logtype_e, const char*, va_list) [static]
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
73 //
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
74 // Common code for the two logfs
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
75 // =============================================================================
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
76 static void logVA (logtype_e eType, const char* fmt, va_list va) {
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
77 // Log it to standard output
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
78 vprintf (fmt, va);
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
79
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
80 return;
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
81
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
82 str zText;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
83 char* sBuffer;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
84
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
85 sBuffer = vdynformat (fmt, va, 128);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
86 zText = sBuffer;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
87 delete[] sBuffer;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
88
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
89 // Replace some things out with HTML entities
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
90 zText.replace ("<", "&lt;");
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
91 zText.replace (">", "&gt;");
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
92 zText.replace ("\n", "<br />");
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
93
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
94 str* zpHTML = &g_qWindow->zMessageLogHTML;
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
95
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
96 switch (eType) {
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
97 case LOG_Normal:
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
98 zpHTML->append (zText);
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
99 break;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
100
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
101 case LOG_Error:
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
102 zpHTML->appendformat ("<span style=\"color: #F8F8F8; background-color: #800\"><b>[ERROR]</b> %s</span>",
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
103 zText.chars());
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
104 break;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
105
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
106 case LOG_Info:
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
107 zpHTML->appendformat ("<span style=\"color: #04F\"><b>[INFO]</b> %s</span>",
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
108 zText.chars());
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
109 break;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
110
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
111 case LOG_Success:
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
112 zpHTML->appendformat ("<span style=\"color: #6A0\"><b>[SUCCESS]</b> %s</span>",
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
113 zText.chars());
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
114 break;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
115
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
116 case LOG_Warning:
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
117 zpHTML->appendformat ("<span style=\"color: #C50\"><b>[WARNING]</b> %s</span>",
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
118 zText.chars());
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
119 break;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
120 }
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
121
23
69a91c1ff583 begin work on subfile caching
Santeri Piippo <crimsondusk64@gmail.com>
parents: 18
diff changeset
122 g_qWindow->qMessageLog->setHtml (*zpHTML);
13
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
123 }
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
124
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
125
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
126 // =============================================================================
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
127 // logf (const char*, ...)
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
128 // logf (logtype_e eType, const char*, ...)
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
129 //
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
130 // Outputs a message into the message log
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
131 // =============================================================================
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
132 void logf (const char* fmt, ...) {
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
133 va_list va;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
134
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
135 va_start (va, fmt);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
136 logVA (LOG_Normal, fmt, va);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
137 va_end (va);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
138 }
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
139
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
140 void logf (logtype_e eType, const char* fmt, ...) {
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
141 va_list va;
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
142
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
143 va_start (va, fmt);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
144 logVA (eType, fmt, va);
3955ff2a7d72 Added logf function to write to message log. Write warnings of unparsable files into the message log.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 4
diff changeset
145 va_end (va);
0
c51cce84a9ac Initial commit
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146 }

mercurial