int eof_menu_help_keys(void) { eof_help_text = eof_buffer_file("keys.txt", 1); //Buffer the help file into memory, appending a NULL terminator if(eof_help_text == NULL) { //Could not buffer file allegro_message("Error reading keys.txt"); return 1; } eof_help_dialog[2].dp = eof_help_text; //Use the buffered file for the text box eof_cursor_visible = 0; eof_pen_visible = 0; eof_render(); eof_color_dialog(eof_help_dialog, gui_fg_color, gui_bg_color); centre_dialog(eof_help_dialog); if(eof_popup_dialog(eof_help_dialog, 0) == 1) { } eof_show_mouse(NULL); eof_cursor_visible = 1; eof_pen_visible = 1; free(eof_help_text); eof_help_text = NULL; return 1; }
static void show_main_dialog(void) { int focus = 1; /* Prepare dialog. */ set_dialog_color(main_dialog, black, white); centre_dialog(main_dialog); /* Parse input. */ while (1) { focus = do_dialog(main_dialog, focus); switch (focus) { case 3: /* Setup all key mappings. */ setup_all_keys(); break; case 4: /* Test key mappings. */ test_key_map(); break; case 5: /* Save and quit. */ save_key_map(); return; case 6: /* Just exit. */ return; } } }
int display_options() { if (display_mode & WINDOWED_MODE_SET) display_mode |= WINDOWED_MODE; else display_mode &= ~WINDOWED_MODE; centre_dialog(options_dialog); return popup_dialog(options_dialog, -1); }
/* handle the setup command */ static void setup_all_keys(void) { int focus = 2; int i; /* Prepare dialog. */ set_dialog_color(keymap_dialog, black, white); centre_dialog(keymap_dialog); /* Parse input. */ while (1) { focus = do_dialog(keymap_dialog, focus); switch (focus) { case 2: case 4: textprintf_centre_ex (screen, font, keymap_dialog[7].x, keymap_dialog[7].y, red, -1, "Press a key to map to the current scancode"); textprintf_centre_ex (screen, font, keymap_dialog[7].x, keymap_dialog[7].y + 8, red, -1, "(or a mouse button to leave it unchanged)"); /* Wait for new key press. */ new_keycode = -1; waiting_for_key = 1; do { poll_keyboard(); poll_mouse(); if (mouse_b) waiting_for_key = 0; } while (waiting_for_key); /* Save keycode to scancode mapping. */ if ((new_keycode >= 0) && (new_keycode < 256)) { keycode_to_scancode[new_keycode] = keymap_dialog[2].d1 + 1; } clear_keybuf(); break; case 5: return; case 6: for (i = 0; i < 256; i++) { if (keycode_to_scancode[i] >= 0) _xwin.keycode_to_scancode[i] = keycode_to_scancode[i]; } return; } } }
void display_text_file(char * title, char * filename, int startpos) { FILE * fp; // what makes this next block of code unique is that i wrote it, // compiled it with no errors, and it worked properly the first // time it was run... unheard-of, really... // i've since simplified it by removing references to sys/stat // for file sizes, and replaced them with allegro's file_size() text_file_dialog[2].d2 = startpos; if (exists(filename)) { if (text_file_buffer) free(text_file_buffer); #if 0 // GN: hmm? sprintf(text_file_dialog[1].dp, title); #endif text_file_buffer = (char *) malloc (file_size(filename)); if (text_file_buffer) { fp = fopen(filename, "rb"); if (fp) { fread(text_file_buffer, 1, file_size(filename), fp); fclose(fp); text_file_dialog[2].dp = text_file_buffer; centre_dialog(text_file_dialog); set_dialog_color(text_file_dialog, GUI_FORE, GUI_BACK); do_dialog(text_file_dialog, 2); if (text_file_buffer) free(text_file_buffer); } else { alert("File access error!", "Could not load file:", filename, "Continue", NULL, 0, 0); } } else { alert("Memory allocation error!", "Could not load file:", filename, "Continue", NULL, 0, 0); } } else { alert("Could not find file:", filename, "", "Continue", NULL, 0, 0); } }
int display_trouble_codes() { int ret; mil_is_on = FALSE; // reset MIL status num_of_codes_reported = 0; clear_trouble_codes(); centre_dialog(confirm_clear_dialog); // center the popup dialog if (comport.status == USER_IGNORED) comport.status = NOT_OPEN; ret = do_dialog(read_codes_dialog, -1); if (get_number_of_codes() > 0) // if the structure is not empty, clear_trouble_codes(); return ret; }
void newGame() { static int configured = 0; if(!configured) { centre_dialog(dlg); configured = 1; } if(current_view != left_view) update(); if(popup_dialog(dlg, -1) != CANCEL) switch(BOARD_SELECTED) { case 0: shuffle(); break; case 1: loadLayoutFromFile(); break; default: loadLayout(BOARD_SELECTED - 2); } }
/* allows the user to choose an animation type */ int pick_animation_type(ANIMATION_TYPE *type) { int ret; centre_dialog(anim_type_dlg); clear_bitmap(screen); /* we set up colors to match screen color depth */ for (ret = 0; anim_type_dlg[ret].proc; ret++) { anim_type_dlg[ret].fg = palette_color[0]; anim_type_dlg[ret].bg = palette_color[1]; } ret = do_dialog(anim_type_dlg, 2); *type = anim_type_dlg[2].d1 + 1; max_fps = anim_type_dlg[3].flags & D_SELECTED; ASSERT(*type >= DOUBLE_BUFFER && *type <= DIRTY_RECTANGLE); return (ret == 6) ? -1 : ret; }
static int save_proc(void) { char filename[1024]; char buffer[256], *p; BITMAP *bmp = NULL; int quality = 0, flags = 0; if (file_select_ex("Save as JPG", last_path, "jpg", 1024, (SCREEN_W * 2) / 3, (SCREEN_H * 2) / 3)) { strcpy(filename, last_path); for (p = last_path + strlen(last_path); (p >= last_path) && (*p != '/') && (*p != '\\'); p--) ; *(p + 1) = '\0'; set_dialog_color(settings_dialog, gui_fg_color, gui_bg_color); centre_dialog(settings_dialog); if (popup_dialog(settings_dialog, -1) < 0) return 0; quality = settings_dialog[QUALITY_SLIDER].d2 + 1; if (settings_dialog[SS_444_RADIO].flags & D_SELECTED) flags = JPG_SAMPLING_444; if (settings_dialog[SS_422_RADIO].flags & D_SELECTED) flags = JPG_SAMPLING_422; if (settings_dialog[SS_411_RADIO].flags & D_SELECTED) flags = JPG_SAMPLING_411; if (settings_dialog[GREYSCALE_CHECK].flags & D_SELECTED) flags |= JPG_GREYSCALE; if (settings_dialog[OPTIMIZE_CHECK].flags & D_SELECTED) flags |= JPG_OPTIMIZE; bmp = settings_dialog[PREVIEW].dp; if (save_jpg_ex(filename, bmp, NULL, quality, flags, progress_cb)) { sprintf(buffer, "Error saving JPG image (error code %d)", jpgalleg_error); alert("", buffer, "", "Ok", NULL, 0, 0); } } return 0; }
void GUITextEntryDialog::InitDialog() { /* int (*proc)(int, DIALOG *, int); - dialog procedure (message handler) int x, y, w, h; - position and size of the object int fg, bg; - foreground and background colors int key; - ASCII keyboard shortcut int flags; - flags about the status of the object int d1, d2; - whatever you want to use them for void *dp, *dp2, *dp3; - pointers to more object-specific data */ // list of controls on the dialog: // d_box_proc -- the entire dialog is within this box // d_box_proc -- the window caption is surrounded by a box // d_ctext_proc -- the window caption is centered horizontally // d_ctext_proc -- the prompt text is centered horizontally // d_ctext_proc -- the prompt text is centered horizontally // d_ctext_proc -- the prompt text is centered horizontally // d_ctext_proc -- the prompt text is centered horizontally // d_box_proc -- the text edit field is surrounded by a box // d_edit_proc -- the text edit field that text is entered by the user into // d_button_proc -- the "OK" button (caption can be changed) // d_yield_proc -- used to let the CPU rest while the user is not actively using the dialog enum ControlNames { FormMain, FrameCaption, StaticCaption, StaticPrompt1, StaticPrompt2, StaticPrompt3, StaticPrompt4, FrameEditField, TextEditField, ButtonOKButton, HiddenCPUYield, EndDialog }; int controlCount = 1 + EndDialog; internalDialog_ = new DIALOG [controlCount]; // zero out all controls for (int index = 0; index < controlCount; index++) { memset(&internalDialog_[index], 0, sizeof(DIALOG)); } // clear the internal string memset(reinterpret_cast<void*>(internalTextBuffer_), 0, sizeof(internalTextBuffer_)); // calculate the size of the form /* form height = the button height + the text entry height + 4 static texts + caption form width = longest line of prompt length * width of the current font each control should have 4 pixel padding */ int charWidth = text_length(font, "A"); int charHeight = text_height(font); int controlPadding = 4; int formWidth = 0; int formHeight = 0; unsigned int longestLine = 0; for (unsigned int index = 0; index < prompts_.size(); index++) { if (prompts_.at(index).size() > longestLine) { longestLine = prompts_.at(index).size(); } } formWidth = controlPadding + (charWidth * longestLine) + controlPadding; formHeight = (controlCount * (2*controlPadding)) + (4 * charHeight); // init the main form -- a d_box_proc control internalDialog_[FormMain].proc = d_box_proc; internalDialog_[FormMain].x = 0; internalDialog_[FormMain].y = 0; internalDialog_[FormMain].w = formWidth; internalDialog_[FormMain].h = formHeight; // init the frame for the window's caption text -- a d_box_proc control internalDialog_[FrameCaption].proc = d_box_proc; internalDialog_[FrameCaption].x = 0; internalDialog_[FrameCaption].y = 0; internalDialog_[FrameCaption].w = internalDialog_[FormMain].w; internalDialog_[FrameCaption].h = controlPadding + charHeight + controlPadding; // init the window's caption text -- a d_ctext_proc control /* These draw text onto the screen. The dp field should point to the string to display. d_ctext_proc() centers the string horizontally, and d_rtext_proc() right aligns it. Any '&' characters in the string will be replaced with lines underneath the following character, for displaying keyboard shortcuts (as in MS Windows). To display a single ampersand, put "&&". To draw the text in something other than the default font, set the dp2 field to point to your custom font data. */ internalDialog_[StaticCaption].proc = d_ctext_proc; internalDialog_[StaticCaption].x = internalDialog_[FrameCaption].x + controlPadding; internalDialog_[StaticCaption].y = controlPadding; internalDialog_[StaticCaption].w = internalDialog_[FrameCaption].w - controlPadding; internalDialog_[StaticCaption].dp = const_cast<void*>(reinterpret_cast<const void*>(windowCaption_.c_str())); // init the prompt texts -- four d_ctext_proc controls internalDialog_[StaticPrompt1].proc = d_ctext_proc; internalDialog_[StaticPrompt1].x = internalDialog_[FrameCaption].x + controlPadding; internalDialog_[StaticPrompt1].y = internalDialog_[FrameCaption].y + internalDialog_[FrameCaption].h + controlPadding; internalDialog_[StaticPrompt1].w = internalDialog_[FrameCaption].w - controlPadding; internalDialog_[StaticPrompt1].h = controlPadding + charHeight + controlPadding; internalDialog_[StaticPrompt1].dp = const_cast<void*>(reinterpret_cast<const void*>(prompts_.at(0).c_str())); internalDialog_[StaticPrompt2].proc = d_ctext_proc; internalDialog_[StaticPrompt2].x = internalDialog_[FrameCaption].x + controlPadding; internalDialog_[StaticPrompt2].y = internalDialog_[StaticPrompt1].y + internalDialog_[StaticPrompt1].h; internalDialog_[StaticPrompt2].w = internalDialog_[FrameCaption].w - controlPadding; internalDialog_[StaticPrompt2].h = controlPadding + charHeight + controlPadding; internalDialog_[StaticPrompt2].dp = const_cast<void*>(reinterpret_cast<const void*>(prompts_.at(1).c_str())); internalDialog_[StaticPrompt3].proc = d_ctext_proc; internalDialog_[StaticPrompt3].x = internalDialog_[FrameCaption].x + controlPadding; internalDialog_[StaticPrompt3].y = internalDialog_[StaticPrompt2].y + internalDialog_[StaticPrompt2].h; internalDialog_[StaticPrompt3].w = internalDialog_[FrameCaption].w - controlPadding; internalDialog_[StaticPrompt3].h = controlPadding + charHeight + controlPadding; internalDialog_[StaticPrompt3].dp = const_cast<void*>(reinterpret_cast<const void*>(prompts_.at(2).c_str())); internalDialog_[StaticPrompt4].proc = d_ctext_proc; internalDialog_[StaticPrompt4].x = internalDialog_[FrameCaption].x + controlPadding; internalDialog_[StaticPrompt4].y = internalDialog_[StaticPrompt3].y + internalDialog_[StaticPrompt3].h; internalDialog_[StaticPrompt4].w = internalDialog_[FrameCaption].w - controlPadding; internalDialog_[StaticPrompt4].h = controlPadding + charHeight + controlPadding; internalDialog_[StaticPrompt4].dp = const_cast<void*>(reinterpret_cast<const void*>(prompts_.at(3).c_str())); // init the frame that surrounds the edit field -- a d_box_proc control internalDialog_[FrameEditField].proc = d_box_proc; internalDialog_[FrameEditField].x = 0; internalDialog_[FrameEditField].y = (internalDialog_[StaticPrompt4].y + internalDialog_[StaticPrompt4].h) - 1; internalDialog_[FrameEditField].w = internalDialog_[FormMain].w; internalDialog_[FrameEditField].h = charHeight + controlPadding; // init the text edit field -- a d_edit_proc control /* An editable text object (the dp field points to the string). When it has the input focus (obtained by clicking on it with the mouse), text can be typed into this object. The d1 field specifies the maximum number of characters that it will accept, and d2 is the text cursor position within the string. Note: dp must point to a buffer at least (d1 + 1) * 4 bytes long because, depending on the encoding format in use, a single character can occupy up to 4 bytes and room must be reserved for the terminating null character. */ internalDialog_[TextEditField].proc = d_edit_proc; internalDialog_[TextEditField].x = controlPadding; internalDialog_[TextEditField].y = internalDialog_[StaticPrompt4].y + internalDialog_[StaticPrompt4].h; internalDialog_[TextEditField].w = internalDialog_[FormMain].w - (2 * controlPadding); internalDialog_[TextEditField].h = charHeight; internalDialog_[TextEditField].d1 = 0x400; internalDialog_[TextEditField].dp = internalTextBuffer_; // init the OK button -- a d_button_proc control internalDialog_[ButtonOKButton].proc = d_button_proc; internalDialog_[ButtonOKButton].x = (internalDialog_[FormMain].w / 2) - ((text_length(font, buttonCaption_.c_str()) + (controlPadding*12)) / 2);; internalDialog_[ButtonOKButton].w = text_length(font, buttonCaption_.c_str()) + (controlPadding * 12); internalDialog_[ButtonOKButton].h = controlPadding + charHeight + controlPadding; internalDialog_[ButtonOKButton].y = controlPadding + controlPadding + internalDialog_[FrameEditField].y + internalDialog_[FrameEditField].h; internalDialog_[ButtonOKButton].flags = D_EXIT; internalDialog_[ButtonOKButton].dp = const_cast<void*>(reinterpret_cast<const void*>(buttonCaption_.c_str())); // init the CPU yield -- a d_yield_proc control internalDialog_[HiddenCPUYield].proc = d_yield_proc; // set the color of the dialog const int controlColorFG = makecol(255, 255, 255); const int controlColorBG = makecol(0, 0, 0); set_dialog_color(internalDialog_, controlColorFG, controlColorBG); // re- color the window caption internalDialog_[StaticCaption].bg = -1; internalDialog_[FrameCaption].bg = makecol(0, 0, 64); internalDialog_[FrameCaption].fg = makecol(255, 255, 255); // center the dialog centre_dialog(internalDialog_); }
void reset_chip() { centre_dialog(reset_chip_dialog); popup_dialog(reset_chip_dialog, -1); }
int raine_file_select_ex( char *message, char *path, char *ext, int size,int width, int height) { char buf[512]; int ret; char *p; if (width == -1) width = 305; #ifdef HAVE_DIR_LIST if (height == -1) height = 161; #else if (height == -1) height = 189; #endif /* for fs_dlist_proc() */ ASSERT(size >= 4 * uwidth_max(U_CURRENT)); ustrcpy(updir, empty_string); file_selector[FS_MESSAGE].dp = (char *)message; file_selector[FS_EDIT].d1 = size/uwidth_max(U_CURRENT) - 1; file_selector[FS_EDIT].dp = path; file_selector[FS_OK].dp = (void*)raine_get_config_text("OK"); file_selector[FS_CANCEL].dp = (void*)raine_get_config_text("Cancel"); fext = ext; if (!ugetc(path)) { if (!getcwd(buf, sizeof(buf))) buf[0]=0; do_uconvert(buf, U_ASCII, path, U_CURRENT, size); fix_filename_case(path); fix_filename_slashes(path); put_backslash(path); } clear_keybuf(); do { } while (gui_mouse_b()); stretch_dialog(file_selector, width, height); centre_dialog(file_selector); // Stupid correction of the allegro colors... file_selector[FS_FILES].fg = CGUI_COL_TEXT_1; file_selector[FS_FILES].bg = CGUI_BOX_COL_MIDDLE; #ifdef HAVE_DIR_LIST /* not all platforms need a directory list */ file_selector[FS_DISKS].fg = CGUI_COL_TEXT_1; file_selector[FS_DISKS].bg = CGUI_BOX_COL_MIDDLE; #endif ret = do_dialog(file_selector, FS_EDIT); if (ret == FS_CANCEL) return FALSE; p = get_extension(path); if ((!ugetc(p)) && (ext) && (!ustrpbrk(ext, uconvert_ascii(" ,;", NULL)))) { p += usetc(p, '.'); ustrcpy(p, ext); } return TRUE; }
static int setup (void) { #define RESOLUTION_LIST 4 #define COLOUR_LIST 6 #define ZBUFFER_LIST 8 #define WINDOWED_BOX 9 #define DOUBLEBUFFER_BOX 10 #define BUTTON_OK 11 DIALOG dlg[] = { /* proc x y w h fg bg key flags d1 d2 dp */ { d_shadow_box_proc, 0, 0, 320, 200, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { d_ctext_proc, 160, 10, 0, 0, 0, 0, 0, 0, 0, 0, "____________", NULL, NULL }, { d_ctext_proc, 160, 8, 0, 0, 0, 0, 0, 0, 0, 0, "OpenGL Setup", NULL, NULL }, { d_text_proc, 10, 30, 0, 0, 0, 0, 0, 0, 0, 0, "Resolution", NULL, NULL }, { d_list_proc, 10, 40, 96, 52, 0, 0, 0, 0, 0, 0, resolution_lister, NULL, NULL }, { d_text_proc, 120, 30, 0, 0, 0, 0, 0, 0, 0, 0, "Colour depth", NULL, NULL }, { d_list_proc, 120, 40, 96, 48, 0, 0, 0, 0, 0, 0, colour_depth_lister, NULL, NULL }, { d_text_proc, 10, 104, 96, 48, 0, 0, 0, 0, 0, 0, "Z buffer", NULL, NULL }, { d_list_proc, 10, 114, 96, 48, 0, 0, 0, 0, 0, 0, zbuffer_depth_lister, NULL, NULL }, { d_check_proc, 10, 170, 96, 8, 0, 0, 0, 0, 1, 0, "Windowed", NULL, NULL }, { d_check_proc, 10, 180, 128, 8, 0, 0, 0,D_SELECTED, 1, 0, "Double Buffered", NULL, NULL }, { d_button_proc, 220, 150, 96, 18, 0, 0, 0, D_EXIT, 0, 0, "Ok", NULL, NULL }, { d_button_proc, 220, 174, 96, 18, 0, 0, 0, D_EXIT, 0, 0, "Exit", NULL, NULL }, { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL } }; int x; if (mode == AGL_WINDOWED) dlg[WINDOWED_BOX].flags |= D_SELECTED; centre_dialog (dlg); set_dialog_color (dlg, makecol(0, 0, 0), makecol(255, 255, 255)); if (secs) { textprintf_centre_ex(screen, font, SCREEN_W / 2, SCREEN_H / 2 + 110, makecol(255, 255, 255), 0, "Frames: %i, Seconds: %i, FPS: %f", frames, secs, (float)frames / (float)secs); } x = do_dialog (dlg, 4); allegro_gl_clear_settings(); allegro_gl_set(AGL_COLOR_DEPTH, colour_depths[dlg[COLOUR_LIST].d1].depth); allegro_gl_set(AGL_Z_DEPTH, zbuffer_depths[dlg[ZBUFFER_LIST].d1].depth); allegro_gl_set(AGL_DOUBLEBUFFER, (dlg[DOUBLEBUFFER_BOX].flags & D_SELECTED) ? 1 : 0); allegro_gl_set(AGL_RENDERMETHOD, 1); mode = ((dlg[WINDOWED_BOX].flags & D_SELECTED) ? AGL_WINDOWED : AGL_FULLSCREEN); allegro_gl_set(mode, TRUE); allegro_gl_set(AGL_SUGGEST, AGL_COLOR_DEPTH | AGL_Z_DEPTH | AGL_DOUBLEBUFFER | AGL_RENDERMETHOD | mode); width = resolutions[dlg[RESOLUTION_LIST].d1].w; height = resolutions[dlg[RESOLUTION_LIST].d1].h; return (x == BUTTON_OK); }
/* Stolen directly from Allegro */ int billalert3(char *s1, char *s2, char *s3, char *b1, char *b2, char *b3, int c1, int c2, int c3) { int maxlen = 0; int len1, len2, len3; int avg_w = text_length(font, " "); int avg_h = text_height(font); int buttons = 0; int b[3]; int c; #define SORT_OUT_BUTTON(x) { \ if (b##x) { \ billalert_dialog[A_B##x].flags &= ~D_HIDDEN; \ billalert_dialog[A_B##x].key = c##x; \ billalert_dialog[A_B##x].dp = b##x; \ len##x = gui_strlen(b##x); \ b[buttons++] = A_B##x; \ } \ else { \ billalert_dialog[A_B##x].flags |= D_HIDDEN; \ len##x = 0; \ } \ } billalert_dialog[A_S1].dp = billalert_dialog[A_S2].dp = billalert_dialog[A_S3].dp = billalert_dialog[A_B1].dp = billalert_dialog[A_B2].dp = ""; if (s1) { billalert_dialog[A_S1].dp = s1; maxlen = text_length(font, s1); } if (s2) { billalert_dialog[A_S2].dp = s2; len1 = text_length(font, s2); if (len1 > maxlen) maxlen = len1; } if (s3) { billalert_dialog[A_S3].dp = s3; len1 = text_length(font, s3); if (len1 > maxlen) maxlen = len1; } SORT_OUT_BUTTON(1); SORT_OUT_BUTTON(2); SORT_OUT_BUTTON(3); len1 = MAX(len1, MAX(len2, len3)) + avg_w*3; if (len1*buttons > maxlen) maxlen = len1*buttons; maxlen += avg_w*4; billalert_dialog[0].w = maxlen; billalert_dialog[A_S2].x = billalert_dialog[A_S3].x = billalert_dialog[0].x + maxlen/2; billalert_dialog[A_B1].w = billalert_dialog[A_B2].w = billalert_dialog[A_B3].w = len1; billalert_dialog[A_B1].x = billalert_dialog[A_B2].x = billalert_dialog[A_B3].x = billalert_dialog[0].x + maxlen/2 - len1/2; if (buttons == 3) { billalert_dialog[b[0]].x = billalert_dialog[0].x + maxlen/2 - len1*3/2 - avg_w; billalert_dialog[b[2]].x = billalert_dialog[0].x + maxlen/2 + len1/2 + avg_w; } else if (buttons == 2) { billalert_dialog[b[0]].x = billalert_dialog[0].x + maxlen/2 - len1 - avg_w; billalert_dialog[b[1]].x = billalert_dialog[0].x + maxlen/2 + avg_w; } billalert_dialog[0].h = avg_h*8; billalert_dialog[A_S2].y = billalert_dialog[0].y + avg_h*2 +5; billalert_dialog[A_S3].y = billalert_dialog[0].y + avg_h*3 +5; billalert_dialog[A_S2].h = avg_h; billalert_dialog[A_B1].y = billalert_dialog[A_B2].y = billalert_dialog[A_B3].y = billalert_dialog[0].y + avg_h*5; billalert_dialog[A_B1].h = billalert_dialog[A_B2].h = billalert_dialog[A_B3].h = avg_h*2; centre_dialog(billalert_dialog); clear_keybuf(); do { } while (mouse_b); c = moveable_do_dialog(billalert_dialog, A_B1); if (c == A_B1) return 1; else if (c == A_B2) return 2; else return 3; }
/** * Shows unit-stats edit-dialog and allows to edit unit stats, * change name, and armour (=skin) */ void Editor::edit_soldier() { MouseRange temp_mouse_range(0, 0, SCREEN_W - 1, SCREEN_H - 1); DIALOG sol_dialog[] = { //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) { d_agup_shadow_box_proc, DX, DY, D_WIDTH, D_HEIGHT, FG, BG, 0, 0, 0, 0, NULL, NULL, NULL}, { d_agup_button_proc, DX + 130, DY + SSY + SH*13 + 4, 100, 20, FG, BG, 0, D_EXIT, 0, 0, (void *)_("OK"), NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + SSY - SH*1, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Name:"), NULL, NULL}, { d_agup_edit_proc, DX + SSX, DY + SSY - SH*1 - 4, 23*8, 16, FG, BG, 0, 0, MAN_NAME_LEN, 0, NULL, NULL, NULL}, { d_agup_text_proc, DX + 100, DY + SSY + SH*12 + 2, 100, 16, FG, BG, 0, 0, 0, 0, (void *)points_str, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + SSY + SH*0 + 1, STW, 16 + 4, FG, BG, 0, 0, 0, 0, (void *)_("Race:"), NULL, NULL}, { race_change_button_proc,DX + SSX, DY + SSY + SH*0 - 6, 0, 16 + 4, FG, BG, 0, D_EXIT, 0, 0, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + SSY + SH*1 + 1, STW, 16 + 4, FG, BG, 0, 0, 0, 0, (void *)_("Armour:"), NULL, NULL}, { armour_change_button_proc,DX + SSX, DY + SSY + SH*1 - 6, 0, 16 + 4, FG, BG, 0, D_EXIT, 0, 0, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + SSY + SH*2 + 1, STW, 16 + 4, FG, BG, 0, 0, 0, 0, (void *)_("Appearance:"), NULL, NULL}, { appearance_change_button_proc,DX + SSX, DY + SSY + SH*2 - 6, 0, 16 + 4, FG, BG, 0, D_EXIT, 0, 0, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*3, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Time Units"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*3, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*4, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Stamina"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*4, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*5, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Health"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*5, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*6, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Bravery"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*6, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*7, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Reactions"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*7, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*8, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Firing"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*8, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*9, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Throwing"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*9, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_rtext_proc, DX + STX, DY + STY + SH*10, STW, 16, FG, BG, 0, 0, 0, 0, (void *)_("Strength"), NULL, NULL}, { d_agup_slider_pro2, DX + SSX, DY + SSY + SH*10, SSW, 16, FG, BG, 0, 0, 100, 33, NULL, NULL, NULL}, { d_agup_ctext_proc, DX, DY + SH/2, D_WIDTH, 16, FG, BG, 0, 0, 0, 0, (void *)_("Edit soldier attributes"), NULL, NULL}, { d_yield_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL}, { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL} }; ::sol_dialog = sol_dialog; sol_dialog[D_BRAVERY].flags |= D_DISABLED; sol_dialog[D_NAME].dp = man->md.Name; sol_dialog[D_TIME].d2 = man->md.TimeUnits; sol_dialog[D_HEALTH].d2 = man->md.Health; sol_dialog[D_STAMINA].d2 = man->md.Stamina; sol_dialog[D_REACTION].d2 = man->md.Reactions; sol_dialog[D_STRENGTH].d2 = man->md.Strength; sol_dialog[D_FIRE_ACCUR].d2 = man->md.Firing; sol_dialog[D_THRU_ACCUR].d2 = man->md.Throwing; sol_dialog[D_BRAVERY].d2 = man->md.Bravery; points = sol_dialog[D_TIME].d2 + sol_dialog[D_HEALTH].d2 + sol_dialog[D_FIRE_ACCUR].d2 + sol_dialog[D_THRU_ACCUR].d2 + sol_dialog[D_STAMINA].d2 + (sol_dialog[D_STRENGTH].d2 * 2) + sol_dialog[D_REACTION].d2; sprintf(points_str, _("Points remain: %2d "), MAXPOINTS - points); sol_dialog[D_POINTS].fg = gui_fg_color; sol_dialog[D_POINTS].bg = gui_bg_color; while (mouse_b & 3) rest(1); if (man->md.SkinType == S_XCOM_0 || man->md.SkinType == S_XCOM_1 || man->md.SkinType == S_XCOM_2 || man->md.SkinType == S_XCOM_3) { appearance_names = appearance_names_human; armour_names = armour_names_human; if (man->md.Appearance >= 4) man->md.Appearance = 0; sol_dialog[D_RACE].d1 = 0; } else { appearance_names = appearance_names_alien; armour_names = armour_names_alien; if (man->md.SkinType == S_SECTOID) sol_dialog[D_RACE].d1 = 1; else if (man->md.SkinType == S_MUTON) sol_dialog[D_RACE].d1 = 2; else if (man->md.SkinType == S_SNAKEMAN) sol_dialog[D_RACE].d1 = 3; else if (man->md.SkinType == S_ETHEREAL) sol_dialog[D_RACE].d1 = 4; else if (man->md.SkinType == S_FLOATER) sol_dialog[D_RACE].d1 = 5; else if (man->md.SkinType == S_CHRYS) sol_dialog[D_RACE].d1 = 6; else sol_dialog[D_RACE].d1 = 7; man->md.fFemale = 0; if (man->md.SkinType != S_CHAMELEON) man->md.Appearance = 0; } switch (man->md.SkinType) { case S_XCOM_0 : sol_dialog[D_ARMOUR].d1 = 0; break; case S_XCOM_1 : sol_dialog[D_ARMOUR].d1 = 1; break; case S_XCOM_2 : sol_dialog[D_ARMOUR].d1 = 2; break; case S_XCOM_3 : sol_dialog[D_ARMOUR].d1 = 3; break; case S_SECTOID: sol_dialog[D_ARMOUR].d1 = 0; break; case S_SNAKEMAN: sol_dialog[D_ARMOUR].d1 = 0; break; //LAWYER: Snakeman case S_ETHEREAL: sol_dialog[D_ARMOUR].d1 = 0; break; //LAWYER: Ethereal case S_FLOATER: sol_dialog[D_ARMOUR].d1 = 0; break; //LAWYER: Floater case S_CHRYS: sol_dialog[D_ARMOUR].d1 = 0; break; //Kratos: Chryssalid default: sol_dialog[D_ARMOUR].d1 = 0; break; } sol_dialog[D_APPEARANCE].d1 = man->md.Appearance + (man->md.fFemale ? 4 : 0); fixup_unit_info(); set_dialog_color(sol_dialog, gui_fg_color, gui_bg_color); centre_dialog(sol_dialog); popup_dialog(sol_dialog, -1); switch (sol_dialog[D_RACE].d1) { case 0: man->md.fFemale = sol_dialog[D_APPEARANCE].d1 >= 4; man->md.Appearance = sol_dialog[D_APPEARANCE].d1 % 4; man->md.SkinType = sol_dialog[D_ARMOUR].d1 + 1; break; case 1: man->md.fFemale = 0; man->md.SkinType = S_SECTOID; break; case 2: man->md.fFemale = 0; man->md.SkinType = S_MUTON; break; case 3: man->md.fFemale = 0; man->md.SkinType = S_SNAKEMAN; //LAWYER: Snakeman!! break; case 4: man->md.fFemale = 0; man->md.SkinType = S_ETHEREAL; //LAWYER: Ethereal!! break; case 5: man->md.fFemale = 0; man->md.SkinType = S_FLOATER; //LAWYER: Floater!! break; case 6: man->md.fFemale = 0; man->md.SkinType = S_CHRYS; //Kratos: Chryssalid break; default: man->md.fFemale = 0; // Here too, even though it looks inconsistent man->md.SkinType = S_CHAMELEON; man->md.Appearance = sol_dialog[D_APPEARANCE].d1; break; } man->md.TimeUnits = sol_dialog[D_TIME].d2; man->md.Health = sol_dialog[D_HEALTH].d2; man->md.Stamina = sol_dialog[D_STAMINA].d2; man->md.Reactions = sol_dialog[D_REACTION].d2; man->md.Strength = sol_dialog[D_STRENGTH].d2; man->md.Firing = sol_dialog[D_FIRE_ACCUR].d2; man->md.Throwing = sol_dialog[D_THRU_ACCUR].d2; man->md.Bravery = sol_dialog[D_BRAVERY].d2; man->process_MANDATA(); ::sol_dialog = NULL; }