forked from github/server
press F3 to save game in editor.
This commit is contained in:
parent
c57907e340
commit
9b9e038438
39
src/gmtool.c
39
src/gmtool.c
|
@ -761,6 +761,29 @@ static void select_regions(state * st, int selectmode)
|
||||||
st->wnd_map->update |= 3;
|
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)
|
static void handlekey(state * st, int c)
|
||||||
{
|
{
|
||||||
window *wnd;
|
window *wnd;
|
||||||
|
@ -816,17 +839,11 @@ static void handlekey(state * st, int c)
|
||||||
case 'S':
|
case 'S':
|
||||||
case KEY_SAVE:
|
case KEY_SAVE:
|
||||||
case KEY_F(2):
|
case KEY_F(2):
|
||||||
/* if (st->modified) */ {
|
savedata(st);
|
||||||
char datafile[MAX_PATH];
|
break;
|
||||||
|
case KEY_F(3):
|
||||||
askstring(st->wnd_status->handle, "save as:", datafile, sizeof(datafile));
|
case KEY_OPEN:
|
||||||
if (strlen(datafile) > 0) {
|
loaddata(st);
|
||||||
create_backup(datafile);
|
|
||||||
remove_empty_units();
|
|
||||||
writegame(datafile);
|
|
||||||
st->modified = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -1348,7 +1348,7 @@ void writefaction(struct gamedata *data, const faction * f)
|
||||||
write_spellbook(f->spellbook, data->store);
|
write_spellbook(f->spellbook, data->store);
|
||||||
}
|
}
|
||||||
|
|
||||||
int readgame(const char *filename, int backup)
|
int readgame(const char *filename, bool backup)
|
||||||
{
|
{
|
||||||
int n, p, nread;
|
int n, p, nread;
|
||||||
faction *f, **fp;
|
faction *f, **fp;
|
||||||
|
|
|
@ -44,7 +44,7 @@ extern "C" {
|
||||||
|
|
||||||
int readorders(const char *filename);
|
int readorders(const char *filename);
|
||||||
int creategame(void);
|
int creategame(void);
|
||||||
int readgame(const char *filename, int backup);
|
int readgame(const char *filename, bool backup);
|
||||||
int writegame(const char *filename);
|
int writegame(const char *filename);
|
||||||
|
|
||||||
/* Versionsänderungen: */
|
/* Versionsänderungen: */
|
||||||
|
|
|
@ -15,7 +15,7 @@ static void test_readwrite_data(CuTest * tc)
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
sprintf(path, "%s/%s", datapath(), filename);
|
sprintf(path, "%s/%s", datapath(), filename);
|
||||||
CuAssertIntEquals(tc, 0, writegame(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, RELEASE_VERSION, global.data_version);
|
||||||
CuAssertIntEquals(tc, 0, remove(path));
|
CuAssertIntEquals(tc, 0, remove(path));
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
|
|
Loading…
Reference in New Issue