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#import "OOFoundation.h"
31
32#if OOLITE_MAC_COCOA_UI
33#import <Quartz/Quartz.h> // For PDFKit.
34#endif
35
36#define MINIMUM_GAME_TICK 0.25
37// * reduced from 0.5s for tgape * //
38
39#define MINIMUM_ANIMATION_TICK 0.0041667
40// 1.0 / (desired framerate cap)
41
43
44// TEMP: whether to use separate OOFullScreenController object, will hopefully be used for all builds soon.
45#define OO_USE_FULLSCREEN_CONTROLLER OOLITE_MAC_COCOA_UI
46
47@interface GameController : NSObject {
48@private
49#if OOLITE_MAC_COCOA_UI
50 IBOutlet NSTextField* splashProgressTextField;
51 IBOutlet NSView* splashView;
52 IBOutlet NSWindow* gameWindow;
53 IBOutlet PDFView* helpView;
54 IBOutlet NSMenu* dockMenu;
55#endif
56
57 IBOutlet MyOpenGLView* gameView;
58
59 NSTimeInterval last_timeInterval;
60 double delta_t;
61
63
64 NSString* playerFileDirectory;
65 NSString* playerFileToLoad;
66 NSMutableArray* expansionPathsToInclude;
67
68 NSTimer* timer;
70
71 NSDate* _splashStart;
72
74 NSObject* pauseTarget;
75
77
80
81// Fullscreen mode stuff.
82#if OO_USE_FULLSCREEN_CONTROLLER
84#elif OOLITE_SDL
85 NSRect fsGeometry;
86 MyOpenGLView* switchView;
87
88 NSMutableArray* displayModes;
89
90 unsigned int width, height;
91 unsigned int refresh;
92 BOOL fullscreen;
93 NSDictionary* originalDisplayMode;
94 NSDictionary* fullscreenDisplayMode;
95
96 BOOL stayInFullScreenMode;
97 BOOL _finishedLaunching;
98#endif
99}
100
101+ (GameController*)sharedController;
102
103- (void)applicationDidFinishLaunching:(NSNotification*)notification;
104- (BOOL)finishedLaunching;
105
106- (BOOL)isGamePaused;
107- (void)setGamePaused:(BOOL)value;
108
109/*
110 Eco Quality of Service currently implemented only on Windows.
111 It sets the game to low power consumption mode when it loses
112 focus or is paused. When EcoQoS is active:
113 - Windows schedules the appliation on more efficient CPU cores
114 - The CPU is kept at a more efficient clock frequency
115
116 On non-Windows platforms it is a no-op.
117*/
118- (void)setEcoQoS:(BOOL)efficiencyModeRequested;
119
120- (OOMouseInteractionMode)mouseInteractionMode;
121- (void)setMouseInteractionMode:(OOMouseInteractionMode)mode;
122- (void)setMouseInteractionModeForFlight; // Chooses mouse control mode appropriately.
123- (void)setMouseInteractionModeForUIWithMouseInteraction:(BOOL)interaction;
124
125- (void)performGameTick:(id)sender;
126
127#if OOLITE_MAC_COCOA_UI
128- (IBAction)showLogAction:(id)sender;
129- (IBAction)showLogFolderAction:(id)sender;
130- (IBAction)showSnapshotsAction:(id)sender;
131- (IBAction)showAddOnsAction:(id)sender;
132- (void)recenterVirtualJoystick;
133#endif
134
135- (void)exitAppWithContext:(NSString*)context;
136- (void)exitAppCommandQ;
137
138- (NSString*)playerFileToLoad;
139- (void)setPlayerFileToLoad:(NSString*)filename;
140
142- (void)setPlayerFileDirectory:(NSString*)filename;
143
145
146- (void)beginSplashScreen;
147- (void)logProgress:(NSString*)message;
148#if OO_DEBUG
149- (void)debugLogProgress:(NSString*)format, ... OO_TAKES_FORMAT_STRING(1, 2);
150- (void)debugLogProgress:(NSString*)format arguments:(va_list)arguments OO_TAKES_FORMAT_STRING(1, 0);
151- (void)debugPushProgressMessage:(NSString*)format, ... OO_TAKES_FORMAT_STRING(1, 2);
152- (void)debugPopProgressMessage;
153#endif
154- (void)endSplashScreen;
155
156- (void)startAnimationTimer;
157- (void)stopAnimationTimer;
158
160- (void)setGameView:(MyOpenGLView*)view;
161
162- (void)windowDidResize:(NSNotification*)aNotification;
163
164- (NSURL*)snapshotsURLCreatingIfNeeded:(BOOL)create;
165
166@end
167
168@interface GameController (FullScreen)
169
170#if OO_USE_FULLSCREEN_CONTROLLER
171#if OOLITE_MAC_COCOA_UI
172- (IBAction)toggleFullScreenAction:(id)sender;
173#endif
174
175- (void)setFullScreenMode:(BOOL)value;
176#endif
177
178- (void)exitFullScreenMode; // FIXME: should be setFullScreenMode:NO
180
181- (BOOL)setDisplayWidth:(unsigned int)d_width Height:(unsigned int)d_height Refresh:(unsigned int)d_refresh;
182- (NSDictionary*)findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int)d_height Refresh:(unsigned int)d_refresh;
183- (NSArray*)displayModes;
185
186- (void)pauseFullScreenModeToPerform:(SEL)selector onTarget:(id)target;
187
188// Internal use only.
190
191@end
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(...) \
199 do { \
200 } while (0)
201#define OO_DEBUG_PUSH_PROGRESS(...) \
202 do { \
203 } while (0)
204#define OO_DEBUG_POP_PROGRESS() \
205 do { \
206 } while (0)
207#endif
OOMouseInteractionMode
NSUInteger indexOfCurrentDisplayMode()
IBOutlet NSTextField * splashProgressTextField
IBOutlet NSWindow * gameWindow
NSString * playerFileToLoad
NSMutableArray * expansionPathsToInclude
OOMouseInteractionMode _resumeMode
NSTimeInterval last_timeInterval
NSArray * displayModes()
NSString * playerFileDirectory
NSDate * _splashStart
NSTimeInterval _animationTimerInterval
OOMouseInteractionMode _mouseMode
NSObject * pauseTarget
IBOutlet MyOpenGLView * gameView
IBOutlet PDFView * helpView
IBOutlet NSView * splashView
OOFullScreenController * _fullScreenController
IBOutlet NSMenu * dockMenu