|
|
@ -32,26 +32,21 @@ class ExpButton(Widget): |
|
|
|
self._experimental_mode = selfdrive_state.experimentalMode |
|
|
|
self._experimental_mode = selfdrive_state.experimentalMode |
|
|
|
self._engageable = selfdrive_state.engageable or selfdrive_state.enabled |
|
|
|
self._engageable = selfdrive_state.engageable or selfdrive_state.enabled |
|
|
|
|
|
|
|
|
|
|
|
def handle_mouse_event(self) -> bool: |
|
|
|
def _handle_mouse_release(self, _): |
|
|
|
if rl.check_collision_point_rec(rl.get_mouse_position(), self._rect): |
|
|
|
super()._handle_mouse_release(_) |
|
|
|
if (rl.is_mouse_button_released(rl.MouseButton.MOUSE_BUTTON_LEFT) and |
|
|
|
if self._is_toggle_allowed(): |
|
|
|
self._is_toggle_allowed()): |
|
|
|
new_mode = not self._experimental_mode |
|
|
|
new_mode = not self._experimental_mode |
|
|
|
self._params.put_bool("ExperimentalMode", new_mode) |
|
|
|
self._params.put_bool("ExperimentalMode", new_mode) |
|
|
|
|
|
|
|
|
|
|
|
# Hold new state temporarily |
|
|
|
# Hold new state temporarily |
|
|
|
self._held_mode = new_mode |
|
|
|
self._held_mode = new_mode |
|
|
|
self._hold_end_time = time.monotonic() + self._hold_duration |
|
|
|
self._hold_end_time = time.monotonic() + self._hold_duration |
|
|
|
|
|
|
|
return True |
|
|
|
|
|
|
|
return False |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _render(self, rect: rl.Rectangle) -> None: |
|
|
|
def _render(self, rect: rl.Rectangle) -> None: |
|
|
|
center_x = int(self._rect.x + self._rect.width // 2) |
|
|
|
center_x = int(self._rect.x + self._rect.width // 2) |
|
|
|
center_y = int(self._rect.y + self._rect.height // 2) |
|
|
|
center_y = int(self._rect.y + self._rect.height // 2) |
|
|
|
|
|
|
|
|
|
|
|
mouse_over = rl.check_collision_point_rec(rl.get_mouse_position(), self._rect) |
|
|
|
self._white_color.a = 180 if self.is_pressed or not self._engageable else 255 |
|
|
|
mouse_down = rl.is_mouse_button_down(rl.MouseButton.MOUSE_BUTTON_LEFT) and self.is_pressed |
|
|
|
|
|
|
|
self._white_color.a = 180 if (mouse_down and mouse_over) or not self._engageable else 255 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
texture = self._txt_exp if self._held_or_actual_mode() else self._txt_wheel |
|
|
|
texture = self._txt_exp if self._held_or_actual_mode() else self._txt_wheel |
|
|
|
rl.draw_circle(center_x, center_y, self._rect.width / 2, self._black_bg) |
|
|
|
rl.draw_circle(center_x, center_y, self._rect.width / 2, self._black_bg) |
|
|
|