added native-review-request to replace old hand-rolled one

This commit is contained in:
Eric 2023-11-09 15:43:25 -08:00
parent 310660403b
commit 8fd4c45b85
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
13 changed files with 134 additions and 39 deletions

56
.efrocachemap generated
View File

@ -4056,26 +4056,26 @@
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "64292918215b9d3e6fc3d470db4c92b1",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "84c840b57ed000407a8b34e9c5015b54",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "bc6fc246d6e0551a18f161183ee89ad5",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "bc87c32aee50fbc67ca0531c536e7f10",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "bcf55f1a1e8e317dc355ebf2ea301d10",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "0ad6f5cea06d4c0754d1763610c7be90",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "2c1c99e0850749741e23e5db7fb45b22",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "960dee8cee9d2fe500629583668eee14",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "1eb609e4f8ba0cf740d9c7b8cbbbf4d3",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "80418b80ad17e283a65b85142b0b490d",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "1527e8235b808c6bdf5f2850875d1843",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "0e8c85459f90cc0a1355aecad5b5306e",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "6c718c797dfaf2b85ce7bd5d6c7f9d8a",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "5eefb534d193a9fa06b413a9d5a05969",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "2dedf11d5e4ffa9ec02eb6025a9b3460",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "3a3075f5f28cbfe9cd302e9c371b9ed4",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "275342bb44f1f5edde893a9775eb0130",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "4866c1b244b493b99da24aa1bc965bb7",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "c2181a4564b675762f89e2bc3314332f",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "ac4a176d550b219aa3cb1f46ad738a66",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "6b30c7563c501435ee9c9d7584124a3d",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "cde906637ab2fd52c7c6752d20c8e5a1",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "fa4c9dddd31d0ae5b5537a70415679b4",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "0ea542deeb3be561b45805e31fff618d",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "09ca80b37e18c24e705e33409fb14cf7",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "057150cf0c86920df2ceba78a0413e15",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "8b9db0a31ad3186b24bf57700285b7ed",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "1252e817e42616e35357e4aa7f30c1f3",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "0fa88240fcf21fb4a8030212731c5c47",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "8fca31f8837dfb689b9c2b8ee0529fab",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "15f7e176817e7b509567764b98ef8a1a",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "ac68b0113512aaa47d91a3a585124181",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "f5caed9be4b5f59aa4a4bffb6d2ba7d7",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "578bdfea257f3913c82fa200c858197a",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "a2fea38fdebf4c687249758c63cae3c7",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "866c89a141e141340de210cb5b6025d6",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "e79d9be3f30cd6aee49ca99cb246a1fd",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "1ea429286200a9db50aa91233c61d13a",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "eb37b75b93f6faa872b270d6e88c3a18",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "c330e1a356877ead65e039dfb59f46ab",
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "f812111f1eb4ea76e99558305ce3980f",
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "c16c1b360b27850f1ac4d3dc55194b0a",
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "f812111f1eb4ea76e99558305ce3980f",
@ -4092,14 +4092,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "380d456bc409849174a36c5d2f61aa1b",
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "4fae9b286a6d1c5c729c49c483c1422a",
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "380d456bc409849174a36c5d2f61aa1b",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "5bee4eaf62c401c65c94513eb3ac18fd",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "69438fa6a8c70381f355ff3fb94c5a13",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "ad27b9e1e63733ba10c34ae5fd8246df",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "5b1b8ac6e3022b633477c3989957fa81",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "d2364a2d49ba3268691fb7e1134c9359",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "a6436bf9a9fb5531b837d9be20c2834b",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "a502732d3df4e7ff6b5086cb1f9bbb08",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "5470de767289dca9b88678e69a1ecca4",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "8cba13ddabc6c29b7360483d35e83b4c",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "9f3a011a47e4b924af06bf22d12eeedd",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "63272196776f495960f4a837d93e1bd5",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "9944dc011d9efc9525e728277c278d29",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "a768ba2d0cc92b4e8a6362bd49cf0a1e",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "67b3ba3f7e7bb1b38f03ea28792ffab5",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "763663746aa11e24970ac1de4c579310",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "8b3169ff64c31243ba401703d95ae0e0",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
"src/assets/ba_data/python/babase/_mgen/enums.py": "28323912b56ec07701eda3d41a6a4101",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "72bfed2cce8ff19741989dec28302f3f",

View File

@ -1,4 +1,4 @@
### 1.7.28 (build 21578, api 8, 2023-11-09)
### 1.7.28 (build 21581, api 8, 2023-11-09)
- Massively cleaned up code related to rendering and window systems (OpenGL,
SDL, etc). This code had been growing into a nasty tangle for 15 years

View File

@ -74,6 +74,8 @@ from _babase import (
music_player_set_volume,
music_player_shutdown,
music_player_stop,
native_review_request,
native_review_request_supported,
native_stack_trace,
print_load_info,
pushcall,
@ -276,6 +278,8 @@ __all__ = [
'music_player_set_volume',
'music_player_shutdown',
'music_player_stop',
'native_review_request',
'native_review_request_supported',
'native_stack_trace',
'NodeNotFoundError',
'normalized_color',

View File

@ -17,7 +17,7 @@ if TYPE_CHECKING:
from typing import Callable
DEBUG_LOG = True
DEBUG_LOG = False
class LoginAdapter:

View File

@ -52,7 +52,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21578
TARGET_BALLISTICA_BUILD = 21581
TARGET_BALLISTICA_VERSION = '1.7.28'

View File

@ -66,6 +66,8 @@ from babase import (
lock_all_input,
LoginAdapter,
Lstr,
native_review_request,
native_review_request_supported,
NotFoundError,
Permission,
Plugin,
@ -191,6 +193,8 @@ __all__ = [
'LoginAdapter',
'Lstr',
'Mesh',
'native_review_request',
'native_review_request_supported',
'NotFoundError',
'open_file_externally',
'open_url',

View File

@ -518,10 +518,13 @@ def show_offer() -> bool:
assert plus is not None
app = bui.app
assert app.classic is not None
if app.classic is None:
raise RuntimeError(
'Classic feature-set is required to show offers.'
)
# Space things out a bit so we don't hit the poor user with an ad and
# then an in-game offer.
# Space things out a bit so we don't hit the poor user with an
# ad and then an in-game offer.
has_been_long_enough_since_ad = True
if app.classic.ads.last_ad_completion_time is not None and (
bui.apptime() - app.classic.ads.last_ad_completion_time < 30.0
@ -532,8 +535,9 @@ def show_offer() -> bool:
app.classic.special_offer is not None
and has_been_long_enough_since_ad
):
# Special case: for pro offers, store this in our prefs so we
# can re-show it if the user kills us (set phasers to 'NAG'!!!).
# Special case: for pro offers, store this in our prefs so
# we can re-show it if the user kills us (set phasers to
# 'NAG'!!!).
if app.classic.special_offer.get('item') == 'pro_fullprice':
cfg = app.config
cfg['pendingSpecialOffer'] = {
@ -543,7 +547,11 @@ def show_offer() -> bool:
cfg.commit()
if app.classic.special_offer['item'] == 'rating':
feedback.ask_for_rating()
# Go with a native thing if we've got one.
if bui.native_review_request_supported():
bui.native_review_request()
else:
feedback.ask_for_rating()
else:
SpecialOfferWindow(app.classic.special_offer)

View File

@ -308,4 +308,13 @@ auto AppAdapter::GetKeyName(int keycode) -> std::string {
return "?";
}
auto AppAdapter::NativeReviewRequestSupported() -> bool { return false; }
void AppAdapter::NativeReviewRequest() {
BA_PRECONDITION(NativeReviewRequestSupported());
PushMainThreadCall([this] { DoNativeReviewRequest(); });
}
void AppAdapter::DoNativeReviewRequest() { FatalError("Fixme unimplemented."); }
} // namespace ballistica::base

View File

@ -230,9 +230,15 @@ class AppAdapter {
/// context. By default this is simply the main thread.
virtual void DoPushGraphicsContextRunnable(Runnable* runnable);
// Return a name for a ballistica keyboard keycode.
/// Return a name for a ballistica keyboard keycode.
virtual auto GetKeyName(int keycode) -> std::string;
/// Return whether there is a native 'review-this-app' prompt.
virtual auto NativeReviewRequestSupported() -> bool;
/// Asynchronously kick off a native review request.
void NativeReviewRequest();
protected:
virtual ~AppAdapter();
@ -241,6 +247,10 @@ class AppAdapter {
virtual void DoClipboardSetText(const std::string& text);
virtual auto DoClipboardGetText() -> std::string;
/// Override to implement native review requests. Will be called in the
/// main thread.
virtual void DoNativeReviewRequest();
private:
void OnAppSuspend_();
void OnAppUnsuspend_();

View File

@ -297,6 +297,23 @@ auto AppAdapterApple::GetKeyName(int keycode) -> std::string {
return MinSDL_GetKeyName(keycode);
}
auto AppAdapterApple::NativeReviewRequestSupported() -> bool {
// StoreKit currently supports this everywhere except tvOS.
if (g_buildconfig.xcode_build() && g_buildconfig.use_store_kit()
&& !g_buildconfig.ostype_tvos()) {
return true;
}
return false;
}
void AppAdapterApple::DoNativeReviewRequest() {
#if BA_XCODE_BUILD && BA_USE_STORE_KIT && !BA_OSTYPE_TVOS
BallisticaKit::StoreKitContext::requestReview();
#else
FatalError("This should not be getting called.");
#endif
}
} // namespace ballistica::base
#endif // BA_XCODE_BUILD

View File

@ -46,6 +46,7 @@ class AppAdapterApple : public AppAdapter {
auto GetKeyRepeatDelay() -> float override;
auto GetKeyRepeatInterval() -> float override;
auto GetKeyName(int keycode) -> std::string override;
auto NativeReviewRequestSupported() -> bool override;
protected:
void DoPushMainThreadRunnable(Runnable* runnable) override;
@ -60,6 +61,7 @@ class AppAdapterApple : public AppAdapter {
auto DoClipboardHasText() -> bool override;
void DoClipboardSetText(const std::string& text) override;
auto DoClipboardGetText() -> std::string override;
void DoNativeReviewRequest() override;
private:
class ScopedAllowGraphics_;

View File

@ -1724,6 +1724,45 @@ static PyMethodDef PyUsingGameCenterDef = {
"(internal)",
};
// --------------------- native_review_request_supported -----------------------
static auto PyNativeReviewRequestSupported(PyObject* self) -> PyObject* {
BA_PYTHON_TRY;
if (g_base->app_adapter->NativeReviewRequestSupported()) {
Py_RETURN_TRUE;
}
Py_RETURN_FALSE;
BA_PYTHON_CATCH;
}
static PyMethodDef PyNativeReviewRequestSupportedDef = {
"native_review_request_supported", // name
(PyCFunction)PyNativeReviewRequestSupported, // method
METH_NOARGS, // flags
"native_review_request_supported() -> bool\n"
"\n"
"(internal)",
};
// -------------------------- native_review_request ----------------------------
static auto PyNativeReviewRequest(PyObject* self) -> PyObject* {
BA_PYTHON_TRY;
g_base->app_adapter->NativeReviewRequest();
Py_RETURN_NONE;
BA_PYTHON_CATCH;
}
static PyMethodDef PyNativeReviewRequestDef = {
"native_review_request", // name
(PyCFunction)PyNativeReviewRequest, // method
METH_NOARGS, // flags
"native_review_request() -> None\n"
"\n"
"(internal)",
};
// -----------------------------------------------------------------------------
auto PythonMethodsMisc::GetMethods() -> std::vector<PyMethodDef> {
@ -1789,6 +1828,8 @@ auto PythonMethodsMisc::GetMethods() -> std::vector<PyMethodDef> {
PyAssetLoadsAllowedDef,
PyUsingGooglePlayGameServicesDef,
PyUsingGameCenterDef,
PyNativeReviewRequestSupportedDef,
PyNativeReviewRequestDef,
};
}

View File

@ -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 = 21578;
const int kEngineBuildNumber = 21581;
const char* kEngineVersion = "1.7.28";
const int kEngineApiVersion = 8;