Skip to content

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ZyMa-1 committed Jan 18, 2024
1 parent d9cc27e commit fb70149
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/backend/PathManager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
import pathlib


Expand Down
18 changes: 10 additions & 8 deletions src/conways_game_of_life/ConwaysGameOfLife.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,20 @@ def __init__(self, parent=None):
self._timer = QTimer(self)

# Connect signals to slots
self._timer.timeout.connect(self.engine.make_turn)
# Engine signals connection (wrapping included)
self.engine.property_setter_error_signal.connect(self.property_setter_error_signal)
self.engine.board_changed.connect(self._handle_board_changed)
self._timer.timeout.connect(self.engine.make_turn)
self.engine.turn_number_changed.connect(self.turn_number_changed)

def _reset_to_defaults(self):
self._border_thickness = DEFAULT_BORDER_THICKNESS
self._border_color = ColorProperty(DEFAULT_BORDER_COLOR)
self._cell_alive_color = ColorProperty(DEFAULT_CELL_ALIVE_COLOR)
self._cell_dead_color = ColorProperty(DEFAULT_CELL_DEAD_COLOR)
self._is_game_running = False
self._edit_mode = ConwaysGameOfLife.EditMode.DEFAULT
# Nuh-uh,
# self._edit_mode = ConwaysGameOfLife.EditMode.DEFAULT
self._turn_duration = DEFAULT_TURN_DURATION
self._active_cell = (0, 0)

Expand Down Expand Up @@ -303,13 +306,12 @@ def paintEvent(self, event):
@Slot()
def _handle_board_changed(self):
"""Handles 'board_changed' signal of the engine"""
if self.is_game_running:
return
if self._active_cell is not None:
if self._active_cell[0] >= self.engine.rows:
self._active_cell = (self.engine.rows - 1, self._active_cell[1])
if self._active_cell[1] >= self.engine.cols:
self._active_cell = (self._active_cell[0], self.engine.cols - 1)

if self._active_cell[0] >= self.engine.rows:
self._active_cell = (self.engine.rows - 1, self._active_cell[1])
if self._active_cell[1] >= self.engine.cols:
self._active_cell = (self._active_cell[0], self.engine.cols - 1)
self.update()

# Miscellaneous stuff
Expand Down

0 comments on commit fb70149

Please sign in to comment.