69 return [[[
OOMacDebugger alloc] initWithController:jsConsoleController] autorelease];
75 NSString *nibPath =
nil;
85 OOLog(
@"debugSupport.load.failed",
@"Could not find OODebugController.nib.");
91 [
NSBundle loadNibFile:nibPath externalNameTable:[
NSDictionary dictionaryWithObject:
self forKey:@"NSOwner"] withZone:NULL];
95 OOLog(
@"debugSupport.load.success",
@"Debug Bundle loaded successfully.");
108 [logMessageClassPanel release];
110 [createShipPanel release];
133- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)type
135 return [[
self bundle] pathForResource:name ofType:type];
133- (NSString *)pathForResource:(NSString *)name ofType:(NSString *)type {
…}
147- (IBAction)showLogAction:sender
149 [[
NSWorkspace sharedWorkspace] openFile:OOLogHandlerGetLogPath()];
147- (IBAction)showLogAction:sender {
…}
153- (IBAction)graphicsResetAction:sender
153- (IBAction)graphicsResetAction:sender {
…}
159- (IBAction)clearTextureCacheAction:sender
159- (IBAction)clearTextureCacheAction:sender {
…}
165- (IBAction)resetAndClearAction:sender
165- (IBAction)resetAndClearAction:sender {
…}
172- (IBAction)dumpEntityListAction:sender
179 [UNIVERSE debugDumpEntities];
172- (IBAction)dumpEntityListAction:sender {
…}
185- (IBAction)dumpPlayerStateAction:sender
185- (IBAction)dumpPlayerStateAction:sender {
…}
191- (IBAction)createShipAction:sender
193 NSString *role =
nil;
195 role = [[
NSUserDefaults standardUserDefaults] stringForKey:@"debug-create-ship-panel-last-role"];
198 [createShipPanelTextField setStringValue:role];
201 [
NSApp runModalForWindow:createShipPanel];
202 [createShipPanel orderOut:
self];
191- (IBAction)createShipAction:sender {
…}
206- (IBAction)clearAllCachesAction:sender
206- (IBAction)clearAllCachesAction:sender {
…}
212- (IBAction)toggleWireframeModeAction:sender
214 [UNIVERSE setWireframeGraphics:![UNIVERSE wireframeGraphics]];
212- (IBAction)toggleWireframeModeAction:sender {
…}
218- (IBAction) hideShowHUD:sender
221 NSString *command = [
NSString stringWithFormat:@"player.ship.hudHidden = %@", hidden ? @"false" : @"true"];
218- (IBAction) hideShowHUD:sender {
…}
226- (IBAction) inspectPlayer:sender
226- (IBAction) inspectPlayer:sender {
…}
233- (IBAction) inspectTarget:sender
233- (IBAction) inspectTarget:sender {
…}
240- (IBAction) cleanUpInspectors:sender
240- (IBAction) cleanUpInspectors:sender {
…}
248 NSString *command = [
NSString stringWithFormat:@"console.setDisplayMessagesInClass(\"%@\", %@)", [
msgClass escapedForJavaScriptLiteral], display ? @"true" : @"false"];
253- (IBAction)toggleThisLogMessageClassAction:sender
255 NSString *msgClass =
nil;
257 if ([sender respondsToSelector:
@selector(representedObject)])
259 msgClass = [
sender representedObject];
253- (IBAction)toggleThisLogMessageClassAction:sender {
…}
265- (IBAction)otherLogMessageClassAction:sender
267 [
NSApp runModalForWindow:logMessageClassPanel];
268 [logMessageClassPanel orderOut:
self];
265- (IBAction)otherLogMessageClassAction:sender {
…}
272- (IBAction)logMsgClassPanelEnableAction:sender
274 NSString *msgClass =
nil;
276 msgClass = [logMsgClassPanelTextField stringValue];
272- (IBAction)logMsgClassPanelEnableAction:sender {
…}
283- (IBAction)logMsgClassPanelDisableAction:sender
285 NSString *msgClass =
nil;
287 msgClass = [logMsgClassPanelTextField stringValue];
283- (IBAction)logMsgClassPanelDisableAction:sender {
…}
294- (IBAction)toggleThisDebugFlagAction:sender
296 NSUInteger tag, bits;
297 NSString *command =
nil;
305 command = [
NSString stringWithFormat:@"console.debugFlags |= 0x%lX", tag];
310 command = [
NSString stringWithFormat:@"console.debugFlags &= ~0x%.lX", tag];
294- (IBAction)toggleThisDebugFlagAction:sender {
…}
317- (IBAction) setShaderModeToTag:(NSMenuItem *)sender
320 NSString *detailString = [OOStringFromGraphicsDetail(detail) escapedForJavaScriptLiteral];
321 NSString *command = [
NSString stringWithFormat:@"console.detailLevel = \"%@\"", detailString];
317- (IBAction) setShaderModeToTag:(NSMenuItem *)sender {
…}
327- (IBAction)showLogPreferencesAction:sender
329 [logShowFunctionCheckBox setState:OOLogShowFunction()];
330 [logShowFileAndLineCheckBox setState:OOLogShowFileAndLine()];
331 [logShowMessageClassCheckBox setState:OOLogShowMessageClass()];
332 [logShowTimeStampCheckBox setState:OOLogShowTime()];
327- (IBAction)showLogPreferencesAction:sender {
…}
338- (IBAction)logSetShowFunctionAction:sender
338- (IBAction)logSetShowFunctionAction:sender {
…}
344- (IBAction)logSetShowFileAndLineAction:sender
344- (IBAction)logSetShowFileAndLineAction:sender {
…}
350- (IBAction)logSetShowMessageClassAction:sender
350- (IBAction)logSetShowMessageClassAction:sender {
…}
356- (IBAction) logSetShowTimeStampAction:sender
356- (IBAction) logSetShowTimeStampAction:sender {
…}
362- (IBAction)insertLogSeparatorAction:sender
362- (IBAction)insertLogSeparatorAction:sender {
…}
368- (IBAction)createShipPanelOKAction:sender
370 NSString *shipRole =
nil;
372 shipRole = [createShipPanelTextField stringValue];
373 if ([shipRole length] != 0)
375 [
self performSelector:@selector(spawnShip:) withObject:shipRole afterDelay:0.1];
376 [[
NSUserDefaults standardUserDefaults] setObject:shipRole forKey:@"debug-create-ship-panel-last-role"];
368- (IBAction)createShipPanelOKAction:sender {
…}
383- (void)spawnShip:(NSString *)shipRole
385 NSString *command =
nil;
387 if (shipRole ==
nil)
return;
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]];
396 [UNIVERSE addShipWithRole:shipRole nearRouteOneAt:1.0];
383- (void)spawnShip:(NSString *)shipRole {
…}
401- (IBAction)modalPanelCancelAction:sender
401- (IBAction)modalPanelCancelAction:sender {
…}
409- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
412 NSString *msgClass =
nil;
413 NSUInteger tag, bits;
418 if (action ==
@selector(toggleThisLogMessageClassAction:))
420 msgClass = [
menuItem representedObject];
421 [
menuItem setState:OOLogWillDisplayMessagesInClass(msgClass)];
424 if (action ==
@selector(toggleThisDebugFlagAction:))
428 if (bits == 0) state = NSOffState;
429 else if (bits == tag) state = NSOnState;
430 else state = NSMixedState;
435 if (action ==
@selector(toggleWireframeModeAction:))
437 [
menuItem setState:!![UNIVERSE wireframeGraphics]];
440 if (action ==
@selector(inspectTarget:))
444 if (action ==
@selector(hideShowHUD:))
447 [
menuItem setTitle:hidden ? @"Show HUD" : @"Hide HUD"];
450 if (action ==
@selector(setShaderModeToTag:))
454 menuItem.state = (
UNIVERSE.detailLevel == itemLevel);
458 return [
self respondsToSelector:action];
409- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
…}
464 NSMenuItem *item =
nil;
467 [menu setTitle:@"Debug"];
468 item = [[
NSMenuItem alloc] initWithTitle:@"Debug" action:NULL keyEquivalent:@""];
469 [
item setSubmenu:menu];
470 [[
NSApp mainMenu] addItem:item];
473 if (![[NSUserDefaults standardUserDefaults] boolForKey:
@"debug-show-extra-menu-items"])
480 index = [menu indexOfItemWithTag:-42];
483 [menu removeItemAtIndex:index];
484 index = [menu indexOfItemWithTag:-42];
492 NSArray *definitions =
nil;
493 NSUInteger i,
count, inserted = 0;
494 NSString *title =
nil, *key =
nil;
495 NSMenuItem *item =
nil;
500 for (i = 0; i !=
count; ++i)
504 if (title ==
nil || key ==
nil)
continue;
506 item = [[
NSMenuItem alloc] initWithTitle:title
507 action:@selector(toggleThisLogMessageClassAction:)
509 [
item setTarget:
self];
510 [
item setRepresentedObject:key];
512 [logMessageClassSubMenu insertItem:item atIndex:inserted++];
520@implementation OODebugController (Singleton)
527+ (id)allocWithZone:(NSZone *)inZone
527+ (id)allocWithZone:(NSZone *)inZone {
…}
538- (id)copyWithZone:(NSZone *)inZone
538- (id)copyWithZone:(NSZone *)inZone {
…}
static OODebugMonitor * sSingleton
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
#define OOLog(class, format,...)
void OOLogSetShowFileAndLine(BOOL flag)
void OOLogSetShowTime(BOOL flag)
void OOLogSetShowFunction(BOOL flag)
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
void OOLogSetShowMessageClass(BOOL flag)
OOCacheManager * sharedCache()
void setUpLogMessageClassMenu()
NSString * pathForResource:ofType:(NSString *name,[ofType] NSString *type)
id< OODebuggerInterface > setUpDebugger()
static void SetDisplayLogMessagesInClassThroughJS(NSString *msgClass, BOOL display)
OODebugController * sharedDebugController()
oneway void performJSConsoleCommand:(in NSString *command)
OODebugMonitor * sharedDebugMonitor()
void resetGraphicsState()
OOGraphicsResetManager * sharedManager()
OOGraphicsDetail maximumDetailLevel()
OOOpenGLExtensionManager * sharedManager()
PlayerEntity * sharedPlayer()
NSArray * arrayFromFilesNamed:inFolder:andMerge:(NSString *fileName,[inFolder] NSString *folderName,[andMerge] BOOL mergeFiles)