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M3PLZH4QTAJRXIZTSDVNCOKZE223I437FN2UJ34RQC }}#define DOLLS_MAX 11#define PARTS_DISP_MAX 11#define PARTS_ITEMS 12#define TILEP_SELECT_DOLL 20static dolls_data current_doll;#if 0static int current_gender = 0;static void _load_doll_data(const char *fn, dolls_data *dolls, int max,int *mode, int *cur){char fbuf[1024];int cur0 = 0;int mode0 = TILEP_M_DEFAULT;FILE *fp = NULL;std::string dollsTxtString = datafile_path(fn, false, true);const char *dollsTxt = (dollsTxtString.c_str()[0] == 0) ?"dolls.txt" : dollsTxtString.c_str();if ( (fp = fopen(dollsTxt, "r")) == NULL ){// File doesn't exist. By default, use show equipment defaults.// This will be saved out (if possible.)for (int i = 0; i < max; i++){// Don't take gender too seriously. -- Ennetilep_race_default(you.species, coinflip() ? 1 : 0,you.experience_level, dolls[i].parts);dolls[i].parts[TILEP_PART_SHADOW] = TILEP_SHADOW_SHADOW;dolls[i].parts[TILEP_PART_CLOAK] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_BOOTS] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_LEG] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_BODY] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_ARM] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_HAND1] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_HAND2] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_HAIR] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_BEARD] = TILEP_SHOW_EQUIP;dolls[i].parts[TILEP_PART_HELM] = TILEP_SHOW_EQUIP;}}else{memset(fbuf, 0, sizeof(fbuf));if (fscanf(fp, "%s", fbuf) != EOF){if (strcmp(fbuf, "MODE=LOADING") == 0)mode0 = TILEP_M_LOADING;}if (fscanf(fp, "%s", fbuf) != EOF){if (strncmp(fbuf, "NUM=", 4) == 0){sscanf(fbuf, "NUM=%d",&cur0);if ( (cur0 < 0)||(cur0 > 10) )cur0 = 0;}}if (max == 1){for (int j = 0; j <= cur0; j++){if (fscanf(fp, "%s", fbuf) != EOF)tilep_scan_parts(fbuf, dolls[0].parts);elsebreak;}}else{for (int j = 0; j < max; j++){if (fscanf(fp, "%s", fbuf) != EOF)tilep_scan_parts(fbuf, dolls[j].parts);elsebreak;}}fclose(fp);}*mode = mode0;*cur = cur0;current_gender = dolls[cur0].parts[TILEP_PART_BASE] % 2;}#endifvoid TilePlayerEdit(){#if 0const int p_lines[PARTS_ITEMS] ={TILEP_SELECT_DOLL,TILEP_PART_BASE,TILEP_PART_HELM,TILEP_PART_HAIR,TILEP_PART_BEARD,TILEP_PART_HAND1,TILEP_PART_HAND2,TILEP_PART_ARM,TILEP_PART_BODY,TILEP_PART_LEG,TILEP_PART_BOOTS,TILEP_PART_CLOAK};const char *p_names[PARTS_ITEMS] ={" Index:"," Gendr:"," Helm :"," Hair :"," Beard:"," Weapn:"," Shild:"," Glove:"," Armor:"," Legs :"," Boots:"," Cloak:"};const char *gender_name[2] = {"Male","Fem "};#define display_parts_idx(part) \{ \cgotoxy(10 , part + 1, GOTO_STAT); \tilep_part_to_str(dolls[cur_doll].parts[ p_lines[part] ], ibuf);\cprintf(ibuf);\}dolls_data dolls[DOLLS_MAX], undo_dolls[DOLLS_MAX];int copy_doll[TILEP_PART_MAX];//int parts[TILEP_PART_MAX];int i, j, x, y, kin, done = 0;int cur_doll = 0;int pre_part = 0;int cur_part = 0;int mode = TILEP_M_DEFAULT;int d = 0;FILE *fp;char fbuf[80], ibuf[8];int tile_str, sx, sy;img_type PartsImg = ImgCreateSimple(TILE_X * PARTS_DISP_MAX, TILE_Y * 1);img_type DollsListImg = ImgCreateSimple( TILE_X * DOLLS_MAX, TILE_Y * 1);ImgClear(ScrBufImg);memset( copy_doll, 0, sizeof(dolls_data) );tilep_race_default(you.species, current_gender,you.experience_level, copy_doll);for (j = 0; j < DOLLS_MAX; j++){memset( dolls[j].parts, 0, sizeof(dolls_data) );memset( undo_dolls[j].parts, 0, sizeof(dolls_data) );tilep_race_default(you.species, current_gender, you.experience_level,dolls[j].parts);tilep_race_default(you.species, current_gender, you.experience_level,undo_dolls[j].parts);}// load settings_load_doll_data("dolls.txt", dolls, DOLLS_MAX, &mode, &cur_doll);for (j = 0; j < DOLLS_MAX; j++)undo_dolls[j] = dolls[j];clrscr();cgotoxy(1,1, GOTO_MSG);mpr("Select Part : [j][k]or[up][down]");mpr("Change Part/Page : [h][l]or[left][right]/[H][L]");mpr("Class-Default : [CTRL]+[D]");mpr("Toggle Equipment Mode : [*]");mpr("Take off/Take off All : [t]/[CTRL]+[T]");mpr("Copy/Paste/Undo : [CTRL]+[C]/[CTRL]+[V]/[CTRL]+[Z]");mpr("Randomize : [CTRL]+[R]");cgotoxy(1, 8, GOTO_MSG);cprintf("Toggle Startup mode : [m] (Current mode:%s)",(mode == TILEP_M_LOADING ? "Load User's Settings": "Class Default" ));for (j = 0; j < PARTS_ITEMS; j++){cgotoxy(1, 1+j, GOTO_STAT);cprintf(p_names[j]);}#define PARTS_Y (TILE_Y*11)// draw strings "Dolls/Parts" into backbuffertile_str = TILE_TEXT_PARTS_E;sx = (tile_str % TILE_PER_ROW) * TILE_X;sy = (tile_str / TILE_PER_ROW) * TILE_Y;ImgCopy(TileImg, sx, sy, TILE_X, TILE_Y/2,ScrBufImg, (TILE_X * 3) - 8,(TILE_Y * 4) - 8-24, 0);ImgCopy(TileImg, sx, sy+ TILE_Y/2, TILE_X, TILE_Y/2,ScrBufImg, (TILE_X * 4) - 8,(TILE_Y * 4) - 8-24, 0);tile_str = TILE_TEXT_DOLLS_E;sx = (tile_str % TILE_PER_ROW) * TILE_X;sy = (tile_str / TILE_PER_ROW) * TILE_Y;ImgCopy(TileImg, sx, sy, TILE_X, TILE_Y/2,ScrBufImg, (TILE_X * 3) - 8,PARTS_Y - 8 -24, 0);ImgCopy(TileImg, sx, sy+ TILE_Y/2, TILE_X, TILE_Y/2,ScrBufImg, (TILE_X * 4) - 8,PARTS_Y - 8 -24, 0);ImgClear(DollsListImg);for (j = 0; j < DOLLS_MAX; j++){_draw_doll(DollCacheImg, &dolls[j], true);ImgCopy(DollCacheImg, 0, 0,ImgWidth(DollCacheImg), ImgHeight(DollCacheImg),DollsListImg, j * TILE_X, 0, 1);}done = 0;while (!done){static int inc = 1;static int cur_inc = 1;ImgClear(PartsImg);region_tile->DrawPanel((TILE_X * 3) - 8, (TILE_Y * 4) - 8,ImgWidth(PartsImg) + 16, ImgHeight(PartsImg) + 16);region_tile->DrawPanel((TILE_X * 3) - 8, PARTS_Y - 8,ImgWidth(DollsListImg) + 16, ImgHeight(DollsListImg) + 16);region_tile->DrawPanel(8*TILE_X - 8, 8*TILE_Y - 8,TILE_X + 16, TILE_Y + 16);if (cur_part == 0){// now selecting doll indexcgotoxy(10 , 1, GOTO_STAT);cprintf("%02d", cur_doll);cgotoxy(10 , 2, GOTO_STAT);current_gender = dolls[cur_doll].parts[TILEP_PART_BASE] % 2;cprintf("%s", gender_name[ current_gender ]);for (i = 2; i < PARTS_ITEMS; i++){cgotoxy(10 , i + 1, GOTO_STAT);tilep_part_to_str(dolls[cur_doll].parts[ p_lines[i] ], ibuf);cprintf("%s / %03d", ibuf, tilep_parts_total[ p_lines[i] ]);}}else{for (i = 0; i < PARTS_DISP_MAX; i++){int index;if (dolls[cur_doll].parts[ p_lines[cur_part] ]== TILEP_SHOW_EQUIP){index = 0;}else{index = i + dolls[cur_doll].parts[ p_lines[cur_part] ]- (PARTS_DISP_MAX / 2);}if (index < 0)index = index + tilep_parts_total[ p_lines[cur_part] ] + 1;if (index > tilep_parts_total[ p_lines[cur_part] ])index = index - tilep_parts_total[ p_lines[cur_part] ] - 1;_tcache_overlay_player(PartsImg, i * TILE_X, 0,p_lines[cur_part], index, TILE_Y, &d);}ImgCopy(PartsImg, 0, 0, ImgWidth(PartsImg), ImgHeight(PartsImg),ScrBufImg, 3 * TILE_X, 4 * TILE_Y, 0);_ImgCopyFromTileImg( TILE_CURSOR, ScrBufImg,(3 + PARTS_DISP_MAX / 2) * TILE_X,4 * TILE_Y, 0);}_draw_doll(DollCacheImg, &dolls[cur_doll], true);ImgCopy(DollCacheImg, 0, 0, TILE_X, TILE_Y,DollsListImg, cur_doll*TILE_X, 0, 1);_ImgCopyToTileImg(TILEP_PLAYER, DollCacheImg, 0, 0, 1);_ImgCopyFromTileImg(TILEP_PLAYER, ScrBufImg, 8*TILE_X, 8*TILE_Y, 0);ImgCopy(DollsListImg, 0, 0,ImgWidth(DollsListImg), ImgHeight(DollsListImg),ScrBufImg, 3 * TILE_X, PARTS_Y, 0);_ImgCopyFromTileImg( TILE_CURSOR, ScrBufImg,(3 + cur_doll) * TILE_X, PARTS_Y, 0);region_tile->redraw();cgotoxy(10 , cur_part + 1, GOTO_STAT);if (cur_part == 1){current_gender = dolls[cur_doll].parts[p_lines[cur_part] ]%2;cprintf("%s", gender_name[ current_gender ]);}else if (cur_part != 0){tilep_part_to_str(dolls[cur_doll].parts[ p_lines[cur_part] ], ibuf);cprintf("%s", ibuf);}cgotoxy(1, pre_part + 1, GOTO_STAT);cprintf(" ");cgotoxy(1, cur_part + 1, GOTO_STAT);cprintf("->");pre_part = cur_part;/* Get a key */kin = getch();inc = cur_inc = 0;/* Analyze the key */switch (kin){case 0x1B: //ESCdone = 1;break;case 'h':inc = -1;break;case 'l':inc = +1;break;case 'H':inc = -PARTS_DISP_MAX;break;case 'L':inc = +PARTS_DISP_MAX;break;case 'j':if (cur_part < (PARTS_ITEMS-1) )cur_part += 1;elsecur_part = 0;break;case 'k':if (cur_part > 0)cur_part -= 1;elsecur_part = (PARTS_ITEMS-1);break;case 'm':if (mode == TILEP_M_LOADING)mode = TILEP_M_DEFAULT;elsemode = TILEP_M_LOADING;cgotoxy(1, 8, GOTO_MSG);cprintf("Toggle Startup mode : [m] (Current mode:%s)",( mode == TILEP_M_LOADING ? "Load User's Settings": "Class Default" ));break;case 't':if (cur_part >= 2){dolls[cur_doll].parts[ p_lines[cur_part] ] = 0;display_parts_idx(cur_part);}break;case CONTROL('D'):tilep_job_default(you.char_class, current_gender,dolls[cur_doll].parts);for (i = 2; i < PARTS_ITEMS; i++)display_parts_idx(i);break;case CONTROL('T'):for (i = 2; i < PARTS_ITEMS; i++){undo_dolls[cur_doll].parts[ p_lines[i] ]= dolls[cur_doll].parts[ p_lines[i] ];dolls[cur_doll].parts[ p_lines[i] ] = 0;display_parts_idx(i);}break;case CONTROL('C'):for (i = 2; i < PARTS_ITEMS; i++){copy_doll[ p_lines[i] ]= dolls[cur_doll].parts[ p_lines[i] ];}break;case CONTROL('V'):for (i = 2; i < PARTS_ITEMS; i++){undo_dolls[cur_doll].parts[ p_lines[i] ]= dolls[cur_doll].parts[ p_lines[i] ];dolls[cur_doll].parts[ p_lines[i] ]= copy_doll[ p_lines[i] ];display_parts_idx(i);}break;case CONTROL('Z'):for (i = 2; i < PARTS_ITEMS; i++){dolls[cur_doll].parts[ p_lines[i] ]= undo_dolls[cur_doll].parts[ p_lines[i] ];display_parts_idx(i);}break;case CONTROL('R'):for (i = 2; i < PARTS_ITEMS; i++){undo_dolls[cur_doll].parts[ p_lines[i] ]= dolls[cur_doll].parts[ p_lines[i] ];}dolls[cur_doll].parts[TILEP_PART_CLOAK]= coinflip() * (random2(tilep_parts_total[ TILEP_PART_CLOAK ]) + 1);dolls[cur_doll].parts[TILEP_PART_BOOTS]= random2(tilep_parts_total[ TILEP_PART_BOOTS ] + 1);dolls[cur_doll].parts[TILEP_PART_LEG]= random2(tilep_parts_total[ TILEP_PART_LEG ] + 1);dolls[cur_doll].parts[TILEP_PART_BODY]= random2(tilep_parts_total[ TILEP_PART_BODY ] + 1);dolls[cur_doll].parts[TILEP_PART_ARM]= coinflip() * ( random2(tilep_parts_total[ TILEP_PART_ARM ]) + 1);dolls[cur_doll].parts[TILEP_PART_HAND1]= random2(tilep_parts_total[ TILEP_PART_HAND1 ] + 1);dolls[cur_doll].parts[TILEP_PART_HAND2]= coinflip() * ( random2(tilep_parts_total[ TILEP_PART_HAND2 ]) + 1);dolls[cur_doll].parts[TILEP_PART_HAIR]= random2(tilep_parts_total[ TILEP_PART_HAIR ] + 1);dolls[cur_doll].parts[TILEP_PART_BEARD]= ((dolls[cur_doll].parts[TILEP_PART_BASE] + 1) % 2)* one_chance_in(4)* ( random2(tilep_parts_total[ TILEP_PART_BEARD ]) + 1 );dolls[cur_doll].parts[TILEP_PART_HELM]= coinflip() * ( random2(tilep_parts_total[ TILEP_PART_HELM ]) + 1 );for (i = 2; i < PARTS_ITEMS; i++)display_parts_idx(i);break;case '*':{int part = p_lines[cur_part];int *target = &dolls[cur_doll].parts[part];if (part == TILEP_PART_BASE)continue;if (*target == TILEP_SHOW_EQUIP)*target = 0;else*target = TILEP_SHOW_EQUIP;display_parts_idx(cur_part);break;}#ifdef WIZARDcase '1':dolls[cur_doll].parts[TILEP_PART_DRCHEAD]++;dolls[cur_doll].parts[TILEP_PART_DRCHEAD]%= tilep_parts_total[TILEP_PART_DRCHEAD] - 1;break;case '2':dolls[cur_doll].parts[TILEP_PART_DRCWING]++;dolls[cur_doll].parts[TILEP_PART_DRCWING]%= tilep_parts_total[TILEP_PART_DRCWING] - 1;break;#endifdefault:break;}if (inc != 0){int *target = &dolls[cur_doll].parts[ p_lines[cur_part] ];if (cur_part == 0){if (inc > 0)cur_doll++;elsecur_doll--;if (cur_doll < 0)cur_doll = DOLLS_MAX - 1;else if (cur_doll == DOLLS_MAX)cur_doll = 0;}else if (cur_part == 1){if (*target % 2)(*target)++;else(*target)--;}else{if (*target == TILEP_SHOW_EQUIP)continue;(*target) += inc;(*target) += tilep_parts_total[ p_lines[cur_part] ] + 1;(*target) %= tilep_parts_total[ p_lines[cur_part] ] + 1;}}delay(20);}current_doll = dolls[cur_doll];_draw_doll(DollCacheImg, ¤t_doll);_ImgCopyToTileImg(TILEP_PLAYER, DollCacheImg, 0, 0, 1);std::string dollsTxtString = datafile_path("dolls.txt", false, true);const char *dollsTxt = (dollsTxtString.c_str()[0] == 0) ?"dolls.txt" : dollsTxtString.c_str();if ( (fp = fopen(dollsTxt, "w+")) != NULL ){fprintf(fp, "MODE=%s\n", (mode == TILEP_M_LOADING) ? "LOADING": "DEFAULT" );fprintf(fp, "NUM=%02d\n", cur_doll);for (j = 0; j < DOLLS_MAX; j++){tilep_print_parts(fbuf, dolls[j].parts);fprintf(fp, "%s\n", fbuf);}fclose(fp);}ImgDestroy(PartsImg);ImgDestroy(DollsListImg);ImgClear(ScrBufImg);_redraw_spx_tcache(TILEP_PLAYER);for (x = 0; x < TILE_DAT_XMAX + 2; x++){for (y = 0; y < TILE_DAT_YMAX + 2; y++){t1buf[x][y] = 0;#if 0t2buf[x][y] = TILE_DNGN_UNSEEN | TILE_FLAG_UNSEEN;#endif}
for (x = 0; x < tile_xmax * tile_ymax; x++)screen_tcache_idx[x] = -1;clrscr();redraw_screen();#endif