return max_ed_fieldy;
}
-void InitZoomLevelSettings()
+void InitZoomLevelSettings(int zoom_tilesize)
{
+ if (zoom_tilesize == -1)
+ zoom_tilesize = setup.auto_setup.editor_zoom_tilesize;
+
+ // limit zoom tilesize by upper and lower bound
+ zoom_tilesize = MIN(MAX(MICRO_TILESIZE, zoom_tilesize), TILESIZE);
+
+ ed_tilesize = setup.auto_setup.editor_zoom_tilesize = zoom_tilesize;
+
MAX_ED_FIELDX = getMaxEdFieldX(FALSE);
MAX_ED_FIELDY = getMaxEdFieldY(FALSE);
}
ClearField();
- InitZoomLevelSettings();
+ InitZoomLevelSettings(-1);
OpenDoor(DOOR_OPEN_1 | DOOR_OPEN_2 | DOOR_NO_DELAY);
// limit zoom level by upper and lower bound
ed_tilesize = MIN(MAX(MICRO_TILESIZE, ed_tilesize), TILESIZE);
- InitZoomLevelSettings();
+ InitZoomLevelSettings(ed_tilesize);
if (edit_mode == ED_MODE_DRAWING)
{
PrintEditorGadgetInfoText(level_editor_gadget[id]);
}
+ /* save current editor zoom tilesize */
+ SaveSetup_AutoSetup();
+
break;
case GADGET_ID_CUSTOM_COPY_FROM:
#define NUM_GLOBAL_SETUP_TOKENS 44
+/* auto setup */
+#define SETUP_TOKEN_AUTO_EDITOR_ZOOM_TILESIZE 0
+
+#define NUM_AUTO_SETUP_TOKENS 1
+
/* editor setup */
#define SETUP_TOKEN_EDITOR_EL_CLASSIC 0
#define SETUP_TOKEN_EDITOR_EL_CUSTOM 1
static struct SetupInfo si;
+static struct SetupAutoSetupInfo sasi;
static struct SetupEditorInfo sei;
static struct SetupEditorCascadeInfo seci;
static struct SetupShortcutInfo ssi;
{ TYPE_INTEGER,&si.touch.drop_distance, "touch.drop_distance" },
};
+static struct TokenInfo auto_setup_tokens[] =
+{
+ { TYPE_INTEGER,&sasi.editor_zoom_tilesize, "editor.zoom_tilesize" },
+};
+
static struct TokenInfo editor_setup_tokens[] =
{
{ TYPE_SWITCH, &sei.el_classic, "editor.el_classic" },
#endif
}
+static void setSetupInfoToDefaults_AutoSetup(struct SetupInfo *si)
+{
+ si->auto_setup.editor_zoom_tilesize = MINI_TILESIZE;
+}
+
static void setSetupInfoToDefaults_EditorCascade(struct SetupInfo *si)
{
si->editor_cascade.el_bd = TRUE;
setup.options = soi;
}
+static void decodeSetupFileHash_AutoSetup(SetupFileHash *setup_file_hash)
+{
+ int i;
+
+ if (!setup_file_hash)
+ return;
+
+ /* auto setup */
+ sasi = setup.auto_setup;
+ for (i = 0; i < NUM_AUTO_SETUP_TOKENS; i++)
+ setSetupInfo(auto_setup_tokens, i,
+ getHashEntry(setup_file_hash,
+ auto_setup_tokens[i].text));
+ setup.auto_setup = sasi;
+}
+
static void decodeSetupFileHash_EditorCascade(SetupFileHash *setup_file_hash)
{
int i;
LoadSetup_SpecialPostProcessing();
}
+void LoadSetup_AutoSetup()
+{
+ char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME);
+ SetupFileHash *setup_file_hash = NULL;
+
+ /* always start with reliable default values */
+ setSetupInfoToDefaults_AutoSetup(&setup);
+
+ setup_file_hash = loadSetupFileHash(filename);
+
+ if (setup_file_hash)
+ {
+ decodeSetupFileHash_AutoSetup(setup_file_hash);
+
+ freeSetupFileHash(setup_file_hash);
+ }
+
+ free(filename);
+}
+
void LoadSetup_EditorCascade()
{
char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
SetFilePermissions(filename, PERMS_PRIVATE);
}
+void SaveSetup_AutoSetup()
+{
+ char *filename = getPath2(getSetupDir(), AUTOSETUP_FILENAME);
+ FILE *file;
+ int i;
+
+ InitUserDataDirectory();
+
+ if (!(file = fopen(filename, MODE_WRITE)))
+ {
+ Error(ERR_WARN, "cannot write auto setup file '%s'", filename);
+ free(filename);
+ return;
+ }
+
+ fprintFileHeader(file, AUTOSETUP_FILENAME);
+
+ sasi = setup.auto_setup;
+ for (i = 0; i < NUM_AUTO_SETUP_TOKENS; i++)
+ fprintf(file, "%s\n", getSetupLine(auto_setup_tokens, "", i));
+
+ fclose(file);
+
+ SetFilePermissions(filename, PERMS_PRIVATE);
+
+ free(filename);
+}
+
void SaveSetup_EditorCascade()
{
char *filename = getPath2(getSetupDir(), EDITORCASCADE_FILENAME);
/* file names and filename extensions */
#define LEVELSETUP_DIRECTORY "levelsetup"
#define SETUP_FILENAME "setup.conf"
+#define AUTOSETUP_FILENAME "autosetup.conf"
#define LEVELSETUP_FILENAME "levelsetup.conf"
#define EDITORSETUP_FILENAME "editorsetup.conf"
#define EDITORCASCADE_FILENAME "editorcascade.conf"
boolean use_template_for_new_levels;
};
+struct SetupAutoSetupInfo
+{
+ int editor_zoom_tilesize;
+};
+
struct SetupEditorCascadeInfo
{
boolean el_bd;
int volume_loops;
int volume_music;
+ struct SetupAutoSetupInfo auto_setup;
struct SetupEditorInfo editor;
struct SetupEditorCascadeInfo editor_cascade;
struct SetupShortcutInfo shortcut;