1 /*
2
3 Copyright (C) 1991-2001 and beyond by Bungie Studios, Inc.
4 and the "Aleph One" developers.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 This license is contained in the file "COPYING",
17 which is included with this source code; it is available online at
18 http://www.gnu.org/licenses/gpl.html
19
20 */
21
22 /*
23 * preprocess_map_sdl.cpp - Save game routines, SDL implementation
24 *
25 * Written in 2000 by Christian Bauer
26 */
27
28 #include "cseries.h"
29 #include "FileHandler.h"
30
31 #include <vector>
32
33 #include "world.h"
34 #include "map.h"
35 #include "shell.h"
36 #include "interface.h"
37 #include "game_wad.h"
38 #include "game_errors.h"
39 #include "QuickSave.h"
40
41 // From shell_sdl.cpp
42 extern vector<DirectorySpecifier> data_search_path;
43
44
45 /*
46 * Get FileSpecifiers for default data files
47 */
48
get_default_spec(FileSpecifier & file,const string & name)49 static bool get_default_spec(FileSpecifier &file, const string &name)
50 {
51 vector<DirectorySpecifier>::const_iterator i = data_search_path.begin(), end = data_search_path.end();
52 while (i != end) {
53 file = *i + name;
54 if (file.Exists())
55 return true;
56 i++;
57 }
58 return false;
59 }
60
get_default_spec(FileSpecifier & file,int type)61 static bool get_default_spec(FileSpecifier &file, int type)
62 {
63 char name[256];
64 getcstr(name, strFILENAMES, type);
65 return get_default_spec(file, name);
66 }
67
have_default_files(void)68 bool have_default_files(void)
69 {
70 FileSpecifier file;
71 return (get_default_spec(file, filenameDEFAULT_MAP) &&
72 (get_default_spec(file, filenameIMAGES) || get_default_spec(file, filenameEXTERNAL_RESOURCES)) &&
73 get_default_spec(file, filenameSHAPES8));
74 }
75
get_default_external_resources_spec(FileSpecifier & file)76 void get_default_external_resources_spec(FileSpecifier& file)
77 {
78 get_default_spec(file, filenameEXTERNAL_RESOURCES);
79 }
80
get_default_map_spec(FileSpecifier & file)81 void get_default_map_spec(FileSpecifier &file)
82 {
83 if (!get_default_spec(file, filenameDEFAULT_MAP))
84 alert_bad_extra_file();
85 }
86
get_default_physics_spec(FileSpecifier & file)87 void get_default_physics_spec(FileSpecifier &file)
88 {
89 get_default_spec(file, filenamePHYSICS_MODEL);
90 // don't care if it does not exist
91 }
92
get_default_shapes_spec(FileSpecifier & file)93 void get_default_shapes_spec(FileSpecifier &file)
94 {
95 if (!get_default_spec(file, filenameSHAPES8))
96 alert_bad_extra_file();
97 }
98
get_default_sounds_spec(FileSpecifier & file)99 void get_default_sounds_spec(FileSpecifier &file)
100 {
101 get_default_spec(file, filenameSOUNDS8);
102 // don't care if it does not exist
103 }
104
get_default_music_spec(FileSpecifier & file)105 bool get_default_music_spec(FileSpecifier &file)
106 {
107 return get_default_spec(file, filenameMUSIC);
108 }
109
get_default_theme_spec(FileSpecifier & file)110 bool get_default_theme_spec(FileSpecifier &file)
111 {
112 FileSpecifier theme = "Themes";
113 theme += getcstr(temporary, strFILENAMES, filenameDEFAULT_THEME);
114 return get_default_spec(file, theme.GetPath());
115 }
116
117 /*
118 * Choose saved game for loading
119 */
120
choose_saved_game_to_load(FileSpecifier & saved_game)121 bool choose_saved_game_to_load(FileSpecifier &saved_game)
122 {
123 return load_quick_save_dialog(saved_game);
124 }
125
126
127 /*
128 * Save game
129 */
130
save_game(void)131 bool save_game(void)
132 {
133 pause_game();
134 bool success = create_quick_save();
135 if (success)
136 screen_printf("Game saved");
137 else
138 screen_printf("Save failed");
139 resume_game();
140
141 return success;
142 }
143
144
145 /*
146 * Store additional data in saved game file
147 */
148
add_finishing_touches_to_save_file(FileSpecifier & file)149 void add_finishing_touches_to_save_file(FileSpecifier &file)
150 {
151 // The MacOS version stores an overhead thumbnail and the level name
152 // in resources. Do we want to imitate this?
153 }
154