Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
trophy.h
Go to the documentation of this file.
1
7
240
241#pragma once
242
243//==============================================================================
244// Includes
245//==============================================================================
246
247#include <stdint.h>
248#include <stdbool.h>
249#include "hdw-nvs.h"
250#include "wsgPalette.h"
251#include "fs_font.h"
252
253//==============================================================================
254// Defines
255//==============================================================================
256
257#define TROPHY_MAX_TITLE_LEN 48
258#define TROPHY_MAX_DESC_LEN 128
259
260#define DRAW_SLIDE_US 262144
261#define DRAW_STATIC_US 524288
262
263#define NO_IMAGE_SET CNFS_NUM_FILES
264
265//==============================================================================
266// Enum
267//==============================================================================
268
278
288
297
298//==============================================================================
299// Structs
300//==============================================================================
301
316
318typedef struct
319{
323 const char* namespaceKey;
325
327typedef struct
328{
329 int32_t length;
330 const trophyData_t* const list;
333
334//==============================================================================
335// Functions
336//==============================================================================
337
338// Trophy system
339
347void trophySystemInit(const trophyDataList_t* settings, const char* modeName);
348
349// Utilize trophies
350
359bool trophyUpdate(const trophyData_t* t, int newVal, bool drawUpdate);
360
369bool trophyUpdateMilestone(const trophyData_t* t, int newVal, int threshold);
370
377int32_t trophyGetSavedValue(const trophyData_t* t);
378
388bool trophySetChecklistTask(const trophyData_t* t, int32_t flag, bool unset, bool drawUpdate);
389
395void trophyClear(const trophyData_t* t);
396
397// Helpers
398
407bool checkBitFlag(int32_t flags, int8_t idx);
408
416void setBitFlag(int32_t* flags, int8_t idx, bool setTrue);
417
425int trophyGetPoints(bool total, const char* namespace);
426
432const trophyData_t* trophyGetLatest(void);
433
440void trophySetSystemData(const trophyDataList_t* dl, const char* modeName);
441
442// Drawing functions
443
450void trophyDraw(font_t* fnt, int64_t elapsedUs);
451
458
469void trophyDrawListColors(paletteColor_t background, paletteColor_t panel, paletteColor_t shadowBoxes,
470 paletteColor_t dimText, paletteColor_t titleText, paletteColor_t checkmark);
471
476void trophyDrawListDeinit(void);
477
484void trophyDrawList(font_t* fnt, int yOffset);
485
491bool isTrophyDrawing(void);
A font is a collection of font_ch_t for all ASCII characters. Each character has the same height and ...
Definition font.h:66
paletteColor_t
All 216 possible colors, named like cRGB.
Definition palette.h:23
trophyDifficulty_t
Dev inferred difficulty of achieving, used to distribute points.
Definition trophy.h:281
@ TROPHY_DIFF_EXTREME
A trophy that takes skill, dedication, and insanity to unlock.
Definition trophy.h:286
@ TROPHY_DIFF_MEDIUM
A bit more difficult to unlock than TROPHY_DIFF_EASY.
Definition trophy.h:284
@ TROPHY_DIFF_EASY
The easiest trophies to unlock.
Definition trophy.h:283
@ TROPHY_DIFF_HARD
A trophy that takes serious skill to unlock.
Definition trophy.h:285
@ TROPHY_DIFF_FINAL
Only used by the trophy System. Will break normal trophies.
Definition trophy.h:282
void trophySystemInit(const trophyDataList_t *settings, const char *modeName)
Initializes the Trophy system settings. The system is a global setting and every mode needs to set th...
Definition trophy.c:280
void trophyDrawListColors(paletteColor_t background, paletteColor_t panel, paletteColor_t shadowBoxes, paletteColor_t dimText, paletteColor_t titleText, paletteColor_t checkmark)
Set the colors of the panel to custom. Call after initialization of the list, or it'll be overwritten...
Definition trophy.c:691
#define TROPHY_MAX_DESC_LEN
The longest possible description for a trophy.
Definition trophy.h:258
char title[TROPHY_MAX_TITLE_LEN]
Name of the Trophy, used as ID.
Definition trophy.h:305
trophyType_t type
Type of trophy. See "trophy.h" for descriptions.
Definition trophy.h:308
bool trophySetChecklistTask(const trophyData_t *t, int32_t flag, bool unset, bool drawUpdate)
Sets or unsets a checklist item.
Definition trophy.c:501
int32_t slideDurationUs
How long the banner will take to slide in and out.
Definition trophy.h:322
bool trophyUpdateMilestone(const trophyData_t *t, int newVal, int threshold)
Updates just like trophyUpdate(), but only draws when crossing percentage boundary.
Definition trophy.c:467
int32_t maxVal
The value that.
Definition trophy.h:310
const void * identifier
Definition trophy.h:313
void trophyClear(const trophyData_t *t)
Erases completion data from swadge. Only use in extreme circumstances.
Definition trophy.c:524
bool hidden
If trophy is hidden by default.
Definition trophy.h:311
bool trophyUpdate(const trophyData_t *t, int newVal, bool drawUpdate)
Updates specifed trophy if required.
Definition trophy.c:352
bool isTrophyDrawing(void)
Check if a trophy is currently being drawn.
Definition trophy.c:594
int32_t length
Length of the trophy arrays.
Definition trophy.h:329
const trophyData_t * trophyGetLatest(void)
Get the Latest Trophy Idx object.
Definition trophy.c:569
char description[TROPHY_MAX_DESC_LEN]
Short description of task required.
Definition trophy.h:306
bool noImage
If trophy will use an image.
Definition trophy.h:312
const trophySettings_t * settings
Setting data.
Definition trophy.h:331
void setBitFlag(int32_t *flags, int8_t idx, bool setTrue)
Set a bit flag.
Definition trophy.c:552
#define TROPHY_MAX_TITLE_LEN
The longest possible name for a trophy.
Definition trophy.h:257
bool drawFromBottom
If banner should be drawn from the bottom of the screen.
Definition trophy.h:320
int32_t staticDurationUs
How long the banner will be drawn fully extended.
Definition trophy.h:321
const char * namespaceKey
key used for trophy namespace
Definition trophy.h:323
void trophyDraw(font_t *fnt, int64_t elapsedUs)
Draws the banner if one is queued.
Definition trophy.c:599
void trophyDrawListInit(trophyListDisplayMode_t mode)
Initialize the trophy Draw list.
Definition trophy.c:665
trophyListDisplayMode_t
What display mode to use to draw trophies.
Definition trophy.h:291
@ TROPHY_DISPLAY_LOCKED
Display only locked trophies.
Definition trophy.h:294
@ TROPHY_DISPLAY_INCL_HIDDEN
Display locked, unlocked, and hidden trophies.
Definition trophy.h:295
@ TROPHY_DISPLAY_UNLOCKED
Display only unlocked trophies.
Definition trophy.h:293
@ TROPHY_DISPLAY_ALL
Display locked and unlocked trophies, but not hidden ones.
Definition trophy.h:292
cnfsFileIdx_t image
Index of the image.
Definition trophy.h:307
void trophySetSystemData(const trophyDataList_t *dl, const char *modeName)
Set the Trophy System to a specific mode's values.
Definition trophy.c:585
int32_t trophyGetSavedValue(const trophyData_t *t)
Returns the value saved to the NVS or 0 if the key isn't found.
Definition trophy.c:489
int trophyGetPoints(bool total, const char *namespace)
Get the point totals for the gamer score.
Definition trophy.c:564
trophyType_t
Types of trophies the devs can instantiate.
Definition trophy.h:271
@ TROPHY_TYPE_TRIGGER
Only needs to be triggered once (Did a handstand, found a hidden message)
Definition trophy.h:272
@ TROPHY_TYPE_ADDITIVE
Each update adds to the previous (Lifetime distance, number of cakes eaten)
Definition trophy.h:273
@ TROPHY_TYPE_CHECKLIST
Definition trophy.h:275
@ TROPHY_TYPE_PROGRESS
Tracks how far a user got per update (How long player survived, how far player ran)
Definition trophy.h:274
bool checkBitFlag(int32_t flags, int8_t idx)
Checks an individual bit flag out of a int32.
Definition trophy.c:547
void trophyDrawList(font_t *fnt, int yOffset)
Draws the list.
Definition trophy.c:714
trophyDifficulty_t difficulty
How many points the trophy is worth.
Definition trophy.h:309
void trophyDrawListDeinit(void)
Tears down the WSGs and height list.
Definition trophy.c:702
const trophyData_t *const list
Array of trophies.
Definition trophy.h:330
The data object dev hands to the trophy showcase that contains all the const data.
Definition trophy.h:328
Individual Trophy data objects.
Definition trophy.h:304
Settings for the trophy system.
Definition trophy.h:319
Provides palette swap functionality for Swadge.