1 /* 2 * gtkatlantic - the gtk+ monopd client, enjoy network monopoly games 3 * 4 * 5 * Copyright © 2002-2015 Sylvain Rochet 6 * 7 * gtkatlantic is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; see the file COPYING. If not, see 19 * <http://www.gnu.org/licenses/>. 20 */ 21 22 #ifndef ENG_MAIN_H 23 #define ENG_MAIN_H 24 25 /* ENG_MAIN: main functions for engine 26 * 27 * 28 * all int functions return 0 if error occur 29 * return >0 when sucess 30 * 31 * all functions kill process if error occurs when allocate memory 32 */ 33 34 35 /* ---- info about: x, y, z 36 * 37 * o-------- x 38 * /| 39 * / | 40 * / | 41 * / | 42 * z | 43 * y 44 * 45 * z = ground, 0 is background 46 * 47 */ 48 49 /* ---- struct hierarchy 50 * 51 * eng > global engine variables 52 * `-> eng_alpha > alpha tables 53 * eng_frame > property of frames (height, width, ...) 54 * |-> eng_zone_upd > display zone to update (x1, y1, x2, y1) 55 * `-> eng_obj > property of pictures (x, y, height, width, ...) 56 */ 57 58 #include <glib.h> 59 #include <gdk-pixbuf/gdk-pixbuf.h> 60 #include "eng_list.h" 61 62 63 #define MAX_HEIGHT 0xffff 64 #define MAX_WIDTH 0xffff 65 66 #define ENG_DEBUG FALSE 67 68 69 /* -- prototypes for eng_main.c -- */ 70 typedef struct eng_coord_ eng_coord; 71 typedef struct eng_alpha_ eng_alpha; 72 typedef struct _eng_ _eng; 73 extern _eng *eng; 74 typedef struct eng_frame_ eng_frame; 75 typedef struct eng_obj_ eng_obj; 76 typedef struct eng_zone_ eng_zone; 77 78 void eng_init(); 79 void eng_close(); 80 81 eng_frame* eng_frame_create(); 82 void eng_frame_destroy (eng_frame *f); 83 void eng_frame_destroy_all(); 84 void eng_frame_reset (eng_frame *f); 85 void eng_frame_free_zoneupd (eng_frame *f); 86 void eng_frame_set_compute (eng_frame *f); 87 void eng_frame_unset_compute (eng_frame *f); 88 void eng_frame_clean (eng_frame *f); 89 void eng_frame_set_height (eng_frame *f, guint16 height); 90 void eng_frame_set_width (eng_frame *f, guint16 width); 91 void eng_frame_showarg (eng_frame *f); 92 93 eng_obj* eng_pic_create (eng_frame *f); 94 void eng_pic_destroy (eng_obj *o); //sent a call to destroy pic 95 void eng_pic_free (eng_obj *o); //real destruction, never use is directly 96 void eng_pic_reset (eng_obj *o); 97 void eng_pic_show (eng_obj *o); 98 void eng_pic_unshow (eng_obj *o); 99 void eng_pic_redraw (eng_obj *o); 100 void eng_pic_set_x (eng_obj *o, guint16 x); 101 void eng_pic_set_y (eng_obj *o, guint16 y); 102 void eng_pic_set_z (eng_obj *o, guint16 z); 103 void eng_pic_set_height (eng_obj *o, guint16 height); 104 void eng_pic_set_width (eng_obj *o, guint16 width); 105 void eng_pic_set_alpha (eng_obj *o, guint8 alpha); 106 void eng_pic_unset_alpha (eng_obj *o); 107 void eng_pic_set_bgcolor (eng_obj *o, guint32 bgcolor); 108 void eng_pic_unset_bgcolor (eng_obj *o); 109 void eng_pic_set_pixbuf (eng_obj *o, GdkPixbuf *pixbuff); 110 void eng_pic_showarg (eng_obj *o); 111 gboolean eng_pic_test (eng_obj *o); 112 /* -- end of prototypes -- */ 113 114 115 struct eng_coord_ { 116 117 gint32 x1; 118 gint32 y1; 119 gint32 x2; 120 gint32 y2; 121 122 gint32 x; 123 gint32 y; 124 gint32 width; 125 gint32 height; 126 gint32 stride; 127 eng_list_e *entry; 128 }; 129 130 131 struct _eng_ { 132 133 eng_alpha *alpha; // alpha tables 134 eng_list *obj; 135 eng_list *frame; 136 137 } ; 138 139 140 struct eng_alpha_ { 141 142 guint8 fg[256][256]; // foreground [alpha][fg] 143 guint8 bg[256][256]; // background [alpha][bg] 144 145 } ; 146 147 148 struct eng_frame_ { 149 150 gboolean compute; // compute/or not the frame 151 152 guint16 width; // set the width of out buffer 153 guint16 height; // set the height of out buffer 154 155 guchar * bufout; // bufout contain image would you want to draw 156 157 // PRIVATE 158 guint32 memalloc; // how much mem is allocated for buf 159 160 guint16 num_zone; // number of zones to update 161 guint16 x_min; // min/max of zone to refresh 162 guint16 y_min; 163 guint16 x_max; 164 guint16 y_max; 165 166 eng_list *obj; 167 eng_list *zone_upd; 168 169 eng_list_e *entry; // entry in frame list 170 }; 171 172 173 struct eng_obj_ { 174 175 eng_frame *frame; 176 177 gboolean show; // show/hide the pic 178 gboolean destroy; // destroy this picture 179 180 guint16 x; // x position 181 guint16 y; // y position 182 guint16 z; // z position (ground) 183 184 guint16 width; // width of img 185 guint16 height; // height of img 186 187 gboolean have_alpha; // have an alpha 188 gboolean have_bgcolor; // have a backgroundcolor 189 190 guint8 alpha; // alpha value 191 guint8 bgcolor[3]; // background color 192 193 GdkPixbuf *pixbuf; // pixbuf contain image data 194 195 // PRIVATE 196 gboolean change; // if pic arg has changed 197 198 guint16 x_old; // x position old 199 guint16 y_old; // y position old 200 201 guint16 width_old; // width of img old 202 guint16 height_old; // height of img old 203 204 eng_list_e *entry; // entry in frame object list 205 eng_list_e *entry_main; // entry in general object list 206 eng_list_e *entry_valid; // entry in tmp valid list 207 eng_list_e *entry_show; // entry in tmp show list 208 eng_list_e *entry_modif; // entry in tmp modif list 209 eng_list_e *entry_zone; // entry in zone modif list 210 }; 211 212 213 struct eng_zone_ { 214 215 gint32 x1; 216 gint32 y1; 217 gint32 x2; 218 gint32 y2; 219 gint32 height; 220 gint32 width; 221 guchar *aux; 222 }; 223 224 #endif /* ENG_MAIN_H */ 225