-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainWindow.cs
87 lines (73 loc) · 2.03 KB
/
MainWindow.cs
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
using System;
using Cannon_GUI;
using Gtk;
using Pango;
/*
* GUI class
*/
public partial class MainWindow : Gtk.Window
{
protected TileManager manager;
public TextView LogBox { get => logBox; }
public Fixed BoardPanel { get => boardPanel; }
public RadioButton LightAI { get => lightAI; }
public RadioButton DarkAI { get => darkAI; }
public TileManager Manager { get => manager; }
public Label TimeLabel { get => timeLabel; }
public bool Quit = false;
public MainWindow() : base(Gtk.WindowType.Toplevel)
{
Build();
// Board background
boardImage.Pixbuf = new Gdk.Pixbuf($"images{Constants.Slash}board.{Constants.ImgExt}");
}
protected void OnDeleteEvent(object sender, DeleteEventArgs a)
{
//Application.Quit();
a.RetVal = true;
Quit = true;
}
protected void OnClick(object sender, EventArgs e)
{
Console.WriteLine("Click");
}
/*
* Switch players event
*/
protected void ChangeAI(object obj, EventArgs e) //TODO handle 2 agents
{
Gtk.RadioButton rb = (Gtk.RadioButton)obj;
if (rb.Active)
{
Console.WriteLine(rb.Name);
if (rb.Name == "darkAI")
{
MainClass.AI1.ChangePlayer(TileColor.Dark);
MainClass.Manager.ChangePlayer(TileColor.Light);
}
else if (rb.Name == "lightAI")
{
MainClass.AI1.ChangePlayer(TileColor.Light);
MainClass.Manager.ChangePlayer(TileColor.Dark);
}
MainClass.Manager.playing = MainClass.Manager.Player == TileColor.Dark;
MainClass.Reset();
}
}
/*
* Start a new game event
*/
protected void Reset(object obj, EventArgs e)
{
//MainClass.Manager.InitialPosition();
//MainClass.Clock.Reset();
MainClass.Reset();
}
/*
* Undo button event
*/
protected void Undo(object obj, EventArgs e)
{
MainClass.Undo();
}
}