2
* recordhistorywindowcontroller.m - record history
5
* Christian Vogelgsang <chris@vogelgsang.org>
7
* This file is part of VICE, the Versatile Commodore Emulator.
8
* See README for copyright notice.
10
* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
20
* You should have received a copy of the GNU General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
27
#import "recordhistorywindowcontroller.h"
28
#import "viceapplication.h"
29
#import "vicenotifications.h"
31
@implementation RecordHistoryWindowController
35
self = [super initWithWindowNibName:@"RecordHistory"];
36
[self registerForResourceUpdate:@selector(updateResources:)];
38
// register notifications
39
[[NSNotificationCenter defaultCenter] addObserver:self
40
selector:@selector(displayRecording:)
41
name:VICEDisplayRecordingNotification
44
[[NSNotificationCenter defaultCenter] addObserver:self
45
selector:@selector(displayPlayback:)
46
name:VICEDisplayPlaybackNotification
49
[[NSNotificationCenter defaultCenter] addObserver:self
50
selector:@selector(displayEventTime:)
51
name:VICEDisplayEventTimeNotification
59
[super windowDidLoad];
60
[recordingText setStringValue:@""];
61
[playbackText setStringValue:@""];
62
[timeText setStringValue:@""];
63
[self setButtonState];
66
-(void)updateResources:(NSNotification *)notification
68
NSString *workDir = [self getStringResource:@"EventSnapshotDir"];
69
[workDirText setStringValue:workDir];
71
int startMode = [self getIntResource:@"EventStartMode"];
72
[startRecordPopup selectItemWithTag:startMode];
75
// ----- Notifications -----
77
-(void)displayPlayback:(NSNotification *)notification
79
NSDictionary * dict = [notification userInfo];
80
BOOL playback = [[dict objectForKey:@"playback"] boolValue];
81
NSString *version = (NSString *)[dict objectForKey:@"version"];
83
[playbackText setStringValue:[NSString stringWithFormat:@"Playback: %@",version]];
85
[playbackText setStringValue:@""];
86
[self setButtonState];
90
-(void)displayRecording:(NSNotification *)notification
92
NSDictionary * dict = [notification userInfo];
93
BOOL recording = [[dict objectForKey:@"recording"] boolValue];
94
[recordingText setStringValue:(recording ? @"Recording" : @"")];
96
[self setButtonState];
99
-(void)displayEventTime:(NSNotification *)notification
101
NSDictionary * dict = [notification userInfo];
102
int curTime = [[dict objectForKey:@"time"] intValue];
103
int totalTime = [[dict objectForKey:@"totalTime"] intValue];
105
int curMin = curTime / 60;
106
int curSec = curTime % 60;
109
int totalMin = totalTime / 60;
110
int totalSec = totalTime % 60;
111
txt = [NSString stringWithFormat:@"Time %02d:%02d Total Time %02d:%02d",
112
curMin,curSec,totalMin,totalSec];
114
txt = [NSString stringWithFormat:@"Time %02d:%02d",
117
[timeText setStringValue:txt];
120
// ----- Actions -----
122
-(void)setButtonState
124
VICEMachineController *ctrl = [VICEApplication theMachineController];
125
BOOL isRecording = [ctrl isRecordingHistory];
126
BOOL isPlayingBack = [ctrl isPlayingBackHistory];
127
BOOL isBusy = isRecording || isPlayingBack;
129
[recordButton setEnabled:!isBusy];
130
[playButton setEnabled:!isBusy];
131
[stopButton setEnabled:isBusy];
133
[setMilestoneButton setEnabled:isRecording];
134
[resetMilestoneButton setEnabled:isRecording];
136
[workDirText setEnabled:!isBusy];
137
[workDirButton setEnabled:!isBusy];
138
[startRecordPopup setEnabled:!isBusy];
141
-(IBAction)startRecord:(id)sender
143
[[VICEApplication theMachineController] startRecordHistory];
144
[self setButtonState];
147
-(IBAction)startPlayback:(id)sender
149
[[VICEApplication theMachineController] startPlaybackHistory];
150
[self setButtonState];
153
-(IBAction)stopRecordOrPlayback:(id)sender
155
VICEMachineController *ctrl = [VICEApplication theMachineController];
156
if([ctrl isRecordingHistory]) {
157
[ctrl stopRecordHistory];
158
} else if([ctrl isPlayingBackHistory]) {
159
[ctrl stopPlaybackHistory];
161
[self setButtonState];
164
-(IBAction)setMilestone:(id)sender
166
[[VICEApplication theMachineController] setRecordMilestone];
169
-(IBAction)resetMilestone:(id)sender
171
[[VICEApplication theMachineController] resetRecordMilestone];
174
-(IBAction)enterWorkDir:(id)sender
176
[self setStringResource:@"EventSnapshotDir" toValue:[sender stringValue]];
177
[self updateResources:nil];
180
-(IBAction)pickWorkDir:(id)sender
182
VICEAppController *appCtrl = [VICEApplication theAppController];
183
NSString *path = [appCtrl pickDirectoryWithTitle:@"Record History"];
185
[self setStringResource:@"EventSnapshotDir" toValue:path];
186
[self updateResources:nil];
190
-(IBAction)pickStartRecord:(id)sender
192
int mode = [[sender selectedItem] tag];
193
[self setIntResource:@"EventStartMode" toValue:mode];
194
[self updateResources:nil];