2012-07-16 17:47:06 +02:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
* See COPYING for further information.
|
2012-07-16 17:47:06 +02:00
|
|
|
* ---
|
2017-09-12 03:28:15 +02:00
|
|
|
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
|
2012-07-16 17:47:06 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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"
|
2017-02-12 04:43:52 +01:00
|
|
|
#include "common.h"
|
2012-07-16 17:47:06 +02:00
|
|
|
|
2017-02-16 17:55:46 +01:00
|
|
|
void save_rpy(MenuData *menu, void *a) {
|
2012-07-16 17:47:06 +02:00
|
|
|
Replay *rpy = &global.replay;
|
|
|
|
char strtime[128], name[128];
|
|
|
|
time_t rawtime;
|
|
|
|
struct tm * timeinfo;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
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);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 15:49:29 +02:00
|
|
|
char prepr[16], drepr[16];
|
2012-08-07 05:28:41 +02:00
|
|
|
plrmode_repr(prepr, 16, rpy->stages[0].plr_char, rpy->stages[0].plr_shot);
|
2017-02-16 07:29:18 +01:00
|
|
|
strlcpy(drepr, difficulty_name(rpy->stages[0].diff), 16);
|
2012-08-07 15:49:29 +02:00
|
|
|
drepr[0] += 'a' - 'A';
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2017-02-09 05:06:46 +01:00
|
|
|
if(rpy->numstages > 1)
|
2012-08-07 15:49:29 +02:00
|
|
|
snprintf(name, 128, "taisei_%s_%s_%s", strtime, prepr, drepr);
|
2012-08-07 05:28:41 +02:00
|
|
|
else
|
2012-08-07 15:49:29 +02:00
|
|
|
snprintf(name, 128, "taisei_%s_stg%d_%s_%s", strtime, rpy->stages[0].stage, prepr, drepr);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-07-16 17:47:06 +02:00
|
|
|
replay_save(rpy, name);
|
|
|
|
}
|
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
void draw_saverpy_menu(MenuData *m) {
|
2012-08-12 16:54:48 +02:00
|
|
|
int i;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-12 16:54:48 +02:00
|
|
|
draw_options_menu_bg(m);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2017-02-12 04:43:52 +01:00
|
|
|
draw_menu_selector(SCREEN_W/2 + 100 * m->drawdata[0] - 50, SCREEN_H/2, 163, 81, m->frames);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 16:22:51 +02:00
|
|
|
glPushMatrix();
|
|
|
|
glColor4f(1, 1, 1, 1);
|
2012-08-07 05:28:41 +02:00
|
|
|
glTranslatef(SCREEN_W/2, SCREEN_H/2 - 100, 0);
|
2012-08-12 16:54:48 +02:00
|
|
|
draw_text(AL_Center, 0, 0, "Save Replay?", _fonts.mainmenu);
|
2012-08-07 05:28:41 +02:00
|
|
|
glTranslatef(0, 100, 0);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 16:22:51 +02:00
|
|
|
m->drawdata[0] += (m->cursor - m->drawdata[0])/10.0;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-12 16:54:48 +02:00
|
|
|
for(i = 0; i < m->ecount; i++) {
|
2012-08-07 05:28:41 +02:00
|
|
|
MenuEntry *e = &(m->entries[i]);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
e->drawdata += 0.2 * (10*(i == m->cursor) - e->drawdata);
|
|
|
|
float a = e->drawdata * 0.1;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
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);
|
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
if(e->name)
|
|
|
|
draw_text(AL_Center, -50 + 100 * i, 0, e->name, _fonts.mainmenu);
|
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
2017-09-29 21:03:49 +02:00
|
|
|
bool savepry_input_handler(SDL_Event *event, void *arg) {
|
|
|
|
if(event->type == MAKE_TAISEI_EVENT(TE_MENU_CURSOR_UP)) {
|
|
|
|
event->type = MAKE_TAISEI_EVENT(TE_MENU_CURSOR_LEFT);
|
|
|
|
} else if(event->type == MAKE_TAISEI_EVENT(TE_MENU_CURSOR_UP)) {
|
|
|
|
event->type = MAKE_TAISEI_EVENT(TE_MENU_CURSOR_RIGHT);
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
2012-08-13 17:50:28 +02:00
|
|
|
}
|
|
|
|
|
2012-08-12 17:28:43 +02:00
|
|
|
void saverpy_menu_input(MenuData *menu) {
|
2017-09-29 21:03:49 +02:00
|
|
|
events_poll((EventHandler[]){
|
|
|
|
{ .proc = savepry_input_handler, .arg = menu },
|
|
|
|
{ .proc = menu_input_handler, .arg = menu },
|
|
|
|
{NULL}
|
|
|
|
}, EFLAG_MENU);
|
2012-08-12 17:28:43 +02:00
|
|
|
}
|
|
|
|
|
2017-02-24 22:58:27 +01:00
|
|
|
void create_saverpy_menu(MenuData *m) {
|
|
|
|
create_menu(m);
|
|
|
|
m->input = saverpy_menu_input;
|
|
|
|
m->draw = draw_saverpy_menu;
|
|
|
|
|
|
|
|
m->flags = MF_Transient;
|
|
|
|
|
|
|
|
add_menu_entry(m, "Yes", save_rpy, NULL);
|
|
|
|
add_menu_entry(m, "No", menu_commonaction_close, NULL);
|
2012-07-16 17:47:06 +02:00
|
|
|
}
|