| 1 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 2 | * Mupen64plus - osd.h * |
| 3 | * Mupen64Plus homepage: http://code.google.com/p/mupen64plus/ * |
| 4 | * Copyright (C) 2008 Nmn, Ebenblues * |
| 5 | * * |
| 6 | * This program is free software; you can redistribute it and/or modify * |
| 7 | * it under the terms of the GNU General Public License as published by * |
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
| 9 | * (at your option) any later version. * |
| 10 | * * |
| 11 | * This program is distributed in the hope that it will be useful, * |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 14 | * GNU General Public License for more details. * |
| 15 | * * |
| 16 | * You should have received a copy of the GNU General Public License * |
| 17 | * along with this program; if not, write to the * |
| 18 | * Free Software Foundation, Inc., * |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * |
| 20 | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
| 21 | |
| 22 | #ifndef __OSD_H__ |
| 23 | #define __OSD_H__ |
| 24 | |
| 25 | #include "main/list.h" |
| 26 | #include "osal/preproc.h" |
| 27 | |
| 28 | /****************************************************************** |
| 29 | osd_corner |
| 30 | 0 1 2 | |
| 31 | \ __|__/ | Offset always effects the same: |
| 32 | | | | +X = Leftward +Y = Upward |
| 33 | 3-| 4 |-5 | With no offset, the text will touch the border. |
| 34 | |_____| | |
| 35 | / | \ | |
| 36 | 6 7 8 | |
| 37 | *******************************************************************/ |
| 38 | enum osd_corner { |
| 39 | OSD_TOP_LEFT, // 0 in the picture above |
| 40 | OSD_TOP_CENTER, // 1 in the picture above |
| 41 | OSD_TOP_RIGHT, // 2 in the picture above |
| 42 | |
| 43 | OSD_MIDDLE_LEFT, // 3 in the picture above |
| 44 | OSD_MIDDLE_CENTER, // 4 in the picture above |
| 45 | OSD_MIDDLE_RIGHT, // 5 in the picture above |
| 46 | |
| 47 | OSD_BOTTOM_LEFT, // 6 in the picture above |
| 48 | OSD_BOTTOM_CENTER, // 7 in the picture above |
| 49 | OSD_BOTTOM_RIGHT, // 8 in the picture above |
| 50 | |
| 51 | OSD_NUM_CORNERS |
| 52 | }; |
| 53 | |
| 54 | enum osd_message_state { |
| 55 | OSD_APPEAR, // OSD message is appearing on the screen |
| 56 | OSD_DISPLAY, // OSD message is being displayed on the screen |
| 57 | OSD_DISAPPEAR, // OSD message is disappearing from the screen |
| 58 | |
| 59 | OSD_NUM_STATES |
| 60 | }; |
| 61 | |
| 62 | enum osd_animation_type { |
| 63 | OSD_NONE, |
| 64 | OSD_FADE, |
| 65 | |
| 66 | OSD_NUM_ANIM_TYPES |
| 67 | }; |
| 68 | |
| 69 | typedef struct { |
| 70 | char *text; // Text that this object will have when displayed |
| 71 | enum osd_corner corner; // One of the 9 corners |
| 72 | float xoffset; // Relative X position |
| 73 | float yoffset; // Relative Y position |
| 74 | float color[3]; // Red, Green, Blue values |
| 75 | float sizebox[4]; // bounding box (xmin, ymin, xmax, ymax) |
| 76 | int state; // display state of current message |
| 77 | enum osd_animation_type animation[OSD_NUM_STATES]; // animations for each display state |
| 78 | unsigned int timeout[OSD_NUM_STATES]; // timeouts for each display state |
| 79 | #define OSD_INFINITE_TIMEOUT 0xffffffff |
| 80 | unsigned int frames; // number of frames in this state |
| 81 | int user_managed; // structure managed by caller and not to be freed by us |
| 82 | struct list_head list; |
| 83 | } osd_message_t; |
| 84 | |
| 85 | enum { R, G, B }; // for referencing color array |
| 86 | |
| 87 | #ifdef __cplusplus |
| 88 | extern "C" { |
| 89 | #endif |
| 90 | |
| 91 | #ifdef M64P_OSD |
| 92 | |
| 93 | void osd_init(int width, int height); |
| 94 | void osd_exit(void); |
| 95 | void osd_render(void); |
| 96 | osd_message_t * osd_new_message(enum osd_corner, const char *, ...); |
| 97 | void osd_update_message(osd_message_t *, const char *, ...); |
| 98 | void osd_delete_message(osd_message_t *); |
| 99 | void osd_message_set_static(osd_message_t *); |
| 100 | void osd_message_set_user_managed(osd_message_t *); |
| 101 | |
| 102 | #else |
| 103 | |
| 104 | static osal_inline void osd_init(int width, int height) |
| 105 | { |
| 106 | } |
| 107 | |
| 108 | static osal_inline void osd_exit(void) |
| 109 | { |
| 110 | } |
| 111 | |
| 112 | static osal_inline void osd_render(void) |
| 113 | { |
| 114 | } |
| 115 | |
| 116 | static osal_inline osd_message_t * osd_new_message(enum osd_corner eCorner, const char *fmt, ...) |
| 117 | { |
| 118 | return NULL; |
| 119 | } |
| 120 | |
| 121 | static osal_inline void osd_update_message(osd_message_t *msg, const char *fmt, ...) |
| 122 | { |
| 123 | } |
| 124 | |
| 125 | static osal_inline void osd_delete_message(osd_message_t *msg) |
| 126 | { |
| 127 | } |
| 128 | |
| 129 | static osal_inline void osd_message_set_static(osd_message_t *msg) |
| 130 | { |
| 131 | } |
| 132 | |
| 133 | static osal_inline void osd_message_set_user_managed(osd_message_t *msg) |
| 134 | { |
| 135 | } |
| 136 | |
| 137 | #endif |
| 138 | |
| 139 | #ifdef __cplusplus |
| 140 | } |
| 141 | #endif |
| 142 | |
| 143 | #endif // __OSD_H__ |
| 144 | |