home *** CD-ROM | disk | FTP | other *** search
- #include "Glue.h"
- #include "Empty.h"
- #include "ModSetups.h"
-
- #define kNumDialogItems 1
-
-
- pascal OSErr settings(ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs)
- {
- ItemInfoHandle myItemInfo;
- unsigned long myParamOne;
- short myParamTwo;
- OSErr error;
-
-
- // load the last used settings.
-
- error = GetModSettings(modInfo, glue, prefs);
- if (error)
- return error;
-
- myParamOne = (**prefs)->paramOne;
- myParamTwo = (**prefs)->paramTwo;
- DisposHandle((Handle)*prefs);
- *prefs = 0L;
-
-
- // set up and show the settings dialog.
-
- myItemInfo = (ItemInfoHandle)NewHandleClear(sizeof(ItemInfoRec) * kNumDialogItems);
- if (myItemInfo == 0L)
- return kModNotEnoughMemory;
-
- (*myItemInfo)[0].type = type_ignore;
- (*myItemInfo)[0].param = 0L;
-
- error = (*glue->ModDoSettingsDialog)(modInfo, myItemInfo, false, 0L, 0L, 0L);
- DisposHandle((Handle)myItemInfo);
- if (error)
- return error;
-
-
- // save the new settings in the *prefs handle.
-
- *prefs = (ModSettingsHandle)NewHandle(sizeof(ModSettingsRec));
- if (*prefs)
- {
- (**prefs)->paramOne = myParamOne;
- (**prefs)->paramTwo = myParamTwo;
-
-
- error = (*glue->SaveEffectSettings)(kModSignature, prefs);
-
- // we must not dispose of the handle, since the ‘effect’ routine may be called
- // immediately after us, and it’ll need it. If the handle is not needed, it
- // will be automatically disposed of.
- }
- else
- return kModNotEnoughMemory;
-
- return kModNoError;
- }
-
-
- pascal OSErr GetModSettings(ModParamsPtr modInfo, GluePtr glue, ModSettingsHandle *prefs)
- {
- // this routine loads the settings. If no settings can be found, but the
- // module requires them, it has to store default settings in a new handle.
- //
- // If the module doesn’t require any parameters, this routine can just return.
-
- OSErr error;
-
- error = (*glue->LoadEffectSettings)(kModSignature, prefs);
- if (error || *prefs == 0L)
- {
- *prefs = (ModSettingsHandle)NewHandle(sizeof(ModSettingsRec));
-
- if (*prefs)
- {
- // Set the default settings.
-
- (**prefs)->paramOne = 1L;
- (**prefs)->paramTwo = 2;
-
- error = kModNoError;
- }
- else
- error = kModNotEnoughMemory;
- }
-
- return error;
- }