summaryrefslogtreecommitdiff
path: root/app/bin/macro.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/bin/macro.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/bin/macro.c')
-rw-r--r--app/bin/macro.c123
1 files changed, 30 insertions, 93 deletions
diff --git a/app/bin/macro.c b/app/bin/macro.c
index 2147eff..1c711ce 100644
--- a/app/bin/macro.c
+++ b/app/bin/macro.c
@@ -20,6 +20,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#ifndef WINDOWS
@@ -47,14 +48,20 @@
#include <stdint.h>
-#include "track.h"
-#include "version.h"
#include "common.h"
-#include "utility.h"
-#include "draw.h"
-#include "misc.h"
#include "compound.h"
+#include "cundo.h"
+#include "custom.h"
+#include "draw.h"
+#include "fileio.h"
#include "i18n.h"
+#include "messages.h"
+#include "misc.h"
+#include "param.h"
+#include "paths.h"
+#include "track.h"
+#include "utility.h"
+#include "version.h"
EXPORT long adjTimer;
static void DemoInitValues( void );
@@ -268,7 +275,7 @@ EXPORT void DoRecord( void * context )
recordFile_fs = wFilSelCreate( mainW, FS_SAVE, 0, title, sRecordFilePattern, StartRecord, NULL );
}
wTextClear( recordT );
- wFilSelect( recordFile_fs, curDirName );
+ wFilSelect( recordFile_fs, GetCurrentPath(MACROPATHKEY ));
}
/*****************************************************************************
@@ -716,11 +723,7 @@ EXPORT void TakeSnapshot( drawCmd_t * d )
wBitMapDelete( d->d );
documentSnapshotNum++;
if (documentCopy && documentFile) {
- cp = strrchr( message, FILE_SEP_CHAR[0] );
- if (cp == 0)
- cp = message;
- else
- cp++;
+ cp = FindFilename(message);
cp[strlen(cp)-4] = 0;
fprintf( documentFile, "\n?G%s\n", cp );
}
@@ -802,6 +805,7 @@ static void Playback( void )
static wBool_t demoWinOnTop = FALSE;
coOrd roomSize;
char * cp, * cq;
+ char *demoFileName = NULL;
useCurrentLayer = FALSE;
inPlayback = TRUE;
@@ -829,13 +833,13 @@ static void Playback( void )
Reset();
if (curDemo < 0 || curDemo >= demoList_da.cnt)
break;
- strcpy( paramFileName, demoList(curDemo).fileName );
- paramFile = fopen( paramFileName, "r" );
+ demoFileName = strdup(demoList(curDemo).fileName );
+ paramFile = fopen( demoFileName, "r" );
if ( paramFile == NULL ) {
- NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Demo"), paramFileName, strerror(errno) );
+ NoticeMessage( MSG_OPEN_FAIL, _("Continue"), NULL, _("Demo"), demoFileName, strerror(errno) );
return;
}
-
+
playbackColor=wDrawColorBlack;
paramLineNum = 0;
wWinSetTitle( demoW, demoList( curDemo ).title );
@@ -848,11 +852,13 @@ static void Playback( void )
DoChangeNotification( CHANGE_ALL );
CompoundClearDemoDefns();
if ( fgets(paramLine, STR_LONG_SIZE, paramFile) == NULL ) {
- NoticeMessage( MSG_CANT_READ_DEMO, _("Continue"), NULL, sProdName, paramFileName );
+ NoticeMessage( MSG_CANT_READ_DEMO, _("Continue"), NULL, sProdName, demoFileName );
fclose( paramFile );
paramFile = NULL;
return;
}
+ free(demoFileName);
+ demoFileName = NULL;
}
if (paramLineNum == 0) {
documentSnapshotNum = 1;
@@ -950,38 +956,15 @@ static void Playback( void )
tempD.orig = mainD.orig;
tempD.size = mainD.size;
tempD.scale = mainD.scale;
-#ifdef LATER
- ResolveIndex();
- RecomputeElevations();
-#endif
+
DoRedraw();
if (playbackD != NULL && playbackBm != NULL)
MacroDrawBitMap( playbackD, playbackBm, playbackX, playbackY, wDrawColorBlack );
-#ifdef LATER
- } else if (strncmp( paramLine, "POSITION ", 9 ) == 0) {
- if ( !GetArgs( paramLine+9, "ff", &x, &y ) )
- continue;
- MovePlaybackCursor( &mainD, x, y );
-#endif
+
} else if (strncmp( paramLine, "PAUSE ", 6 ) == 0) {
paramTogglePlaybackHilite = TRUE;
didPause = TRUE;
-#ifdef DOPAUSE
- if (lastCmd == mouseCmd) {
- thisCmd = pauseCmd;
- } else {
- if ( !GetArgs( paramLine+6, "l", &timeout ) )
- continue;
-#ifdef LATER
- wFlush();
- wAlarm( timeout*playbackDelay/100, playback );
- return;
-#else
- if (playbackTimer == 0)
- wPause( timeout*playbackDelay/100 );
-#endif
- }
-#endif
+
if ( !GetArgs( paramLine+6, "l", &timeout ) )
continue;
if (timeout > 10000)
@@ -996,18 +979,13 @@ static void Playback( void )
} else if (strncmp( paramLine, "BIGPAUSE ", 6 ) == 0) {
paramTogglePlaybackHilite = TRUE;
didPause = FALSE;
-#ifdef LATER
- wFlush();
- wAlarm( bigPause*playbackDelay/100, playback );
- return;
-#else
+
if (playbackTimer == 0) {
timeout = bigPause*playbackDelay/100;
if (timeout <= dragTimeout)
timeout = dragTimeout+1;
wPause( timeout );
}
-#endif
} else if (strncmp( paramLine, "KEYSTATE ", 9 ) == 0 ) {
playbackKeyState = atoi( paramLine+9 );
} else if (strncmp( paramLine, "TIMESTART", 9 ) == 0 ) {
@@ -1059,49 +1037,9 @@ static void Playback( void )
DemoInitValues();
} else {
if (strncmp( paramLine, "MOUSE ", 6 ) == 0) {
-#ifdef LATER
- if ( GetArgs( paramLine+6, "dff", &rc, &pos.x, &pos.y) ) {
- pos.x = pos.x / mainD.scale - mainD.orig.x;
- pos.y = pos.y / mainD.scale - mainD.orig.y;
-#ifdef DOPAUSE
- if (lastCmd == pauseCmd) {
-#endif
- d = sqrt( (pos.x-mainPos.x)*(pos.x-mainPos.x) +
- (pos.y-mainPos.y)*(pos.y-mainPos.y) );
- d *= mainD.dpi;
- timeout = (long)(MSEC_PER_PIXEL * d);
- if (timeout > 2)
- if (playbackTimer == 0)
- wPause( timeout );
-#ifdef DOPAUSE
- }
-#endif
- mainPos = pos;
- }
-#endif
thisCmd = mouseCmd;
}
if (strncmp( paramLine, "MAP ", 6 ) == 0) {
-#ifdef LATER
- if ( GetArgs( paramLine+6, "dff", &rc, &pos.x, &pos.y ) ) {
- pos.x = pos.x / mapD.scale - mapD.orig.x;
- pos.y = pos.y / mapD.scale - mapD.orig.y;
-#ifdef DOPAUSE
- if (lastCmd == pauseCmd) {
-#endif
- d = sqrt( (pos.x-mapPos.y)*(pos.x-mapPos.x) +
- (pos.y-mapPos.y)*(pos.y-mapPos.y) );
- d *= mapD.dpi;
- timeout = (long)(MSEC_PER_PIXEL * d);
- if (timeout > 2)
- if (playbackTimer == 0)
- wPause( timeout );
-#ifdef DOPAUSE
- }
-#endif
- mapPos = pos;
- }
-#endif
thisCmd = mouseCmd;
}
for ( inx=0; inx<playbackProc_da.cnt; inx++ ) {
@@ -1241,7 +1179,7 @@ EXPORT void DoPlayBack( void * context )
if (demoW == NULL)
CreateDemoW();
wButtonSetLabel( demoNext, _("Save") );
- wFilSelect( playbackFile_fs, curDirName );
+ wFilSelect( playbackFile_fs, GetCurrentPath(MACROPATHKEY));
}
@@ -1380,6 +1318,7 @@ static BOOL_T ReadDemo(
static wMenu_p m;
char * cp;
char *oldLocale = NULL;
+ char *path;
if ( m == NULL )
m = demoM;
@@ -1405,10 +1344,8 @@ static BOOL_T ReadDemo(
if (userLocale)
oldLocale = SaveLocale(userLocale);
demoList( demoList_da.cnt-1 ).title = MyStrdup( _(line+6) );
- demoList( demoList_da.cnt-1 ).fileName =
- (char*)MyMalloc( strlen(libDir) + 1 + 5 + 1 + strlen(cp) + 1 );
- sprintf( demoList( demoList_da.cnt-1 ).fileName, "%s%s%s%s%s",
- libDir, FILE_SEP_CHAR, "demos", FILE_SEP_CHAR, cp );
+ MakeFullpath(&path, libDir, "demos", cp, NULL);
+ demoList(demoList_da.cnt - 1).fileName = path;
wMenuPushCreate( m, NULL, _(line+6), 0, DoDemo, (void*)(intptr_t)(demoList_da.cnt-1) );
if (oldLocale)
RestoreLocale(oldLocale);