Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
trophy.h
Go to the documentation of this file.
1
7
235
236#pragma once
237
238//==============================================================================
239// Includes
240//==============================================================================
241
242#include <stdint.h>
243#include <stdbool.h>
244#include "hdw-nvs.h"
245#include "wsgPalette.h"
246#include "fs_font.h"
247
248//==============================================================================
249// Defines
250//==============================================================================
251
252#define TROPHY_MAX_TITLE_LEN 48
253#define TROPHY_MAX_DESC_LEN 128
254
255#define DRAW_SLIDE_US 262144
256#define DRAW_STATIC_US 524288
257
258#define NO_IMAGE_SET CNFS_NUM_FILES
259
260//==============================================================================
261// Enum
262//==============================================================================
263
273
283
292
293//==============================================================================
294// Structs
295//==============================================================================
296
311
320
322typedef struct
323{
324 int32_t length;
325 const trophyData_t* const list;
328
329//==============================================================================
330// Functions
331//==============================================================================
332
333// Trophy system
334
342void trophySystemInit(trophyDataList_t* settings, const char* modeName);
343
344// Utilize trophies
345
354bool trophyUpdate(trophyData_t t, int newVal, bool drawUpdate);
355
364bool trophyUpdateMilestone(trophyData_t t, int newVal, int threshold);
365
373
383bool trophySetChecklistTask(trophyData_t t, int32_t flag, bool unset, bool drawUpdate);
384
391
392// Helpers
393
402bool checkBitFlag(int32_t flags, int8_t idx);
403
411void setBitFlag(int32_t* flags, int8_t idx, bool setTrue);
412
420int trophyGetPoints(bool total, const char* modeName);
421
428
435void trophySetSystemData(trophyDataList_t* dl, const char* modeName);
436
437// Drawing functions
438
445void trophyDraw(font_t* fnt, int64_t elapsedUs);
446
453
464void trophyDrawListColors(paletteColor_t background, paletteColor_t panel, paletteColor_t shadowBoxes,
465 paletteColor_t dimText, paletteColor_t titleText, paletteColor_t checkmark);
466
471void trophyDrawListDeinit(void);
472
479void trophyDrawList(font_t* fnt, int yOffset);
480
486bool 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
#define NVS_KEY_NAME_MAX_SIZE
Definition hdw-nvs.h:59
paletteColor_t
All 216 possible colors, named like cRGB.
Definition palette.h:23
int trophyGetPoints(bool total, const char *modeName)
Get the point totals for the gamer score.
Definition trophy.c:548
trophyDifficulty_t
Dev inferred difficulty of achieving, used to distribute points.
Definition trophy.h:276
@ TROPHY_DIFF_EXTREME
A trophy that takes skill, dedication, and insanity to unlock.
Definition trophy.h:281
@ TROPHY_DIFF_MEDIUM
A bit more difficult to unlock than TROPHY_DIFF_EASY.
Definition trophy.h:279
@ TROPHY_DIFF_EASY
The easiest trophies to unlock.
Definition trophy.h:278
@ TROPHY_DIFF_HARD
A trophy that takes serious skill to unlock.
Definition trophy.h:280
@ TROPHY_DIFF_FINAL
Only used by the trophy System. Will break normal trophies.
Definition trophy.h:277
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:682
#define TROPHY_MAX_DESC_LEN
The longest possible description for a trophy.
Definition trophy.h:253
char title[TROPHY_MAX_TITLE_LEN]
Name of the Trophy, used as ID.
Definition trophy.h:300
trophyType_t type
Type of trophy. See "trophy.h" for descriptions.
Definition trophy.h:303
int32_t slideDurationUs
How long the banner will take to slide in and out.
Definition trophy.h:317
int32_t maxVal
The value that.
Definition trophy.h:305
const void * identifier
Definition trophy.h:308
bool hidden
If trophy is hidden by default.
Definition trophy.h:306
bool isTrophyDrawing(void)
Check if a trophy is currently being drawn.
Definition trophy.c:585
bool trophySetChecklistTask(trophyData_t t, int32_t flag, bool unset, bool drawUpdate)
Sets or unsets a checklist item.
Definition trophy.c:485
int32_t length
Length of the trophy arrays.
Definition trophy.h:324
bool trophyUpdateMilestone(trophyData_t t, int newVal, int threshold)
Updates just like trophyUpdate(), but only draws when crossing percentage boundary.
Definition trophy.c:451
char description[TROPHY_MAX_DESC_LEN]
Short description of task required.
Definition trophy.h:301
trophySettings_t * settings
Setting data.
Definition trophy.h:326
bool noImage
If trophy will use an image.
Definition trophy.h:307
void trophyClear(trophyData_t t)
Erases completion data from swadge. Only use in extreme circumstances.
Definition trophy.c:508
void trophySystemInit(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:274
void setBitFlag(int32_t *flags, int8_t idx, bool setTrue)
Set a bit flag.
Definition trophy.c:536
#define TROPHY_MAX_TITLE_LEN
The longest possible name for a trophy.
Definition trophy.h:252
bool drawFromBottom
If banner should be drawn from the bottom of the screen.
Definition trophy.h:315
int32_t staticDurationUs
How long the banner will be drawn fully extended.
Definition trophy.h:316
bool trophyUpdate(trophyData_t t, int newVal, bool drawUpdate)
Updates specifed trophy if required.
Definition trophy.c:336
void trophyDraw(font_t *fnt, int64_t elapsedUs)
Draws the banner if one is queued.
Definition trophy.c:590
void trophyDrawListInit(trophyListDisplayMode_t mode)
Initialize the trophy Draw list.
Definition trophy.c:656
char namespaceKey[NVS_KEY_NAME_MAX_SIZE]
key used for trophy namespace
Definition trophy.h:318
trophyListDisplayMode_t
What display mode to use to draw trophies.
Definition trophy.h:286
@ TROPHY_DISPLAY_LOCKED
Display only locked trophies.
Definition trophy.h:289
@ TROPHY_DISPLAY_INCL_HIDDEN
Display locked, unlocked, and hidden trophies.
Definition trophy.h:290
@ TROPHY_DISPLAY_UNLOCKED
Display only unlocked trophies.
Definition trophy.h:288
@ TROPHY_DISPLAY_ALL
Display locked and unlocked trophies, but not hidden ones.
Definition trophy.h:287
cnfsFileIdx_t image
Index of the image.
Definition trophy.h:302
trophyData_t trophyGetLatest(void)
Get the Latest Trophy Idx object.
Definition trophy.c:553
void trophySetSystemData(trophyDataList_t *dl, const char *modeName)
Set the Trophy System to a specific mode's values.
Definition trophy.c:575
trophyType_t
Types of trophies the devs can instantiate.
Definition trophy.h:266
@ TROPHY_TYPE_TRIGGER
Only needs to be triggered once (Did a handstand, found a hidden message)
Definition trophy.h:267
@ TROPHY_TYPE_ADDITIVE
Each update adds to the previous (Lifetime distance, number of cakes eaten)
Definition trophy.h:268
@ TROPHY_TYPE_CHECKLIST
Definition trophy.h:270
@ TROPHY_TYPE_PROGRESS
Tracks how far a user got per update (How long player survived, how far player ran)
Definition trophy.h:269
bool checkBitFlag(int32_t flags, int8_t idx)
Checks an individual bit flag out of a int32.
Definition trophy.c:531
void trophyDrawList(font_t *fnt, int yOffset)
Draws the list.
Definition trophy.c:705
int32_t trophyGetSavedValue(trophyData_t t)
Returns the value saved to the NVS or 0 if the key isn't found.
Definition trophy.c:473
trophyDifficulty_t difficulty
How many points the trophy is worth.
Definition trophy.h:304
void trophyDrawListDeinit(void)
Tears down the WSGs and height list.
Definition trophy.c:693
const trophyData_t *const list
Array of trophies.
Definition trophy.h:325
The data object dev hands to the trophy showcase that contains all the const data.
Definition trophy.h:323
Individual Trophy data objects.
Definition trophy.h:299
Settings for the trophy system.
Definition trophy.h:314
Provides palette swap functionality for Swadge.