mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-06-30 02:52:04 +08:00
4ccafff123
* fix multilang dialog height
* split to file
* stash
* Revert "stash"
This reverts commit deb4239fe69f0260420fad03f2350e622e31542f.
* add updater
* add files
* stuff
* try
rev
* stash
* works!
* works!
* this should be the flow?
* cursor wrapping -- it missed entire sections, changed formatting, and didn't use trn properly!!!!!!!!!!!!!!!!!
* update translations
* learned my lesson
* this should be the one thing it's good at
* update trans
* onroad wrap
* spanish
* rename
* clean up
* load all
* Revert "load all"
This reverts commit 6f2a45861c914ffb9d40a5edd15751afd798d614.
* jp translations
* try jp
* Revert "try jp"
This reverts commit d0524b10110104baafcdc1ec385c3d57bc5ef901.
* remove languages we can't add rn
* tr
* pt and fr
* ai cannot be trusted
* ai cannot be trusted
* missing trans
* add fonts
* Revert "remove languages we can't add rn"
This reverts commit 73dc75fae2b9e347d867b6636dab6e2b5fe59da7.
* painfully slow to startup
* only load what we need
* Reapply "remove languages we can't add rn"
This reverts commit 52cb48f3b838520a421f9b90e5ea4409c27d4bd0.
* add system
* that's sick that this just works (dynamic)
* fix description falling back to first str + support callable titles in list items
* device is now live!
* make firehose live
* developer
* network live
* software live
* and that
* toggles live
* regen
* start to clean up gpt
* revert op sans
* bruh
* update translations
* rm old script
* add noops for descriptions to fix translating away from non-english after startup
* missing de
* do filtering in multilang.py
* clean up
clean up
* codespell: ignore po
* fix update
* should not depend
* more live
* sidebar and offroad alert panel live
* fix issues with offroad alerts
* fix firehose live
* fix weird tr("") behavior
* sh key live bugfix
* setup.py live
* update
* update
* no fuzzy matching -- breaks dynamic translations
* rm this
* fix calib desc live trans
* change onroad
* rm dfonts
* clean up device
* missing live
* update
* op lint
* not true
* add to gitignore
* speed up startup by reducing chars by ~half
* fix scons
* fix crash going from qt
* preserve original lang
* cancel kb live translate
* no preserve
* fix lint
102 lines
3.8 KiB
Python
102 lines
3.8 KiB
Python
import pyray as rl
|
|
from openpilot.common.time_helpers import system_time_valid
|
|
from openpilot.selfdrive.ui.ui_state import ui_state
|
|
from openpilot.selfdrive.ui.widgets.pairing_dialog import PairingDialog
|
|
from openpilot.system.ui.lib.application import gui_app, FontWeight, FONT_SCALE
|
|
from openpilot.system.ui.lib.multilang import tr
|
|
from openpilot.system.ui.lib.wrap_text import wrap_text
|
|
from openpilot.system.ui.widgets import Widget
|
|
from openpilot.system.ui.widgets.confirm_dialog import alert_dialog
|
|
from openpilot.system.ui.widgets.button import Button, ButtonStyle
|
|
from openpilot.system.ui.widgets.label import Label
|
|
|
|
|
|
class SetupWidget(Widget):
|
|
def __init__(self):
|
|
super().__init__()
|
|
self._open_settings_callback = None
|
|
self._pairing_dialog: PairingDialog | None = None
|
|
self._pair_device_btn = Button(lambda: tr("Pair device"), self._show_pairing, button_style=ButtonStyle.PRIMARY)
|
|
self._open_settings_btn = Button(lambda: tr("Open"), lambda: self._open_settings_callback() if self._open_settings_callback else None,
|
|
button_style=ButtonStyle.PRIMARY)
|
|
self._firehose_label = Label(lambda: tr("🔥 Firehose Mode 🔥"), font_weight=FontWeight.MEDIUM, font_size=64)
|
|
|
|
def set_open_settings_callback(self, callback):
|
|
self._open_settings_callback = callback
|
|
|
|
def _render(self, rect: rl.Rectangle):
|
|
if not ui_state.prime_state.is_paired():
|
|
self._render_registration(rect)
|
|
else:
|
|
self._render_firehose_prompt(rect)
|
|
|
|
def _render_registration(self, rect: rl.Rectangle):
|
|
"""Render registration prompt."""
|
|
|
|
rl.draw_rectangle_rounded(rl.Rectangle(rect.x, rect.y, rect.width, rect.height), 0.03, 20, rl.Color(51, 51, 51, 255))
|
|
|
|
x = rect.x + 64
|
|
y = rect.y + 48
|
|
w = rect.width - 128
|
|
|
|
# Title
|
|
font = gui_app.font(FontWeight.BOLD)
|
|
rl.draw_text_ex(font, tr("Finish Setup"), rl.Vector2(x, y), 75, 0, rl.WHITE)
|
|
y += 113 # 75 + 38 spacing
|
|
|
|
# Description
|
|
desc = tr("Pair your device with comma connect (connect.comma.ai) and claim your comma prime offer.")
|
|
light_font = gui_app.font(FontWeight.LIGHT)
|
|
wrapped = wrap_text(light_font, desc, 50, int(w))
|
|
for line in wrapped:
|
|
rl.draw_text_ex(light_font, line, rl.Vector2(x, y), 50, 0, rl.WHITE)
|
|
y += 50 * FONT_SCALE
|
|
|
|
button_rect = rl.Rectangle(x, y + 30, w, 200)
|
|
self._pair_device_btn.render(button_rect)
|
|
|
|
def _render_firehose_prompt(self, rect: rl.Rectangle):
|
|
"""Render firehose prompt widget."""
|
|
|
|
rl.draw_rectangle_rounded(rl.Rectangle(rect.x, rect.y, rect.width, 500), 0.04, 20, rl.Color(51, 51, 51, 255))
|
|
|
|
# Content margins (56, 40, 56, 40)
|
|
x = rect.x + 56
|
|
y = rect.y + 40
|
|
w = rect.width - 112
|
|
spacing = 42
|
|
|
|
# Title with fire emojis
|
|
self._firehose_label.render(rl.Rectangle(rect.x, y, rect.width, 64))
|
|
y += 64 + spacing
|
|
|
|
# Description
|
|
desc_font = gui_app.font(FontWeight.NORMAL)
|
|
desc_text = tr("Maximize your training data uploads to improve openpilot's driving models.")
|
|
wrapped_desc = wrap_text(desc_font, desc_text, 40, int(w))
|
|
|
|
for line in wrapped_desc:
|
|
rl.draw_text_ex(desc_font, line, rl.Vector2(x, y), 40, 0, rl.WHITE)
|
|
y += 40 * FONT_SCALE
|
|
|
|
y += spacing
|
|
|
|
# Open button
|
|
button_height = 48 + 64 # font size + padding
|
|
button_rect = rl.Rectangle(x, y, w, button_height)
|
|
self._open_settings_btn.render(button_rect)
|
|
|
|
def _show_pairing(self):
|
|
if not system_time_valid():
|
|
dlg = alert_dialog(tr("Please connect to Wi-Fi to complete initial pairing"))
|
|
gui_app.set_modal_overlay(dlg)
|
|
return
|
|
|
|
if not self._pairing_dialog:
|
|
self._pairing_dialog = PairingDialog()
|
|
gui_app.set_modal_overlay(self._pairing_dialog, lambda result: setattr(self, '_pairing_dialog', None))
|
|
|
|
def __del__(self):
|
|
if self._pairing_dialog:
|
|
del self._pairing_dialog
|