Skip to content

Commit f2576c8

Browse files
Put repeated methods into an inheritable class
1 parent 1ebed95 commit f2576c8

File tree

3 files changed

+120
-126
lines changed

3 files changed

+120
-126
lines changed

AlgoVisual.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ def main(fps):
9595
if (sorting_actions is not None):
9696
sorting_actions.update()
9797

98-
if (window.options_screen):
99-
options_screen_group.draw(window.window)
100-
options_screen_group.update()
98+
#if (window.options_screen):
99+
options_screen_group.draw(window.window)
100+
options_screen_group.update()
101101
text_box_group.draw(window.window)
102102
text_box_group.update(events_list)
103103

UI/UI.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def display_main_menu(window, slide_in, screen_group, options_screen_group):
3838
pressed_sorting = Wrapper.add_args_to_func(MainMenuActions.pressed_sorting, window)
3939
pressed_graph = Wrapper.add_args_to_func(MainMenuActions.pressed_graph, window)
4040
screen_group.add(Wrapper.Text(Wrapper.DefaultText.text("Algorithm Visualizer", Wrapper.FontSizes.TITLE_SIZE), (window.window.get_size()[0]/2, TITLE_Y), window, slide_in))
41-
screen_group.add(Wrapper.TextButton(Wrapper.DefaultText.text("Sorting", Wrapper.FontSizes.BUTTON_SIZE), ((window.window.get_size()[0]/2), SORTING_Y), pressed_sorting, window, slide_in))
42-
screen_group.add(Wrapper.TextButton(Wrapper.DefaultText.text("Graphs", Wrapper.FontSizes.BUTTON_SIZE), ((window.window.get_size()[0]/2), GRAPH_Y), pressed_graph, window, slide_in))
41+
screen_group.add(Wrapper.TextButton(Wrapper.DefaultText.text("Sorting", Wrapper.FontSizes.BUTTON_SIZE), ((window.window.get_size()[0] / 2), SORTING_Y), pressed_sorting, window, slide_in))
42+
screen_group.add(Wrapper.TextButton(Wrapper.DefaultText.text("Graphs", Wrapper.FontSizes.BUTTON_SIZE), ((window.window.get_size()[0] / 2), GRAPH_Y), pressed_graph, window, slide_in))
4343

4444
# Options
4545
OptionActions.display_options_button(window, screen_group, options_screen_group)
@@ -59,7 +59,7 @@ def display_options_button(window, screen_group, options_screen_group):
5959
options_button_2 = pygame.transform.rotozoom(options_button_2, 0, 0.1)
6060
display_options = Wrapper.add_args_to_func(OptionActions.display_options, window, options_screen_group)
6161
# TODO: Crop image properly using Figma
62-
screen_group.add(Wrapper.Button((options_button_1, options_button_2), ((window.window.get_size()[0])-40, 40), display_options, window, False, Wrapper.Screen.NONE))
62+
screen_group.add(Wrapper.Button((options_button_1, options_button_2), ((window.window.get_size()[0])-40, 40), display_options, window, True))
6363

6464
# Input (specifically buttons)
6565

@@ -91,7 +91,7 @@ def display_options(window, options_group):
9191
options_group.empty()
9292

9393
# Draw everything
94-
options_group.add(Wrapper.Background((window.window.get_size()[0]/2, window.window.get_size()[1]/2), (OPTIONS_WIDTH, OPTIONS_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR, 3, window))
94+
options_group.add(Wrapper.Background((window.window.get_size()[0]/2, window.window.get_size()[1]/2), (OPTIONS_WIDTH, OPTIONS_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR, window, False, 3))
9595

9696
# Where the text starts rendering
9797
text_start = window.window.get_size()[1]/2 - OPTIONS_HEIGHT/2 + 50
@@ -218,7 +218,7 @@ def display_sorting(self, screen_group, options_screen_group):
218218
# Drawing Everything
219219
screen_group.empty()
220220
screen_group.add(Wrapper.Text(Wrapper.DefaultText.text("Sorting", Wrapper.FontSizes.TITLE_SIZE), (self.window.window.get_size()[0]/2, self.TITLE_Y), self.window))
221-
screen_group.add(Wrapper.Background((self.SORTING_X, self.SORTING_Y), (self.SORTING_WIDTH, self.SORTING_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR))
221+
screen_group.add(Wrapper.Background((self.SORTING_X, self.SORTING_Y), (self.SORTING_WIDTH, self.SORTING_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR, self.window, False))
222222

223223
def set_sorting_thread(thread):
224224
if self.sorting_thread is not None:
@@ -299,7 +299,7 @@ def show_advanced(self):
299299

300300
# Draw everything
301301
self.options_group.empty()
302-
self.options_group.add(Wrapper.Background((self.window.window.get_size()[0]/2, self.window.window.get_size()[1]/2), (OPTIONS_WIDTH, OPTIONS_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR, 3, self.window))
302+
self.options_group.add(Wrapper.Background((self.window.window.get_size()[0]/2, self.window.window.get_size()[1]/2), (OPTIONS_WIDTH, OPTIONS_HEIGHT), Wrapper.Colors.SMALL_BACKGROUND_COLOR, self.window, False, 3))
303303

304304
# Exit button
305305
exit_1 = pygame.image.load('Button/remove.png').convert_alpha()

0 commit comments

Comments
 (0)