2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
11 COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
16 * Routines for recording/playing/saving macros
43 #define MAX_NUM_EVENTS 10000
45 UI_EVENT * RecordBuffer;
47 int MacroNumEvents = 0;
50 static char filename[PATH_MAX] = "*.MIN";
54 if ( MacroStatus== UI_STATUS_NORMAL )
56 if (RecordBuffer) d_free( RecordBuffer );
57 MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
58 ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_MOUSE | UI_RECORD_KEYS );
59 MacroStatus = UI_STATUS_RECORDING;
66 if ( MacroStatus== UI_STATUS_NORMAL )
68 if (RecordBuffer) d_free( RecordBuffer );
69 MALLOC( RecordBuffer, UI_EVENT, MAX_NUM_EVENTS );
70 ui_record_events( MAX_NUM_EVENTS, RecordBuffer, UI_RECORD_KEYS );
71 MacroStatus = UI_STATUS_RECORDING;
78 if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
80 ui_set_playback_speed( 1 );
81 ui_play_events_realtime(MacroNumEvents, RecordBuffer);
82 MacroStatus = UI_STATUS_PLAYING;
89 if (MacroStatus== UI_STATUS_NORMAL && MacroNumEvents > 0 && RecordBuffer )
92 ui_play_events_fast(MacroNumEvents, RecordBuffer);
93 MacroStatus = UI_STATUS_FASTPLAY;
101 if (MacroNumEvents < 1 )
103 ui_messagebox( -2, -2, 1, "No macro has been defined to save!", "Oops" );
107 if (ui_get_filename( filename, "*.MAC", "SAVE MACRO" ))
109 PHYSFS_file *fp = PHYSFS_openWrite(filename);
112 RecordBuffer[0].type = 7;
113 RecordBuffer[0].frame = 0;
114 RecordBuffer[0].data = MacroNumEvents;
115 PHYSFS_write(fp, RecordBuffer, sizeof(UI_EVENT), MacroNumEvents);
123 if (ui_get_filename( filename, "*.MAC", "LOAD MACRO" ))
125 PHYSFS_file *fp = PHYSFS_openRead(filename);
131 d_free( RecordBuffer );
132 length = (int)PHYSFS_fileLength(fp);
133 RecordBuffer = d_malloc(length);
137 PHYSFS_read(fp, RecordBuffer, length, 1);
139 MacroNumEvents = RecordBuffer[0].data;
144 void macro_free_buffer()
147 d_free(RecordBuffer);
153 char * MenuItems[] = { "Play fast",
160 x = MenuX( -1, -1, 6, MenuItems );