Oolite 1.91.0.7644-241112-7f5034b
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
64
65 NSTimeInterval last_timeInterval;
66 double delta_t;
67
69
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#endif
104}
105
106+ (GameController *) sharedController;
107
108- (void) applicationDidFinishLaunching:(NSNotification *)notification;
109
110- (BOOL) isGamePaused;
111- (void) setGamePaused:(BOOL)value;
112
113- (OOMouseInteractionMode) mouseInteractionMode;
114- (void) setMouseInteractionMode:(OOMouseInteractionMode)mode;
115- (void) setMouseInteractionModeForFlight; // Chooses mouse control mode appropriately.
116- (void) setMouseInteractionModeForUIWithMouseInteraction:(BOOL)interaction;
117
118- (void) performGameTick:(id)sender;
119
120#if OOLITE_MAC_OS_X
121- (IBAction) showLogAction:(id)sender;
122- (IBAction) showLogFolderAction:(id)sender;
123- (IBAction) showSnapshotsAction:(id)sender;
124- (IBAction) showAddOnsAction:(id)sender;
125- (void) recenterVirtualJoystick;
126#endif
127
128- (void) exitAppWithContext:(NSString *)context;
129- (void) exitAppCommandQ;
130
131- (NSString *) playerFileToLoad;
132- (void) setPlayerFileToLoad:(NSString *)filename;
133
134- (NSString *) playerFileDirectory;
135- (void) setPlayerFileDirectory:(NSString *)filename;
136
137- (void) loadPlayerIfRequired;
138
139- (void) beginSplashScreen;
140- (void) logProgress:(NSString *)message;
141#if OO_DEBUG
142- (void) debugLogProgress:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
143- (void) debugLogProgress:(NSString *)format arguments:(va_list)arguments OO_TAKES_FORMAT_STRING(1, 0);
144- (void) debugPushProgressMessage:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
145- (void) debugPopProgressMessage;
146#endif
147- (void) endSplashScreen;
148
149- (void) startAnimationTimer;
150- (void) stopAnimationTimer;
151
152- (MyOpenGLView *) gameView;
153- (void) setGameView:(MyOpenGLView *)view;
154
155- (void)windowDidResize:(NSNotification *)aNotification;
156
157- (void)setUpBasicOpenGLStateWithSize:(NSSize)viewSize;
158
159- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create;
160
161@end
162
163
164@interface GameController (FullScreen)
165
166#if OO_USE_FULLSCREEN_CONTROLLER
167#if OOLITE_MAC_OS_X
168- (IBAction) toggleFullScreenAction:(id)sender;
169#endif
170
171- (void) setFullScreenMode:(BOOL)value;
172#endif
173
174- (void) exitFullScreenMode; // FIXME: should be setFullScreenMode:NO
175- (BOOL) inFullScreenMode;
176
177- (BOOL) setDisplayWidth:(unsigned int) d_width Height:(unsigned int)d_height Refresh:(unsigned int) d_refresh;
178- (NSDictionary *) findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh;
179- (NSArray *) displayModes;
180- (NSUInteger) indexOfCurrentDisplayMode;
181
182- (void) pauseFullScreenModeToPerform:(SEL) selector onTarget:(id) target;
183
184
185// Internal use only.
186- (void) setUpDisplayModes;
187
188@end
189
190
191#if OO_DEBUG
192#define OO_DEBUG_PROGRESS(...) [[GameController sharedController] debugLogProgress:__VA_ARGS__]
193#define OO_DEBUG_PUSH_PROGRESS(...) [[GameController sharedController] debugPushProgressMessage:__VA_ARGS__]
194#define OO_DEBUG_POP_PROGRESS() [[GameController sharedController] debugPopProgressMessage]
195#else
196#define OO_DEBUG_PROGRESS(...) do {} while (0)
197#define OO_DEBUG_PUSH_PROGRESS(...) do {} while (0)
198#define OO_DEBUG_POP_PROGRESS() do {} while (0)
199#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