]> Dogcows Code - chaz/thecheat/blob - cheat_global.m
The Cheat 1.2
[chaz/thecheat] / cheat_global.m
1
2 // **********************************************************************
3 // The Cheat - A universal game cheater for Mac OS X
4 // (C) 2003-2005 Chaz McGarvey (BrokenZipper)
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 1, or (at your option)
9 // any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 //
20
21 #import "cheat_global.h"
22
23 #import <Carbon/Carbon.h>
24
25
26 // globals
27 float gFadeAnimationDuration = TCDefaultFadeAnimation;
28
29
30 // user default constants
31 NSString *TCFirstLaunchPref = nil;
32 NSString *TCWindowsOnTopPref = @"TCWindowsOnTopPref";
33 NSString *TCUpdateCheckPref = @"TCUpdateCheckPref";
34 NSString *TCDisplayValuesPref = @"TCDisplayValuesPref";
35 NSString *TCValueUpdatePref = @"TCValueUpdatePref";
36 NSString *TCHitsDisplayedPref = @"TCHitsDisplayedPref";
37 NSString *TCRunServerPref = @"TCRunServerPref";
38 NSString *TCBroadcastNamePref = @"TCBroadcastNamePref";
39 NSString *TCListenPortPref = @"TCListenPortPref";
40 NSString *TCFadeAnimationPref = @"TCFadeAnimationPref";
41 NSString *TCAskForSavePref = @"TCAskForSavePref";
42 NSString *TCSwitchVariablesPref = @"TCSwitchVariablesPref";
43 NSString *TCAutoStartEditingVarsPref = @"TCAutoStartEditingVarsPref";
44
45
46 // notification constants
47 NSString *TCServiceFoundNote = @"TCServiceFoundNote";
48 NSString *TCServiceRemovedNote = @"TCServiceRemovedNote";
49 NSString *TCServerStartedNote = @"TCServerStartedNote";
50 NSString *TCServerStoppedNote = @"TCServerStoppedNote";
51 NSString *TCServerConnectionsChangedNote = @"TCServerConnectionsChangedNote";
52 NSString *TCWindowsOnTopChangedNote = @"TCWindowsOnTopChangedNote";
53 NSString *TCDisplayValuesChangedNote = @"TCDisplayValuesChangedNote";
54 NSString *TCHitsDisplayedChangedNote = @"TCHitsDisplayedChangedNote";
55
56
57 void LaunchWebsite()
58 {
59 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/"]];
60 }
61
62 void LaunchEmail()
63 {
64 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"mailto:chaz@brokenzipper.com?subject=The%20Cheat%20Feedback"]];
65 }
66
67
68 int MacOSXVersion()
69 {
70 SInt32 static version = -1;
71
72 if ( version != -1 ) {
73 return (int)version;
74 }
75
76 // get the version
77 if ( Gestalt( gestaltSystemVersion, &version ) != noErr ) {
78 return -1;
79 }
80 return (int)version;
81 }
82
83 NSString *ApplicationVersion( NSString *appPath )
84 {
85 NSString *tVersion = nil;
86 NSBundle *tBundle = [NSBundle bundleWithPath:appPath];
87
88 if ( tBundle ) {
89 NSDictionary *tInfoDictionary;
90
91 tInfoDictionary = [tBundle infoDictionary];
92
93 if ( tInfoDictionary ) {
94 tVersion = [tInfoDictionary objectForKey:@"CFBundleShortVersionString"];
95 if ( !tVersion ) {
96 tVersion = [tInfoDictionary objectForKey:@"CFBundleVersion"];
97 }
98 }
99 }
100 else {
101 CFBundleRef tBundleRef;
102 short resNum = 0;
103
104 tBundleRef = CFBundleCreate( NULL, (CFURLRef)[NSURL fileURLWithPath:appPath] );
105
106 if ( tBundleRef ) {
107 resNum = CFBundleOpenBundleResourceMap( tBundleRef );
108 }
109
110 if ( resNum != 0 ) {
111 VersRecHndl tVersionHandle;
112 unsigned long tNumVersion;
113
114 tVersionHandle = (VersRecHndl)Get1IndResource( 'vers', 1 );
115
116 if ( tVersionHandle ) {
117 tNumVersion = *((unsigned long *) &((*tVersionHandle)->numericVersion));
118
119 if ( (tNumVersion & 0x00040000) != 0 ) {
120 tVersion = [NSString stringWithFormat:@"%d.%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20, (tNumVersion & 0x000F0000)>>16];
121 }
122 else {
123 tVersion = [NSString stringWithFormat:@"%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20];
124 }
125 }
126
127 }
128 if ( tBundleRef ) {
129 CFBundleCloseBundleResourceMap( tBundleRef, resNum );
130 // Release Memory
131 CFRelease( tBundleRef );
132 }
133 }
134 return tVersion;
135 }
This page took 0.03901 seconds and 5 git commands to generate.