static void replayview_drawitem(void *n, int item, int cnt) { MenuEntry *e = (MenuEntry*)n; Replay *rpy = (Replay*)e->arg; float sizes[] = {1.2, 1.45, 0.8, 0.8, 0.65}; int columns = 5, i, j; for(i = 0; i < columns; ++i) { char tmp[128]; int csize = sizes[i] * (SCREEN_W - 210)/columns; int o = 0; for(j = 0; j < i; ++j) o += sizes[j] * (SCREEN_W - 210)/columns; Alignment a = AL_Center; // hell yeah, another loop-switch sequence switch(i) { case 0: a = AL_Left; time_t t = rpy->stages[0].seed; struct tm* timeinfo = localtime(&t); strftime(tmp, 128, "%Y-%m-%d %H:%M", timeinfo); break; case 1: a = AL_Center; strncpy(tmp, rpy->playername, 128); break; case 2: plrmode_repr(tmp, 128, rpy->stages[0].plr_char, rpy->stages[0].plr_shot); tmp[0] = tmp[0] - 'a' + 'A'; break; case 3: snprintf(tmp, 128, difficulty_name(rpy->stages[0].diff)); break; case 4: a = AL_Right; if(rpy->stgcount == 1) snprintf(tmp, 128, "Stage %i", rpy->stages[0].stage); else snprintf(tmp, 128, "%i stages", rpy->stgcount); break; } shorten(tmp, csize); switch(a) { case AL_Center: o += csize * 0.5 - stringwidth(tmp, _fonts.standard) * 0.5; break; case AL_Right: o += csize - stringwidth(tmp, _fonts.standard); break; default: break; } draw_text(AL_Left, o + 10, 20*item, tmp, _fonts.standard); } }
void save_rpy(void *a) { Replay *rpy = &global.replay; char strtime[128], name[128]; time_t rawtime; struct tm * timeinfo; // time when the game was *initiated* rawtime = (time_t)rpy->stages[0].seed; timeinfo = localtime(&rawtime); strftime(strtime, 128, "%Y%m%d_%H-%M-%S_%Z", timeinfo); char prepr[16], drepr[16]; plrmode_repr(prepr, 16, rpy->stages[0].plr_char, rpy->stages[0].plr_shot); strncpy(drepr, difficulty_name(rpy->stages[0].diff), 16); drepr[0] += 'a' - 'A'; if(rpy->stgcount > 1) snprintf(name, 128, "taisei_%s_%s_%s", strtime, prepr, drepr); else snprintf(name, 128, "taisei_%s_stg%d_%s_%s", strtime, rpy->stages[0].stage, prepr, drepr); replay_save(rpy, name); }