-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.py
695 lines (572 loc) · 28.1 KB
/
main.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
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
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import Qt, QPoint, QThread, pyqtSlot
from PyQt5.QtGui import QPixmap, QMovie
from PyQt5.QtWidgets import QApplication, QLabel, QSystemTrayIcon, QAction, QMenu, QWidget, QDesktopWidget
import sys
import random
import os
import webbrowser
from screeninfo import get_monitors
# Get path for temp folder when the program is executed
def resource_path(relative_path):
if hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative_path)
return os.path.join(os.path.abspath("."), relative_path)
# Thread for opening the web browser
# Only seems to be a problem in Linux
class OpenWeb(QThread):
def __init__(self, function, *args, **kwargs):
super(OpenWeb, self).__init__()
self.function = function
self.args = args
self.kwargs = kwargs
@pyqtSlot()
def run(self):
self.function(*self.args, **self.kwargs)
def open_about():
webbrowser.open("https://modestcarl.itch.io/homestuck-desktop-buddies", 2)
def open_hs():
webbrowser.open("https://www.homestuck.com/", 2)
def open_hs2():
webbrowser.open("https://www.homestuck2.com/", 2)
class BuddySelection(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.init_ui()
self.active_buddies = [] # Active buddies list to iterate through it to celebrate the update
self.want_to_close = False # Check for overriding the close event
# Creating the system tray icon
self.tray_icon = QSystemTrayIcon(self)
# Action for reopening the main window
open_action = QAction("Open", self)
open_action.triggered.connect(self.show)
# Action for opening the Homestuck website
open_hs_action = QAction("Open Homestuck", self)
open_hs_action.setIcon(QtGui.QIcon(resource_path('graphics/logo.ico')))
open_hs_action.triggered.connect(self.open_hs)
# Action for opening the Homestuck^2 website
open_hs2_action = QAction("Open Homestuck^2", self)
open_hs2_action.setIcon(QtGui.QIcon(resource_path('graphics/logo-hs2.ico')))
open_hs2_action.triggered.connect(self.open_hs2)
# Action for opening the software itch.io page
about_action = QAction("About", self)
about_action.triggered.connect(self.open_about)
# Action for quiting
quit_action = QAction("Exit", self)
quit_action.triggered.connect(self.exit)
# Creating the context menu for the system tray icon and adding the previously defined actions
tray_menu = QMenu()
tray_menu.addAction(open_action)
tray_menu.addAction(open_hs_action)
tray_menu.addAction(open_hs2_action)
tray_menu.addAction(about_action)
tray_menu.addAction(quit_action)
self.tray_icon.setContextMenu(tray_menu) # Adding the context menu to the tray icon
self.tray_icon.setIcon(QtGui.QIcon(resource_path('graphics/logo.ico'))) # Setting the icon
self.tray_icon.show()
self.tray_icon.activated.connect(self.show_hide) # Connecting the click to the show function
self.minimized_once = False # Variable for checking if the window has been minimized to tray once
def show_hide(self, reason):
# If the system tray icon was clicked, and the main window is hidden, show the main window
if reason == QSystemTrayIcon.Trigger:
if self.isHidden():
self.show()
# Open the itch.io page for the project
def open_about(self):
self.opener = OpenWeb(open_about)
self.opener.start()
# Open the Homestuck website
def open_hs(self):
self.opener = OpenWeb(open_hs)
self.opener.start()
# Open the Homestuck^2 website
def open_hs2(self):
self.opener = OpenWeb(open_hs2)
self.opener.start()
def init_ui(self):
# Set the window icon and title
self.setWindowIcon(QtGui.QIcon(resource_path('graphics/logo.ico')))
self.setWindowTitle("Homestuck Desktop Buddies v1.0.0")
# Set window geometry and disable resizing
self.setGeometry(0, 0, 850, 240)
self.resize(850, 240)
self.setMinimumSize(QtCore.QSize(850, 240))
self.setMaximumSize(QtCore.QSize(850, 240))
self.setStyleSheet("background-color: #c6c6c6;")
# Center window
qtRectangle = self.frameGeometry()
centerPoint = QDesktopWidget().availableGeometry().center()
qtRectangle.moveCenter(centerPoint)
self.move(qtRectangle.topLeft())
# Initialize the rest of the GUI
self.grid_layout_widget = QtWidgets.QWidget(self)
self.grid_layout_widget.setGeometry(QtCore.QRect(60, 0, 730, 240))
self.grid_layout_widget.setObjectName("gridLayoutWidget")
self.grid_layout = QtWidgets.QGridLayout(self.grid_layout_widget)
self.grid_layout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
self.grid_layout.setContentsMargins(0, 0, 0, 0)
self.grid_layout.setHorizontalSpacing(6)
self.grid_layout.setObjectName("gridLayout")
self.frame = QtWidgets.QFrame(self.grid_layout_widget)
self.frame.setStyleSheet("background-color: #efefef;")
self.frame.setFrameShape(QtWidgets.QFrame.NoFrame)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.frame.resize(730, 240)
self.grid_layout_widget_2 = QtWidgets.QWidget(self.frame)
self.grid_layout_widget_2.setGeometry(QtCore.QRect(9, 0, 711, 241))
self.grid_layout_widget_2.setObjectName("gridLayoutWidget_2")
self.grid_layout_2 = QtWidgets.QGridLayout(self.grid_layout_widget_2)
self.grid_layout_2.setContentsMargins(0, 0, 0, 0)
self.grid_layout_2.setObjectName("gridLayout_2")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(resource_path("graphics/menu/logo.png")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.john_button = QtWidgets.QPushButton(self.grid_layout_widget_2)
self.john_button.setStyleSheet("QPushButton {\n"
" border: none;\n"
" background-color: #efefef;\n"
"}\n"
"\n"
"QPushButton:checked{\n"
" border-top: 2px solid #535353;\n"
" border-left: 2px solid #535353;\n"
" background-color: #c6c6c6;\n"
"}")
self.john_button.setText("")
john_icon = QtGui.QIcon()
john_icon.addPixmap(QtGui.QPixmap(resource_path("graphics/menu/john-icon.png")), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
self.john_button.setIcon(john_icon)
self.john_button.setIconSize(QtCore.QSize(160, 160))
self.john_button.setCheckable(True)
self.john_button.setChecked(False)
self.john_button.setAutoRepeat(False)
self.john_button.setFlat(True)
self.john_button.setObjectName("johnButton")
self.grid_layout_2.addWidget(self.john_button, 0, 0, 1, 1)
self.rose_button = QtWidgets.QPushButton(self.grid_layout_widget_2)
self.rose_button.setStyleSheet("QPushButton {\n"
" border: none;\n"
" background-color: #efefef;\n"
"}\n"
"\n"
"QPushButton:checked{\n"
" border-top: 2px solid #535353;\n"
" border-left: 2px solid #535353;\n"
" background-color: #c6c6c6;\n"
"}")
self.rose_button.setText("")
rose_icon = QtGui.QIcon()
rose_icon.addPixmap(QtGui.QPixmap(resource_path("graphics/menu/rose-icon.png")), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
self.rose_button.setIcon(rose_icon)
self.rose_button.setIconSize(QtCore.QSize(160, 160))
self.rose_button.setCheckable(True)
self.rose_button.setFlat(True)
self.rose_button.setObjectName("roseButton")
self.grid_layout_2.addWidget(self.rose_button, 0, 1, 1, 1)
self.dave_button = QtWidgets.QPushButton(self.grid_layout_widget_2)
self.dave_button.setStyleSheet("QPushButton {\n"
" border: none;\n"
" background-color: #efefef;\n"
"}\n"
"\n"
"QPushButton:checked{\n"
" border-top: 2px solid #535353;\n"
" border-left: 2px solid #535353;\n"
" background-color: #c6c6c6;\n"
"}")
self.dave_button.setText("")
dave_icon = QtGui.QIcon()
dave_icon.addPixmap(QtGui.QPixmap(resource_path("graphics/menu/dave-icon.png")), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
self.dave_button.setIcon(dave_icon)
self.dave_button.setIconSize(QtCore.QSize(160, 160))
self.dave_button.setCheckable(True)
self.dave_button.setFlat(True)
self.dave_button.setObjectName("daveButton")
self.grid_layout_2.addWidget(self.dave_button, 0, 2, 1, 1)
self.jade_button = QtWidgets.QPushButton(self.grid_layout_widget_2)
self.jade_button.setStyleSheet("QPushButton {\n"
" border: none;\n"
" background-color: #efefef;\n"
"}\n"
"\n"
"QPushButton:checked{\n"
" border-top: 2px solid #535353;\n"
" border-left: 2px solid #535353;\n"
" background-color: #c6c6c6;\n"
"}")
self.jade_button.setText("")
icon3 = QtGui.QIcon()
icon3.addPixmap(QtGui.QPixmap(resource_path("graphics/menu/jade-icon.png")), QtGui.QIcon.Normal,
QtGui.QIcon.Off)
self.jade_button.setIcon(icon3)
self.jade_button.setIconSize(QtCore.QSize(160, 160))
self.jade_button.setCheckable(True)
self.jade_button.setFlat(True)
self.jade_button.setObjectName("jadeButton")
self.grid_layout_2.addWidget(self.jade_button, 0, 3, 1, 1)
self.grid_layout.addWidget(self.frame, 0, 0, 1, 1)
# Instance the available buddies and connect their respective buttons to their spawn function
self.john = JohnBuddy()
self.rose = RoseBuddy()
self.dave = DaveBuddy()
self.jade = JadeBuddy()
self.john_button.toggled.connect(self.spawn_john)
self.rose_button.toggled.connect(self.spawn_rose)
self.dave_button.toggled.connect(self.spawn_dave)
self.jade_button.toggled.connect(self.spawn_jade)
# Override close event for main window
def closeEvent(self, event):
if not self.want_to_close: # Check if window should be minimized to tray or actually closed
self.hide() # Hide window instead of closing it
# Check if window has been minimized once. If it hasn't, show a notification
if not self.minimized_once:
self.tray_icon.showMessage("Homestuck Buddy Selection",
"Program is still running in the background. "
"Exit from System Tray to close.",
QtGui.QIcon(resource_path("graphics/logo.ico")))
# Connect the message to a dummy function and then disconnect the messageClicked signal
# This was the only way I could find to disconnect the signal in case it wasn't already connected
# Otherwise, the program would crash
self.tray_icon.messageClicked.connect(self.dummy)
self.tray_icon.messageClicked.disconnect()
# Set the minimized once variable to True so the notification is only showed once
self.minimized_once = True
event.ignore() # Ignore the close event for override
# Dummy function
def dummy(self):
pass
# Actual exit function, in case the program is closed from the system tray
def exit(self):
self.want_to_close = True # Set this variable to True to not override the close event
self.worker.stop() # Stop the thread to check for updates
self.close() # Actually close the window
# Spawn the buddies
def spawn_john(self):
if self.john_button.isChecked(): # If the button is checked:
self.john.init_ui() # Initialize the buddy's UI
self.john.show() # Show the buddy
self.john.end_state() # Select a random state for the buddy
self.active_buddies.append(self.john) # Append the buddy to the active buddies list
else: # If the button is unchecked
self.john.stop() # Call the buddy's stop function
self.john.close() # Close the buddy's window
self.active_buddies.remove(self.john) # Remove the buddy form the active buddies list
# Same for the other buddies
def spawn_rose(self):
if self.rose_button.isChecked():
self.rose.init_ui()
self.rose.show()
self.rose.end_state()
self.active_buddies.append(self.rose)
else:
self.rose.stop()
self.rose.close()
self.active_buddies.remove(self.rose)
def spawn_dave(self):
if self.dave_button.isChecked():
self.dave.init_ui()
self.dave.show()
self.dave.end_state()
self.active_buddies.append(self.dave)
else:
self.dave.stop()
self.dave.close()
self.active_buddies.remove(self.dave)
def spawn_jade(self):
if self.jade_button.isChecked():
self.jade.init_ui()
self.jade.show()
self.jade.end_state()
self.active_buddies.append(self.jade)
else:
self.jade.stop()
self.jade.close()
self.active_buddies.remove(self.jade)
class HomestuckBuddy(QLabel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Set the respective graphics, default to John
self.front_left_sprite = resource_path("graphics/john/john-front-left.png")
self.front_right_sprite = resource_path("graphics/john/john-front-right.png")
self.front_walk_left_sprite = resource_path("graphics/john/john-front-walk-left.gif")
self.front_walk_right_sprite = resource_path("graphics/john/john-front-walk-right.gif")
self.dance_sprite = resource_path("graphics/john/john-dance.gif")
self.abscond_sprite = resource_path("graphics/john/john-abscond.gif")
self.stupid_sprite = resource_path("graphics/john/john-stupid.gif")
# Create variable to get the current press position when dragging
self.__press_pos = QPoint()
# If a new HS^2 update is detected, make the buddy perform their dance action
def celebrate_update(self):
# Stop the current timers
self.timer.stop()
if self.move_timer is not None:
if self.move_timer.isActive():
self.move_timer.stop()
# Pick the dance state for the buddy
self.pick_state("DANCE")
def init_ui(self):
# Make the buddy window transparent, and disable the task bar icon by setting the flag "Qt.Tool"
self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
self.setAttribute(Qt.WA_TranslucentBackground)
self.setWindowIcon(QtGui.QIcon(resource_path('graphics/logo.ico')))
# Set the starting graphics
self.pixmap = QPixmap(self.front_left_sprite)
self.setPixmap(self.pixmap)
# Create the max width and height variables
self.max_width = 0
self.max_height = 0
# Loop through all current monitors to get the max width
for m in get_monitors():
self.max_width += m.width # Add the current monitor width to the max width variable
current_height = m.height # Get the current monitor height
self.max_height = min(current_height, m.height) # In case monitor heights don't match, use the smallest one
# Set the state machine
self.state_list = ["WALK", "DANCE", "STUPID"] # The state list
self.state = "IDLE" # Set the current state
self.previous_state = self.state # Set the previous state, variable to avoid repeating actions
# Set the direction values for moving
self.dir_x = -4
self.dir_y = 4
#Create the timers
self.timer = QtCore.QTimer(self)
self.move_timer = QtCore.QTimer(self)
self.change_state_timer = QtCore.QTimer(self)
self.moving = False
self.setGeometry(960 - 150, 540 - 128, 650, 400)
# Pick a state instead of randomly choosing one
def pick_state(self, state):
self.state = state
self.timer.stop()
if self.state == "WALK" and not self.moving:
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.walk)
self.timer.start(500)
elif self.state == "DANCE":
self.dance()
elif self.state == "STUPID":
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.stupid)
self.timer.start(20)
# Set previous state to the current state
self.previous_state = self.state
# Randomly choose a sate
# I could probably use one function for randomly choosing and manually picking a state, I'll figure it out later
def end_state(self):
self.idle()
self.state = random.choice(self.state_list)
self.timer.stop()
if self.state == "WALK" and not self.moving:
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.walk)
self.timer.start(500)
# If the chosen state is "Dance" or "Stupid", choose again
elif self.state == "DANCE":
if self.previous_state == "DANCE":
self.end_state()
return
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.dance)
self.timer.start(random.randint(1, 2) * 1000)
elif self.state == "STUPID":
if self.previous_state == "STUPID":
self.end_state()
return
self.timer = QtCore.QTimer(self)
self.timer.setSingleShot(True)
self.timer.timeout.connect(self.stupid)
self.timer.start(random.randint(1, 2) * 1000)
# Set previous state to the current state
self.previous_state = self.state
# Move state
def walk(self):
# Select a random direction
self.dir_list = [4, -4]
self.dir_x = random.choice(self.dir_list)
self.dir_y = random.choice(self.dir_list)
# Select the correct animation depending on the direction
if self.dir_x > 0:
self.gif = QMovie(self.front_walk_right_sprite)
elif self.dir_x < 0:
self.gif = QMovie(self.front_walk_left_sprite)
self.setMovie(self.gif)
self.gif.start()
# Start the timers for the walk state
self.walk_timer = QtCore.QTimer(self)
self.walk_timer.setSingleShot(True)
self.walk_timer.timeout.connect(self.stop_walk)
self.walk_timer.start(2000)
self.move_timer = QtCore.QTimer(self)
self.move_timer.timeout.connect(self.walk_move)
self.move_timer.start(20)
# Move the character
def walk_move(self):
if self.state == "WALK":
self.moving = True
self.move(self.pos() + QPoint(self.dir_x, self.dir_y))
# Bounce off the screen limits
# Using magic numbers here, I'll fix it later
if self.pos().x() < -250:
self.gif = QMovie(self.front_walk_right_sprite)
self.setMovie(self.gif)
self.gif.start()
self.dir_x *= -1
if self.pos().x() > self.max_width - 400:
self.gif = QMovie(self.front_walk_left_sprite)
self.setMovie(self.gif)
self.gif.start()
self.dir_x *= -1
if self.pos().y() < -150:
self.dir_y *= -1
if self.pos().y() > self.max_height - 400:
self.dir_y *= -1
elif self.state == "DRAG":
self.stop_walk()
# Stop moving
def stop_walk(self):
self.moving = False
self.move_timer.stop()
if self.state == "WALK":
self.gif.stop()
self.end_state()
# THIS IS STUPID state
def stupid(self):
# Set the "THIS IS STUPID" animation
self.loop_count = 0 # Initialize the animation loop count
self.gif = QMovie(self.stupid_sprite)
self.setMovie(self.gif)
self.gif.start()
self.loop_limit = random.randint(3, 5) # Randomly choose how many times the animation should loop
self.gif.updated.connect(self.check_for_anim_finished) # Check every frame if the animation has finished
# Dance state
def dance(self):
# Same thing for the dance animation
self.loop_count = 0
self.gif = QMovie(self.dance_sprite)
self.setMovie(self.gif)
self.gif.start()
self.loop_limit = random.randint(2, 3)
self.gif.updated.connect(self.check_for_anim_finished)
def check_for_anim_finished(self):
# Add to the loop count if the animation is finished
if self.gif.currentFrameNumber()+1 == self.gif.frameCount():
self.loop_count += 1
# If the loop count is greater than or equal to the loop limit, stop the animation and randomly choose a state
if self.loop_count >= self.loop_limit:
self.gif.stop()
self.end_state()
# Idle state
def idle(self):
# Choose the graphics depending on the direction the character is facing
if self.dir_x > 0:
self.pixmap = QPixmap(self.front_right_sprite)
elif self.dir_x < 0:
self.pixmap = QPixmap(self.front_left_sprite)
self.setPixmap(self.pixmap)
# Drag state
def drag(self):
# Stop timers
self.timer.stop()
if self.move_timer is not None:
if self.move_timer.isActive():
self.move_timer.stop()
self.state = "DRAG" # Change state to Drag
# Set the corresponding animations for the Drag state
self.gif = QMovie(self.abscond_sprite)
self.setMovie(self.gif)
self.gif.start()
def release_drag(self):
# Stop the drag animation, and randomly choose a state
self.gif.stop()
self.idle()
self.end_state()
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
# If the left mouse button is pressed over the character, call the drag state
self.__press_pos = event.pos()
self.drag()
def mouseReleaseEvent(self, event):
if event.button() == Qt.LeftButton:
# If the character is released, call the releaseDrag function
self.__press_pos = QPoint()
self.release_drag()
def mouseMoveEvent(self, event):
if not self.__press_pos.isNull():
# Check against screen limits. If it's not colliding, move the character
# Using magic numbers here too, I'll fix it later
if (not event.globalX() - self.__press_pos.x() < -250
and not event.globalX() - self.__press_pos.x() > self.max_width - 400
and not event.globalY() - self.__press_pos.y() < -150
and not event.globalY() - self.__press_pos.y() > self.max_height - 400):
self.move(self.pos() + (event.pos() - self.__press_pos))
# Stop function called when the character is despawned
# Instead of creating a new character object every time, it's just hidden until it's called again
def stop(self):
self.timer.stop()
if self.move_timer is not None:
if self.move_timer.isActive():
self.move_timer.stop()
self.state = "STOP"
class JohnBuddy(HomestuckBuddy):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Assign the corresponding graphics
self.front_left_sprite = resource_path("graphics/john/john-front-left.png")
self.front_right_sprite = resource_path("graphics/john/john-front-right.png")
self.front_walk_left_sprite = resource_path("graphics/john/john-front-walk-left.gif")
self.front_walk_right_sprite = resource_path("graphics/john/john-front-walk-right.gif")
self.dance_sprite = resource_path("graphics/john/john-dance.gif")
self.abscond_sprite = resource_path("graphics/john/john-abscond.gif")
self.stupid_sprite = resource_path("graphics/john/john-stupid.gif")
self.init_ui()
class RoseBuddy(HomestuckBuddy):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Assign the corresponding graphics
self.front_left_sprite = resource_path("graphics/rose/rose-front-left.png")
self.front_right_sprite = resource_path("graphics/rose/rose-front-right.png")
self.front_walk_left_sprite = resource_path("graphics/rose/rose-front-walk-left.gif")
self.front_walk_right_sprite = resource_path("graphics/rose/rose-front-walk-right.gif")
self.dance_sprite = resource_path("graphics/rose/rose-laptop.gif")
self.abscond_sprite = resource_path("graphics/rose/rose-abscond.gif")
self.stupid_sprite = resource_path("graphics/rose/rose-facepalm.gif")
self.init_ui()
class DaveBuddy(HomestuckBuddy):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Assign the corresponding graphics
self.front_left_sprite = resource_path("graphics/dave/dave-front-left.png")
self.front_right_sprite = resource_path("graphics/dave/dave-front-right.png")
self.front_walk_left_sprite = resource_path("graphics/dave/dave-front-walk-left.gif")
self.front_walk_right_sprite = resource_path("graphics/dave/dave-front-walk-right.gif")
self.dance_sprite = resource_path("graphics/dave/dave-jump.gif")
self.abscond_sprite = resource_path("graphics/dave/dave-abscond.gif")
self.stupid_sprite = resource_path("graphics/dave/dave-roll.gif")
self.init_ui()
class JadeBuddy(HomestuckBuddy):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Assign the corresponding graphics
self.front_left_sprite = resource_path("graphics/jade/jade-front-left.png")
self.front_right_sprite = resource_path("graphics/jade/jade-front-right.png")
self.front_walk_left_sprite = resource_path("graphics/jade/jade-front-walk-left.gif")
self.front_walk_right_sprite = resource_path("graphics/jade/jade-front-walk-right.gif")
self.dance_sprite = resource_path("graphics/jade/jade-bass.gif")
self.abscond_sprite = resource_path("graphics/jade/jade-abscond.gif")
self.stupid_sprite = resource_path("graphics/jade/jade-sleep.gif")
self.init_ui()
def main():
random.seed(None) # Randomize the seed
# Create the application
app = QApplication(sys.argv)
w = BuddySelection()
w.show()
return app.exec_()
if __name__ == '__main__':
sys.exit(main())