]> Dogcows Code - chaz/thecheat/blob - cheat_global.m
update contact information and project URL
[chaz/thecheat] / cheat_global.m
1
2 /*
3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
5 *
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
7 *
8 * Distributable under the terms and conditions of the 2-clause BSD
9 * license; see the file COPYING for the legal text of the license.
10 */
11
12 #import "cheat_global.h"
13
14 #import <Carbon/Carbon.h>
15
16
17 // globals
18 float gFadeAnimationDuration = TCDefaultFadeAnimation;
19
20
21 // user default constants
22 NSString *TCFirstLaunchPref = nil;
23 NSString *TCWindowsOnTopPref = @"TCWindowsOnTopPref";
24 NSString *TCUpdateCheckPref = @"TCUpdateCheckPref";
25 NSString *TCDisplayValuesPref = @"TCDisplayValuesPref";
26 NSString *TCValueUpdatePref = @"TCValueUpdatePref";
27 NSString *TCHitsDisplayedPref = @"TCHitsDisplayedPref";
28 NSString *TCRunServerPref = @"TCRunServerPref";
29 NSString *TCBroadcastNamePref = @"TCBroadcastNamePref";
30 NSString *TCListenPortPref = @"TCListenPortPref";
31 NSString *TCFadeAnimationPref = @"TCFadeAnimationPref";
32 NSString *TCAskForSavePref = @"TCAskForSavePref";
33 NSString *TCSwitchVariablesPref = @"TCSwitchVariablesPref";
34 NSString *TCAutoStartEditingVarsPref = @"TCAutoStartEditingVarsPref";
35
36
37 // notification constants
38 NSString *TCServiceFoundNote = @"TCServiceFoundNote";
39 NSString *TCServiceRemovedNote = @"TCServiceRemovedNote";
40 NSString *TCServerStartedNote = @"TCServerStartedNote";
41 NSString *TCServerStoppedNote = @"TCServerStoppedNote";
42 NSString *TCServerConnectionsChangedNote = @"TCServerConnectionsChangedNote";
43 NSString *TCWindowsOnTopChangedNote = @"TCWindowsOnTopChangedNote";
44 NSString *TCDisplayValuesChangedNote = @"TCDisplayValuesChangedNote";
45 NSString *TCHitsDisplayedChangedNote = @"TCHitsDisplayedChangedNote";
46
47
48 void LaunchWebsite()
49 {
50 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/"]];
51 }
52
53 void LaunchEmail()
54 {
55 //[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"mailto:chaz@brokenzipper.com?subject=The%20Cheat%20Feedback"]];
56 /* Ed Palma will act as a contact person for The Cheat. */
57 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/contact.html"]];
58 }
59
60
61 int MacOSXVersion()
62 {
63 SInt32 static version = -1;
64
65 if ( version != -1 ) {
66 return (int)version;
67 }
68
69 // get the version
70 if ( Gestalt( gestaltSystemVersion, &version ) != noErr ) {
71 return -1;
72 }
73 return (int)version;
74 }
75
76 NSString *ApplicationVersion( NSString *appPath )
77 {
78 NSString *tVersion = nil;
79 NSBundle *tBundle = [NSBundle bundleWithPath:appPath];
80
81 if ( tBundle ) {
82 NSDictionary *tInfoDictionary;
83
84 tInfoDictionary = [tBundle infoDictionary];
85
86 if ( tInfoDictionary ) {
87 tVersion = [tInfoDictionary objectForKey:@"CFBundleShortVersionString"];
88 if ( !tVersion ) {
89 tVersion = [tInfoDictionary objectForKey:@"CFBundleVersion"];
90 }
91 }
92 }
93 else {
94 CFBundleRef tBundleRef;
95 short resNum = 0;
96
97 tBundleRef = CFBundleCreate( NULL, (CFURLRef)[NSURL fileURLWithPath:appPath] );
98
99 if ( tBundleRef ) {
100 resNum = CFBundleOpenBundleResourceMap( tBundleRef );
101 }
102
103 if ( resNum != 0 ) {
104 VersRecHndl tVersionHandle;
105 unsigned long tNumVersion;
106
107 tVersionHandle = (VersRecHndl)Get1IndResource( 'vers', 1 );
108
109 if ( tVersionHandle ) {
110 tNumVersion = *((unsigned long *) &((*tVersionHandle)->numericVersion));
111
112 if ( (tNumVersion & 0x00040000) != 0 ) {
113 tVersion = [NSString stringWithFormat:@"%d.%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20, (tNumVersion & 0x000F0000)>>16];
114 }
115 else {
116 tVersion = [NSString stringWithFormat:@"%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20];
117 }
118 }
119
120 }
121 if ( tBundleRef ) {
122 CFBundleCloseBundleResourceMap( tBundleRef, resNum );
123 // Release Memory
124 CFRelease( tBundleRef );
125 }
126 }
127 return tVersion;
128 }
This page took 0.033369 seconds and 4 git commands to generate.