Oolite
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 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/*
116 Eco Quality of Service currently implemented only on Windows.
117 It sets the game to low power consumption mode when it loses
118 focus or is paused. When EcoQoS is active:
119 - Windows schedules the appliation on more efficient CPU cores
120 - The CPU is kept at a more efficient clock frequency
121
122 On non-Windows platforms it is a no-op.
123*/
124- (void) setEcoQoS: (BOOL)efficiencyModeRequested;
125
126- (OOMouseInteractionMode) mouseInteractionMode;
127- (void) setMouseInteractionMode:(OOMouseInteractionMode)mode;
128- (void) setMouseInteractionModeForFlight; // Chooses mouse control mode appropriately.
129- (void) setMouseInteractionModeForUIWithMouseInteraction:(BOOL)interaction;
130
131- (void) performGameTick:(id)sender;
132
133#if OOLITE_MAC_OS_X
134- (IBAction) showLogAction:(id)sender;
135- (IBAction) showLogFolderAction:(id)sender;
136- (IBAction) showSnapshotsAction:(id)sender;
137- (IBAction) showAddOnsAction:(id)sender;
138- (void) recenterVirtualJoystick;
139#endif
140
141- (void) exitAppWithContext:(NSString *)context;
142- (void) exitAppCommandQ;
143
144- (NSString *) playerFileToLoad;
145- (void) setPlayerFileToLoad:(NSString *)filename;
146
147- (NSString *) playerFileDirectory;
148- (void) setPlayerFileDirectory:(NSString *)filename;
149
150- (void) loadPlayerIfRequired;
151
152- (void) beginSplashScreen;
153- (void) logProgress:(NSString *)message;
154#if OO_DEBUG
155- (void) debugLogProgress:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
156- (void) debugLogProgress:(NSString *)format arguments:(va_list)arguments OO_TAKES_FORMAT_STRING(1, 0);
157- (void) debugPushProgressMessage:(NSString *)format, ... OO_TAKES_FORMAT_STRING(1, 2);
158- (void) debugPopProgressMessage;
159#endif
160- (void) endSplashScreen;
161
162- (void) startAnimationTimer;
163- (void) stopAnimationTimer;
164
165- (MyOpenGLView *) gameView;
166- (void) setGameView:(MyOpenGLView *)view;
167
168- (void)windowDidResize:(NSNotification *)aNotification;
169
170- (void)setUpBasicOpenGLStateWithSize:(NSSize)viewSize;
171
172- (NSURL *) snapshotsURLCreatingIfNeeded:(BOOL)create;
173
174@end
175
176
177@interface GameController (FullScreen)
178
179#if OO_USE_FULLSCREEN_CONTROLLER
180#if OOLITE_MAC_OS_X
181- (IBAction) toggleFullScreenAction:(id)sender;
182#endif
183
184- (void) setFullScreenMode:(BOOL)value;
185#endif
186
187- (void) exitFullScreenMode; // FIXME: should be setFullScreenMode:NO
188- (BOOL) inFullScreenMode;
189
190- (BOOL) setDisplayWidth:(unsigned int) d_width Height:(unsigned int)d_height Refresh:(unsigned int) d_refresh;
191- (NSDictionary *) findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh;
192- (NSArray *) displayModes;
193- (NSUInteger) indexOfCurrentDisplayMode;
194
195- (void) pauseFullScreenModeToPerform:(SEL) selector onTarget:(id) target;
196
197
198// Internal use only.
199- (void) setUpDisplayModes;
200
201@end
202
203
204#if OO_DEBUG
205#define OO_DEBUG_PROGRESS(...) [[GameController sharedController] debugLogProgress:__VA_ARGS__]
206#define OO_DEBUG_PUSH_PROGRESS(...) [[GameController sharedController] debugPushProgressMessage:__VA_ARGS__]
207#define OO_DEBUG_POP_PROGRESS() [[GameController sharedController] debugPopProgressMessage]
208#else
209#define OO_DEBUG_PROGRESS(...) do {} while (0)
210#define OO_DEBUG_PUSH_PROGRESS(...) do {} while (0)
211#define OO_DEBUG_POP_PROGRESS() do {} while (0)
212#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