Permalink
Browse files

Add rudimentary movie exporting

  • Loading branch information...
1 parent 7575d9f commit 927de21385832f2eee38b9ebe8923664be78bd4f @qwzybug committed Sep 15, 2008
View
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">352.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="3"/>
+ <integer value="50"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -48,36 +48,78 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSMutableArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <string>0393A3E8-17F6-4FB4-B0D0-66AAD66DAB01</string>
<string>0CCD776B-ED18-439C-B371-0D6F7A6A1A96</string>
<string>3E71148B-C999-422E-B009-B1D61DB14E22</string>
<string>D2A6BE3F-C3C2-4436-9DE3-9833E8551CC8</string>
<string>NSToolbarFlexibleSpaceItem</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSToolbarItem" id="1058431446">
+ <object class="NSMutableString" key="NSToolbarItemIdentifier">
+ <characters key="NS.bytes">0393A3E8-17F6-4FB4-B0D0-66AAD66DAB01</characters>
+ </object>
+ <string key="NSToolbarItemLabel">Record</string>
+ <string key="NSToolbarItemPaletteLabel">Record</string>
+ <nil key="NSToolbarItemToolTip"/>
+ <object class="NSButton" key="NSToolbarItemView" id="519692533">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{10, 14}, {25, 25}}</string>
+ <reference key="NSSuperview"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="506645712">
+ <int key="NSCellFlags">67239424</int>
+ <int key="NSCellFlags2">134217728</int>
+ <string key="NSContents">Round Textured</string>
+ <object class="NSFont" key="NSSupport" id="960872248">
+ <string key="NSName">LucidaGrande</string>
+ <double key="NSSize">1.300000e+01</double>
+ <int key="NSfFlags">1044</int>
+ </object>
+ <reference key="NSControlView" ref="519692533"/>
+ <int key="NSButtonFlags">-1228652289</int>
+ <int key="NSButtonFlags2">163</int>
+ <object class="NSCustomResource" key="NSNormalImage" id="38535845">
+ <string key="NSClassName">NSImage</string>
+ <string key="NSResourceName">record_small</string>
+ </object>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">400</int>
+ <int key="NSPeriodicInterval">75</int>
+ </object>
+ </object>
+ <reference key="NSToolbarItemImage" ref="38535845"/>
+ <nil key="NSToolbarItemTarget"/>
+ <nil key="NSToolbarItemAction"/>
+ <string key="NSToolbarItemMinSize">{25, 25}</string>
+ <string key="NSToolbarItemMaxSize">{25, 25}</string>
+ <bool key="NSToolbarItemEnabled">YES</bool>
+ <bool key="NSToolbarItemAutovalidates">YES</bool>
+ <int key="NSToolbarItemTag">0</int>
+ <bool key="NSToolbarIsUserRemovable">YES</bool>
+ <int key="NSToolbarItemVisibilityPriority">0</int>
+ </object>
<object class="NSToolbarItem" id="555220856">
<object class="NSMutableString" key="NSToolbarItemIdentifier">
<characters key="NS.bytes">0CCD776B-ED18-439C-B371-0D6F7A6A1A96</characters>
</object>
- <string key="NSToolbarItemLabel">Custom View</string>
+ <string key="NSToolbarItemLabel">Run</string>
<string key="NSToolbarItemPaletteLabel">Run</string>
<nil key="NSToolbarItemToolTip"/>
<object class="NSButton" key="NSToolbarItemView" id="290405164">
<reference key="NSNextResponder"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{0, 14}, {49, 25}}</string>
<reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="487984375">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string type="base64-UTF8" key="NSContents">4pa2IEdvA</string>
- <object class="NSFont" key="NSSupport">
- <string key="NSName">LucidaGrande</string>
- <double key="NSSize">1.300000e+01</double>
- <int key="NSfFlags">1044</int>
- </object>
+ <reference key="NSSupport" ref="960872248"/>
<reference key="NSControlView" ref="290405164"/>
<int key="NSButtonFlags">-1232977665</int>
<int key="NSButtonFlags2">163</int>
@@ -110,7 +152,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{6, 14}, {19, 19}}</string>
<reference key="NSSuperview"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="907117630">
<int key="NSCellFlags">67239424</int>
@@ -204,9 +245,11 @@
<reference ref="719331101"/>
<reference ref="993495022"/>
<reference ref="4439273"/>
+ <reference ref="1058431446"/>
</object>
<object class="NSMutableArray" key="NSToolbarIBDefaultItems">
<bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="1058431446"/>
<reference ref="555220856"/>
<reference ref="719331101"/>
<reference ref="993495022"/>
@@ -325,6 +368,22 @@
</object>
<int key="connectionID">47</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: recording</string>
+ <reference key="source" ref="519692533"/>
+ <reference key="destination" ref="1001"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="519692533"/>
+ <reference key="NSDestination" ref="1001"/>
+ <string key="NSLabel">value: recording</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">recording</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">53</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -375,6 +434,7 @@
<reference ref="719331101"/>
<reference ref="555220856"/>
<reference ref="4439273"/>
+ <reference ref="1058431446"/>
</object>
<reference key="parent" ref="923943861"/>
</object>
@@ -467,6 +527,29 @@
<reference key="object" ref="4439273"/>
<reference key="parent" ref="508263219"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">50</int>
+ <reference key="object" ref="1058431446"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="519692533"/>
+ </object>
+ <reference key="parent" ref="508263219"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">48</int>
+ <reference key="object" ref="519692533"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="506645712"/>
+ </object>
+ <reference key="parent" ref="1058431446"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">49</int>
+ <reference key="object" ref="506645712"/>
+ <reference key="parent" ref="519692533"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -494,6 +577,8 @@
<string>4.IBEditorWindowLastContentRect</string>
<string>4.IBPluginDependency</string>
<string>46.IBPluginDependency</string>
+ <string>48.IBPluginDependency</string>
+ <string>49.IBPluginDependency</string>
<string>5.IBPluginDependency</string>
<string>7.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
@@ -518,7 +603,9 @@
<string>{{213, 497}, {300, 300}}</string>
<integer value="1"/>
<string>{3.40282e+38, 3.40282e+38}</string>
- <string>{{55, 797}, {616, 0}}</string>
+ <string>{{55, 628}, {616, 169}}</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -546,7 +633,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">47</int>
+ <int key="maxID">53</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -10,22 +10,27 @@
#import "ALifeController.h"
-@class StatisticsController, ALifeSimulationController;
+@class StatisticsController, ALifeSimulationController, DMQuicktimeExporter;
@interface ALifeWindowController : NSWindowController {
IBOutlet StatisticsController *statisticsController;
ALifeSimulationController *simulationController;
+ DMQuicktimeExporter *movieExporter;
BOOL running;
+ BOOL recording;
}
@property(readwrite, assign) BOOL running;
+@property(readwrite, assign) BOOL recording;
@property(readwrite, retain) ALifeSimulationController *simulationController;
+@property(readwrite, retain) DMQuicktimeExporter *movieExporter;
+ (id)windowControllerForModel:(Class <ALifeController>)lifeController withConfiguration:(NSDictionary *)configuration;
- (id)initWithSimulationClass:(Class <ALifeController>)modelClass configuration:(NSDictionary *)configuration;
- (IBAction)tick:(id)sender;
- (void)stepSimulation;
+- (IBAction)exportMovie:(id)sender;
@end
@@ -10,10 +10,11 @@
#import "StatisticsController.h"
#import "ALifeSimulationController.h"
+#import "DMQuicktimeExporter.h"
@implementation ALifeWindowController
-@synthesize simulationController, running;
+@synthesize simulationController, running, recording, movieExporter;
+ (id)windowControllerForModel:(Class <ALifeController>)lifeController withConfiguration:(NSDictionary *)configuration;
{
@@ -66,6 +67,9 @@ - (IBAction)tick:(id)sender;
- (void)stepSimulation;
{
[simulationController.lifeController update];
+ if (recording) {
+ [self.movieExporter addFrameFromView:[self.window contentView]];
+ }
if (running) {
[self performSelector:@selector(stepSimulation) withObject:nil afterDelay:0.02];
}
@@ -82,4 +86,35 @@ - (void)windowWillClose:(NSNotification *)notification;
[self autorelease];
}
+- (void)setRecording:(BOOL)isRecording;
+{
+ if (isRecording) {
+ self.movieExporter = [DMQuicktimeExporter movieExporter];
+ recording = YES;
+ if (!running) {
+ self.running = YES;
+ [self tick:self];
+ }
+ } else {
+ self.running = NO;
+ [self exportMovie:self];
+ }
+}
+
+- (IBAction)exportMovie:(id)sender;
+{
+ NSSavePanel *panel = [NSSavePanel savePanel];
+ [panel setAllowedFileTypes:[NSArray arrayWithObject:@"mov"]];
+ [panel beginSheetForDirectory:nil file:nil modalForWindow:self.window modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil];
+}
+
+- (void)savePanelDidEnd:(NSSavePanel *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo;
+{
+ if (returnCode == NSOKButton)
+ [self.movieExporter exportMovie:[sheet filename]];
+
+ self.movieExporter = nil;
+}
+
+
@end
Oops, something went wrong.

0 comments on commit 927de21

Please sign in to comment.