projects
/
neverball
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed the problem that in a rare case, a set is downloaded and the neverballrc is...
[neverball]
/
ball
/
st_save.c
diff --git
a/ball/st_save.c
b/ball/st_save.c
index
59dea2c
..
ea4abe3
100644
(file)
--- a/
ball/st_save.c
+++ b/
ball/st_save.c
@@
-13,6
+13,7
@@
*/
#include <string.h>
*/
#include <string.h>
+#include <ctype.h>
#include "gui.h"
#include "game.h"
#include "gui.h"
#include "game.h"
@@
-20,12
+21,15
@@
#include "audio.h"
#include "config.h"
#include "demo.h"
#include "audio.h"
#include "config.h"
#include "demo.h"
-#include "st_shared.h"
+#include "levels.h"
+#include "text.h"
+#include "st_shared.h"
#include "st_save.h"
extern struct state st_save;
extern struct state st_clobber;
#include "st_save.h"
extern struct state st_save;
extern struct state st_clobber;
+
static char filename[MAXNAM];
/*---------------------------------------------------------------------------*/
static char filename[MAXNAM];
/*---------------------------------------------------------------------------*/
@@
-36,55
+40,57
@@
static struct state *cancel_state;
int goto_save(struct state *ok, struct state *cancel)
{
demo_unique(filename);
int goto_save(struct state *ok, struct state *cancel)
{
demo_unique(filename);
+
ok_state = ok;
cancel_state = cancel;
ok_state = ok;
cancel_state = cancel;
+
return goto_state(&st_save);
}
/*---------------------------------------------------------------------------*/
return goto_state(&st_save);
}
/*---------------------------------------------------------------------------*/
-#define SAVE_SAVE 2
-#define SAVE_CANCEL 3
-
static int file_id;
static int file_id;
+#define SAVE_SAVE 1
+#define SAVE_CANCEL 2
+
static int save_action(int i)
{
static int save_action(int i)
{
- size_t l = strlen(filename);
+ char *n;
audio_play(AUD_MENU, 1.0f);
switch (i)
{
case SAVE_SAVE:
audio_play(AUD_MENU, 1.0f);
switch (i)
{
case SAVE_SAVE:
- if (strcmp(filename, "") == 0)
+ n = text_to_locale(filename);
+
+ if (strlen(n) == 0)
return 1;
return 1;
- if (demo_exists(filename))
+
+ if (demo_exists(n))
return goto_state(&st_clobber);
else
{
return goto_state(&st_clobber);
else
{
- demo_play_save(filename);
+ demo_rename(n);
return goto_state(ok_state);
}
case SAVE_CANCEL:
return goto_state(cancel_state);
return goto_state(ok_state);
}
case SAVE_CANCEL:
return goto_state(cancel_state);
+ case GUI_CL:
+ gui_keyboard_lock();
+ break;
+
case GUI_BS:
case GUI_BS:
- if (l > 0)
- {
- filename[l - 1] = 0;
+ if (text_del_char(filename))
gui_set_label(file_id, filename);
gui_set_label(file_id, filename);
- }
break;
default:
break;
default:
- if (l < MAXNAM - 1)
- {
- filename[l + 0] = (char) i;
- filename[l + 1] = 0;
+ if (text_add_char(i, filename, MAXNAM, 17))
gui_set_label(file_id, filename);
gui_set_label(file_id, filename);
- }
}
return 1;
}
}
return 1;
}
@@
-100,13
+106,13
@@
static int save_enter(void)
gui_label(id, _("Replay Name"), GUI_MED, GUI_ALL, 0, 0);
gui_space(id);
gui_label(id, _("Replay Name"), GUI_MED, GUI_ALL, 0, 0);
gui_space(id);
- gui_space(id);
file_id = gui_label(id, filename, GUI_MED, GUI_ALL, gui_yel, gui_yel);
gui_space(id);
gui_keyboard(id);
file_id = gui_label(id, filename, GUI_MED, GUI_ALL, gui_yel, gui_yel);
gui_space(id);
gui_keyboard(id);
+
if ((jd = gui_harray(id)))
{
enter_id = gui_start(jd, _("Save"), GUI_SML, SAVE_SAVE, 0);
if ((jd = gui_harray(id)))
{
enter_id = gui_start(jd, _("Save"), GUI_SML, SAVE_SAVE, 0);
@@
-130,15
+136,14
@@
static void save_leave(int id)
static int save_keybd(int c, int d)
{
if (d)
static int save_keybd(int c, int d)
{
if (d)
- if ((c & 0xFF80) == 0)
- {
- gui_focus(enter_id);
- c &= 0x7F;
- if (c == '\b')
- return save_action(GUI_BS);
- else if (c > ' ')
- return save_action(c);
- }
+ {
+ gui_focus(enter_id);
+
+ if (c == '\b' || c == 0x7F)
+ return save_action(GUI_BS);
+ if (c > ' ')
+ return save_action(c);
+ }
return 1;
}
return 1;
}
@@
-147,7
+152,13
@@
static int save_buttn(int b, int d)
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return save_action(gui_token(gui_click()));
+ {
+ int c = gui_token(gui_click());
+
+ /* Ugh. This is such a hack. */
+
+ return save_action(isupper(c) ? gui_keyboard_char(c) : c);
+ }
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return save_action(SAVE_CANCEL);
}
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return save_action(SAVE_CANCEL);
}
@@
-162,7
+173,7
@@
static int clobber_action(int i)
if (i == SAVE_SAVE)
{
if (i == SAVE_SAVE)
{
- demo_play_save(filename);
+ demo_rename(text_to_locale(filename));
return goto_state(ok_state);
}
return goto_state(&st_save);
return goto_state(ok_state);
}
return goto_state(&st_save);
@@
-212,6
+223,7
@@
struct state st_save = {
shared_timer,
shared_point,
shared_stick,
shared_timer,
shared_point,
shared_stick,
+ shared_angle,
shared_click,
save_keybd,
save_buttn,
shared_click,
save_keybd,
save_buttn,
@@
-225,6
+237,7
@@
struct state st_clobber = {
shared_timer,
shared_point,
shared_stick,
shared_timer,
shared_point,
shared_stick,
+ shared_angle,
shared_click,
NULL,
clobber_buttn,
shared_click,
NULL,
clobber_buttn,