void defaultnew_text( tag_entry *e ) { string_definition* def = NULL; // our new text tag // MRB - Build 124: the two lines down kill OS X. //def->string_length = 1; // One item.... //def->string_buffer[0] = '\r'; // .... a return. set_entry_data( e, &def, sizeof(def), false ); // add this to the tag window edit_text( e ); // open up the edit window. }
VOID open_obj(WORD sobj) { LONG tree; WORD type; if (rcs_state == MENU_STATE) if (!in_bar(ad_view, sobj)) if (!menu_ok(ad_view, sobj)) return; if (rcs_state == FREE_STATE) if (sobj == ROOT) return; tree = ad_view; obj_redraw(tree, sobj); type = LLOBT(GET_TYPE(tree, sobj)); switch (type) { case G_TITLE: case G_STRING: case G_BUTTON: edit_str(tree, sobj); break; case G_IBOX: case G_BOX: case G_BOXCHAR: edit_box(tree, sobj); break; case G_TEXT: case G_BOXTEXT: case G_FTEXT: case G_FBOXTEXT: edit_text(tree, sobj); break; case G_IMAGE: edit_bit(tree, sobj); break; case G_ICON: edit_icon(tree, sobj); break; default: break; } if (rcs_state == MENU_STATE || rcs_state == ALRT_STATE) view_objs(); else obj_redraw(ad_view, sobj); }
/** * ------------------------------------------------------------------------ * Allowing the player to choose their history. * ------------------------------------------------------------------------ */ static enum birth_stage get_history_command(void) { enum birth_stage next = 0; struct keypress ke; char old_history[240]; /* Save the original history */ my_strcpy(old_history, player->history, sizeof(old_history)); /* Ask for some history */ prt("Accept character history? [y/n]", 0, 0); ke = inkey(); /* Quit, go back, change history, or accept */ if (ke.code == KTRL('X')) { quit(NULL); } else if (ke.code == ESCAPE) { next = BIRTH_BACK; } else if (ke.code == 'N' || ke.code == 'n') { char history[240]; my_strcpy(history, player->history, sizeof(history)); switch (edit_text(history, sizeof(history))) { case -1: next = BIRTH_BACK; case 0: cmdq_push(CMD_HISTORY_CHOICE); cmd_set_arg_string(cmdq_peek(), "history", history); next = BIRTH_HISTORY_CHOICE; } } else { next = BIRTH_FINAL_CONFIRM; } return next; }
SLONG control_process() { SWORD temp; switch (game_state) { case NORMAL: if (lbKeyOn[KB_LALT]) { switch(lbInkey) { case KB_X: flow_control_flags |= QUIT_TO_DOS; lbInkey = 0; break; } } else if (lbKeyOn[KB_LSHIFT] || lbKeyOn[KB_RSHIFT]) { if (KeyOn[KB_LEFT]) scroll_tile(current_tile,1); if (KeyOn[KB_RIGHT]) scroll_tile(current_tile,2); if (KeyOn[KB_UP]) scroll_tile(current_tile,3); if (KeyOn[KB_DOWN]) scroll_tile(current_tile,4); } else { if (lbKeyOn[KB_LEFT]) { lbKeyOn[KB_LEFT] = 0; current_tile--; if (current_tile < 0) current_tile = num_tiles-1; anim_frame = 0; anim_direction = 0; } if (lbKeyOn[KB_RIGHT]) { lbKeyOn[KB_RIGHT] = 0; current_tile++; if (current_tile >= num_tiles) current_tile = 0; anim_frame = 0; anim_direction = 0; } if (lbKeyOn[KB_F1]) { lbKeyOn[KB_F1] = 0; if (flow_control_flags & SHOW_HELP) flow_control_flags &= ~SHOW_HELP; else flow_control_flags |= SHOW_HELP; } if (lbKeyOn[KB_F11]) { lbKeyOn[KB_F11] = 0; if (flow_control_flags & RUN_ANIM) flow_control_flags &= ~RUN_ANIM; else flow_control_flags |= RUN_ANIM; } if (lbKeyOn[KB_F12]) { lbKeyOn[KB_F12] = 0; if (LbScreenLock() != Lb_ERROR) { WritePBM("duke",Display.WScreen,palette); LbScreenUnlock(); } } if (lbKeyOn[KB_F2]) { lbKeyOn[KB_F2] = 0; game_state = ENTERING_LOAD1; } if (lbKeyOn[KB_F3]) { lbKeyOn[KB_F3] = 0; game_state = ENTERING_SAVE1; } if (lbKeyOn[KB_F4]) { lbKeyOn[KB_F4] = 0; game_state = ENTERING_LOAD3; } if (lbKeyOn[KB_F5]) { lbKeyOn[KB_F5] = 0; game_state = ENTERING_LOAD2; } if (lbKeyOn[KB_F6]) { lbKeyOn[KB_F6] = 0; game_state = ENTERING_LOAD4; } if (lbKeyOn[KB_A]) { UBYTE a; lbKeyOn[KB_A] = 0; a = ANIM_TYPE(local_tiles[current_tile].Attributes); a++; if (a > 3) a = 0; CLEAR_ANIM_TYPE(local_tiles[current_tile].Attributes); SET_ANIM_TYPE(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_COMMA]) { UBYTE a; lbKeyOn[KB_COMMA] = 0; a = ANIM_SPEED(local_tiles[current_tile].Attributes); if (a > 0) a--; CLEAR_ANIM_SPEED(local_tiles[current_tile].Attributes); SET_ANIM_SPEED(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_DOT]) { UBYTE a; lbKeyOn[KB_DOT] = 0; a = ANIM_SPEED(local_tiles[current_tile].Attributes); if (a < 15) a++; CLEAR_ANIM_SPEED(local_tiles[current_tile].Attributes); SET_ANIM_SPEED(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_LSBRACKET]) { UBYTE a; lbKeyOn[KB_LSBRACKET] = 0; a = ANIM_NUMBER(local_tiles[current_tile].Attributes); if (a > 0) a--; CLEAR_ANIM_NUMBER(local_tiles[current_tile].Attributes); SET_ANIM_NUMBER(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_RSBRACKET]) { UBYTE a; lbKeyOn[KB_RSBRACKET] = 0; a = ANIM_NUMBER(local_tiles[current_tile].Attributes); if (a < 63) a++; switch (ANIM_TYPE(local_tiles[current_tile].Attributes)) { case ANMFD: case OSCIL: if (current_tile+a >= num_tiles) a = num_tiles-current_tile-1; break; case ANMBK: if (current_tile-a < 0) a = current_tile; break; default: break; } CLEAR_ANIM_NUMBER(local_tiles[current_tile].Attributes); SET_ANIM_NUMBER(local_tiles[current_tile].Attributes,a); } if (lbKeyOn[KB_C]) { SWORD a, b; SBYTE x, y; lbKeyOn[KB_C] = 0; CLEAR_X_CENTRE(local_tiles[current_tile].Attributes); CLEAR_Y_CENTRE(local_tiles[current_tile].Attributes); a = Display.MMouseX - tile_x; b = Display.MMouseY - tile_y; if (a > 127) a = 127; if (a < -128) a = -128; if (b > 127) b = 127; if (b < -128) b = -128; x = a; y = b; SET_X_CENTRE(local_tiles[current_tile].Attributes,x); SET_Y_CENTRE(local_tiles[current_tile].Attributes,y); } if (lbKeyOn[KB_M]) { lbKeyOn[KB_M] = 0; if (flow_control_flags & CROSS_HAIRS) flow_control_flags &= ~CROSS_HAIRS; else flow_control_flags |= CROSS_HAIRS; } if (lbKeyOn[KB_N]) { lbKeyOn[KB_N] = 0; lbInkey = 0; game_state = NAMING_TILE; } if (lbKeyOn[KB_G]) { lbKeyOn[KB_G] = 0; lbInkey = 0; game_state = GOTO_TILE; } if (lbKeyOn[KB_O]) { lbKeyOn[KB_O] = 0; optimise_tile(current_tile); } if (lbKeyOn[KB_R]) { lbKeyOn[KB_R] = 0; rotate_tile(current_tile); } if (lbKeyOn[KB_X]) { lbKeyOn[KB_X] = 0; flip_tile(current_tile,0); } if (lbKeyOn[KB_Y]) { lbKeyOn[KB_Y] = 0; flip_tile(current_tile,1); } if (lbKeyOn[KB_SLASH]) { lbKeyOn[KB_SLASH] = 0; reset_tile(current_tile); } if (lbKeyOn[KB_RETURN]) { lbKeyOn[KB_RETURN] = 0; if (tile_inits[current_tile].Palette) { remap_tile_palette(current_tile,palette,palette2); tile_inits[current_tile].Palette = 0; } } } break; case ENTERING_LOAD1: if (edit_text(filename_text)) { load_art_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_SAVE1: if (edit_text(filename_text)) { save_art_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD2: if (edit_text(filename_text)) { load_sprite_file(filename_text); game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD4: if (edit_text(filename_text)) { read_grp_file(filename_text); game_state = VIEWING_GRP; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case ENTERING_LOAD3: if (edit_text(filename_text)) { if (LbScreenLock() != Lb_ERROR) { if (ReadPBM(filename_text,palette2)) { game_state = SHOW_PIC; SetPalette(palette2); } else { game_state = NORMAL; } LbScreenUnlock(); } } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case SHOW_PIC: if (lbDisplay.LeftButton) { cut_x1 = lbDisplay.MouseX; cut_y1 = lbDisplay.MouseY; lbDisplay.LeftButton = 0; } if (cut_x1 != -1) { cut_x2 = lbDisplay.MMouseX; cut_y2 = lbDisplay.MMouseY; if (!lbDisplay.MLeftButton) { if (cut_x2 < cut_x1) { temp = cut_x1; cut_x1 = cut_x2; cut_x2 = temp; } if (cut_y2 < cut_y1) { temp = cut_y1; cut_y1 = cut_y2; cut_y2 = temp; } replace_tile(cut_x1,cut_y1,cut_x2,cut_y2,current_tile); SetPalette(palette); game_state = NORMAL; cut_x1 = cut_y1 = cut_x2 = cut_y2 = -1; if (!KeyOn[KB_LSHIFT] && !KeyOn[KB_RSHIFT]) { remap_tile_palette(current_tile,palette,palette2); tile_inits[current_tile].Palette = 0; } else tile_inits[current_tile].Palette = 1; } } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; SetPalette(palette); cut_x1 = cut_y1 = cut_x2 = cut_y2 = -1; game_state = NORMAL; } break; case NAMING_TILE: if (edit_text(tile_name_text)) { game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; case GOTO_TILE: if (edit_text(gen_text)) { sscanf(gen_text,"%d",¤t_tile); if (current_tile >= num_tiles) current_tile = num_tiles-1; if (current_tile < 0) current_tile = 0; gen_text[0] = 0; game_state = NORMAL; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; gen_text[0] = 0; game_state = NORMAL; } break; case VIEWING_GRP: if (KeyOn[KB_UP]) { KeyOn[KB_UP] = 0; if (groupfile.IdxOffset > 0) groupfile.IdxOffset--; } if (KeyOn[KB_DOWN]) { KeyOn[KB_DOWN] = 0; if (groupfile.IdxCount-groupfile.IdxOffset > 48*4) groupfile.IdxOffset++; } if (KeyOn[KB_ESC]) { KeyOn[KB_ESC] = 0; game_state = NORMAL; } break; } return(0); }