mirror of
https://github.com/RYDE-WORK/ballistica.git
synced 2026-02-07 08:03:30 +08:00
Edit browser.py
This commit is contained in:
parent
baefe3dcba
commit
4a75399f3e
@ -197,9 +197,11 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
bui.containerwidget(
|
bui.containerwidget(
|
||||||
edit=self._root_widget, selected_child=self._scrollwidget
|
edit=self._root_widget, selected_child=self._scrollwidget
|
||||||
)
|
)
|
||||||
self._columnwidget = bui.columnwidget(
|
self._subcontainer = bui.containerwidget(
|
||||||
parent=self._scrollwidget, border=2, margin=0
|
parent=self._scrollwidget,
|
||||||
)
|
size=(self._scroll_width, 32),
|
||||||
|
background=False,
|
||||||
|
)
|
||||||
v -= 255
|
v -= 255
|
||||||
self._profiles: dict[str, dict[str, Any]] | None = None
|
self._profiles: dict[str, dict[str, Any]] | None = None
|
||||||
self._selected_profile = selected_profile
|
self._selected_profile = selected_profile
|
||||||
@ -344,6 +346,7 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
# pylint: disable=too-many-locals
|
# pylint: disable=too-many-locals
|
||||||
from efro.util import asserttype
|
from efro.util import asserttype
|
||||||
from bascenev1 import PlayerProfilesChangedMessage
|
from bascenev1 import PlayerProfilesChangedMessage
|
||||||
|
from bascenev1lib.actor import spazappearance
|
||||||
|
|
||||||
assert bui.app.classic is not None
|
assert bui.app.classic is not None
|
||||||
|
|
||||||
@ -359,14 +362,27 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
assert self._profiles is not None
|
assert self._profiles is not None
|
||||||
items = list(self._profiles.items())
|
items = list(self._profiles.items())
|
||||||
items.sort(key=lambda x: asserttype(x[0], str).lower())
|
items.sort(key=lambda x: asserttype(x[0], str).lower())
|
||||||
|
spazzes = spazappearance.get_appearances()
|
||||||
|
spazzes.sort()
|
||||||
|
icon_textures = [
|
||||||
|
bui.gettexture(bui.app.classic.spaz_appearances[s].icon_texture)
|
||||||
|
for s in spazzes
|
||||||
|
]
|
||||||
|
icon_tint_textures = [
|
||||||
|
bui.gettexture(
|
||||||
|
bui.app.classic.spaz_appearances[s].icon_mask_texture
|
||||||
|
)
|
||||||
|
for s in spazzes
|
||||||
|
]
|
||||||
index = 0
|
index = 0
|
||||||
|
y_val = 35 * (len(self._profiles) - 1)
|
||||||
account_name: str | None
|
account_name: str | None
|
||||||
if plus.get_v1_account_state() == 'signed_in':
|
if plus.get_v1_account_state() == 'signed_in':
|
||||||
account_name = plus.get_v1_account_display_string()
|
account_name = plus.get_v1_account_display_string()
|
||||||
else:
|
else:
|
||||||
account_name = None
|
account_name = None
|
||||||
widget_to_select = None
|
|
||||||
for p_name, _ in items:
|
for p_name, p_info in items:
|
||||||
if p_name == '__account__' and account_name is None:
|
if p_name == '__account__' and account_name is None:
|
||||||
continue
|
continue
|
||||||
color, _highlight = bui.app.classic.get_player_profile_colors(
|
color, _highlight = bui.app.classic.get_player_profile_colors(
|
||||||
@ -379,15 +395,32 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
else bui.app.classic.get_player_profile_icon(p_name) + p_name
|
else bui.app.classic.get_player_profile_icon(p_name) + p_name
|
||||||
)
|
)
|
||||||
assert isinstance(tval, str)
|
assert isinstance(tval, str)
|
||||||
|
character = bui.buttonwidget(
|
||||||
|
parent=self._subcontainer,
|
||||||
|
position=(0, y_val),
|
||||||
|
size=(28, 28),
|
||||||
|
label='',
|
||||||
|
color=(1, 1, 1),
|
||||||
|
mask_texture=bui.gettexture('characterIconMask'),
|
||||||
|
tint_color=color,
|
||||||
|
tint2_color=_highlight,
|
||||||
|
texture=icon_textures[
|
||||||
|
spazzes.index(p_info['character'])
|
||||||
|
],
|
||||||
|
tint_texture=icon_tint_textures[
|
||||||
|
spazzes.index(p_info['character'])
|
||||||
|
],
|
||||||
|
selectable=False,
|
||||||
|
)
|
||||||
txtw = bui.textwidget(
|
txtw = bui.textwidget(
|
||||||
parent=self._columnwidget,
|
parent=self._subcontainer,
|
||||||
position=(0, 32),
|
position=(35, y_val),
|
||||||
size=((self._width - 210) / scl, 28),
|
size=((self._width - 40) / scl, 28),
|
||||||
text=bui.Lstr(value=tval),
|
text=bui.Lstr(value=tval),
|
||||||
h_align='left',
|
h_align='left',
|
||||||
v_align='center',
|
v_align='center',
|
||||||
on_select_call=bui.WeakCall(self._select, p_name, index),
|
on_select_call=bui.WeakCall(self._select, p_name, index),
|
||||||
maxwidth=self._scroll_width * 0.86,
|
maxwidth=self._scroll_width * 0.92,
|
||||||
corner_scale=scl,
|
corner_scale=scl,
|
||||||
color=bui.safecolor(color, 0.4),
|
color=bui.safecolor(color, 0.4),
|
||||||
always_highlight=True,
|
always_highlight=True,
|
||||||
@ -398,6 +431,7 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
bui.widget(edit=txtw, up_widget=self._back_button)
|
bui.widget(edit=txtw, up_widget=self._back_button)
|
||||||
bui.widget(edit=txtw, show_buffer_top=40, show_buffer_bottom=40)
|
bui.widget(edit=txtw, show_buffer_top=40, show_buffer_bottom=40)
|
||||||
self._profile_widgets.append(txtw)
|
self._profile_widgets.append(txtw)
|
||||||
|
self._profile_widgets.append(character)
|
||||||
|
|
||||||
# Select/show this one if it was previously selected
|
# Select/show this one if it was previously selected
|
||||||
# (but defer till after this loop since our height is
|
# (but defer till after this loop since our height is
|
||||||
@ -406,10 +440,15 @@ class ProfileBrowserWindow(bui.Window):
|
|||||||
widget_to_select = txtw
|
widget_to_select = txtw
|
||||||
|
|
||||||
index += 1
|
index += 1
|
||||||
|
y_val -= 35
|
||||||
|
|
||||||
|
bui.containerwidget(
|
||||||
|
edit=self._subcontainer,
|
||||||
|
size=(self._scroll_width, index * 35),
|
||||||
|
)
|
||||||
if widget_to_select is not None:
|
if widget_to_select is not None:
|
||||||
bui.columnwidget(
|
bui.containerwidget(
|
||||||
edit=self._columnwidget,
|
edit=self._subcontainer,
|
||||||
selected_child=widget_to_select,
|
selected_child=widget_to_select,
|
||||||
visible_child=widget_to_select,
|
visible_child=widget_to_select,
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user