-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGUI_FrameDataOverlay.py
More file actions
323 lines (268 loc) · 13.3 KB
/
GUI_FrameDataOverlay.py
File metadata and controls
323 lines (268 loc) · 13.3 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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
"""
A transparent frame data display that sits on top of Tekken.exe in windowed or borderless mode.
"""
from tkinter import *
from tkinter.ttk import *
import sys
from enum import Enum
import GUI_Overlay
from GUI_Overlay import CurrentColorScheme, ColorSchemeEnum
class DataColumns(Enum):
idX = 0
XXCOMXX = 1
impX = 2
AT = 3
BLOCK = 4
XXHITXX = 5
COUNTER = 6
DM = 7
GD = 8
A = 9
WHF = 10
REC = 11
GAP = 12
#BSTN = 7
#HSTN = 8
#CSTN = 9
NOTE = 13
def config_name():
return "DataColumns"
DataColumnsToMenuNames = {
DataColumns.idX : 'internal move id number',
DataColumns.XXCOMXX : 'best guess for input command',
DataColumns.impX : 'the startup frames before the move becomes active',
DataColumns.AT : 'the type of attack (low/mid/high/throw/special)',
DataColumns.BLOCK : 'frame advantage when the move is blocked',
DataColumns.XXHITXX : 'frame advantage when the move hits',
DataColumns.COUNTER : 'frame advantage when the move counter hits',
DataColumns.DM : 'the amount of damage listed for the move',
DataColumns.GD : 'amount of guard damage inflicted on block, all characters have a starting guard health of 240 points',
DataColumns.A : 'The number of active frames, hitting an opponent with a later active frame is not reflected in the displayed frame data',
DataColumns.WHF: 'total number of frames in the animation',
DataColumns.REC: 'number of frames after impact but before returning to neutral',
DataColumns.GAP: 'number of frames between the impact of previous move and impact of this move',
#DataColumns.BSTN : 'amount of frames before defender recovers from blocking',
#DataColumns.HSTN : 'amount of frames before defender recovers from being hit',
#DataColumns.CSTN : 'amount of frames before defender recovers from being counter hit',
DataColumns.NOTE : '???'
}
class TextRedirector(object):
def __init__(self, stdout, widget, style, fa_p1_var, fa_p2_var):
self.KEY = 'FDO:'
self.NOTE = 'NOTE:'
self.p1_note = ''
self.p2_note = ''
self.stdout = stdout
self.widget = widget
#self.fa_p1_var = fa_p1_var
#self.fa_p2_var = fa_p2_var
self.style = style
self.widget.tag_config("p1", foreground=CurrentColorScheme.dict[ColorSchemeEnum.p1_text])
self.widget.tag_config("p1s", foreground=CurrentColorScheme.dict[ColorSchemeEnum.p1s_text])
self.widget.tag_config("p2", foreground=CurrentColorScheme.dict[ColorSchemeEnum.p2_text])
self.widget.tag_config("p2s", foreground=CurrentColorScheme.dict[ColorSchemeEnum.p2s_text])
self.widget.tag_config("MID", foreground=CurrentColorScheme.dict[ColorSchemeEnum.mid])
self.widget.tag_config("HIGH", foreground=CurrentColorScheme.dict[ColorSchemeEnum.high])
self.widget.tag_config("LOW", foreground=CurrentColorScheme.dict[ColorSchemeEnum.low])
self.widget.tag_config("THROW", foreground=CurrentColorScheme.dict[ColorSchemeEnum.throw])
self.columns_to_print = [True] * len(DataColumns)
#self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_slight_minus])
def set_columns_to_print(self, booleans_for_columns):
self.columns_to_print = booleans_for_columns
self.populate_column_names(booleans_for_columns)
def populate_column_names(self, booleans_for_columns):
column_names = ""
for i, enum in enumerate(DataColumns):
if booleans_for_columns[i]:
column_names += "|{}".format(enum.name.replace('X', ' '))
self.set_first_column(column_names)
def set_first_column(self, first_column_string):
self.widget.configure(state="normal")
self.widget.delete("1.0", "2.0")
self.widget.insert("1.0", first_column_string + '\n')
self.widget.configure(state="disabled")
def write(self, output_str):
#self.stdout.write(output_str)
lines = int(self.widget.index('end-1c').split('.')[0])
max_lines = 5
if lines > max_lines:
r = lines - max_lines
for _ in range(r):
self.widget.configure(state="normal")
self.widget.delete('2.0', '3.0')
self.widget.configure(state="disabled")
if self.KEY in output_str:
data = output_str.split(self.KEY)[1]
fa = output_str.split(self.KEY)[1][:3]
'''if '?' not in fa:
if int(fa) <= -14:
self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_very_punishible])
elif int(fa) <= -10:
self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_punishible])
elif int(fa) <= -5:
self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_safe_minus])
elif int(fa) < 0:
self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_slight_minus])
else:
self.style.configure('.', background=CurrentColorScheme.dict[ColorSchemeEnum.advantage_plus])'''
text_tag = None
if "p1:" in output_str:
#self.fa_p1_var.set(fa)
data = data.replace('p1:', '')
player_text_tag = 'p1'
note_placeholder = self.p1_note
elif "p1s:" in output_str:
#self.fa_p1_var.set(fa)
data = data.replace('p1s:', '')
player_text_tag = 'p1s'
note_placeholder = self.p1_note
elif "p2s:" in output_str:
#self.fa_p2_var.set(fa)
data = data.replace('p2s:', '')
player_text_tag = 'p2s'
note_placeholder = self.p2_note
else:
#self.fa_p2_var.set(fa)
data = data.replace('p2:', '')
player_text_tag = 'p2'
note_placeholder = self.p2_note
if '|' in output_str:
out = ""
self.widget.configure(state="normal")
for i, col in enumerate(data.split('|')):
if self.columns_to_print[i]:
text_tag = player_text_tag
self.widget.insert("end", '|', text_tag)
if 'throw_mid' in col:
text_tag = 'THROW'
out = 'M TH'
elif 'mid' in col:
text_tag = 'MID'
out = 'M '
elif 'high' in col:
text_tag = 'HIGH'
out = 'H '
elif 'low' in col:
text_tag = 'LOW'
out = 'L '
elif 'throw' in col:
text_tag = 'THROW'
out = 'TH'
elif 'sl' in col:
text_tag = 'LOW'
out = 'SL'
elif 'sm' in col:
text_tag = 'MID'
out = 'SM'
else:
text_tag = player_text_tag
out = col
self.widget.insert("end", out, text_tag)
out = note_placeholder + "\n"
self.widget.insert("end", out, text_tag)
self.widget.configure(state="disabled")
self.widget.see('0.0')
self.widget.yview('moveto', '.02')
if self.NOTE in output_str:
out = output_str.replace(self.NOTE, '')
self.widget.configure(state="normal")
if 'p1:' in out:
pos = self.widget.search(self.p1_note, END, stopindex=1.0, backwards=True)
out = out.replace('p1:', '')
elif 'p2:' in out:
pos = self.widget.search(self.p2_note, END, stopindex=1.0, backwards=True)
out = out.replace('p2:', '')
else:
pos = None
if pos:
out = out.lstrip()
self.widget.mark_set('note', pos)
self.widget.insert('note', out)
self.widget.configure(state="disabled")
class GUI_FrameDataOverlay(GUI_Overlay.Overlay):
def __init__(self, master, launcher, log=True):
GUI_Overlay.Overlay.__init__(self, master, (1260, 86), "SCUFFLE: Frame Data Overlay", log)
self.launcher = launcher
self.s = Style()
self.s.theme_use('alt')
self.s.configure('Overlay.TFrame', background=self.background_color)
#self.s.configure('.', foreground=CurrentColorScheme.dict[ColorSchemeEnum.advantage_text])
Grid.columnconfigure(self.toplevel, 0, weight=0)
Grid.columnconfigure(self.toplevel, 1, weight=0)
Grid.columnconfigure(self.toplevel, 2, weight=0)
Grid.columnconfigure(self.toplevel, 3, weight=1)
Grid.columnconfigure(self.toplevel, 4, weight=0)
Grid.columnconfigure(self.toplevel, 5, weight=0)
Grid.columnconfigure(self.toplevel, 6, weight=0)
Grid.rowconfigure(self.toplevel, 0, weight=1)
Grid.rowconfigure(self.toplevel, 1, weight=0)
self.s.configure('Overlay.TFrame', background=self.tranparency_color)
#self.fa_p1_var, fa_p1_label = self.create_frame_advantage_label(1)
#self.fa_p2_var, fa_p2_label = self.create_frame_advantage_label(5)
self.l_margin = self.create_padding_frame(0)
self.r_margin = self.create_padding_frame(6)
self.l_seperator = self.create_padding_frame(2)
self.r_seperator = self.create_padding_frame(4)
self.text = self.create_textbox(3)
self.stdout = sys.stdout
self.redirector = TextRedirector(self.stdout, self.text, self.s, None, None)
self.text.configure(state="normal")
self.text.delete("1.0", "end")
#self.redirector.populate_column_names(self.get_data_columns())
self.redirector.set_columns_to_print(self.get_data_columns())
self.text.configure(state="disabled")
def get_data_columns(self):
booleans_for_columns = []
for enum in DataColumns:
bool = self.tekken_config.get_property(DataColumns.config_name(), enum.name, True)
booleans_for_columns.append(bool)
return booleans_for_columns
def create_padding_frame(self, col):
padding = Frame(self.toplevel, width=10, style='Overlay.TFrame')
padding.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
return padding
def create_live_recovery(self, parent, col):
live_recovery_var = StringVar()
live_recovery_var.set('??')
live_recovery_label = Label(parent, textvariable=live_recovery_var, font=("Segoe UI", 12), width=5, anchor='c')
#live_recovery_label.grid(row=0, column=col, sticky =S+W)
live_recovery_label.place(rely=0.0, relx=0.0, x=4, y=4, anchor=NW)
return live_recovery_var
def create_frame_advantage_label(self, col):
frame_advantage_var = StringVar()
frame_advantage_var.set('?')
frame_advantage_label = Label(self.toplevel, textvariable=frame_advantage_var, font=("Consolas", 44), width=4, anchor='c',
borderwidth=4, relief='ridge')
frame_advantage_label.grid(row=0, column=col)
return frame_advantage_var, frame_advantage_label
def create_attack_type_label(self, col):
attack_type_var = StringVar()
attack_type_var.set('?')
attack_type_label = Label(self.toplevel, textvariable=attack_type_var, font=("Verdana", 12), width=10, anchor='c',
borderwidth=4, relief='ridge')
attack_type_label.grid(row=1, column=col)
return attack_type_var
def create_textbox(self, col):
textbox = Text(self.toplevel, font=("Consolas", 14), wrap=NONE, highlightthickness=0, pady=0, relief='flat')
textbox.grid(row=0, column=col, rowspan=2, sticky=N + S + W + E)
textbox.configure(background=self.background_color)
textbox.configure(foreground=CurrentColorScheme.dict[ColorSchemeEnum.system_text])
return textbox
def update_state(self):
pass
#GUI_Overlay.Overlay.update_state(self)
'''if self.show_live_framedata:
if len(self.launcher.gameState.stateLog) > 1:
l_recovery = str(self.launcher.gameState.GetOppFramesTillNextMove() - self.launcher.gameState.GetBotFramesTillNextMove())
r_recovery = str(self.launcher.gameState.GetBotFramesTillNextMove() - self.launcher.gameState.GetOppFramesTillNextMove())
if not '-' in l_recovery:
l_recovery = '+' + l_recovery
if not '-' in r_recovery:
r_recovery = '+' + r_recovery
self.l_live_recovery.set(l_recovery)
self.r_live_recovery.set(r_recovery)'''
def set_columns_to_print(self, columns_to_print):
self.redirector.set_columns_to_print(columns_to_print)
def update_column_to_print(self, enum, value):
self.tekken_config.set_property(DataColumns.config_name(), enum.name, value)
self.write_config_file()