blob: 2ee9623fe7cb4d1209f515bec0c142d43809c0f0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
//
// WorldSettingsController.m
// Moxie
//
// Created by Brian Cully on Thu Jan 01 2004.
// Copyright (c) 2004 Brian Cully. All rights reserved.
//
#import "WorldSettingsController.h"
#import "World.h"
@implementation WorldSettingsController
+ (WorldSettingsController *)sharedController
{
static WorldSettingsController *sharedController = nil;
if (sharedController == nil) {
sharedController = [[WorldSettingsController alloc] init];
}
return sharedController;
}
- (id)init
{
self = [self initWithWindowNibName: @"WorldSettings"];
[self setWindowFrameAutosaveName: @"worldSettingsWindow"];
return self;
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
[super dealloc];
}
- (void)setMainWindow: (NSWindow *)aWindow
{
World *world;
world = [[aWindow windowController] document];
if ([world isKindOfClass: [World class]]) {
// XXX: this needs to be pluginified
[self setSettings: [world settings]];
}
}
- (void)windowDidLoad
{
NSNotificationCenter *defaultCenter;
[super windowDidLoad];
[self setMainWindow: [NSApp mainWindow]];
defaultCenter = [NSNotificationCenter defaultCenter];
[defaultCenter addObserver: self
selector: @selector(mainWindowChanged:)
name: NSWindowDidBecomeMainNotification
object: nil];
[defaultCenter addObserver: self
selector: @selector(mainWindowResigned:)
name: NSWindowDidResignMainNotification
object: nil];
}
- (void)mainWindowChanged: (NSNotification *)aNotification
{
[self setMainWindow: [aNotification object]];
}
- (void)mainWindowResigned: (NSNotification *)aNotification
{
[self setMainWindow: nil];
}
- (void)changeFont: (id)sender
{
NSFont *oldFont, *newFont;
oldFont = [[self settings] font];
newFont = [sender convertFont: oldFont];
[[self settings] setFont: newFont];
}
- (IBAction)saveSettingsAsDefault: (id)sender
{
[[NSUserDefaults standardUserDefaults] setDefaultsFromWorldSettings: [self settings]];
}
- (IBAction)openLogDirectory: (id)sender
{
[[NSWorkspace sharedWorkspace] openFile: [[NSUserDefaults standardUserDefaults] logDirectory]];
}
- (void)showHostSettingsTab
{
[self showWindow: self];
[theTabView selectTabViewItem: theHostSettingsTab];
}
@end
@implementation WorldSettingsController (Accessors)
- (MxWorldSettings *)settings
{
return [theSettingsController content];
}
- (void)setSettings: (MxWorldSettings *)someSettings
{
[theSettingsController setContent: someSettings];
}
@end
|