1

Archive Project

This commit is contained in:
Kim Wittenburg
2017-07-25 17:04:24 +02:00
parent e715f08a85
commit 8e065f91e4
26 changed files with 506 additions and 33 deletions

88
Kara Quick View.xcodeproj/project.pbxproj Normal file → Executable file
View File

@@ -7,17 +7,50 @@
objects = {
/* Begin PBXBuildFile section */
3B05222A15DD9486004E705C /* Kara.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05222615DD9486004E705C /* Kara.tiff */; };
3B05222B15DD9486004E705C /* Mushroom.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05222715DD9486004E705C /* Mushroom.tiff */; };
3B05222C15DD9486004E705C /* Shamrock.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05222815DD9486004E705C /* Shamrock.tiff */; };
3B05222D15DD9486004E705C /* Tree.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05222915DD9486004E705C /* Tree.tiff */; };
3B05223615DDAD85004E705C /* Kara1.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05223215DDAD85004E705C /* Kara1.tiff */; };
3B05223715DDAD85004E705C /* Kara2.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05223315DDAD85004E705C /* Kara2.tiff */; };
3B05223815DDAD85004E705C /* Kara3.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05223415DDAD85004E705C /* Kara3.tiff */; };
3B05223915DDAD85004E705C /* Kara0.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 3B05223515DDAD85004E705C /* Kara0.tiff */; };
3B19AB2515DC06BF00A9737D /* QuickLook.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2415DC06BF00A9737D /* QuickLook.framework */; };
3B19AB2715DC06BF00A9737D /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */; };
3B19AB2915DC06BF00A9737D /* CoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2815DC06BF00A9737D /* CoreServices.framework */; };
3B19AB2B15DC06BF00A9737D /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB2A15DC06BF00A9737D /* CoreFoundation.framework */; };
3B19AB3115DC06BF00A9737D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 3B19AB2F15DC06BF00A9737D /* InfoPlist.strings */; };
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */; };
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */; };
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.m */; };
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.m in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.m */; };
3B19AB3715DC06BF00A9737D /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 3B19AB3615DC06BF00A9737D /* main.c */; };
3B19AB4315DC3E6500A9737D /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB4215DC3E6500A9737D /* Cocoa.framework */; };
3B19AB4915DC41DC00A9737D /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB4815DC41DC00A9737D /* AppKit.framework */; };
3B19AB4B15DC41E200A9737D /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B19AB4A15DC41E200A9737D /* Foundation.framework */; };
3B19AB5115DC493300A9737D /* Kara Quick View.qlgenerator in CopyFiles */ = {isa = PBXBuildFile; fileRef = 3B19AB2115DC06BF00A9737D /* Kara Quick View.qlgenerator */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
3B19AB4F15DC491500A9737D /* CopyFiles */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "~/Library/QuickLook";
dstSubfolderSpec = 0;
files = (
3B19AB5115DC493300A9737D /* Kara Quick View.qlgenerator in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
3B05222615DD9486004E705C /* Kara.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Kara.tiff; sourceTree = "<group>"; };
3B05222715DD9486004E705C /* Mushroom.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Mushroom.tiff; sourceTree = "<group>"; };
3B05222815DD9486004E705C /* Shamrock.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Shamrock.tiff; sourceTree = "<group>"; };
3B05222915DD9486004E705C /* Tree.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Tree.tiff; sourceTree = "<group>"; };
3B05223215DDAD85004E705C /* Kara1.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Kara1.tiff; sourceTree = "<group>"; };
3B05223315DDAD85004E705C /* Kara2.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Kara2.tiff; sourceTree = "<group>"; };
3B05223415DDAD85004E705C /* Kara3.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Kara3.tiff; sourceTree = "<group>"; };
3B05223515DDAD85004E705C /* Kara0.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Kara0.tiff; sourceTree = "<group>"; };
3B19AB2115DC06BF00A9737D /* Kara Quick View.qlgenerator */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Kara Quick View.qlgenerator"; sourceTree = BUILT_PRODUCTS_DIR; };
3B19AB2415DC06BF00A9737D /* QuickLook.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuickLook.framework; path = System/Library/Frameworks/QuickLook.framework; sourceTree = SDKROOT; };
3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
@@ -25,10 +58,14 @@
3B19AB2A15DC06BF00A9737D /* CoreFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreFoundation.framework; path = System/Library/Frameworks/CoreFoundation.framework; sourceTree = SDKROOT; };
3B19AB2E15DC06BF00A9737D /* Kara Quick View-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Kara Quick View-Info.plist"; sourceTree = "<group>"; };
3B19AB3015DC06BF00A9737D /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GenerateThumbnailForURL.c; sourceTree = "<group>"; };
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = GeneratePreviewForURL.c; sourceTree = "<group>"; };
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GenerateThumbnailForURL.m; sourceTree = "<group>"; };
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GeneratePreviewForURL.m; sourceTree = "<group>"; };
3B19AB3615DC06BF00A9737D /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
3B19AB3815DC06BF00A9737D /* Kara Quick View-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Kara Quick View-Prefix.pch"; sourceTree = "<group>"; };
3B19AB4215DC3E6500A9737D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
3B19AB4815DC41DC00A9737D /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
3B19AB4A15DC41E200A9737D /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
3BB78A0B15DE82D900DA6913 /* de */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = de; path = de.lproj/InfoPlist.strings; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -36,6 +73,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
3B19AB4B15DC41E200A9737D /* Foundation.framework in Frameworks */,
3B19AB4915DC41DC00A9737D /* AppKit.framework in Frameworks */,
3B19AB4315DC3E6500A9737D /* Cocoa.framework in Frameworks */,
3B19AB2515DC06BF00A9737D /* QuickLook.framework in Frameworks */,
3B19AB2715DC06BF00A9737D /* ApplicationServices.framework in Frameworks */,
3B19AB2915DC06BF00A9737D /* CoreServices.framework in Frameworks */,
@@ -46,6 +86,21 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
3B05222515DD9486004E705C /* Icons */ = {
isa = PBXGroup;
children = (
3B05222615DD9486004E705C /* Kara.tiff */,
3B05223215DDAD85004E705C /* Kara1.tiff */,
3B05223315DDAD85004E705C /* Kara2.tiff */,
3B05223415DDAD85004E705C /* Kara3.tiff */,
3B05223515DDAD85004E705C /* Kara0.tiff */,
3B05222715DD9486004E705C /* Mushroom.tiff */,
3B05222815DD9486004E705C /* Shamrock.tiff */,
3B05222915DD9486004E705C /* Tree.tiff */,
);
path = Icons;
sourceTree = "<group>";
};
3B19AB1415DC06BF00A9737D = {
isa = PBXGroup;
children = (
@@ -66,6 +121,9 @@
3B19AB2315DC06BF00A9737D /* Frameworks */ = {
isa = PBXGroup;
children = (
3B19AB4A15DC41E200A9737D /* Foundation.framework */,
3B19AB4815DC41DC00A9737D /* AppKit.framework */,
3B19AB4215DC3E6500A9737D /* Cocoa.framework */,
3B19AB2415DC06BF00A9737D /* QuickLook.framework */,
3B19AB2615DC06BF00A9737D /* ApplicationServices.framework */,
3B19AB2815DC06BF00A9737D /* CoreServices.framework */,
@@ -77,8 +135,9 @@
3B19AB2C15DC06BF00A9737D /* Kara Quick View */ = {
isa = PBXGroup;
children = (
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.c */,
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.c */,
3B19AB3215DC06BF00A9737D /* GenerateThumbnailForURL.m */,
3B19AB3415DC06BF00A9737D /* GeneratePreviewForURL.m */,
3B05222515DD9486004E705C /* Icons */,
3B19AB3615DC06BF00A9737D /* main.c */,
3B19AB2D15DC06BF00A9737D /* Supporting Files */,
);
@@ -117,6 +176,7 @@
3B19AB1D15DC06BF00A9737D /* Headers */,
3B19AB1E15DC06BF00A9737D /* Resources */,
3B19AB1F15DC06BF00A9737D /* Rez */,
3B19AB4F15DC491500A9737D /* CopyFiles */,
);
buildRules = (
);
@@ -158,6 +218,14 @@
buildActionMask = 2147483647;
files = (
3B19AB3115DC06BF00A9737D /* InfoPlist.strings in Resources */,
3B05222A15DD9486004E705C /* Kara.tiff in Resources */,
3B05222B15DD9486004E705C /* Mushroom.tiff in Resources */,
3B05222C15DD9486004E705C /* Shamrock.tiff in Resources */,
3B05222D15DD9486004E705C /* Tree.tiff in Resources */,
3B05223615DDAD85004E705C /* Kara1.tiff in Resources */,
3B05223715DDAD85004E705C /* Kara2.tiff in Resources */,
3B05223815DDAD85004E705C /* Kara3.tiff in Resources */,
3B05223915DDAD85004E705C /* Kara0.tiff in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -178,8 +246,8 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.c in Sources */,
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.c in Sources */,
3B19AB3315DC06BF00A9737D /* GenerateThumbnailForURL.m in Sources */,
3B19AB3515DC06BF00A9737D /* GeneratePreviewForURL.m in Sources */,
3B19AB3715DC06BF00A9737D /* main.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -191,6 +259,7 @@
isa = PBXVariantGroup;
children = (
3B19AB3015DC06BF00A9737D /* en */,
3BB78A0B15DE82D900DA6913 /* de */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
@@ -250,6 +319,7 @@
3B19AB3C15DC06BF00A9737D /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Kara Quick View/Kara Quick View-Prefix.pch";
@@ -263,6 +333,7 @@
3B19AB3D15DC06BF00A9737D /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COMBINE_HIDPI_IMAGES = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Kara Quick View/Kara Quick View-Prefix.pch";
@@ -292,6 +363,7 @@
3B19AB3D15DC06BF00A9737D /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:Kara Quick View.xcodeproj">
</FileRef>
</Workspace>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>HasAskedToTakeAutomaticSnapshotBeforeSignificantChanges</key>
<true/>
<key>SnapshotAutomaticallyBeforeSignificantChanges</key>
<false/>
</dict>
</plist>

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
</Bucket>

View File

@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0440"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3B19AB2015DC06BF00A9737D"
BuildableName = "Kara Quick View.qlgenerator"
BlueprintName = "Kara Quick View"
ReferencedContainer = "container:Kara Quick View.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
</Testables>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<PathRunnable
FilePath = "/Users/kim/Entwickler/Cocoa/Xcode/Kara Quick View/qlmanage">
</PathRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "-p test.world"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>Kara Quick View.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>3B19AB2015DC06BF00A9737D</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>

View File

@@ -1,23 +0,0 @@
#include <CoreFoundation/CoreFoundation.h>
#include <CoreServices/CoreServices.h>
#include <QuickLook/QuickLook.h>
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
/* -----------------------------------------------------------------------------
Generate a preview for file
This function's job is to create preview for designated file
----------------------------------------------------------------------------- */
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
// To complete your generator please implement the function GeneratePreviewForURL in GeneratePreviewForURL.c
return noErr;
}
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
{
// Implement only if supported
}

View File

@@ -0,0 +1,219 @@
#import <CoreFoundation/CoreFoundation.h>
#import <CoreServices/CoreServices.h>
#import <QuickLook/QuickLook.h>
#import <Cocoa/Cocoa.h>
@interface FakeClass : NSObject
@end
@implementation FakeClass
@end
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options);
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview);
struct Kara {
CGFloat x;
CGFloat y;
CGFloat direction;
};
typedef struct Kara Kara;
/* -----------------------------------------------------------------------------
Generate a preview for file
This function's job is to create preview for designated file
----------------------------------------------------------------------------- */
void HandleError(NSError *error)
{
}
NSPoint ConvertXMLElelementToPoint(NSXMLElement *element)
{
NSPoint point;
point.x = [[[element attributeForName:@"x"] stringValue] integerValue];
point.y = [[[element attributeForName:@"y"] stringValue] integerValue];
return point;
}
int fieldBorderLength = 10;
NSPoint ConvertPointToFlipped(NSPoint point, NSSize world)
{
NSPoint flippedPoint;
flippedPoint.x = point.x;
flippedPoint.y = world.height-point.y-1;
return flippedPoint;
}
void DrawBackground(NSSize world) {
NSColor *greenBackground = [NSColor colorWithCalibratedRed:180/255.0 green:230/255.0 blue:180/255.0 alpha:1];
[greenBackground set];
NSRectFill(NSMakeRect(0, 0, world.width*fieldBorderLength, world.height*fieldBorderLength));
}
void DrawField(NSSize world)
{
for (int y = 0; y<world.height; y++) {
for (int x = 0; x<world.width; x++) {
NSRect field = NSMakeRect(x*fieldBorderLength, y*fieldBorderLength, fieldBorderLength, fieldBorderLength);
[[NSColor lightGrayColor] set];
NSFrameRectWithWidth(field, 0.25);
}
}
}
void DrawKara(Kara kara, NSSize world)
{
NSString *filename = [NSString stringWithFormat:@"%@%i", @"Kara", ((int)kara.direction)];
NSString *imagePath = [[NSBundle bundleForClass:[FakeClass class]] pathForResource:filename ofType:@"tiff"];
NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath];
NSPoint flippedOrigin = ConvertPointToFlipped(NSMakePoint(kara.x, kara.y), world);
NSPoint origin = NSMakePoint(flippedOrigin.x*fieldBorderLength, flippedOrigin.y*fieldBorderLength);
NSSize size = {fieldBorderLength, fieldBorderLength};
NSRect destRect;
destRect.origin = origin;
destRect.size = size;
[image drawInRect:destRect fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:1.0];
}
void DrawObjects(NSArray *objects, NSString *imageName, NSSize world)
{
NSString *imagePath = [[NSBundle bundleForClass:[FakeClass class]] pathForResource:imageName ofType:@"tiff"];
NSImage *image = [[NSImage alloc] initWithContentsOfFile:imagePath];
NSSize imageSize = {fieldBorderLength, fieldBorderLength};
for (NSXMLElement *element in objects) {
[[NSGraphicsContext currentContext] setImageInterpolation: NSImageInterpolationHigh];
NSPoint originInWorld = ConvertXMLElelementToPoint(element);
NSPoint flippedOriginInWorld = ConvertPointToFlipped(originInWorld, world);
NSPoint origin;
origin.x = flippedOriginInWorld.x * fieldBorderLength;
origin.y = flippedOriginInWorld.y * fieldBorderLength;
NSRect destRect;
destRect.origin = origin;
destRect.size = imageSize;
[image drawInRect: destRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
}
}
OSStatus GenerateWorldPreview(QLPreviewRequestRef preview, NSXMLElement *root)
{
NSArray *children = [root children];
NSMutableArray *trees = [NSMutableArray new];
NSMutableArray *leafs = [NSMutableArray new];
NSMutableArray *mushrooms = [NSMutableArray new];
Kara kara;
BOOL karaExists = NO;
int worldWidth = [[[root attributeForName:@"sizex"] stringValue] intValue];
int worldHeight = [[[root attributeForName:@"sizey"] stringValue] intValue];
for (NSXMLNode *node in children) {
if ([node.name isEqualToString:@"XmlWallPoints"]) {
for (NSXMLNode *object in node.children) {
[trees addObject:object];
}
} else if ([node.name isEqualToString:@"XmlObstaclePoints"]) {
for (NSXMLNode *object in node.children) {
[mushrooms addObject:object];
}
} else if ([node.name isEqualToString:@"XmlPaintedfieldPoints"]) {
for (NSXMLNode *object in node.children) {
[leafs addObject:object];
}
} else if ([node.name isEqualToString:@"XmlKaraList"]) {
if (node.children.count > 0) {
NSXMLElement *karaElement = [node.children objectAtIndex:0];
kara.x = [[[karaElement attributeForName:@"x"] stringValue] integerValue];
kara.y = [[[karaElement attributeForName:@"y"] stringValue] integerValue];
kara.direction = [[[karaElement attributeForName:@"direction"] stringValue] integerValue];
karaExists = YES;
}
}
}
NSSize world = NSMakeSize(worldWidth, worldHeight);
NSSize field = NSMakeSize(worldWidth*fieldBorderLength, worldHeight*fieldBorderLength);
CGContextRef cgContext = QLPreviewRequestCreateContext(preview, *(CGSize *)&field, false, NULL);
NSGraphicsContext* context = [NSGraphicsContext graphicsContextWithGraphicsPort:(void *)cgContext flipped:YES];
if (context) {
[NSGraphicsContext setCurrentContext:context];
DrawBackground(world);
DrawField(world);
DrawObjects(trees, @"Tree", world);
DrawObjects(leafs, @"Shamrock", world);
DrawObjects(mushrooms, @"Mushroom", world);
if (karaExists) {
DrawKara(kara, world);
}
QLPreviewRequestFlushContext(preview, cgContext);
CFRelease(cgContext);
}
return noErr;
}
OSStatus GenerateProgramPreview(QLPreviewRequestRef preview, NSXMLElement *root)
{
return noErr;
}
OSStatus GeneratePreviewForURL(void *thisInterface, QLPreviewRequestRef preview, CFURLRef url, CFStringRef contentTypeUTI, CFDictionaryRef options)
{
NSXMLDocument *xmlDoc;
NSError *err=nil;
NSURL *furl = (__bridge NSURL *)url;
if (!furl) {
NSLog(@"Can't create an URL from file %@.", furl.path);
return noErr;
}
xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl options:(NSXMLNodePreserveWhitespace|NSXMLNodePreserveCDATA) error:&err];
if (xmlDoc == nil) {
xmlDoc = [[NSXMLDocument alloc] initWithContentsOfURL:furl options:NSXMLDocumentTidyXML error:&err];
}
if (xmlDoc == nil) {
if (err) {
HandleError(err);
}
return noErr;
}
if (err) {
HandleError(err);
return noErr;
}
NSXMLElement *root = xmlDoc.rootElement;
if ([furl.pathExtension compare:@"world" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
return GenerateWorldPreview(preview, root);
} else if ([furl.pathExtension compare:@"kara" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
return GenerateProgramPreview(preview, root);
}
return noErr;
}
void CancelPreviewGeneration(void *thisInterface, QLPreviewRequestRef preview)
{
// Implement only if supported
}

BIN
Kara Quick View/Icons/Kara.tiff Executable file

Binary file not shown.

BIN
Kara Quick View/Icons/Kara0.tiff Executable file

Binary file not shown.

BIN
Kara Quick View/Icons/Kara1.tiff Executable file

Binary file not shown.

BIN
Kara Quick View/Icons/Kara2.tiff Executable file

Binary file not shown.

BIN
Kara Quick View/Icons/Kara3.tiff Executable file

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
Kara Quick View/Icons/Tree.tiff Executable file

Binary file not shown.

6
Kara Quick View/Kara Quick View-Info.plist Normal file → Executable file
View File

@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<string>de_DE</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
@@ -11,7 +11,7 @@
<string>QLGenerator</string>
<key>LSItemContentTypes</key>
<array>
<string>SUPPORTED_UTI_TYPE</string>
<string>ch.karatojava.Kara-World</string>
</array>
</dict>
</array>
@@ -57,5 +57,7 @@
<false/>
<key>QLThumbnailMinimumSize</key>
<real>17</real>
<key>UTImportedTypeDeclarations</key>
<array/>
</dict>
</plist>

0
Kara Quick View/Kara Quick View-Prefix.pch Normal file → Executable file
View File

View File

@@ -0,0 +1,4 @@
/* Localized versions of Info.plist keys */
/* Kara Welt */
"Kara World" = "Kara Welt";

2
Kara Quick View/en.lproj/InfoPlist.strings Normal file → Executable file
View File

@@ -1,2 +1,4 @@
/* Localized versions of Info.plist keys */
/* Kara World */
"Kara World" = "Kara World";

0
Kara Quick View/main.c Normal file → Executable file
View File

BIN
qlmanage Executable file

Binary file not shown.

67
test.kara Executable file
View File

@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XmlStateMachines version="KaraX 1.0 kara">
<XmlStateMachine actor="Kara">
<XmlState y="67.0" x="151.0" name="Test" finalstate="false">
<XmlSensors>
<XmlSensor name="treeFront"/>
</XmlSensors>
</XmlState>
<XmlState y="165.0" x="175.0" name="r" finalstate="false">
<XmlSensors>
<XmlSensor name="treeLeft"/>
<XmlSensor name="mushroomFront"/>
</XmlSensors>
</XmlState>
<XmlState y="142.0" x="380.0" name="Stop" finalstate="true">
<XmlSensors/>
</XmlState>
<XmlTransition to="Test" from="Test">
<XmlSensorValues>
<XmlSensorValue value="1" name="treeFront"/>
</XmlSensorValues>
<XmlCommands>
<XmlCommand name="move"/>
</XmlCommands>
</XmlTransition>
<XmlTransition to="Test" from="Test">
<XmlSensorValues>
<XmlSensorValue value="0" name="treeFront"/>
</XmlSensorValues>
<XmlCommands>
<XmlCommand name="turnRight"/>
</XmlCommands>
</XmlTransition>
<XmlTransition to="Test" from="Test">
<XmlSensorValues>
<XmlSensorValue value="2" name="treeFront"/>
</XmlSensorValues>
<XmlCommands>
<XmlCommand name="turnRight"/>
</XmlCommands>
</XmlTransition>
<XmlTransition to="r" from="Test">
<XmlSensorValues>
<XmlSensorValue value="0" name="treeFront"/>
</XmlSensorValues>
<XmlCommands/>
</XmlTransition>
<XmlTransition to="Stop" from="Test">
<XmlSensorValues>
<XmlSensorValue value="0" name="treeFront"/>
</XmlSensorValues>
<XmlCommands/>
</XmlTransition>
<XmlTransition to="Stop" from="r">
<XmlSensorValues>
<XmlSensorValue value="0" name="treeLeft"/>
<XmlSensorValue value="0" name="mushroomFront"/>
</XmlSensorValues>
<XmlCommands/>
</XmlTransition>
</XmlStateMachine>
<XmlSensorDefinition name="treeFront" identifier="treeFront" description="Baum vorne?"/>
<XmlSensorDefinition name="treeLeft" identifier="treeLeft" description="Baum links?"/>
<XmlSensorDefinition name="treeRight" identifier="treeRight" description="Baum rechts?"/>
<XmlSensorDefinition name="mushroomFront" identifier="mushroomFront" description="Pilz vorne?"/>
<XmlSensorDefinition name="onLeaf" identifier="onLeaf" description="Kleeblatt unten?"/>
</XmlStateMachines>

18
test.world Executable file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<XmlWorld version="KaraX 1.0 kara" sizey="6" sizex="21">
<XmlWallPoints>
<XmlPoint y="1" x="1"/>
</XmlWallPoints>
<XmlObstaclePoints>
<XmlPoint y="0" x="0"/>
</XmlObstaclePoints>
<XmlPaintedfieldPoints>
<XmlPoint y="0" x="2" type="0"/>
<XmlPoint y="2" x="13" type="0"/>
<XmlPoint y="1" x="8" type="0"/>
</XmlPaintedfieldPoints>
<XmlKaraList>
<XmlKara y="5" x="4" name="Kara" direction="2"/>
</XmlKaraList>
<XmlStreetList/>
</XmlWorld>