static UI_MENU_CALLBACK(license_callback) { menu_draw_t *menu_draw; #ifdef WINMIPS char *new_text = NULL; #endif if (activated) { menu_draw = sdl_ui_get_menu_param(); if (menu_draw->max_text_x > 60) { #ifdef WINMIPS new_text = concat_all(info_license_text); show_text(new_text); lib_free(new_text); #else show_text(info_license_text); #endif } else { #ifdef WINMIPS new_text = concat_all(info_license_text40); show_text(new_text); lib_free(new_text); #else show_text(info_license_text40); #endif } } return NULL; }
console_t *uimon_window_open(void) { sdl_ui_activate_pre_action(); sdl_ui_init_draw_params(); sdl_ui_clear(); menu_draw = sdl_ui_get_menu_param(); mon_console.console_xres = menu_draw->max_text_x; mon_console.console_yres = menu_draw->max_text_y; x_pos = 0; return &mon_console; }
static UI_MENU_CALLBACK(warranty_callback) { menu_draw_t *menu_draw; if (activated) { menu_draw = sdl_ui_get_menu_param(); if (menu_draw->max_text_x > 60) { show_text(info_warranty_text); } else { show_text(info_warranty_text40); } } return NULL; }
static UI_MENU_CALLBACK(cmdline_callback) { menu_draw_t *menu_draw; char *options; char *options_n; if (activated) { menu_draw = sdl_ui_get_menu_param(); options = cmdline_options_string(); options_n = convert_cmdline_to_n_cols(options, menu_draw->max_text_x); lib_free(options); show_text((const char *)options_n); lib_free(options_n); } return NULL; }
static UI_MENU_CALLBACK(contributors_callback) { menu_draw_t *menu_draw; char *info_contrib_text_n; #ifdef WINMIPS char *new_text = NULL; #endif if (activated) { menu_draw = sdl_ui_get_menu_param(); #ifdef WINMIPS new_text = concat_all(info_contrib_text); info_contrib_text_n = contrib_convert(new_text, menu_draw->max_text_x); lib_free(new_text); #else info_contrib_text_n = contrib_convert((char *)info_contrib_text, menu_draw->max_text_x); #endif show_text((const char *)info_contrib_text_n); lib_free(info_contrib_text_n); } return NULL; }
int sdl_ui_image_file_selection_dialog(const char* filename, ui_menu_filereq_mode_t mode) { int total, dirs = 0, files, menu_max; int active = 1; int offset = 0; int redraw = 1; int cur = 0, cur_old = -1; image_contents_t *contents = NULL; image_contents_file_list_t *entry; int retval = -1; menu_draw = sdl_ui_get_menu_param(); /* FIXME: it might be a good idea to wrap this into a common imagecontents_read */ contents = tapecontents_read(filename); if (contents == NULL) { contents = diskcontents_read(filename, 0); if (contents == NULL) { return 0; } } /* count files in the list */ files = 0; for (entry = contents->file_list; entry != NULL; entry = entry->next) { files++; } total = dirs + files + SDL_FILEREQ_META_NUM; menu_max = menu_draw->max_text_y - (IMAGE_FIRST_Y + SDL_FILEREQ_META_NUM); if (menu_max > 0) { menu_max--; } /* make room for BLOCKS FREE */ while (active) { sdl_ui_set_active_font(MENU_FONT_IMAGES); if (redraw) { sdl_ui_image_file_selector_redraw(contents, filename, offset, (total - offset > menu_max) ? menu_max : total - offset, (total - offset > menu_max) ? 1 : 0, mode, cur); redraw = 0; } else { sdl_ui_image_file_selector_redraw_cursor(contents, offset, (total - offset > menu_max) ? menu_max : total - offset, mode, cur, cur_old); } sdl_ui_set_active_font(MENU_FONT_ASCII); sdl_ui_refresh(); switch (sdl_ui_menu_poll_input()) { case MENU_ACTION_HOME: cur_old = cur; cur = 0; offset = 0; redraw = 1; break; case MENU_ACTION_END: cur_old = cur; if (total < (menu_max - 1)) { cur = total - 1; offset = 0; } else { cur = menu_max - 1; offset = total - menu_max; } redraw = 1; break; case MENU_ACTION_UP: if (cur > 0) { cur_old = cur; --cur; } else { if (offset > 0) { offset--; redraw = 1; } } break; case MENU_ACTION_PAGEUP: case MENU_ACTION_LEFT: offset -= menu_max; if (offset < 0) { offset = 0; cur_old = -1; cur = 0; } redraw = 1; break; case MENU_ACTION_DOWN: if (cur < (menu_max - 1)) { if ((cur + offset) < total - 1) { cur_old = cur; ++cur; } } else { if (offset < (total - menu_max)) { offset++; redraw = 1; } } break; case MENU_ACTION_PAGEDOWN: case MENU_ACTION_RIGHT: offset += menu_max; if (offset >= total) { offset = total - 1; cur_old = -1; cur = 0; } else if ((cur + offset) >= total) { cur_old = -1; cur = total - offset - 1; } redraw = 1; break; case MENU_ACTION_SELECT: active = 0; retval = offset + cur - dirs - SDL_FILEREQ_META_NUM + 1; break; case MENU_ACTION_CANCEL: case MENU_ACTION_EXIT: active = 0; break; default: SDL_Delay(10); break; } } return retval; }
static void show_text(const char *text) { int first_line = 0; int next_line = 0; int next_page = 0; unsigned int current_line = 0; unsigned int len; int x, y, z; int active = 1; int active_keys; char *string; menu_draw_t *menu_draw; menu_draw = sdl_ui_get_menu_param(); string = lib_malloc(128); len = strlen(text); while (active) { sdl_ui_clear(); first_line = current_line; for (y = 0; (y < menu_draw->max_text_y) && (current_line < len); y++) { z = 0; for (x = 0; text[current_line + x] != '\n'; x++) { switch (text[current_line + x]) { case '`': string[x + z] = '\''; break; case 'ä': string[x + z] = 'a'; break; case '~': string[x + z] = '-'; break; case 'é': case 'è': string[x + z] = 'e'; break; case 'Ö': string[x + z] = 'O'; break; case 'ö': string[x + z] = 'o'; break; case 'å': string[x + z] = 'a'; break; case '\t': string[x + z] = ' '; string[x + z + 1] = ' '; string[x + z + 2] = ' '; string[x + z + 3] = ' '; z += 3; break; default: string[x + z] = text[current_line + x]; break; } } if (x != 0) { string[x + z] = 0; sdl_ui_print(string, 0, y); } if (y == 0) { next_line = current_line + x + 1; } current_line += x + 1; } next_page = current_line; active_keys = 1; sdl_ui_refresh(); while (active_keys) { switch(sdl_ui_menu_poll_input()) { case MENU_ACTION_CANCEL: case MENU_ACTION_EXIT: case MENU_ACTION_SELECT: active_keys = 0; active = 0; break; case MENU_ACTION_RIGHT: active_keys = 0; current_line = next_page; break; case MENU_ACTION_DOWN: active_keys = 0; current_line = next_line; break; case MENU_ACTION_LEFT: active_keys = 0; current_line = scroll_up(text, first_line, menu_draw->max_text_y); break; case MENU_ACTION_UP: active_keys = 0; current_line = scroll_up(text, first_line, 1); break; default: SDL_Delay(10); break; } } } lib_free(string); }
static void show_text(const char *text) { int first_line = 0; int last_line = 0; int next_line = 0; int next_page = 0; unsigned int current_line = 0; unsigned int this_line = 0; unsigned int len; int x, y, z; int active = 1; int active_keys; char *string; menu_draw_t *menu_draw; menu_draw = sdl_ui_get_menu_param(); string = lib_malloc(0x400); len = strlen(text); /* find out how many lines */ for (x = 0, z = 0; text[x] != 0; x++) { if (text[x] == '\n') { last_line++; } } last_line -= menu_draw->max_text_y; for (x = 0, z = 0; text[x] != 0; x++) { if (last_line == 0) { break; } if (text[x] == '\n') { last_line--; } } last_line = x; /* save the offset */ while (active) { sdl_ui_clear(); first_line = current_line; this_line = current_line; for (y = 0; (y < menu_draw->max_text_y) && (this_line < len); y++) { z = 0; for (x = 0; (text[this_line + x] != '\n') && (text[this_line + x] != 0); x++) { switch (text[this_line + x]) { case '`': string[x + z] = '\''; break; /* FIXME: we should actually be able to handle some of these */ case CHARCODE_UMLAUT_A_LOWER: case CHARCODE_KROUZEK_A_LOWER: string[x + z] = 'a'; break; case CHARCODE_UMLAUT_A_UPPER: string[x + z] = 'A'; break; case '~': string[x + z] = '-'; break; case CHARCODE_GRAVE_E_LOWER: case CHARCODE_AIGU_E_LOWER: string[x + z] = 'e'; break; case CHARCODE_UMLAUT_O_UPPER: string[x + z] = 'O'; break; case CHARCODE_UMLAUT_O_LOWER: string[x + z] = 'o'; break; case CHARCODE_UMLAUT_U_UPPER: string[x + z] = 'U'; break; case CHARCODE_UMLAUT_U_LOWER: string[x + z] = 'u'; break; case '\t': string[x + z] = ' '; string[x + z + 1] = ' '; string[x + z + 2] = ' '; string[x + z + 3] = ' '; z += 3; break; default: string[x + z] = text[this_line + x]; break; } } if (x != 0) { string[x + z] = 0; sdl_ui_print(string, 0, y); } if (y == 0) { next_line = this_line + x + 1; } this_line += x + 1; } next_page = this_line; active_keys = 1; sdl_ui_refresh(); while (active_keys) { switch (sdl_ui_menu_poll_input()) { case MENU_ACTION_CANCEL: case MENU_ACTION_EXIT: case MENU_ACTION_SELECT: active_keys = 0; active = 0; break; case MENU_ACTION_RIGHT: case MENU_ACTION_PAGEDOWN: active_keys = 0; if (current_line < last_line) { current_line = next_page; if (current_line > last_line) { current_line = last_line; } } break; case MENU_ACTION_DOWN: active_keys = 0; if (current_line < last_line) { current_line = next_line; if (current_line > last_line) { current_line = last_line; } } break; case MENU_ACTION_LEFT: case MENU_ACTION_PAGEUP: active_keys = 0; current_line = scroll_up(text, first_line, menu_draw->max_text_y); break; case MENU_ACTION_UP: active_keys = 0; current_line = scroll_up(text, first_line, 1); break; case MENU_ACTION_HOME: active_keys = 0; current_line = 0; break; case MENU_ACTION_END: active_keys = 0; if (current_line < last_line) { current_line = last_line; } break; default: SDL_Delay(10); break; } } } lib_free(string); }