press F3 to save game in editor.

This commit is contained in:
Enno Rehling 2015-05-12 17:18:51 -07:00
parent c57907e340
commit 9b9e038438
4 changed files with 31 additions and 14 deletions

View File

@ -761,6 +761,29 @@ static void select_regions(state * st, int selectmode)
st->wnd_map->update |= 3;
}
void loaddata(state *st) {
char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
if (strlen(datafile) > 0) {
create_backup(datafile);
readgame(datafile, false);
st->modified = 0;
}
}
void savedata(state *st) {
char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
if (strlen(datafile) > 0) {
create_backup(datafile);
remove_empty_units();
writegame(datafile);
st->modified = 0;
}
}
static void handlekey(state * st, int c)
{
window *wnd;
@ -816,17 +839,11 @@ static void handlekey(state * st, int c)
case 'S':
case KEY_SAVE:
case KEY_F(2):
/* if (st->modified) */ {
char datafile[MAX_PATH];
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
if (strlen(datafile) > 0) {
create_backup(datafile);
remove_empty_units();
writegame(datafile);
st->modified = 0;
}
}
savedata(st);
break;
case KEY_F(3):
case KEY_OPEN:
loaddata(st);
break;
case 'B':
/*

View File

@ -1348,7 +1348,7 @@ void writefaction(struct gamedata *data, const faction * f)
write_spellbook(f->spellbook, data->store);
}
int readgame(const char *filename, int backup)
int readgame(const char *filename, bool backup)
{
int n, p, nread;
faction *f, **fp;

View File

@ -44,7 +44,7 @@ extern "C" {
int readorders(const char *filename);
int creategame(void);
int readgame(const char *filename, int backup);
int readgame(const char *filename, bool backup);
int writegame(const char *filename);
/* Versionsänderungen: */

View File

@ -15,7 +15,7 @@ static void test_readwrite_data(CuTest * tc)
test_cleanup();
sprintf(path, "%s/%s", datapath(), filename);
CuAssertIntEquals(tc, 0, writegame(filename));
CuAssertIntEquals(tc, 0, readgame(filename, 0));
CuAssertIntEquals(tc, 0, readgame(filename, false));
CuAssertIntEquals(tc, RELEASE_VERSION, global.data_version);
CuAssertIntEquals(tc, 0, remove(path));
test_cleanup();