Skip to content

Commit

Permalink
playlist add-game window is now screen-size-responsive
Browse files Browse the repository at this point in the history
  • Loading branch information
efroemling committed Jan 26, 2025
1 parent 94c59be commit 4d37294
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 55 deletions.
64 changes: 32 additions & 32 deletions .efrocachemap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### 1.7.37 (build 22251, api 9, 2025-01-25)
### 1.7.37 (build 22252, api 9, 2025-01-25)
- Bumping api version to 9. As you'll see below, there's some UI changes that
will require a bit of work for any UI mods to adapt to. If your mods don't
touch UI stuff at all you can simply bump your api version and call it a day.
Expand Down
2 changes: 1 addition & 1 deletion src/assets/ba_data/python/baenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@

# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 22251
TARGET_BALLISTICA_BUILD = 22252
TARGET_BALLISTICA_VERSION = '1.7.37'


Expand Down
56 changes: 36 additions & 20 deletions src/assets/ba_data/python/bauiv1lib/playlist/addgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,65 @@ def __init__(
self._r = 'addGameWindow'
assert bui.app.classic is not None
uiscale = bui.app.ui_v1.uiscale
self._width = 750 if uiscale is bui.UIScale.SMALL else 650
x_inset = 50 if uiscale is bui.UIScale.SMALL else 0
yoffs = -44 if uiscale is bui.UIScale.SMALL else 0
self._width = 900 if uiscale is bui.UIScale.SMALL else 650

self._height = (
400
1200.0
if uiscale is bui.UIScale.SMALL
else 400 if uiscale is bui.UIScale.MEDIUM else 460
else 450.0 if uiscale is bui.UIScale.MEDIUM else 500.0
)
self._scroll_width = 210

# Do some fancy math to fill all available screen area up to the
# size of our backing container. This lets us fit to the exact
# screen shape at small ui scale.
screensize = bui.get_virtual_screen_size()
scale = (
2.4
if uiscale is bui.UIScale.SMALL
else 1.35 if uiscale is bui.UIScale.MEDIUM else 1.0
)
# Calc screen size in our local container space and clamp to a
# bit smaller than our container size.
target_width = min(self._width - 50, screensize[0] / scale)
target_height = min(self._height - 70, screensize[1] / scale)

# To get top/left coords, go to the center of our window and
# offset by half the width/height of our target area.
yoffs = 0.5 * self._height + 0.5 * target_height + 5.0
x_inset = 0.5 * self._width - 0.5 * target_width

super().__init__(
root_widget=bui.containerwidget(
size=(self._width, self._height),
scale=(
1.95
if uiscale is bui.UIScale.SMALL
else 1.5 if uiscale is bui.UIScale.MEDIUM else 1.0
),
stack_offset=(0, 1) if uiscale is bui.UIScale.SMALL else (0, 0),
scale=scale,
toolbar_visibility='menu_minimal',
),
transition=transition,
origin_widget=origin_widget,
# We're affected by screen size only at small ui-scale.
refresh_on_screen_size_changes=uiscale is bui.UIScale.SMALL,
)

if uiscale is bui.UIScale.SMALL:
self._back_button = bui.get_special_widget('back_button')
else:
self._back_button = bui.buttonwidget(
parent=self._root_widget,
position=(58 + x_inset, self._height - 53 + yoffs),
position=(58 + x_inset, yoffs - 53),
size=(60, 48),
label=bui.charstr(bui.SpecialChar.BACK),
autoselect=True,
button_type='backSmall',
on_activate_call=self.main_window_back,
)

self._select_button = select_button = bui.buttonwidget(
parent=self._root_widget,
position=(self._width - (172 + x_inset), self._height - 50 + yoffs),
position=(
x_inset + target_width - 172,
yoffs - 50,
),
autoselect=True,
size=(160, 60),
scale=0.75,
Expand All @@ -82,7 +100,7 @@ def __init__(

bui.textwidget(
parent=self._root_widget,
position=(self._width * 0.5, self._height - 28 + yoffs),
position=(self._width * 0.5, yoffs - 28),
size=(0, 0),
scale=1.0,
text=bui.Lstr(resource=f'{self._r}.titleText'),
Expand All @@ -91,7 +109,7 @@ def __init__(
maxwidth=250,
v_align='center',
)
v = self._height - 64 + yoffs
v = yoffs - 64

self._selected_title_text = bui.textwidget(
parent=self._root_widget,
Expand All @@ -115,11 +133,9 @@ def __init__(
h_align='left',
)

scroll_height = self._height - (
160 if uiscale is bui.UIScale.SMALL else 100
)
scroll_height = target_height - 60

v = self._height - 60 + yoffs
v = yoffs - 60

self._scrollwidget = bui.scrollwidget(
parent=self._root_widget,
Expand Down Expand Up @@ -260,7 +276,7 @@ def _on_get_more_games_press(self) -> None:
from bauiv1lib.store.browser import StoreBrowserWindow

# No-op if we're not in control.
if self.main_window_has_control():
if not self.main_window_has_control():
return

plus = bui.app.plus
Expand Down
2 changes: 1 addition & 1 deletion src/ballistica/shared/ballistica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {

// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 22251;
const int kEngineBuildNumber = 22252;
const char* kEngineVersion = "1.7.37";
const int kEngineApiVersion = 9;

Expand Down

0 comments on commit 4d37294

Please sign in to comment.