int recipe_dropdown_draw(window_info *win){ int i; for (i=0;i<SHOW_MAX_RECIPE;i++){ draw_production_pipe(0,33*i,i); } draw_production_pipe(0,33*cur_recipe,cur_recipe); if ((cur_recipe < SHOW_MAX_RECIPE) && (recipe_name[cur_recipe] != NULL)) show_help(recipe_name[cur_recipe], win->len_x+5, 33*cur_recipe+(33-SMALL_FONT_Y_LEN)/2); if (mouse_over_recipe != -1) { if ((mouse_over_recipe != cur_recipe) && (mouse_over_recipe < SHOW_MAX_RECIPE) && (recipe_name[mouse_over_recipe] != NULL)) show_help(recipe_name[mouse_over_recipe], win->len_x+5, 33*mouse_over_recipe+(33-SMALL_FONT_Y_LEN)/2); if (show_help_text) { show_help(recipe_select_str, 0, win->len_y+10); show_help(recipe_load_str, 0, win->len_y+10+SMALL_FONT_Y_LEN); } } mouse_over_recipe = -1; return 1; }
/* draw the recipes - finishing any resize to snap to a reasonable size */ static int recipe_dropdown_draw(window_info *win){ static int resizing = 0; size_t i; int first_displayed_recipe = vscrollbar_get_pos (win->window_id, recipe_win_scroll_id); int relative_cur = cur_recipe - first_displayed_recipe; int help_line = 0; int find_active = 0; /* if resizing wait until we stop */ if (win->resized) resizing = 1; /* once we stop, snap the window size to fit nicely */ else if (resizing) { resizing = 0; num_displayed_recipes = (int)(win->len_y / SLOT_SIZE); if (num_displayed_recipes > num_recipe_entries) num_displayed_recipes = num_recipe_entries; resize_window(win->window_id, recipe_win_width, num_displayed_recipes*SLOT_SIZE); } /* draw all the shown recipes */ for (i=0; i<num_displayed_recipes && i<num_recipe_entries; i++) draw_production_pipe(win,0,SLOT_SIZE*i,i+first_displayed_recipe); /* if shown, the current (highlighted in red) recipe needs drawing again and its name displayed */ if ((relative_cur >= 0) && (relative_cur < num_displayed_recipes)) { draw_production_pipe(win,0,SLOT_SIZE*relative_cur,cur_recipe); if ((cur_recipe < num_recipe_entries) && (recipes_store[cur_recipe].name != NULL)) show_help(recipes_store[cur_recipe].name, win->len_x+5, SLOT_SIZE*relative_cur+(SLOT_SIZE-win->small_font_len_y)/2, win->current_scale); } /* display any name search text */ if (strlen(recipe_name_filter)) { if (SDL_GetTicks() > (last_recipe_key_time+5000)) clear_recipe_filter(); else { static char tmp[30]; safe_snprintf(tmp, sizeof(tmp), "%s[%s]", item_list_find_str, recipe_name_filter); show_help(tmp, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); find_active = 1; } } /* display the name of the recipe with the mouse over, plus general help */ if (mouse_over_recipe != -1) { size_t actual_recipe = mouse_over_recipe + first_displayed_recipe; if ((actual_recipe != cur_recipe) && (actual_recipe < num_recipe_entries) && (recipes_store[actual_recipe].name != NULL)) show_help(recipes_store[actual_recipe].name, win->len_x+5, SLOT_SIZE*mouse_over_recipe+(SLOT_SIZE-win->small_font_len_y)/2, win->current_scale); if (show_help_text) { show_help(cm_help_options_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(recipe_select_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(recipe_load_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); show_help(find_active?recipe_during_find_str:recipe_find_str, 0, win->len_y + 10 + win->small_font_len_y*help_line++, win->current_scale); } } mouse_over_recipe = -1; return 1; }
static int display_manufacture_handler(window_info *win) { Uint8 str[80]; int i; // keep the main and recipe windows opacity in sync if (recipe_win >= 0) { static int last_recipes_opaque = -1, last_main_opaque = -1; if (win->opaque != last_main_opaque) last_recipes_opaque = last_main_opaque = windows_list.window[recipe_win].opaque = win->opaque; else if (windows_list.window[recipe_win].opaque != last_recipes_opaque) last_recipes_opaque = last_main_opaque = win->opaque = windows_list.window[recipe_win].opaque; } glColor3f(0.77f,0.57f,0.39f); glEnable(GL_TEXTURE_2D); glColor3f(1.0f,1.0f,1.0f); //ok, now let's draw the objects... for(i=35;i>=0;i--){ if(manufacture_list[i].quantity > 0) { int x_start,y_start; int use_large = (mouse_over_main_pos == i) && enlarge_text(); //get the x and y x_start=SLOT_SIZE*(i%GRID_COLS)+1; y_start=SLOT_SIZE*(i/GRID_COLS); draw_item(manufacture_list[i].image_id,x_start,y_start,SLOT_SIZE); safe_snprintf((char *)str, sizeof(str), "%i",manufacture_list[i].quantity); y_start += (i&1) ? 2 : SLOT_SIZE - ((use_large) ?win->default_font_len_y :win->small_font_len_y); if (use_large) draw_string_shadowed_zoomed(x_start, y_start, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale); else draw_string_small_shadowed_zoomed(x_start, y_start, (unsigned char*)str, 1, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, win->current_scale); } } //ok, now let's draw the mixed objects draw_production_pipe(win, pipeline_x,manufacture_menu_y_len-recipe_y_offset, -1); //now, draw the inventory text, if any. if (last_items_string_id != inventory_item_string_id) { put_small_text_in_box_zoomed((unsigned char*)inventory_item_string, strlen(inventory_item_string), win->len_x-2*win->small_font_len_x, items_string, win->current_scale); last_items_string_id = inventory_item_string_id; } draw_string_small_zoomed(win->small_font_len_x,manufacture_menu_y_len-text_y_offset,(unsigned char *)items_string,4, win->current_scale); // Render the grid *after* the images. It seems impossible to code // it such that images are rendered exactly within the boxes on all // cards glDisable(GL_TEXTURE_2D); glColor3f(0.77f,0.57f,0.39f); //draw the grid rendergrid(GRID_COLS, GRID_ROWS, 0, 0, SLOT_SIZE, SLOT_SIZE); //Draw recipe control buttons draw_recipe_controls(win); glEnable(GL_TEXTURE_2D); mouse_over_main_pos = -1; mouse_over_pipe_pos = -1; #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }
int display_manufacture_handler(window_info *win) { Uint8 str[80]; int i; //dirty hack for opacity //if manufacture_win is opaque then recipe_win should be and viceversa if (recipes_shown) win->opaque=windows_list.window[recipe_win].opaque; else windows_list.window[recipe_win].opaque=win->opaque; glColor3f(0.77f,0.57f,0.39f); glEnable(GL_TEXTURE_2D); glColor3f(1.0f,1.0f,1.0f); //ok, now let's draw the objects... for(i=35;i>=0;i--){ if(manufacture_list[i].quantity > 0) { int x_start,y_start; //get the x and y x_start=33*(i%12)+1; y_start=33*(i/12); draw_item(manufacture_list[i].image_id,x_start,y_start,33); safe_snprintf((char *)str, sizeof(str), "%i",manufacture_list[i].quantity); draw_string_small_shadowed(x_start, (i&1)?(y_start+17):(y_start+7), (unsigned char*)str, 1,1.0f,1.0f,1.0f, 0.0f, 0.0f, 0.0f); } } //ok, now let's draw the mixed objects draw_production_pipe(2,manufacture_menu_y_len-37, -1); //now, draw the inventory text, if any. if (last_items_string_id != inventory_item_string_id) { put_small_text_in_box((unsigned char*)inventory_item_string, strlen(inventory_item_string), win->len_x-8, items_string); last_items_string_id = inventory_item_string_id; } draw_string_small(4,manufacture_menu_y_len-85,(unsigned char *)items_string,4); // Render the grid *after* the images. It seems impossible to code // it such that images are rendered exactly within the boxes on all // cards glDisable(GL_TEXTURE_2D); glColor3f(0.77f,0.57f,0.39f); //draw the grid rendergrid(12,3,0,0,33,33); //Draw the bottom grid - NOT NEEDED, DONE IN draw_production_pipe //rendergrid(6,1,0, manufacture_menu_y_len-37, 33, 33); //Draw recipe control buttons draw_recipe_controls(); glEnable(GL_TEXTURE_2D); #ifdef OPENGL_TRACE CHECK_GL_ERRORS(); #endif //OPENGL_TRACE return 1; }