Subversion Repositories eduke32

Rev

Rev 7291 | Rev 8351 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2396 hendricks2 1
 
2
3
 
4
#include "game.h"
2430 helixhorne 5
#include "common.h"
2726 hendricks2 6
#include "common_game.h"
7
#include "build.h"
2396 hendricks2 8
#include "compat.h"
9
#include "baselayer.h"
10
#include "grpscan.h"
11
12
 
13
#import "GameListSource.game.h"
14
15
 
6109 hendricks2 16
# define NSImageScaleNone NSScaleNone
17
#endif
18
19
 
20
# define NSEventModifierFlagOption NSAlternateKeyMask
21
# define NSEventModifierFlagCommand NSCommandKeyMask
22
# define NSEventMaskAny NSAnyEventMask
23
# define NSWindowStyleMaskTitled NSTitledWindowMask
24
# define NSWindowStyleMaskClosable NSClosableWindowMask
25
# define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
26
# define NSWindowStyleMaskResizable NSResizableWindowMask
27
# define NSAlertStyleInformational NSInformationalAlertStyle
28
# define NSControlSizeSmall NSSmallControlSize
29
#endif
30
31
 
7688 hendricks2 32
# define NSButtonTypeSwitch NSSwitchButton
33
# define NSBezelStyleRounded NSRoundedBezelStyle
34
# define NSControlStateValueOn NSOnState
35
# define NSControlStateValueOff NSOffState
36
#endif
37
38
 
5975 hendricks2 39
{
5964 hendricks2 40
    return NSMakeRect(x, y, rect.size.width, rect.size.height);
5975 hendricks2 41
}
5964 hendricks2 42
static NSRect NSSizeAddXY(NSSize const size, CGFloat const x, CGFloat const y)
5975 hendricks2 43
{
5964 hendricks2 44
    return NSMakeRect(x, y, size.width, size.height);
5975 hendricks2 45
}
5964 hendricks2 46
#if 0
47
static CGFloat NSRightEdge(NSRect rect)
5975 hendricks2 48
{
5964 hendricks2 49
    return rect.origin.x + rect.size.width;
50
}
51
#endif
52
static CGFloat NSTopEdge(NSRect rect)
5975 hendricks2 53
{
5964 hendricks2 54
    return rect.origin.y + rect.size.height;
55
}
56
57
 
58
{
59
    [control setFont:[NSFont fontWithDescriptor:[[control font] fontDescriptor] size:[NSFont smallSystemFontSize]]];
60
}
61
62
 
63
{
64
    [control setControlSize:NSControlSizeSmall];
65
}
66
67
 
68
{
69
    NSTextField *textField = [[NSTextField alloc] init];
70
    setFontToSmall(textField);
71
    setControlToSmall([textField cell]);
72
    [textField setStringValue:labelText];
73
    [textField setBezeled:NO];
74
    [textField setDrawsBackground:NO];
75
    [textField setEditable:NO];
76
    [textField setSelectable:NO];
77
    [textField sizeToFit];
78
    return textField;
79
}
80
81
 
82
{
83
    NSButton *checkbox = [[NSButton alloc] init];
84
    setFontToSmall(checkbox);
85
    setControlToSmall([checkbox cell]);
86
    [checkbox setTitle:labelText];
87
    [checkbox setButtonType:NSButtonTypeSwitch];
7688 hendricks2 88
    [checkbox sizeToFit];
5964 hendricks2 89
    return checkbox;
90
}
91
92
 
93
{
94
    NSPopUpButton *comboBox = [[NSPopUpButton alloc] init];
95
    [comboBox setPullsDown:NO];
96
    setFontToSmall(comboBox);
97
    setControlToSmall([comboBox cell]);
98
    [comboBox setBezelStyle:NSBezelStyleRounded];
7688 hendricks2 99
    [comboBox setPreferredEdge:NSMaxYEdge];
5964 hendricks2 100
    [[comboBox cell] setArrowPosition:NSPopUpArrowAtCenter];
101
    [comboBox sizeToFit];
102
    return comboBox;
103
}
104
105
 
2429 helixhorne 106
107
 
5966 hendricks2 108
@interface NSApplication(NSAppleMenu)
109
- (void)setAppleMenu:(NSMenu *)menu;
110
@end
111
112
 
113
{
114
    NSString *appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
115
    if (!appName)
116
        appName = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"];
117
    if (![appName length])
118
        appName = [[NSProcessInfo processInfo] processName];
119
120
 
121
}
122
123
 
124
{
125
    NSString *appName;
126
    NSString *title;
127
    NSMenu *rootMenu;
128
    NSMenu *serviceMenu;
129
    NSMenuItem *menuItem;
130
131
 
132
133
 
134
    appName = GetApplicationName();
135
    rootMenu = [[NSMenu alloc] init];
136
137
 
138
    menuItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
139
    [menuItem setSubmenu:rootMenu];
140
    [mainMenu addItem:menuItem];
141
    [menuItem release];
142
143
 
144
    title = [@"About " stringByAppendingString:appName];
145
    [rootMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
146
147
 
148
149
 
150
    menuItem = (NSMenuItem *)[rootMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
151
    [menuItem setSubmenu:serviceMenu];
152
153
 
154
    [serviceMenu release];
155
156
 
157
158
 
159
    [rootMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];
160
161
 
162
    [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];
6109 hendricks2 163
5966 hendricks2 164
 
165
166
 
167
168
 
169
    [rootMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
170
171
 
172
    [nsapp setMainMenu:mainMenu];
173
    [mainMenu release];  /* we're done with it, let NSApp own it. */
174
175
 
176
    [nsapp setAppleMenu:rootMenu];
177
    [rootMenu release];
178
}
179
180
 
5965 hendricks2 181
182
 
2396 hendricks2 183
    grpfile_t const * grp;
5103 hendricks2 184
    int fullscreen;
2396 hendricks2 185
    int xdim3d, ydim3d, bpp3d;
186
    int forcesetup;
187
} settings;
188
189
 
5964 hendricks2 190
{
2396 hendricks2 191
    NSMutableArray *modeslist3d;
192
    GameListSource *gamelistsrc;
193
2431 helixhorne 194
 
5964 hendricks2 195
    NSButton *fullscreenButton;
196
    NSTextView *messagesView;
197
    NSTabView *tabView;
198
    NSTabViewItem *tabViewItemSetup;
199
    NSTabViewItem *tabViewItemMessageLog;
200
    NSPopUpButton *videoMode3DPUButton;
201
    NSScrollView *gameList;
202
2431 helixhorne 203
 
5964 hendricks2 204
    NSButton *startButton;
205
}
2396 hendricks2 206
207
 
5964 hendricks2 208
209
 
2396 hendricks2 210
- (void)populateVideoModes:(BOOL)firstTime;
211
212
 
5964 hendricks2 213
2396 hendricks2 214
 
5964 hendricks2 215
- (void)start:(id)sender;
216
2396 hendricks2 217
 
218
- (void)setupMessagesMode;
219
5964 hendricks2 220
 
2396 hendricks2 221
222
 
223
224
 
5964 hendricks2 225
2396 hendricks2 226
 
5964 hendricks2 227
{
228
    NSUInteger const style = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskMiniaturizable | NSWindowStyleMaskResizable;
6109 hendricks2 229
    NSRect const windowFrame = NSMakeRect(0, 0, 480, 280);
5975 hendricks2 230
    self = [super initWithContentRect:windowFrame styleMask:style backing:NSBackingStoreBuffered defer:NO];
5964 hendricks2 231
232
 
233
    {
234
        // window properties
235
        [self setDelegate:self];
236
        [self setReleasedWhenClosed:NO];
237
#if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
238
        [self setContentMinSize:[[self contentView] frame].size];
239
#else
240
        [self setMinSize:[NSWindow frameRectForContentRect:[[self contentView] frame] styleMask:[self styleMask]].size];
241
#endif
242
243
 
244
 
245
        NSRect const imageFrame = NSMakeRect(0, 0, 100, 280);
5975 hendricks2 246
        NSImageView * imageView = [[NSImageView alloc] initWithFrame:imageFrame];
5964 hendricks2 247
        [imageView setImageScaling:NSImageScaleNone];
248
        [imageView setImage:[NSImage imageNamed:@"game"]];
249
        [[self contentView] addSubview:imageView];
250
        [imageView setAutoresizingMask:NSViewMaxXMargin | NSViewHeightSizable];
251
252
 
253
 
254
        CGFloat const buttonWidth = 80;
255
        CGFloat const buttonHeight = 32;
256
257
 
5975 hendricks2 258
        startButton = [[NSButton alloc] initWithFrame:startButtonFrame];
5964 hendricks2 259
        [[self contentView] addSubview:startButton];
260
        [startButton setTitle:@"Start"];
261
        [startButton setTarget:self];
262
        [startButton setAction:@selector(start:)];
263
        [startButton setBezelStyle:NSBezelStyleRounded];
7688 hendricks2 264
        [startButton setKeyEquivalent:@"\r"];
5964 hendricks2 265
        [startButton setAutoresizingMask:NSViewMinXMargin | NSViewMaxYMargin];
266
267
 
5975 hendricks2 268
        cancelButton = [[NSButton alloc] initWithFrame:cancelButtonFrame];
5964 hendricks2 269
        [[self contentView] addSubview:cancelButton];
270
        [cancelButton setTitle:@"Cancel"];
271
        [cancelButton setTarget:self];
272
        [cancelButton setAction:@selector(cancel:)];
273
        [cancelButton setBezelStyle:NSBezelStyleRounded];
7688 hendricks2 274
        [cancelButton setAutoresizingMask:NSViewMinXMargin | NSViewMaxYMargin];
5964 hendricks2 275
276
 
277
 
278
        NSRect const tabViewFrame = NSMakeRect(imageFrame.size.width, buttonHeight, windowFrame.size.width - imageFrame.size.width, windowFrame.size.height - buttonHeight - 5);
5975 hendricks2 279
        tabView = [[NSTabView alloc] initWithFrame:tabViewFrame];
5964 hendricks2 280
        [[self contentView] addSubview:tabView];
281
        setFontToSmall(tabView);
282
        setControlToSmall(tabView);
283
        [tabView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
284
285
 
286
 
287
288
 
289
        [tabView addTabViewItem:tabViewItemSetup];
290
        [tabViewItemSetup setLabel:@"Setup"];
291
        NSRect const tabViewItemSetupFrame = [[tabViewItemSetup view] frame];
5975 hendricks2 292
5964 hendricks2 293
 
294
 
295
        alwaysShowButton = makeCheckbox(@"Always show this window at startup");
296
        [[tabViewItemSetup view] addSubview:alwaysShowButton];
297
        NSSize const alwaysShowButtonSize = [alwaysShowButton frame].size;
5975 hendricks2 298
        NSRect const alwaysShowButtonFrame = NSSizeAddXY(alwaysShowButtonSize, tabViewItemSetupFrame.size.width - alwaysShowButtonSize.width, 0);
299
        [alwaysShowButton setFrame:alwaysShowButtonFrame];
5964 hendricks2 300
        [alwaysShowButton setAutoresizingMask:NSViewMinXMargin | NSViewMaxYMargin];
301
302
 
303
 
304
        NSTextField * labelVideoMode = makeLabel(@"Video mode:");
305
        [[tabViewItemSetup view] addSubview:labelVideoMode];
306
        NSSize const labelVideoModeSize = [labelVideoMode frame].size;
5975 hendricks2 307
        [labelVideoMode setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin];
5964 hendricks2 308
309
 
310
        [[tabViewItemSetup view] addSubview:fullscreenButton];
311
        NSSize const fullscreenButtonSize = [fullscreenButton frame].size;
5975 hendricks2 312
        [fullscreenButton setAction:@selector(fullscreenClicked:)];
5964 hendricks2 313
        [fullscreenButton setAutoresizingMask:NSViewMinXMargin | NSViewMinYMargin];
314
315
 
316
        [[tabViewItemSetup view] addSubview:videoMode3DPUButton];
317
        NSSize const videoMode3DPUButtonSize = [videoMode3DPUButton frame].size;
5975 hendricks2 318
        CGFloat const videoMode3DButtonX = labelVideoModeSize.width; // NSRightEdge(labelVideoModeFrame);
319
        NSRect const videoMode3DPUButtonFrame = NSMakeRect(videoMode3DButtonX, tabViewItemSetupFrame.size.height - videoMode3DPUButtonSize.height, tabViewItemSetupFrame.size.width - videoMode3DButtonX - fullscreenButtonSize.width, videoMode3DPUButtonSize.height);
320
        [videoMode3DPUButton setFrame:videoMode3DPUButtonFrame];
5964 hendricks2 321
        [videoMode3DPUButton setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin];
322
323
 
5975 hendricks2 324
        [labelVideoMode setFrame:labelVideoModeFrame];
5964 hendricks2 325
326
 
5975 hendricks2 327
        [fullscreenButton setFrame:fullscreenButtonFrame];
5964 hendricks2 328
329
 
330
 
331
        NSTextField * labelGame = makeLabel(@"Game:");
332
        [[tabViewItemSetup view] addSubview:labelGame];
333
        NSSize const labelGameSize = [labelGame frame].size;
5975 hendricks2 334
        NSRect const labelGameFrame = NSSizeAddXY(labelGameSize, 0, videoMode3DPUButtonFrame.origin.y - labelGameSize.height);
335
        [labelGame setFrame:labelGameFrame];
5964 hendricks2 336
        [labelGame setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin];
337
338
 
339
        CGFloat const gameListY = NSTopEdge(alwaysShowButtonFrame) + gameListVerticalPadding;
5975 hendricks2 340
        NSRect const gameListFrame = NSMakeRect(0, gameListY, tabViewItemSetupFrame.size.width, labelGameFrame.origin.y - gameListY - gameListVerticalPadding);
341
        gameList = [[NSScrollView alloc] initWithFrame:gameListFrame];
5964 hendricks2 342
        [[tabViewItemSetup view] addSubview:gameList];
343
        [gameList setBorderType:NSBezelBorder];
344
        [gameList setHasVerticalScroller:YES];
345
        [gameList setHasHorizontalScroller:NO];
346
        setControlToSmall([[gameList verticalScroller] cell]);
347
        NSSize const gameListContentSize = [gameList contentSize];
348
        [gameList setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
349
350
 
351
        [gameList setDocumentView:gameListTable];
352
353
 
354
        [gameListTable addTableColumn:nameColumn];
355
        NSTableColumn * fileColumn = [[NSTableColumn alloc] initWithIdentifier:@"1"];
356
        [gameListTable addTableColumn:fileColumn];
357
        [nameColumn setEditable:NO];
358
        [[nameColumn headerCell] setStringValue:@"Name"];
359
        [nameColumn setWidth:gameListContentSize.width * (2.f/3.f)];
360
        [fileColumn setEditable:NO];
361
        [[fileColumn headerCell] setStringValue:@"File"];
362
        [gameListTable sizeLastColumnToFit];
363
        [gameListTable setAutoresizingMask:NSViewWidthSizable];
364
365
 
366
 
367
368
 
369
        [tabView addTabViewItem:tabViewItemMessageLog];
370
        [tabViewItemMessageLog setLabel:@"Message Log"];
371
        NSRect const tabViewItemMessageLogFrame = [[tabViewItemMessageLog view] frame];
5975 hendricks2 372
5964 hendricks2 373
 
374
 
375
        NSScrollView * messagesScrollView = [[NSScrollView alloc] initWithFrame:NSRectChangeXY(tabViewItemMessageLogFrame, 0, 0)];
5975 hendricks2 376
        [[tabViewItemMessageLog view] addSubview:messagesScrollView];
5964 hendricks2 377
        [messagesScrollView setBorderType:NSBezelBorder];
378
        [messagesScrollView setHasVerticalScroller:YES];
379
        [messagesScrollView setHasHorizontalScroller:NO];
380
        setControlToSmall([[messagesScrollView verticalScroller] cell]);
381
        NSSize const messagesScrollViewContentSize = [messagesScrollView contentSize];
382
        [messagesScrollView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
383
384
 
5975 hendricks2 385
        [messagesScrollView setDocumentView:messagesView];
5964 hendricks2 386
        [messagesView setEditable:NO];
387
        [messagesView setRichText:NO];
388
        setFontToSmall(messagesView);
389
        [messagesView setMinSize:NSMakeSize(0.0, messagesScrollViewContentSize.height)];
5975 hendricks2 390
        [messagesView setMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
391
        [messagesView setVerticallyResizable:YES];
5964 hendricks2 392
        [messagesView setHorizontallyResizable:NO];
393
        [messagesView setAutoresizingMask:NSViewWidthSizable];
394
395
 
5975 hendricks2 396
        [[messagesView textContainer] setWidthTracksTextView:YES];
5964 hendricks2 397
    }
398
399
 
400
}
401
402
 
403
{
404
    return YES;
405
}
406
407
 
408
{
409
    return YES;
410
}
411
412
 
413
{
414
    UNREFERENCED_PARAMETER(sender);
415
416
 
5965 hendricks2 417
5964 hendricks2 418
 
419
}
420
421
 
2396 hendricks2 422
{
423
    [gamelistsrc release];
424
    [modeslist3d release];
425
    [super dealloc];
426
}
427
428
 
429
{
430
    int i, mode3d, fullscreen = ([fullscreenButton state] == NSControlStateValueOn);
7688 hendricks2 431
    int idx3d = -1;
2396 hendricks2 432
    int xdim = 0, ydim = 0, bpp = 0;
4644 hendricks2 433
2431 helixhorne 434
 
2396 hendricks2 435
        xdim = settings.xdim3d;
436
        ydim = settings.ydim3d;
437
        bpp  = settings.bpp3d;
438
    } else {
439
        mode3d = [[modeslist3d objectAtIndex:[videoMode3DPUButton indexOfSelectedItem]] intValue];
440
        if (mode3d >= 0) {
441
            xdim = validmode[mode3d].xdim;
442
            ydim = validmode[mode3d].ydim;
443
            bpp = validmode[mode3d].bpp;
444
        }
445
2431 helixhorne 446
 
2396 hendricks2 447
    mode3d = videoCheckMode(&xdim, &ydim, bpp, fullscreen, 1);
6855 terminx 448
    if (mode3d < 0) {
2396 hendricks2 449
        int i, cd[] = { 32, 24, 16, 15, 8, 0 };
450
        for (i=0; cd[i]; ) { if (cd[i] >= bpp) i++; else break; }
451
        for ( ; cd[i]; i++) {
452
            mode3d = videoCheckMode(&xdim, &ydim, cd[i], fullscreen, 1);
6855 terminx 453
            if (mode3d < 0) continue;
2396 hendricks2 454
            break;
455
        }
456
    }
457
2431 helixhorne 458
 
2396 hendricks2 459
    [videoMode3DPUButton removeAllItems];
460
2431 helixhorne 461
 
2396 hendricks2 462
2431 helixhorne 463
 
2396 hendricks2 464
        if (fullscreen == validmode[i].fs) {
465
            if (i == mode3d) idx3d = [modeslist3d count];
466
            [modeslist3d addObject:[NSNumber numberWithInt:i]];
467
            [videoMode3DPUButton addItemWithTitle:[NSString stringWithFormat:@"%d %C %d %d-bpp",
468
                                                   validmode[i].xdim, 0xd7, validmode[i].ydim, validmode[i].bpp]];
469
        }
470
    }
471
2431 helixhorne 472
 
2396 hendricks2 473
}
474
475
 
5964 hendricks2 476
{
2396 hendricks2 477
    UNREFERENCED_PARAMETER(sender);
4647 hendricks2 478
2396 hendricks2 479
 
480
}
481
482
 
5964 hendricks2 483
{
2396 hendricks2 484
    UNREFERENCED_PARAMETER(sender);
4647 hendricks2 485
4644 hendricks2 486
 
5965 hendricks2 487
}
2396 hendricks2 488
489
 
5964 hendricks2 490
{
2396 hendricks2 491
    UNREFERENCED_PARAMETER(sender);
4647 hendricks2 492
4644 hendricks2 493
 
2396 hendricks2 494
    if (mode >= 0) {
495
        settings.xdim3d = validmode[mode].xdim;
496
        settings.ydim3d = validmode[mode].ydim;
497
        settings.bpp3d = validmode[mode].bpp;
498
        settings.fullscreen = validmode[mode].fs;
499
    }
500
2431 helixhorne 501
 
2396 hendricks2 502
    if (row >= 0) {
503
        settings.grp = [[gamelistsrc grpAtIndex:row] entryptr];
5103 hendricks2 504
    }
2396 hendricks2 505
2431 helixhorne 506
 
7688 hendricks2 507
2431 helixhorne 508
 
5965 hendricks2 509
}
2396 hendricks2 510
511
 
512
{
513
    videoGetModes();
6855 terminx 514
2431 helixhorne 515
 
7688 hendricks2 516
    [alwaysShowButton setState: (settings.forcesetup ? NSControlStateValueOn : NSControlStateValueOff)];
517
    [self populateVideoModes:YES];
2396 hendricks2 518
2431 helixhorne 519
 
2396 hendricks2 520
    NSEnumerator *enumerator = [[[tabViewItemSetup view] subviews] objectEnumerator];
5964 hendricks2 521
    NSControl *control;
2396 hendricks2 522
    while ((control = [enumerator nextObject]))
5964 hendricks2 523
    {
524
        if ([control respondsToSelector:@selector(setEnabled:)])
525
            [control setEnabled:true];
526
    }
527
2431 helixhorne 528
 
2396 hendricks2 529
    [[gameList documentView] setDataSource:gamelistsrc];
530
    [[gameList documentView] deselectAll:nil];
531
2431 helixhorne 532
 
6448 hendricks2 533
    {
534
        int row = [gamelistsrc findIndexForGrpname:[NSString stringWithUTF8String:settings.grp->filename]];
535
        if (row >= 0)
536
        {
537
            [[gameList documentView] scrollRowToVisible:row];
538
#if defined MAC_OS_X_VERSION_10_3 && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_3
5964 hendricks2 539
            [[gameList documentView] selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
6448 hendricks2 540
#else
2396 hendricks2 541
            [[gameList documentView] selectRow:row byExtendingSelection:NO];
6448 hendricks2 542
#endif
2396 hendricks2 543
        }
6448 hendricks2 544
    }
2396 hendricks2 545
2431 helixhorne 546
 
2396 hendricks2 547
    [startButton setEnabled:true];
548
2431 helixhorne 549
 
5964 hendricks2 550
    [NSCursor unhide]; // Why should I need to do this?
4647 hendricks2 551
}
2396 hendricks2 552
553
 
554
{
555
    [tabView selectTabViewItem:tabViewItemMessageLog];
5964 hendricks2 556
2431 helixhorne 557
 
2396 hendricks2 558
    // user can enable it if they want to while waiting for something else to happen
559
    NSEnumerator *enumerator = [[[tabViewItemSetup view] subviews] objectEnumerator];
5964 hendricks2 560
    NSControl *control;
2396 hendricks2 561
    while ((control = [enumerator nextObject]))
5964 hendricks2 562
    {
563
        if (control != alwaysShowButton && [control respondsToSelector:@selector(setEnabled:)])
564
            [control setEnabled:false];
565
    }
2396 hendricks2 566
2431 helixhorne 567
 
2396 hendricks2 568
    [startButton setEnabled:false];
569
}
570
571
 
572
{
573
    NSRange end;
574
    NSTextStorage *text = [messagesView textStorage];
575
    BOOL shouldAutoScroll;
576
2431 helixhorne 577
 
2396 hendricks2 578
2431 helixhorne 579
 
2396 hendricks2 580
    end.length = 0;
581
2431 helixhorne 582
 
2396 hendricks2 583
    [messagesView replaceCharactersInRange:end withString:str];
584
    [text endEditing];
585
2431 helixhorne 586
 
2396 hendricks2 587
        end.location = [text length];
588
        end.length = 0;
589
        [messagesView scrollRangeToVisible:end];
590
    }
591
}
592
593
 
594
595
 
5964 hendricks2 596
2396 hendricks2 597
 
598
{
599
    // fix for "ld: absolute address to symbol _NSApp in a different linkage unit not supported"
2429 helixhorne 600
    // (OS X 10.6) when building for PPC
601
    nsapp = [NSApplication sharedApplication];
602
603
 
2396 hendricks2 604
2431 helixhorne 605
 
5964 hendricks2 606
    if (startwin == nil) return -1;
2396 hendricks2 607
2431 helixhorne 608
 
2396 hendricks2 609
2431 helixhorne 610
 
5967 hendricks2 611
612
 
613
    [startwin makeKeyAndOrderFront:nil];
614
615
 
616
617
 
2396 hendricks2 618
}
619
620
 
621
{
622
    if (startwin == nil) return 1;
623
2431 helixhorne 624
 
2396 hendricks2 625
    [startwin release];
626
    startwin = nil;
627
2431 helixhorne 628
 
2396 hendricks2 629
}
630
631
 
632
{
633
    NSString *ns;
634
2431 helixhorne 635
 
2396 hendricks2 636
    if (startwin == nil) return 1;
637
2431 helixhorne 638
 
5964 hendricks2 639
    [startwin putsMessage:ns];
2396 hendricks2 640
    [ns release];
641
2431 helixhorne 642
 
2396 hendricks2 643
}
644
645
 
646
{
647
    NSString *ns;
648
2431 helixhorne 649
 
2396 hendricks2 650
    if (startwin == nil) return 1;
651
2431 helixhorne 652
 
5964 hendricks2 653
    [startwin setTitle:ns];
2396 hendricks2 654
    [ns release];
655
2431 helixhorne 656
 
2396 hendricks2 657
}
658
659
 
660
{
661
    UNREFERENCED_PARAMETER(v);
4647 hendricks2 662
663
 
5967 hendricks2 664
    {
665
        NSEvent *event;
666
        do
667
        {
668
            event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate date] inMode:NSDefaultRunLoopMode dequeue:YES];
6109 hendricks2 669
            [nsapp sendEvent:event];
5967 hendricks2 670
        }
671
        while (event != nil);
672
673
 
674
        [nsapp updateWindows];
675
    }
676
677
 
2396 hendricks2 678
}
679
680
 
681
 
682
{
683
    if (startwin == nil) return 0;
684
2431 helixhorne 685
 
7241 terminx 686
    settings.xdim3d = ud.setup.xdim;
687
    settings.ydim3d = ud.setup.ydim;
688
    settings.bpp3d = ud.setup.bpp;
689
    settings.forcesetup = ud.setup.forcesetup;
7291 terminx 690
    settings.grp = g_selectedGrp;
5103 hendricks2 691
2431 helixhorne 692
 
2396 hendricks2 693
2431 helixhorne 694
 
5965 hendricks2 695
    {
696
        NSEvent *event = [nsapp nextEventMatchingMask:NSEventMaskAny untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
6109 hendricks2 697
        [nsapp sendEvent:event];
5965 hendricks2 698
        [nsapp updateWindows];
699
    }
2396 hendricks2 700
    while (retval == -1);
5965 hendricks2 701
2431 helixhorne 702
 
2396 hendricks2 703
    [nsapp updateWindows];
5967 hendricks2 704
2431 helixhorne 705
 
2396 hendricks2 706
        ud.setup.fullscreen = settings.fullscreen;
7241 terminx 707
        ud.setup.xdim = settings.xdim3d;
708
        ud.setup.ydim = settings.ydim3d;
709
        ud.setup.bpp = settings.bpp3d;
710
        ud.setup.forcesetup = settings.forcesetup;
711
        g_selectedGrp = settings.grp;
5103 hendricks2 712
    }
2396 hendricks2 713
2431 helixhorne 714
 
2396 hendricks2 715
}
716