void create_update_root_window (int width, int height, int time, int next_window) { if (update_root_win < 0) { float window_ratio = (float) height / 480.0f; int restart_width = (strlen(restart_now_label) * 11) + 40; int abort_width = (strlen(abort_restart_label) * 11) + 40; int restart_x = (width - restart_width - abort_width - 50) /2; int restart_height = 32; update_root_win = create_window ("Update", -1, -1, 0, 0, width, height, ELW_TITLE_NONE|ELW_SHOW_LAST); update_root_restart_id = button_add_extended (update_root_win, update_root_restart_id, NULL, restart_x, height - (160 * window_ratio), restart_width, restart_height, 0, 1.0f, 1.0f, 1.0f, 1.0f, restart_now_label); update_root_abort_id = button_add_extended (update_root_win, update_root_abort_id, NULL, restart_x + restart_width + 50, height - (160 * window_ratio), abort_width, restart_height, 0, 1.0f, 1.0f, 1.0f, 1.0f, abort_restart_label); set_window_handler (update_root_win, ELW_HANDLER_DISPLAY, &display_update_root_handler); set_window_handler (update_root_win, ELW_HANDLER_CLICK, &click_update_root_handler); set_window_handler (update_root_win, ELW_HANDLER_KEYPRESS, &keypress_update_root_handler); set_window_handler (update_root_win, ELW_HANDLER_SHOW, &show_update_handler); widget_set_OnClick(update_root_win, update_root_restart_id, &click_update_root_restart); widget_set_OnClick(update_root_win, update_root_abort_id, &click_update_root_abort); } init_update_interface (1.0, time, width, height, next_window); }
void display_popup_win (INPUT_POPUP *ipu, const char* label) { widget_list *wok; widget_list *wno; if(ipu->popup_win < 0) { Uint32 flags = ELW_WIN_DEFAULT & ~ELW_CLOSE_BOX; ipu->popup_win = create_window (win_prompt, ipu->parent, 0, ipu->x, ipu->y, ipu->popup_x_len, ipu->popup_y_len, flags); // clear the buffer init_text_message (&ipu->popup_text, ipu->maxlen); set_text_message_color (&ipu->popup_text, 0.77f, 0.57f, 0.39f); // Label ipu->popup_label = label_add (ipu->popup_win, NULL, label, 5, 5); widget_set_color (ipu->popup_win, ipu->popup_label, 0.77f, 0.57f, 0.39f); // Input ipu->popup_field = text_field_add_extended (ipu->popup_win, 101, NULL, 5, 28, ipu->popup_x_len - 10, 28*ipu->rows, ipu->text_flags, 1.0f, 0.77f, 0.57f, 0.39f, &ipu->popup_text, 1, FILTER_ALL, 5, 5); widget_set_color (ipu->popup_win, ipu->popup_field, 0.77f, 0.57f, 0.39f); // Accept ipu->popup_ok = button_add (ipu->popup_win, NULL, button_okay, 0, 0); widget_set_OnClick (ipu->popup_win, ipu->popup_ok, popup_ok_button_handler); widget_set_color (ipu->popup_win, ipu->popup_ok, 0.77f, 0.57f, 0.39f); // Reject ipu->popup_no = button_add (ipu->popup_win, NULL, button_cancel, 0, 0); widget_set_OnClick (ipu->popup_win, ipu->popup_no, popup_cancel_button_handler); widget_set_color (ipu->popup_win, ipu->popup_no, 0.77f, 0.57f, 0.39f); // align the buttons wok = widget_find(ipu->popup_win, ipu->popup_ok); wno = widget_find(ipu->popup_win, ipu->popup_no); widget_move(ipu->popup_win, ipu->popup_ok, (ipu->popup_x_len - wok->len_x - wno->len_x)/3, ipu->popup_y_len - (wok->len_y + 5)); widget_move(ipu->popup_win, ipu->popup_no, wok->len_x + 2*(ipu->popup_x_len - wok->len_x - wno->len_x)/3, ipu->popup_y_len - (wno->len_y + 5)); set_window_handler (ipu->popup_win, ELW_HANDLER_KEYPRESS, popup_keypress_handler); if ((ipu->popup_win > -1) && (ipu->popup_win < windows_list.num_windows)) windows_list.window[ipu->popup_win].data = ipu; } else { if ((ipu->parent > -1) && (ipu->parent < windows_list.num_windows)) { window_info *win = &windows_list.window[ipu->parent]; move_window(ipu->popup_win, ipu->parent, 0, win->pos_x+ipu->x, win->pos_y+ipu->y); } text_field_clear(ipu->popup_win, ipu->popup_field); label_set_text (ipu->popup_win, ipu->popup_label, label); show_window (ipu->popup_win); select_window (ipu->popup_win); } }
static int display_accept_buddy(char *name) { window_info *win = NULL; int label_id = 101, yes_button = 102, no_button = 103; char string[250] = {0}; int current_window; for(current_window = 0; current_window < MAX_ACCEPT_BUDDY_WINDOWS; current_window++) { /* Find a free slot in the array */ if(accept_windows[current_window].window_id == -1) { break; } } if (current_window >= MAX_ACCEPT_BUDDY_WINDOWS) { // uh oh, no free window return -1; } safe_snprintf(accept_windows[current_window].name, sizeof (accept_windows[current_window].name), "%s", name); accept_windows[current_window].window_id = create_window(buddy_accept_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, (ELW_USE_UISCALE|ELW_WIN_DEFAULT) ^ ELW_CLOSE_BOX); set_window_handler(accept_windows[current_window].window_id, ELW_HANDLER_DISPLAY, &display_accept_buddy_handler); set_window_handler(accept_windows[current_window].window_id, ELW_HANDLER_UI_SCALE, &ui_scale_accept_handler ); if (accept_windows[current_window].window_id <=0 || accept_windows[current_window].window_id >= windows_list.num_windows) return -1; win = &windows_list.window[accept_windows[current_window].window_id]; /* Add text */ safe_snprintf(string, sizeof(string), buddy_wants_to_add_str, accept_windows[current_window].name); accept_windows[current_window].text = malloc((strlen(string)+5)*sizeof(*accept_windows[current_window].text)); /* Add checkbox if we don't have him/her in our list. */ if(!is_in_buddylist(accept_windows[current_window].name)) { accept_windows[current_window].checkbox = checkbox_add(win->window_id, NULL, 0, 0, win->small_font_len_y, win->small_font_len_y, NULL); label_id = label_add_extended(win->window_id, label_id, NULL, 0, 0, 0, win->current_scale * DEFAULT_SMALL_RATIO, -1, -1, -1, buddy_add_to_list_str); widget_set_OnClick(win->window_id, label_id, click_accept_checkbox_label); } /* Add buttons */ yes_button = button_add_extended(win->window_id, yes_button, NULL, 0, 0, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, yes_str); no_button = button_add_extended(win->window_id, no_button, NULL, 0, 0, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, no_str); widget_set_OnClick(win->window_id, yes_button, click_accept_yes); widget_set_OnClick(win->window_id, no_button, click_accept_no); ui_scale_accept_handler(win); return win->window_id; }
void fill_notepad_window() { int i, tmp; widget_list *wnew; widget_list *wsave; int note_tabs_width = notepad_win_x_len; int note_tabs_height = notepad_win_y_len - 5; note_button_scroll_height = note_tabs_height - 55 - 20; // -20 for the tab tags note_button_width = (note_tabs_width - note_button_scroll_width - note_button_x_space - 15) / 2; set_window_handler(notepad_win, ELW_HANDLER_DISPLAY, &display_notepad_handler); set_window_handler(notepad_win, ELW_HANDLER_CLICK, &click_buttonwin_handler); note_tabcollection_id = tab_collection_add (notepad_win, NULL, 0, 5, note_tabs_width, note_tabs_height, 20); widget_set_size (notepad_win, note_tabcollection_id, 0.7); widget_set_color (notepad_win, note_tabcollection_id, 0.77f, 0.57f, 0.39f); main_note_tab_id = tab_add (notepad_win, note_tabcollection_id, tab_main, 0, 0, 0); widget_set_color (notepad_win, main_note_tab_id, 0.77f, 0.57f, 0.39f); set_window_handler(main_note_tab_id, ELW_HANDLER_CLICK, &click_buttonwin_handler); // Add Category new_note_button_id = button_add(main_note_tab_id, NULL, button_new_category, 0, 0); widget_set_OnClick(main_note_tab_id, new_note_button_id, notepad_add_category); widget_set_color(main_note_tab_id, new_note_button_id, 0.77f, 0.57f, 0.39f); // Save Notes save_notes_button_id = button_add(main_note_tab_id, NULL, button_save_notes, 0, 0); widget_set_OnClick(main_note_tab_id, save_notes_button_id, click_save_handler); widget_set_color(main_note_tab_id, save_notes_button_id, 0.77f, 0.57f, 0.39f); // align the buttons wnew = widget_find(main_note_tab_id, new_note_button_id); wsave = widget_find(main_note_tab_id, save_notes_button_id); tmp = (notepad_win_x_len - note_button_scroll_width)/2; widget_move(main_note_tab_id, new_note_button_id, (tmp - wnew->len_x)/2, 10); widget_move(main_note_tab_id, save_notes_button_id, tmp + (tmp - wsave->len_x)/2, 10); notepad_load_file (); init_ipu (&popup_str, main_note_tab_id, NOTE_NAME_LEN*DEFAULT_FONT_X_LEN, 100, NOTE_NAME_LEN, 1, NULL, notepad_add_continued); popup_str.x = (notepad_win_x_len - popup_str.popup_x_len) / 2; popup_str.y = (notepad_win_y_len - popup_str.popup_y_len) / 2; note_button_scroll_id = vscrollbar_add (main_note_tab_id, NULL, note_tabs_width - note_button_scroll_width - 5, 50, note_button_scroll_width, note_button_scroll_height); widget_set_OnClick (main_note_tab_id, note_button_scroll_id, note_button_scroll_handler); widget_set_OnDrag (main_note_tab_id, note_button_scroll_id, note_button_scroll_handler); // Add the note selection buttons and their scroll bar for(i = 0; i < nr_notes; i++) note_button_add (i, i); update_note_button_scrollbar (0); }
static void open_note_tab_continued(int id) { int tf_x = 10; int tf_y = 45; int tf_width = notepad_win_x_len - 20; int tf_height = notepad_win_y_len - 80; int tab; note_list[id].window = tab_add (notepad_win, note_tabcollection_id, note_list[id].name, 0, 1, 0); widget_set_color (notepad_win, note_list[id].window, 0.77f, 0.57f, 0.39f); // input text field note_list[id].input = text_field_add_extended(note_list[id].window, note_widget_id++, NULL, tf_x, tf_y, tf_width, tf_height, TEXT_FIELD_BORDER|TEXT_FIELD_EDITABLE|TEXT_FIELD_CAN_GROW|TEXT_FIELD_SCROLLBAR, note_zoom, 0.77f, 0.57f, 0.39f, ¬e_list[id].text, 1, FILTER_ALL, 5, 5); // remove button note_list[id].button = button_add (note_list[id].window, NULL, button_remove_category, 20, 8); widget_set_OnClick(note_list[id].window, note_list[id].button, notepad_remove_category); widget_set_color(note_list[id].window, note_list[id].button, 0.77f, 0.57f, 0.39f); widget_set_OnMouseover(note_list[id].window, note_list[id].button, mouseover_remove_handler); set_window_handler (note_list[id].window, ELW_HANDLER_DESTROY, note_tab_destroy); tab = tab_collection_get_tab_nr (notepad_win, note_tabcollection_id, note_list[id].window); tab_collection_select_tab (notepad_win, note_tabcollection_id, tab); }
void create_update_root_window (int width, int height, int time) { if (update_root_win < 0) { window_info *win = NULL; int update_root_restart_id = 0; update_root_win = create_window ("Update", -1, -1, 0, 0, width, height, ELW_USE_UISCALE|ELW_TITLE_NONE|ELW_SHOW_LAST); if (update_root_win < 0 || update_root_win >= windows_list.num_windows) return; win = &windows_list.window[update_root_win]; update_root_restart_id = button_add_extended (update_root_win, update_root_restart_id, NULL, 0, 0, 0, 0, 0, win->current_scale, 1.0f, 1.0f, 1.0f, restart_now_label); widget_move(update_root_win, update_root_restart_id, (width - widget_get_width(update_root_win, update_root_restart_id)) /2, height - 2 * widget_get_height(update_root_win, update_root_restart_id)); set_window_handler (update_root_win, ELW_HANDLER_DISPLAY, &display_update_root_handler); set_window_handler (update_root_win, ELW_HANDLER_KEYPRESS, &keypress_update_root_handler); set_window_handler (update_root_win, ELW_HANDLER_SHOW, &show_update_handler); widget_set_OnClick(update_root_win, update_root_restart_id, &click_update_root_restart); } update_countdown = time; }
void display_buddy(void) { if(buddy_win < 0) { int our_root_win = -1; if (!windows_on_top) { our_root_win = game_root_win; } buddy_win = create_window(win_buddy, our_root_win, 0, buddy_menu_x, buddy_menu_y, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT); set_window_handler(buddy_win, ELW_HANDLER_DISPLAY, &display_buddy_handler ); set_window_handler(buddy_win, ELW_HANDLER_CLICK, &click_buddy_handler ); set_window_handler(buddy_win, ELW_HANDLER_UI_SCALE, &ui_scale_buddy_handler ); buddy_scroll_id = vscrollbar_add_extended (buddy_win, buddy_scroll_id, NULL, 0, 0, 0, 0, 0, 1.0, newcol_r, newcol_g, newcol_b, 0, 1, 0); buddy_button_id = button_add_extended(buddy_win, buddy_button_id, NULL, 0, 0, 0, 0, BUTTON_SQUARE, 1.0, newcol_r, newcol_g, newcol_b, buddy_add_str); widget_set_OnClick(buddy_win, buddy_button_id, click_buddy_button_handler); if (buddy_win >=0 && buddy_win < windows_list.num_windows) ui_scale_buddy_handler(&windows_list.window[buddy_win]); } else { toggle_window(buddy_win); } }
static void note_button_add(int nr, int next_id) { note_list[nr].button_id = button_add_extended (main_note_tab_id, next_id, NULL, 0, 0, note_button_width, note_button_height, 0, 0.8, 0.77f, 0.57f, 0.39f, note_list[nr].name); widget_set_OnClick (main_note_tab_id, note_list[nr].button_id, open_note_tab); note_button_set_pos (nr); update_note_button_scrollbar (nr); }
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 ); mixone_button_id=button_add_extended(manufacture_win, mixone_button_id, NULL, 33*6+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, 33*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, 33*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); //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, 33*6, SHOW_MAX_RECIPE*33, ELW_TITLE_NONE|ELW_SHOW|ELW_USE_BACKGROUND|ELW_ALPHA_BORDER|ELW_SWITCHABLE_OPAQUE|ELW_USE_BORDER); 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 ); hide_window(recipe_win); //start hidden } else { show_window(manufacture_win); if (!recipes_shown) hide_window(recipe_win); else show_window(recipe_win); select_window(manufacture_win); } }
void fill_session_win(void) { int reset_button_id = -1; set_window_handler(session_win, ELW_HANDLER_DISPLAY, &display_session_handler); reset_button_id=button_add_extended(session_win, reset_button_id, NULL, 450, 3, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, reset_str); widget_set_OnClick(session_win, reset_button_id, session_reset_handler); widget_set_OnMouseover(session_win, reset_button_id, mouseover_session_reset_handler); }
void fill_session_win(int window_id) { set_window_handler(window_id, ELW_HANDLER_DISPLAY, &display_session_handler); set_window_handler(window_id, ELW_HANDLER_CLICK, &click_session_handler ); set_window_handler(window_id, ELW_HANDLER_MOUSEOVER, &mouseover_session_handler ); set_window_handler(window_id, ELW_HANDLER_RESIZE, &resize_session_handler ); reset_button_id=button_add_extended(window_id, reset_button_id, NULL, 0, 0, 0, 0, 0, 1.0f, 0.77f, 0.57f, 0.39f, reset_str); widget_set_OnClick(window_id, reset_button_id, session_reset_handler); widget_set_OnMouseover(window_id, reset_button_id, mouseover_session_reset_handler); }
void fill_knowledge_win (int window_id) { set_window_handler(window_id, ELW_HANDLER_DISPLAY, &display_knowledge_handler ); set_window_handler(window_id, ELW_HANDLER_CLICK, &click_knowledge_handler ); set_window_handler(window_id, ELW_HANDLER_MOUSEOVER, &mouseover_knowledge_handler ); set_window_handler(window_id, ELW_HANDLER_RESIZE, &resize_knowledge_handler ); knowledge_scroll_id = vscrollbar_add_extended (window_id, knowledge_scroll_id, NULL, 0, 0, 0, 0, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, (knowledge_count+1)/2-displayed_book_rows); knowledge_book_image_id = add_knowledge_book_image(window_id); widget_set_OnClick(window_id, knowledge_book_image_id, &handle_knowledge_book); knowledge_book_label_id = label_add_extended(window_id, knowledge_book_image_id + 1, NULL, 0, 0, WIDGET_DISABLED, 0.8, 1.0, 1.0, 1.0, knowledge_read_book); widget_set_OnClick(window_id, knowledge_book_label_id, &handle_knowledge_book); if (cm_valid(!cm_know_id)) { cm_know_id = cm_create(know_highlight_cm_str, cm_knowledge_handler); cm_add_window(cm_know_id, window_id); init_ipu(&ipu_know, -1, 1, 1, 1, NULL, NULL); } }
void fill_session_win(void) { int reset_button_id = -1; set_window_handler(session_win, ELW_HANDLER_DISPLAY, &display_session_handler); set_window_handler(session_win, ELW_HANDLER_CLICK, &click_session_handler ); set_window_handler(session_win, ELW_HANDLER_MOUSEOVER, &mouseover_session_handler ); reset_button_id=button_add_extended(session_win, reset_button_id, NULL, 450, 280, 0, 0, 0, 1.0f, newcol_r, newcol_g, newcol_b, reset_str); widget_set_OnClick(session_win, reset_button_id, session_reset_handler); widget_set_OnMouseover(session_win, reset_button_id, mouseover_session_reset_handler); }
/* fill the URL window created as a tab. */ void fill_url_window(void) { const Uint32 scroll_width = 20; const Uint32 cross_height = 20; int clear_all_button = 101; widget_list *widget; /* create the main window */ url_win_x_len = INFO_TAB_WIDTH; url_win_y_len = INFO_TAB_HEIGHT; url_win_max_string_width = url_win_x_len - (2*url_win_sep + scroll_width); set_window_handler(url_win, ELW_HANDLER_DISPLAY, &display_url_handler ); set_window_handler(url_win, ELW_HANDLER_CLICK, &click_url_handler ); /* create the clear all button */ clear_all_button = button_add_extended (url_win, clear_all_button, NULL, url_win_sep, url_win_sep, 0, 0, 0, 0.75, 0.77f, 0.57f, 0.39f, "CLEAR ALL "); widget_set_OnClick(url_win, clear_all_button, url_win_click_clear_all); widget = widget_find(url_win, clear_all_button); widget_set_OnMouseover(url_win, clear_all_button, url_win_mouseover_clear_all); /* calc text and help postions from size of other stuff */ url_win_text_start_y = 2*url_win_sep + ((widget->len_y > cross_height) ?widget->len_y :cross_height); url_win_line_step = (int)(3 + DEFAULT_FONT_Y_LEN * url_win_text_zoom); url_win_text_len_y = 12 * url_win_line_step; url_win_full_url_y_len = url_win_sep + 3 * SMALL_FONT_Y_LEN; url_win_y_len = url_win_text_start_y + url_win_text_len_y + url_win_sep + url_win_full_url_y_len; url_win_help_x = widget->len_x + 2 * url_win_sep; url_win_url_y_start = url_win_y_len - url_win_full_url_y_len - url_win_sep/2; resize_window (url_win, url_win_x_len, url_win_y_len); /* create the scroll bar */ url_scroll_id = vscrollbar_add_extended(url_win, url_scroll_id, NULL, url_win_x_len - scroll_width, url_win_text_start_y, scroll_width, url_win_text_len_y, 0, 1.0, 0.77f, 0.57f, 0.39f, 0, 1, have_url_count); widget_set_OnDrag(url_win, url_scroll_id, url_win_scroll_drag); widget_set_OnClick(url_win, url_scroll_id, url_win_scroll_click); }
int display_buddy_add(void) { if(buddy_add_win < 0) { int label_id = 100, input_id = 101, button_id = 102; window_info *win = NULL; int label_width = 0; int win_x_len = 0; int win_y_len = 0; /* Create the window */ buddy_add_win = create_window(buddy_add_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT); if (buddy_add_win <=0 || buddy_add_win >= windows_list.num_windows) return -1; win = &windows_list.window[buddy_add_win]; /* Add name input and label */ label_id = label_add_extended(buddy_add_win, label_id, NULL, buddy_border_space, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_str); label_width = widget_get_width(buddy_add_win, label_id); input_id = pword_field_add_extended(buddy_add_win, input_id, NULL, 2 * buddy_border_space + label_width, buddy_border_space, MAX_USERNAME_LENGTH * win->default_font_len_x, win->default_font_len_y + buddy_border_space, P_TEXT, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_buffer, MAX_USERNAME_LENGTH); widget_set_OnMouseover(buddy_add_win, label_id, name_onmouseover_handler); widget_set_OnMouseover(buddy_add_win, input_id, name_onmouseover_handler); widget_set_OnKey(buddy_add_win, input_id, name_input_keypress_handler); /* Add "Add buddy" button */ button_id = button_add_extended(buddy_add_win, button_id, NULL, 0, 0, 0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_add_str); widget_set_OnClick(buddy_add_win, button_id, click_add_buddy_handler); /* Resize window and centre button */ win_x_len = 3 * buddy_border_space + label_width + widget_get_width(buddy_add_win, input_id) + win->box_size; win_y_len = 3 * buddy_border_space + widget_get_height(buddy_add_win, input_id) + widget_get_height(buddy_add_win, button_id); resize_window(buddy_add_win, win_x_len, win_y_len); widget_move(buddy_add_win, button_id, (win_x_len - widget_get_width(buddy_add_win, button_id)) / 2, 3 * buddy_border_space + win->default_font_len_y); return buddy_add_win; } else { toggle_window(buddy_add_win); return buddy_add_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); } }
static int display_buddy_change(_buddy *buddy) { int label_id = 100, name_id = 101, type_label_id = 102, checkbox_id = 103, checkbox_label_id = 104, change_button_id = 105; int buddy_change_x_len = 0; int buddy_change_y_len = 0; window_info *win = NULL; int tmp_width = 0; buddy_to_change = buddy->name; if(buddy_change_win >= 0) { /* Destroy the window to make sure everything's set up. */ destroy_window(buddy_change_win); buddy_change_win = -1; buddy_delete = 0; } /* Create the window */ buddy_change_win = create_window(buddy_change_str, buddy_win, 0, buddy_menu_x_len/2, buddy_menu_y_len/4, 0, 0, ELW_USE_UISCALE|ELW_WIN_DEFAULT); if (buddy_change_win <=0 || buddy_change_win >= windows_list.num_windows) return -1; win = &windows_list.window[buddy_change_win]; /* Add name label and name */ label_id = label_add_extended(buddy_change_win, label_id, NULL, buddy_border_space, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_name_str); tmp_width = widget_get_width(buddy_change_win, label_id); name_id = label_add_extended(buddy_change_win, name_id, NULL, 2 * buddy_border_space + tmp_width, buddy_border_space, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_to_change); buddy_change_x_len = 3 * buddy_border_space + tmp_width + MAX_USERNAME_LENGTH * win->default_font_len_x + win->box_size; buddy_change_y_len = 2 * buddy_border_space + widget_get_height(buddy_change_win, name_id); buddy_type_input_id = -1; if (buddy->type < 0xFE) { size_t i; const size_t num_type_labels = 5; char * type_labels_text[] = {buddy_white_str, buddy_red_str, buddy_green_str, buddy_blue_str, buddy_yellow_str}; /* Add type label and input widget */ type_label_id = label_add_extended(buddy_change_win, type_label_id, NULL, buddy_border_space, buddy_change_y_len, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_type_str); tmp_width = widget_get_width(buddy_change_win, type_label_id); buddy_type_input_id = multiselect_add(buddy_change_win, NULL, 2 * buddy_border_space + tmp_width, buddy_change_y_len, buddy_change_x_len - tmp_width - 3 * buddy_border_space); for (i=0; i<num_type_labels; i++) multiselect_button_add_extended(buddy_change_win, buddy_type_input_id, 0, i * 25 * win->current_scale, 0, type_labels_text[i], DEFAULT_SMALL_RATIO * win->current_scale, i==0); multiselect_set_selected(buddy_change_win, buddy_type_input_id, buddy->type); widget_set_OnMouseover(buddy_change_win, label_id, type_onmouseover_handler); widget_set_OnMouseover(buddy_change_win, buddy_type_input_id, type_onmouseover_handler); if ((3 * buddy_border_space + tmp_width + widget_get_width(buddy_change_win, buddy_type_input_id)) > buddy_change_x_len) buddy_change_x_len = 3 * buddy_border_space + tmp_width + widget_get_width(buddy_change_win, buddy_type_input_id); buddy_change_y_len += buddy_border_space + multiselect_get_height(buddy_change_win, buddy_type_input_id); } /* Delete buddy checkbox and label */ checkbox_id = checkbox_add(buddy_change_win, NULL, 0, 0, win->default_font_len_y, win->default_font_len_y, &buddy_delete); checkbox_label_id = label_add_extended(buddy_change_win, checkbox_label_id, NULL, 0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_delete_str); widget_set_OnClick(buddy_change_win, checkbox_label_id, click_delete_checkbox_label); widget_set_OnMouseover(buddy_change_win, checkbox_label_id, delete_onmouseover_handler); tmp_width = widget_get_width(buddy_change_win, checkbox_id) + buddy_border_space + widget_get_width(buddy_change_win, checkbox_label_id); widget_move(buddy_change_win, checkbox_id, (buddy_change_x_len - tmp_width) / 2, buddy_change_y_len); widget_move(buddy_change_win, checkbox_label_id, buddy_change_x_len - ((buddy_change_x_len - tmp_width) / 2) - widget_get_width(buddy_change_win, checkbox_label_id), buddy_change_y_len); buddy_change_y_len += buddy_border_space + widget_get_height(buddy_change_win, checkbox_id); /* Change button */ change_button_id = button_add_extended(buddy_change_win, change_button_id, NULL, 0, 0, 0, 0, 0, win->current_scale, newcol_r, newcol_g, newcol_b, buddy_change_str); widget_set_OnClick(buddy_change_win, change_button_id, click_change_buddy_handler); widget_move(buddy_change_win, change_button_id, (buddy_change_x_len - widget_get_width(buddy_change_win, change_button_id)) / 2, buddy_change_y_len); buddy_change_y_len += buddy_border_space + widget_get_height(buddy_change_win, change_button_id); resize_window(buddy_change_win, buddy_change_x_len, buddy_change_y_len); return buddy_change_win; }