ScummVM API documentation
saveload.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 *
21 * This file is dual-licensed.
22 * In addition to the GPLv3 license mentioned above, this code is also
23 * licensed under LGPL 2.1. See LICENSES/COPYING.LGPL file for the
24 * full text of the license.
25 *
26 */
27
28#ifndef GOB_SAVE_SAVELOAD_H
29#define GOB_SAVE_SAVELOAD_H
30
31#include "gob/save/savefile.h"
32#include "gob/save/savehandler.h"
33
34namespace Gob {
35
36class GobEngine;
37
39class SaveLoad {
40public:
42 enum SaveMode {
47 };
48
54 virtual ~SaveLoad();
55
57 static const char *stripPath(const char *fileName, char separator = '\\');
58
60 static Common::String replacePathSeparators(const char *path, char newSeparator);
61
63 virtual SaveMode getSaveMode(const char *fileName) const;
64
67
69 int32 getSize(const char *fileName);
71 bool load(const char *fileName, int16 dataVar, int32 size, int32 offset);
72 bool loadToRaw(const char *fileName, byte *ptr, int32 size, int32 offset);
74 bool save(const char *fileName, int16 dataVar, int32 size, int32 offset);
75 bool saveFromRaw(const char *fileName, byte *ptr, int32 size, int32 offset);
76 bool copySaveGame(const char *fileNameSrc, const char *fileNameDest);
77
79 bool deleteFile(const char *fileName);
80
81protected:
82 GobEngine *_vm;
83
84 virtual SaveHandler *getHandler(const char *fileName) const;
85 virtual const char *getDescription(const char *fileName) const;
86};
87
89class SaveLoad_Geisha : public SaveLoad {
90public:
91 SaveLoad_Geisha(GobEngine *vm, const char *targetName);
92 ~SaveLoad_Geisha() override;
93
94 SaveMode getSaveMode(const char *fileName) const override;
95
96protected:
97 static const uint32 kSlotCount = 7;
98 static const uint32 kSlotSize = 44;
99
100 static const uint32 kSaveFileSize = kSlotCount * kSlotSize;
101
102 struct SaveFile {
103 const char *sourceName;
104 SaveMode mode;
105 SaveHandler *handler;
106 const char *description;
107 };
108
110 class GameHandler : public SaveHandler {
111 public:
112 GameHandler(GobEngine *vm, const Common::String &target);
113 ~GameHandler() override;
114
115 int32 getSize() override;
116 bool load(int16 dataVar, int32 size, int32 offset) override;
117 bool save(int16 dataVar, int32 size, int32 offset) override;
118
119 private:
121 class File : public SlotFileIndexed {
122 public:
123 File(GobEngine *vm, const Common::String &base);
124 ~File() override;
125
126 int getSlot(int32 offset) const override;
127 int getSlotRemainder(int32 offset) const override;
128 };
129
130 File _file;
131 };
132
133 static SaveFile _saveFiles[];
134
135 SaveHandler *getHandler(const char *fileName) const override;
136 const char *getDescription(const char *fileName) const override;
137
138 const SaveFile *getSaveFile(const char *fileName) const;
139 SaveFile *getSaveFile(const char *fileName);
140};
141
143class SaveLoad_v2 : public SaveLoad {
144public:
145 static const uint32 kSlotCount = 15;
146 static const uint32 kSlotNameLength = 40;
147
149 static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
150
151 SaveLoad_v2(GobEngine *vm, const char *targetName);
152 ~SaveLoad_v2() override;
153
154 SaveMode getSaveMode(const char *fileName) const override;
155
156protected:
157 struct SaveFile {
158 const char *sourceName;
159 SaveMode mode;
160 SaveHandler *handler;
161 const char *description;
162 };
163
165 class GameHandler : public SaveHandler {
166 public:
167 GameHandler(GobEngine *vm, const char *target);
168 ~GameHandler() override;
169
170 int32 getSize() override;
171 bool load(int16 dataVar, int32 size, int32 offset) override;
172 bool save(int16 dataVar, int32 size, int32 offset) override;
173
174 private:
176 class File : public SlotFileIndexed {
177 public:
178 File(GobEngine *vm, const char *base);
179 ~File() override;
180
181 int getSlot(int32 offset) const override;
182 int getSlotRemainder(int32 offset) const override;
183 };
184
185 byte _index[kIndexSize];
186 bool _hasIndex;
187
188 File *_slotFile;
189
190 void buildIndex(byte *buffer) const;
191 };
192
193 static SaveFile _saveFiles[];
194
195 GameHandler *_gameHandler;
196 NotesHandler *_notesHandler;
197 TempSpriteHandler *_tempSpriteHandler;
198
199 SaveHandler *getHandler(const char *fileName) const override;
200 const char *getDescription(const char *fileName) const override;
201
202 const SaveFile *getSaveFile(const char *fileName) const;
203 SaveFile *getSaveFile(const char *fileName);
204};
205
208public:
209 static const uint32 kSlotCount = 15;
210 static const uint32 kSlotNameLength = 40;
211
213 static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
214
215 SaveLoad_Fascination(GobEngine *vm, const char *targetName);
216 ~SaveLoad_Fascination() override;
217
218 SaveMode getSaveMode(const char *fileName) const override;
219
220protected:
221 struct SaveFile {
222 const char *sourceName;
223 SaveMode mode;
224 int slot;
225 SaveHandler *handler;
226 const char *description;
227 };
228
230 class GameHandler : public SaveHandler {
231 public:
232 GameHandler(GobEngine *vm, const char *target, int slot, byte *index, bool *hasIndex);
233 ~GameHandler() override;
234
235 int32 getSize() override;
236 bool load(int16 dataVar, int32 size, int32 offset) override;
237 bool save(int16 dataVar, int32 size, int32 offset) override;
238
239 private:
241 class File : public SlotFileIndexed {
242 public:
243 File(GobEngine *vm, const char *base);
244 ~File() override;
245
246 int getSlot(int32 offset) const override;
247 int getSlotRemainder(int32 offset) const override;
248 };
249
250 byte *_index;
251 bool *_hasIndex;
252 int _slot;
253
254 File *_slotFile;
255
256 void buildIndex(byte *buffer) const;
257 };
258
259 byte _index[kIndexSize];
260 bool _hasIndex;
261
262 static SaveFile _saveFiles[];
263
264 SaveHandler *getHandler(const char *fileName) const override;
265 const char *getDescription(const char *fileName) const override;
266
267 const SaveFile *getSaveFile(const char *fileName) const;
268 SaveFile *getSaveFile(const char *fileName);
269};
270
273public:
274 static const int32 kAdibou1NbrOfDrawings = 8;
275 SaveLoad_Adibou1(GobEngine *vm, const char *targetName);
276 ~SaveLoad_Adibou1() override;
277
278 SaveMode getSaveMode(const char *fileName) const override;
279
280protected:
281 struct SaveFile {
282 const char *sourceName;
283 SaveMode mode;
284 SaveHandler *handler;
285 const char *description;
286 };
287
289 public:
290 SpriteHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
291 ~SpriteHandler() override;
292
293 int32 getSize() override;
294 bool load(int16 dataVar, int32 size, int32 offset) override;
295 bool save(int16 dataVar, int32 size, int32 offset) override;
296
297 private:
298 class File : public SlotFileStatic {
299 public:
300 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
301 ~File() override;
302 };
303
304 File _file;
305 };
306
307
309 public:
311 const Common::String &target,
312 const Common::String &ext);
314
315 int32 getSize() override;
316 bool load(int16 dataVar, int32 size, int32 offset) override;
317 bool save(int16 dataVar, int32 size, int32 offset) override;
318
319 private:
320 class File : public SlotFileStatic {
321 public:
322 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
323 ~File() override;
324 };
325
326 File _file;
327 SaveWriter *_writer;
328 SaveReader *_reader;
329 };
330
332 public:
333 GameFileHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
334 ~GameFileHandler() override;
335
336 int32 getSize() override;
337 bool load(int16 dataVar, int32 size, int32 offset) override;
338 bool save(int16 dataVar, int32 size, int32 offset) override;
339 bool deleteFile() override;
340
341 private:
342 // Save from raw pointer if ptrRaw != nullptr, else save from game variables
343 bool save(const byte *ptrRaw, int16 dataVar, int32 size, int32 offset);
344
345 class File : public SlotFileStatic {
346 public:
347 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
348 ~File() override;
349 };
350
351 File _file;
352 };
353
354 static SaveFile _saveFiles[];
355
356 GameFileHandler *_bouHandler;
357 GameFileHandler *_constructionHandler;
358 SpriteHandler *_drawingHandler;
359 TempSpriteHandler *_menuHandler;
360 DrawingWithThumbnailHandler *_drawingWithThumbnailHandler[kAdibou1NbrOfDrawings];
361
362 SaveHandler *getHandler(const char *fileName) const override;
363 const char *getDescription(const char *fileName) const override;
364
365 const SaveFile *getSaveFile(const char *fileName) const;
366 SaveFile *getSaveFile(const char *fileName);
367};
368
370class SaveLoad_v3 : public SaveLoad {
371public:
372 static const uint32 kSlotCount = 30;
373 static const uint32 kSlotNameLength = 40;
374
375 static const uint32 kPropsSize = 500;
377 static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
378
382 };
383
384 SaveLoad_v3(GobEngine *vm, const char *targetName, ScreenshotType sShotType);
385 ~SaveLoad_v3() override;
386
387 SaveMode getSaveMode(const char *fileName) const override;
388
389protected:
390 struct SaveFile {
391 const char *sourceName;
392 SaveMode mode;
393 SaveHandler *handler;
394 const char *description;
395 };
396
397 class ScreenshotHandler;
398
400 class GameHandler : public SaveHandler {
402 public:
403
404 GameHandler(GobEngine *vm, const char *target, bool usesScreenshots);
405 ~GameHandler() override;
406
407 int32 getSize() override;
408 bool load(int16 dataVar, int32 size, int32 offset) override;
409 bool save(int16 dataVar, int32 size, int32 offset) override;
410
411 bool saveScreenshot(int slot, const SavePartSprite *screenshot);
412 bool loadScreenshot(int slot, SavePartSprite *screenshot);
413
415 class File : public SlotFileIndexed {
416 public:
417 File(GobEngine *vm, const char *base);
418 File(const File &file);
419 ~File() override;
420
421 int getSlot(int32 offset) const override;
422 int getSlotRemainder(int32 offset) const override;
423 };
424 private:
425
426 File *_slotFile;
427
428 bool _usesScreenshots;
429
430 bool _firstSize;
431
433 byte _props[kPropsSize];
434 byte _index[kIndexSize];
435 bool _hasIndex;
436
437 SaveReader *_reader;
438 SaveWriter *_writer;
439
440 void buildIndex(byte *buffer) const;
441
442 bool createReader(int slot);
443 bool createWriter(int slot);
444
445 };
446
449 public:
450 ScreenshotHandler(GobEngine *vm, GameHandler *gameHandler, ScreenshotType sShotType);
451 ~ScreenshotHandler() override;
452
453 int32 getSize() override;
454 bool load(int16 dataVar, int32 size, int32 offset) override;
455 bool save(int16 dataVar, int32 size, int32 offset) override;
456
457 private:
459 class File : public SaveLoad_v3::GameHandler::File {
460 public:
461 File(const SaveLoad_v3::GameHandler::File &file,
462 uint32 shotSize, uint32 shotIndexSize);
463 ~File() override;
464
465 int getSlot(int32 offset) const override;
466 int getSlotRemainder(int32 offset) const override;
467
468 void buildScreenshotIndex(byte *buffer) const;
469
470 protected:
471 uint32 _shotSize;
472 uint32 _shotIndexSize;
473 };
474
475 File *_file;
476 GameHandler *_gameHandler;
477 ScreenshotType _sShotType;
478
479 uint32 _shotSize;
480 int32 _shotIndexSize;
481 byte _index[80];
482 };
483
484 static SaveFile _saveFiles[];
485
486 ScreenshotType _sShotType;
487
488 GameHandler *_gameHandler;
489 NotesHandler *_notesHandler;
490 TempSpriteHandler *_tempSpriteHandler;
491 ScreenshotHandler *_screenshotHandler;
492
493 SaveHandler *getHandler(const char *fileName) const override;
494 const char *getDescription(const char *fileName) const override;
495
496 const SaveFile *getSaveFile(const char *fileName) const;
497 SaveFile *getSaveFile(const char *fileName);
498};
499
501class SaveLoad_Inca2 : public SaveLoad {
502public:
503 static const uint32 kSlotCount = 40;
504 static const uint32 kPropsSize = 500;
505
506 SaveLoad_Inca2(GobEngine *vm, const char *targetName);
507 ~SaveLoad_Inca2() override;
508
509 SaveMode getSaveMode(const char *fileName) const override;
510
511protected:
512 struct SaveFile {
513 const char *sourceName;
514 SaveMode mode;
515 SaveHandler *handler;
516 const char *description;
517 };
518
520 class VoiceHandler : public SaveHandler {
521 public:
523 ~VoiceHandler() override;
524
525 int32 getSize() override;
526 bool load(int16 dataVar, int32 size, int32 offset) override;
527 bool save(int16 dataVar, int32 size, int32 offset) override;
528 };
529
530 class ScreenshotHandler;
531
533 class GameHandler : public SaveHandler {
535 public:
536
537 GameHandler(GobEngine *vm, const char *target);
538 ~GameHandler() override;
539
540 int32 getSize() override;
541 bool load(int16 dataVar, int32 size, int32 offset) override;
542 bool save(int16 dataVar, int32 size, int32 offset) override;
543
544 bool saveScreenshot(int slot, const SavePartSprite *screenshot);
545 bool loadScreenshot(int slot, SavePartSprite *screenshot);
546
548 class File : public SlotFileIndexed {
549 public:
550 File(GobEngine *vm, const char *base);
551 File(const File &file);
552 ~File() override;
553
554 int getSlot(int32 offset) const override;
555 int getSlotRemainder(int32 offset) const override;
556 };
557
558 private:
559
560 File *_slotFile;
561
562 byte _props[kPropsSize];
563
564 SaveReader *_reader;
565 SaveWriter *_writer;
566
567 void buildIndex();
568
569 bool createReader(int slot);
570 bool createWriter(int slot);
571 };
572
575 public:
576 ScreenshotHandler(GobEngine *vm, GameHandler *gameHandler);
577 ~ScreenshotHandler() override;
578
579 int32 getSize() override;
580 bool load(int16 dataVar, int32 size, int32 offset) override;
581 bool save(int16 dataVar, int32 size, int32 offset) override;
582
583 private:
585 class File : public SaveLoad_Inca2::GameHandler::File {
586 public:
587 File(const SaveLoad_Inca2::GameHandler::File &file);
588 ~File() override;
589
590 int getSlot(int32 offset) const override;
591 int getSlotRemainder(int32 offset) const override;
592
593 void buildScreenshotIndex(byte *buffer) const;
594 };
595
596 File *_file;
597 GameHandler *_gameHandler;
598
599 byte _index[80];
600 };
601
602 static SaveFile _saveFiles[];
603
604 VoiceHandler *_voiceHandler;
605 TempSpriteHandler *_tempSpriteHandler;
606 GameHandler *_gameHandler;
607 ScreenshotHandler *_screenshotHandler;
608
609 SaveHandler *getHandler(const char *fileName) const override;
610 const char *getDescription(const char *fileName) const override;
611
612 const SaveFile *getSaveFile(const char *fileName) const;
613 SaveFile *getSaveFile(const char *fileName);
614};
615
617class SaveLoad_v4 : public SaveLoad {
618public:
619 static const uint32 kSlotCount = 10;
620 static const uint32 kSlotNameLength = 40;
621
622 static const uint32 kPropsSize = 500;
624 static const uint32 kIndexSize = (kSlotCount * kSlotNameLength) + 800;
625
626 SaveLoad_v4(GobEngine *vm, const char *targetName);
627 ~SaveLoad_v4() override;
628
629 SaveMode getSaveMode(const char *fileName) const override;
630
631protected:
632 struct SaveFile {
633 const char *sourceName;
634 SaveMode mode;
635 SaveHandler *handler;
636 const char *description;
637 };
638
639 class ScreenPropsHandler;
640
642 class GameHandler : public SaveHandler {
644 public:
645 GameHandler(GobEngine *vm, const char *target);
646 ~GameHandler() override;
647
648 int getLastSlot() const;
649
650 int32 getSize() override;
651 bool load(int16 dataVar, int32 size, int32 offset) override;
652 bool save(int16 dataVar, int32 size, int32 offset) override;
653
654 bool saveScreenProps(int slot, const byte *props);
655 bool loadScreenProps(int slot, byte *props);
656
658 class File : public SlotFileIndexed {
659 public:
660 File(GobEngine *vm, const char *base);
661 File(const File &file);
662 ~File() override;
663
664 int getSlot(int32 offset) const override;
665 int getSlotRemainder(int32 offset) const override;
666 };
667
668 private:
669 bool _firstSize;
670
671 byte _props[kPropsSize];
672 byte _index[kIndexSize];
673 bool _hasIndex;
674
675 File *_slotFile;
676
677 int _lastSlot;
678
679 SaveReader *_reader;
680 SaveWriter *_writer;
681
682 void buildIndex(byte *buffer) const;
683
684 bool createReader(int slot);
685 bool createWriter(int slot);
686 };
687
690 public:
692 ~CurScreenPropsHandler() override;
693
694 int32 getSize() override;
695 bool load(int16 dataVar, int32 size, int32 offset) override;
696 bool save(int16 dataVar, int32 size, int32 offset) override;
697
698 private:
699 byte *_props;
700 };
701
703 public:
704 ScreenPropsHandler(GobEngine *vm, uint32 slot,
705 CurScreenPropsHandler *curProps, GameHandler *gameHandler);
706 ~ScreenPropsHandler() override;
707
708 int32 getSize() override;
709 bool load(int16 dataVar, int32 size, int32 offset) override;
710 bool save(int16 dataVar, int32 size, int32 offset) override;
711
712 private:
713 class File : public SaveLoad_v4::GameHandler::File {
714 public:
715 File(const SaveLoad_v4::GameHandler::File &file, uint32 slot);
716 ~File() override;
717
718 int getSlot(int32 offset) const override;
719 int getSlotRemainder(int32 offset) const override;
720
721 private:
722 uint32 _slot;
723 };
724
725 uint32 _slot;
726 CurScreenPropsHandler *_curProps;
727 GameHandler *_gameHandler;
728
729 File *_file;
730 };
731
732 static SaveFile _saveFiles[];
733
734 GameHandler *_gameHandler;
735 CurScreenPropsHandler *_curProps;
736 ScreenPropsHandler *_props[10];
737
738 SaveHandler *getHandler(const char *fileName) const override;
739 const char *getDescription(const char *fileName) const override;
740
741 const SaveFile *getSaveFile(const char *fileName) const;
742 SaveFile *getSaveFile(const char *fileName);
743};
744
746class SaveLoad_v6 : public SaveLoad {
747public:
748 static const uint32 kSlotCount = 60;
749 static const uint32 kSlotNameLength = 40;
750
751 static const uint32 kPropsSize = 500;
753 static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
754
755 SaveLoad_v6(GobEngine *vm, const char *targetName);
756 ~SaveLoad_v6() override;
757
758 SaveMode getSaveMode(const char *fileName) const override;
759
760protected:
761 struct SaveFile {
762 const char *sourceName;
763 SaveMode mode;
764 SaveHandler *handler;
765 const char *description;
766 };
767
770 public:
772 ~SpriteHandler() override;
773
774 bool set(SaveReader *reader, uint32 part);
775 bool get(SaveWriter *writer, uint32 part);
776 };
777
779 class GameHandler : public SaveHandler {
780 public:
781 GameHandler(GobEngine *vm, const char *target, SpriteHandler &spriteHandler);
782 ~GameHandler() override;
783
784 int32 getSize() override;
785 bool load(int16 dataVar, int32 size, int32 offset) override;
786 bool save(int16 dataVar, int32 size, int32 offset) override;
787
788 uint8 getExtraID(int slot);
789 bool loadExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset);
790 bool saveExtra(int slot, uint8 id, int16 dataVar, int32 size, int32 offset);
791
792 private:
794 class File : public SlotFileIndexed {
795 public:
796 File(GobEngine *vm, const char *base);
797 ~File() override;
798
799 int getSlot(int32 offset) const override;
800 int getSlotRemainder(int32 offset) const override;
801 };
802
803 SpriteHandler *_spriteHandler;
804
805 byte _props[kPropsSize];
806 byte _index[kIndexSize];
807
808 File *_slotFile;
809
810 SaveReader *_reader;
811 SaveWriter *_writer;
812
813 bool _hasExtra;
814
815 void buildIndex(byte *buffer) const;
816
817 void refreshProps();
818
819 bool createReader(int slot);
820 bool createWriter(int slot);
821 };
822
824 class AutoHandler : public SaveHandler {
825 public:
826 AutoHandler(GobEngine *vm, const Common::String &target);
827 ~AutoHandler() override;
828
829 int32 getSize() override;
830 bool load(int16 dataVar, int32 size, int32 offset) override;
831 bool save(int16 dataVar, int32 size, int32 offset) override;
832
833 private:
834 class File : public SlotFileStatic {
835 public:
836 File(GobEngine *vm, const Common::String &base);
837 ~File() override;
838 };
839
840 File _file;
841 };
842
845 public:
846 AutoSpriteHandler(GobEngine *vm, const Common::String &target);
847 ~AutoSpriteHandler() override;
848
849 int32 getSize() override;
850 bool load(int16 dataVar, int32 size, int32 offset) override;
851 bool save(int16 dataVar, int32 size, int32 offset) override;
852
853 private:
854 class File : public SlotFileStatic {
855 public:
856 File(GobEngine *vm, const Common::String &base);
857 ~File() override;
858 };
859
860 File _file;
861 };
862
864 class TempHandler : public SaveHandler {
865 public:
867 ~TempHandler() override;
868
869 int32 getSize() override;
870 bool load(int16 dataVar, int32 size, int32 offset) override;
871 bool save(int16 dataVar, int32 size, int32 offset) override;
872 bool deleteFile() override;
873
874 private:
875 bool _empty;
876
877 uint32 _size;
878 byte *_data;
879 };
880
881 class ExtraHandler : public SaveHandler {
882 public:
883 ExtraHandler(GobEngine *vm, GameHandler &game, uint8 id, int slot);
884 ~ExtraHandler() override;
885
886 int32 getSize() override;
887 bool load(int16 dataVar, int32 size, int32 offset) override;
888 bool save(int16 dataVar, int32 size, int32 offset) override;
889
890 private:
891 uint8 _id;
892 int _slot;
893
894 GameHandler *_game;
895 };
896
897 static SaveFile _saveFiles[];
898
899 SpriteHandler *_spriteHandler;
900 GameHandler *_gameHandler;
901 AutoHandler *_autoHandler;
902 AutoSpriteHandler *_autoSpriteHandler;
903 TempHandler *_tmpHandler[2];
904 ExtraHandler *_extraHandler[120];
905
906 SaveHandler *getHandler(const char *fileName) const override;
907 const char *getDescription(const char *fileName) const override;
908
909 const SaveFile *getSaveFile(const char *fileName) const;
910 SaveFile *getSaveFile(const char *fileName);
911};
912
915public:
916 static const uint32 kSlotCount = 60;
917 static const uint32 kSlotNameLength = 40;
918
919 static const uint32 kPropsSize = 3921;
921 static const uint32 kIndexSize = kSlotCount * kSlotNameLength;
922
923 SaveLoad_Playtoons(GobEngine *vm, const char *targetName);
924 ~SaveLoad_Playtoons() override;
925
926 SaveMode getSaveMode(const char *fileName) const override;
927
928protected:
929 struct SaveFile {
930 const char *sourceName;
931 SaveMode mode;
932 SaveHandler *handler;
933 const char *description;
934 };
935
937 class GameHandler : public SaveHandler {
938 public:
939 GameHandler(GobEngine *vm, const char *target);
940 ~GameHandler() override;
941
942 int32 getSize() override;
943 bool load(int16 dataVar, int32 size, int32 offset) override;
944 bool save(int16 dataVar, int32 size, int32 offset) override;
945
946 private:
948 class File : public SlotFileIndexed {
949 public:
950 File(GobEngine *vm, const char *base);
951 ~File() override;
952
953 int getSlot(int32 offset) const override;
954 int getSlotRemainder(int32 offset) const override;
955 };
956
957 byte _props[kPropsSize];
958 byte _index[kIndexSize];
959
960 File *_slotFile;
961 TempSpriteHandler *_tempSpriteHandler;
962
963 void buildIndex(byte *buffer) const;
964 };
965
966 static SaveFile _saveFiles[];
967
968 GameHandler *_gameHandler;
969
970 SaveHandler *getHandler(const char *fileName) const override;
971 const char *getDescription(const char *fileName) const override;
972
973 const SaveFile *getSaveFile(const char *fileName) const;
974 SaveFile *getSaveFile(const char *fileName);
975};
976
978class SaveLoad_v7: public SaveLoad {
979public:
980 static const uint32 kChildrenCount = 16;
981 static const uint32 kAdibou2NbrOfApplications = 7;
982 static const uint32 kAdibou2NbrOfSavedDrawings = 12;
983 static const uint32 kAdibou2NbrOfConstructionGameFiles = 3;
984
985 static const uint32 kAdi4NbrOfTempFiles = 3;
986 static const uint32 kAdi4NbrOfApplications = 4; // Only Math/Language/English/Euro for now
987 static const uint32 kAdi4NbrOfSchoolYears = 8;
988 // 13 isolated files, 1 "config" and "statv" file per child, 1 "dip" and "res" file per app x school year x child
989 static const uint32 kAdi4NbrOfGameFiles = 13 + 2 * kChildrenCount + 2 * kAdi4NbrOfApplications * kAdi4NbrOfSchoolYears * kChildrenCount;
990
991 SaveLoad_v7(GobEngine *vm, const char *targetName);
992 ~SaveLoad_v7() override;
993
994 SaveMode getSaveMode(const char *fileName) const override;
996
997protected:
998 struct SaveFile {
999 const char *sourceName;
1000 SaveMode mode;
1001 SaveHandler *handler;
1002 const char *description;
1003 };
1004
1006 public:
1007 SpriteHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
1008 ~SpriteHandler() override;
1009
1010 int32 getSize() override;
1011 bool load(int16 dataVar, int32 size, int32 offset) override;
1012 bool save(int16 dataVar, int32 size, int32 offset) override;
1013 bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
1014 bool saveFromRaw(const byte* ptr, int32 size, int32 offset) override;
1015 bool deleteFile() override;
1016
1017 private:
1018 class File : public SlotFileStatic {
1019 public:
1020 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1021 ~File() override;
1022 };
1023
1024 File _file;
1025 };
1026
1028 public:
1030 SaveReader *reader,
1031 SaveWriter *writer,
1032 bool isThumbnail,
1033 uint32 chunkSize = 1);
1034 ~DrawingOnFloppyDiskHandler() override;
1035
1036 int32 getSize() override;
1037 bool load(int16 dataVar, int32 size, int32 offset) override;
1038 bool save(int16 dataVar, int32 size, int32 offset) override;
1039 bool deleteFile() override;
1040
1041 private:
1042 class File : public SlotFileStatic {
1043 public:
1044 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1045 ~File() override;
1046 };
1047
1048 //File _file;
1049 SaveWriter *_writer;
1050 SaveReader *_reader;
1051 bool _isThumbnail;
1052 int32 _chunkSize;
1053 };
1054
1056 public:
1057 GameFileHandler(GobEngine *vm, const Common::String &target, const Common::String &ext);
1058 ~GameFileHandler() override;
1059
1060 int32 getSize() override;
1061 bool load(int16 dataVar, int32 size, int32 offset) override;
1062 bool save(int16 dataVar, int32 size, int32 offset) override;
1063 bool loadToRaw(byte *ptr, int32 size, int32 offset) override;
1064 bool saveFromRaw(const byte *ptr, int32 size, int32 offset) override;
1065 bool deleteFile() override;
1066
1067 private:
1068 // Save from raw pointer if ptrRaw != nullptr, else save from game variables
1069 bool save(const byte *ptrRaw, int16 dataVar, int32 size, int32 offset);
1070
1071 class File : public SlotFileStatic {
1072 public:
1073 File(GobEngine *vm, const Common::String &base, const Common::String &ext);
1074 ~File() override;
1075 };
1076
1077 File _file;
1078 };
1079
1080
1081 static SaveFile _saveFiles[];
1082
1083 SpriteHandler *_faceHandler[kChildrenCount];
1084 FakeFileHandler *_childrenHandler;
1085 FakeFileHandler *_debilHandler[4];
1086 GameFileHandler *_configHandler;
1087 GameFileHandler *_adibou2EnvHandler[kChildrenCount];
1088 SpriteHandler *_adibou2WeatherHandler[kChildrenCount];
1089 GameFileHandler *_adibou2BreakoutGameProgressHandler[kChildrenCount];
1090 FakeFileHandler *_adibou2ConstructionGameTempFileHandler[kAdibou2NbrOfConstructionGameFiles];
1091 GameFileHandler *_adibou2ConstructionGameProgressHandler[kChildrenCount][kAdibou2NbrOfConstructionGameFiles];
1092 GameFileHandler *_adibou2AppProgressHandler[kChildrenCount][kAdibou2NbrOfApplications];
1093 GameFileHandler *_adibou2MemoHandler[kChildrenCount];
1094 GameFileHandler *_adibou2DiploHandler[kChildrenCount];
1095 GameFileHandler *_adibou2AppliHandler[kAdibou2NbrOfApplications];
1096 GameFileHandler *_adibou2CriteHandler[kAdibou2NbrOfApplications];
1097 GameFileHandler *_adibou2ExoHandler[kAdibou2NbrOfApplications];
1098 GameFileHandler *_adibou2ApplicationsInfoHandler;
1099 FakeFileHandler *_adibou2RetourHandler;
1100 FakeFileHandler *_adibou2LanceHandler;
1101 TempSpriteHandler *_adibou2AppIcoHandler[kAdibou2NbrOfApplications];
1102 SpriteHandler *_adibou2DrawingHandler[kChildrenCount][kAdibou2NbrOfSavedDrawings];
1103 SpriteHandler *_adibou2DrawingThumbnailHandler[kChildrenCount][kAdibou2NbrOfSavedDrawings];
1104 GameFileHandler *_adibou2DrawingPaletteHandler[kChildrenCount];
1105 SpriteHandler *_adibou2DrawingMailboxHandler[kChildrenCount];
1106 SpriteHandler *_adibou2CakePhotoHandler[kChildrenCount];
1107 SpriteHandler *_adibou2FlowerPhotoHandler[kChildrenCount];
1108 SpriteHandler *_adibou2FlowerInVaseHandler[kChildrenCount];
1109 SpriteHandler *_adibou2FadedFlowerInVaseHandler[kChildrenCount];
1110 SpriteHandler *_adibou2PosterHandler[kChildrenCount];
1111 DrawingOnFloppyDiskHandler *_adibou2DrawingOnFloppyDiskHandler;
1112 DrawingOnFloppyDiskHandler *_adibou2DrawingThumbnailOnFloppyDiskHandler;
1113 FakeFileHandler *_adibou2TestDobHandler;
1114 FakeFileHandler *_adibou2ExerciseListHandler;
1115 FakeFileHandler *_adibou2RelanceHandler;
1116 FakeFileHandler *_adibou2MemHandler;
1117 GameFileHandler *_adibou2AppProgressExtHandler[kAdibou2NbrOfApplications - 4][kChildrenCount];
1118 GameFileHandler *_adibou2AppliIniHandler[kAdibou2NbrOfApplications];
1119
1120 FakeFileHandler *_adi4TempFileHandler[kAdi4NbrOfTempFiles];
1121 TempSpriteHandler *_adi4TempSpriteHandler;
1122 GameFileHandler *_adi4GameFileHandler[kAdi4NbrOfGameFiles];
1123
1124 SaveHandler *getHandler(const char *fileName) const override;
1125 const char *getDescription(const char *fileName) const override;
1126
1127 const SaveFile *getSaveFile(const char *fileName) const;
1128};
1129
1130} // End of namespace Gob
1131
1132#endif // GOB_SAVE_SAVELOAD_H
Definition: path.h:52
Definition: str.h:59
Definition: savehandler.h:194
Definition: gob.h:166
Definition: savehandler.h:172
Definition: savehandler.h:116
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:331
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:288
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:272
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:230
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:207
static const uint32 kIndexSize
Definition: saveload.h:213
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:110
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:89
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:548
int getSlot(int32 offset) const override
int getSlotRemainder(int32 offset) const override
Definition: saveload.h:533
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:574
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:520
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:501
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:937
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:914
SaveMode getSaveMode(const char *fileName) const override
static const uint32 kIndexSize
Definition: saveload.h:921
Definition: saveload.h:165
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:143
static const uint32 kIndexSize
Definition: saveload.h:149
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:415
int getSlot(int32 offset) const override
int getSlotRemainder(int32 offset) const override
Definition: saveload.h:400
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:448
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:370
ScreenshotType
Definition: saveload.h:379
@ kScreenshotTypeLost
Lost in Time type screenshot.
Definition: saveload.h:381
@ kScreenshotTypeGob3
Goblins 3 type screenshot.
Definition: saveload.h:380
static const uint32 kIndexSize
Definition: saveload.h:377
SaveMode getSaveMode(const char *fileName) const override
Definition: saveload.h:688
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:658
int getSlotRemainder(int32 offset) const override
int getSlot(int32 offset) const override
Definition: saveload.h:642
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:702
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:617
SaveMode getSaveMode(const char *fileName) const override
static const uint32 kIndexSize
Definition: saveload.h:624
Definition: saveload.h:824
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:844
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:881
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:779
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:769
Definition: saveload.h:864
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:746
SaveMode getSaveMode(const char *fileName) const override
static const uint32 kIndexSize
Definition: saveload.h:753
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:1055
bool save(int16 dataVar, int32 size, int32 offset) override
bool load(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:1005
bool load(int16 dataVar, int32 size, int32 offset) override
bool save(int16 dataVar, int32 size, int32 offset) override
Definition: saveload.h:978
SaveMode getSaveMode(const char *fileName) const override
Common::List< Common::Path > getFilesMatchingPattern(const Common::Path &pattern) const override
Definition: saveload.h:39
static const char * stripPath(const char *fileName, char separator='\\')
virtual Common::List< Common::Path > getFilesMatchingPattern(const Common::Path &pattern) const
SaveLoad(GobEngine *vm)
SaveMode
Definition: saveload.h:42
@ kSaveModeExists
Just claim it exists.
Definition: saveload.h:45
@ kSaveModeIgnore
Ignore it.
Definition: saveload.h:44
@ kSaveModeNone
Don't handle it.
Definition: saveload.h:43
@ kSaveModeSave
A normal save.
Definition: saveload.h:46
static Common::String replacePathSeparators(const char *path, char newSeparator)
bool load(const char *fileName, int16 dataVar, int32 size, int32 offset)
virtual SaveMode getSaveMode(const char *fileName) const
bool save(const char *fileName, int16 dataVar, int32 size, int32 offset)
bool deleteFile(const char *fileName)
int32 getSize(const char *fileName)
Definition: savefile.h:162
Definition: savefile.h:313
Definition: savefile.h:340
Definition: savehandler.h:68
Definition: savehandler.h:96
Definition: savehandler.h:141
Definition: saveload.h:281
Definition: saveload.h:221
Definition: saveload.h:102
Definition: saveload.h:512
Definition: saveload.h:929
Definition: saveload.h:157
Definition: saveload.h:390
Definition: saveload.h:632
Definition: saveload.h:761
Definition: saveload.h:998