Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
OOObjectDebugInspectorModule.m
Go to the documentation of this file.
1/*
2
3OOObjectDebugInspectorModule.m
4
5
6Oolite Debug Bundle
7
8Copyright © 2007-2013 Jens Ayton
9
10Permission is hereby granted, free of charge, to any person obtaining a copy
11of this software and associated documentation files (the “Software”), to deal
12in the Software without restriction, including without limitation the rights
13to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14copies of the Software, and to permit persons to whom the Software is
15furnished to do so, subject to the following conditions:
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26SOFTWARE.
27
28*/
29
31#import "PlayerEntity.h"
33
34
35@implementation OOObjectDebugInspectorModule
36
37- (void) awakeFromNib
38{
39 NSRect basicIDFrame, secondaryIDFrame, targetSelfFrame, rootFrame;
40 NSView *rootView = [self rootView];
41 CGFloat delta;
42
43 id object = [self object];
44
45 basicIDFrame = [_basicIdentityField frame];
46 secondaryIDFrame = [_secondaryIdentityField frame];
47 targetSelfFrame = [_targetSelfButton frame];
48 rootFrame = [rootView frame];
49
50 if (![object inspCanBecomeTarget])
51 {
52 // Remove targetSelfButton.
53 [_targetSelfButton removeFromSuperview];
55 basicIDFrame.size.width = secondaryIDFrame.size.width;
56 }
57
58 if (![object inspHasSecondaryIdentityLine])
59 {
60 // No secondary identity line, remove secondary identity field.
61 delta = basicIDFrame.origin.y - secondaryIDFrame.origin.y;
62 [_secondaryIdentityField removeFromSuperview];
64
65 rootFrame.size.height -= delta;
66 basicIDFrame.origin.y -= delta;
67 targetSelfFrame.origin.y -= delta;
68 }
69
70 // Put bits in the right place.
71 [rootView setFrame:rootFrame];
72 [_basicIdentityField setFrame:basicIDFrame];
73 [_secondaryIdentityField setFrame:secondaryIDFrame];
74 [_targetSelfButton setFrame:targetSelfFrame];
75}
76
77
78- (void) update
79{
80 id object = [self object];
81
82 if (object != nil) [_basicIdentityField setStringValue:[object inspBasicIdentityLine]];
84 {
85 if (object != nil)
86 {
87 [_secondaryIdentityField setStringValue:[object inspSecondaryIdentityLine] ?: InspectorUnknownValueString()];
88 }
89 else
90 {
91 [_secondaryIdentityField setStringValue:@"Dead"];
92 }
93 }
94}
95
96
97- (IBAction) targetSelf:sender
98{
99 [[self object] inspBecomeTarget];
100}
101
102@end
103
104
105@implementation NSObject (OOObjectDebugInspectorModule)
106
107- (NSArray *) debugInspectorModules
108{
109 return [[NSArray array] arrayByAddingInspectorModuleOfClass:[OOObjectDebugInspectorModule class]
110 forObject:(id)self];
111}
112
113@end
return nil