-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpychoss.py
More file actions
607 lines (590 loc) · 27.6 KB
/
pychoss.py
File metadata and controls
607 lines (590 loc) · 27.6 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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
#!/usr/bin/env python
import os
import sys
import configparser
import time
import threading
import webbrowser
import tkinter
from tkinter import *
import tkinter.font as font
from tkinter import filedialog
from tkinter import ttk
from tkinter import messagebox
import ttkbootstrap as tb
from ttkbootstrap.constants import *
from ttkbootstrap.validation import *
from ttkbootstrap.widgets import *
from obswebsocket import obsws, requests
from github import Github
appVersion = "v1.2.0"
latestRelease = appVersion
repoURL = "https://github.com/Yoshibyl/PyCHOSS"
print("Python Clone Hero OBS Scene Switcher (PyCHOSS) " + appVersion)
print("Created by Yoshibyl (Yoshi) :: https://github.com/Yoshibyl/")
## Update checker stuff
updateAvailable = False
isChecking = False
txtTimer = 0.0
def updateBtnTimerStart(): # This should only be called ONCE during execution!
btnBgThread = threading.Thread(target=timerTickLoop)
btnBgThread.start()
def checkGithubForUpdate(event=None):
global updateAvailable
global isChecking
if not updateAvailable:
if txtTimer == 0.0:
isChecking = True
checkerThread = threading.Thread(target=updateCheckWorker)
checkerThread.start()
updateBtn.config(state="disabled", bootstyle="primary")
updateBtnTxtVar.set("Checking...")
else:
updatePrompt = messagebox.askyesno(title="PyCHOSS Update", message="Download PyCHOSS " + latestRelease + "?\n\nClicking \"Yes\" will open GitHub in your default web browser.")
if updatePrompt:
webbrowser.open_new_tab(repoURL + "/releases/tag/" + latestRelease)
def updateCheckWorker():
global updateAvailable
global latestRelease
global txtTimer
global isChecking
global updateChannel
global appVersion
txtTimer = 67 # haha six seven (please laugh)
print("\nChecking GitHub for update...")
try:
gHub = Github()
gTags = gHub.get_repo("Yoshibyl/PyCHOSS").get_tags()
tags = []
channel = "stable"
try:
channel = updateChannel.get()
except: pass
updateAvailable = False
for gTag in gTags:
tag = gTag.name.lower()
tags.append(tag)
if tag != appVersion:
if "pre" not in channel.lower() and "pre" in tag:
tags.remove(tag)
latestRelease = tags[0]
if appVersion in tags and tags[0] != appVersion: # only count latest version if current version is on github
isChecking = False
print("Version %s found: " % latestRelease)
print(repoURL + "/releases/tag/" + latestRelease)
updateAvailable = True
else:
print("No update available at this time (%s)" % appVersion)
updateAvailable = False
try:
if updateAvailable:
updateBtnTxtVar.set("Update available: " + latestRelease)
updateBtn.config(state="enabled",bootstyle="success")
txtTimer = -1 # disable timer for resetting button text because update was found
updateToolTip.text = "Click to go to GitHub and download PyCHOSS " + latestRelease
else:
updateBtnTxtVar.set("On the latest version: %s" % appVersion)
updateBtn.config(state="enabled",bootstyle="info")
txtTimer = 6
except: pass
except:
print("An error occurred while trying to check GitHub")
updateAvailable = False
try:
txtTimer = 6
updateBtnTxtVar.set("Can't connect to GitHub")
updateBtn.config(state="enabled",bootstyle="danger")
except: pass
isChecking = False
def timerTickLoop():
global exiting
global txtTimer
if appcfg["general"]["auto_check_update"].lower() == "true":
checkGithubForUpdate()
while exiting == False and txtTimer > -1:
time.sleep(0.1)
if txtTimer > 0:
txtTimer -= 0.1
if txtTimer < 0: txtTimer = 0
if txtTimer == 0.0:
try:
updateBtnTxtVar.set("Check for update")
except: pass
## config.ini setup
appcfg = configparser.ConfigParser(allow_no_value=True, strict=False, interpolation=None)
defaultChannel = "Stable"
if "pre" in appVersion: defaultChannel = "PreRelease"
defaultGeneral = {
"app_theme": "Dark",
"ip_address": "localhost",
"port": "4455",
"password": "",
"auto_check_update": "true",
"update_channel": defaultChannel, # Changes to "Stable" on release, or "PreRelease" in pre-release builds
"cooldown_seconds": "1.0",
"afk_scene": "AFK"
}
defaultCloneHero = {
"currentsong_path": os.path.expanduser("~/.clonehero/currentsong.txt"),
"game_scene":"CH Gameplay",
"menu_scene":"CH Menu"
}
defaultYarg = {
"currentsong_path": os.path.expanduser("~/.config/unity3d/YARC/YARG/release/currentSong.txt"),
"game_scene":"YARG Gameplay",
"menu_scene":"YARG Menu"
}
defaultYargNightly = {
"currentsong_path": os.path.expanduser("~/.config/unity3d/YARC/YARG/nightly/currentSong.txt"),
"game_scene":"YARG Gameplay",
"menu_scene":"YARG Menu"
}
if sys.platform == "win32":
defaultCloneHero["currentsong_path"] = os.path.expanduser("~\\OneDrive\\Documents\\Clone Hero\\currentsong.txt")
defaultYarg["currentsong_path"] = os.path.expanduser("~\\AppData\\LocalLow\\YARC\\YARG\\release\\currentSong.txt")
defaultYargNightly["currentsong_path"] = os.path.expanduser("~\\AppData\\LocalLow\\YARC\\YARG\\nightly\\currentSong.txt")
def update_config(reload=False):
global appcfg
if not os.path.exists("config.ini"):
appcfg["general"] = defaultGeneral
appcfg["clonehero"] = defaultCloneHero
appcfg["yarg"] = defaultYarg
appcfg["yarg_nightly"] = defaultYargNightly
if reload:
appcfg.read("config.ini")
# General
if "general" not in appcfg.sections():
appcfg["general"] = defaultGeneral
for k in defaultGeneral.keys():
if k not in appcfg["general"].keys(): appcfg["general"][k] = defaultGeneral[k]
# Clone Hero
if "clonehero" not in appcfg.sections():
appcfg["clonehero"] = defaultCloneHero
for k in defaultCloneHero.keys():
if k not in appcfg["clonehero"].keys(): appcfg["clonehero"][k] = defaultCloneHero[k]
# YARG Stable and Nightly
if "yarg" not in appcfg.sections():
appcfg["yarg"] = defaultYarg
for k in defaultYarg.keys():
if k not in appcfg["yarg"].keys(): appcfg["yarg"][k] = defaultYarg[k]
if "yarg_nightly" not in appcfg.sections():
appcfg["yarg_nightly"] = defaultYargNightly
for k in defaultYargNightly.keys():
if k not in appcfg["yarg_nightly"].keys(): appcfg["yarg_nightly"][k] = defaultYargNightly[k]
with open("config.ini", "w") as cfgfile:
appcfg.write(cfgfile)
cfgfile.close()
## read the config.ini; create/populate if necessary
update_config(True)
# connect/disconnect button click
def connectBtnClick(event=None):
global cooldownTxtVar
global cooldownSpin
global cooldown
global wsThread
fixCooldownTxt()
if connStatusBool == False:
connBtnTxtVar.set("Connecting...")
connectBtn.config(state="disabled")
for child in nbFrameCH.winfo_children():
child.config(state="disabled")
for child in nbFrameYARG.winfo_children():
child.config(state="disabled")
for child in nbFrameYARGnightly.winfo_children():
child.config(state="disabled")
wsThread = threading.Thread(target=wsConnectionWorker)
wsThread.start()
else:
client.disconnect()
connStatusTxt.set("Not connected")
connStatusLbl.config(bootstyle="danger")
connBtnTxtVar.set("Connect")
connectBtn.config(state="enabled")
for child in nbFrameCH.winfo_children():
child.config(state="enabled")
for child in nbFrameYARG.winfo_children():
child.config(state="enabled")
def onConnect(sock):
global connStatusBool
connStatusBool = True
connStatusTxt.set("Connected (%s)" % whichTabMode)
connStatusLbl.config(bootstyle="success")
connBtnTxtVar.set("Disconnect")
connectBtn.config(state="enabled")
def onDisconnect(sock):
global connStatusBool
if exiting == False:
connStatusBool = False
connStatusTxt.set("Not connected")
connStatusLbl.config(bootstyle="danger")
connBtnTxtVar.set("Connect")
connectBtn.config(state="enabled")
for child in nbFrameCH.winfo_children():
child.config(state="enabled")
for child in nbFrameYARG.winfo_children():
child.config(state="enabled")
for child in nbFrameYARGnightly.winfo_children():
child.config(state="enabled")
# websocket thread thing
def wsConnectionWorker():
global client
global whichTabMode
global connStatusBool
global cooldown
ip = ipVar.get()
portStr = portVar.get()
port = 4455
if isStringInt(portStr): port = int(portStr)
pw = passVar.get()
csPath = ""
gameScene = ""
menuScene = ""
whichTabMode = nb.tab(nb.select(), "text")
if whichTabMode == "Clone Hero":
csPath = currSongTxtVar_CH.get()
gameScene = gameSceneTxtVar_CH.get()
menuScene = menuSceneTxtVar_CH.get()
elif whichTabMode == "YARG stable":
csPath = currSongTxtVar_YARG.get()
gameScene = gameSceneTxtVar_YARG.get()
menuScene = menuSceneTxtVar_YARG.get()
elif whichTabMode == "YARG nightly":
csPath = currSongTxtVar_YARGnightly.get()
gameScene = gameSceneTxtVar_YARGnightly.get()
menuScene = menuSceneTxtVar_YARGnightly.get()
if os.path.isfile(csPath):
client = obsws(ip, port, pw, on_connect=onConnect, on_disconnect=onDisconnect, timeout=5)
try:
client.connect()
connStatusBool = True
except:
connStatusBool = False
connStatusLbl.config(bootstyle="danger")
connStatusTxt.set("Connection failed. Check OBS websocket settings/password")
connBtnTxtVar.set("Connect")
connectBtn.config(state="enabled")
connBtnTxtVar.set("Connect")
for child in nbFrameCH.winfo_children():
child.config(state="enabled")
for child in nbFrameYARG.winfo_children():
child.config(state="enabled")
for child in nbFrameYARGnightly.winfo_children():
child.config(state="enabled")
if connStatusBool == True:
old_size = os.path.getsize(csPath)
while connStatusBool == True:
new_size = os.path.getsize(csPath)
if old_size != new_size:
cooldown = cooldownChangeHandler()
currentScene = " "
try:
curSceneReq = client.call(requests.GetCurrentProgramScene())
currentScene = curSceneReq.datain["sceneName"].strip()
except: pass
afkScene = afkSceneTxtVar_global.get().strip()
if (currentScene != afkScene and afkScene != "") or afkScene == "":
if new_size == 0: # menu scene
client.call(requests.SetCurrentProgramScene(sceneName=menuScene))
if cooldown > 0: time.sleep(cooldown)
else: # gameplay scene
client.call(requests.SetCurrentProgramScene(sceneName=gameScene))
if cooldown > 0: time.sleep(cooldown)
old_size = new_size
time.sleep(0.1)
else:
connStatusLbl.config(bootstyle="warning")
connStatusTxt.set("currentsong.txt not found! (%s)" % whichTabMode)
connBtnTxtVar.set("Connect")
connectBtn.config(state="enabled")
for child in nbFrameCH.winfo_children():
child.config(state="enabled")
for child in nbFrameYARG.winfo_children():
child.config(state="enabled")
for child in nbFrameYARGnightly.winfo_children():
child.config(state="enabled")
# application close handler
def onCloseWindow(event=None):
global client
global connStatusBool
global exiting
global cooldownTxtVar
global cooldownSpin
global cooldown
fixCooldownTxt()
if connStatusBool == True:
if messagebox.askyesno("Warning", "There is an active connection to the OBS websocket. Are you sure you want to exit?", icon="warning"):
try:
client.disconnect()
except:
print("Error trying to disconnect websocket")
exiting = True
saveBtnClick()
root.destroy()
sys.exit()
else:
exiting = True
saveBtnClick()
root.destroy()
sys.exit()
# save config button click
def saveBtnClick(event=None):
global cooldownTxtVar
global cooldownSpin
global cooldown
global appcfg
fixCooldownTxt()
appcfg["general"]["ip_address"] = ipVar.get()
appcfg["general"]["port"] = portVar.get()
appcfg["general"]["password"] = passVar.get()
appcfg["general"]["auto_check_update"] = "true" if autoCheckUpdateVar.get() == True else "false"
appcfg["general"]["update_channel"] = updateChannel.get()
appcfg["general"]["cooldown_seconds"] = cooldownTxtVar.get()
appcfg["general"]["afk_scene"] = afkSceneTxtVar_global.get()
appcfg["clonehero"]["currentsong_path"] = currSongTxtVar_CH.get()
appcfg["yarg"]["currentsong_path"] = currSongTxtVar_YARG.get()
appcfg["yarg_nightly"]["currentsong_path"] = currSongTxtVar_YARGnightly.get()
appcfg["clonehero"]["game_scene"] = gameSceneTxtVar_CH.get()
appcfg["clonehero"]["menu_scene"] = menuSceneTxtVar_CH.get()
appcfg["yarg"]["game_scene"] = gameSceneTxtVar_YARG.get()
appcfg["yarg"]["menu_scene"] = menuSceneTxtVar_YARG.get()
appcfg["yarg_nightly"]["game_scene"] = gameSceneTxtVar_YARGnightly.get()
appcfg["yarg_nightly"]["menu_scene"] = menuSceneTxtVar_YARGnightly.get()
update_config()
# theme select handler
def updateTheme(event=None):
themeOption.config(width=5)
themeVal = themeTxtVar.get()
if themeVal == "Dark":
root.style.theme_use("darkly")
elif themeVal == "Black":
root.style.theme_use("cyborg")
elif themeVal == "Light":
root.style.theme_use("litera")
appcfg["general"]["app_theme"] = themeVal
# update channel select handler
def changeUpdateChannel(event=None):
appcfg["general"]["update_channel"] = updateChannel.get()
# "Browse currentsong.txt" button handlers
def browseForTxt_CH(event=None):
global appcfg
startDir = appcfg["clonehero"]["currentsong_path"].replace("currentsong.txt", "")
filepath = filedialog.askopenfilename(filetypes=[("Text file","*.txt")], initialdir=startDir)
if len(filepath) > 0:
currSongTxtVar_CH.set(filepath)
def browseForTxt_YARG(event=None):
global appcfg
startDir = appcfg["yarg"]["currentsong_path"].replace("currentSong.txt", "")
filepath = filedialog.askopenfilename(filetypes=[("Text file","*.txt")], initialdir=startDir)
if len(filepath) > 0:
currSongTxtVar_YARG.set(filepath)
def browseForTxt_YARGnightly(event=None):
global appcfg
startDir = appcfg["yarg_nightly"]["currentsong_path"].replace("currentSong.txt", "")
filepath = filedialog.askopenfilename(filetypes=[("Text file","*.txt")], initialdir=startDir)
if len(filepath) > 0:
currSongTxtVar_YARGnightly.set(filepath)
# cooldown spinbox validation
def isStringFloat(string_ = ""):
try:
float_ = float(string_)
except:
return False
return True
def isStringInt(string_ = ""):
try:
int_ = int(string_)
except:
return False
return True
# port entry validation
def numValidation(inputString, actionType):
if actionType == '1':
if not inputString.isdigit() or len(portVar.get()) >= 5:
return False
return True
# cooldown changed
def cooldownChangeHandler(event=None):
global cooldown
global cooldownTxtVar
fixCooldownTxt()
if isStringFloat(cooldownTxtVar.get()):
cooldown = float(cooldownTxtVar.get())
if cooldown > 30.0: cooldown = 30.0
elif cooldown < 0.0: cooldown = 0.0
return cooldown
# cooldown validation
def fixCooldownTxt(a=None,b=None,c=None):
global cooldownTxtVar
global cooldown
cooldownStr = cooldownTxtVar.get().replace("-","")
if isStringFloat(cooldownStr) == False:
cooldownStr = "1.0"
cooldown = 1.0
cooldownTxtVar.set(cooldownStr)
else:
cooldown = float(cooldownStr)
if cooldown > 30.0: cooldown = 30.0
elif cooldown < 0.0: cooldown = 0.0
cooldownStr = f"{cooldown:0.1f}"
cooldownTxtVar.set(cooldownStr)
## initialize main window and stuff
root = tb.Window(title="PyCHOSS " + appVersion, themename="darkly")
root.protocol("WM_DELETE_WINDOW", onCloseWindow)
## variables
themeTxtVar = tkinter.StringVar(root, appcfg["general"]["app_theme"])
connStatusBool = False
connStatusTxt = tkinter.StringVar(root, "Not connected")
ipVar = tkinter.StringVar(root, appcfg["general"]["ip_address"])
portVar = tkinter.StringVar(root, appcfg["general"]["port"][:5])
if not isStringInt(portVar.get()): portVar.set("4455")
passVar = tkinter.StringVar(root, appcfg["general"]["password"])
connBtnTxtVar = tkinter.StringVar(root, "Connect")
currSongTxtVar_CH = tkinter.StringVar(root, appcfg["clonehero"]["currentsong_path"])
currSongTxtVar_YARG = tkinter.StringVar(root, appcfg["yarg"]["currentsong_path"])
currSongTxtVar_YARGnightly = tkinter.StringVar(root, appcfg["yarg_nightly"]["currentsong_path"])
gameSceneTxtVar_CH = tkinter.StringVar(root, appcfg["clonehero"]["game_scene"])
menuSceneTxtVar_CH = tkinter.StringVar(root, appcfg["clonehero"]["menu_scene"])
gameSceneTxtVar_YARG = tkinter.StringVar(root, appcfg["yarg"]["game_scene"])
menuSceneTxtVar_YARG = tkinter.StringVar(root, appcfg["yarg"]["menu_scene"])
gameSceneTxtVar_YARGnightly = tkinter.StringVar(root, appcfg["yarg_nightly"]["game_scene"])
menuSceneTxtVar_YARGnightly = tkinter.StringVar(root, appcfg["yarg_nightly"]["menu_scene"])
afkSceneTxtVar_global = tkinter.StringVar(root, appcfg["general"]["afk_scene"])
updateBtnTxtVar = tkinter.StringVar(root, "Check for update")
exiting = False
autoCheckUpdateVar = tkinter.BooleanVar(root, appcfg["general"]["auto_check_update"] == "true")
updateChannel = tkinter.StringVar(root, appcfg["general"]["update_channel"])
cooldownTxtVar = tkinter.StringVar(root, appcfg["general"]["cooldown_seconds"])
cooldown = 0.0
if isStringFloat(cooldownTxtVar.get()):
cooldown = float(cooldownTxtVar.get())
fixCooldownTxt()
whichTabMode = "Clone Hero"
## Layout stuff
# Scene Switcher settings
nb = ttk.Notebook(root, padding=0, height=170)
# Clone Hero
nbFrameCH = ttk.Frame(nb, padding=10)
currSongBrowseCH = ttk.Button(nbFrameCH, text="Browse currentsong.txt", command=browseForTxt_CH, width=20)
currSongBrowseCH.grid(row=0,column=0,pady=2)
currSongEntryCH = ttk.Entry(nbFrameCH, textvariable=currSongTxtVar_CH,width=35)
currSongEntryCH.grid(row=0,column=1,pady=2)
ttk.Label(nbFrameCH, text="Gameplay Scene:").grid(row=1,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameCH, text="Menu Scene:").grid(row=2,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameCH, text="(Global) AFK Scene:").grid(row=3,column=0,padx=5,pady=2,sticky=E)
gameSceneEntryCH = ttk.Entry(nbFrameCH, textvariable=gameSceneTxtVar_CH, width=35)
gameSceneEntryCH.grid(row=1,column=1,padx=10,pady=2,sticky=E)
menuSceneEntryCH = ttk.Entry(nbFrameCH, textvariable=menuSceneTxtVar_CH, width=35)
menuSceneEntryCH.grid(row=2,column=1,padx=10,pady=2,sticky=E)
afkSceneEntryCH = ttk.Entry(nbFrameCH, textvariable=afkSceneTxtVar_global, width=35)
afkSceneEntryCH.grid(row=3,column=1,padx=10,pady=2,sticky=E)
# YARG stable
nbFrameYARG = ttk.Frame(nb, padding=10)
currSongBrowseYARG = ttk.Button(nbFrameYARG, text="Browse currentSong.txt", command=browseForTxt_YARG, width=20)
currSongBrowseYARG.grid(row=0,column=0,pady=2)
currSongEntryYARG = ttk.Entry(nbFrameYARG, textvariable=currSongTxtVar_YARG,width=35).grid(row=0,column=1,pady=2)
ttk.Label(nbFrameYARG, text="Gameplay Scene:").grid(row=1,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameYARG, text="Menu Scene:").grid(row=2,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameYARG, text="(Global) AFK Scene:").grid(row=3,column=0,padx=5,pady=2,sticky=E)
gameSceneEntryYARG = ttk.Entry(nbFrameYARG, textvariable=gameSceneTxtVar_YARG, width=35)
gameSceneEntryYARG.grid(row=1,column=1,padx=10,pady=2,sticky=E)
menuSceneEntryYARG = ttk.Entry(nbFrameYARG, textvariable=menuSceneTxtVar_YARG, width=35)
menuSceneEntryYARG.grid(row=2,column=1,padx=10,pady=2,sticky=E)
afkSceneEntryYARG = ttk.Entry(nbFrameYARG, textvariable=afkSceneTxtVar_global, width=35)
afkSceneEntryYARG.grid(row=3,column=1,padx=10,pady=2,sticky=E)
# YARG nightly
nbFrameYARGnightly = ttk.Frame(nb, padding=10)
currSongBrowseYARGnightly = ttk.Button(nbFrameYARGnightly, text="Browse currentSong.txt", command=browseForTxt_YARGnightly, width=20)
currSongBrowseYARGnightly.grid(row=0,column=0,pady=2)
currSongEntryYARGnightly = ttk.Entry(nbFrameYARGnightly, textvariable=currSongTxtVar_YARGnightly,width=35)
currSongEntryYARGnightly.grid(row=0,column=1,pady=2)
ttk.Label(nbFrameYARGnightly, text="Gameplay Scene:").grid(row=1,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameYARGnightly, text="Menu Scene:").grid(row=2,column=0,padx=5,pady=2,sticky=E)
ttk.Label(nbFrameYARGnightly, text="(Global) AFK Scene:").grid(row=3,column=0,padx=5,pady=2,sticky=E)
gameSceneEntryYARGnightly = ttk.Entry(nbFrameYARGnightly, textvariable=gameSceneTxtVar_YARGnightly, width=35)
gameSceneEntryYARGnightly.grid(row=1,column=1,padx=10,pady=2,sticky=E)
menuSceneEntryYARGnightly = ttk.Entry(nbFrameYARGnightly, textvariable=menuSceneTxtVar_YARGnightly, width=35)
menuSceneEntryYARGnightly.grid(row=2,column=1,padx=10,pady=2,sticky=E)
afkSceneEntryYARGnightly = ttk.Entry(nbFrameYARGnightly, textvariable=afkSceneTxtVar_global, width=35)
afkSceneEntryYARGnightly.grid(row=3,column=1,padx=10,pady=2,sticky=E)
nb.add(nbFrameCH, text="Clone Hero")
nb.add(nbFrameYARG, text="YARG stable")
nb.add(nbFrameYARGnightly, text="YARG nightly")
nb.grid(row=0,column=0,rowspan=3, padx=10, pady=10, sticky=NW)
# Websocket Settings frame
wsFrame = ttk.Labelframe(root, text="Websocket Connection", width=370, height=180, padding=10)
ipLabel = ttk.Label(wsFrame, text=" IP Address:")
ipEntry = ttk.Entry(wsFrame, textvariable=ipVar, width=16)
portLabel = ttk.Label(wsFrame, text=" Port:")
portEntry = ttk.Entry(wsFrame, textvariable=portVar, width=6, validate="key")
portEntry["validatecommand"] = (portEntry.register(numValidation), "%P", "%d") # limits input to digits
passLabel = ttk.Label(wsFrame, text="Password:")
passEntry = ttk.Entry(wsFrame, textvariable=passVar, show="•", width=34)
ipLabel.grid(row=0, column=0, padx=10, pady=2, sticky=E)
ipEntry.grid(row=0, column=1, padx=10, pady=2, sticky=E)
portLabel.grid(row=0,column=2, padx=10, pady=2, sticky=E)
portEntry.grid(row=0, column=3, padx=10, pady=2, sticky=E)
passLabel.grid(row=1, column=0, padx=10, pady=2, sticky=E)
passEntry.grid(row=1, column=1, columnspan=3, padx=10, pady=2, sticky=W)
wsFrame.grid(row=0, column=1, padx=10, pady=10, sticky=NE)
# Theme select and other settings
genSettingsFrame = tkinter.Frame(root, padx=10, pady=10)
themeLbl = tb.Label(genSettingsFrame, text=" App theme: ")
themeOption = tb.OptionMenu(genSettingsFrame, themeTxtVar, "","Dark","Black","Light", command=updateTheme)
updateTheme()
themeLbl.grid(row=0,column=0,sticky=W)
themeOption.grid(row=0,column=1,sticky=W, padx=10,pady=10)
cooldownLbl = tb.Label(genSettingsFrame, text=" Scene cooldown (sec): ").grid(row=0,column=2,columnspan=2,sticky=W)
cooldownSpin = ttk.Spinbox(genSettingsFrame, increment=0.1, from_=0, to=30, command=cooldownChangeHandler, validatecommand=isStringFloat, textvariable=cooldownTxtVar, width=4)
# cooldownTxtVar.trace("w", fixCooldownTxt)
cooldownSpin.grid(row=0,column=4,sticky=W)
updateBtn = tb.Button(genSettingsFrame, textvariable=updateBtnTxtVar, command=checkGithubForUpdate, width=29)
updateBtn.grid(row=1,column=0,columnspan=3,sticky=SW)
autoUpdateToggle = tb.Checkbutton(genSettingsFrame, variable=autoCheckUpdateVar, text="Auto-check: ", bootstyle="round-toggle")
autoUpdateToggle.grid(row=1,column=3,padx=10)
updChanOption = tb.OptionMenu(genSettingsFrame, updateChannel, "","Stable","PreRelease", command=changeUpdateChannel)
updChanOption.grid(row=1,column=4)
genSettingsFrame.grid(row=3, column=0, rowspan=2, sticky=SW)
# Save config button
saveBtn = ttk.Button(root, text="Save configuration", width=50, command=saveBtnClick)
saveBtn.grid(row=1, column=1, ipady=5, pady=10, sticky=N)
# Connection status indicator
connStatusLbl = tb.Label(root, textvariable=connStatusTxt, bootstyle="danger")
connStatusLbl.grid(row=3, column=1, sticky=S)
# Connect button
connectBtn = tb.Button(root, textvariable=connBtnTxtVar, width=50, command=connectBtnClick, bootstyle="info")
connectBtn.grid(row=4, column=1, ipady=18, pady=10)
# Tooltips (for helpful information)
tips = {
saveBtn: "Saves the current configuration.\nNote: This happens automatically on closing.",
connectBtn: "Connects the scene switcher to OBS Studio's websocket server.",
autoUpdateToggle: "Toggles whether to automatically check for updates at launch.",
cooldownSpin: "Controls how many seconds the scene switcher waits after switching scenes before the next scene switch can occur.\n\nRange: 0.0 to 30.0",
ipEntry: "The local IP address of the OBS websocket server.\n\nIf unsure, leave it as localhost",
portEntry: "The port of the OBS websocket server.\n\nDefault: 4455",
themeOption: "Controls the application theme (dark, black, or light mode)",
updChanOption: "Controls whether to check for pre-release builds, or just stable ones.\n\nIf unsure, set it to Stable"
}
importantTips = {
passEntry: "It is strongly recommended to generate a password in the OBS websocket server settings and paste it here (Ctrl+V).",
gameSceneEntryCH: "Scene to switch to when playing a song.\nCASE-SENSITIVE!",
menuSceneEntryCH: "Scene to switch to when in menus.\nCASE-SENSITIVE!",
gameSceneEntryYARG: "Scene to switch to when playing a song.\nCASE-SENSITIVE!",
menuSceneEntryYARG: "Scene to switch to when in menus.\nCASE-SENSITIVE!",
gameSceneEntryYARGnightly: "Scene to switch to when playing a song.\nCASE-SENSITIVE!",
menuSceneEntryYARGnightly: "Scene to switch to when in menus.\nCASE-SENSITIVE!",
afkSceneEntryCH: "Scene that will prevent switching while active. This is for privacy purposes (for example, when you're away from your stream).\nLeave blank to disable.\n\nThis setting is the same regardless of the game, and it's CASE-SENSITIVE!",
afkSceneEntryYARG: "Scene that will prevent switching while active. This is for privacy purposes (for example, when you're away from your stream).\nLeave blank to disable.\n\nThis setting is the same regardless of the game, and it's CASE-SENSITIVE!",
afkSceneEntryYARGnightly: "Scene that will prevent switching while active. This is for privacy purposes (for example, when you're away from your stream).\nLeave blank to disable.\n\nThis setting is the same regardless of the game, and it's CASE-SENSITIVE!"
}
updateToolTip = ToolTip(updateBtn, text="Checks for a new version of PyCHOSS on GitHub.", padding=3, delay=500)
for widg, tip in tips.items():
ToolTip(widg, tip, 3, delay=500)
for widg_, tip_ in importantTips.items():
ToolTip(widg_, tip_, 3, delay=0)
# set things up
root.geometry()
root.resizable(False,False)
client = obsws()
root.after(0, updateBtnTimerStart)
# main loop
root.mainloop()