|
Atrinik Client 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00030 #ifndef WIDGET_H 00031 #define WIDGET_H 00032 00033 /* If you want (a LOT of) debug info about widgets, uncomment this */ 00034 /*#define DEBUG_WIDGET*/ 00035 00037 typedef struct widgetdata 00038 { 00040 char *name; 00041 00043 int x1; 00044 00046 int y1; 00047 00049 int wd; 00050 00052 int ht; 00053 00055 int moveable; 00056 00058 int show; 00059 00061 int redraw; 00062 00064 int unique; 00065 00067 int no_kill; 00068 00070 int visible; 00071 00073 int delete_inv; 00074 00076 int save; 00077 00079 int save_width_height; 00080 00082 struct widgetdata *next; 00083 00085 struct widgetdata *prev; 00086 00088 struct widgetdata *inv; 00089 00091 struct widgetdata *inv_rev; 00092 00094 struct widgetdata *env; 00095 00097 struct widgetdata *type_next; 00098 00100 struct widgetdata *type_prev; 00101 00103 void *subwidget; 00104 00106 SDL_Surface *widgetSF; 00107 00109 int WidgetTypeID; 00110 00112 int WidgetSubtypeID; 00113 00115 int WidgetObjID; 00116 00117 uint8 resizeable; 00118 00119 int min_w; 00120 00121 int min_h; 00122 00123 int resize_flags; 00124 00125 int disable_snapping; 00126 } widgetdata; 00127 00129 typedef struct _widget_container 00130 { 00132 int widget_type; 00133 00135 int outer_padding_top; 00136 00138 int outer_padding_bottom; 00139 00141 int outer_padding_left; 00142 00144 int outer_padding_right; 00145 00146 /* these are the top two values of the widgets inside stored here for fast movement and resizing. 00147 * the values are in relation to each border of the container. if a widget's relative co-ordinate 00148 * was equal to one of these values before movement/resizing and then dips below the second top 00149 * value, the client will scan the immediate children of the container to find out what the new 00150 * second top value is after the movement/resizing is complete. this means it doesn't have to keep 00151 * scanning the children for the new highest size during the movement */ 00152 int x_left_buf1; 00153 int x_left_buf2; 00154 int x_right_buf1; 00155 int x_right_buf2; 00156 int y_top_buf1; 00157 int y_top_buf2; 00158 int y_bottom_buf1; 00159 int y_bottom_buf2; 00160 00161 /* Used for custom attributes of a container. */ 00162 void *subcontainer; 00163 } _widget_container; 00164 00165 typedef struct _widget_label 00166 { 00168 char *text; 00169 00171 int font; 00172 00174 const char *color; 00175 } _widget_label; 00176 00177 typedef struct _widget_bitmap 00178 { 00180 int bitmap_id; 00181 } _widget_bitmap; 00182 00184 typedef struct _widget_container_strip 00185 { 00187 int inner_padding; 00188 00190 int horizontal; 00191 00193 int size; 00194 00196 void *subcontainer_strip; 00197 } _widget_container_strip; 00198 00200 typedef struct _menu 00201 { 00203 widgetdata *submenu; 00204 00206 widgetdata *owner; 00207 } _menu; 00208 00213 typedef struct _menuitem 00214 { 00216 void (*menu_func_ptr)(widgetdata *, int, int); 00217 00219 int menu_type; 00220 } _menuitem; 00221 00223 enum _MEvent 00224 { 00225 MOUSE_UP = 1, 00226 MOUSE_DOWN, 00227 MOUSE_MOVE 00228 }; 00229 00231 typedef enum WidgetID 00232 { 00233 MAP_ID, 00234 STATS_ID, 00235 RESIST_ID, 00236 MAIN_LVL_ID, 00237 SKILL_EXP_ID, 00238 REGEN_ID, 00239 SKILL_LVL_ID, 00240 MENU_B_ID, 00241 QUICKSLOT_ID, 00242 CHATWIN_ID, 00243 MSGWIN_ID, 00244 PDOLL_ID, 00245 BELOW_INV_ID, 00246 PLAYER_INFO_ID, 00247 RANGE_ID, 00248 TARGET_ID, 00249 MAIN_INV_ID, 00250 MAPNAME_ID, 00251 IN_CONSOLE_ID, 00252 IN_NUMBER_ID, 00253 FPS_ID, 00254 MPLAYER_ID, 00255 SPELLS_ID, 00256 SKILLS_ID, 00257 PARTY_ID, 00258 CONTAINER_ID, 00259 LABEL_ID, 00260 BITMAP_ID, 00261 00263 TOTAL_WIDGETS 00264 } WidgetID; 00265 00267 enum 00268 { 00270 CONTAINER_STRIP_ID = TOTAL_WIDGETS, 00271 MENU_ID, 00272 MENUITEM_ID, 00273 00275 TOTAL_SUBWIDGETS 00276 }; 00277 00279 enum 00280 { 00281 RESIZE_LEFT = 1, 00282 RESIZE_TOP = 2, 00283 RESIZE_RIGHT = 4, 00284 RESIZE_BOTTOM = 8, 00285 RESIZE_TOPLEFT = RESIZE_TOP | RESIZE_LEFT, 00286 RESIZE_TOPRIGHT = RESIZE_TOP | RESIZE_RIGHT, 00287 RESIZE_BOTTOMRIGHT = RESIZE_BOTTOM | RESIZE_RIGHT, 00288 RESIZE_BOTTOMLEFT = RESIZE_BOTTOM | RESIZE_LEFT 00289 }; 00290 00292 enum 00293 { 00294 MENU_NORMAL, 00295 MENU_SUBMENU, 00296 MENU_CHECKBOX, 00297 MENU_RADIO 00298 }; 00299 00301 typedef struct widgetevent 00302 { 00304 widgetdata *owner; 00305 00307 int x; 00308 00310 int y; 00311 } widgetevent; 00312 00314 typedef struct widgetmove 00315 { 00317 int active; 00318 00320 widgetdata *owner; 00321 00323 int xOffset; 00324 00326 int yOffset; 00327 } widgetmove; 00328 00330 typedef struct widgetresize 00331 { 00333 int active; 00334 00336 widgetdata *owner; 00337 } widgetresize; 00338 00339 extern widgetdata *cur_widget[TOTAL_SUBWIDGETS]; 00340 extern widgetevent widget_mouse_event; 00341 00343 #define WIDGET_REDRAW(__tmp) __tmp->redraw = 1; 00344 00345 /* Macro to redraw all widgets of a particular type. Don't use this often. */ 00346 #define WIDGET_REDRAW_ALL(__id) widget_redraw_all(__id); 00347 00349 #define TEXTWIN(__textwin) ((textwin_struct *) ((__textwin)->subwidget)) 00350 #define CONTAINER(__widget_container) (_widget_container *) (__widget_container->subwidget) 00351 #define LABEL(__widget_label) (_widget_label *) (__widget_label->subwidget) 00352 #define BITMAP(__widget_bitmap) (_widget_bitmap *) (__widget_bitmap->subwidget) 00353 #define CONTAINER_STRIP(__widget_container_strip) \ 00354 (_widget_container_strip *) ( ((_widget_container *) (__widget_container_strip->subwidget)) ->subcontainer) 00355 #define MENU(__menu) \ 00356 (_menu *) ( (( ((_widget_container_strip *) ((_widget_container *) (__menu->subwidget)) ->subcontainer)) ->subcontainer_strip)) 00357 #define MENUITEM(__menuitem) \ 00358 (_menuitem *) ( (( ((_widget_container_strip *) ((_widget_container *) (__menuitem->subwidget)) ->subcontainer)) ->subcontainer_strip)) 00359 00360 #endif
1.7.4