home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
gfx
/
edit
/
tsmorph
/
src
/
tsmorph-prefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-25
|
39KB
|
1,512 lines
// TSMorph - Amiga Morphing program
// Copyright (C) © 1993 Topicsave Limited
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// mpaddock@cix.compulink.co.uk
// This code was written a bit quick and includes a
// lot of hard coded stuff which should be #defined
// Include headers
#include <proto/exec.h>
#include <proto/gadtools.h>
#include <proto/intuition.h>
#include <proto/diskfont.h>
#include <proto/graphics.h>
#include <proto/utility.h>
#include <proto/asl.h>
#include <proto/icon.h>
#include <proto/dos.h>
#include <libraries/amigaguide.h>
#include <clib/amigaguide_protos.h>
#include <pragmas/amigaguide_pragmas.h>
#define LIBRARIES_MATHFFP_H // Do not include other math stuff
#include <clib/alib_protos.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <intuition/gadgetclass.h>
// following not in 2.02 headers
#if INCLUDE_VERSION < 37
LONG Stricmp(UBYTE *string1,UBYTE *string2);
#pragma libcall UtilityBase Stricmp A2 9802
#endif
#include "Prefs.h"
struct Library *GadToolsBase;
struct Library *UtilityBase;
struct Library *AslBase;
struct Library *AmigaGuideBase;
struct FileRequester *filereq = NULL;
char TempFilename[257];
AMIGAGUIDECONTEXT handle = NULL;
struct NewAmigaGuide nag = {NULL};
ULONG ASig = 0;
/* Version string for CLI version */
char *Version = "$VER: TSMorph-prefs 3.0 (25.2.94)";
// Help nodes
unsigned char *context[] = {
"", // 0
"Main", // 1
"P-KEEPSETTINGS", // 2
"P-CHANGEPALETTE",// 3
"P-CREATEICONS", // 4
"P-CREATEICONSP", // 5
"P-OPENMODE", // 6
"P-PUBSCREEN", // 7
"P-ZOOM", // 8
"P-CREATEICONSR", // 9
"P-DEPTH", // 10
"P-DX", // 11
"P-DY", // 12
"P-LOADSCRIPT", // 13
"P-MODE", // 14
"P-POSTSCRIPT", // 15
"P-PRESCRIPT", // 16
"P-PUBSCREENR", // 17
"P-QUALITY", // 18
"P-SAVEFORMAT", // 19
"P-ANTIALIAS", // 20
"P-HELP", // 21
"P-PREVIEW", // 22
"P-CUSTOMMODE", // 23
"P-CUSTOMDEPTH", // 24
"TSMP-Close", // 25
"TSMP-Depth", // 26
"TSMP-Zoom", // 27
"TSMorph-prefs", // 28
"TSMP-Save", // 29
"TSMP-Use", // 30
"TSMP-Cancel", // 31
"TSMP-men-Project",// 32
"TSMP-men-P-Open",// 33
"TSMP-men-P-SaveAs",// 34
"TSMP-men-P-Quit",// 35
"TSMP-men-Edit", // 36
"TSMP-men-E-ResetD",//37
"TSMP-men-E-LastS",//38
"TSMP-men-E-Restore",//39
"TSMP-men-Settings",//40
"TSMP-men-S-Icons",//41
"TSMP-men", //42
"P-INTEGER", // 43
};
// Settings
STRPTR CustomScreen[100] = {"NONE",NULL}; // table of modes - headed by none
ULONG CustomMode = 0;
ULONG CustomDepth = 4;
ULONG DX = 0;
ULONG DY = 0;
ULONG RenderMode = 0;
ULONG SaveFormat = 0;
ULONG Quality = 75;
BOOL AntiAlias = FALSE;
BOOL Integer = FALSE;
ULONG Depth = 2;
ULONG Zoom = 1;
ULONG Palette = 0;
ULONG OpenMode = 2;
BOOL KeepPrefs = TRUE;
BOOL Help = FALSE;
BOOL ProjectI = TRUE;
BOOL PrefsI = TRUE;
BOOL RenderI = FALSE;
// Icons from this program
BOOL Icons = TRUE;
// Prototypes
void UpdateGadgets(void);
void DisableWindow(void);
void EnableWindow(void);
void Error(char *ErrorMessage,char *extra);
void SaveSettings(char *filename);
void LoadSettings(char *filename);
BOOL GetAFile(char *name,char *Prompt,ULONG flags);
void InitParams(UBYTE *string);
void help(ULONG helpnum);
// Is point in a rectangle
#define PointInBox(x,y,mx,my,MX,MY) ((x>=mx)&&(y>=my)&&(x<=MX)&&(y<=MY))
struct List NodeList; // Custom mode table
struct Node FirstNode = {0};
/* Disable CTRL-C checking */
int CXBRK(void) { return(0); }
int chkabort(void) { return(0); }
int __regargs __chkabort(void) { return(0); }
int
main(void) {
int running = 1;
struct NameInfo buff;
ULONG id = INVALID_ID;
int kount = 1;
struct Node *MyNode;
struct AmigaGuideMsg *agm;
ULONG Signals;
// Initialise Custom list and add "NONE"
NewList(&NodeList);
FirstNode.ln_Name = CustomScreen[0];
AddTail(&NodeList,&FirstNode);
// try and open amigaguide
if (AmigaGuideBase = OpenLibrary ("amigaguide.library", 34L)) {
nag.nag_BaseName = "TSMorph";
nag.nag_Name = "TSMorph.guide";
nag.nag_ClientPort = "TSMorph-prefs_HELP";
nag.nag_Context = context;
nag.nag_Flags = HTF_NOACTIVATE;
nag.nag_PubScreen = NULL;
if (handle = OpenAmigaGuideAsync(&nag, NULL)) {
ASig = AmigaGuideSignal(handle);
}
}
// Open various libraries
if (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",37)) {
if (GadToolsBase = OpenLibrary("gadtools.library",37)) {
if (DiskfontBase = OpenLibrary("diskfont.library",36)) {
if (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",37)) {
// build up list of display modes (max ~100)
id = NextDisplayInfo(id);
while ((id != INVALID_ID) && (kount < 98)) {
if (GetDisplayInfoData(NULL,(UBYTE *)&buff,sizeof(struct NameInfo),DTAG_NAME,id)) {
if ((MyNode = (struct Node *)calloc(1,sizeof(struct Node))) &&
(CustomScreen[kount] = (STRPTR)strdup(buff.Name))) {
MyNode->ln_Name = CustomScreen[kount];
AddTail(&NodeList,MyNode);
kount++;
}
}
id = NextDisplayInfo(id);
}
CustomScreen[kount] = NULL;
// open other libraries
if (UtilityBase = OpenLibrary("utility.library",37)) {
if (AslBase = OpenLibrary("asl.library",37)) {
if (IconBase = OpenLibrary("icon.library",37)) {
// get File requester and open window
if (filereq = (struct FileRequester *)AllocFileRequest()) {
if (!SetupScreen()) {
if (!OpenTSMorphPrefsWindow()) {
// Set up custom modes
GT_SetGadgetAttrs(TSMorphPrefsGadgets[GDX_CustomMode],TSMorphPrefsWnd,NULL,
GTLV_Labels,&NodeList,
TAG_END);
// Load settings from ENV:
LoadSettings("ENV:TSMorph/TSMorph.prefs");
// Loop until quit
while (running) {
Signals = Wait((ASig) |
(1L << TSMorphPrefsWnd->UserPort->mp_SigBit));
// amigaguide stuff
if (Signals & ASig) {
if (handle) {
while (agm = GetAmigaGuideMsg(handle)) {
switch (agm->agm_Type) {
case ToolCmdReplyID:
break;
case ToolStatusID:
break;
default:
break;
}
ReplyAmigaGuideMsg(agm);
}
}
}
// Normal stuff
if (Signals & (1L << TSMorphPrefsWnd->UserPort->mp_SigBit)) {
running = HandleTSMorphPrefsIDCMP();
}
// Close everything down
}
}
CloseTSMorphPrefsWindow();
}
CloseDownScreen();
FreeFileRequest(filereq);
}
CloseLibrary(IconBase);
}
CloseLibrary(AslBase);
}
CloseLibrary(UtilityBase);
}
CloseLibrary((struct Library *)GfxBase);
}
CloseLibrary(DiskfontBase);
}
CloseLibrary(GadToolsBase);
}
CloseLibrary((struct Library *)IntuitionBase);
}
if (AmigaGuideBase) {
if (handle) {
CloseAmigaGuide(handle);
}
CloseLibrary(AmigaGuideBase);
}
return 0;
}
/* Display help using amigaguide (if available)
* based on a number
*/
void
help(ULONG helpnum) {
if (handle) {
SetAmigaGuideContext(handle,helpnum,NULL);
SendAmigaGuideContext(handle,NULL);
}
}
int
CustomDepthClicked( void ) {
/* routine when gadget "Depth" is clicked. */
CustomDepth = TSMorphPrefsMsg.Code;
return 1;
}
int
DXClicked( void ) {
/* routine when gadget "DX" is clicked. */
DX = TSMorphPrefsMsg.Code;
return 1;
}
int DYClicked( void