-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChessUIAppDelegate.m
More file actions
71 lines (61 loc) · 2.21 KB
/
ChessUIAppDelegate.m
File metadata and controls
71 lines (61 loc) · 2.21 KB
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
//
// ChessUIAppDelegate.m
// ChessUI
//
// Created by Michael Weingert on 12-01-21.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "ChessUIAppDelegate.h"
#import "ChessEngineWrapper.h"
@implementation ChessUIAppDelegate
@synthesize window, NewGameButton, MoveList, openGLView, AIGameButton, ResetBoard, PlayAgainstCPUButton;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
[NewGameButton setTitle:@"Make AI Move"];
[NewGameButton setAction: @selector(myButtonClick:)];
[AIGameButton setTitle:@"Play Match"];
[AIGameButton setAction: @selector(AIGameButtonClick:)];
[ResetBoard setTitle:@"Reset Board"];
[ResetBoard setAction: @selector(ResetBoardButtonClick:)];
[PlayAgainstCPUButton setTitle:@"Play CPU?"];
[PlayAgainstCPUButton setAction: @selector(PlayAgainstCPUButtonClick:)];
//[NewGameButton addTarget:self action:@selector(myButtonClick:)
// forControlEvents:(UIControlEvents)UIControlEventTouchDown];
[MoveList setStringValue: @"Welcome to Mikey's Chess Game :)"];
[MoveList setEnabled:FALSE];
[MoveList setEditable:FALSE];
[[ChessEngineWrapper getInstance]SetMoveList:MoveList];
[[ChessEngineWrapper getInstance]UpdateMoveList];
[[ChessEngineWrapper getInstance]SetOpenGLView:openGLView];
[[ChessEngineWrapper getInstance]SetButtons:NewGameButton : AIGameButton : PlayAgainstCPUButton];
}
-(IBAction) myButtonClick: (id)sender
{
[sender setEnabled:NO];
[[ChessEngineWrapper getInstance]GenerateTree];
[openGLView setNeedsDisplay:true];
}
-(IBAction) AIGameButtonClick: (id)sender
{
[sender setEnabled: NO];
//[[ChessEngineWrapper getInstance]ResetBoard];
[[ChessEngineWrapper getInstance]PlayMatch];
[openGLView setNeedsDisplay:true];
//[sender setEnabled:YES];
}
-(IBAction) ResetBoardButtonClick: (id)sender
{
[[ChessEngineWrapper getInstance]ResetBoard];
[[PieceQueue getInstance]ResetQueue];
[[ChessEngineWrapper getInstance]UpdateBoard];
[openGLView setNeedsDisplay:true];
}
-(IBAction) PlayAgainstCPUButtonClick: (id)sender
{
[[ChessEngineWrapper getInstance]SetPlayAgainstCPU: true];
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication
{
return YES;
}
@end