1 /* 2 * This software is licensed under the terms of the MIT License. 3 * See COPYING for further information. 4 * --- 5 * Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>. 6 * Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>. 7 */ 8 9 #ifndef IGUARD_progress_h 10 #define IGUARD_progress_h 11 12 #include "taisei.h" 13 14 #include <SDL.h> 15 16 #include "ending.h" 17 18 #define PROGRESS_FILE "storage/progress.dat" 19 #define PROGRESS_MAXFILESIZE 4096 20 21 #ifdef DEBUG 22 // #define PROGRESS_UNLOCK_ALL 23 #endif 24 25 typedef enum ProgfileCommand { 26 // Do not reorder this! 27 28 PCMD_UNLOCK_STAGES = 0x00, 29 PCMD_UNLOCK_STAGES_WITH_DIFFICULTY = 0x01, 30 PCMD_HISCORE = 0x02, 31 PCMD_STAGE_PLAYINFO = 0x03, 32 PCMD_ENDINGS = 0x04, 33 PCMD_GAME_SETTINGS = 0x05, 34 PCMD_GAME_VERSION = 0x06, 35 PCMD_UNLOCK_BGMS = 0x07, 36 } ProgfileCommand; 37 38 typedef struct StageProgress { 39 // Keep this struct small if you can 40 // See stage_get_progress_from_info() in stage.c for more information 41 42 uint32_t num_played; 43 uint32_t num_cleared; 44 uchar unlocked : 1; 45 } StageProgress; 46 47 typedef enum ProgressBGMID { 48 // Do not reorder! Append at the end only, reserve space if removing. 49 50 PBGM_MENU, 51 PBGM_STAGE1, 52 PBGM_STAGE1_BOSS, 53 PBGM_STAGE2, 54 PBGM_STAGE2_BOSS, 55 PBGM_STAGE3, 56 PBGM_STAGE3_BOSS, 57 PBGM_STAGE4, 58 PBGM_STAGE4_BOSS, 59 PBGM_STAGE5, 60 PBGM_STAGE5_BOSS, 61 PBGM_STAGE6, 62 PBGM_STAGE6_BOSS1, 63 PBGM_STAGE6_BOSS2, 64 PBGM_STAGE6_BOSS3, 65 PBGM_ENDING, 66 PBGM_CREDITS, 67 PBGM_BONUS0, // old Iku theme 68 PBGM_BONUS1, // Scuttle theme 69 } ProgressBGMID; 70 71 struct UnknownCmd; 72 73 typedef struct GlobalProgress { 74 uint32_t hiscore; 75 uint32_t achieved_endings[NUM_ENDINGS]; 76 uint64_t unlocked_bgms; 77 struct UnknownCmd *unknown; 78 79 struct { 80 uint8_t difficulty; 81 uint8_t character; 82 uint8_t shotmode; 83 } game_settings; 84 } GlobalProgress; 85 86 extern GlobalProgress progress; 87 88 void progress_load(void); 89 void progress_save(void); 90 void progress_unload(void); 91 92 uint32_t progress_times_any_ending_achieved(void); 93 uint32_t progress_times_any_good_ending_achieved(void); 94 95 bool progress_is_bgm_unlocked(const char *name); 96 void progress_unlock_bgm(const char *name); 97 98 #endif // IGUARD_progress_h 99