Oolite 1.93.0.7767-260207-f2a8cb5
Loading...
Searching...
No Matches
GameController.h
Go to the documentation of this file.
1/*
2
3GameController.h
4
5Main application controller class.
6
7Oolite
8Copyright (C) 2004-2013 Giles C Williams and contributors
9
10This program is free software; you can redistribute it and/or
11modify it under the terms of the GNU General Public License
12as published by the Free Software Foundation; either version 2
13of the License, or (at your option) any later version.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23MA 02110-1301, USA.
24
25*/
26
27
28#import "OOCocoa.h"
32
33
34#if OOLITE_MAC_OS_X
35#import <Quartz/Quartz.h> // For PDFKit.
36#endif
37
38#define MINIMUM_GAME_TICK 0.25
39// * reduced from 0.5s for tgape * //
40
41#define MINIMUM_ANIMATION_TICK 0.0041667
42// 1.0 / (desired framerate cap)
43
44
46
47
48// TEMP: whether to use separate OOFullScreenController object, will hopefully be used for all builds soon.
49#define OO_USE_FULLSCREEN_CONTROLLER OOLITE_MAC_OS_X
50
51
52@interface GameController: NSObject
53{
54@private
55#if OOLITE_MAC_OS_X
56 IBOutlet NSTextField *splashProgressTextField;
57 IBOutlet NSView *splashView;
58 IBOutlet NSWindow *gameWindow;
59 IBOutlet PDFView *helpView;
60 IBOutlet NSMenu *dockMenu;
61#endif
62
63 IBOutlet MyOpenGLView *gameView;
64
65 NSTimeInterval last_timeInterval;
66 double delta_t;
67
69
70 NSString *playerFileDirectory;
71 NSString *playerFileToLoad;
72 NSMutableArray *expansionPathsToInclude;
73
74 NSTimer *timer;
76
77 NSDate *_splashStart;
78
80 NSObject *pauseTarget;
81
83
86
87// Fullscreen mode stuff.
88#if OO_USE_FULLSCREEN_CONTROLLER
90#elif OOLITE_SDL
91 NSRect fsGeometry;
92 MyOpenGLView *switchView;
93
94 NSMutableArray *displayModes;
95
96 unsigned int width, height;
97 unsigned int refresh;
98 BOOL fullscreen;
99 NSDictionary *originalDisplayMode;
100 NSDictionary *fullscreenDisplayMode;
101
102 BOOL stayInFullScreenMode;
103 BOOL _finishedLaunching;
104#endif
105}
106
107+ (GameController *) sharedController;
108
109- (void) applicationDidFinishLaunching:(NSNotification *)notification;
110- (BOOL) finishedLaunching;
111
112- (BOOL) isGamePaused;
113- (void) setGamePaused:(BOOL)value;
114
115- (OOMouseInteractionMode) mouseInteractionMode;
116- (void) setMouseInteractionMode:(OOMouseInteractionMode)mode;
117- (void) setMouseInteractionModeForFlight; // Chooses mouse control mode appropriately.
118- (void) setMouseInteractionModeForUIWithMouseInteraction:(BOOL)interaction;
119
120- (void) performGameTick:(id)sender;
121
122#if OOLITE_MAC_OS_X
123- (IBAction) showLogAction:(id)sender;
124- (IBAction) showLogFolderAction:(id)sender;
125- (IBAction) showSnapshotsAction:(id)sender;
126- (IBAction) showAddOnsAction:(id)sender;
127- (void) recenterVirtualJoystick;
128#endif
129
130- (void) exitAppWithContext:(NSString *)context;
131- (void) exitAppCommandQ;
132
133- (NSString *) playerFileToLoad;
134- (void) setPlayerFileToLoad:(NSString *)filename;
135
136- (NSString *) playerFileDirectory;
137- (void) setPlayerFileDirectory:(NSString *)filename;
138
139- (void) loadPlayerIfRequired;
140
141- (void) beginSplashScreen;
142- (void) logProgress:(NSString *)message;
143#if OO_DEBUG
144- (void) debugLogProgress:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
145- (void) debugLogProgress:(NSString *)format arguments:(va_list)arguments OO_TAKES_FORMAT_STRING(1, 0);
146- (void) debugPushProgressMessage:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
147- (void) debugPopProgressMessage;
148#endif
149- (void) endSplashScreen;
150
151- (void) startAnimationTimer;
152- (void) stopAnimationTimer;
153
155- (void) setGameView:(MyOpenGLView *)view;
156
157- (void)windowDidResize:(NSNotification *)aNotification;
158
159- (void)setUpBasicOpenGLStateWithSize:(NSSize)viewSize;
160
161- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create;
162
163@end
164
165
166@interface GameController (FullScreen)
167
168#if OO_USE_FULLSCREEN_CONTROLLER
169#if OOLITE_MAC_OS_X
170- (IBAction) toggleFullScreenAction:(id)sender;
171#endif
172
173- (void) setFullScreenMode:(BOOL)value;
174#endif
175
176- (void) exitFullScreenMode; // FIXME: should be setFullScreenMode:NO
177- (BOOL) inFullScreenMode;
178
179- (BOOL) setDisplayWidth:(unsigned int) d_width Height:(unsigned int)d_height Refresh:(unsigned int) d_refresh;
180- (NSDictionary *) findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh;
181- (NSArray *) displayModes;
182- (NSUInteger) indexOfCurrentDisplayMode;
183
184- (void) pauseFullScreenModeToPerform:(SEL) selector onTarget:(id) target;
185
186
187// Internal use only.
188- (void) setUpDisplayModes;
189
190@end
191
192
193#if OO_DEBUG
194#define OO_DEBUG_PROGRESS(...) [[GameController sharedController] debugLogProgress:__VA_ARGS__]
195#define OO_DEBUG_PUSH_PROGRESS(...) [[GameController sharedController] debugPushProgressMessage:__VA_ARGS__]
196#define OO_DEBUG_POP_PROGRESS() [[GameController sharedController] debugPopProgressMessage]
197#else
198#define OO_DEBUG_PROGRESS(...) do {} while (0)
199#define OO_DEBUG_PUSH_PROGRESS(...) do {} while (0)
200#define OO_DEBUG_POP_PROGRESS() do {} while (0)
201#endif
OOMouseInteractionMode
IBOutlet NSTextField * splashProgressTextField
IBOutlet NSWindow * gameWindow
NSString * playerFileToLoad
NSMutableArray * expansionPathsToInclude
OOMouseInteractionMode _resumeMode
NSTimeInterval last_timeInterval
NSString * playerFileDirectory
NSDate * _splashStart
NSTimeInterval _animationTimerInterval
OOMouseInteractionMode _mouseMode
NSObject * pauseTarget
IBOutlet MyOpenGLView * gameView
IBOutlet PDFView * helpView
IBOutlet NSView * splashView
OOFullScreenController * _fullScreenController
IBOutlet NSMenu * dockMenu