15 * You should have received a copy of the GNU General Public License |
15 * You should have received a copy of the GNU General Public License |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ |
17 */ |
18 |
18 |
19 #include <vector> |
19 #include <vector> |
20 |
20 #include <stdio.h> |
21 #include "common.h" |
21 #include "common.h" |
22 #include "config.h" |
22 #include "config.h" |
23 #include "file.h" |
23 #include "file.h" |
24 #include "misc.h" |
24 #include "misc.h" |
25 #include "bbox.h" |
25 #include "bbox.h" |
26 #include "gui.h" |
26 #include "gui.h" |
27 |
27 |
28 cfg (str, io_ldpath, ""); |
28 cfg (str, io_ldpath, ""); |
|
29 cfg (str, io_recentfiles, ""); |
29 |
30 |
30 // ============================================================================= |
31 // ============================================================================= |
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
32 // ============================================================================= |
33 // ============================================================================= |
33 OpenFile* findLoadedFile (str zName) { |
34 OpenFile* findLoadedFile (str zName) { |
196 } |
197 } |
197 |
198 |
198 // ============================================================================= |
199 // ============================================================================= |
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
200 // ============================================================================= |
201 // ============================================================================= |
|
202 void addRecentFile (str zPath) { |
|
203 long lPos = io_recentfiles.value.first (zPath); |
|
204 |
|
205 // If this file already is in the list, pop it out. |
|
206 if (lPos != -1) { |
|
207 if (~io_recentfiles.value == ~zPath) |
|
208 return; // only recent file - do nothing |
|
209 |
|
210 // Pop it out. |
|
211 str zFront = io_recentfiles.value.substr (0, lPos); |
|
212 str zBack = io_recentfiles.value.substr (lPos + ~zPath + 1, -1); |
|
213 io_recentfiles.value = zFront + zBack; |
|
214 } |
|
215 |
|
216 // If there's too many recent files, drop one out. |
|
217 while (io_recentfiles.value.count ('@') > 3) |
|
218 io_recentfiles.value = io_recentfiles.value.substr (io_recentfiles.value.first ("@") + 1, -1); |
|
219 |
|
220 // Add the file |
|
221 if (~io_recentfiles.value > 0) |
|
222 io_recentfiles.value += "@"; |
|
223 |
|
224 io_recentfiles += zPath; |
|
225 |
|
226 config::save (); |
|
227 g_ForgeWindow->updateRecentFilesMenu (); |
|
228 } |
|
229 |
|
230 // ============================================================================= |
|
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
|
232 // ============================================================================= |
201 void openMainFile (str zPath) { |
233 void openMainFile (str zPath) { |
202 closeAll (); |
234 closeAll (); |
203 |
235 |
204 OpenFile* pFile = openDATFile (zPath); |
236 OpenFile* pFile = openDATFile (zPath); |
205 |
237 |
211 // Recalculate the bounding box |
243 // Recalculate the bounding box |
212 g_BBox.calculate(); |
244 g_BBox.calculate(); |
213 |
245 |
214 // Rebuild the object tree view now. |
246 // Rebuild the object tree view now. |
215 g_ForgeWindow->refresh (); |
247 g_ForgeWindow->refresh (); |
|
248 |
|
249 // Add it to the recent files list. |
|
250 addRecentFile (zPath); |
216 } |
251 } |
217 |
252 |
218 // ============================================================================= |
253 // ============================================================================= |
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
220 // ============================================================================= |
255 // ============================================================================= |