taisei/src/progress.h

124 lines
2.9 KiB
C
Raw Normal View History

/*
* This software is licensed under the terms of the MIT License.
2017-09-12 03:28:15 +02:00
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
2019-07-03 20:00:56 +02:00
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
2017-09-12 03:28:15 +02:00
*/
#pragma once
#include "taisei.h"
2017-02-11 12:38:50 +01:00
#include <SDL.h>
#include "cutscenes/cutscene.h"
2017-04-18 21:48:18 +02:00
#define PROGRESS_FILE "storage/progress.dat"
#define PROGRESS_MAXFILESIZE 4096
typedef enum ProgfileCommand {
2019-03-11 00:21:43 +01:00
// Do not reorder this!
PCMD_UNLOCK_STAGES = 0x00,
PCMD_UNLOCK_STAGES_WITH_DIFFICULTY = 0x01,
PCMD_HISCORE = 0x02,
PCMD_STAGE_PLAYINFO = 0x03,
PCMD_ENDINGS = 0x04,
PCMD_GAME_SETTINGS = 0x05,
PCMD_GAME_VERSION = 0x06,
2019-03-11 00:21:43 +01:00
PCMD_UNLOCK_BGMS = 0x07,
PCMD_UNLOCK_CUTSCENES = 0x08,
} ProgfileCommand;
2017-02-11 12:38:50 +01:00
typedef struct StageProgress {
2019-03-11 00:21:43 +01:00
// Keep this struct small if you can
// See stage_get_progress_from_info() in stage.c for more information
2017-02-11 12:38:50 +01:00
uint32_t num_played;
uint32_t num_cleared;
2019-03-11 00:21:43 +01:00
uchar unlocked : 1;
2017-02-11 12:38:50 +01:00
} StageProgress;
2019-03-11 00:21:43 +01:00
typedef enum ProgressBGMID {
// Do not reorder! Append at the end only, reserve space if removing.
PBGM_MENU,
PBGM_STAGE1,
PBGM_STAGE1_BOSS,
PBGM_STAGE2,
PBGM_STAGE2_BOSS,
PBGM_STAGE3,
PBGM_STAGE3_BOSS,
PBGM_STAGE4,
PBGM_STAGE4_BOSS,
PBGM_STAGE5,
PBGM_STAGE5_BOSS,
PBGM_STAGE6,
PBGM_STAGE6_BOSS1,
PBGM_STAGE6_BOSS2,
PBGM_STAGE6_BOSS3,
PBGM_ENDING,
PBGM_CREDITS,
PBGM_BONUS0, // old Iku theme
PBGM_BONUS1, // Scuttle theme
2020-06-24 19:51:00 +02:00
PBGM_GAMEOVER,
2019-03-11 00:21:43 +01:00
} ProgressBGMID;
struct UnknownCmd;
typedef enum EndingID {
// WARNING: Reordering this will break current progress files.
ENDING_BAD_MARISA,
ENDING_BAD_YOUMU,
ENDING_GOOD_MARISA,
ENDING_GOOD_YOUMU,
ENDING_BAD_REIMU,
ENDING_GOOD_REIMU,
NUM_ENDINGS,
} EndingID;
#define GOOD_ENDINGS \
ENDING(ENDING_GOOD_MARISA) \
ENDING(ENDING_GOOD_YOUMU) \
ENDING(ENDING_GOOD_REIMU)
#define BAD_ENDINGS \
ENDING(ENDING_BAD_MARISA) \
ENDING(ENDING_BAD_YOUMU) \
ENDING(ENDING_BAD_REIMU)
2017-03-20 06:29:22 +01:00
typedef struct GlobalProgress {
uint32_t hiscore;
uint32_t achieved_endings[NUM_ENDINGS];
2019-03-11 00:21:43 +01:00
uint64_t unlocked_bgms;
uint64_t unlocked_cutscenes;
struct UnknownCmd *unknown;
struct {
uint8_t difficulty;
uint8_t character;
uint8_t shotmode;
} game_settings;
2017-03-20 06:29:22 +01:00
} GlobalProgress;
2017-03-20 06:29:22 +01:00
extern GlobalProgress progress;
void progress_load(void);
void progress_save(void);
void progress_unload(void);
void progress_unlock_all(void);
uint32_t progress_times_any_ending_achieved(void);
uint32_t progress_times_any_good_ending_achieved(void);
2019-03-11 00:21:43 +01:00
bool progress_is_bgm_unlocked(const char *name);
2021-12-22 22:52:22 +01:00
bool progress_is_bgm_id_unlocked(ProgressBGMID id);
2019-03-11 00:21:43 +01:00
void progress_unlock_bgm(const char *name);
void progress_track_ending(EndingID id);
bool progress_is_cutscene_unlocked(CutsceneID id);
void progress_unlock_cutscene(CutsceneID id);