forked from wT-/TekkenBot
-
Notifications
You must be signed in to change notification settings - Fork 45
/
GUI_FrameTrapBot.py
131 lines (98 loc) · 4.67 KB
/
GUI_FrameTrapBot.py
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
"""
A GUI that launches the frame trap bot, to practice frame traps on. The move the bot does out of block can be changed.
"""
from tkinter import *
from tkinter.ttk import *
from _TekkenBotLauncher import TekkenBotLauncher
from BotFrameTrap import BotFrameTrap
import sys
class GUI_FrameTrapBot(Tk):
def __init__(self):
Tk.__init__(self)
self.wm_title("Tekken Bot")
self.geometry(str(720) + 'x' + str(720))
#self.configure(background='white')
#self.wm_attributes("-transparentcolor", "white")
#self.attributes("-alpha", "0.80")
Style().theme_use('alt')
self.DoStyleNotebook()
#self.s = Style()
#self.s.configure('TNotebook', background='black')
self.controller_select_radio = self.GetRadiobuttonFrame()
self.note = Notebook(self, width=999, height=50)
self.frame_bot = FrameTrapBotTab(self.note)
self.dummy_tab1 = Frame(self.note)
self.dummy_tab2 = Frame(self.note)
self.dummy_tab3 = Frame(self.note)
Grid.columnconfigure(self, 0, weight=0)
Grid.columnconfigure(self, 1, weight=0)
#Grid.columnconfigure(self, 2, weight=0)
Grid.rowconfigure(self, 0, weight=0)
Grid.rowconfigure(self, 1, weight=1)
self.frame_bot.frame.grid(row=0, column=0)
self.note.add(self.frame_bot.frame, text = "Frame Trap Bot")
self.note.add(self.dummy_tab1, text="dummy bot")
self.note.add(self.dummy_tab2, text="dummy bot")
self.note.add(self.dummy_tab3, text="dummy bot")
self.controller_select_radio.grid(row=0, column=0, sticky=W)
self.note.grid(row=1, column=0, columnspan=2, sticky=N+S+E+W)
def DoStyleNotebook(self):
myTabBarColor = 'black'
myActiveTabBackgroundColor = 'gray22'
myActiveTabForegroundColor = 'green'
myTabBackgroundColor = 'black'
myTabForegroundColor = 'green'
Style().configure("TNotebook", background=myTabBarColor, foreground=myTabBarColor);
Style().map("TNotebook.Tab", background=[("selected", myActiveTabBackgroundColor)],
foreground=[("selected", myActiveTabForegroundColor)]);
Style().configure("TNotebook.Tab", background=myTabBackgroundColor, foreground=myTabForegroundColor, font=("Consolas", 18));
def GetRadiobuttonFrame(self):
player_var = IntVar()
radio_frame = Frame(self)
radio_label = Label(radio_frame, text="Bot Controls:")
radio_player_2 = Radiobutton(radio_frame, text='Player 2 (right side)', variable=player_var, value=2)
radio_player_1 = Radiobutton(radio_frame, text='Player 1 (left side)', variable=player_var, value=1)
radio_label.grid(row=0, column = 0, sticky=W)
radio_player_2.grid(row=1, column=1, sticky=W)
radio_player_1.grid(row=1, column=0, sticky=W)
#cell.grid(row=2, column=1, sticky=W)
return radio_frame
def update_launcher(self):
self.frame_bot.update()
self.after(7, self.update_launcher)
class FrameTrapBotTab():
def __init__(self, notebook):
self.frame = Frame(notebook)
self.launcher = TekkenBotLauncher(BotFrameTrap, False)
self.notation_display = NotationDisplayEntry(self.frame, self.launcher.GetBot())
self.notation_display.frame.grid(row=0, column=0, sticky=N + S + E + W)
Style().configure('TFrame', background='black')
def update(self):
self.launcher.GetBot().SetFrameTrapCommandFromNotationString(self.notation_display.entry_var.get())
self.launcher.Update()
class NotationDisplayEntry():
def __init__(self, parent, bot):
self.bot = bot
self.frame = Frame(parent)
self.entry_var = StringVar()
self.entry_var.set("+4")
self.entry = Entry(self.frame, textvariable=self.entry_var, font=("Consolas", 44))
self.entry.configure(state="normal")
self.recording = False
self.button_record = Button(self.frame, text="Record")
self.button_record.bind("<Button-1>", self.record_button)
self.button_record.grid(row=1, column=0, sticky=W)
self.entry.grid(row=0, column=0, sticky=N + S + E + W)
def record_button(self, event):
if not self.recording:
self.bot.Record()
print('pressed record')
else:
notation = self.bot.Stop()
self.entry_var.set(notation)
print('stopped record')
self.recording = not self.recording
if __name__ == '__main__':
app = GUI_FrameTrapBot()
app.update_launcher()
app.mainloop()