RetroArch/gfx/gfx_widgets.h

146 lines
4.6 KiB
C
Raw Normal View History

/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - natinusala
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
2020-02-17 00:43:40 +00:00
#ifndef _GFX_WIDGETS_H
#define _GFX_WIDGETS_H
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
2020-01-12 20:46:28 +00:00
#include <formats/image.h>
#include <queues/task_queue.h>
#include <queues/message_queue.h>
#define DEFAULT_BACKDROP 0.75f
#define MSG_QUEUE_PENDING_MAX 32
#define MSG_QUEUE_ONSCREEN_MAX 4
#define MSG_QUEUE_ANIMATION_DURATION 330
#define VOLUME_DURATION 3000
#define SCREENSHOT_DURATION_IN 66
#define SCREENSHOT_DURATION_OUT SCREENSHOT_DURATION_IN*10
#define SCREENSHOT_NOTIFICATION_DURATION 6000
#define CHEEVO_NOTIFICATION_DURATION 4000
#define TASK_FINISHED_DURATION 3000
#define HOURGLASS_INTERVAL 5000
#define HOURGLASS_DURATION 1000
#define GENERIC_MESSAGE_DURATION 3000
2020-03-09 08:55:27 +00:00
/* A widget */
/* TODO: cleanup all unused parameters */
2020-03-09 08:55:27 +00:00
struct gfx_widget
{
/* called when the widgets system is initialized
* -> initialize the widget here */
bool (*init)(bool video_is_threaded, bool fullscreen);
/* called when the widgets system is freed
* -> free the widget here */
void (*free)(void);
/* called when the graphics context is reset
* -> (re)load the textures here */
void (*context_reset)(bool is_threaded,
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path);
/* called when the graphics context is destroyed
* -> release the textures here */
void (*context_destroy)(void);
/* called when the window resolution changes
* -> (re)layout the widget here */
void (*layout)(bool is_threaded, const char *dir_assets, char *font_path);
/* called every frame on the main thread
* -> update the widget logic here */
void (*iterate)(
unsigned width, unsigned height, bool fullscreen,
const char *dir_assets, char *font_path,
bool is_threaded);
/* called every frame
* (on the video thread if threaded video is on)
* -> draw the widget here */
void (*frame)(void* data);
};
typedef struct gfx_widget gfx_widget_t;
extern gfx_widget_t gfx_widget_screenshot;
2020-03-09 08:55:27 +00:00
bool gfx_widgets_init(bool video_is_threaded, bool fullscreen);
2019-08-15 12:56:38 +00:00
2020-02-17 00:43:40 +00:00
void gfx_widgets_free(void);
2020-02-17 00:43:40 +00:00
void gfx_widgets_msg_queue_push(
retro_task_t *task, const char *msg,
unsigned duration,
char *title,
enum message_queue_icon icon,
enum message_queue_category category,
2020-02-17 15:07:37 +00:00
unsigned prio, bool flush,
bool menu_is_alive);
2020-02-17 00:43:40 +00:00
void gfx_widgets_volume_update_and_show(float new_volume,
2020-02-16 22:34:49 +00:00
bool mute);
2020-02-17 00:43:40 +00:00
void gfx_widgets_iterate(
unsigned width, unsigned height, bool fullscreen,
2020-02-16 22:38:24 +00:00
const char *dir_assets, char *font_path,
bool is_threaded);
2020-02-17 00:43:40 +00:00
void gfx_widgets_screenshot_taken(const char *shotname, const char *filename);
2019-10-23 21:15:14 +00:00
/* AI Service functions */
#ifdef HAVE_TRANSLATE
2020-02-17 00:43:40 +00:00
int gfx_widgets_ai_service_overlay_get_state(void);
bool gfx_widgets_ai_service_overlay_set_state(int state);
2019-10-23 21:15:14 +00:00
2020-02-17 00:43:40 +00:00
bool gfx_widgets_ai_service_overlay_load(
2020-01-12 20:46:28 +00:00
char* buffer, unsigned buffer_len,
enum image_type_enum image_type);
2019-10-23 21:15:14 +00:00
2020-02-17 00:43:40 +00:00
void gfx_widgets_ai_service_overlay_unload(void);
#endif
2019-10-23 21:15:14 +00:00
2020-02-17 00:43:40 +00:00
void gfx_widgets_start_load_content_animation(
2020-01-12 20:46:28 +00:00
const char *content_name, bool remove_extension);
2019-08-15 13:50:26 +00:00
2020-02-17 00:43:40 +00:00
void gfx_widgets_cleanup_load_content_animation(void);
2020-02-17 00:43:40 +00:00
void gfx_widgets_context_reset(bool is_threaded,
unsigned width, unsigned height, bool fullscreen,
2020-02-13 17:26:16 +00:00
const char *dir_assets, char *font_path);
2020-02-17 00:43:40 +00:00
void gfx_widgets_push_achievement(const char *title, const char *badge);
/* Warning: not thread safe! */
2020-02-17 00:43:40 +00:00
void gfx_widgets_set_message(char *message);
/* Warning: not thread safe! */
2020-02-17 00:43:40 +00:00
void gfx_widgets_set_libretro_message(const char *message, unsigned duration);
/* All the functions below should be called in
* the video driver - once they are all added, set
* enable_menu_widgets to true for that driver */
2020-02-17 00:43:40 +00:00
void gfx_widgets_frame(void *data);
2020-02-17 00:43:40 +00:00
bool gfx_widgets_set_fps_text(const char *new_fps_text);
2019-09-23 07:22:35 +00:00
2019-05-04 16:26:57 +00:00
#endif