home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 8
/
FreshFishVol8-CD1.bin
/
new
/
game
/
think
/
chaos
/
src
/
projectami.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-19
|
13KB
|
495 lines
/* Chaos: The Chess HAppening Organisation System V5.3
Copyright (C) 1993 Jochen Wiedmann
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
(at your option) 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.
$RCSfile: ProjectAmi.c,v $
$Revision: 3.4 $
$Date: 1994/11/19 19:32:01 $
This file contains the system dependent functions that support the
Project menu.
Computer: Amiga 1200 Compiler: Dice 2.07.54 (3.0)
Author: Jochen Wiedmann
Am Eisteich 9
72555 Metzingen
Tel. 07123 / 14881
Internet: wiedmann@mailserv.zdv.uni-tuebingen.de
*/
#ifndef CHAOS_H
#include "chaos.h"
#endif
#ifdef AMIGA
#ifndef LIBRARIES_ASL_H
#include <libraries/asl.h>
#endif
#ifndef LIBRARIES_GADTOOLS_H
#include <libraries/gadtools.h>
#endif
#ifndef DOS_DOS_H
#include <libraries/dos.h>
#endif
#ifndef CLIB_ASL_PROTOS_H
#include <clib/asl_protos.h>
#endif
#ifndef CLIB_ICON_PROTOS_H
#include <clib/icon_protos.h>
#endif
#ifdef AZTEC_C
#ifndef PRAGMAS_ASL_LIB_H
#include <pragmas/asl_lib.h>
#endif
#ifndef PRAGMAS_ICON_LIB_H
#include <pragmas/icon_lib.h>
#endif
#define strrchr rindex
#endif /* AZTEC_C */
#if defined(_DCC) || defined(__SASC) || defined(__MAXON__)
#ifndef PRAGMAS_ASL_PRAGMAS_H
#include <pragmas/asl_pragmas.h>
#endif
#ifndef PRAGMAS_ICON_PRAGMAS_H
#include <pragmas/icon_pragmas.h>
#endif
#endif /* _DCC || __SASC || __MAXON__ */
#ifdef __GNUC__
#ifndef _INLINE_ASL_H
#include <inline/asl.h>
#endif
#ifndef _INLINE_ICON_H
#include <inline/icon.h>
#endif
#endif /* __GNUC__ */
#endif /* AMIGA */
/*
FileRequest() creates a file requester which reads a file name.
Inputs: defaultfile a pointer to a string containing the default name
title a pointer to a string containing the requester's
title. This may be NULL, in which case
MSG_CDAT_SELECTION is assumed.
ending a pointer to a string containing the default ending.
This may be NULL, in which case "#?.cdat" is assumed.
Note, that this MUST be something like "#?.xxx" on
the Amiga!
savemode TRUE, if non-existing files may be selected.
Result: Full path name of the file, that was selected or NULL, if the
user cancelled.
*/
char *FileRequest(char *defaultfile, char *title, char *ending, int savemode)
#ifdef AMIGA
{ struct FileRequester *requester;
char pattern[20];
char *result = NULL;
char *filename, *pathname, *endptr;
BPTR dir;
static char FileRequestName[TRNFILENAME_LEN+1];
static char PathName[TRNFILENAME_LEN+1];
struct Window *window;
/*
Bring up default settings, if needed.
*/
if (title == NULL)
{ title = (char *) GetChaosString(MSG_CDAT_SELECTION);
}
if (ending == NULL)
{ ending = "#?.cdat";
}
/*
Get Intuition window pointer from MUI window, allocate Filerequester
and parse the ending for wildcards.
*/
get(MainWnd, MUIA_Window_Window, &window);
if ((requester = (struct FileRequester *)
MUI_AllocAslRequest(ASL_FileRequest, NULL)) == NULL)
{ MemError();
return(NULL);
}
ParsePatternNoCase((UBYTE *) ending, (UBYTE *) pattern, sizeof(pattern));
/*
Get default file- and drawername.
*/
if (defaultfile && *defaultfile != '\0')
{ strcpy(FileRequestName, defaultfile);
}
else
{ if (TrnFileName != '\0')
{ strcpy(FileRequestName, TrnFileName);
}
else
{ sprintf(FileRequestName, savemode ? "chaos.%d.cdat" : "", NumRounds);
}
}
filename = (char *) FilePart((STRPTR) FileRequestName);
strcpy(PathName, FileRequestName);
*(pathname = (char *) PathPart((STRPTR) PathName)) = '\0';
/*
Make the drawername absolute.
*/
dir = Lock((STRPTR) PathName, SHARED_LOCK);
NameFromLock(dir, (STRPTR) PathName, sizeof(PathName));
UnLock(dir);
/*
Ensure, that the default filename has the right ending.
*/
if (ending != NULL && (endptr = strrchr(filename, '.')) != NULL)
{ strcpy(endptr, ending+2);
}
/*
Bring up the requester
*/
#ifdef V39_INCLUDES
if (MUI_AslRequestTags(requester,
ASLFR_Window, window,
ASLFR_PrivateIDCMP, TRUE,
ASLFR_SleepWindow, TRUE,
ASLFR_TitleText, title,
ASLFR_InitialFile, filename,
ASLFR_InitialDrawer, PathName,
ASLFR_InitialPattern, ending,
ASLFR_DoSaveMode, savemode,
ASLFR_RejectIcons, TRUE,
ASLFR_AcceptPattern, pattern,
TAG_DONE) != FALSE &&
requester->fr_File != NULL && requester->fr_File != '\0')
{ strcpy(FileRequestName, (char *) requester->fr_Drawer);
AddPart((STRPTR) FileRequestName, requester->fr_File,
sizeof(FileRequestName));
result = FileRequestName;
}
#else
if (MUI_AslRequestTags(requester,
ASL_Window, window,
ASL_Hail, title
ASL_File, filename,
ASL_Dir, PathName,
TAG_DONE) == FALSE &&
requester->rf_File != NULL && requester->rf_File != '\0')
{ strcpy(FileRequestName, (char *) requester->rf_Dir);
AddPart((STRPTR) FileRequestName, (STRPTR) requester->rf_File,
sizeof(FileRequestName));
result = FileRequestName;
}
#endif
MUI_FreeAslRequest((APTR) requester);
return (result);
}
#endif /* AMIGA */
/*
CreateIcon() puts an icon to a recently saved file.
Inputs: name of the file just created; must not be NULL
*/
void CreateIcon(char *name)
#ifdef AMIGA
{ extern int MakeIcons;
/*
Does the user want to have an icon?
*/
if (MakeIcons)
{ /*
Yes, get a diskobject
*/
struct DiskObject *dobj;
char *olddeftool;
int len = strlen(IconName);
/*
Icon.library doesn't like a trailing ".info" when calling
GetDiskObject().
*/
if (len >= 5 &&
Stricmp((STRPTR) IconName+len-5, (STRPTR) ".info") == 0)
{ IconName[len-5] = '\0';
}
if ((dobj = GetDiskObject((STRPTR) IconName)) != NULL ||
(dobj = GetDiskObject((STRPTR) "s:Chaos_Project")) != NULL ||
(dobj = GetDefDiskObject(WBPROJECT)) != NULL)
{ /*
Put the right settings into the diskobject and save it.
*/
dobj->do_Type = WBPROJECT;
olddeftool = dobj->do_DefaultTool;
dobj->do_DefaultTool = ProgName;
dobj->do_CurrentX = dobj->do_CurrentY = NO_ICON_POSITION;
if (dobj->do_StackSize < 20000)
{ dobj->do_StackSize = 20000;
}
PutDiskObject((STRPTR) name, dobj);
dobj->do_DefaultTool = olddeftool;
FreeDiskObject(dobj);
}
}
}
#else /* !AMIGA */
{ /*
There is nothing to be done on other systems.
*/
}
#endif /* !AMIGA */
/*
AskSave brings up a requester asking the user, if he wants to save
first.
*/
int AskSave(void)
#ifdef AMIGA
{
switch (MUI_RequestA(App, MainWnd, 0,
(char *) GetChaosString(MSG_ATTENTION),
(char *) GetChaosString(MSG_YES_NO_CANCEL),
(char *) GetChaosString(MSG_CHANGES_MADE), NULL))
{ case 2:
return(TRUE);
case 1:
return(SaveTournament(NULL));
}
return(FALSE);
}
#endif /* AMIGA */
/*
The TerminateTrnWnd() function closes the tournament input window.
*/
#ifdef AMIGA
static APTR TrnWnd = NULL; /* Tournament window */
static APTR TrnOkGad; /* Ok gadget (tournament window) */
static APTR TrnCancelGad; /* Cancel gadget (tournament window) */
static APTR TrnNameGad; /* Tournament name gadget */
static APTR WinnerPointsGad; /* Winner points gadget */
static APTR DrawPointsGad; /* Draw points gadget */
void TerminateTrnWnd(void)
{ if (TrnWnd)
{ set(TrnWnd, MUIA_Window_Open, FALSE);
DoMethod(App, OM_REMMEMBER, TrnWnd);
MUI_DisposeObject(TrnWnd);
TrnWnd = NULL;
}
}
#endif /* AMIGA */
/*
The