]> Dogcows Code - chaz/thecheat/blob - cheat_global.m
The Cheat 1.2.1
[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 /* Ed Palma will act as a contact person for The Cheat. */
66 [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.brokenzipper.com/contact.html"]];
67 }
68
69
70 int MacOSXVersion()
71 {
72 SInt32 static version = -1;
73
74 if ( version != -1 ) {
75 return (int)version;
76 }
77
78 // get the version
79 if ( Gestalt( gestaltSystemVersion, &version ) != noErr ) {
80 return -1;
81 }
82 return (int)version;
83 }
84
85 NSString *ApplicationVersion( NSString *appPath )
86 {
87 NSString *tVersion = nil;
88 NSBundle *tBundle = [NSBundle bundleWithPath:appPath];
89
90 if ( tBundle ) {
91 NSDictionary *tInfoDictionary;
92
93 tInfoDictionary = [tBundle infoDictionary];
94
95 if ( tInfoDictionary ) {
96 tVersion = [tInfoDictionary objectForKey:@"CFBundleShortVersionString"];
97 if ( !tVersion ) {
98 tVersion = [tInfoDictionary objectForKey:@"CFBundleVersion"];
99 }
100 }
101 }
102 else {
103 CFBundleRef tBundleRef;
104 short resNum = 0;
105
106 tBundleRef = CFBundleCreate( NULL, (CFURLRef)[NSURL fileURLWithPath:appPath] );
107
108 if ( tBundleRef ) {
109 resNum = CFBundleOpenBundleResourceMap( tBundleRef );
110 }
111
112 if ( resNum != 0 ) {
113 VersRecHndl tVersionHandle;
114 unsigned long tNumVersion;
115
116 tVersionHandle = (VersRecHndl)Get1IndResource( 'vers', 1 );
117
118 if ( tVersionHandle ) {
119 tNumVersion = *((unsigned long *) &((*tVersionHandle)->numericVersion));
120
121 if ( (tNumVersion & 0x00040000) != 0 ) {
122 tVersion = [NSString stringWithFormat:@"%d.%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20, (tNumVersion & 0x000F0000)>>16];
123 }
124 else {
125 tVersion = [NSString stringWithFormat:@"%d.%d", (tNumVersion & 0xFF000000)>>24, (tNumVersion & 0x00F00000)>>20];
126 }
127 }
128
129 }
130 if ( tBundleRef ) {
131 CFBundleCloseBundleResourceMap( tBundleRef, resNum );
132 // Release Memory
133 CFRelease( tBundleRef );
134 }
135 }
136 return tVersion;
137 }
This page took 0.035595 seconds and 4 git commands to generate.