| 1 | #include "stdlib.h" |
|---|
| 2 | #include "platform.h" |
|---|
| 3 | #include "core.h" |
|---|
| 4 | #include "keyboard.h" |
|---|
| 5 | #include "conf.h" |
|---|
| 6 | #include "font.h" |
|---|
| 7 | #include "lang.h" |
|---|
| 8 | #include "gui.h" |
|---|
| 9 | #include "gui_draw.h" |
|---|
| 10 | #include "gui_palette.h" |
|---|
| 11 | #include "gui_menu.h" |
|---|
| 12 | #include "gui_lang.h" |
|---|
| 13 | |
|---|
| 14 | //------------------------------------------------------------------- |
|---|
| 15 | #define MENUSTACK_MAXDEPTH 4 |
|---|
| 16 | |
|---|
| 17 | //------------------------------------------------------------------- |
|---|
| 18 | typedef struct { |
|---|
| 19 | CMenu *menu; |
|---|
| 20 | int curpos; |
|---|
| 21 | int toppos; |
|---|
| 22 | } CMenuStacked; |
|---|
| 23 | |
|---|
| 24 | //------------------------------------------------------------------- |
|---|
| 25 | |
|---|
| 26 | static CMenu *curr_menu; |
|---|
| 27 | static CMenuStacked gui_menu_stack[MENUSTACK_MAXDEPTH]; |
|---|
| 28 | static unsigned int gui_menu_stack_ptr; |
|---|
| 29 | static int gui_menu_curr_item; |
|---|
| 30 | static int gui_menu_top_item; |
|---|
| 31 | static int gui_menu_redraw; |
|---|
| 32 | |
|---|
| 33 | static int count; |
|---|
| 34 | static coord x, y, w, num_lines; |
|---|
| 35 | static int len_bool, len_int, len_enum, len_space, len_br1, len_br2, cl_rect; |
|---|
| 36 | static int int_incr, incr_modified; |
|---|
| 37 | static int c, j; |
|---|
| 38 | static unsigned char *item_color; |
|---|
| 39 | |
|---|
| 40 | //------------------------------------------------------------------- |
|---|
| 41 | static void gui_menu_set_curr_menu(CMenu *menu_ptr, int top_item, int curr_item) { |
|---|
| 42 | curr_menu = menu_ptr; |
|---|
| 43 | gui_menu_top_item = top_item; |
|---|
| 44 | gui_menu_curr_item = curr_item; |
|---|
| 45 | } |
|---|
| 46 | |
|---|
| 47 | //------------------------------------------------------------------- |
|---|
| 48 | void gui_menu_init(CMenu *menu_ptr) { |
|---|
| 49 | if (menu_ptr) { |
|---|
| 50 | if (conf.menu_select_first_entry) |
|---|
| 51 | gui_menu_set_curr_menu(menu_ptr, 0, 0); |
|---|
| 52 | else |
|---|
| 53 | gui_menu_set_curr_menu(menu_ptr, 0, -1); |
|---|
| 54 | gui_menu_stack_ptr = 0; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | num_lines = screen_height/rbf_font_height()-1; |
|---|
| 58 | x = CAM_MENU_BORDERWIDTH; |
|---|
| 59 | w = screen_width-x-x; |
|---|
| 60 | len_bool = rbf_str_width("\x95"); |
|---|
| 61 | len_int = rbf_str_width("99999"); |
|---|
| 62 | len_enum = rbf_str_width("WUBfS3a"); |
|---|
| 63 | len_space = rbf_char_width(' '); |
|---|
| 64 | len_br1 = rbf_char_width('['); |
|---|
| 65 | len_br2 = rbf_char_width(']'); |
|---|
| 66 | cl_rect = rbf_font_height() - 4; |
|---|
| 67 | int_incr = 1; |
|---|
| 68 | |
|---|
| 69 | gui_menu_redraw=2; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | //------------------------------------------------------------------- |
|---|
| 73 | void gui_menu_force_redraw() |
|---|
| 74 | { |
|---|
| 75 | if (gui_get_mode() == GUI_MODE_MENU) |
|---|
| 76 | { |
|---|
| 77 | gui_menu_redraw=2; |
|---|
| 78 | } |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | //------------------------------------------------------------------- |
|---|
| 82 | static void gui_menu_color_selected(color clr) { |
|---|
| 83 | *item_color = (unsigned char)(clr&0xFF); |
|---|
| 84 | gui_menu_redraw=2; |
|---|
| 85 | draw_restore(); |
|---|
| 86 | gui_force_restore(); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | //------------------------------------------------------------------- |
|---|
| 90 | static void gui_menu_back() { |
|---|
| 91 | if (gui_menu_stack_ptr > 0){ |
|---|
| 92 | gui_menu_stack_ptr--; |
|---|
| 93 | gui_menu_set_curr_menu(gui_menu_stack[gui_menu_stack_ptr].menu, gui_menu_stack[gui_menu_stack_ptr].toppos, gui_menu_stack[gui_menu_stack_ptr].curpos); |
|---|
| 94 | gui_menu_redraw=2; |
|---|
| 95 | draw_restore(); |
|---|
| 96 | gui_force_restore(); |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | |
|---|
| 100 | //------------------------------------------------------------------- |
|---|
| 101 | void gui_menu_kbd_process() { |
|---|
| 102 | static char sbuf[7]; |
|---|
| 103 | switch (kbd_get_autoclicked_key() | get_jogdial_direction()) { |
|---|
| 104 | #if CAM_HAS_ERASE_BUTTON |
|---|
| 105 | case KEY_ERASE: |
|---|
| 106 | #else |
|---|
| 107 | case KEY_SHOOT_HALF: |
|---|
| 108 | #endif |
|---|
| 109 | if (conf.user_menu_enable == 3) { |
|---|
| 110 | if (curr_menu->title != LANG_MENU_USER_MENU) { |
|---|
| 111 | /* |
|---|
| 112 | * Add new entry |
|---|
| 113 | * user menu is currently not visible so no redraw necessary |
|---|
| 114 | */ |
|---|
| 115 | mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 1); |
|---|
| 116 | } |
|---|
| 117 | else { |
|---|
| 118 | int x; |
|---|
| 119 | /* |
|---|
| 120 | * Remove entry from menu |
|---|
| 121 | */ |
|---|
| 122 | mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 0); |
|---|
| 123 | |
|---|
| 124 | |
|---|
| 125 | /* |
|---|
| 126 | * Check to see if the last visible entry was deleted and we need need |
|---|
| 127 | * to move up our top menu item. |
|---|
| 128 | */ |
|---|
| 129 | if(gui_menu_top_item) |
|---|
| 130 | if(!curr_menu->menu[gui_menu_top_item + num_lines-1].text) |
|---|
| 131 | gui_menu_top_item--; |
|---|
| 132 | |
|---|
| 133 | /* |
|---|
| 134 | * menu list is smaller so have to redraw everything to get |
|---|
| 135 | * things like scroll bar correct. |
|---|
| 136 | */ |
|---|
| 137 | gui_menu_redraw=2; |
|---|
| 138 | |
|---|
| 139 | /* |
|---|
| 140 | * Count the numer of menu entries |
|---|
| 141 | */ |
|---|
| 142 | for(x = 0; curr_menu->menu[x].text; x++) |
|---|
| 143 | ; |
|---|
| 144 | |
|---|
| 145 | /* |
|---|
| 146 | * if the new menu is smaller than visible menu lines on screen |
|---|
| 147 | * you have to restore full screen before menu redraw. |
|---|
| 148 | * If you don't do this, then a new smaller menu will be drawn |
|---|
| 149 | * on top of the older larger menu |
|---|
| 150 | * |
|---|
| 151 | */ |
|---|
| 152 | if(x < num_lines) |
|---|
| 153 | draw_restore(); |
|---|
| 154 | } |
|---|
| 155 | } |
|---|
| 156 | break; |
|---|
| 157 | case JOGDIAL_LEFT: |
|---|
| 158 | case KEY_UP: |
|---|
| 159 | if (kbd_is_key_pressed(KEY_SHOOT_HALF) || kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) c=4; else c=1; |
|---|
| 160 | for (j=0;j<c;++j){ |
|---|
| 161 | do { |
|---|
| 162 | if (gui_menu_curr_item>0) { |
|---|
| 163 | if (gui_menu_curr_item-1==gui_menu_top_item && gui_menu_top_item>0) |
|---|
| 164 | --gui_menu_top_item; |
|---|
| 165 | --gui_menu_curr_item; |
|---|
| 166 | } else { |
|---|
| 167 | int i; |
|---|
| 168 | while (curr_menu->menu[gui_menu_curr_item+1].text) |
|---|
| 169 | ++gui_menu_curr_item; |
|---|
| 170 | gui_menu_top_item = gui_menu_curr_item - num_lines +1; |
|---|
| 171 | if (gui_menu_top_item<0) gui_menu_top_item=0; |
|---|
| 172 | } |
|---|
| 173 | } while ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || |
|---|
| 174 | (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR); |
|---|
| 175 | int_incr = 1; |
|---|
| 176 | if (gui_menu_redraw == 0) gui_menu_redraw=1; |
|---|
| 177 | } |
|---|
| 178 | break; |
|---|
| 179 | case JOGDIAL_RIGHT: |
|---|
| 180 | case KEY_DOWN: |
|---|
| 181 | if (kbd_is_key_pressed(KEY_SHOOT_HALF) || kbd_is_key_pressed(KEY_ZOOM_IN) || kbd_is_key_pressed(KEY_ZOOM_OUT)) c=4; else c=1; |
|---|
| 182 | for (j=0;j<c;++j){ |
|---|
| 183 | do { |
|---|
| 184 | if (curr_menu->menu[gui_menu_curr_item+1].text) { |
|---|
| 185 | int i; |
|---|
| 186 | for (i=0; i<num_lines-1 && curr_menu->menu[gui_menu_top_item+i].text; ++i); |
|---|
| 187 | if (i==num_lines-1 && curr_menu->menu[gui_menu_top_item+i].text |
|---|
| 188 | && gui_menu_top_item+i-1==gui_menu_curr_item && curr_menu->menu[gui_menu_top_item+i+1].text) |
|---|
| 189 | ++gui_menu_top_item; |
|---|
| 190 | ++gui_menu_curr_item; |
|---|
| 191 | } else { |
|---|
| 192 | gui_menu_curr_item = gui_menu_top_item = 0; |
|---|
| 193 | } |
|---|
| 194 | } while ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || |
|---|
| 195 | (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR); |
|---|
| 196 | int_incr = 1; |
|---|
| 197 | if (gui_menu_redraw == 0) gui_menu_redraw=1; |
|---|
| 198 | } |
|---|
| 199 | break; |
|---|
| 200 | case FRONTDIAL_LEFT: |
|---|
| 201 | case KEY_LEFT: |
|---|
| 202 | if (gui_menu_curr_item>=0) { |
|---|
| 203 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) { |
|---|
| 204 | case MENUITEM_INT: |
|---|
| 205 | { |
|---|
| 206 | if (kbd_is_key_pressed(KEY_ZOOM_OUT)) { |
|---|
| 207 | int_incr=10; |
|---|
| 208 | incr_modified=1; |
|---|
| 209 | } |
|---|
| 210 | if (kbd_is_key_pressed(KEY_ZOOM_IN)) { |
|---|
| 211 | int_incr=100; |
|---|
| 212 | incr_modified=1; |
|---|
| 213 | } |
|---|
| 214 | if (kbd_is_key_pressed(KEY_SHOOT_HALF)) { |
|---|
| 215 | int_incr=1000; |
|---|
| 216 | incr_modified=1; |
|---|
| 217 | } |
|---|
| 218 | } |
|---|
| 219 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) { |
|---|
| 220 | case MENUITEM_ARG_INC: |
|---|
| 221 | *(curr_menu->menu[gui_menu_curr_item].value) -= curr_menu->menu[gui_menu_curr_item].arg; |
|---|
| 222 | break; |
|---|
| 223 | case MENUITEM_ARG_ADDR_INC: |
|---|
| 224 | *(curr_menu->menu[gui_menu_curr_item].value) -= *(int *)(curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 225 | break; |
|---|
| 226 | default: |
|---|
| 227 | *(curr_menu->menu[gui_menu_curr_item].value) -= int_incr; |
|---|
| 228 | break; |
|---|
| 229 | } |
|---|
| 230 | if (*(curr_menu->menu[gui_menu_curr_item].value) < -9999) |
|---|
| 231 | *(curr_menu->menu[gui_menu_curr_item].value) = -9999; |
|---|
| 232 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_UNSIGNED) { |
|---|
| 233 | if (*(curr_menu->menu[gui_menu_curr_item].value) < 0) |
|---|
| 234 | *(curr_menu->menu[gui_menu_curr_item].value) = 0; |
|---|
| 235 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MIN) { |
|---|
| 236 | if (*(curr_menu->menu[gui_menu_curr_item].value) < (unsigned short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF)) |
|---|
| 237 | *(curr_menu->menu[gui_menu_curr_item].value) = (unsigned short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF); |
|---|
| 238 | } |
|---|
| 239 | } else { |
|---|
| 240 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MIN) { |
|---|
| 241 | if (*(curr_menu->menu[gui_menu_curr_item].value) < (short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF)) |
|---|
| 242 | *(curr_menu->menu[gui_menu_curr_item].value) = (short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF); |
|---|
| 243 | } |
|---|
| 244 | } |
|---|
| 245 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) { |
|---|
| 246 | ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); |
|---|
| 247 | } |
|---|
| 248 | if (curr_menu->on_change) { |
|---|
| 249 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 250 | } |
|---|
| 251 | if (incr_modified) { |
|---|
| 252 | int_incr=1; |
|---|
| 253 | incr_modified=0; |
|---|
| 254 | draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 255 | } |
|---|
| 256 | gui_menu_redraw=1; |
|---|
| 257 | break; |
|---|
| 258 | case MENUITEM_BOOL: |
|---|
| 259 | *(curr_menu->menu[gui_menu_curr_item].value) = !(*(curr_menu->menu[gui_menu_curr_item].value)); |
|---|
| 260 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) { |
|---|
| 261 | ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); |
|---|
| 262 | } |
|---|
| 263 | if (curr_menu->on_change) { |
|---|
| 264 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 265 | } |
|---|
| 266 | gui_menu_redraw=1; |
|---|
| 267 | break; |
|---|
| 268 | case MENUITEM_ENUM: |
|---|
| 269 | if (curr_menu->menu[gui_menu_curr_item].value) { |
|---|
| 270 | int c; |
|---|
| 271 | if (kbd_is_key_pressed(KEY_SHOOT_HALF)) c=3; |
|---|
| 272 | else if (kbd_is_key_pressed(KEY_ZOOM_IN)) c=6; |
|---|
| 273 | else if (kbd_is_key_pressed(KEY_ZOOM_OUT)) c=3; |
|---|
| 274 | else c=1; |
|---|
| 275 | ((const char* (*)(int change, int arg))(curr_menu->menu[gui_menu_curr_item].value))(-c, curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 276 | } |
|---|
| 277 | gui_menu_redraw=1; |
|---|
| 278 | break; |
|---|
| 279 | case MENUITEM_UP: |
|---|
| 280 | gui_menu_back(); |
|---|
| 281 | break; |
|---|
| 282 | } |
|---|
| 283 | } else { |
|---|
| 284 | gui_menu_back(); |
|---|
| 285 | } |
|---|
| 286 | break; |
|---|
| 287 | case FRONTDIAL_RIGHT: |
|---|
| 288 | case KEY_RIGHT: |
|---|
| 289 | if (gui_menu_curr_item>=0) { |
|---|
| 290 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){ |
|---|
| 291 | case MENUITEM_INT: |
|---|
| 292 | { |
|---|
| 293 | if (kbd_is_key_pressed(KEY_ZOOM_OUT)) { |
|---|
| 294 | int_incr=10; |
|---|
| 295 | incr_modified=1; |
|---|
| 296 | } |
|---|
| 297 | if (kbd_is_key_pressed(KEY_ZOOM_IN)) { |
|---|
| 298 | int_incr=100; |
|---|
| 299 | incr_modified=1; |
|---|
| 300 | } |
|---|
| 301 | if (kbd_is_key_pressed(KEY_SHOOT_HALF)) { |
|---|
| 302 | int_incr=1000; |
|---|
| 303 | incr_modified=1; |
|---|
| 304 | } |
|---|
| 305 | } |
|---|
| 306 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) { |
|---|
| 307 | case MENUITEM_ARG_INC: |
|---|
| 308 | *(curr_menu->menu[gui_menu_curr_item].value) += curr_menu->menu[gui_menu_curr_item].arg; |
|---|
| 309 | break; |
|---|
| 310 | case MENUITEM_ARG_ADDR_INC: |
|---|
| 311 | *(curr_menu->menu[gui_menu_curr_item].value) += *(int *)(curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 312 | break; |
|---|
| 313 | default: |
|---|
| 314 | *(curr_menu->menu[gui_menu_curr_item].value) += int_incr; |
|---|
| 315 | break; |
|---|
| 316 | } |
|---|
| 317 | if (*(curr_menu->menu[gui_menu_curr_item].value) > 99999) |
|---|
| 318 | *(curr_menu->menu[gui_menu_curr_item].value) = 99999; |
|---|
| 319 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_UNSIGNED) { |
|---|
| 320 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MAX) { |
|---|
| 321 | if (*(curr_menu->menu[gui_menu_curr_item].value) > (unsigned short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF)) |
|---|
| 322 | *(curr_menu->menu[gui_menu_curr_item].value) = (unsigned short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF); |
|---|
| 323 | } |
|---|
| 324 | } else { |
|---|
| 325 | if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MAX) { |
|---|
| 326 | if (*(curr_menu->menu[gui_menu_curr_item].value) > (short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF)) |
|---|
| 327 | *(curr_menu->menu[gui_menu_curr_item].value) = (short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF); |
|---|
| 328 | } |
|---|
| 329 | } |
|---|
| 330 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) { |
|---|
| 331 | ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); |
|---|
| 332 | } |
|---|
| 333 | if (curr_menu->on_change) { |
|---|
| 334 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 335 | } |
|---|
| 336 | if (incr_modified) { |
|---|
| 337 | int_incr=1; |
|---|
| 338 | incr_modified=0; |
|---|
| 339 | draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 340 | } |
|---|
| 341 | gui_menu_redraw=1; |
|---|
| 342 | break; |
|---|
| 343 | case MENUITEM_BOOL: |
|---|
| 344 | *(curr_menu->menu[gui_menu_curr_item].value) = !(*(curr_menu->menu[gui_menu_curr_item].value)); |
|---|
| 345 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) { |
|---|
| 346 | ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); |
|---|
| 347 | } |
|---|
| 348 | if (curr_menu->on_change) { |
|---|
| 349 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 350 | } |
|---|
| 351 | gui_menu_redraw=1; |
|---|
| 352 | break; |
|---|
| 353 | case MENUITEM_ENUM: |
|---|
| 354 | if (curr_menu->menu[gui_menu_curr_item].value) { |
|---|
| 355 | int c; |
|---|
| 356 | if (kbd_is_key_pressed(KEY_SHOOT_HALF)) c=3; |
|---|
| 357 | else if (kbd_is_key_pressed(KEY_ZOOM_IN)) c=6; |
|---|
| 358 | else if (kbd_is_key_pressed(KEY_ZOOM_OUT)) c=3; |
|---|
| 359 | else c=1; |
|---|
| 360 | ((const char* (*)(int change, int arg))(curr_menu->menu[gui_menu_curr_item].value))(+c, curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 361 | } |
|---|
| 362 | gui_menu_redraw=1; |
|---|
| 363 | break; |
|---|
| 364 | case MENUITEM_SUBMENU: |
|---|
| 365 | gui_menu_stack[gui_menu_stack_ptr].menu = curr_menu; |
|---|
| 366 | gui_menu_stack[gui_menu_stack_ptr].curpos = gui_menu_curr_item; |
|---|
| 367 | gui_menu_stack[gui_menu_stack_ptr].toppos = gui_menu_top_item; |
|---|
| 368 | if (conf.menu_select_first_entry) { |
|---|
| 369 | gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, 0); |
|---|
| 370 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR) { |
|---|
| 371 | // ++gui_menu_top_item; |
|---|
| 372 | ++gui_menu_curr_item; |
|---|
| 373 | } |
|---|
| 374 | } |
|---|
| 375 | else |
|---|
| 376 | gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, -1); |
|---|
| 377 | gui_menu_stack_ptr++; |
|---|
| 378 | // FIXME check on stack overrun; |
|---|
| 379 | if (gui_menu_stack_ptr > MENUSTACK_MAXDEPTH){ |
|---|
| 380 | draw_txt_string(0, 0, "E1", MAKE_COLOR(COLOR_RED, COLOR_YELLOW)); |
|---|
| 381 | gui_menu_stack_ptr = 0; |
|---|
| 382 | } |
|---|
| 383 | gui_menu_redraw=2; |
|---|
| 384 | draw_restore(); |
|---|
| 385 | gui_force_restore(); |
|---|
| 386 | break; |
|---|
| 387 | } |
|---|
| 388 | } |
|---|
| 389 | break; |
|---|
| 390 | case KEY_SET: |
|---|
| 391 | if (gui_menu_curr_item>=0) { |
|---|
| 392 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){ |
|---|
| 393 | case MENUITEM_INT: |
|---|
| 394 | switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) { |
|---|
| 395 | default: |
|---|
| 396 | if (kbd_is_key_pressed(KEY_SHOOT_HALF)) *(curr_menu->menu[gui_menu_curr_item].value) = 0; |
|---|
| 397 | break; |
|---|
| 398 | } |
|---|
| 399 | gui_menu_redraw=1; |
|---|
| 400 | break; |
|---|
| 401 | case MENUITEM_BOOL: |
|---|
| 402 | *(curr_menu->menu[gui_menu_curr_item].value) = !(*(curr_menu->menu[gui_menu_curr_item].value)); |
|---|
| 403 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) { |
|---|
| 404 | ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); |
|---|
| 405 | } |
|---|
| 406 | if (curr_menu->on_change) { |
|---|
| 407 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 408 | } |
|---|
| 409 | gui_menu_redraw=1; |
|---|
| 410 | break; |
|---|
| 411 | case MENUITEM_PROC: |
|---|
| 412 | if (curr_menu->menu[gui_menu_curr_item].value) { |
|---|
| 413 | ((void (*)(int arg))(curr_menu->menu[gui_menu_curr_item].value))(curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 414 | if (curr_menu->on_change) { |
|---|
| 415 | curr_menu->on_change(gui_menu_curr_item); |
|---|
| 416 | } |
|---|
| 417 | //gui_menu_set_curr_menu(curr_menu, 0, 0); // restore this if it causes problems |
|---|
| 418 | gui_menu_redraw=2; |
|---|
| 419 | } |
|---|
| 420 | break; |
|---|
| 421 | case MENUITEM_SUBMENU: |
|---|
| 422 | gui_menu_stack[gui_menu_stack_ptr].menu = curr_menu; |
|---|
| 423 | gui_menu_stack[gui_menu_stack_ptr].curpos = gui_menu_curr_item; |
|---|
| 424 | gui_menu_stack[gui_menu_stack_ptr].toppos = gui_menu_top_item; |
|---|
| 425 | if (conf.menu_select_first_entry) { |
|---|
| 426 | gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, 0); |
|---|
| 427 | if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR) { |
|---|
| 428 | // ++gui_menu_top_item; |
|---|
| 429 | ++gui_menu_curr_item; |
|---|
| 430 | } |
|---|
| 431 | } |
|---|
| 432 | else |
|---|
| 433 | gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, -1); |
|---|
| 434 | gui_menu_stack_ptr++; |
|---|
| 435 | // FIXME check on stack overrun; |
|---|
| 436 | if (gui_menu_stack_ptr > MENUSTACK_MAXDEPTH){ |
|---|
| 437 | draw_txt_string(0, 0, "E1", MAKE_COLOR(COLOR_RED, COLOR_YELLOW)); |
|---|
| 438 | gui_menu_stack_ptr = 0; |
|---|
| 439 | } |
|---|
| 440 | gui_menu_redraw=2; |
|---|
| 441 | draw_restore(); |
|---|
| 442 | gui_force_restore(); |
|---|
| 443 | break; |
|---|
| 444 | case MENUITEM_UP: |
|---|
| 445 | gui_menu_back(); |
|---|
| 446 | break; |
|---|
| 447 | case MENUITEM_COLOR_FG: |
|---|
| 448 | case MENUITEM_COLOR_BG: |
|---|
| 449 | draw_restore(); |
|---|
| 450 | item_color=((unsigned char*)(curr_menu->menu[gui_menu_curr_item].value)) + (((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?1:0); |
|---|
| 451 | gui_palette_init(PALETTE_MODE_SELECT, (*item_color)&0xFF, gui_menu_color_selected); |
|---|
| 452 | gui_set_mode(GUI_MODE_PALETTE); |
|---|
| 453 | gui_menu_redraw=2; |
|---|
| 454 | break; |
|---|
| 455 | case MENUITEM_ENUM: |
|---|
| 456 | if (curr_menu->menu[gui_menu_curr_item].value) { |
|---|
| 457 | ((const char* (*)(int change, int arg))(curr_menu->menu[gui_menu_curr_item].value))(+1, curr_menu->menu[gui_menu_curr_item].arg); |
|---|
| 458 | } |
|---|
| 459 | gui_menu_redraw=1; |
|---|
| 460 | break; |
|---|
| 461 | } |
|---|
| 462 | } |
|---|
| 463 | break; |
|---|
| 464 | |
|---|
| 465 | #if CAM_HAS_ZOOM_LEVER |
|---|
| 466 | case KEY_ZOOM_IN: |
|---|
| 467 | /* |
|---|
| 468 | * Move current entry up in menu |
|---|
| 469 | * if in user menu edit mode and viewing user menu |
|---|
| 470 | */ |
|---|
| 471 | if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { |
|---|
| 472 | mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 2); |
|---|
| 473 | if(gui_menu_curr_item < gui_menu_top_item+1) { |
|---|
| 474 | if(gui_menu_curr_item) |
|---|
| 475 | gui_menu_top_item = gui_menu_curr_item-1; |
|---|
| 476 | } |
|---|
| 477 | |
|---|
| 478 | gui_menu_redraw=1; |
|---|
| 479 | } |
|---|
| 480 | else { |
|---|
| 481 | if (int_incr >= 10){ |
|---|
| 482 | int_incr /= 10; |
|---|
| 483 | } |
|---|
| 484 | sprintf(sbuf, "±%d",int_incr); |
|---|
| 485 | draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 486 | draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); |
|---|
| 487 | } |
|---|
| 488 | break; |
|---|
| 489 | |
|---|
| 490 | case KEY_ZOOM_OUT: |
|---|
| 491 | /* |
|---|
| 492 | * Move current entry down in menu |
|---|
| 493 | * if in user menu edit mode and viewing user menu |
|---|
| 494 | */ |
|---|
| 495 | if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { |
|---|
| 496 | mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 3); |
|---|
| 497 | gui_menu_redraw=1; |
|---|
| 498 | if(gui_menu_curr_item > gui_menu_top_item + num_lines -2) { |
|---|
| 499 | if((gui_menu_curr_item < USER_MENU_ITEMS) && curr_menu->menu[gui_menu_curr_item +1].text) |
|---|
| 500 | gui_menu_top_item++; |
|---|
| 501 | } |
|---|
| 502 | } |
|---|
| 503 | else { |
|---|
| 504 | if (int_incr <= 1000){ |
|---|
| 505 | int_incr *= 10; |
|---|
| 506 | } |
|---|
| 507 | sprintf(sbuf, "±%d",int_incr); |
|---|
| 508 | draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); |
|---|
| 509 | } |
|---|
| 510 | break; |
|---|
| 511 | |
|---|
| 512 | case KEY_DISPLAY: |
|---|
| 513 | if (gui_menu_stack_ptr > 0){ |
|---|
| 514 | gui_menu_stack_ptr--; |
|---|
| 515 | gui_menu_set_curr_menu(gui_menu_stack[gui_menu_stack_ptr].menu, gui_menu_stack[gui_menu_stack_ptr].toppos, gui_menu_stack[gui_menu_stack_ptr].curpos); |
|---|
| 516 | gui_menu_redraw=2; |
|---|
| 517 | draw_restore(); |
|---|
| 518 | gui_force_restore(); |
|---|
| 519 | } |
|---|
| 520 | break; |
|---|
| 521 | #else |
|---|
| 522 | case KEY_DISPLAY: |
|---|
| 523 | if (conf.user_menu_enable == 3 && curr_menu->title == LANG_MENU_USER_MENU) { |
|---|
| 524 | if (gui_menu_stack_ptr > 0){ |
|---|
| 525 | gui_menu_stack_ptr--; |
|---|
| 526 | gui_menu_set_curr_menu(gui_menu_stack[gui_menu_stack_ptr].menu, gui_menu_stack[gui_menu_stack_ptr].toppos, gui_menu_stack[gui_menu_stack_ptr].curpos); |
|---|
| 527 | gui_menu_redraw=2; |
|---|
| 528 | draw_restore(); |
|---|
| 529 | gui_force_restore(); |
|---|
| 530 | } |
|---|
| 531 | } |
|---|
| 532 | else { |
|---|
| 533 | if (int_incr <= 1000){ |
|---|
| 534 | int_incr *= 10; |
|---|
| 535 | } |
|---|
| 536 | else { |
|---|
| 537 | int_incr = 1; |
|---|
| 538 | } |
|---|
| 539 | sprintf(sbuf, "±%d",int_incr); |
|---|
| 540 | if (int_incr == 1) { |
|---|
| 541 | draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); |
|---|
| 542 | } |
|---|
| 543 | draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); |
|---|
| 544 | break; |
|---|
| 545 | } |
|---|
| 546 | #endif |
|---|
| 547 | } |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | //------------------------------------------------------------------- |
|---|
| 551 | void gui_menu_draw_initial() { |
|---|
| 552 | color cl=conf.menu_title_color>>8; |
|---|
| 553 | unsigned char wplus=0; |
|---|
| 554 | |
|---|
| 555 | for (count=0; curr_menu->menu[count].text; ++count); |
|---|
| 556 | if (count>num_lines) { |
|---|
| 557 | y = ((screen_height-(num_lines-1)*rbf_font_height())>>1); |
|---|
| 558 | wplus=8; |
|---|
| 559 | // scrollbar background |
|---|
| 560 | draw_filled_rect((x+w), y, (x+w)+wplus, y+num_lines*rbf_font_height()-1, MAKE_COLOR((conf.menu_color>>8)&0xFF, (conf.menu_color>>8)&0xFF)); |
|---|
| 561 | } else { |
|---|
| 562 | if (conf.menu_center) { |
|---|
| 563 | y = (screen_height-(count-1)*rbf_font_height())>>1; |
|---|
| 564 | } else { |
|---|
| 565 | y = ((screen_height-(num_lines-1)*rbf_font_height())>>1); |
|---|
| 566 | } |
|---|
| 567 | } |
|---|
| 568 | if (conf.menu_symbol_enable) |
|---|
| 569 | rbf_draw_string_center_len(x, y-rbf_font_height(), w+wplus, curr_menu->symbol, lang_str(curr_menu->title), conf.menu_title_color); |
|---|
| 570 | else |
|---|
| 571 | rbf_draw_string_center_len(x, y-rbf_font_height(), w+wplus, 0x0, lang_str(curr_menu->title), conf.menu_title_color); |
|---|
| 572 | // if (cl!=COLOR_FG) |
|---|
| 573 | // draw_line(x,y-1,x+w-1+wplus,y-1,COLOR_FG); |
|---|
| 574 | } |
|---|
| 575 | //------------------------------------------------------------------- |
|---|
| 576 | void gui_menu_draw() { |
|---|
| 577 | static char tbuf[64]; |
|---|
| 578 | int imenu, i, j, yy, xx, symbol_width; |
|---|
| 579 | color cl, cl_symbol; |
|---|
| 580 | const char *ch = ""; |
|---|
| 581 | |
|---|
| 582 | if (gui_menu_redraw) { |
|---|
| 583 | if (gui_menu_redraw==2) |
|---|
| 584 | gui_menu_draw_initial(); |
|---|
| 585 | |
|---|
| 586 | gui_menu_redraw=0; |
|---|
| 587 | |
|---|
| 588 | for (imenu=gui_menu_top_item, i=0, yy=y; curr_menu->menu[imenu].text && i<num_lines; ++imenu, ++i, yy+=rbf_font_height()){ |
|---|
| 589 | cl = (gui_menu_curr_item==imenu)?conf.menu_cursor_color:conf.menu_color; |
|---|
| 590 | /* |
|---|
| 591 | * When cursor is over a symbol, force symbol background color to be the menu cursor color but |
|---|
| 592 | * keep the symbol color user defined. |
|---|
| 593 | * old method was to set the symbol color to the symbol background color when the cursor highlighted it. |
|---|
| 594 | * This method allows the user to have any symbol color and background color they want with the restriction |
|---|
| 595 | * that the symbol background color will match the rest of the line when the cursor highlights it. |
|---|
| 596 | * It creates a nice consistent look expecially when the symbol color matches the menu text color. |
|---|
| 597 | * without this mod, there is no way to ever make the symbol color match the color of the rest of text menu line |
|---|
| 598 | * when the cursor highlights a line. |
|---|
| 599 | */ |
|---|
| 600 | cl_symbol=(gui_menu_curr_item==imenu)?MAKE_COLOR((cl>>8)&0xFF,(conf.menu_symbol_color)&0xFF):conf.menu_symbol_color; //color 8Bit=Hintergrund 8Bit=Vordergrund |
|---|
| 601 | |
|---|
| 602 | xx = x; |
|---|
| 603 | |
|---|
| 604 | switch (curr_menu->menu[imenu].type & MENUITEM_MASK) { |
|---|
| 605 | case MENUITEM_BOOL: |
|---|
| 606 | if (conf.menu_symbol_enable) { |
|---|
| 607 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 608 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 609 | symbol_width+=len_space; |
|---|
| 610 | } else { |
|---|
| 611 | symbol_width=0; |
|---|
| 612 | } |
|---|
| 613 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 614 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-len_br1-len_bool-len_br2-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 615 | xx+=rbf_draw_string(xx, yy, " [", cl); |
|---|
| 616 | xx+=rbf_draw_string_len(xx, yy, len_bool, (*(curr_menu->menu[imenu].value))?"\x95":"", cl); |
|---|
| 617 | rbf_draw_string(xx, yy, "] ", cl); |
|---|
| 618 | break; |
|---|
| 619 | case MENUITEM_INT: |
|---|
| 620 | if (conf.menu_symbol_enable) { |
|---|
| 621 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 622 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 623 | symbol_width+=len_space; |
|---|
| 624 | } else { |
|---|
| 625 | symbol_width=0; |
|---|
| 626 | } |
|---|
| 627 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 628 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-len_br1-len_int-len_br2-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 629 | xx+=rbf_draw_string(xx, yy, " [", cl); |
|---|
| 630 | sprintf(tbuf, "%d", *(curr_menu->menu[imenu].value)); |
|---|
| 631 | xx+=rbf_draw_string_right_len(xx, yy, len_int, tbuf, cl); |
|---|
| 632 | rbf_draw_string(xx, yy, "] ", cl); |
|---|
| 633 | break; |
|---|
| 634 | case MENUITEM_SUBMENU: |
|---|
| 635 | if (conf.menu_symbol_enable) { |
|---|
| 636 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 637 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 638 | symbol_width+=len_space+symbol_width; |
|---|
| 639 | sprintf(tbuf, "%s", lang_str(curr_menu->menu[imenu].text)); |
|---|
| 640 | } else { |
|---|
| 641 | sprintf(tbuf, "%s ->", lang_str(curr_menu->menu[imenu].text)); |
|---|
| 642 | symbol_width=0; |
|---|
| 643 | } |
|---|
| 644 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 645 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-symbol_width, tbuf, cl); |
|---|
| 646 | if (conf.menu_symbol_enable) { |
|---|
| 647 | xx+=rbf_draw_symbol(xx, yy, 0x52, cl_symbol); |
|---|
| 648 | rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 649 | } else rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 650 | break; |
|---|
| 651 | case MENUITEM_UP: |
|---|
| 652 | if (conf.menu_symbol_enable) { |
|---|
| 653 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 654 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 655 | symbol_width+=len_space; |
|---|
| 656 | sprintf(tbuf, "%s", lang_str(curr_menu->menu[imenu].text)); |
|---|
| 657 | } else { |
|---|
| 658 | symbol_width=0; |
|---|
| 659 | sprintf(tbuf, "<- %s", lang_str(curr_menu->menu[imenu].text)); |
|---|
| 660 | } |
|---|
| 661 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 662 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-symbol_width, tbuf, cl); |
|---|
| 663 | rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 664 | break; |
|---|
| 665 | case MENUITEM_PROC: |
|---|
| 666 | case MENUITEM_TEXT: |
|---|
| 667 | if (conf.menu_symbol_enable) { |
|---|
| 668 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 669 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 670 | symbol_width+=len_space; |
|---|
| 671 | } else { |
|---|
| 672 | symbol_width=0; |
|---|
| 673 | } |
|---|
| 674 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 675 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 676 | rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 677 | break; |
|---|
| 678 | case MENUITEM_SEPARATOR: |
|---|
| 679 | if (lang_str(curr_menu->menu[imenu].text)[0]) { |
|---|
| 680 | j = rbf_str_width(lang_str(curr_menu->menu[imenu].text)); |
|---|
| 681 | #if defined (CAMERA_g11) || defined (CAMERA_s90) || defined (CAMERA_sx130is) |
|---|
| 682 | xx+=((int)w-j-len_space*2)>>1; |
|---|
| 683 | #else |
|---|
| 684 | xx+=(w-j-len_space*2)>>1; |
|---|
| 685 | #endif |
|---|
| 686 | (conf.menu_symbol_enable)?rbf_draw_char(x, yy, ' ', cl_symbol):rbf_draw_char(x, yy, ' ', cl); |
|---|
| 687 | draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 688 | draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); |
|---|
| 689 | draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 690 | |
|---|
| 691 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 692 | xx+=rbf_draw_string(xx, yy, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 693 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 694 | |
|---|
| 695 | draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 696 | draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); |
|---|
| 697 | draw_filled_rect(xx, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 698 | rbf_draw_char(x+w-len_space, yy, ' ', cl); |
|---|
| 699 | } else { |
|---|
| 700 | rbf_draw_char(x, yy, ' ', cl); |
|---|
| 701 | draw_filled_rect(x+len_space, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 702 | draw_line(x+len_space, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); |
|---|
| 703 | draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, x+w-len_space-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8)); |
|---|
| 704 | rbf_draw_char(x+w-len_space, yy, ' ', cl); |
|---|
| 705 | } |
|---|
| 706 | break; |
|---|
| 707 | case MENUITEM_COLOR_FG: |
|---|
| 708 | case MENUITEM_COLOR_BG: |
|---|
| 709 | if (conf.menu_symbol_enable) { |
|---|
| 710 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 711 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 712 | symbol_width+=len_space; |
|---|
| 713 | } else { |
|---|
| 714 | symbol_width=0; |
|---|
| 715 | } |
|---|
| 716 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 717 | xx+=rbf_draw_string_len(xx, yy, w-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 718 | draw_filled_round_rect(x+w-1-cl_rect-2-len_space, yy+2, x+w-1-2-len_space, yy+rbf_font_height()-1-2, |
|---|
| 719 | MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF, |
|---|
| 720 | ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF)); |
|---|
| 721 | break; |
|---|
| 722 | case MENUITEM_ENUM: |
|---|
| 723 | if (curr_menu->menu[imenu].value) { |
|---|
| 724 | ch=((const char* (*)(int change, int arg))(curr_menu->menu[imenu].value))(0, curr_menu->menu[imenu].arg); |
|---|
| 725 | } |
|---|
| 726 | if (conf.menu_symbol_enable) { |
|---|
| 727 | xx+=rbf_draw_char(xx, yy, ' ', cl_symbol); |
|---|
| 728 | xx+=symbol_width=rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); |
|---|
| 729 | symbol_width+=len_space; |
|---|
| 730 | } else { |
|---|
| 731 | symbol_width=0; |
|---|
| 732 | } |
|---|
| 733 | xx+=rbf_draw_char(xx, yy, ' ', cl); |
|---|
| 734 | xx+=rbf_draw_string_len(xx, yy, w-len_space-len_space-len_br1-len_enum-len_br2-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); |
|---|
| 735 | xx+=rbf_draw_string(xx, yy, " [", cl); |
|---|
| 736 | xx+=rbf_draw_string_right_len(xx, yy, len_enum, ch, cl); |
|---|
| 737 | rbf_draw_string(xx, yy, "] ", cl); |
|---|
| 738 | break; |
|---|
| 739 | } |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | // scrollbar |
|---|
| 743 | if (count>num_lines) { |
|---|
| 744 | i=num_lines*rbf_font_height()-1 -1; // full height |
|---|
| 745 | j=i*num_lines/count; // bar height |
|---|
| 746 | if (j<20) j=20; |
|---|
| 747 | i=(i-j)*((gui_menu_curr_item<0)?0:gui_menu_curr_item)/(count-1); // top pos |
|---|
| 748 | draw_filled_round_rect((x+w)+2, y+1, |
|---|
| 749 | (x+w)+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); |
|---|
| 750 | draw_filled_round_rect((x+w)+2, y+i+j, |
|---|
| 751 | (x+w)+6, y+num_lines*rbf_font_height()-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); |
|---|
| 752 | draw_filled_round_rect((x+w)+2, y+1+i, |
|---|
| 753 | (x+w)+6, y+i+j, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE)); |
|---|
| 754 | // } else { |
|---|
| 755 | // draw_filled_rect((x+w)*FONT_WIDTH+2, y*FONT_HEIGHT+1, |
|---|
| 756 | // (x+w)*FONT_WIDTH+6, (y+count)*FONT_HEIGHT-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); |
|---|
| 757 | } |
|---|
| 758 | } |
|---|
| 759 | } |
|---|