DungeonCrawl
|
Implements a handler for outputing media to the screen. More...
#include "media_output_handler.h"
#include "../../../logging/logger.h"
#include "../../io_handler.h"
#include "../common/output_handler.h"
#include "media_files.h"
#include <notcurses/notcurses.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
Go to the source code of this file.
Macros | |
#define | MAX_RESOURCES 128 |
Functions | |
bool | init_media_output (void) |
Initialize the media output handler. | |
void | shutdown_media_output (void) |
Shutdown the media output handler. | |
void | media_cleanup (void) |
void | destroy_media (loaded_visual_t *media) |
Frees the memory associated with a loaded media resource. | |
bool | refresh_media_display (void) |
Force a refresh of the media display. | |
loaded_visual_t * | load_media (const char *filename) |
load a media resource from file they can be different types (PNG, GIF, MP4) | |
loaded_visual_t * | ready_media (const char *filename, int x, int y, int height, int width, scale_type_t scale_type) |
Prepares a media resource for display. | |
bool | unload_media (const char *filename) |
Unload a specific media resource. | |
void | setup_scaling_options (loaded_visual_t *visual, scale_type_t scale_type, int target_width, int target_height) |
Enable different scaling options for the loaded visual. | |
media_type_t | get_file_type (const char *filename) |
Get the media type based on the file extension. | |
bool | is_file_extension (const char *filename, const char *extension) |
Check if a filename has a specific extension. | |
char * | build_filepath (const char *filename, media_type_t media_type) |
Build a file path for the specified media type. |
Implements a handler for outputing media to the screen.
Definition in file media_output_handler.c.
#define MAX_RESOURCES 128 |
Definition at line 23 of file media_output_handler.c.
char * build_filepath | ( | const char * | filename, |
media_type_t | media_type ) |
Build a file path for the specified media type.
filename | File name to build the path for |
media_type | Type of media (PNG, GIF, MP4) |
Definition at line 433 of file media_output_handler.c.
void destroy_media | ( | loaded_visual_t * | media | ) |
Frees the memory associated with a loaded media resource.
media | Pointer to the loaded media instance to destroy |
Definition at line 76 of file media_output_handler.c.
media_type_t get_file_type | ( | const char * | filename | ) |
Get the media type based on the file extension.
filename | File name to check |
Definition at line 403 of file media_output_handler.c.
bool init_media_output | ( | void | ) |
Initialize the media output handler.
Must be called after the common output handler is initialized.
Definition at line 37 of file media_output_handler.c.
bool is_file_extension | ( | const char * | filename, |
const char * | extension ) |
Check if a filename has a specific extension.
filename | File name to check |
extension | Extension to check for |
Definition at line 417 of file media_output_handler.c.
loaded_visual_t * load_media | ( | const char * | filename | ) |
load a media resource from file they can be different types (PNG, GIF, MP4)
filename | File name to load |
Definition at line 99 of file media_output_handler.c.
void media_cleanup | ( | void | ) |
Definition at line 66 of file media_output_handler.c.
loaded_visual_t * ready_media | ( | const char * | filename, |
int | x, | ||
int | y, | ||
int | height, | ||
int | width, | ||
scale_type_t | scale_type ) |
Prepares a media resource for display.
filename | File name to load |
x | X coordinate in terminal cells |
y | Y coordinate in terminal cells |
height | Height in terminal cells |
width | Width in terminal cells (0 for auto) |
scale_type | Scaling type to apply |
Definition at line 226 of file media_output_handler.c.
bool refresh_media_display | ( | void | ) |
Force a refresh of the media display.
Definition at line 81 of file media_output_handler.c.
void setup_scaling_options | ( | loaded_visual_t * | visual, |
scale_type_t | scale_type, | ||
int | target_width, | ||
int | target_height ) |
Enable different scaling options for the loaded visual.
visual | Pointer to the loaded visual instance |
scale_type | Scaling type to apply |
target_width | Width to scale to |
target_height | Height to scale to |
Definition at line 333 of file media_output_handler.c.
void shutdown_media_output | ( | void | ) |
Shutdown the media output handler.
Cleans up resources used by the media output handler.
Definition at line 62 of file media_output_handler.c.
bool unload_media | ( | const char * | filename | ) |
Unload a specific media resource.
filename | File name to unload |
Definition at line 269 of file media_output_handler.c.