author | alfadur |
Sat, 03 Aug 2019 00:54:29 +0300 | |
changeset 15306 | 6382a14c9e83 |
parent 12872 | 00215a7ec5f5 |
permissions | -rw-r--r-- |
4028 | 1 |
/* |
2 |
* Hedgewars-iOS, a Hedgewars port for iOS devices |
|
6700 | 3 |
* Copyright (c) 2009-2012 Vittorio Giovara <vittorio.giovara@gmail.com> |
4028 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
7048
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4028 | 17 |
*/ |
18 |
||
19 |
||
20 |
#import "ObjcExports.h" |
|
5175
a3da220dbb3f
finish overlay refactoring and some leak annihilation
koda
parents:
5174
diff
changeset
|
21 |
|
4028 | 22 |
#pragma mark - |
23 |
#pragma mark functions called by pascal code |
|
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6866
diff
changeset
|
24 |
BOOL inline isApplePhone(void) { |
5994 | 25 |
return (IS_IPAD() == NO); |
26 |
} |
|
27 |
||
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6866
diff
changeset
|
28 |
void startLoadingIndicator(void) { |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
29 |
// this is the first ojbc function called by engine, so we have to initialize some variables here |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
30 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
31 |
if ([HWUtils gameType] == gtSave) { |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
32 |
[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
33 |
|
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
34 |
/* |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
35 |
overlay_instance.view.backgroundColor = [UIColor blackColor]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
36 |
overlay_instance.view.alpha = 0.75; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
37 |
overlay_instance.view.userInteractionEnabled = NO; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
38 |
*/ |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
39 |
} |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
40 |
/* |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
41 |
CGPoint center = overlay_instance.view.center; |
6624
e049b5bb0ad1
BUUUUURN OBJC AMMOMENU BUUUURNhg diff! (on a separate note, this reduces the codesize by ~37k)
koda
parents:
6615
diff
changeset
|
42 |
CGPoint loaderCenter = ([HWUtils gameType] == gtSave) ? center : CGPointMake(center.x, center.y * 5/3); |
5174
f5294509783e
initial refactoring of ObjcExports and OverlayViewController
koda
parents:
5106
diff
changeset
|
43 |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
44 |
overlay_instance.loadingIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
45 |
overlay_instance.loadingIndicator.hidesWhenStopped = YES; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
46 |
overlay_instance.loadingIndicator.center = loaderCenter; |
6615 | 47 |
overlay_instance.loadingIndicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | |
48 |
UIViewAutoresizingFlexibleRightMargin | |
|
49 |
UIViewAutoresizingFlexibleTopMargin | |
|
50 |
UIViewAutoresizingFlexibleBottomMargin; |
|
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
51 |
[overlay_instance.loadingIndicator startAnimating]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
52 |
[overlay_instance.view addSubview:overlay_instance.loadingIndicator]; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
53 |
*/ |
4028 | 54 |
} |
55 |
||
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6866
diff
changeset
|
56 |
void stopLoadingIndicator(void) { |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
57 |
//HW_zoomSet(1.7); |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
58 |
if ([HWUtils gameType] != gtSave) { |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
59 |
//[overlay_instance.loadingIndicator stopAnimating]; |
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
60 |
//[overlay_instance.loadingIndicator removeFromSuperview]; |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
61 |
[HWUtils setGameStatus:gsInGame]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
62 |
} |
6866
efdd2e4fc45c
ios: don't prompt restoring a game that didn't complete loading
koda
parents:
6832
diff
changeset
|
63 |
// mark the savefile as valid, eg it's been loaded correctly |
efdd2e4fc45c
ios: don't prompt restoring a game that didn't complete loading
koda
parents:
6832
diff
changeset
|
64 |
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithBool:YES] forKey:@"saveIsValid"]; |
efdd2e4fc45c
ios: don't prompt restoring a game that didn't complete loading
koda
parents:
6832
diff
changeset
|
65 |
[[NSUserDefaults standardUserDefaults] synchronize]; |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
66 |
} |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
67 |
|
6908
896ed2afcfb8
ios: turn on more warning messages and start correcting them
koda
parents:
6866
diff
changeset
|
68 |
void saveFinishedSynching(void) { |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
69 |
/* |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
70 |
[UIView beginAnimations:@"fading from save synch" context:NULL]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
71 |
[UIView setAnimationDuration:1]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
72 |
overlay_instance.view.backgroundColor = [UIColor clearColor]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
73 |
overlay_instance.view.alpha = 1; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
74 |
overlay_instance.view.userInteractionEnabled = YES; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
75 |
[UIView commitAnimations]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
76 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
77 |
[overlay_instance.loadingIndicator stopAnimating]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
78 |
[overlay_instance.loadingIndicator performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:1]; |
7048
0a4c88935902
the ios port runs again, although with a few things to sort out
koda
parents:
6908
diff
changeset
|
79 |
*/ |
6247
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
80 |
|
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
81 |
[[UIApplication sharedApplication] setIdleTimerDisabled:NO]; |
6dfad55fd71c
unified the objc game state in a single place, which allowed some optimization to ObjcExport class (and more)
koda
parents:
6078
diff
changeset
|
82 |
[HWUtils setGameStatus:gsInGame]; |
4028 | 83 |
} |
84 |
||
85 |
||
5106
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
86 |
// dummy function to prevent linkage fail |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
87 |
int SDL_main(int argc, char **argv) { |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
88 |
return 0; |
517bdd3865f1
wow we're getting famous http://hg.libsdl.org/SDL/rev/8a04b596b472
koda
parents:
5002
diff
changeset
|
89 |
} |