Changeset 1299
- Timestamp:
- 08/20/11 00:38:07 (22 months ago)
- Location:
- trunk/core
- Files:
-
- 3 edited
-
gui_draw.c (modified) (1 diff)
-
gui_menu.c (modified) (12 diffs)
-
gui_space.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/gui_draw.c
r1250 r1299 254 254 //------------------------------------------------------------------- 255 255 256 // Local variables set up by draw_rectangle, and used in fill_rect 256 257 static unsigned int xMin, yMin, xMax, yMax; 257 258 -
trunk/core/gui_menu.c
r1292 r1299 35 35 static int len_bool, len_int, len_enum, len_space, len_br1, len_br2, cl_rect; 36 36 static int int_incr, incr_modified; 37 static int c, j;38 37 static unsigned char *item_color; 39 38 … … 49 48 if (menu_ptr) { 50 49 if (conf.menu_select_first_entry) 51 gui_menu_set_curr_menu(menu_ptr, 0, 0);50 gui_menu_set_curr_menu(menu_ptr, 0, 0); 52 51 else 53 gui_menu_set_curr_menu(menu_ptr, 0, -1);52 gui_menu_set_curr_menu(menu_ptr, 0, -1); 54 53 gui_menu_stack_ptr = 0; 55 54 } 56 55 57 56 num_lines = screen_height/rbf_font_height()-1; 58 57 x = CAM_MENU_BORDERWIDTH; … … 66 65 cl_rect = rbf_font_height() - 4; 67 66 int_incr = 1; 68 67 69 68 gui_menu_redraw=2; 70 69 } 71 70 72 71 //------------------------------------------------------------------- 72 int gui_menu_rows() 73 { 74 int n; 75 // Count the numer of rows in current menu 76 for(n = 0; curr_menu->menu[n].text; n++); 77 return n; 78 } 79 80 //------------------------------------------------------------------- 81 // Called from other gui functions to force redraw of menu 73 82 void gui_menu_force_redraw() 74 83 { 75 84 if (gui_get_mode() == GUI_MODE_MENU) 76 85 { 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; 86 gui_menu_redraw = 2; 87 } 88 } 89 90 //------------------------------------------------------------------- 91 // Full screen erase and redraw of menu 92 static void gui_menu_erase_and_redraw() 93 { 94 gui_menu_redraw = 2; 85 95 draw_restore(); 86 96 gui_force_restore(); … … 88 98 89 99 //------------------------------------------------------------------- 100 // Function passed to gui_palette_init 101 // This is called when a new color is selected to update the menu / config value 102 static void gui_menu_color_selected(color clr) 103 { 104 *item_color = (unsigned char)(clr&0xFF); 105 gui_menu_erase_and_redraw(); 106 } 107 108 //------------------------------------------------------------------- 109 // Return to previous menu on stack 90 110 static void gui_menu_back() { 91 if (gui_menu_stack_ptr > 0){ 111 if (gui_menu_stack_ptr > 0) 112 { 92 113 gui_menu_stack_ptr--; 93 114 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 //------------------------------------------------------------------- 115 gui_menu_erase_and_redraw(); 116 } 117 } 118 119 //------------------------------------------------------------------- 120 // Helper functions for gui_menu_kbd_process 121 // common code blocks extracted to try and make it easier to understand 122 123 // If updating an 'int' value check if other buttons are also pressed, and set increment accordingly 124 // E.G. if ZOOM_OUT is held then RIGHT pressed the 'int' value will be incremented by 10, ZOOM_IN + RIGHT increment by 100 125 static void get_int_incr_from_button() 126 { 127 if (kbd_is_key_pressed(KEY_ZOOM_OUT)) 128 { 129 int_incr=10; 130 incr_modified=1; 131 } 132 if (kbd_is_key_pressed(KEY_ZOOM_IN)) 133 { 134 int_incr=100; 135 incr_modified=1; 136 } 137 if (kbd_is_key_pressed(KEY_SHOOT_HALF)) 138 { 139 int_incr=1000; 140 incr_modified=1; 141 } 142 } 143 144 // After updating a value check for callback and on_change functions and call if necessary 145 static void do_callback() 146 { 147 if ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) == MENUITEM_ARG_CALLBACK && curr_menu->menu[gui_menu_curr_item].arg) 148 { 149 ((void (*)())(curr_menu->menu[gui_menu_curr_item].arg))(); 150 } 151 152 if (curr_menu->on_change) 153 { 154 curr_menu->on_change(gui_menu_curr_item); 155 } 156 } 157 158 // Update an 'int' value, direction = 1 for increment, -1 for decrement 159 static void update_int_value(int direction) 160 { 161 // set amount to increment by (int_incr) if other buttons pressed 162 get_int_incr_from_button(); 163 164 // do update based on 'int' sub-type 165 switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_ARG_MASK) 166 { 167 case MENUITEM_ARG_INC: 168 *(curr_menu->menu[gui_menu_curr_item].value) += curr_menu->menu[gui_menu_curr_item].arg * direction; 169 break; 170 case MENUITEM_ARG_ADDR_INC: 171 *(curr_menu->menu[gui_menu_curr_item].value) += *(int *)(curr_menu->menu[gui_menu_curr_item].arg) * direction; 172 break; 173 default: 174 *(curr_menu->menu[gui_menu_curr_item].value) += int_incr * direction; 175 break; 176 } 177 178 // Limit new value to defined bounds 179 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_UNSIGNED) 180 { 181 if (*(curr_menu->menu[gui_menu_curr_item].value) < 0) 182 *(curr_menu->menu[gui_menu_curr_item].value) = 0; 183 184 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MIN) 185 { 186 if (*(curr_menu->menu[gui_menu_curr_item].value) < (unsigned short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF)) 187 *(curr_menu->menu[gui_menu_curr_item].value) = (unsigned short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF); 188 } 189 } 190 else 191 { 192 if (*(curr_menu->menu[gui_menu_curr_item].value) < -9999) 193 *(curr_menu->menu[gui_menu_curr_item].value) = -9999; 194 195 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MIN) 196 { 197 if (*(curr_menu->menu[gui_menu_curr_item].value) < (short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF)) 198 *(curr_menu->menu[gui_menu_curr_item].value) = (short)(curr_menu->menu[gui_menu_curr_item].arg & 0xFFFF); 199 } 200 } 201 202 if (*(curr_menu->menu[gui_menu_curr_item].value) > 99999) 203 *(curr_menu->menu[gui_menu_curr_item].value) = 99999; 204 205 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_UNSIGNED) 206 { 207 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MAX) 208 { 209 if (*(curr_menu->menu[gui_menu_curr_item].value) > (unsigned short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF)) 210 *(curr_menu->menu[gui_menu_curr_item].value) = (unsigned short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF); 211 } 212 } 213 else 214 { 215 if ( curr_menu->menu[gui_menu_curr_item].type & MENUITEM_F_MAX) 216 { 217 if (*(curr_menu->menu[gui_menu_curr_item].value) > (short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF)) 218 *(curr_menu->menu[gui_menu_curr_item].value) = (short)((curr_menu->menu[gui_menu_curr_item].arg>>16) & 0xFFFF); 219 } 220 } 221 222 // execute custom callback and on_change functions 223 do_callback(); 224 225 // reset int_incr if necessary 226 if (incr_modified) 227 { 228 int_incr=1; 229 incr_modified=0; 230 draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); 231 } 232 233 // force menu redraw 234 gui_menu_redraw=1; 235 } 236 237 // Update a 'bool' value 238 static void update_bool_value() 239 { 240 // update value 241 *(curr_menu->menu[gui_menu_curr_item].value) = !(*(curr_menu->menu[gui_menu_curr_item].value)); 242 243 // execute custom callback and on_change functions 244 do_callback(); 245 246 // force menu redraw 247 gui_menu_redraw=1; 248 } 249 250 // Update an 'enum' value, direction = 1 for increment, -1 for decrement 251 static void update_enum_value(int direction) 252 { 253 // update value 254 if (curr_menu->menu[gui_menu_curr_item].value) 255 { 256 int c; 257 if (kbd_is_key_pressed(KEY_SHOOT_HALF)) c=3; 258 else if (kbd_is_key_pressed(KEY_ZOOM_IN)) c=6; 259 else if (kbd_is_key_pressed(KEY_ZOOM_OUT)) c=3; 260 else c=1; 261 ((const char* (*)(int change, int arg))(curr_menu->menu[gui_menu_curr_item].value))(c*direction, curr_menu->menu[gui_menu_curr_item].arg); 262 } 263 264 // force menu redraw 265 gui_menu_redraw=1; 266 } 267 268 // Open a sub-menu 269 static void select_sub_menu() 270 { 271 // push current menu on stack 272 gui_menu_stack[gui_menu_stack_ptr].menu = curr_menu; 273 gui_menu_stack[gui_menu_stack_ptr].curpos = gui_menu_curr_item; 274 gui_menu_stack[gui_menu_stack_ptr].toppos = gui_menu_top_item; 275 276 // Select first item in menu, (or none) 277 if (conf.menu_select_first_entry) 278 { 279 gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, 0); 280 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) 281 { 282 //++gui_menu_top_item; 283 ++gui_menu_curr_item; 284 } 285 } 286 else 287 gui_menu_set_curr_menu((CMenu*)(curr_menu->menu[gui_menu_curr_item].value), 0, -1); 288 289 gui_menu_stack_ptr++; 290 291 // FIXME check on stack overrun; 292 if (gui_menu_stack_ptr > MENUSTACK_MAXDEPTH) 293 { 294 draw_txt_string(0, 0, "E1", MAKE_COLOR(COLOR_RED, COLOR_YELLOW)); 295 gui_menu_stack_ptr = 0; 296 } 297 298 // Force full redraw 299 gui_menu_erase_and_redraw(); 300 } 301 302 // Move up / down in menu, adjusting scroll position if needed 303 // increment = -1 to move up, 1 to move down 304 static void gui_menu_updown(int increment) 305 { 306 int c, j; 307 308 // Determine number of rows to move (1 or 4) 309 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; 310 311 for (j = 0; j < c; ++j) 312 { 313 do 314 { 315 // Move to next or previous row 316 gui_menu_curr_item += increment; 317 318 if (gui_menu_curr_item < 0) // Off top, move to bottom 319 { 320 gui_menu_curr_item = gui_menu_rows() - 1; 321 gui_menu_top_item = gui_menu_curr_item - num_lines + 1; 322 } 323 else if (gui_menu_curr_item >= gui_menu_rows()) // Off bottom, move to top 324 { 325 gui_menu_curr_item = gui_menu_top_item = 0; 326 } 327 else if (increment == 1) // Still in menu, if moving down adjust scroll if needed 328 { 329 if (gui_menu_curr_item - gui_menu_top_item >= num_lines - 1) 330 { 331 gui_menu_top_item = gui_menu_curr_item - num_lines + 2; 332 if (gui_menu_top_item + num_lines > gui_menu_rows()) gui_menu_top_item = gui_menu_rows() - num_lines; 333 } 334 } 335 else // Still in menu, and moving up, adjust scroll 336 { 337 if (gui_menu_curr_item == gui_menu_top_item) 338 --gui_menu_top_item; 339 } 340 341 // Check in case scroll moved off top of menu 342 if (gui_menu_top_item < 0) gui_menu_top_item = 0; 343 } while ((curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_TEXT || 344 (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK)==MENUITEM_SEPARATOR); 345 346 // Reset amount to increment integer values by 347 int_incr = 1; 348 349 // Redraw menu if needed 350 if (gui_menu_redraw == 0) gui_menu_redraw=1; 351 } 352 } 353 354 //------------------------------------------------------------------- 355 // Process button presses when in GUI_MODE_MENU mode 101 356 void gui_menu_kbd_process() { 102 static char sbuf[7]; 357 static char sbuf[7]; 358 103 359 switch (kbd_get_autoclicked_key() | get_jogdial_direction()) { 104 360 #if CAM_HAS_ERASE_BUTTON … … 107 363 case KEY_SHOOT_HALF: 108 364 #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; 365 if (conf.user_menu_enable == 3) { 366 if (curr_menu->title != LANG_MENU_USER_MENU) { 367 /* 368 * Add new entry 369 * user menu is currently not visible so no redraw necessary 370 */ 371 mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 1); 372 } 373 else { 374 /* 375 * Remove entry from menu 376 */ 377 mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 0); 378 379 /* 380 * Check to see if the last visible entry was deleted and we need need 381 * to move up our top menu item. 382 */ 383 if(gui_menu_top_item) 384 if(!curr_menu->menu[gui_menu_top_item + num_lines-1].text) 385 gui_menu_top_item--; 386 387 /* 388 * menu list is smaller so have to redraw everything to get 389 * things like scroll bar correct. 390 */ 391 gui_menu_redraw=2; 392 393 /* 394 * if the new menu is smaller than visible menu lines on screen 395 * you have to restore full screen before menu redraw. 396 * If you don't do this, then a new smaller menu will be drawn 397 * on top of the older larger menu 398 * 399 */ 400 if(gui_menu_rows() < num_lines) 401 draw_restore(); 402 } 403 } 404 break; 157 405 case JOGDIAL_LEFT: 158 406 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 } 407 gui_menu_updown(-1); 178 408 break; 179 409 case JOGDIAL_RIGHT: 180 410 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 } 411 gui_menu_updown(1); 199 412 break; 200 413 case FRONTDIAL_LEFT: 201 414 case KEY_LEFT: 202 if (gui_menu_curr_item >=0) {415 if (gui_menu_curr_item >= 0) { 203 416 switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK) { 204 417 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; 418 update_int_value(-1); 257 419 break; 258 420 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; 421 update_bool_value(); 267 422 break; 268 423 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; 424 update_enum_value(-1); 278 425 break; 279 426 case MENUITEM_UP: … … 287 434 case FRONTDIAL_RIGHT: 288 435 case KEY_RIGHT: 289 if (gui_menu_curr_item >=0) {436 if (gui_menu_curr_item >= 0) { 290 437 switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){ 291 438 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; 439 update_int_value(1); 342 440 break; 343 441 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; 442 update_bool_value(); 352 443 break; 353 444 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; 445 update_enum_value(1); 363 446 break; 364 447 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(); 448 select_sub_menu(); 386 449 break; 387 450 } … … 389 452 break; 390 453 case KEY_SET: 391 if (gui_menu_curr_item >=0) {454 if (gui_menu_curr_item >= 0) { 392 455 switch (curr_menu->menu[gui_menu_curr_item].type & MENUITEM_MASK){ 393 456 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; 457 if (kbd_is_key_pressed(KEY_SHOOT_HALF)) 458 { 459 *(curr_menu->menu[gui_menu_curr_item].value) = 0; 460 gui_menu_redraw=1; 461 } 462 break; 401 463 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; 464 update_bool_value(); 410 465 break; 411 466 case MENUITEM_PROC: 412 if (curr_menu->menu[gui_menu_curr_item].value) { 467 if (curr_menu->menu[gui_menu_curr_item].value) 468 { 413 469 ((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) { 470 if (curr_menu->on_change) 471 { 415 472 curr_menu->on_change(gui_menu_curr_item); 416 473 } … … 420 477 break; 421 478 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(); 479 select_sub_menu(); 443 480 break; 444 481 case MENUITEM_UP: … … 454 491 break; 455 492 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 } 493 update_enum_value(1); 459 494 gui_menu_redraw=1; 460 495 break; … … 465 500 #if CAM_HAS_ZOOM_LEVER 466 501 case KEY_ZOOM_IN: 467 /*468 * Move current entry up in menu469 * if in user menu edit mode and viewing user menu470 */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;502 /* 503 * Move current entry up in menu 504 * if in user menu edit mode and viewing user menu 505 */ 506 if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { 507 mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 2); 508 if(gui_menu_curr_item < gui_menu_top_item+1) { 509 if(gui_menu_curr_item) 510 gui_menu_top_item = gui_menu_curr_item-1; 511 } 512 513 gui_menu_redraw=1; 514 } 515 else { 516 if (int_incr >= 10){ 517 int_incr /= 10; 518 } 519 sprintf(sbuf, "±%d",int_incr); 520 draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); 521 draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); 522 } 523 break; 489 524 490 525 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; 526 /* 527 * Move current entry down in menu 528 * if in user menu edit mode and viewing user menu 529 */ 530 if( (conf.user_menu_enable == 3) && (curr_menu->title == LANG_MENU_USER_MENU)) { 531 mod_user_menu(curr_menu->menu[gui_menu_curr_item],&gui_menu_curr_item, 3); 532 if(gui_menu_curr_item > gui_menu_top_item + num_lines -2) { 533 if((gui_menu_curr_item < USER_MENU_ITEMS) && curr_menu->menu[gui_menu_curr_item +1].text) 534 gui_menu_top_item++; 535 } 536 537 gui_menu_redraw=1; 538 } 539 else { 540 if (int_incr <= 1000){ 541 int_incr *= 10; 542 } 543 sprintf(sbuf, "±%d",int_incr); 544 draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); 545 } 546 break; 511 547 512 548 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 } 549 gui_menu_back(); 520 550 break; 521 551 #else 522 552 case KEY_DISPLAY: 523 553 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 } 554 gui_menu_back(); 531 555 } 532 556 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;557 if (int_incr <= 1000){ 558 int_incr *= 10; 559 } 560 else { 561 int_incr = 1; 562 } 563 sprintf(sbuf, "±%d",int_incr); 564 if (int_incr == 1) { 565 draw_string(FONT_WIDTH*2,0," ", MAKE_COLOR(COLOR_TRANSPARENT, COLOR_TRANSPARENT)); 566 } 567 draw_string(0,0,sbuf,MAKE_COLOR(COLOR_SELECTED_BG, COLOR_SELECTED_FG)); 568 break; 545 569 } 546 570 #endif … … 549 573 550 574 //------------------------------------------------------------------- 575 // Draw menu scroll bar if needed, and title bar 551 576 void gui_menu_draw_initial() { 552 577 color cl=conf.menu_title_color>>8; 553 578 unsigned char wplus=0; 554 579 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 } 580 count = gui_menu_rows(); 581 582 if (count > num_lines) 583 { 584 y = ((screen_height-(num_lines-1)*rbf_font_height())>>1); 585 wplus=8; 586 // scrollbar background 587 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)); 588 } 589 else 590 { 591 if (conf.menu_center) 592 { 593 y = (screen_height-(count-1)*rbf_font_height())>>1; 594 } 595 else 596 { 597 y = ((screen_height-(num_lines-1)*rbf_font_height())>>1); 598 } 599 } 600 601 rbf_draw_string_center_len(x, y-rbf_font_height(), w+wplus, (conf.menu_symbol_enable)?curr_menu->symbol:0, lang_str(curr_menu->title), conf.menu_title_color); 602 } 603 604 //------------------------------------------------------------------- 605 606 // Local variables used by menu draw functions 607 static int imenu, yy, xx, symbol_width; 608 static color cl, cl_symbol; 609 610 // Common code extracted from gui_menu_draw for displaying the symbol on the left 611 static void gui_menu_draw_symbol(int num_symbols) 612 { 568 613 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); 614 { 615 xx += rbf_draw_char(xx, yy, ' ', cl_symbol); 616 xx += symbol_width = rbf_draw_symbol(xx, yy, curr_menu->menu[imenu].symbol, cl_symbol); 617 symbol_width = (symbol_width * num_symbols) + len_space; 618 } 570 619 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 } 620 { 621 symbol_width = 0; 622 } 623 624 xx += rbf_draw_char(xx, yy, ' ', cl); 625 } 626 627 // Common code extracted from gui_menu_draw for displaying an int, enum or bool value on the right 628 static void gui_menu_draw_value(const char *str, int len_str) 629 { 630 gui_menu_draw_symbol(1); 631 xx += rbf_draw_string_len(xx, yy, w-len_space-len_space-len_br1-len_str-len_br2-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); 632 xx += rbf_draw_string(xx, yy, " [", cl); 633 xx += rbf_draw_string_right_len(xx, yy, len_str, str, cl); 634 rbf_draw_string(xx, yy, "] ", cl); 635 } 636 637 // Common code extracted from gui_menu_draw for displaying a text menu string 638 static void gui_menu_draw_text(char *str, int num_symbols) 639 { 640 gui_menu_draw_symbol(num_symbols); 641 xx += rbf_draw_string_len(xx, yy, w-len_space-len_space-symbol_width, str, cl); 642 if ((num_symbols == 2) && conf.menu_symbol_enable) 643 xx += rbf_draw_symbol(xx, yy, 0x52, cl_symbol); 644 rbf_draw_char(xx, yy, ' ', cl); 645 } 646 575 647 //------------------------------------------------------------------- 576 648 void gui_menu_draw() { 577 649 static char tbuf[64]; 578 int imenu, i, j, yy, xx, symbol_width; 579 color cl, cl_symbol; 650 int i, j; 580 651 const char *ch = ""; 581 652 582 if (gui_menu_redraw) { 653 if (gui_menu_redraw) 654 { 583 655 if (gui_menu_redraw==2) 584 656 gui_menu_draw_initial(); … … 586 658 gui_menu_redraw=0; 587 659 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()){ 660 for (imenu=gui_menu_top_item, i=0, yy=y; curr_menu->menu[imenu].text && i<num_lines; ++imenu, ++i, yy+=rbf_font_height()) 661 { 589 662 cl = (gui_menu_curr_item==imenu)?conf.menu_cursor_color:conf.menu_color; 590 663 /* 591 * When cursor is over a symbol, force symbol background color to be the menu cursor color but592 * 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 restriction595 * 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 line598 * 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=Vordergrund664 * When cursor is over a symbol, force symbol background color to be the menu cursor color but 665 * keep the symbol color user defined. 666 * old method was to set the symbol color to the symbol background color when the cursor highlighted it. 667 * This method allows the user to have any symbol color and background color they want with the restriction 668 * that the symbol background color will match the rest of the line when the cursor highlights it. 669 * It creates a nice consistent look expecially when the symbol color matches the menu text color. 670 * without this mod, there is no way to ever make the symbol color match the color of the rest of text menu line 671 * when the cursor highlights a line. 672 */ 673 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 674 602 675 xx = x; 603 676 604 switch (curr_menu->menu[imenu].type & MENUITEM_MASK) { 677 switch (curr_menu->menu[imenu].type & MENUITEM_MASK) 678 { 605 679 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); 680 gui_menu_draw_value((*(curr_menu->menu[imenu].value))?"\x95":"", len_bool); 618 681 break; 619 682 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 683 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); 684 gui_menu_draw_value(tbuf, len_int); 633 685 break; 634 686 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); 687 sprintf(tbuf, "%s%s", lang_str(curr_menu->menu[imenu].text),(conf.menu_symbol_enable)?"":" ->"); 688 gui_menu_draw_text(tbuf,2); 650 689 break; 651 690 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); 691 sprintf(tbuf, "%s%s", (conf.menu_symbol_enable)?"":"<- ", lang_str(curr_menu->menu[imenu].text)); 692 gui_menu_draw_text(tbuf,1); 664 693 break; 665 694 case MENUITEM_PROC: 666 695 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); 696 gui_menu_draw_text(lang_str(curr_menu->menu[imenu].text),1); 677 697 break; 678 698 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 } 699 rbf_draw_char(x, yy, ' ', cl); 700 701 if (lang_str(curr_menu->menu[imenu].text)[0]) 702 sprintf(tbuf," %s ",lang_str(curr_menu->menu[imenu].text)); 703 704 j = rbf_str_width(lang_str(curr_menu->menu[imenu].text)); 705 xx += ((int)w - j - len_space*2) >> 1; 706 707 draw_filled_rect(x+len_space, yy, xx-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 708 draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl); 709 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)); 710 711 if (j) xx += rbf_draw_string(xx, yy, tbuf, cl); 712 713 draw_filled_rect(xx, yy, x+w-len_space-1, yy+rbf_font_height()/2-1, MAKE_COLOR(cl>>8, cl>>8)); 714 draw_line(xx, yy+rbf_font_height()/2, x+w-1-len_space, yy+rbf_font_height()/2, cl); 715 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)); 716 717 rbf_draw_char(x+w-len_space, yy, ' ', cl); 706 718 break; 707 719 case MENUITEM_COLOR_FG: 708 720 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); 721 gui_menu_draw_symbol(1); 717 722 xx+=rbf_draw_string_len(xx, yy, w-len_space-symbol_width, lang_str(curr_menu->menu[imenu].text), cl); 718 723 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));724 MAKE_COLOR(((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF, 725 ((*(curr_menu->menu[imenu].value))>>(((curr_menu->menu[imenu].type & MENUITEM_MASK)==MENUITEM_COLOR_BG)?8:0))&0xFF)); 721 726 break; 722 727 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 728 if (curr_menu->menu[imenu].value) 729 ch = ((const char* (*)(int change, int arg))(curr_menu->menu[imenu].value))(0, curr_menu->menu[imenu].arg); 730 gui_menu_draw_value(ch, len_enum); 731 break; 732 } 733 } 734 742 735 // 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 736 if (count > num_lines) 737 { 738 i = num_lines*rbf_font_height()-1 -1; // full height 739 j = i*num_lines/count; // bar height 746 740 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 } 741 i = (i-j)*((gui_menu_curr_item<0)?0:gui_menu_curr_item)/(count-1); // top pos 742 draw_filled_round_rect((x+w)+2, y+1, (x+w)+6, y+1+i, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 743 draw_filled_round_rect((x+w)+2, y+i+j, (x+w)+6, y+num_lines*rbf_font_height()-1-1, MAKE_COLOR(COLOR_BLACK, COLOR_BLACK)); 744 draw_filled_round_rect((x+w)+2, y+1+i, (x+w)+6, y+i+j, MAKE_COLOR(COLOR_WHITE, COLOR_WHITE)); 745 } 746 } 747 } -
trunk/core/gui_space.c
r1286 r1299 18 18 } 19 19 20 // Local variables used by various space display functions, setup in space_color 21 static color cl; 22 static coord xx, yy; 23 static int perc, width, height; 24 25 // Set up color and percent free variables for free space OSD 26 static void space_color() 27 { 28 perc = get_space_perc(); 29 cl = conf.space_color; 30 if (((conf.space_warn_type == 0) && (perc <= conf.space_perc_warn)) || 31 ((conf.space_warn_type == 1) && (GetFreeCardSpaceKb() <= conf.space_mb_warn*1024))) 32 { 33 cl = conf.osd_color_warn; 34 } 35 } 36 37 // Setup position and size variables then draw free space bar, outer shape 38 static void spacebar_outer(OSD_pos pos, int w, int h) 39 { 40 // Get color and percent free 41 space_color(); 42 43 // space icon / bar position 44 xx = pos.x; 45 yy = pos.y; 46 47 // space icon / bar size 48 width = w; 49 height = h; 50 51 // Clamp co-ordinates to keep bar on screen 52 if (xx > (screen_width-width-4)) { 53 xx = screen_width-width-4; 54 } 55 if (yy > (screen_height-height-4)) { 56 yy = screen_height-height-4; 57 } 58 59 draw_rect(xx, yy, xx+width+3, yy+height+3, COLOR_BLACK); // Outer black rectangle 60 draw_rect(xx+1, yy+1, xx+width+2, yy+height+2, cl); // Inner white/red rectangle 61 } 62 20 63 static void gui_space_draw_spacebar_horizontal() { 21 64 coord x; 22 register coord xx, yy;23 65 24 xx = conf.space_hor_pos.x; 25 yy = conf.space_hor_pos.y; 26 27 color cl = conf.space_color; 28 int perc = get_space_perc(),height = 2; 29 int size = 0; 30 if (conf.space_warn_type == 0) { 31 cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color); 32 } else if (conf.space_warn_type == 1) { 33 cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color); 34 } else if (conf.space_warn_type == 2) { 35 cl = conf.space_color; 36 } 37 // space icon / bar 38 height = conf.space_bar_width+1; 39 if (conf.space_bar_size == 0) { 40 size = screen_width/4-4; 41 if (xx>(screen_width-size)) { 42 xx = screen_width-size; 43 } 44 } else if (conf.space_bar_size == 1) { 45 size = screen_width/2-4; 46 if (xx>(screen_width-size)) { 47 xx = screen_width-size; 48 } 49 } else if (conf.space_bar_size == 2) { 50 size = screen_width-4; 51 if (xx>(screen_width-size)) { 52 xx = 0; 53 } 54 } 55 if (yy > (screen_height-height-3)) { 56 yy = screen_height-height-3; 57 } 58 draw_rect(xx+1, yy+1, xx+1+size+2, yy+1+height+1, cl); 59 draw_vline(xx+1-1, yy+1-1, 1+height+2, COLOR_BLACK); // l 60 draw_hline(xx+1-1, yy+1-1, 1+size+3, COLOR_BLACK); // t 61 draw_hline(xx+1-1, yy+1+height+2, 1+size+3, COLOR_BLACK); // b 62 draw_vline(xx+1+size+3, yy+1-1, 1+height+2, COLOR_BLACK); // r 66 // Setup and draw outer shape 67 spacebar_outer(conf.space_hor_pos, (screen_width / (4 >> conf.space_bar_size)) - 4, conf.space_bar_width); 63 68 64 69 // space bar fill 65 66 x = xx + size - ((perc*size)/100); 67 if (x<=xx+1) x=xx+1; 68 if (x>xx+size) x=xx+size; 69 draw_filled_rect(xx+1+1, yy+1+1, x-1, yy+1+height, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK)); 70 draw_filled_rect(x, yy+1+1, xx+1+size+2, yy+1+height, MAKE_COLOR(cl, cl)); 70 x = width - ((perc*width)/100); 71 if (x < 1) x = 1; 72 if (x >= width) x = width; 73 else draw_filled_rect(xx+x+2, yy+2, xx+width+1, yy+height+1, MAKE_COLOR(cl, cl)); // If not empty fill 'free' space area 74 draw_filled_rect(xx+2, yy+2, xx+x+1, yy+height+1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK)); // fill 'used' space area 71 75 } 72 76 73 77 static void gui_space_draw_spacebar_vertical() { 74 78 coord y; 75 register coord xx, yy;76 79 77 xx = conf.space_ver_pos.x; 78 yy = conf.space_ver_pos.y; 79 80 color cl = conf.space_color; 81 int perc = get_space_perc(), width = 2; 82 int size = 0; 83 if (conf.space_warn_type == 0) { 84 cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color); 85 } else if (conf.space_warn_type == 1) { 86 cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color); 87 } else if (conf.space_warn_type == 2) { 88 cl = conf.space_color; 89 } 90 91 // space icon / bar 92 width = conf.space_bar_width+1; 93 if (conf.space_bar_size == 0) { 94 size = screen_height/4-4; 95 if (yy>(screen_height-size)) { 96 yy = screen_height-size; 97 } 98 } else if (conf.space_bar_size == 1) { 99 size = screen_height/2-4; 100 if (yy>(screen_height-size)) { 101 yy = screen_height-size; 102 } 103 } else if (conf.space_bar_size == 2) { 104 size = screen_height-4; 105 if (yy>(screen_height-size)) { 106 yy = 0; 107 } 108 } 109 if (xx > (screen_width-width-3)) { 110 xx = screen_width-width-3; 111 } 112 draw_rect(xx+1, yy+1, xx+1+width+1, yy+1+size+2, cl); 113 draw_vline(xx+1-1, yy+1-1, 1+5, COLOR_BLACK); // l 114 draw_hline(xx+1-1, yy+1-1, 1+width+2, COLOR_BLACK); // t 115 draw_hline(xx+1-1, yy+1+size+3, 1+width+2, COLOR_BLACK); // b 116 draw_vline(xx+1+width+2, yy+1-1, 1+size+3, COLOR_BLACK); // r 80 // Setup and draw outer shape 81 spacebar_outer(conf.space_ver_pos, conf.space_bar_width, (screen_height / (4 >> conf.space_bar_size)) - 4); 117 82 118 83 // space bar fill 119 y = yy + size - ((perc*size)/100);120 if (y <=yy+1) y=yy+1;121 if (y >yy+size) y=yy+size;122 draw_filled_rect(xx+1+1, yy+1+1, xx+1+width, y-1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK));123 draw_filled_rect(xx+ 1+1, y, xx+1+width, yy+1+size+2, MAKE_COLOR(cl, cl));84 y = height - ((perc*height)/100); 85 if (y < 1) y = 1; 86 if (y >= height) y = height; 87 else draw_filled_rect(xx+2, yy+y+2, xx+width+1, yy+height+1, MAKE_COLOR(cl, cl)); // If not empty fill 'free' space area 88 draw_filled_rect(xx+2, yy+2, xx+width+1, yy+y+1, MAKE_COLOR(COLOR_TRANSPARENT, COLOR_BLACK)); // fill 'used' space area 124 89 } 125 90 … … 127 92 coord x; 128 93 register coord xx, yy; 94 int i; 129 95 130 96 xx = conf.space_icon_pos.x; 131 97 yy = conf.space_icon_pos.y; 132 98 133 color cl = conf.space_color; 134 int perc = get_space_perc(); 135 if (conf.space_warn_type == 0) { 136 cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color); 137 } else if (conf.space_warn_type == 1) { 138 cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color); 139 } else if (conf.space_warn_type == 2) { 140 cl = conf.space_color; 141 } 142 int i; 99 space_color(); 100 143 101 #define LE 23 144 102 #define WI 15 145 // int le = 23; // length146 // int wi = 15; // width147 103 148 draw_hline(xx+5, yy, LE-5, COLOR_BLACK); // outer top149 draw_hline(xx+6, yy+1, LE-7, MAKE_COLOR(cl, cl)); // inner top150 draw_vline(xx, yy+5, WI-5, COLOR_BLACK); // outer left151 draw_vline(xx+1, yy+6, WI-7, MAKE_COLOR(cl, cl)); // inner left152 draw_hline(xx, yy+WI, LE, COLOR_BLACK); // outer bottom153 draw_hline(xx+1, yy+WI-1, LE-2, MAKE_COLOR(cl, cl)); // inner bottom154 draw_vline(xx+LE, yy, WI, COLOR_BLACK); // outer right155 draw_vline(xx+LE-1, yy+1, WI-2, MAKE_COLOR(cl, cl)); // inner right156 draw_line(xx+5, yy, xx,yy+5, COLOR_BLACK); // edge157 draw_line(xx+5, yy+1, xx+1,yy+5, MAKE_COLOR(cl, cl)); // edge158 draw_line(xx+6, yy+1, xx+1,yy+6, MAKE_COLOR(cl, cl)); // edge104 draw_hline(xx+5, yy, LE-5, COLOR_BLACK); // outer top 105 draw_hline(xx+6, yy+1, LE-7, MAKE_COLOR(cl, cl)); // inner top 106 draw_vline(xx, yy+5, WI-5, COLOR_BLACK); // outer left 107 draw_vline(xx+1, yy+6, WI-7, MAKE_COLOR(cl, cl)); // inner left 108 draw_hline(xx, yy+WI, LE, COLOR_BLACK); // outer bottom 109 draw_hline(xx+1, yy+WI-1, LE-2, MAKE_COLOR(cl, cl)); // inner bottom 110 draw_vline(xx+LE, yy, WI, COLOR_BLACK); // outer right 111 draw_vline(xx+LE-1, yy+1, WI-2, MAKE_COLOR(cl, cl)); // inner right 112 draw_line(xx+5, yy, xx, yy+5, COLOR_BLACK); // edge 113 draw_line(xx+5, yy+1, xx+1, yy+5, MAKE_COLOR(cl, cl)); // edge 114 draw_line(xx+6, yy+1, xx+1, yy+6, MAKE_COLOR(cl, cl)); // edge 159 115 160 116 // memory fill … … 163 119 if (x>2) draw_hline(xx+x+1, yy+2, LE-x-3, MAKE_COLOR(cl, cl)); 164 120 else draw_hline(xx+4, yy+2, LE-6, MAKE_COLOR(cl, cl)); 165 for(i=3; i<7; i++) { // /--------------|121 for(i=3; i<7; i++) { // /--------------| 166 122 if (x>7-i) draw_pixel(xx+8-i, yy+i, COLOR_BLACK); // / 1st for loop | 167 123 if (x>7-i) draw_pixel(xx+x, yy+i, COLOR_BLACK); // /__________________| 168 draw_hline(xx+x+1, yy+i, LE-x-3, MAKE_COLOR(cl, cl));// | |169 } // | 2nd for loop |170 for(i=7; i<WI-2; i++) { // | |124 draw_hline(xx+x+1, yy+i, LE-x-3, MAKE_COLOR(cl, cl)); // | | 125 } // | 2nd for loop | 126 for(i=7; i<WI-2; i++) { // | | 171 127 if (x>1) draw_pixel(xx+2, yy+i, COLOR_BLACK); // |-------------------| 172 128 if (x>1) draw_pixel(xx+x, yy+i, COLOR_BLACK); 173 draw_hline(xx+x+1, yy+i, LE-x-3,MAKE_COLOR(cl, cl));129 draw_hline(xx+x+1, yy+i, LE-x-3, MAKE_COLOR(cl, cl)); 174 130 } 175 131 if (x>1) draw_hline(xx+2, yy+WI-2, x-2, COLOR_BLACK); … … 179 135 //------------------------------------------------------------------- 180 136 static void gui_space_draw_percent() { 181 int perc = get_space_perc(); 182 color cl = conf.space_color; 183 if (conf.space_warn_type == 0) { 184 cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color); 185 } else if (conf.space_warn_type == 1) { 186 cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color); 187 } else if (conf.space_warn_type == 2) { 188 cl = conf.space_color; 189 } 190 sprintf(osd_buf, "%3d%%", get_space_perc()); 137 space_color(); 138 sprintf(osd_buf, "%3d%%", perc); 191 139 osd_buf[5]=0; 192 140 draw_string(conf.space_txt_pos.x, conf.space_txt_pos.y, osd_buf, cl); … … 195 143 //------------------------------------------------------------------- 196 144 static void gui_space_draw_mb() { 197 int perc = get_space_perc(); 198 color cl = conf.space_color; 199 if (conf.space_warn_type == 0) { 200 cl = (perc<=conf.space_perc_warn)?conf.osd_color_warn:(conf.space_color); 201 } else if (conf.space_warn_type == 1) { 202 cl = (GetFreeCardSpaceKb()/1024<=conf.space_mb_warn)?conf.osd_color_warn:(conf.space_color); 203 } else if (conf.space_warn_type == 2) { 204 cl = conf.space_color; 205 } 145 space_color(); 206 146 unsigned int freemb=GetFreeCardSpaceKb()/1024; 207 147 if (freemb < 10000) sprintf(osd_buf, "%3d%M",freemb);
Note: See TracChangeset
for help on using the changeset viewer.