DungeonCrawl
Loading...
Searching...
No Matches
media_output.h File Reference

Exposes functions for drawing to the screen. More...

#include "media_output_handler.h"
#include <notcurses/notcurses.h>
#include <stdbool.h>

Go to the source code of this file.

Functions

bool display_image_at (const char *filename, int x, int y, int height, int width, scale_type_t scale_type)
 Display an image file at specified coordinates with scaling.
bool display_image_background (const char *filename)
 Fill the background with an image file scaled to terminal size.
bool display_image_cell (const char *filename, int x, int y)
 Fill a single terminal cell with an image.
bool display_gif_at (const char *filename, int x, int y, int height, int width, scale_type_t scale_type, float fps, bool loop)
 Display an animation file at specified coordinates with scaling.
bool display_gif_background (const char *filename, float fps, bool loop)
 Fill the background with an animation file scaled to terminal size.
bool display_video_at (const char *filename, int x, int y, int width, int height, scale_type_t scale)
 Display a video file at specified coordinates with scaling.
bool display_video_background (const char *filename, float fps, bool loop)
 Fill the background with a video file scaled to terminal size.
void media_output_play (loaded_visual_t *media)
 Start playback of an animation or video Note: This does not handle actual timing, which must be done in the game loop.
void media_output_pause (loaded_visual_t *media)
 Pause playback of an animation or video.
void media_output_reset (loaded_visual_t *media)
 Reset animation or video to the beginning.

Detailed Description

Exposes functions for drawing to the screen.

Definition in file media_output.h.

Function Documentation

◆ display_gif_at()

bool display_gif_at ( const char * filename,
int x,
int y,
int height,
int width,
scale_type_t scale_type,
float fps,
bool loop )

Display an animation file at specified coordinates with scaling.

Parameters
filenameAnimation file name (GIF supported, loaded from src/art/gif/)
xX coordinate in terminal cells
yY coordinate in terminal cells
heightHeight in terminal cells
widthWidth in terminal cells (0 for auto)
scalingScaling mode to use
fpsFrames per second
loopWhether to loop the animation
Returns
true on success, false on failure

◆ display_gif_background()

bool display_gif_background ( const char * filename,
float fps,
bool loop )

Fill the background with an animation file scaled to terminal size.

Parameters
filenameAnimation file name (GIF supported, loaded from src/art/gif/)
fpsFrames per second
loopWhether to loop the animation
Returns
true on success, false on failure

◆ display_image_at()

bool display_image_at ( const char * filename,
int x,
int y,
int height,
int width,
scale_type_t scale_type )

Display an image file at specified coordinates with scaling.

Parameters
filenameImage file name (PNG supported, loaded from src/art/png/)
xX coordinate in terminal cells
yY coordinate in terminal cells
heightHeight in terminal cells
widthWidth in terminal cells (0 for auto)
scale_typeScaling mode to use
Returns
true on success, false on failure

Definition at line 32 of file media_output.c.

32 {
33 // Validate parameters
34 if (!filename || height < 0) {
35 // Allow height=0 for automatic scaling
36 log_msg(ERROR, "media_output", "Invalid parameters for display_png_at");
37 return false;
38 }
39 loaded_visual_t* resource = ready_media(filename, x, y, height, width, scale_type);
40 if (!resource) {
41 log_msg(ERROR, "media_output", "Failed to load image for display");
42 return false;
43 }
44 return display_image(resource);
45}
void log_msg(const log_level_t level, const char *module, const char *format,...)
Logs a formatted message with a specified log level and module.
Definition logger.c:246
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.
struct loaded_visual_s loaded_visual_t
Structure to represent a loaded visual.

◆ display_image_background()

bool display_image_background ( const char * filename)

Fill the background with an image file scaled to terminal size.

Parameters
filenameImage file name (PNG supported, loaded from src/art/png/)
Returns
true on success, false on failure

◆ display_image_cell()

bool display_image_cell ( const char * filename,
int x,
int y )

Fill a single terminal cell with an image.

Parameters
filenameImage file name (PNG supported, loaded from src/art/png/)
xX coordinate in terminal cells
yY coordinate in terminal cells
Returns
true on success, false on failure

Definition at line 54 of file media_output.c.

54 {
55 // Validate parameters
56 if (!filename) {
57 log_msg(ERROR, "media_output", "Invalid filename for fill_cell_with_png");
58 return false;
59 }
60 loaded_visual_t* resource = ready_media(filename, x, y, 1, 1, SCALE_CELL);
61 if (!resource) {
62 log_msg(ERROR, "media_output", "Failed to load image for cell");
63 return false;
64 }
65 return display_image(resource);
66}

◆ display_video_at()

bool display_video_at ( const char * filename,
int x,
int y,
int width,
int height,
scale_type_t scale )

Display a video file at specified coordinates with scaling.

Parameters
filenameVideo file name (MP4 supported, loaded from src/art/mp4/)
xX coordinate in terminal cells
yY coordinate in terminal cells
widthWidth in terminal cells
heightHeight in terminal cells
scaleScaling mode to use
Returns
true on success, false on failure

◆ display_video_background()

bool display_video_background ( const char * filename,
float fps,
bool loop )

Fill the background with a video file scaled to terminal size.

Parameters
filenameVideo file name (MP4 supported, loaded from src/art/mp4/)
fpsFrames per second
loopWhether to loop the video
Returns
true on success, false on failure

◆ media_output_pause()

void media_output_pause ( loaded_visual_t * media)

Pause playback of an animation or video.

Parameters
mediaPointer to a loaded media instance

◆ media_output_play()

void media_output_play ( loaded_visual_t * media)

Start playback of an animation or video Note: This does not handle actual timing, which must be done in the game loop.

Parameters
mediaPointer to a loaded media instance

◆ media_output_reset()

void media_output_reset ( loaded_visual_t * media)

Reset animation or video to the beginning.

Parameters
mediaPointer to a loaded media instance