|
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 #include <global.h> 00031 00033 enum 00034 { 00036 BUTTON_SPELLS, 00038 BUTTON_SKILLS, 00040 BUTTON_PARTY, 00042 BUTTON_MPLAYER, 00044 BUTTON_MAP, 00046 BUTTON_QUEST, 00048 BUTTON_HELP, 00050 BUTTON_SETTINGS, 00051 00053 NUM_BUTTONS 00054 }; 00055 00057 static button_struct buttons[NUM_BUTTONS]; 00059 static int button_images[NUM_BUTTONS] = 00060 { 00061 BITMAP_ICON_MAGIC, BITMAP_ICON_SKILL, BITMAP_ICON_PARTY, BITMAP_ICON_MUSIC, BITMAP_ICON_MAP, BITMAP_ICON_QUEST, -1, BITMAP_ICON_COGS 00062 }; 00064 static const char *const button_tooltips[NUM_BUTTONS] = 00065 { 00066 "Spells", "Skills", "Party", "Music player", "Region map", "Quest list", "Help", "Settings" 00067 }; 00069 static uint8 did_init = 0; 00070 00074 void widget_menubuttons(widgetdata *widget) 00075 { 00076 size_t i; 00077 const char *text; 00078 int x, y; 00079 00080 /* Initialize buttons. */ 00081 if (!did_init) 00082 { 00083 did_init = 1; 00084 00085 for (i = 0; i < NUM_BUTTONS; i++) 00086 { 00087 button_create(&buttons[i]); 00088 buttons[i].bitmap = BITMAP_BUTTON_RECT; 00089 buttons[i].bitmap_over = BITMAP_BUTTON_RECT_HOVER; 00090 buttons[i].bitmap_pressed = BITMAP_BUTTON_RECT_DOWN; 00091 } 00092 00093 buttons[BUTTON_HELP].flags |= TEXT_MARKUP; 00094 buttons[BUTTON_HELP].font = FONT_SANS16; 00095 } 00096 00097 sprite_blt(Bitmaps[BITMAP_MENU_BUTTONS], widget->x1, widget->y1, NULL, NULL); 00098 00099 x = 4; 00100 y = 3; 00101 00102 /* Render the buttons. */ 00103 for (i = 0; i < NUM_BUTTONS; i++) 00104 { 00105 if (i && !(i % 2)) 00106 { 00107 x = 4; 00108 y += Bitmaps[buttons[i].bitmap]->bitmap->h + 1; 00109 } 00110 00111 text = NULL; 00112 00113 if (i == BUTTON_HELP) 00114 { 00115 text = "<y=2>?"; 00116 } 00117 else if (i == BUTTON_SPELLS) 00118 { 00119 buttons[i].pressed = cur_widget[SPELLS_ID]->show; 00120 } 00121 else if (i == BUTTON_MPLAYER) 00122 { 00123 buttons[i].pressed = cur_widget[MPLAYER_ID]->show; 00124 } 00125 else if (i == BUTTON_SKILLS) 00126 { 00127 buttons[i].pressed = cur_widget[SKILLS_ID]->show; 00128 } 00129 else if (i == BUTTON_PARTY) 00130 { 00131 buttons[i].pressed = cur_widget[PARTY_ID]->show; 00132 } 00133 00134 buttons[i].x = widget->x1 + x; 00135 buttons[i].y = widget->y1 + y; 00136 button_render(&buttons[i], text); 00137 button_tooltip(&buttons[i], FONT_ARIAL10, button_tooltips[i]); 00138 00139 if (button_images[i] != -1) 00140 { 00141 sprite_blt(Bitmaps[button_images[i]], widget->x1 + x, widget->y1 + y, NULL, NULL); 00142 } 00143 00144 x += Bitmaps[buttons[i].bitmap]->bitmap->w + 3; 00145 } 00146 } 00147 00155 void widget_menubuttons_event(widgetdata *widget, SDL_Event *event) 00156 { 00157 size_t i; 00158 00159 (void) widget; 00160 00161 for (i = 0; i < NUM_BUTTONS; i++) 00162 { 00163 if (button_event(&buttons[i], event)) 00164 { 00165 if (i == BUTTON_SPELLS) 00166 { 00167 cur_widget[SPELLS_ID]->show = !cur_widget[SPELLS_ID]->show; 00168 SetPriorityWidget(cur_widget[SPELLS_ID]); 00169 } 00170 else if (i == BUTTON_SKILLS) 00171 { 00172 cur_widget[SKILLS_ID]->show = !cur_widget[SKILLS_ID]->show; 00173 SetPriorityWidget(cur_widget[SKILLS_ID]); 00174 } 00175 else if (i == BUTTON_PARTY) 00176 { 00177 if (cur_widget[PARTY_ID]->show) 00178 { 00179 cur_widget[PARTY_ID]->show = 0; 00180 } 00181 else 00182 { 00183 send_command_check("/party list"); 00184 } 00185 } 00186 else if (i == BUTTON_MPLAYER) 00187 { 00188 cur_widget[MPLAYER_ID]->show = !cur_widget[MPLAYER_ID]->show; 00189 SetPriorityWidget(cur_widget[MPLAYER_ID]); 00190 } 00191 else if (i == BUTTON_MAP) 00192 { 00193 send_command("/region_map"); 00194 } 00195 else if (i == BUTTON_QUEST) 00196 { 00197 keybind_process_command("?QLIST"); 00198 } 00199 else if (i == BUTTON_HELP) 00200 { 00201 show_help("main"); 00202 } 00203 else if (i == BUTTON_SETTINGS) 00204 { 00205 /* Popup will block any future events, including the mouse 00206 * being released, so we have to take care of clearing the 00207 * pressed state of the button ourselves. */ 00208 buttons[i].pressed = 0; 00209 settings_open(); 00210 } 00211 00212 break; 00213 } 00214 } 00215 }
1.7.4