Skip to content

Commit

Permalink
Stop storing args in self.
Browse files Browse the repository at this point in the history
Store background_color there instead.
  • Loading branch information
porridge committed Jul 15, 2023
1 parent 833241e commit 4bcfb74
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions bambam.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def load_items(cls, lst, blacklist, load_function, failure_message):

def __init__(self):
self.data_dirs = []
self.args = None

self.background_color = None
self.background = None
self.screen = None
self.display_height = None
Expand Down Expand Up @@ -274,7 +274,6 @@ def _prepare_background(self):
command_strings = [QUIT_STRING]
# noinspection PyArgumentList
self.background = pygame.Surface(self.screen.get_size()).convert()
self.background_color = (0, 0, 0) if self.args.dark else (250, 250, 250)
self.background.fill(self.background_color)
caption_font = pygame.font.SysFont(None, 20)
caption_label = caption_font.render(
Expand Down Expand Up @@ -428,7 +427,7 @@ def run(self):
help=_('Do not prevent running under Wayland.'))
parser.add_argument('--in-dedicated-session', action='store_true',
help=argparse.SUPPRESS)
self.args = parser.parse_args()
args = parser.parse_args()

pygame.init()

Expand All @@ -441,6 +440,7 @@ def run(self):
else:
self._sound_enabled = True

self.background_color = (0, 0, 0) if args.dark else (250, 250, 250)
pygame.display.set_mode((0, 0), pygame.FULLSCREEN)

# determine display resolution
Expand All @@ -458,9 +458,9 @@ def run(self):
self.screen.blit(self.background, (0, 0))
pygame.display.flip()

if self.args.in_dedicated_session:
if args.in_dedicated_session:
self._prepare_welcome_message(dedicated_session=True)
elif not self.args.wayland_ok and (os.getenv('WAYLAND_DISPLAY') or os.getenv('XDG_SESSION_TYPE') == 'wayland'):
elif not args.wayland_ok and (os.getenv('WAYLAND_DISPLAY') or os.getenv('XDG_SESSION_TYPE') == 'wayland'):
self._prepare_wayland_warning()
poll_for_any_key_press(clock)
sys.exit(1)
Expand All @@ -470,14 +470,14 @@ def run(self):
self.screen.blit(self.background, (0, 0))
pygame.display.flip()

self.sound_muted = self.args.mute
self.sound_muted = args.mute
self._image_mapper = LegacyImageMapper()
self._sound_mapper = LegacySoundMapper(self.args.deterministic_sounds)
self._sound_mapper = LegacySoundMapper(args.deterministic_sounds)

if self._sound_enabled:
sounds = self.load_items(
self.glob_data(['.wav', '.ogg']),
self.args.sound_blacklist,
args.sound_blacklist,
self.load_sound,
_("All sounds failed to load."))

Expand All @@ -489,12 +489,12 @@ def run(self):

images = self.load_items(
self.glob_data(['.gif', '.jpg', '.jpeg', '.png', '.tif', '.tiff']),
self.args.image_blacklist,
args.image_blacklist,
self.load_image,
_("All images failed to load."))

self._image_policies = dict(
font=FontImagePolicy(self.args.uppercase),
font=FontImagePolicy(args.uppercase),
random=RandomPolicy(images),
)

Expand Down

0 comments on commit 4bcfb74

Please sign in to comment.