-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAlgoVisual.py
More file actions
115 lines (99 loc) · 4.6 KB
/
AlgoVisual.py
File metadata and controls
115 lines (99 loc) · 4.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
from sys import exit
import pygame
import pygame.midi
import this
import UI.UI as UI
import UI.Wrapper as Wrapper
def main(fps):
'''Equivalent of public static void main(String[] args)'''
pygame.init()
pygame.midi.init()
window = Wrapper.Window(1200, 600, Wrapper.Screen.NONE, True, False)
midi = Wrapper.Midi()
screen_group = pygame.sprite.Group()
options_real_group = pygame.sprite.Group()
options_screen_group = pygame.sprite.Group()
sorting_group = pygame.sprite.Group()
aux_sorting_group = pygame.sprite.Group()
# TODO: Find a way to not have to make an entire sprite group
scroll_group_1 = pygame.sprite.Group()
scroll_group_2 = pygame.sprite.Group()
text_box_group = pygame.sprite.Group()
scroll_bar = []
sorting_actions = None
UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group, midi)
while True:
# General Events should be placed here
events_list = pygame.event.get()
for event in events_list:
# If window changes size
if event.type == pygame.VIDEORESIZE:
width, height = event.size
window.change(width, height, window.screen, False, True)
if event.type == pygame.QUIT:
window.event.set()
del midi
pygame.midi.quit()
pygame.quit()
exit()
# apparentally python has no switch cases?
# This should only have logic for what to do when its on screen x or something like that
if (window.screen == Wrapper.Screen.MAIN_MENU and window.window_size_change):
options_real_group = UI.MainMenuActions.display_main_menu(window, False, screen_group, options_screen_group, midi)
window.window_size_change = False
elif (window.screen == Wrapper.Screen.MAIN_MENU and window.screen_change):
options_real_group = UI.MainMenuActions.display_main_menu(window, True, screen_group, options_screen_group, midi)
window.screen_change = False
elif (window.screen == Wrapper.Screen.SORTING_SCREEN and window.screen_change):
sorting_actions = UI.SortingActions(window, screen_group, sorting_group, aux_sorting_group, [scroll_group_1, scroll_group_2], options_screen_group, text_box_group, midi)
scroll_bar = sorting_actions.display_sorting(screen_group, options_screen_group, True)
window.screen_change = False
# TODO: make objects on screen scale better when screen size changes
elif (window.screen == Wrapper.Screen.SORTING_SCREEN and window.window_size_change):
scroll_bar = sorting_actions.display_sorting(screen_group, options_screen_group, False)
window.window_size_change = False
# This should update everything (Logic to update everything)
window.update() # Clears the screen
screen_group.draw(window.window)
screen_group.update()
if (window.screen == Wrapper.Screen.SORTING_SCREEN):
sorting_group.draw(window.window)
sorting_group.update()
aux_sorting_group.draw(window.window)
aux_sorting_group.update()
# find a way to just get rid of this logic for future
extended = -1
if (scroll_bar != None):
for i in range(len(scroll_bar)):
if (scroll_bar[i].extended):
extended = i
scroll_group_1.draw(window.window)
scroll_group_1.update()
scroll_group_2.draw(window.window)
scroll_group_2.update()
# Maybe make enum class instead
if (extended != -1):
if (extended == 0):
scroll_group_1.draw(window.window)
scroll_group_1.update()
elif (extended == 1):
scroll_group_2.draw(window.window)
scroll_group_2.update()
if (scroll_bar is not None):
for scroll in scroll_bar:
scroll.button_checks()
if (sorting_actions is not None):
sorting_actions.update()
#if (window.options_screen):
options_screen_group.draw(window.window)
options_screen_group.update()
text_box_group.draw(window.window)
text_box_group.update(events_list)
options_real_group.update()
# Must have to update
pygame.display.update()
midi.update()
window.clock.tick(fps)
# If only this file is run, then the code is executed
if __name__ == "__main__":
main(60)