void draw_pick_up_menu() { if(ground_items_win < 0){ int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } if (ground_items_menu_x_len < (min_grid_cols+1)*GRIDSIZE || ground_items_menu_x_len >= window_width || ground_items_menu_y_len < min_grid_rows*GRIDSIZE || ground_items_menu_y_len >= window_height) { ground_items_menu_x_len=6*GRIDSIZE; ground_items_menu_y_len=10*GRIDSIZE; } ground_items_win= create_window(win_bag, our_root_win, 0, ground_items_menu_x, ground_items_menu_y, ground_items_menu_x_len, ground_items_menu_y_len, ELW_SCROLLABLE|ELW_RESIZEABLE|ELW_WIN_DEFAULT); set_window_handler(ground_items_win, ELW_HANDLER_DISPLAY, &display_ground_items_handler ); set_window_handler(ground_items_win, ELW_HANDLER_CLICK, &click_ground_items_handler ); set_window_handler(ground_items_win, ELW_HANDLER_MOUSEOVER, &mouseover_ground_items_handler ); set_window_handler(ground_items_win, ELW_HANDLER_RESIZE, &resize_ground_items_handler ); set_window_handler(ground_items_win, ELW_HANDLER_CLOSE, &clear_groundlist ); set_window_min_size(ground_items_win, (min_grid_cols+1)*GRIDSIZE, min_grid_rows*GRIDSIZE); set_window_scroll_inc(ground_items_win, GRIDSIZE/3); set_window_scroll_yoffset(ground_items_win, GRIDSIZE); resize_ground_items_handler(&windows_list.window[ground_items_win]); } else { show_window(ground_items_win); select_window(ground_items_win); } set_window_scroll_pos(ground_items_win, 0); }
// 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(); } }
// Called when UI scaling changed static int ui_scale_manufacture_handler(window_info *win) { int mbw = (int)(0.5 + 43 * win->current_scale); int cbw = (int)(0.5 + 70 * win->current_scale); int space = (int)(0.5 + 7 * win->current_scale); int free_x = 0; SLOT_SIZE = (int)(0.5 + 33 * win->current_scale); PIPE_CONTROL_X = (int)(0.5 + 5 * win->current_scale) * 2 + win->small_font_len_x; recipe_win_width = SLOT_SIZE * NUM_MIX_SLOTS + win->box_size + 2; manufacture_menu_x_len = GRID_COLS * SLOT_SIZE + win->box_size; manufacture_menu_y_len = (GRID_ROWS+1) * SLOT_SIZE + (4+1) * win->small_font_len_y; text_y_offset = SLOT_SIZE + 4 + 4.5 * win->small_font_len_y; recipe_y_offset = SLOT_SIZE + 4; control_elem_size = (int)(0.5 + 5 * win->current_scale); free_x = manufacture_menu_x_len - (cbw + 2*mbw + 3*space); pipeline_x = space + cbw + free_x/2 - (SLOT_SIZE*NUM_MIX_SLOTS + PIPE_CONTROL_X)/2; resize_window(win->window_id, manufacture_menu_x_len, manufacture_menu_y_len); button_resize(win->window_id, mixone_button_id, mbw, 0, win->current_scale); button_resize(win->window_id, mixall_button_id, mbw, 0, win->current_scale); button_resize(win->window_id, clear_button_id, cbw, 0, win->current_scale); widget_move(win->window_id, mixone_button_id, manufacture_menu_x_len-2*(mbw+space), manufacture_menu_y_len - recipe_y_offset); widget_move(win->window_id, mixall_button_id, manufacture_menu_x_len-(mbw+space), manufacture_menu_y_len - recipe_y_offset); widget_move(win->window_id, clear_button_id, space, manufacture_menu_y_len - recipe_y_offset); if ((recipe_win > -1) && (recipe_win < windows_list.num_windows)) { set_window_min_size(recipe_win, recipe_win_width, 4*SLOT_SIZE); move_window(recipe_win, win->window_id, 0, win->pos_x + pipeline_x, win->pos_y + manufacture_menu_y_len - 2); resize_window(recipe_win, recipe_win_width, num_displayed_recipes*SLOT_SIZE); } last_items_string_id = (size_t)-1; return 1; }
void display_manufacture_menu() { if(manufacture_win < 0){ static int clear_button_id=100; static int mixone_button_id=101; static int mixall_button_id=102; 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, manufacture_menu_x_len, manufacture_menu_y_len, 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 ); mixone_button_id=button_add_extended(manufacture_win, mixone_button_id, NULL, SLOT_SIZE*NUM_MIX_SLOTS+15+10, manufacture_menu_y_len-36, 43, 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, SLOT_SIZE*8+10, manufacture_menu_y_len-36, 43, 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, SLOT_SIZE*9+18+10, manufacture_menu_y_len-36, 70, 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, 2, manufacture_menu_y_len-2, recipe_win_width, num_displayed_recipes*SLOT_SIZE, 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, recipe_win_width-ELW_BOX_SIZE, 0, ELW_BOX_SIZE, num_displayed_recipes*SLOT_SIZE - ELW_BOX_SIZE, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, num_recipe_entries-num_displayed_recipes); set_window_min_size(recipe_win, recipe_win_width, 4*SLOT_SIZE); // 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); } }