Oolite 1.91.0.7604-240417-a536cbe
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
43
44
45// TEMP: whether to use separate OOFullScreenController object, will hopefully be used for all builds soon.
46#define OO_USE_FULLSCREEN_CONTROLLER OOLITE_MAC_OS_X
47
48
49@interface GameController: NSObject
50{
51@private
52#if OOLITE_MAC_OS_X
53 IBOutlet NSTextField *splashProgressTextField;
54 IBOutlet NSView *splashView;
55 IBOutlet NSWindow *gameWindow;
56 IBOutlet PDFView *helpView;
57 IBOutlet NSMenu *dockMenu;
58#endif
59
61
62 NSTimeInterval last_timeInterval;
63 double delta_t;
64
66
69 NSMutableArray *expansionPathsToInclude;
70
71 NSTimer *timer;
73
74 NSDate *_splashStart;
75
77 NSObject *pauseTarget;
78
80
83
84// Fullscreen mode stuff.
85#if OO_USE_FULLSCREEN_CONTROLLER
87#elif OOLITE_SDL
88 NSRect fsGeometry;
89 MyOpenGLView *switchView;
90
91 NSMutableArray *displayModes;
92
93 unsigned int width, height;
94 unsigned int refresh;
95 BOOL fullscreen;
96 NSDictionary *originalDisplayMode;
97 NSDictionary *fullscreenDisplayMode;
98
99 BOOL stayInFullScreenMode;
100#endif
101}
102
103+ (GameController *) sharedController;
104
105- (void) applicationDidFinishLaunching:(NSNotification *)notification;
106
107- (BOOL) isGamePaused;
108- (void) setGamePaused:(BOOL)value;
109
110- (OOMouseInteractionMode) mouseInteractionMode;
111- (void) setMouseInteractionMode:(OOMouseInteractionMode)mode;
112- (void) setMouseInteractionModeForFlight; // Chooses mouse control mode appropriately.
113- (void) setMouseInteractionModeForUIWithMouseInteraction:(BOOL)interaction;
114
115- (void) performGameTick:(id)sender;
116
117#if OOLITE_MAC_OS_X
118- (IBAction) showLogAction:(id)sender;
119- (IBAction) showLogFolderAction:(id)sender;
120- (IBAction) showSnapshotsAction:(id)sender;
121- (IBAction) showAddOnsAction:(id)sender;
122- (void) recenterVirtualJoystick;
123#endif
124
125- (void) exitAppWithContext:(NSString *)context;
126- (void) exitAppCommandQ;
127
128- (NSString *) playerFileToLoad;
129- (void) setPlayerFileToLoad:(NSString *)filename;
130
131- (NSString *) playerFileDirectory;
132- (void) setPlayerFileDirectory:(NSString *)filename;
133
134- (void) loadPlayerIfRequired;
135
136- (void) beginSplashScreen;
137- (void) logProgress:(NSString *)message;
138#if OO_DEBUG
139- (void) debugLogProgress:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
140- (void) debugLogProgress:(NSString *)format arguments:(va_list)arguments OO_TAKES_FORMAT_STRING(1, 0);
141- (void) debugPushProgressMessage:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
142- (void) debugPopProgressMessage;
143#endif
144- (void) endSplashScreen;
145
146- (void) startAnimationTimer;
147- (void) stopAnimationTimer;
148
149- (MyOpenGLView *) gameView;
150- (void) setGameView:(MyOpenGLView *)view;
151
152- (void)windowDidResize:(NSNotification *)aNotification;
153
154- (void)setUpBasicOpenGLStateWithSize:(NSSize)viewSize;
155
156- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create;
157
158@end
159
160
161@interface GameController (FullScreen)
162
163#if OO_USE_FULLSCREEN_CONTROLLER
164#if OOLITE_MAC_OS_X
165- (IBAction) toggleFullScreenAction:(id)sender;
166#endif
167
168- (void) setFullScreenMode:(BOOL)value;
169#endif
170
171- (void) exitFullScreenMode; // FIXME: should be setFullScreenMode:NO
172- (BOOL) inFullScreenMode;
173
174- (BOOL) setDisplayWidth:(unsigned int) d_width Height:(unsigned int)d_height Refresh:(unsigned int) d_refresh;
175- (NSDictionary *) findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh;
176- (NSArray *) displayModes;
177- (NSUInteger) indexOfCurrentDisplayMode;
178
179- (void) pauseFullScreenModeToPerform:(SEL) selector onTarget:(id) target;
180
181
182// Internal use only.
183- (void) setUpDisplayModes;
184
185@end
186
187
188#if OO_DEBUG
189#define OO_DEBUG_PROGRESS(...) [[GameController sharedController] debugLogProgress:__VA_ARGS__]
190#define OO_DEBUG_PUSH_PROGRESS(...) [[GameController sharedController] debugPushProgressMessage:__VA_ARGS__]
191#define OO_DEBUG_POP_PROGRESS() [[GameController sharedController] debugPopProgressMessage]
192#else
193#define OO_DEBUG_PROGRESS(...) do {} while (0)
194#define OO_DEBUG_PUSH_PROGRESS(...) do {} while (0)
195#define OO_DEBUG_POP_PROGRESS() do {} while (0)
196#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