/************************************************************************* * *N displaymessage * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function displays a list of text strings in a * popup text window. The list must be NULL-terminated. Must be in * graphics mode to call this function. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * string <input> == (char *) first text string to be displayed. * ... <input> == (char *) variable list of text strings to be displayed. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels August 1991 DOS Turbo C *E *************************************************************************/ void displaymessage( char *string, ... ) { int i,maxw,height,x,y,pad, nlines; panel_type panel; char **text; va_list arglist; va_start(arglist,string); nlines = 1; while (va_arg(arglist,char *)) nlines++; va_end(arglist); text = (char **)vpfmalloc((nlines+1)*sizeof(char *)); text[0] = string; va_start(arglist,string); for (i=1;i<nlines;i++) { text[i] = va_arg(arglist,char *); } va_end(arglist); settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); maxw = 0; height = 0; for (i=0;i<nlines;i++) { if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]); height = height + textheight(text[i]) + 5; } if (maxw < (textwidth("Continue") + 10)) maxw = textwidth("Continue") + 10; pad = (maxw*10)/100; maxw = maxw + (2*pad); if (maxw > getmaxx()) maxw = getmaxx() - 8; height = height + 2*(textheight("Continue") + 5) + 5; create_panel( &panel, maxw, height, menucolor, menubordercolor ); x = pad; y = 0; for (i=0;i<nlines;i++) { y = y + textheight(text[i]) + 5; create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel ); } y = height - (textheight("Continue") + 6); x = (maxw - (textwidth("Continue") + 10))/2; create_button( 27, "Continue", x, y, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); get_display_position( &x, &y, panel.window ); display_panel( &panel, x, y ); i = process_panel( &panel, i ); destroy_panel( &panel ); close_panel( &panel ); free(text); }
void close_windows(void) { if (tui_disabled) return; /* must delete panels before their attached windows */ if (dialogue_window) close_panel(dialogue_panel); if (cooling_device_window) close_panel(data_panel); close_window(title_bar_window); close_window(tz_sensor_window); close_window(status_bar_window); close_window(cooling_device_window); close_window(control_window); close_window(thermal_data_window); close_window(dialogue_window); }
/************************************************************************* * *N yes_no * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function displays a panel asking the user a yes or no * question and returns the response. Must be in graphics mode to call * this function. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * text <input>==(char *) question string. * return <output>==(int) yes (TRUE) or no (FALSE). *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels May 1991 DOS Turbo C *E *************************************************************************/ int yes_no( char *text ) { panel_type panel; int no_id = 27; int yes_id = 13; int x,y,width,height,maxheight,id=0; settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); width = 0; maxheight = 0; width = textwidth(text); maxheight = textheight(text); width = width + 50; if (width > getmaxx()) width = getmaxx()-10; height = maxheight * 5; create_panel( &panel,width,height,menucolor,menubordercolor ); y = maxheight; create_label( text,CENTER,y,SMALL_FONT,4,menutextcolor,&panel ); y += maxheight; create_button( yes_id, "Yes", 3, height-textheight("Y")-6, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); create_button( no_id, "No", width-textwidth("No")-13, height-textheight("No")-6, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); get_display_position( &x, &y, panel.window ); display_panel( &panel, x,y ); id = process_panel(&panel, id); destroy_panel( &panel ); close_panel( &panel ); if (id == yes_id) return TRUE; else return FALSE; }
uint8_t OSD::write(uint8_t c) { if(c == '|') { close_panel(); //It does all needed to finish auto increment and change current row open_panel(); //It does all needed to re-enable auto increment } else { spi->take_spi_right(&spi_dev_max7456); spi->write(MAX7456_DMDI_reg); spi->write(c); spi->release_spi_right(); } return 1; }
/************************************************************************* * *N displayinfo * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function displays an array of text strings in a * popup text window. Must be in graphics mode to call this function. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * text[] <input> == (char *) array of text strings to be displayed. * nlines <input> == (int) number of text lines. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels June 1990 Original Version DOS Turbo C *E *************************************************************************/ void displayinfo( char *text[], int nlines ) { int i,maxw,height,x,y,pad; panel_type panel; arrow_cursor(); settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); maxw = 0; height = 0; for (i=0;i<nlines;i++) { if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]); height = height + textheight(text[i]) + 5; } if (maxw < (textwidth("Continue") + 10)) maxw = textwidth("Continue") + 10; pad = (maxw*10)/100; maxw = maxw + (2*pad); if (maxw > getmaxx()) maxw = getmaxx() - 8; height = height + 2*(textheight("Continue") + 10); create_panel( &panel, maxw, height, menucolor, menubordercolor ); x = pad; y = 0; for (i=0;i<nlines;i++) { y = y + textheight(text[i]) + 3; create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel ); } y = height - (textheight("Continue") + 6); x = (maxw - (textwidth("Continue") + 10))/2; create_button( 27, "Continue", x, y, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); get_display_position( &x, &y, panel.window ); display_panel( &panel, x, y ); i = process_panel( &panel, i ); destroy_panel( &panel ); close_panel( &panel ); }
void close_all_panels(void) { // actually doesn't close main or log panels int i; for (i = 1; i < PANEL_BCODE+1; i ++) // note i = 1 { if (panel[i].open) { inter.panel_restore [i] = 1; close_panel(i, 0); } else inter.panel_restore [i] = 0; } }
/************************************************************************* * *N displayerror * *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Purpose: *P * This function displays an error message when a disk error is detected. * It displays the given lines of text in a popup panel and waits for * the user to click on either retry or cancel. It returns 1 for retry * and 0 for cancel. Must be in graphics mode to call this function. * * text strings may contain embedded newlines, in which case text to the * right of the newline will be displayed on (what else?) a new line. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * Parameters: *A * text[] <input> == (char *) array of text strings to be displayed. * nlines <input> == (int) number of lines of text (this count ignores * newline characters embedded in the text * strings * return <output> == (VPF_BOOLEAN) 1 => retry, * 0 => cancel. *E *:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: * * History: *H * Barry Michaels July 1990 Prototype 3 DOS Turbo C *E *************************************************************************/ VPF_BOOLEAN displayerror( char *text[], int nlines ) { register int i; int maxw, height, x, y, pad, choice, n_real_lines; panel_type panel; int retry_button = 'r', cancel_button = 'c', msg_ar_sz = 10; char * walker, ** msgs; struct viewporttype view; getviewsettings( &view ); setviewport(0,0,getmaxx(),getmaxy(),1); settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); msgs = (char **) vpfmalloc(msg_ar_sz * sizeof(char *)); maxw = height = 0; for (n_real_lines = i = 0; i < nlines; i++) { walker = text[i]; while (1) { size_t substr_len = strcspn(walker, "\n"); char plug; maxw = max(maxw, textwidth(walker)); height = height + textheight(walker) + 5; plug = walker[substr_len]; walker[substr_len] = '\0'; msgs[n_real_lines++] = strdup(walker); if (n_real_lines == msg_ar_sz) msgs = (char **) realloc(msgs, (msg_ar_sz += 5) * sizeof(char *)); if (plug == 0) break; walker[substr_len] = plug; walker += substr_len + 1; } } if (maxw < (textwidth("Retry") + textwidth("Cancel") + 20)) maxw = textwidth("Retry") + textwidth("Cancel") + 20; pad = (maxw*10)/100; maxw = maxw + (2*pad); height = height + 2*(textheight("Retry") + 5) + 1; maxw = min(getmaxx(), maxw); height = min(getmaxy()-10, height); create_panel( &panel, maxw, height, menucolor, menubordercolor ); for (y = i = 0; i < n_real_lines; i++) { create_label(msgs[i], pad, y, SMALL_FONT, 4, menutextcolor, &panel ); y += textheight(msgs[i]) + 3; } y = height-15; create_button( retry_button, "Retry", 3, y, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); create_button( cancel_button, "Cancel", maxw - (textwidth("Cancel") + 13), y, SMALL_FONT, 4, menutextcolor, menucolor, menubordercolor, RELIEVED, &panel ); get_display_position( &x, &y, panel.window ); display_panel( &panel, x,y ); showmousecursor(); arrow_cursor(); choice = process_panel( &panel, 0 ); hidemousecursor(); destroy_panel( &panel ); close_panel( &panel ); setviewport(view.left,view.top,view.right,view.bottom,view.clip); for (i = 0; i < n_real_lines; i++) free(msgs[i]); free(msgs); return (choice == retry_button) ? 1 : 0; }
// call this when one of the mode buttons is pressed // see also close_any_edit_window() in g_game.c void mode_button(int mode_pressed) { // if (inter.mode_button_available [mode_pressed] == 0) // return; #define MODE_BUTTON_SAMPLE SAMPLE_BLIP4 #define MODE_BUTTON_TONE_OPEN TONE_3C #define MODE_BUTTON_TONE_CLOSE TONE_2G switch(mode_pressed) { case MODE_BUTTON_SYSTEM: if (panel[PANEL_SYSMENU].open) { close_panel(PANEL_SYSMENU, 1); play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); // panel[PANEL_SYSMENU].element [FPE_SYSMENU_CONFIRM_QUIT].open = 0; this is now done by close_panel } else { open_panel(PANEL_SYSMENU); play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); } break; case MODE_BUTTON_EDITOR: if (panel[PANEL_EDITOR].open) { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); close_panel(PANEL_EDITOR, 1); } else { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); open_panel(PANEL_EDITOR); } break; case MODE_BUTTON_DESIGN: if (panel[PANEL_DESIGN].open) { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); close_panel(PANEL_DESIGN, 1); } else { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); open_panel(PANEL_DESIGN); } break; case MODE_BUTTON_TEMPLATES: if (panel[PANEL_TEMPLATE].open) { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); close_panel(PANEL_TEMPLATE, 1); } else { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); open_panel(PANEL_TEMPLATE); } break; case MODE_BUTTON_BCODE: if (panel[PANEL_BCODE].open) { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); close_panel(PANEL_BCODE, 1); } else { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); open_panel(PANEL_BCODE); } break; case MODE_BUTTON_CLOSE: // if (inter.mode_buttons_maximised) if (panel[PANEL_DESIGN].open || panel[PANEL_EDITOR].open || panel[PANEL_TEMPLATE].open || panel[PANEL_BCODE].open || panel[PANEL_SYSMENU].open) { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_CLOSE); close_all_panels(); } else { play_interface_sound(MODE_BUTTON_SAMPLE, MODE_BUTTON_TONE_OPEN); int opened_any = 0; int i; for (i = 1; i < PANEL_BCODE+1; i ++) // note i starts at 1 { if (inter.panel_restore [i]) { open_panel(i); opened_any = 1; } } if (!opened_any) open_panel(PANEL_SYSMENU); } // else // inter.mode_buttons_maximised = 1; break; // case MODE_BUTTON_MIN_MAX: // inter.mode_buttons_maximised ^= 1; // break; } }