// handle context menu options // int Hud_Timer::cm_handler(window_info *win, int option) { switch (option) { case CMHT_MODE: toggle_mode(); break; case CMHT_RUNSTATE: toggle_running(); break; case CMHT_SETTIME: { if (!input) input = new INPUT_POPUP; else close_ipu(input); init_ipu(input, win->window_id, 220, -1, 4, 1, 0, set_timer_time); input->x = -230; input->y = last_base_y_start; display_popup_win(input, hud_timer_popup_title_str); } break; case CMHT_RESET: reset(); break; case CMHT_HELP: { const char *desc = get_option_description("view_hud_timer", INI_FILE_VAR); if (desc && (strlen(desc) > 0)) LOG_TO_CONSOLE(c_green1, desc); } break; case CMHT_KEEPSTATE: break; default: return 0; } return 1; }
static int cm_knowledge_handler(window_info *win, int widget_id, int mx, int my, int option) { switch (option) { case 0: close_ipu(&ipu_know); init_ipu(&ipu_know, win->window_id, 21, 1, 22, NULL, set_hightlight_callback); ipu_know.x = mx; ipu_know.y = my; display_popup_win(&ipu_know, know_highlight_prompt_str); if (ipu_know.popup_win >=0 && ipu_know.popup_win<windows_list.num_windows) windows_list.window[ipu_know.popup_win].opaque = 1; break; case 1: set_hightlight_callback("", NULL); break; case 2: { int i; for(i=0; i<knowledge_count; i++) if (knowledge_list[i].mouse_over) { copy_to_clipboard(knowledge_list[i].name); break; } } break; } return 1; }
// if we have a popup window for the timer, destroy it // void Hud_Timer::destroy_popup(void) { if (input) { close_ipu(input); delete input; input = 0; } }
/* Handle options selected from the main context menu */ static int cm_encycl_handler(window_info *win, int widget_id, int mx, int my, int option) { switch (option) { case CM_ENCYCL_INDEX: currentpage = page_index[ENCYCLT_ENCYC]; vscrollbar_set_pos(encyclopedia_win, encyclopedia_scroll_id, 0); vscrollbar_set_bar_len(encyclopedia_win, encyclopedia_scroll_id, Page[currentpage].max_y); break; case CM_ENCYCL_SEARCH: close_ipu(&ipu_encycl); init_ipu(&ipu_encycl, encyclopedia_win, DEFAULT_FONT_X_LEN * 20, -1, 40, 1, NULL, find_page_callback); ipu_encycl.x = mx; ipu_encycl.y = my; display_popup_win(&ipu_encycl, encycl_search_propmt); if (ipu_encycl.popup_win >=0 && ipu_encycl.popup_win<windows_list.num_windows) windows_list.window[ipu_encycl.popup_win].opaque = 1; break; case CM_ENCYCL_REPSEARCH: if (last_search != NULL) repeat_search = 1; break; case CM_ENCYCL_BOOKMARK: if (num_bookmarks < MAX_BOOKMARKS) { size_t i; for (i=0; i<num_page_links; i++) if(!xmlStrcasecmp((xmlChar*)Page[currentpage].Name,(xmlChar*)page_links[i].link)) { book_marks[num_bookmarks++] = i; rebuild_cm_encycl(); break; } } break; case CM_ENCYCL_UNBOOKMARK: { size_t i; size_t index = get_page_bookmark_index(); if (index < MAX_BOOKMARKS) { for (i=index+1; i<num_bookmarks; i++) book_marks[i-1] = book_marks[i]; num_bookmarks--; rebuild_cm_encycl(); } break; } case CM_ENCYCL_CLEARBOOKMARKS: num_bookmarks = 0; rebuild_cm_encycl(); break; default: open_page(book_marks[option-CM_ENCYCL_THEBOOKMARKS]); } return 1; }
// Prompt for the new list name, starting the process of adding a new list // void List_Window::new_or_rename_list(bool is_new) { if ((win_id < 0) || (win_id >= windows_list.num_windows)) return; window_info *win = &windows_list.window[win_id]; close_ipu(&ipu_item_list_name); init_ipu(&ipu_item_list_name, win_id, 310, 100, 25, 1, NULL, (is_new) ?new_list_handler :rename_list_handler); ipu_item_list_name.x = (win->len_x - ipu_item_list_name.popup_x_len) / 2; ipu_item_list_name.y = (get_grid_size()*num_grid_rows - ipu_item_list_name.popup_y_len) / 2; display_popup_win(&ipu_item_list_name, (is_new) ?item_list_name_str : item_list_rename_str ); }
// Create the window or just toggle its open/closed state. // void List_Window::show(window_info *win) { if (win_id < 0 ) { ItemLists::Vars::lists()->load(); ItemLists::Vars::cat_maps()->load(); filter[0] = '\0'; calc_num_show_names(get_grid_size()*6+110); add_button_x = static_cast<int>(get_size_x() - DEFAULT_FONT_X_LEN*2); add_button_y = get_grid_size(); win_id = create_window(item_list_preview_title, win->window_id, 0, get_window_pos_x(win), 0, get_size_x(), get_size_y(), ELW_WIN_DEFAULT|ELW_RESIZEABLE); set_window_handler(win_id, ELW_HANDLER_DISPLAY, (int (*)())&display_itemlist_handler ); set_window_handler(win_id, ELW_HANDLER_CLICK, (int (*)())&click_itemlist_handler ); set_window_handler(win_id, ELW_HANDLER_MOUSEOVER, (int (*)())&mouseover_itemlist_handler ); set_window_handler(win_id, ELW_HANDLER_HIDE, (int (*)())&hide_itemlist_handler ); set_window_handler(win_id, ELW_HANDLER_KEYPRESS, (int (*)())&keypress_itemlist_handler ); set_window_handler(win_id, ELW_HANDLER_RESIZE, (int (*)())&resize_itemlist_handler ); set_window_min_size(win_id, get_size_x(), get_size_y()); cm_selected_item_menu = cm_create(cm_item_list_selected_str, cm_selected_item_handler); cm_names_menu = cm_create(cm_item_list_names_str, cm_names_handler); cm_set_pre_show_handler(cm_names_menu, cm_names_pre_show_handler); cm_add_region(cm_names_menu, win_id, 0, get_size_y()-get_names_size_y(), get_size_y(), get_names_size_y()); names_scroll_id = vscrollbar_add_extended(win_id, 1, NULL, get_size_x()-ELW_BOX_SIZE, get_grid_size()*num_grid_rows, ELW_BOX_SIZE, get_names_size_y()-ELW_BOX_SIZE, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, Vars::lists()->size()-num_show_names_list); init_ipu(&ipu_item_list_name, -1, -1, -1, 1, 1, NULL, NULL); make_active_visable(); } else { toggle_window(win_id); make_active_visable(); close_ipu(&ipu_item_list_name); Vars::quantity_input()->close(); } }
~Quantity_Input(void) { close_ipu(&ipu); }