/* Regenerate the main context menu with any bookmarks appended. */ static void rebuild_cm_encycl(void) { size_t i; cm_set(cm_encycl, cm_encycl_base_str, cm_encycl_handler); if (num_bookmarks == 0) return; cm_add(cm_encycl, "--", NULL); for (i=0; i<num_bookmarks; i++) cm_add(cm_encycl, page_links[book_marks[i]].title, NULL); }
void display_storage_menu() { int i; /* Entropy suggested hack to determine if this is the view only "#sto" opened storage */ view_only_storage = 0; for (i = 0; i < no_storage_categories; i++) { if ((storage_categories[i].id != -1) && (strcmp(&storage_categories[i].name[1], "Quest") == 0)) { view_only_storage = 1; break; } } if(storage_win<=0){ int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } storage_win=create_window(win_storage, our_root_win, 0, storage_win_x, storage_win_y, storage_win_x_len, storage_win_y_len, ELW_WIN_DEFAULT|ELW_TITLE_NAME); set_window_handler(storage_win, ELW_HANDLER_DISPLAY, &display_storage_handler); set_window_handler(storage_win, ELW_HANDLER_CLICK, &click_storage_handler); set_window_handler(storage_win, ELW_HANDLER_MOUSEOVER, &mouseover_storage_handler); set_window_handler(storage_win, ELW_HANDLER_KEYPRESS, &keypress_storage_handler ); vscrollbar_add_extended(storage_win, STORAGE_SCROLLBAR_CATEGORIES, NULL, 130, 10, 20, 192, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, max2i(no_storage_categories - STORAGE_CATEGORIES_DISPLAY, 0)); vscrollbar_add_extended(storage_win, STORAGE_SCROLLBAR_ITEMS, NULL, 352, 10, 20, 192, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, 28); cm_add(windows_list.window[storage_win].cm_id, cm_storage_menu_str, context_storage_handler); cm_add(windows_list.window[storage_win].cm_id, cm_dialog_options_str, context_storage_handler); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+2, &sort_storage_categories, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+3, &disable_storage_filter, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+4, &autoclose_storage_dialogue, NULL); cm_bool_line(windows_list.window[storage_win].cm_id, ELW_CM_MENU_LEN+5, &auto_select_storage_option, NULL); } else { no_storage=0; for(i = 0; i < no_storage_categories; i++) storage_categories[i].name[0] = to_color_char (c_orange1); show_window(storage_win); select_window(storage_win); vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_CATEGORIES, 0); vscrollbar_set_pos(storage_win, STORAGE_SCROLLBAR_ITEMS, 0); } storage_text[0] = '\0'; set_window_name("", ""); }
/* Search the list of link title for a match */ static void find_page(const char *search_title, void *data) { size_t i; /* find matches where the search string is a substring of the title */ num_found_links = 0; for (i=0; i<num_page_links && num_found_links<MAX_FOUND_LINKS; ++i) if(xmlStrcasestr((xmlChar*)page_links[i].title,(xmlChar*)search_title)!=NULL) found_links[num_found_links++] = i; /* ignore if no matches, open if one match, or display a list of the first few matches */ if (num_found_links < 1) return; else if (num_found_links == 1) open_page(found_links[0]); else { if (cm_valid(cm_encycl_res)) cm_destroy(cm_encycl_res); cm_encycl_res = cm_create(page_links[found_links[0]].title, cm_encycl_res_handler); cm_set_pre_show_handler(cm_encycl_res, cm_encycl_res_pre_show_handler); for (i=1; i<num_found_links; i++) cm_add(cm_encycl_res, page_links[found_links[i]].title, NULL); cm_show_direct(cm_encycl_res, -1, -1); } }
void display_minimap() { window_info *win; minimap_size = 256 * minimap_size_coefficient; float_minimap_size = 256.0 * minimap_size_coefficient; if(minimap_tiles_distance < 48) minimap_tiles_distance = 48; if(minimap_tiles_distance > 144) minimap_tiles_distance = 144; if(minimap_win < 0) { //init minimap minimap_win = create_window(win_minimap, windows_on_top?-1:game_root_win, 0, minimap_win_x, minimap_win_y, minimap_size, minimap_size+ELW_TITLE_HEIGHT, ELW_CLICK_TRANSPARENT|ELW_SHOW|ELW_TITLE_NAME|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE|ELW_DRAGGABLE); set_window_handler(minimap_win, ELW_HANDLER_DISPLAY, &display_minimap_handler); set_window_handler(minimap_win, ELW_HANDLER_CLICK, &click_minimap_handler); set_window_handler(minimap_win, ELW_HANDLER_MOUSEOVER, &mouseover_minimap_handler); set_window_handler(minimap_win, ELW_HANDLER_KEYPRESS, &keypress_minimap_handler ); win = &(windows_list.window[minimap_win]); win->owner_drawn_title_bar = 1; change_minimap(); if (!cm_valid(win->cm_id)) { win->cm_id = cm_create(cm_title_menu_str, cm_minimap_title_handler); cm_grey_line(win->cm_id, 1, 1); cm_bool_line(win->cm_id, 2, &windows_on_top, "windows_on_top"); } cm_add(win->cm_id, cm_minimap_menu_str, NULL); cm_add_region(win->cm_id, minimap_win, win->len_x/2-32, 0, 64, ELW_TITLE_HEIGHT ); cm_bool_line(win->cm_id, ELW_CM_MENU_LEN+1, &rotate_minimap, "rotate_minimap"); cm_bool_line(win->cm_id, ELW_CM_MENU_LEN+2, &pin_minimap, "pin_minimap"); cm_bool_line(win->cm_id, ELW_CM_MENU_LEN+3, &open_minimap_on_start, NULL); } else { show_window(minimap_win); select_window(minimap_win); } }
void display_astrology_window(const char * raw_text) { if(astrology_win < 0) { int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } astrology_win= create_window(win_astrology, our_root_win, 0, astrology_win_x, astrology_win_y, astrology_win_x_len, astrology_win_y_len, ELW_WIN_DEFAULT ^ ELW_CLOSE_BOX); set_window_handler(astrology_win, ELW_HANDLER_DISPLAY, &display_astrology_handler ); ok_button_id=button_add_extended(astrology_win, ok_button_id, NULL, (astrology_win_x_len >>1) - 40, astrology_win_y_len-36, 80, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, "Ok"); widget_set_OnClick(astrology_win, ok_button_id, ok_handler); cm_add(windows_list.window[astrology_win].cm_id, cm_astro_menu_str, cm_astro_handler); cm_bool_line(windows_list.window[astrology_win].cm_id, ELW_CM_MENU_LEN+2, &always_show_astro_details, NULL ); }
void display_manufacture_menu() { if(manufacture_win < 0){ int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } manufacture_win= create_window(win_manufacture, our_root_win, 0, manufacture_menu_x, manufacture_menu_y, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT); set_window_handler(manufacture_win, ELW_HANDLER_DISPLAY, &display_manufacture_handler ); set_window_handler(manufacture_win, ELW_HANDLER_CLICK, &click_manufacture_handler ); set_window_handler(manufacture_win, ELW_HANDLER_MOUSEOVER, &mouseover_manufacture_slot_handler ); set_window_handler(manufacture_win, ELW_HANDLER_KEYPRESS, &keypress_manufacture_handler ); set_window_handler(manufacture_win, ELW_HANDLER_UI_SCALE, &ui_scale_manufacture_handler ); mixone_button_id=button_add_extended(manufacture_win, mixone_button_id, NULL, 0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">"); widget_set_OnClick(manufacture_win, mixone_button_id, mixone_handler); widget_set_OnMouseover(manufacture_win, mixone_button_id, mouseover_mixone_handler); mixall_button_id=button_add_extended(manufacture_win, mixall_button_id, NULL, 0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, ">>"); widget_set_OnClick(manufacture_win, mixall_button_id, mixall_handler); widget_set_OnMouseover(manufacture_win, mixall_button_id, mouseover_mixall_handler); clear_button_id=button_add_extended(manufacture_win, clear_button_id, NULL, 0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, clear_str); widget_set_OnClick(manufacture_win, clear_button_id, clear_handler); if ((manufacture_win > -1) && (manufacture_win < windows_list.num_windows)) { cm_add(windows_list.window[manufacture_win].cm_id, cm_manuwin_menu_str, NULL); cm_bool_line(windows_list.window[manufacture_win].cm_id, ELW_CM_MENU_LEN+1, &disable_manuwin_keypress, NULL); } //Create a child window to show recipes in a dropdown panel recipe_win= create_window("w_recipe", manufacture_win, 0, 0, 0, 0, 0, ELW_USE_UISCALE|ELW_TITLE_NONE|ELW_SHOW|ELW_USE_BACKGROUND|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE|ELW_USE_BORDER|ELW_RESIZEABLE); set_window_handler(recipe_win, ELW_HANDLER_DISPLAY, &recipe_dropdown_draw); set_window_handler(recipe_win, ELW_HANDLER_CLICK, &recipe_dropdown_click_handler ); set_window_handler(recipe_win, ELW_HANDLER_MOUSEOVER, &mouseover_recipe_handler ); set_window_handler(recipe_win, ELW_HANDLER_RESIZE, &resize_recipe_handler ); set_window_handler(recipe_win, ELW_HANDLER_KEYPRESS, keypress_recipe_handler ); recipe_win_scroll_id = vscrollbar_add_extended(recipe_win, 1, NULL, 0, 0, 0, 0, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, num_recipe_entries-num_displayed_recipes); if ((manufacture_win > -1) && (manufacture_win < windows_list.num_windows)) ui_scale_manufacture_handler(&windows_list.window[manufacture_win]); // context menu cm_recipewin = cm_create(cm_recipe_menu_str, context_recipe_handler); cm_add_window(cm_recipewin, recipe_win); cm_set_pre_show_handler(cm_recipewin, context_recipe_pre_show_handler); hide_window(recipe_win); //start hidden build_manufacture_list(); } else { show_window(manufacture_win); if (!recipes_shown) hide_window(recipe_win); else show_window(recipe_win); select_window(manufacture_win); } }
// the stats display static int ui_scale_stats_bar_handler(window_info *win) { int i; int num_exp = get_num_statsbar_exp(); int actual_num_exp = 0; int stats_height = 0; int stats_width = window_width - HUD_MARGIN_X; int stats_y_pos = window_height - (HUD_MARGIN_Y - player_statsbar_y_offset); player_statsbar_bar_height = (int)(0.5 + win->current_scale * 8); stats_height = get_player_statsbar_active_height(); init_window(stats_bar_win, -1, 0, 0, stats_y_pos, stats_width, stats_height); /* use a fixed width for user attrib stat bar text */ stats_bar_text_len = 4.5 * win->small_font_len_x; // calculate the statsbar len given curent config stats_bar_len = calc_stats_bar_len(win, num_exp); // calculate the maximum number of exp bars we can have max_disp_stats = calc_max_disp_stats(stats_bar_len); // if we need to reduce the number of bars, recalculate the optimum stats bar len if (num_exp > max_disp_stats) stats_bar_len = calc_stats_bar_len(win, max_disp_stats); // all the bars are at the top of the window mana_bar_start_y = food_bar_start_y = health_bar_start_y = load_bar_start_y = action_bar_start_y = exp_bar_start_y = 0; // calculate the stats bar x position mana_bar_start_x = stats_bar_text_len; food_bar_start_x = stats_bar_len + 2 * stats_bar_text_len; health_bar_start_x = 2 * stats_bar_len + 3 * stats_bar_text_len; load_bar_start_x = 3 * stats_bar_len + 4 * stats_bar_text_len; if (show_action_bar) action_bar_start_x = 4 * stats_bar_len + 5 * stats_bar_text_len; // clear any unused slots in the watch list and recalc how many are being displayed if (max_disp_stats < MAX_WATCH_STATS) { size_t i; for (i=max_disp_stats;i<MAX_WATCH_STATS;i++) if (watch_this_stats[i] > 0) { statsinfo[watch_this_stats[i]-1].is_selected=0; watch_this_stats[i]=0; } } actual_num_exp = get_num_statsbar_exp(); // the x position of the first exp bar, keep right aligned exp_bar_start_x = window_width + exp_bar_text_len - HUD_MARGIN_X - 2 - actual_num_exp * (exp_bar_text_len + stats_bar_len); // apologise if we had to reduce the number of exp bars if (num_exp > actual_num_exp) LOG_TO_CONSOLE(c_red2, remove_bar_message_str); // create the exp bars context menu, used by all ative exp bars if (!cm_valid(cm_id)) { int thestat; cm_id = cm_create(NULL, cm_statsbar_handler); for (thestat=0; thestat<NUM_WATCH_STAT-1; thestat++) cm_add(cm_id, (char *)statsinfo[thestat].skillnames->name, NULL); cm_add(cm_id, cm_stats_bar_base_str, NULL); cm_set_pre_show_handler(cm_id,cm_statsbar_pre_show_handler); } reset_statsbar_exp_cm_regions(); for (i=0; i<MAX_WATCH_STATS; i++) { if (watch_this_stats[i] > 0) statsinfo[watch_this_stats[i]-1].is_selected = 1; } return 1; }