Bombsquad-Ballistica-Modded.../dist/ba_data/python/bauiv1lib/feedback.py

101 lines
2.7 KiB
Python
Raw Normal View History

2021-03-29 03:24:13 +05:30
# Released under the MIT License. See LICENSE for details.
#
"""UI functionality related to users rating the game."""
from __future__ import annotations
2023-08-13 17:21:49 +05:30
import bauiv1 as bui
2021-03-29 03:24:13 +05:30
2023-08-13 17:21:49 +05:30
def ask_for_rating() -> bui.Widget | None:
2021-03-29 03:24:13 +05:30
"""(internal)"""
2023-08-13 17:21:49 +05:30
app = bui.app
assert app.classic is not None
platform = app.classic.platform
subplatform = app.classic.subplatform
2021-03-29 03:24:13 +05:30
# FIXME: should whitelist platforms we *do* want this for.
2023-09-30 17:21:33 +05:30
if bui.app.env.test:
2021-03-29 03:24:13 +05:30
return None
if not (
platform == 'mac'
or (platform == 'android' and subplatform in ['google', 'cardboard'])
):
2021-03-29 03:24:13 +05:30
return None
width = 700
height = 400
spacing = 40
2023-08-13 17:21:49 +05:30
assert bui.app.classic is not None
uiscale = bui.app.ui_v1.uiscale
dlg = bui.containerwidget(
2021-03-29 03:24:13 +05:30
size=(width, height),
transition='in_right',
scale=(
1.6
2023-08-13 17:21:49 +05:30
if uiscale is bui.UIScale.SMALL
else 1.35
2023-08-13 17:21:49 +05:30
if uiscale is bui.UIScale.MEDIUM
else 1.0
),
)
2021-03-29 03:24:13 +05:30
v = height - 50
v -= spacing
v -= 140
2023-08-13 17:21:49 +05:30
bui.imagewidget(
parent=dlg,
position=(width / 2 - 100, v + 10),
size=(200, 200),
2023-08-13 17:21:49 +05:30
texture=bui.gettexture('cuteSpaz'),
)
2023-08-13 17:21:49 +05:30
bui.textwidget(
parent=dlg,
position=(15, v - 55),
size=(width - 30, 30),
2023-08-13 17:21:49 +05:30
color=bui.app.ui_v1.infotextcolor,
text=bui.Lstr(
resource='pleaseRateText',
2023-08-13 17:21:49 +05:30
subs=[('${APP_NAME}', bui.Lstr(resource='titleText'))],
),
maxwidth=width * 0.95,
max_height=130,
scale=0.85,
h_align='center',
v_align='center',
)
2021-03-29 03:24:13 +05:30
def do_rating() -> None:
if platform == 'android':
2023-08-13 17:21:49 +05:30
appname = bui.appname()
2021-03-29 03:24:13 +05:30
if subplatform == 'google':
url = f'market://details?id=net.froemling.{appname}'
else:
2022-10-01 14:51:35 +05:30
url = f'market://details?id=net.froemling.{appname}cb'
2021-03-29 03:24:13 +05:30
else:
url = 'macappstore://itunes.apple.com/app/id416482767?ls=1&mt=12'
2023-08-13 17:21:49 +05:30
bui.open_url(url)
bui.containerwidget(edit=dlg, transition='out_left')
2021-03-29 03:24:13 +05:30
2023-08-13 17:21:49 +05:30
bui.buttonwidget(
parent=dlg,
position=(60, 20),
size=(200, 60),
2023-08-13 17:21:49 +05:30
label=bui.Lstr(resource='wellSureText'),
autoselect=True,
on_activate_call=do_rating,
)
2021-03-29 03:24:13 +05:30
def close() -> None:
2023-08-13 17:21:49 +05:30
bui.containerwidget(edit=dlg, transition='out_left')
2021-03-29 03:24:13 +05:30
2023-08-13 17:21:49 +05:30
btn = bui.buttonwidget(
parent=dlg,
position=(width - 270, 20),
size=(200, 60),
2023-08-13 17:21:49 +05:30
label=bui.Lstr(resource='noThanksText'),
autoselect=True,
on_activate_call=close,
)
2023-08-13 17:21:49 +05:30
bui.containerwidget(edit=dlg, cancel_button=btn, selected_child=btn)
2021-03-29 03:24:13 +05:30
return dlg