io.cpp

changeset 4
758302636564
parent 0
c51cce84a9ac
child 7
098e3c4949c6
equal deleted inserted replaced
3:2b78cf8634c3 4:758302636564
2 2
3 #include "common.h" 3 #include "common.h"
4 #include "io.h" 4 #include "io.h"
5 #include "ldtypes.h" 5 #include "ldtypes.h"
6 #include "misc.h" 6 #include "misc.h"
7 #include "gui.h"
8 #include "bbox.h"
7 9
8 // ============================================================================= 10 // =============================================================================
9 // IO_FindLoadedFile (str) 11 // IO_FindLoadedFile (str)
10 // 12 //
11 // Returns a pointer to the first found open file with the given name. 13 // Returns a pointer to the first found open file with the given name.
21 23
22 return NULL; 24 return NULL;
23 } 25 }
24 26
25 // ============================================================================= 27 // =============================================================================
26 // IO_ParseLDFile (str) 28 // IO_OpenLDrawFile (str)
27 // 29 //
28 // Opens the given file and parses the LDraw code within. 30 // Opens the given file and parses the LDraw code within.
29 // ============================================================================= 31 // =============================================================================
30 OpenFile* IO_ParseLDFile (str path) { 32 OpenFile* IO_OpenLDrawFile (str path) {
31 FILE* fp = fopen (path.chars (), "r"); 33 FILE* fp = fopen (path.chars (), "r");
32 34
33 if (!fp) { 35 if (!fp) {
34 printf ("Couldn't open %s!\n", path.chars ()); 36 printf ("Couldn't open %s!\n", path.chars ());
35 return NULL; 37 return NULL;
56 58
57 for (ulong i = 0; i < lines.size(); ++i) 59 for (ulong i = 0; i < lines.size(); ++i)
58 load->objects.push_back (ParseLine (lines[i])); 60 load->objects.push_back (ParseLine (lines[i]));
59 61
60 g_LoadedFiles.push_back (load); 62 g_LoadedFiles.push_back (load);
61 return g_LoadedFiles[g_LoadedFiles.size() - 1]; 63 g_CurrentFile = g_LoadedFiles[g_LoadedFiles.size() - 1];
64
65 // Recalculate the bounding box
66 g_BBox.calculate();
67
68 // Rebuild the object tree view now.
69 g_qWindow->buildObjList ();
70
71 return g_CurrentFile;
62 } 72 }
63 73
64 // ============================================================================= 74 // =============================================================================
65 // ParseLine (str) 75 // ParseLine (str)
66 // 76 //

mercurial