file.cpp

Sat, 20 Apr 2013 04:26:36 +0300

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Sat, 20 Apr 2013 04:26:36 +0300
changeset 119
b93a64f5ee67
parent 117
7eb7a43a511b
child 127
a6e2067bb2f1
permissions
-rw-r--r--

some GUI tweaks

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
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
3 * Copyright (C) 2013 Santeri Piippo
30
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
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
19 #include <vector>
99
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
20 #include <stdio.h>
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
21 #include "common.h"
69
6790dea720a8 Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 66
diff changeset
22 #include "config.h"
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
23 #include "file.h"
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
24 #include "misc.h"
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
25 #include "bbox.h"
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
26 #include "gui.h"
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
27
69
6790dea720a8 Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 66
diff changeset
28 cfg (str, io_ldpath, "");
99
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
29 cfg (str, io_recentfiles, "");
69
6790dea720a8 Simplified configuration code. Use a std::vector object to contain config pointers and have config objects register themselves upon creation instead of relying on a cfgdefs.h. Removed sections, all configurations are just simply written one after another now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 66
diff changeset
30
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
31 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
33 // =============================================================================
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
34 OpenFile* findLoadedFile (str zName) {
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
35 for (OpenFile* file : g_LoadedFiles)
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
36 if (file->zFileName == zName)
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
37 return file;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
38
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
39 return null;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
40 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
41
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
42 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
44 // =============================================================================
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
45 FILE* openLDrawFile (str path, bool bSubDirectories) {
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
46 str zTruePath = path;
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
47
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
48 #ifndef WIN32
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
49 zTruePath.replace ("\\", "/");
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
50 #endif // WIN32
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
51
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
52 FILE* fp = fopen (path.chars (), "r");
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
53 str zFilePath;
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
54
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
55 if (fp != null)
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
56 return fp;
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
57
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
58 if (~io_ldpath.value) {
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
59 // Try with just the LDraw path first
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
60 zFilePath = format ("%s" DIRSLASH "%s",
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
61 io_ldpath.value.chars(), zTruePath.chars());
117
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
62 logf ("Trying %s\n", zFilePath.chars());
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
63
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
64 fp = fopen (zFilePath, "r");
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
65 if (fp != null)
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
66 return fp;
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
67
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
68 if (bSubDirectories) {
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
69 char const* saSubdirectories[] = {
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
70 "parts",
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
71 "p",
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
72 };
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
73
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
74 for (char const* sSubdir : saSubdirectories) {
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
75 zFilePath = format ("%s" DIRSLASH "%s" DIRSLASH "%s",
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
76 io_ldpath.value.chars(), sSubdir, zTruePath.chars());
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
77 printf ("try %s\n", zFilePath.chars());
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
78
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
79 fp = fopen (zFilePath.chars (), "r");
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
80
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
81 if (fp)
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
82 return fp;
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
83 }
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
84 }
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
85 }
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
86
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
87 return null;
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
88 }
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
89
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
90 // =============================================================================
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
92 // =============================================================================
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
93 OpenFile* openDATFile (str path) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
94 logf ("Opening %s...\n", path.chars());
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
95
66
12aca5d5a51e Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
96 // Convert the file name to lowercase since some parts contain uppercase
12aca5d5a51e Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
97 // file names. I'll assume here that the library will always use lowercase
12aca5d5a51e Restructured inlining to use a proper caching.. one cache per sub-file reference? What was I thinking? *whacks self with a 55295.dat*
Santeri Piippo <crimsondusk64@gmail.com>
parents: 65
diff changeset
98 // file names for the actual parts..
72
5755c02d89f0 Added LDConfig.ldr parsing. All colors now available as long as LDConfig.ldr is provided.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 71
diff changeset
99 FILE* fp = openLDrawFile (-path, true);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
100
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
101 if (!fp) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
102 logf (LOG_Error, "Couldn't open %s: %s\n", path.chars (), strerror (errno));
104
6e29bb0e83c5 GL picking stuff
Santeri Piippo <crimsondusk64@gmail.com>
parents: 99
diff changeset
103 return null;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
104 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
105
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
106 OpenFile* load = new OpenFile;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
107 ulong numWarnings = 0;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
108
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
109 load->zFileName = path;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
110
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
111 vector<str> lines;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
112
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
113 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
114 char line[1024];
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
115 while (fgets (line, sizeof line, fp)) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
116 // Trim the trailing newline
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
117 str zLine = line;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
118 while (zLine[~zLine - 1] == '\n' || zLine[~zLine - 1] == '\r')
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
119 zLine -= 1;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
120
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
121 lines.push_back (zLine);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
122 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
123 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
124
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
125 fclose (fp);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
126
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
127 for (str line : lines) {
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
128 LDObject* obj = parseLine (line);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
129 load->objects.push_back (obj);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
130
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
131 // Check for parse errors and warn about tthem
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
132 if (obj->getType() == OBJ_Gibberish) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
133 logf (LOG_Warning, "Couldn't parse line #%lu: %s\n",
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
134 (&line - &(lines[0])),
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
135 static_cast<LDGibberish*> (obj)->zReason.chars());
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
136
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
137 logf (LOG_Warning, "- Line was: %s\n", line.chars());
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
138 numWarnings++;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
139 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
140 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
141
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
142 g_LoadedFiles.push_back (load);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
143
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
144 logf (LOG_Success, "File %s parsed successfully (%lu warning%s).\n",
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
145 path.chars(), numWarnings, PLURAL (numWarnings));
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
146
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
147 return load;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
148 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
149
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
150 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
152 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
153 // Clear everything from the model
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
154 void OpenFile::close () {
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
155 for (LDObject* obj : objects)
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
156 delete obj;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
157
71
c9f02d2dd9eb Draw main color in the selection dialog based on preferences, take subfiles into account when calculating bbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
158 // Clear the cache as well
c9f02d2dd9eb Draw main color in the selection dialog based on preferences, take subfiles into account when calculating bbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
159 for (LDObject* obj : objCache)
c9f02d2dd9eb Draw main color in the selection dialog based on preferences, take subfiles into account when calculating bbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
160 delete obj;
c9f02d2dd9eb Draw main color in the selection dialog based on preferences, take subfiles into account when calculating bbox
Santeri Piippo <crimsondusk64@gmail.com>
parents: 70
diff changeset
161
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
162 delete this;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
163 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
164
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
165 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
167 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
168 void closeAll () {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
169 if (!g_LoadedFiles.size())
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
170 return;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
171
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
172 // Remove all loaded files and the objects they contain
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
173 for (OpenFile* file : g_LoadedFiles)
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
174 file->close ();
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
175
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
176 // Clear the array
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
177 g_LoadedFiles.clear();
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
178 g_CurrentFile = NULL;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
179
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
180 g_ForgeWindow->refresh ();
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
181 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
182
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
183 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
184 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
185 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
186 void newFile () {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
187 // Create a new anonymous file and set it to our current
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
188 closeAll ();
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
189
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
190 OpenFile* f = new OpenFile;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
191 f->zFileName = "";
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
192 g_LoadedFiles.push_back (f);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
193 g_CurrentFile = f;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
194
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
195 g_BBox.calculate();
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
196 g_ForgeWindow->refresh ();
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
197 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
198
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
199 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
201 // =============================================================================
99
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
202 void addRecentFile (str zPath) {
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
203 long lPos = io_recentfiles.value.first (zPath);
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
204
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
205 // If this file already is in the list, pop it out.
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
206 if (lPos != -1) {
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
207 if (~io_recentfiles.value == ~zPath)
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
208 return; // only recent file - do nothing
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
209
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
210 // Pop it out.
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
211 str zFront = io_recentfiles.value.substr (0, lPos);
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
212 str zBack = io_recentfiles.value.substr (lPos + ~zPath + 1, -1);
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
213 io_recentfiles.value = zFront + zBack;
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
214 }
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
215
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
216 // If there's too many recent files, drop one out.
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
217 while (io_recentfiles.value.count ('@') > 3)
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
218 io_recentfiles.value = io_recentfiles.value.substr (io_recentfiles.value.first ("@") + 1, -1);
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
219
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
220 // Add the file
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
221 if (~io_recentfiles.value > 0)
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
222 io_recentfiles.value += "@";
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
223
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
224 io_recentfiles += zPath;
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
225
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
226 config::save ();
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
227 g_ForgeWindow->updateRecentFilesMenu ();
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
228 }
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
229
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
230 // =============================================================================
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
232 // =============================================================================
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
233 void openMainFile (str zPath) {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
234 closeAll ();
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
235
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
236 OpenFile* pFile = openDATFile (zPath);
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
237
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
238 if (!pFile)
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
239 return;
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
240
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
241 g_CurrentFile = pFile;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
242
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
243 // Recalculate the bounding box
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
244 g_BBox.calculate();
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
245
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
246 // Rebuild the object tree view now.
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
247 g_ForgeWindow->refresh ();
109
f40b35142586 Improved shared selection handling; added select by color
Santeri Piippo <crimsondusk64@gmail.com>
parents: 104
diff changeset
248 g_ForgeWindow->setTitle ();
99
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
249
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
250 // Add it to the recent files list.
920d51fec412 Recent files are now remembered and displayed in a submenu
Santeri Piippo <crimsondusk64@gmail.com>
parents: 94
diff changeset
251 addRecentFile (zPath);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
252 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
253
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
254 // =============================================================================
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
256 // =============================================================================
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
257 bool OpenFile::save (str zPath) {
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
258 if (!~zPath)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
259 zPath = zFileName;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
260
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
261 FILE* fp = fopen (zPath, "w");
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
262 if (!fp)
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
263 return false;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
264
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
265 // Write all entries now
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
266 for (LDObject* obj : objects) {
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
267 // LDraw requires lines to have DOS line endings
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
268 str zLine = format ("%s\r\n", obj->getContents ().chars ());
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
269
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
270 fwrite (zLine.chars(), 1, ~zLine, fp);
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
271 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
272
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
273 fclose (fp);
28
208adc847377 added Save As function
Santeri Piippo <crimsondusk64@gmail.com>
parents: 26
diff changeset
274 return true;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
275 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
276
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
277 #define CHECK_TOKEN_COUNT(N) \
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
278 if (tokens.size() != N) \
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
279 return new LDGibberish (zLine, "Bad amount of tokens");
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
280
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
281 #define CHECK_TOKEN_NUMBERS(MIN,MAX) \
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
282 for (ushort i = MIN; i <= MAX; ++i) \
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
283 if (!isNumber (tokens[i])) \
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
284 return new LDGibberish (zLine, format ("Token #%u was `%s`, expected a number", \
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
285 (i + 1), tokens[i].chars()));
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
286
45
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
287 // =============================================================================
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
288 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
289 // =============================================================================
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
290 static vertex parseVertex (vector<str>& s, const ushort n) {
45
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
291 // Disable the locale while parsing the line or atof's behavior changes
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
292 // between locales (i.e. fails to read decimals properly). That is
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
293 // quite undesired...
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
294 setlocale (LC_NUMERIC, "C");
19d99d62d88e Disable the locale when parsing LDraw code or atof's behavior becomes locale-dependant. Who the hell thought that was a great idea?
Santeri Piippo <crimsondusk64@gmail.com>
parents: 42
diff changeset
295
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
296 vertex v;
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
297 v.x = atof (s[n]);
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
298 v.y = atof (s[n + 1]);
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
299 v.z = atof (s[n + 2]);
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
300
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
301 return v;
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
302 }
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
303
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
304 // =============================================================================
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
305 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
306 // =============================================================================
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
307 LDObject* parseLine (str zLine) {
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
308 vector<str> tokens = zLine.split (" ", true);
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
309
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
310 if (!tokens.size ()) {
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
311 // Line was empty, or only consisted of whitespace
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
312 return new LDEmpty;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
313 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
314
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
315 if (~tokens[0] != 1)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
316 return new LDGibberish (zLine, "Illogical line code");
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
317
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
318 const char c = tokens[0][0];
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
319 switch (c - '0') {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
320 case 0:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
321 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
322 // Comment
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
323 str zComment;
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
324 for (uint i = 1; i < tokens.size(); ++i) {
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
325 zComment += tokens[i];
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
326
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
327 if (i != tokens.size() - 1)
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
328 zComment += ' ';
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
329 }
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
330
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
331 // Handle BFC statements
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
332 if (tokens.size() > 2 && tokens[1] == "BFC") {
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
333 for (short i = 0; i < LDBFC::NumStatements; ++i)
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
334 if (zComment == format ("BFC %s", LDBFC::saStatements [i]))
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
335 return new LDBFC ((LDBFC::Type) i);
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
336
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
337 // MLCAD is notorious for stuffing these statements in parts it
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
338 // creates. The above block only handles valid statements, so we
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
339 // need to handle MLCAD-style invertnext separately.
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
340 if (zComment == "BFC CERTIFY INVERTNEXT")
114
fe1bfc5f59ed Added functionality for getting a primitive name from a radial.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 113
diff changeset
341 return new LDBFC (LDBFC::InvertNext);
73
d20867ac03cc Added support for BFC types
Santeri Piippo <crimsondusk64@gmail.com>
parents: 72
diff changeset
342 }
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
343
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
344 if (tokens.size() > 2 && tokens[1] == "!LDFORGE") {
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
345 // Handle LDForge-specific types, they're embedded into comments
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
346
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
347 if (tokens[2] == "VERTEX") {
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
348 // Vertex (0 !LDFORGE VERTEX)
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
349 CHECK_TOKEN_COUNT (7)
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
350 CHECK_TOKEN_NUMBERS (3, 6)
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
351
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
352 LDVertex* obj = new LDVertex;
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
353 obj->dColor = atol (tokens[3]);
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
354 obj->vPosition.x = atof (tokens[4]);
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
355 obj->vPosition.y = atof (tokens[5]);
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
356 obj->vPosition.z = atof (tokens[6]);
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
357
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
358 return obj;
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
359 }
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
360
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
361 if (tokens[2] == "RADIAL") {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
362 CHECK_TOKEN_COUNT (20)
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
363 CHECK_TOKEN_NUMBERS (4, 19)
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
364
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
365 LDRadial::Type eType = LDRadial::NumTypes;
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
366
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
367 for (int i = 0; i < LDRadial::NumTypes; ++i) {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
368 if (str (LDRadial::radialTypeName ((LDRadial::Type) i)).toupper ().strip (' ') == tokens[3]) {
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
369 eType = (LDRadial::Type) i;
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
370 break;
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
371 }
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
372 }
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
373
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
374 if (eType == LDRadial::NumTypes)
116
4fde8fdf258a Some renaming
Santeri Piippo <crimsondusk64@gmail.com>
parents: 114
diff changeset
375 return new LDGibberish (zLine, format ("Unknown radial type %s", tokens[3].chars ()));
113
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
376
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
377 LDRadial* obj = new LDRadial;
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
378
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
379 obj->eRadialType = eType; // 3
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
380 obj->dColor = atol (tokens[4]); // 4
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
381 obj->dSegments = atol (tokens[5]); // 5
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
382 obj->dDivisions = atol (tokens[6]); // 6
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
383 obj->dRingNum = atol (tokens[7]); // 7
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
384
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
385 obj->vPosition = parseVertex (tokens, 8); // 8 - 10
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
386
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
387 for (short i = 0; i < 9; ++i)
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
388 obj->mMatrix[i] = atof (tokens[i + 11]); // 11 - 19
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
389
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
390 return obj;
bbaa40226ec9 Radial saving and reading from files
Santeri Piippo <crimsondusk64@gmail.com>
parents: 109
diff changeset
391 }
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
392 }
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
393
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
394 LDComment* obj = new LDComment;
42
499c25af0303 Added code for parsing vertices
Santeri Piippo <crimsondusk64@gmail.com>
parents: 40
diff changeset
395 obj->zText = zComment;
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
396 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
397 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
398
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
399 case 1:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
400 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
401 // Subfile
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
402 CHECK_TOKEN_COUNT (15)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
403 CHECK_TOKEN_NUMBERS (1, 13)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
404
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
405 // Try open the file
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
406 OpenFile* pFile = loadSubfile (tokens[14]);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
407
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
408 // If we cannot open the file, mark it an error
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
409 if (!pFile)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
410 return new LDGibberish (zLine, "Could not open referred file");
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
411
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
412 LDSubfile* obj = new LDSubfile;
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
413 obj->dColor = atol (tokens[1]);
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
414 obj->vPosition = parseVertex (tokens, 2); // 2 - 4
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
415
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
416 for (short i = 0; i < 9; ++i)
64
ada4679d5bce Considerably improved sub-file inlining. Use a matrix class instead of double[9], educated myself on what matrix multiplication actually is and fixed the algorithm up. Aside from I/O problems, 32551.dat is correctly rendered now.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 60
diff changeset
417 obj->mMatrix[i] = atof (tokens[i + 5]); // 5 - 13
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
418
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
419 obj->zFileName = tokens[14];
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
420 obj->pFile = pFile;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
421 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
422 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
423
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
424 case 2:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
425 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
426 CHECK_TOKEN_COUNT (8)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
427 CHECK_TOKEN_NUMBERS (1, 7)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
428
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
429 // Line
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
430 LDLine* obj = new LDLine;
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
431 obj->dColor = atol (tokens[1]);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
432 for (short i = 0; i < 2; ++i)
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
433 obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 7
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
434 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
435 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
436
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
437 case 3:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
438 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
439 CHECK_TOKEN_COUNT (11)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
440 CHECK_TOKEN_NUMBERS (1, 10)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
441
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
442 // Triangle
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
443 LDTriangle* obj = new LDTriangle;
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
444 obj->dColor = atol (tokens[1]);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
445
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
446 for (short i = 0; i < 3; ++i)
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
447 obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 10
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
448
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
449 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
450 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
451
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
452 case 4:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
453 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
454 CHECK_TOKEN_COUNT (14)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
455 CHECK_TOKEN_NUMBERS (1, 13)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
456
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
457 // Quadrilateral
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
458 LDQuad* obj = new LDQuad;
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
459 obj->dColor = atol (tokens[1]);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
460
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
461 for (short i = 0; i < 4; ++i)
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
462 obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
463
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
464 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
465 }
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
466
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
467 case 5:
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
468 {
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
469 CHECK_TOKEN_COUNT (14)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
470 CHECK_TOKEN_NUMBERS (1, 13)
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
471
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
472 // Conditional line
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
473 LDCondLine* obj = new LDCondLine;
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
474 obj->dColor = atol (tokens[1]);
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
475
40
215b9f8f0cd7 Added triangle, quad and condline to the add object dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 39
diff changeset
476 for (short i = 0; i < 4; ++i)
60
961663d05463 Parsing stability, finally figured that dumb crash
Santeri Piippo <crimsondusk64@gmail.com>
parents: 55
diff changeset
477 obj->vaCoords[i] = parseVertex (tokens, 2 + (i * 3)); // 2 - 13
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
478
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
479 return obj;
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
480 }
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
481
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
482 default: // Strange line we couldn't parse
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
483 return new LDGibberish (zLine, "Unknown line code number");
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
484 }
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
485 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
486
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
487 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
488 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
489 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
490 OpenFile* loadSubfile (str zFile) {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
491 // Try open the file
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
492 OpenFile* pFile = findLoadedFile (zFile);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
493 if (!pFile)
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
494 pFile = openDATFile (zFile);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
495
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
496 return pFile;
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
497 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
498
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
499 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
500 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
501 // =============================================================================
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
502 void reloadAllSubfiles () {
32
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
503 if (!g_CurrentFile)
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
504 return;
5d22b7ecf110 Made the GL renderer background color configurable
Santeri Piippo <crimsondusk64@gmail.com>
parents: 30
diff changeset
505
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
506 // First, close all but the current open file.
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
507 for (OpenFile* file : g_LoadedFiles)
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
508 if (file != g_CurrentFile)
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
509 file->close ();
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
510
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
511 g_LoadedFiles.clear ();
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
512 g_LoadedFiles.push_back (g_CurrentFile);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
513
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
514 // Go through all objects in the current file and reload the subfiles
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
515 for (LDObject* obj : g_CurrentFile->objects) {
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
516 if (obj->getType() == OBJ_Subfile) {
70
e6b8dab8f81a Phased out FOREACH macro in favor of C++11-style for iteration.
Santeri Piippo <crimsondusk64@gmail.com>
parents: 69
diff changeset
517 // Note: ref->pFile is invalid right now since all subfiles were closed.
29
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
518 LDSubfile* ref = static_cast<LDSubfile*> (obj);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
519 OpenFile* pFile = loadSubfile (ref->zFileName);
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
520
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
521 if (pFile)
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
522 ref->pFile = pFile;
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
523 else {
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
524 // Couldn't load the file, mark it an error
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
525 ref->replace (new LDGibberish (ref->getContents (), "Could not open referred file"));
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
526 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
527 }
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
528
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
529 // Reparse gibberish files. It could be that they are invalid because
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
530 // the file could not be opened. Circumstances may be different now.
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
531 if (obj->getType() == OBJ_Gibberish)
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
532 obj->replace (parseLine (static_cast<LDGibberish*> (obj)->zContents));
55406ce7446e Added LDraw path setting dialog
Santeri Piippo <crimsondusk64@gmail.com>
parents: 28
diff changeset
533 }
38
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
534 }
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
535
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
536 // =============================================================================
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
537 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
538 // =============================================================================
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
539 ulong OpenFile::addObject (LDObject* obj) {
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 38
diff changeset
540 if (this != g_CurrentFile) {
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 38
diff changeset
541 objects.insert (objects.end (), obj);
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
542 return objects.size() - 1;
39
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 38
diff changeset
543 }
110669124caf Begin work on dialogs for adding objects. Comments functional!
Santeri Piippo <crimsondusk64@gmail.com>
parents: 38
diff changeset
544
79
f8917e9d07f6 Extracted actions from ForgeWindow into their own files. The ACTION macro now manages meta, instances and callback definitions all in one. Too bad I still need to extern these actions in gui.cpp... maybe someday I'll find a way around it :)
Santeri Piippo <crimsondusk64@gmail.com>
parents: 73
diff changeset
545 const ulong ulSpot = g_ForgeWindow->getInsertionPoint ();
38
20f5eaae8425 Implemented insertion of triangles, quads, condlines and comments
Santeri Piippo <crimsondusk64@gmail.com>
parents: 32
diff changeset
546 objects.insert (objects.begin() + ulSpot, obj);
94
a9e67f6e610e Added history management for cut and paste, copy doesn't alter the object list by itself so it doesn't touch history
Santeri Piippo <crimsondusk64@gmail.com>
parents: 79
diff changeset
547 return ulSpot;
55
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
548 }
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
549
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
550 // =============================================================================
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
551 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
552 // =============================================================================
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
553 void OpenFile::forgetObject (LDObject* obj) {
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
554 // Find the index for the given object
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
555 ulong ulIndex;
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
556 for (ulIndex = 0; ulIndex < (ulong)objects.size(); ++ulIndex)
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
557 if (objects[ulIndex] == obj)
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
558 break; // found it
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
559
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
560 if (ulIndex >= objects.size ())
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
561 return; // was not found
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
562
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
563 // Erase it from memory
b08f10e668e5 Added clipboard, added delete action
Santeri Piippo <crimsondusk64@gmail.com>
parents: 46
diff changeset
564 objects.erase (objects.begin() + ulIndex);
117
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
565 }
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
566
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
567 // =============================================================================
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
568 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
569 // =============================================================================
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
570 std::vector<partListEntry> g_PartList;
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
571
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
572 void initPartList () {
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
573 logf ("%s: initializing parts.lst\n", __func__);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
574
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
575 FILE* fp = openLDrawFile ("parts.lst", false);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
576
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
577 if (!fp)
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
578 return;
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
579
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
580 char sLine[1024];
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
581 while (fgets (sLine, sizeof sLine, fp)) {
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
582 // Locate the first whitespace
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
583 char* cpWhite = strstr (sLine, " ");
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
584
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
585 char sName[65];
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
586 size_t uLength = (cpWhite - sLine);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
587
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
588 if (uLength >= 64)
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
589 continue; // too long
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
590
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
591 strncpy (sName, sLine, uLength);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
592 sName[uLength] = '\0';
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
593
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
594 // Surf through the whitespace sea!
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
595 while (*cpWhite == ' ')
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
596 cpWhite++;
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
597
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
598 // Get the end point
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
599 char* cpEnd = strstr (sLine, "\r");
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
600
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
601 if (cpEnd == null) {
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
602 // must not be DOS-formatted
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
603 cpEnd = strstr (sLine, "\n");
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
604 }
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
605
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
606 assert (cpEnd != null);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
607
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
608 // Make the file title now
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
609 char sTitle[81];
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
610 uLength = (cpEnd - cpWhite);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
611 strncpy (sTitle, cpWhite, uLength);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
612 sTitle[uLength] = '\0';
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
613
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
614 // Add it to the array.
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
615 partListEntry entry;
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
616 strcpy (entry.sName, sName);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
617 strcpy (entry.sTitle, sTitle);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
618 g_PartList.push_back (entry);
7eb7a43a511b Generalized SetContentsHistory to an EditHistory
Santeri Piippo <crimsondusk64@gmail.com>
parents: 116
diff changeset
619 }
26
83184d9407c7 Renamed io.cpp to file.cpp, draw.cpp to gldraw.cpp
Santeri Piippo <crimsondusk64@gmail.com>
parents:
diff changeset
620 }

mercurial