Editor shows an error menu if save fails
This commit is contained in:
parent
dbba73f598
commit
d0e4c7e4e4
3 changed files with 24 additions and 8 deletions
src
|
@ -1272,7 +1272,7 @@ local void EditorCallbackKeyDown(unsigned key, unsigned keychar)
|
|||
case 's': // ALT s F11 save pud menu
|
||||
case 'S':
|
||||
case KeyCodeF11:
|
||||
if (EditorSave()) {
|
||||
if (EditorSave() != -1) {
|
||||
SetStatusLine("Pud saved");
|
||||
}
|
||||
InterfaceState = IfaceStateNormal;
|
||||
|
@ -1862,11 +1862,13 @@ local void CreateEditor(void)
|
|||
**
|
||||
** @param file Save the level to this file.
|
||||
**
|
||||
** @return 0 for success, -1 for error
|
||||
**
|
||||
** @todo FIXME: Check if the pud is valid, contains no failures.
|
||||
** Alteast two players, one human slot, every player a startpoint
|
||||
** At least two players, one human slot, every player a startpoint
|
||||
** ...
|
||||
*/
|
||||
global void EditorSavePud(const char *file)
|
||||
global int EditorSavePud(const char *file)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -1881,7 +1883,15 @@ global void EditorSavePud(const char *file)
|
|||
~MapFieldLandUnit;
|
||||
}
|
||||
}
|
||||
SavePud(file, &TheMap);
|
||||
if (SavePud(file, &TheMap) == -1) {
|
||||
ErrorMenu("Cannot save map");
|
||||
MustRedraw = RedrawEverything;
|
||||
InterfaceState = IfaceStateNormal;
|
||||
EditorUpdateDisplay();
|
||||
InterfaceState = IfaceStateMenu;
|
||||
MustRedraw = RedrawMenu;
|
||||
return -1;
|
||||
}
|
||||
for (i = 0; i < NumUnits; ++i) {
|
||||
const UnitType *type;
|
||||
|
||||
|
@ -1893,6 +1903,7 @@ global void EditorSavePud(const char *file)
|
|||
MapFieldLandUnit;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
|
|
|
@ -57,7 +57,7 @@ extern void EditorMainLoop(void);
|
|||
extern void EditorUpdateDisplay(void);
|
||||
|
||||
/// Save a pud from editor
|
||||
extern void EditorSavePud(const char *file);
|
||||
extern int EditorSavePud(const char *file);
|
||||
|
||||
/// Register ccl features
|
||||
extern void EditorCclRegister(void);
|
||||
|
|
|
@ -5699,6 +5699,8 @@ local void EditorEditAiPropertiesCancel(void)
|
|||
|
||||
/**
|
||||
** Save map from the editor
|
||||
**
|
||||
** @return 0 for success, -1 for error
|
||||
*/
|
||||
global int EditorSave(void)
|
||||
{
|
||||
|
@ -5706,7 +5708,9 @@ global int EditorSave(void)
|
|||
char path[PATH_MAX];
|
||||
char *s;
|
||||
char *p;
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
menu = FindMenu("menu-editor-save");
|
||||
|
||||
EditorCancelled = 0;
|
||||
|
@ -5723,16 +5727,17 @@ global int EditorSave(void)
|
|||
|
||||
if (!EditorCancelled) {
|
||||
sprintf(path, "%s/%s.gz", ScenSelectPath, ScenSelectFileName);
|
||||
EditorSavePud(path);
|
||||
if (EditorSavePud(path) == -1) {
|
||||
ret = -1;
|
||||
}
|
||||
s = ScenSelectPath + strlen(ScenSelectPath);
|
||||
*s = '/';
|
||||
strcpy(s+1, ScenSelectFileName); // Final map name with path
|
||||
p = ScenSelectPath + strlen(FreeCraftLibPath) + 1;
|
||||
strcpy(CurrentMapPath, p);
|
||||
*s = '\0';
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue