2012-07-16 17:47:06 +02:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
|
|
|
* See COPYING for further information.
|
|
|
|
* ---
|
|
|
|
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
|
|
|
|
* Copyright (C) 2012, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <time.h>
|
|
|
|
#include "savereplay.h"
|
2012-08-07 05:28:41 +02:00
|
|
|
#include "options.h"
|
2012-07-16 17:47:06 +02:00
|
|
|
#include "global.h"
|
|
|
|
#include "replay.h"
|
|
|
|
#include "plrmodes.h"
|
|
|
|
|
|
|
|
void save_rpy(void *a) {
|
|
|
|
Replay *rpy = &global.replay;
|
|
|
|
char strtime[128], name[128];
|
|
|
|
time_t rawtime;
|
|
|
|
struct tm * timeinfo;
|
|
|
|
|
2012-07-29 22:39:52 +02:00
|
|
|
// time when the game was *initiated*
|
2012-08-07 05:28:41 +02:00
|
|
|
rawtime = (time_t)rpy->stages[0].seed;
|
2012-07-16 17:47:06 +02:00
|
|
|
timeinfo = localtime(&rawtime);
|
|
|
|
strftime(strtime, 128, "%Y%m%d_%H-%M-%S_%Z", timeinfo);
|
|
|
|
|
|
|
|
char prepr[16];
|
2012-08-07 05:28:41 +02:00
|
|
|
plrmode_repr(prepr, 16, rpy->stages[0].plr_char, rpy->stages[0].plr_shot);
|
|
|
|
|
|
|
|
if(rpy->stgcount > 1)
|
|
|
|
snprintf(name, 128, "taisei_%s_%s", prepr, strtime);
|
|
|
|
else
|
|
|
|
snprintf(name, 128, "taisei_stg%d_%s_%s", rpy->stages[0].stage, prepr, strtime);
|
2012-07-16 17:47:06 +02:00
|
|
|
|
|
|
|
replay_save(rpy, name);
|
2012-08-07 05:53:21 +02:00
|
|
|
if(a) ((MenuData*)a)->quit = 2;
|
2012-07-16 17:47:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void dont_save_rpy(void *a) {
|
2012-08-07 05:28:41 +02:00
|
|
|
((MenuData*)a)->quit = 2;
|
2012-07-16 17:47:06 +02:00
|
|
|
}
|
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
void create_saverpy_menu(MenuData *m) {
|
2012-07-16 17:47:06 +02:00
|
|
|
create_menu(m);
|
2012-08-07 05:28:41 +02:00
|
|
|
m->type = MT_Persistent;
|
|
|
|
m->title = "Save replay?";
|
2012-07-16 17:47:06 +02:00
|
|
|
|
|
|
|
add_menu_entry(m, "Yes", save_rpy, m);
|
|
|
|
add_menu_entry(m, "No", dont_save_rpy, m);
|
2012-08-07 05:28:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void draw_saverpy_menu(MenuData *m) {
|
|
|
|
draw_options_menu_bg(m);
|
|
|
|
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(SCREEN_W/2, SCREEN_H/2 - 100, 0);
|
|
|
|
draw_text(AL_Center, 0, 0, m->title, _fonts.mainmenu);
|
|
|
|
glTranslatef(0, 100, 0);
|
2012-07-16 17:47:06 +02:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
int i; for(i = 0; i < m->ecount; i++) {
|
|
|
|
MenuEntry *e = &(m->entries[i]);
|
|
|
|
|
|
|
|
e->drawdata += 0.2 * (10*(i == m->cursor) - e->drawdata);
|
|
|
|
float a = e->drawdata * 0.1;
|
|
|
|
|
|
|
|
if(e->action == NULL)
|
|
|
|
glColor4f(0.5, 0.5, 0.5, 0.5);
|
|
|
|
else {
|
|
|
|
float ia = 1-a;
|
|
|
|
glColor4f(0.9 + ia * 0.1, 0.6 + ia * 0.4, 0.2 + ia * 0.8, 0.7 + 0.3 * a);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(e->name)
|
|
|
|
draw_text(AL_Center, -50 + 100 * i, 0, e->name, _fonts.mainmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
fade_out(m->fade);
|
|
|
|
}
|
|
|
|
|
|
|
|
int saverpy_menu_loop(MenuData *m) {
|
|
|
|
return menu_loop(m, NULL, draw_saverpy_menu);
|
2012-07-16 17:47:06 +02:00
|
|
|
}
|