Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OODebugController Class Reference

#include <OODebugController.h>

+ Inheritance diagram for OODebugController:
+ Collaboration diagram for OODebugController:

Instance Methods

(NSBundle *) - bundle
 
(NSString *) - pathForResource:ofType:
 
(IBAction) - showLogAction:
 
(IBAction) - graphicsResetAction:
 
(IBAction) - clearTextureCacheAction:
 
(IBAction) - resetAndClearAction:
 
(IBAction) - dumpEntityListAction:
 
(IBAction) - dumpPlayerStateAction:
 
(IBAction) - createShipAction:
 
(IBAction) - clearAllCachesAction:
 
(IBAction) - toggleWireframeModeAction:
 
(IBAction) - hideShowHUD:
 
(IBAction) - inspectPlayer:
 
(IBAction) - inspectTarget:
 
(IBAction) - cleanUpInspectors:
 
(IBAction) - toggleThisLogMessageClassAction:
 
(IBAction) - otherLogMessageClassAction:
 
(IBAction) - logMsgClassPanelEnableAction:
 
(IBAction) - logMsgClassPanelDisableAction:
 
(IBAction) - toggleThisDebugFlagAction:
 
(IBAction) - setShaderModeToTag:
 
(IBAction) - showLogPreferencesAction:
 
(IBAction) - logSetShowFunctionAction:
 
(IBAction) - logSetShowFileAndLineAction:
 
(IBAction) - logSetShowMessageClassAction:
 
(IBAction) - logSetShowTimeStampAction:
 
(IBAction) - insertLogSeparatorAction:
 
(IBAction) - createShipPanelOKAction:
 
(IBAction) - modalPanelCancelAction:
 
(id< OODebuggerInterface >) - setUpDebugger [implementation]
 
(id) - init [implementation]
 
(void) - dealloc [implementation]
 
(void) - awakeFromNib [implementation]
 
(void) - spawnShip: [implementation]
 
(BOOL) - validateMenuItem: [implementation]
 
(void) - insertDebugMenu [implementation]
 
(void) - setUpLogMessageClassMenu [implementation]
 
(id) - copyWithZone: [implementation]
 
(id) - retain [implementation]
 
(NSUInteger) - retainCount [implementation]
 
(void) - release [implementation]
 
(id) - autorelease [implementation]
 

Class Methods

(OODebugController *) + sharedDebugController
 
(static void) + SetDisplayLogMessagesInClassThroughJS [implementation]
 
(id) + allocWithZone: [implementation]
 

Private Attributes

IBOutlet NSMenu * menu
 
IBOutlet NSMenu * logMessageClassSubMenu
 
IBOutlet NSPanel * logMessageClassPanel
 
IBOutlet NSTextField * logMsgClassPanelTextField
 
IBOutlet NSWindow * logPrefsWindow
 
IBOutlet NSButton * logShowFunctionCheckBox
 
IBOutlet NSButton * logShowFileAndLineCheckBox
 
IBOutlet NSButton * logShowMessageClassCheckBox
 
IBOutlet NSButton * logShowTimeStampCheckBox
 
IBOutlet NSPanel * createShipPanel
 
IBOutlet NSTextField * createShipPanelTextField
 
IBOutlet OOJavaScriptConsoleControllerjsConsoleController
 
NSBundle * _bundle
 

Detailed Description

Definition at line 54 of file OODebugController.h.

Method Documentation

◆ allocWithZone:

+ (id) allocWithZone: (NSZone *) inZone
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

527 :(NSZone *)inZone
528{
529 if (sSingleton == nil)
530 {
531 sSingleton = [super allocWithZone:inZone];
532 return sSingleton;
533 }
534 return nil;
535}
static OODebugMonitor * sSingleton
return nil

◆ autorelease

- (id) autorelease
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

561{
562 return self;
563}

◆ awakeFromNib

- (void) awakeFromNib
implementation

Definition at line 54 of file OODebugController.m.

140{
141 [logPrefsWindow center];
142}

◆ bundle

- (NSBundle *) bundle

Definition at line 54 of file OODebugController.m.

128{
129 return _bundle;
130}

◆ cleanUpInspectors:

- (IBAction) cleanUpInspectors: (id) sender

Definition at line 54 of file OODebugController.m.

◆ clearAllCachesAction:

- (IBAction) clearAllCachesAction: (id) sender

Definition at line 54 of file OODebugController.m.

206 :sender
207{
209}
OOCacheManager * sharedCache()

◆ clearTextureCacheAction:

- (IBAction) clearTextureCacheAction: (id) sender

Definition at line 54 of file OODebugController.m.

159 :sender
160{
162}
void clearCache()
Definition OOTexture.m:357

◆ copyWithZone:

- (id) copyWithZone: (NSZone *) inZone
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

538 :(NSZone *)inZone
539{
540 return self;
541}

◆ createShipAction:

- (IBAction) createShipAction: (id) sender

Definition at line 54 of file OODebugController.m.

191 :sender
192{
193 NSString *role = nil;
194
195 role = [[NSUserDefaults standardUserDefaults] stringForKey:@"debug-create-ship-panel-last-role"];
196 if (role != nil)
197 {
198 [createShipPanelTextField setStringValue:role];
199 }
200
201 [NSApp runModalForWindow:createShipPanel];
202 [createShipPanel orderOut:self];
203}

◆ createShipPanelOKAction:

- (IBAction) createShipPanelOKAction: (id) sender

Definition at line 246 of file OODebugController.m.

368 :sender
369{
370 NSString *shipRole = nil;
371
372 shipRole = [createShipPanelTextField stringValue];
373 if ([shipRole length] != 0)
374 {
375 [self performSelector:@selector(spawnShip:) withObject:shipRole afterDelay:0.1];
376 [[NSUserDefaults standardUserDefaults] setObject:shipRole forKey:@"debug-create-ship-panel-last-role"];
377 }
378
379 [NSApp stopModal];
380}

◆ dealloc

- (void) dealloc
implementation

Definition at line 54 of file OODebugController.m.

104{
105 if (sSingleton == self) sSingleton = nil;
106
107 [menu release];
108 [logMessageClassPanel release];
109 [logPrefsWindow release];
110 [createShipPanel release];
111 [jsConsoleController release];
112
113 [_bundle release];
114
115 [super dealloc];
116}

◆ dumpEntityListAction:

- (IBAction) dumpEntityListAction: (id) sender

Definition at line 54 of file OODebugController.m.

172 :sender
173{
174 BOOL wasEnabled;
175
176 wasEnabled = OOLogWillDisplayMessagesInClass(@"universe.objectDump");
177 OOLogSetDisplayMessagesInClass(@"universe.objectDump", YES);
178
179 [UNIVERSE debugDumpEntities];
180
181 OOLogSetDisplayMessagesInClass(@"universe.objectDump", wasEnabled);
182}
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
Definition OOLogging.m:144
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
Definition OOLogging.m:182

◆ dumpPlayerStateAction:

- (IBAction) dumpPlayerStateAction: (id) sender

Definition at line 54 of file OODebugController.m.

185 :sender
186{
188}
void dumpState()
Definition Entity.m:996
PlayerEntity * sharedPlayer()

◆ graphicsResetAction:

- (IBAction) graphicsResetAction: (id) sender

◆ hideShowHUD:

- (IBAction) hideShowHUD: (id) sender

Definition at line 54 of file OODebugController.m.

218 :sender
219{
220 BOOL hidden = [[[PlayerEntity sharedPlayer] hud] isHidden];
221 NSString *command = [NSString stringWithFormat:@"player.ship.hudHidden = %@", hidden ? @"false" : @"true"];
223}
oneway void performJSConsoleCommand:(in NSString *command)
OODebugMonitor * sharedDebugMonitor()
HeadUpDisplay * hud

◆ init

- (id) init
implementation

Definition at line 54 of file OODebugController.m.

74{
75 NSString *nibPath = nil;
76
77 self = [super init];
78 if (self != nil)
79 {
80 _bundle = [[NSBundle bundleForClass:[self class]] retain];
81
82 nibPath = [self pathForResource:@"OODebugController" ofType:@"nib"];
83 if (nibPath == nil)
84 {
85 OOLog(@"debugSupport.load.failed", @"Could not find OODebugController.nib.");
86 [self release];
87 self = nil;
88 }
89 else
90 {
91 [NSBundle loadNibFile:nibPath externalNameTable:[NSDictionary dictionaryWithObject:self forKey:@"NSOwner"] withZone:NULL];
92
93 [self insertDebugMenu];
94 [self setUpLogMessageClassMenu];
95 OOLog(@"debugSupport.load.success", @"Debug Bundle loaded successfully.");
96 }
97 }
98
99 return self;
100}
#define OOLog(class, format,...)
Definition OOLogging.h:88

◆ insertDebugMenu

- (void) insertDebugMenu
implementation

Definition at line 246 of file OODebugController.m.

463{
464 NSMenuItem *item = nil;
465 NSInteger index;
466
467 [menu setTitle:@"Debug"];
468 item = [[NSMenuItem alloc] initWithTitle:@"Debug" action:NULL keyEquivalent:@""];
469 [item setSubmenu:menu];
470 [[NSApp mainMenu] addItem:item];
471 [item release];
472
473 if (![[NSUserDefaults standardUserDefaults] boolForKey:@"debug-show-extra-menu-items"])
474 {
475 // Old school and not elegant, but it removes the compiler warning
476 // on possible misuse of comma operator [-Wcomma],
477 // produced by the following statement
478 // while (index = [menu indexOfItemWithTag:-42], index != -1)
479 // Bracketing the operands with parenthesis, doesn't help either.
480 index = [menu indexOfItemWithTag:-42];
481 while (index != -1)
482 {
483 [menu removeItemAtIndex:index];
484 index = [menu indexOfItemWithTag:-42];
485 }
486 }
487}

◆ insertLogSeparatorAction:

- (IBAction) insertLogSeparatorAction: (id) sender

Definition at line 246 of file OODebugController.m.

362 :sender
363{
364 [[OODebugMonitor sharedDebugMonitor] performJSConsoleCommand:@"console.writeLogMarker()"];
365}

◆ inspectPlayer:

- (IBAction) inspectPlayer: (id) sender

Definition at line 54 of file OODebugController.m.

226 :sender
227{
228 // [[PlayerEntity sharedPlayer] inspect];
229 [[OODebugMonitor sharedDebugMonitor] performJSConsoleCommand:@"player.ship.inspect()"];
230}

◆ inspectTarget:

- (IBAction) inspectTarget: (id) sender

Definition at line 54 of file OODebugController.m.

233 :sender
234{
235 // [[[PlayerEntity sharedPlayer] primaryTarget] inspect];
236 [[OODebugMonitor sharedDebugMonitor] performJSConsoleCommand:@"player.ship.target.inspect()"];
237}

◆ logMsgClassPanelDisableAction:

- (IBAction) logMsgClassPanelDisableAction: (id) sender

Definition at line 246 of file OODebugController.m.

283 :sender
284{
285 NSString *msgClass = nil;
286
287 msgClass = [logMsgClassPanelTextField stringValue];
288 if ([msgClass length] != 0) SetDisplayLogMessagesInClassThroughJS(msgClass, NO);
289
290 [NSApp stopModal];
291}
static void SetDisplayLogMessagesInClassThroughJS(NSString *msgClass, BOOL display)

◆ logMsgClassPanelEnableAction:

- (IBAction) logMsgClassPanelEnableAction: (id) sender

Definition at line 246 of file OODebugController.m.

272 :sender
273{
274 NSString *msgClass = nil;
275
276 msgClass = [logMsgClassPanelTextField stringValue];
277 if ([msgClass length] != 0) SetDisplayLogMessagesInClassThroughJS(msgClass, YES);
278
279 [NSApp stopModal];
280}

◆ logSetShowFileAndLineAction:

- (IBAction) logSetShowFileAndLineAction: (id) sender

Definition at line 246 of file OODebugController.m.

344 :sender
345{
346 OOLogSetShowFileAndLine([sender state]);
347}
void OOLogSetShowFileAndLine(BOOL flag)
Definition OOLogging.m:531

◆ logSetShowFunctionAction:

- (IBAction) logSetShowFunctionAction: (id) sender

Definition at line 246 of file OODebugController.m.

338 :sender
339{
340 OOLogSetShowFunction([sender state]);
341}
void OOLogSetShowFunction(BOOL flag)
Definition OOLogging.m:513

◆ logSetShowMessageClassAction:

- (IBAction) logSetShowMessageClassAction: (id) sender

Definition at line 246 of file OODebugController.m.

350 :sender
351{
352 OOLogSetShowMessageClass([sender state]);
353}
void OOLogSetShowMessageClass(BOOL flag)
Definition OOLogging.m:567

◆ logSetShowTimeStampAction:

- (IBAction) logSetShowTimeStampAction: (id) sender

Definition at line 246 of file OODebugController.m.

356 :sender
357{
358 OOLogSetShowTime([sender state]);
359}
void OOLogSetShowTime(BOOL flag)
Definition OOLogging.m:549

◆ modalPanelCancelAction:

- (IBAction) modalPanelCancelAction: (id) sender

Definition at line 246 of file OODebugController.m.

401 :sender
402{
403 [NSApp stopModal];
404}

◆ otherLogMessageClassAction:

- (IBAction) otherLogMessageClassAction: (id) sender

Definition at line 246 of file OODebugController.m.

265 :sender
266{
267 [NSApp runModalForWindow:logMessageClassPanel];
268 [logMessageClassPanel orderOut:self];
269}

◆ pathForResource:ofType:

- (NSString *) pathForResource: (NSString *) name
ofType: (NSString *) type 

Definition at line 54 of file OODebugController.m.

133 :(NSString *)name ofType:(NSString *)type
134{
135 return [[self bundle] pathForResource:name ofType:type];
136}

◆ release

- (void) release
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

557{}

◆ resetAndClearAction:

- (IBAction) resetAndClearAction: (id) sender

Definition at line 54 of file OODebugController.m.

◆ retain

- (id) retain
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

545{
546 return self;
547}

◆ retainCount

- (NSUInteger) retainCount
implementation

Provided by category OODebugController(Singleton).

Definition at line 246 of file OODebugController.m.

551{
552 return UINT_MAX;
553}

◆ SetDisplayLogMessagesInClassThroughJS

+ (static void) SetDisplayLogMessagesInClassThroughJS (NSString *) msgClass
(BOOL) display 
implementation

Definition at line 246 of file OODebugController.m.

247{
248 NSString *command = [NSString stringWithFormat:@"console.setDisplayMessagesInClass(\"%@\", %@)", [msgClass escapedForJavaScriptLiteral], display ? @"true" : @"false"];
250}

◆ setShaderModeToTag:

- (IBAction) setShaderModeToTag: (NSMenuItem *) sender

Definition at line 246 of file OODebugController.m.

317 :(NSMenuItem *)sender
318{
319 OOGraphicsDetail detail = (OOGraphicsDetail)sender.tag;
320 NSString *detailString = [OOStringFromGraphicsDetail(detail) escapedForJavaScriptLiteral];
321 NSString *command = [NSString stringWithFormat:@"console.detailLevel = \"%@\"", detailString];
322
324}
OOGraphicsDetail
Definition OOTypes.h:243

◆ setUpDebugger

- (id< OODebuggerInterface >) setUpDebugger
implementation

Definition at line 54 of file OODebugController.m.

68{
69 return [[[OOMacDebugger alloc] initWithController:jsConsoleController] autorelease];
70}

◆ setUpLogMessageClassMenu

- (void) setUpLogMessageClassMenu
implementation

Definition at line 246 of file OODebugController.m.

491{
492 NSArray *definitions = nil;
493 NSUInteger i, count, inserted = 0;
494 NSString *title = nil, *key = nil;
495 NSMenuItem *item = nil;
496
497 definitions = [ResourceManager arrayFromFilesNamed:@"debugLogMessageClassesMenu.plist" inFolder:@"Config" andMerge:YES];
498 count = [definitions count] / 2;
499
500 for (i = 0; i != count; ++i)
501 {
502 title = [definitions oo_stringAtIndex:i * 2];
503 key = [definitions oo_stringAtIndex:i * 2 + 1];
504 if (title == nil || key == nil) continue;
505
506 item = [[NSMenuItem alloc] initWithTitle:title
507 action:@selector(toggleThisLogMessageClassAction:)
508 keyEquivalent:@""];
509 [item setTarget:self];
510 [item setRepresentedObject:key];
511
512 [logMessageClassSubMenu insertItem:item atIndex:inserted++];
513 [item release];
514 }
515}
unsigned count
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)

◆ sharedDebugController

+ (id) sharedDebugController

Definition at line 54 of file OODebugController.m.

120{
121 // NOTE: assumes single-threaded first access. See header.
122 if (sSingleton == nil) sSingleton = [[self alloc] init];
123 return sSingleton;
124}

◆ showLogAction:

- (IBAction) showLogAction: (id) sender

Definition at line 54 of file OODebugController.m.

147 :sender
148{
149 [[NSWorkspace sharedWorkspace] openFile:OOLogHandlerGetLogPath()];
150}

◆ showLogPreferencesAction:

- (IBAction) showLogPreferencesAction: (id) sender

Definition at line 246 of file OODebugController.m.

327 :sender
328{
329 [logShowFunctionCheckBox setState:OOLogShowFunction()];
330 [logShowFileAndLineCheckBox setState:OOLogShowFileAndLine()];
331 [logShowMessageClassCheckBox setState:OOLogShowMessageClass()];
332 [logShowTimeStampCheckBox setState:OOLogShowTime()];
333
334 [logPrefsWindow makeKeyAndOrderFront:self];
335}

◆ spawnShip:

- (void) spawnShip: (NSString *) shipRole
implementation

Definition at line 246 of file OODebugController.m.

383 :(NSString *)shipRole
384{
385 NSString *command = nil;
386
387 if (shipRole == nil) return;
388
389 if ([[OODebugMonitor sharedDebugMonitor] debuggerConnected])
390 {
391 command = [NSString stringWithFormat:@"this.T = system.addShips('%@', 1, player.ship.position, 10000); if (this.T) this.T = this.T[0]; else consoleMessage('command-error', 'Could not spawn \"%@\".');", [shipRole escapedForJavaScriptLiteral], [shipRole escapedForJavaScriptLiteral]];
393 }
394 else
395 {
396 [UNIVERSE addShipWithRole:shipRole nearRouteOneAt:1.0];
397 }
398}

◆ toggleThisDebugFlagAction:

- (IBAction) toggleThisDebugFlagAction: (id) sender

Definition at line 246 of file OODebugController.m.

294 :sender
295{
296 NSUInteger tag, bits;
297 NSString *command = nil;
298
299 tag = [sender tag];
300 bits = gDebugFlags & tag;
301
302 if (bits != tag)
303 {
304 // Flags are off or mixed.
305 command = [NSString stringWithFormat:@"console.debugFlags |= 0x%lX", tag];
306 }
307 else
308 {
309 // Flags are all on.
310 command = [NSString stringWithFormat:@"console.debugFlags &= ~0x%.lX", tag];
311 }
312
314}
NSUInteger gDebugFlags
Definition main.m:7

◆ toggleThisLogMessageClassAction:

- (IBAction) toggleThisLogMessageClassAction: (id) sender

Definition at line 246 of file OODebugController.m.

253 :sender
254{
255 NSString *msgClass = nil;
256
257 if ([sender respondsToSelector:@selector(representedObject)])
258 {
259 msgClass = [sender representedObject];
261 }
262}

◆ toggleWireframeModeAction:

- (IBAction) toggleWireframeModeAction: (id) sender

Definition at line 54 of file OODebugController.m.

212 :sender
213{
214 [UNIVERSE setWireframeGraphics:![UNIVERSE wireframeGraphics]];
215}

◆ validateMenuItem:

- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
implementation

Definition at line 246 of file OODebugController.m.

409 :(NSMenuItem *)menuItem
410{
411 SEL action = NULL;
412 NSString *msgClass = nil;
413 NSUInteger tag, bits;
414 int state;
415
416 action = [menuItem action];
417
418 if (action == @selector(toggleThisLogMessageClassAction:))
419 {
420 msgClass = [menuItem representedObject];
421 [menuItem setState:OOLogWillDisplayMessagesInClass(msgClass)];
422 return YES;
423 }
424 if (action == @selector(toggleThisDebugFlagAction:))
425 {
426 tag = [menuItem tag];
427 bits = gDebugFlags & tag;
428 if (bits == 0) state = NSOffState;
429 else if (bits == tag) state = NSOnState;
430 else state = NSMixedState;
431
432 [menuItem setState:state];
433 return YES;
434 }
435 if (action == @selector(toggleWireframeModeAction:))
436 {
437 [menuItem setState:!![UNIVERSE wireframeGraphics]];
438 return YES;
439 }
440 if (action == @selector(inspectTarget:))
441 {
443 }
444 if (action == @selector(hideShowHUD:))
445 {
446 BOOL hidden = [[[PlayerEntity sharedPlayer] hud] isHidden];
447 [menuItem setTitle:hidden ? @"Show HUD" : @"Hide HUD"];
448 return YES;
449 }
450 if (action == @selector(setShaderModeToTag:))
451 {
452 OOGraphicsDetail itemLevel = (OOGraphicsDetail)menuItem.tag;
453
454 menuItem.state = (UNIVERSE.detailLevel == itemLevel);
456 }
457
458 return [self respondsToSelector:action];
459}
#define UNIVERSE
Definition Universe.h:833
OOOpenGLExtensionManager * sharedManager()

Member Data Documentation

◆ _bundle

- (NSBundle*) _bundle
private

Definition at line 74 of file OODebugController.h.

◆ createShipPanel

- (IBOutlet NSPanel*) createShipPanel
private

Definition at line 69 of file OODebugController.h.

◆ createShipPanelTextField

- (IBOutlet NSTextField*) createShipPanelTextField
private

Definition at line 70 of file OODebugController.h.

◆ jsConsoleController

- (IBOutlet OOJavaScriptConsoleController*) jsConsoleController
private

Definition at line 72 of file OODebugController.h.

◆ logMessageClassPanel

- (IBOutlet NSPanel*) logMessageClassPanel
private

Definition at line 60 of file OODebugController.h.

◆ logMessageClassSubMenu

- (IBOutlet NSMenu*) logMessageClassSubMenu
private

Definition at line 58 of file OODebugController.h.

◆ logMsgClassPanelTextField

- (IBOutlet NSTextField*) logMsgClassPanelTextField
private

Definition at line 61 of file OODebugController.h.

◆ logPrefsWindow

- (IBOutlet NSWindow*) logPrefsWindow
private

Definition at line 63 of file OODebugController.h.

◆ logShowFileAndLineCheckBox

- (IBOutlet NSButton*) logShowFileAndLineCheckBox
private

Definition at line 65 of file OODebugController.h.

◆ logShowFunctionCheckBox

- (IBOutlet NSButton*) logShowFunctionCheckBox
private

Definition at line 64 of file OODebugController.h.

◆ logShowMessageClassCheckBox

- (IBOutlet NSButton*) logShowMessageClassCheckBox
private

Definition at line 66 of file OODebugController.h.

◆ logShowTimeStampCheckBox

- (IBOutlet NSButton*) logShowTimeStampCheckBox
private

Definition at line 67 of file OODebugController.h.

◆ menu

- (IBOutlet NSMenu*) menu
private

Definition at line 57 of file OODebugController.h.


The documentation for this class was generated from the following files: