more c++ tidying

This commit is contained in:
Eric 2022-09-02 20:59:22 -07:00
parent 38ff9badb3
commit 4d4645022d
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
26 changed files with 129 additions and 125 deletions

View File

@ -3995,50 +3995,50 @@
"assets/src/ba_data/python/ba/_generated/__init__.py": "https://files.ballistica.net/cache/ba1/ee/e8/cad05aa531c7faf7ff7b96db7f6e",
"assets/src/ba_data/python/ba/_generated/enums.py": "https://files.ballistica.net/cache/ba1/b2/e5/0ee0561e16257a32830645239f34",
"ballisticacore-windows/Generic/BallisticaCore.ico": "https://files.ballistica.net/cache/ba1/89/c0/e32c7d2a35dc9aef57cc73b0911a",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/d9/57/123cd8f5f4e59fff6f7ab6301440",
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/cc/e4/c0b4ee2723764731b4c583df7632",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/7a/ca/250edaa7f67af4728721b13b41ae",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a1/8a/c45b021007b1b440cb7c56c95300",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/2e/b1/8cffa62ead9db7791ab6b7d13a44",
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/14/d9/c024d934e304796de1b4aff3aae0",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a7/bc/db9eb7138e23276d5b75540a60c6",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/76/b5/62e9a24394fb6a5d46b718b9f846",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/8e/83/223b4a190bf10ff7cece9c6376c4",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/06/ad/fd3a9809664e810c19b6fa554139",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/92/09/c1e4f2e70af0dd1381efb82f1472",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/a0/82/54fbd261222c43b807653c86e771",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/8f/0c/2197464e39e8b14b9dde2d445b6b",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/a0/40/fbc022e5c5d11f5ba2c1a619e71a",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/86/ab/1df134bc1995a26175784309db3b",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/9c/d4/bd65fdaca17a078a1ee1e0ef8fd4",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/0d/0a/5fdae5c69d07610a8cac0f983b79",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/5b/43/3a0f5464d64c34c1cc049f2c5dd6",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/b6/7c/f8bda2f3dbce598e2118860dcc9e",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/3a/66/8b96fdce49a8c4b90f3bc1faa41b",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/02/4d/5652672bc763235bb098c350d56a",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/1a/18/764195445dffb753f922a9ed271d",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5b/3f/cd3f804350db1420ae27621225ed",
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/25/a8/3440285403322919cf898c588691",
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/de/32/6617f583d30e3670e0de13fcf275",
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f0/6b/422a883bcc071a181f0bdde67b73",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/df/5e/c1c2906261112d0fcf2a93e63ec9",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/90/ca/8eb48f0ac0074ae51e57b6c865b2",
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c2/42/c226954a0860554d216d4bfde5b6",
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/86/4b/097a75c1a75e4f4ce8ba548bc68c",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/99/b3/2eb848a098fa3ea6237fe6b6c666",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/05/3d/ca92f309675f8d8499be665ee93c",
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/f7/9d/9ca7c4da9d55f0ec17ad57b10bd3",
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b3/59/c1f138006a8dfde1764847eb9534",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/9d/21/2f0c5cadca8f6594c4a0158c35df",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/8f/6a/263d0f76099de60bda8a1e9b4f48",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/f5/1e/fb527cb55daadb622b37cead85cd",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/47/86/ae60bb70acd670194e295cc7d366",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/47/b9/c8b99dac3f9c30ce03378eb7141f",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/08/2a/8838448d6e0614eaa8fa5bae3302",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/85/d5/a82555f266551105e9e3499f780c",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/59/a4/648c3743893d4b9b8360a7090258",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/15/49/8c08285819c4b0c122601a92bbdb",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/9a/e8/0dcfa1db61409ceeda4c9b3f1f1f",
"build/prefab/full/linux_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/98/2c/3a57b1e26899a8ce72deddfedc2d",
"build/prefab/full/linux_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/65/ae/a6e93b58ec3db43bdc9141ff2292",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/16/1e/f5561596304ba3f4c5e1e689a417",
"build/prefab/full/linux_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/1b/c6/8c7e33ce20abfdb5400fac24d912",
"build/prefab/full/linux_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/2e/40/e7a558c524f184060a1a285a3bd4",
"build/prefab/full/linux_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/fb/c1/e0a9dda43fac36bab931339e0549",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/44/cd/55425e1bd9a2355f5f26d103247e",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/5c/80/d897514c88cb34e558964c3fd84e",
"build/prefab/full/mac_arm64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/ff/3f/5f6d6b1ef938fcf5dab41c9bf6b4",
"build/prefab/full/mac_arm64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/c3/26/28015b10cee6fa0e5b4f5a8cf74c",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/52/45/fb6e9c424f5b02fe1282e4750ba1",
"build/prefab/full/mac_arm64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/8a/ec/5277ccd466bba1f9e2787dca8702",
"build/prefab/full/mac_x86_64_gui/debug/ballisticacore": "https://files.ballistica.net/cache/ba1/c3/43/0b694331a64171c28b3f7bf3070d",
"build/prefab/full/mac_x86_64_gui/release/ballisticacore": "https://files.ballistica.net/cache/ba1/77/e3/02852c073ca65312a31423bb9ac9",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/72/56/abde9450dcf0d34fab2e51c37f18",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticacore_headless": "https://files.ballistica.net/cache/ba1/e7/6d/508a7e7eb92ef5893591d1bc1705",
"build/prefab/full/windows_x86_gui/debug/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/a4/6c/0a43b4165e225c625db50225ea88",
"build/prefab/full/windows_x86_gui/release/BallisticaCore.exe": "https://files.ballistica.net/cache/ba1/30/5c/49531bd06432ea2468a2a8d8cad3",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/eb/a5/732bdadc7d22a861f0f395774069",
"build/prefab/full/windows_x86_server/release/dist/BallisticaCoreHeadless.exe": "https://files.ballistica.net/cache/ba1/e8/7b/7f577295652610d105ddcb65ea38",
"build/prefab/lib/linux_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a4/3e/9436a48d22a818f5c38ec6c79662",
"build/prefab/lib/linux_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/5e/0f/f4f6f8a2379f03ac45d475c10d69",
"build/prefab/lib/linux_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/6f/59/cf17fc32ed37c901d7ef5f838918",
"build/prefab/lib/linux_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/05/a3/21155690a20d59ddc49388bf2dc2",
"build/prefab/lib/linux_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/a9/ba/501984f66a889f1482856e515fb2",
"build/prefab/lib/linux_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/77/d6/ace05e23b2b241dcadec1aba7253",
"build/prefab/lib/linux_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/47/f6/3019e4ef93ac786057a77f3fff1d",
"build/prefab/lib/linux_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/cd/dd/47d65260ca9c04eda20adccd6f71",
"build/prefab/lib/mac_arm64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/24/6e/a05c396868c18e8c66ef52b49166",
"build/prefab/lib/mac_arm64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/b0/8e/e14993bad63ef92ba5ccb532dbb4",
"build/prefab/lib/mac_arm64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/c5/39/75d3dde444ab63aa2c1d49b212f8",
"build/prefab/lib/mac_arm64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/0f/92/8630636fbcdbeee3c95660342639",
"build/prefab/lib/mac_x86_64_gui/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/7b/5f/6f8a0d6cd233aae4b7d394f3dc9e",
"build/prefab/lib/mac_x86_64_gui/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/fb/f2/759a510b82faeb4ab5acc2c3052b",
"build/prefab/lib/mac_x86_64_server/debug/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/84/e7/553f60e4603414a35598284c13d6",
"build/prefab/lib/mac_x86_64_server/release/libballisticacore_internal.a": "https://files.ballistica.net/cache/ba1/d9/1c/411f47bc58390560f347ece26172",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/4e/27/fac43344cb6ad625ee6b8f4eb025",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/64/71/fd8c80764edb5c8b3c3e9302283c",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/2f/9c/100bc1657b231fad168f36d2b5f9",
"build/prefab/lib/windows/Debug_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/4d/91/c51ecec26a14c86ac04ac864b92e",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.lib": "https://files.ballistica.net/cache/ba1/13/3b/476da858cec08be51883372cfc4f",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreGenericInternal.pdb": "https://files.ballistica.net/cache/ba1/58/ed/9738b4be3c927e807cfaa38a7df8",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.lib": "https://files.ballistica.net/cache/ba1/97/e9/a10d1fc18dd3360dfad40624efd5",
"build/prefab/lib/windows/Release_Win32/BallisticaCoreHeadlessInternal.pdb": "https://files.ballistica.net/cache/ba1/38/61/9da5f4158128bb2330645f44ae8c",
"src/ballistica/generated/python_embedded/binding.inc": "https://files.ballistica.net/cache/ba1/7d/3e/229a581cb2454ed856f1d8b564a7",
"src/ballistica/generated/python_embedded/bootstrap.inc": "https://files.ballistica.net/cache/ba1/98/12/571b2160d69d42580e8f31fa6a8d"
}

View File

@ -1,4 +1,4 @@
### 1.7.7 (build 20736, api 7, 2022-09-02)
### 1.7.7 (build 20741, api 7, 2022-09-02)
- Added `ba.app.meta.load_exported_classes()` for loading classes discovered by the meta subsystem cleanly in a background thread.
- Improved logging of missing playlist game types.
- Some ba.Lstr functionality can now be used in background threads.

View File

@ -1 +1 @@
165792406555478528390294774863684706424
121748926490457154634465746862153767685

View File

@ -32,7 +32,7 @@ def bootstrap() -> None:
# Give a soft warning if we're being used with a different binary
# version than we expect.
expected_build = 20736
expected_build = 20741
running_build: int = env['build_number']
if running_build != expected_build:
print(

View File

@ -53,13 +53,11 @@ class AppGlobals {
Console* console{};
bool reset_vr_orientation{};
bool user_ran_commands{};
UIScale ui_scale{UIScale::kLarge};
V1AccountType account_type{V1AccountType::kInvalid};
bool remote_server_accepting_connections{true};
std::string exec_command;
std::string user_agent_string{"BA_USER_AGENT_UNSET (" BA_PLATFORM_STRING ")"};
int return_value{};
bool is_stdin_a_terminal{true};
bool debug_timing{};
std::thread::id main_thread_id{};
bool is_bootstrapped{};

View File

@ -17,11 +17,12 @@
#include "ballistica/platform/platform.h"
#include "ballistica/python/python.h"
#include "ballistica/scene/scene.h"
#include "ballistica/ui/ui.h"
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kAppBuildNumber = 20736;
const int kAppBuildNumber = 20741;
const char* kAppVersion = "1.7.7";
// Our standalone globals.
@ -268,16 +269,12 @@ auto InNetworkWriteThread() -> bool {
&& g_network_write_module->thread()->IsCurrent());
}
auto GetUIScale() -> UIScale { return g_app_globals->ui_scale; }
void Log(const std::string& msg, bool to_stdout, bool to_server) {
Logging::Log(msg, to_stdout, to_server);
}
auto IsVRMode() -> bool { return g_app_globals->vr_mode; }
auto IsStdinATerminal() -> bool { return g_app_globals->is_stdin_a_terminal; }
void ScreenMessage(const std::string& s, const Vector3f& color) {
if (g_game) {
g_game->PushScreenMessage(s, color);

View File

@ -204,14 +204,6 @@ auto IsUnmodifiedBlessedBuild() -> bool;
auto ScreenMessage(const std::string& msg) -> void;
auto ScreenMessage(const std::string& msg, const Vector3f& color) -> void;
/// Log a fatal error and kill the app.
/// Can be called from any thread at any time.
/// message is a message to be shown to the user if possible.
/// This will attempt to ship all accumulated logs to the master-server
/// so the standard Log() call can be used before this to include extra
/// info not relevant to the end user.
auto FatalError(const std::string& message = "") -> void;
// Check current-threads.
auto InMainThread() -> bool; // (main and graphics are same currently)
auto InGraphicsThread() -> bool; // (main and graphics are same currently)
@ -230,11 +222,13 @@ auto GetCurrentThreadName() -> std::string;
auto Log(const std::string& msg, bool to_stdout = true, bool to_server = true)
-> void;
auto GetUIScale() -> UIScale;
/// Return true if stdin seems to be coming from a terminal
/// (so we know to print prompts, etc).
auto IsStdinATerminal() -> bool;
/// Log a fatal error and kill the app.
/// Can be called from any thread at any time.
/// Provided message will be shown to the user if possible.
/// This will attempt to ship all accumulated logs to the master-server
/// so the standard Log() call can be used before this to include extra
/// info not relevant to the end user.
auto FatalError(const std::string& message = "") -> void;
/// Are we running in a VR environment?
auto IsVRMode() -> bool;

View File

@ -69,7 +69,7 @@ auto static_cast_check_fit_always(IN_TYPE in) -> OUT_TYPE {
template <typename OUT_TYPE, typename IN_TYPE>
auto static_cast_check_fit_always_2(IN_TYPE in) -> OUT_TYPE {
if (!check_static_cast_fit<OUT_TYPE>(in)) {
fprintf(stderr, "static_cast_check_fit_always failed for value %s.",
fprintf(stderr, "static_cast_check_fit_always_2 failed for value %s.",
std::to_string(in).c_str());
abort();
}

View File

@ -93,6 +93,7 @@ Game::Game(Thread* thread)
// (need to be able to create weak-refs to it).
assert(g_ui == nullptr);
g_ui = Object::NewUnmanaged<UI>();
g_ui->PostInit();
assert(g_networking == nullptr);
g_networking = new Networking();
@ -943,7 +944,8 @@ void Game::PushStdinScriptCommand(const std::string& command) {
if (PyObject* obj = cmd.RunReturnObj(true, nullptr)) {
// Print the value if we're running directly from a terminal
// (or being run under the server-manager)
if ((IsStdinATerminal() || g_app->server_wrapper_managed())
if ((g_platform->is_stdin_a_terminal()
|| g_app->server_wrapper_managed())
&& obj != Py_None) {
PyObject* s = PyObject_Repr(obj);
if (s) {

View File

@ -2,6 +2,8 @@
#include "ballistica/graphics/area_of_interest.h"
#include "ballistica/ui/ui.h"
namespace ballistica {
AreaOfInterest::AreaOfInterest(bool in_focus) : in_focus_(in_focus) {}
@ -10,7 +12,7 @@ AreaOfInterest::~AreaOfInterest() = default;
void AreaOfInterest::SetRadius(float r_in) {
// We slightly scale this for phone situations.
float extrascale = (GetUIScale() == UIScale::kSmall) ? 0.85f : 1.0f;
float extrascale = (g_ui->scale() == UIScale::kSmall) ? 0.85f : 1.0f;
radius_ = r_in * extrascale;
}

View File

@ -21,6 +21,7 @@
#if !BA_USE_ES3_INCLUDES
#include "ballistica/platform/android/android_gl3.h"
#endif
#include "ballistica/ui/ui.h"
#define glDepthRange glDepthRangef
#define glDiscardFramebufferEXT _glDiscardFramebufferEXT
#ifndef GL_RGB565_OES
@ -5819,11 +5820,11 @@ std::string RendererGL::GetAutoAndroidRes() {
const char* renderer = (const char*)glGetString(GL_RENDERER);
// on the adreno 4xxx or 5xxx series we should be able to do anything...
// On the adreno 4xxx or 5xxx series we should be able to do anything.
if (strstr(renderer, "Adreno (TM) 4") || strstr(renderer, "Adreno (TM) 5")) {
// for phones lets go with 1080p (phones most likely have 1920x1080-ish
// aspect ratios)
if (GetUIScale() == UIScale::kSmall) {
if (g_ui->scale() == UIScale::kSmall) {
return "1080p";
} else {
// tablets are more likely to have 1920x1200 so lets inch a bit higher
@ -5831,11 +5832,11 @@ std::string RendererGL::GetAutoAndroidRes() {
}
}
// on extra-speedy devices we should be able to do 1920x1200
// On extra-speedy devices we should be able to do 1920x1200.
if (is_extra_speedy_android_device_) {
// for phones lets go with 1080p (phones most likely have 1920x1080-ish
// aspect ratios)
if (GetUIScale() == UIScale::kSmall) {
if (g_ui->scale() == UIScale::kSmall) {
return "1080p";
} else {
// tablets are more likely to have 1920x1200 so lets inch a bit higher
@ -5843,7 +5844,7 @@ std::string RendererGL::GetAutoAndroidRes() {
}
}
// Amazon Fire tablet (as of jan '18) needs REAL low res to feel smooth..
// Amazon Fire tablet (as of jan '18) needs REAL low res to feel smooth.
if (g_platform->GetDeviceName() == "Amazon KFAUWI") {
return "480p";
}

View File

@ -433,7 +433,7 @@ void Graphics::DrawMiscOverlays(RenderPass* pass) {
// during gameplay.
float start_v = g_graphics->screen_virtual_height() * 0.05f;
float scale;
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kSmall:
scale = 1.5f;
break;

View File

@ -67,7 +67,7 @@ void TouchInput::HandleTouchEvent(TouchEvent::Type type, void* touch, float x,
}
TouchInput::TouchInput() {
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kSmall:
base_controls_scale_ = 2.0f;
world_draw_scale_ = 1.2f;
@ -862,7 +862,7 @@ void TouchInput::UpdateMapping() {
g_app_config->Resolve(AppConfig::BoolID::kTouchControlsSwipeHidden);
// Start with defaults.
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kSmall:
buttons_default_frac_x_ = 0.88f;
buttons_default_frac_y_ = 0.2f;

View File

@ -21,7 +21,7 @@ StdInputModule::~StdInputModule() = default;
void StdInputModule::PushBeginReadCall() {
PushCall([this] {
bool stdin_is_terminal = IsStdinATerminal();
bool stdin_is_terminal = g_platform->is_stdin_a_terminal();
while (true) {
// Print a prompt if we're a tty.

View File

@ -119,6 +119,13 @@ auto Platform::PostInit() -> void {
// more closely or at least log it somewhere.
device_name_ = Utils::GetValidUTF8(DoGetDeviceName().c_str(), "dn");
ran_base_post_init_ = true;
// Are we running in a terminal?
if (g_buildconfig.use_stdin_thread()) {
is_stdin_a_terminal_ = GetIsStdinATerminal();
} else {
is_stdin_a_terminal_ = false;
}
}
Platform::~Platform() = default;
@ -536,15 +543,8 @@ static void Init() {
assert(true);
#endif // !BA_DEBUG_BUILD
// Are we running in a terminal?
if (g_buildconfig.use_stdin_thread()) {
g_app_globals->is_stdin_a_terminal = g_platform->IsStdinATerminal();
} else {
g_app_globals->is_stdin_a_terminal = false;
}
// If we're running in a terminal, print some info.
if (g_app_globals->is_stdin_a_terminal) {
if (g_platform->is_stdin_a_terminal()) {
if (g_buildconfig.headless_build()) {
printf("BallisticaCore Headless %s build %d.\n", kAppVersion,
kAppBuildNumber);
@ -793,7 +793,7 @@ void Platform::SetEnv(const std::string& name, const std::string& value) {
#endif
}
auto Platform::IsStdinATerminal() -> bool {
auto Platform::GetIsStdinATerminal() -> bool {
// This covers non-windows cases.
#if BA_OSTYPE_WINDOWS
throw Exception();

View File

@ -192,9 +192,6 @@ class Platform {
/// Raises an exception on errors.
virtual void SetEnv(const std::string& name, const std::string& value);
/// Are we being run from a terminal? (should we show prompts, etc?).
virtual auto IsStdinATerminal() -> bool;
/// Return hostname or other id suitable for displaying in network search
/// results, etc.
auto GetDeviceName() -> std::string;
@ -516,7 +513,13 @@ class Platform {
return using_custom_app_python_dir_;
}
/// Are we being run from a terminal? (should we show prompts, etc?).
auto is_stdin_a_terminal() const { return is_stdin_a_terminal_; }
protected:
/// Are we being run from a terminal? (should we show prompts, etc?).
virtual auto GetIsStdinATerminal() -> bool;
/// Open the provided URL in a browser or whatnot.
virtual auto DoOpenURL(const std::string& url) -> void;
@ -557,6 +560,7 @@ class Platform {
virtual auto DoClipboardGetText() -> std::string;
private:
bool is_stdin_a_terminal_{};
bool using_custom_app_python_dir_{};
bool have_config_dir_{};
bool have_has_touchscreen_value_{};

View File

@ -782,7 +782,7 @@ void PlatformWindows::SetEnv(const std::string& name,
}
}
bool PlatformWindows::IsStdinATerminal() { return _isatty(_fileno(stdin)); }
bool PlatformWindows::GetIsStdinATerminal() { return _isatty(_fileno(stdin)); }
std::string PlatformWindows::GetOSVersionString() {
DWORD dw_version = 0;

View File

@ -35,7 +35,7 @@ class PlatformWindows : public Platform {
void HandleLog(const std::string& msg) override;
void SetupDataDirectory() override;
void SetEnv(const std::string& name, const std::string& value) override;
auto IsStdinATerminal() -> bool override;
auto GetIsStdinATerminal() -> bool override;
auto GetOSVersionString() -> std::string override;
auto GetCWD() -> std::string override;
void DoOpenURL(const std::string& url) override;

View File

@ -17,6 +17,7 @@
#include "ballistica/python/python.h"
#include "ballistica/python/python_context_call_runnable.h"
#include "ballistica/scene/scene.h"
#include "ballistica/ui/ui.h"
namespace ballistica {
@ -721,7 +722,7 @@ auto PyEnv(PyObject* self) -> PyObject* {
bool demo_mode{g_buildconfig.demo_build()};
const char* ui_scale;
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kLarge:
ui_scale = "large";
break;

View File

@ -67,7 +67,6 @@ namespace ballistica {
#pragma ide diagnostic ignored "hicpp-signed-bitwise"
#pragma ide diagnostic ignored "RedundantCast"
// Used by our built in exception type.
void Python::SetPythonException(const Exception& exc) {
PyExcType exctype{exc.python_type()};
const char* description{GetShortExceptionDescription(exc)};

View File

@ -21,6 +21,7 @@
#include "ballistica/python/python.h"
#include "ballistica/scene/node/node_attribute.h"
#include "ballistica/scene/node/node_type.h"
#include "ballistica/ui/ui.h"
#include "ode/ode_collision_util.h"
namespace ballistica {
@ -4925,7 +4926,7 @@ void SpazNode::Draw(FrameDef* frame_def) {
int elem_count = name_text_group_.GetElementCount();
float s_extra =
(IsVRMode() || GetUIScale() == UIScale::kSmall) ? 1.2f : 1.0f;
(IsVRMode() || g_ui->scale() == UIScale::kSmall) ? 1.2f : 1.0f;
for (int e = 0; e < elem_count; e++) {
// Gracefully skip unloaded textures.

View File

@ -23,7 +23,7 @@ const float kMenuButtonDrawDepth = -0.07f;
RootUI::RootUI() {
float base_scale;
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kLarge:
base_scale = 1.0f;
break;

View File

@ -39,20 +39,20 @@ UI::UI() {
}
}
if (force_test_small) {
g_app_globals->ui_scale = UIScale::kSmall;
scale_ = UIScale::kSmall;
} else if (force_test_medium) {
g_app_globals->ui_scale = UIScale::kMedium;
scale_ = UIScale::kMedium;
} else if (force_test_large) {
g_app_globals->ui_scale = UIScale::kLarge;
scale_ = UIScale::kLarge;
} else {
// Use automatic val.
if (g_buildconfig.iircade_build()) { // NOLINT(bugprone-branch-clone)
g_app_globals->ui_scale = UIScale::kMedium;
scale_ = UIScale::kMedium;
} else if (IsVRMode() || g_platform->IsRunningOnTV()) {
// VR and tv builds always use medium.
g_app_globals->ui_scale = UIScale::kMedium;
scale_ = UIScale::kMedium;
} else {
g_app_globals->ui_scale = g_platform->GetUIScale();
scale_ = g_platform->GetUIScale();
}
}
@ -72,9 +72,10 @@ UI::UI() {
base_timers_.NewTimer(base_time_, kGameStepMilliseconds, 0, -1,
NewLambdaRunnable([this] { StepScene(); }));
scene_ = Object::New<Scene>(0);
root_ui_ = new RootUI();
}
auto UI::PostInit() -> void { root_ui_ = new RootUI(); }
// Currently the UI never dies so we don't bother doing a clean tear-down..
// (verifying scene cleanup, etc)
UI::~UI() {

View File

@ -31,6 +31,7 @@ namespace ballistica {
class UI : public ContextTarget {
public:
UI();
auto PostInit() -> void;
~UI() override;
auto Reset() -> void;
@ -116,11 +117,13 @@ class UI : public ContextTarget {
const Object::Ref<Runnable>& runnable) -> int override;
auto DeleteTimer(TimeType timetype, int timer_id) -> void override;
RootUI* root_ui() const {
auto root_ui() -> RootUI* const {
assert(root_ui_);
return root_ui_;
}
auto scale() const { return scale_; }
private:
auto StepScene() -> void;
RootUI* root_ui_{};
@ -138,6 +141,7 @@ class UI : public ContextTarget {
Object::Ref<ContainerWidget> overlay_root_widget_;
Object::Ref<RootWidget> root_widget_;
int ui_lock_count_{};
UIScale scale_{UIScale::kLarge};
// Media loaded in the UI context.
std::unordered_map<std::string, Object::WeakRef<Texture> > textures_;

View File

@ -138,7 +138,7 @@ auto RootWidget::AddCover(float h_align, VAlign v_align, float x, float y,
// when the user specifies no backing it means they intend to cover the screen
// with a flat-ish window texture.. however this only applies to phone-size;
// for other sizes we always draw a backing.
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.visibility_mask |=
static_cast<uint32_t>(Widget::ToolbarVisibility::kMenuFull);
}
@ -152,7 +152,7 @@ auto RootWidget::AddCover(float h_align, VAlign v_align, float x, float y,
void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
float b, bool plus, const std::string& s) {
float yoffs = (GetUIScale() == UIScale::kSmall) ? 0.0f : -7.0f;
float yoffs = (g_ui->scale() == UIScale::kSmall) ? 0.0f : -7.0f;
float width = type == 1 ? 80.0f : 110.0f;
// bar
@ -170,7 +170,7 @@ void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
bd.color_r = 0.32f;
bd.color_g = 0.30f;
bd.color_b = 0.4f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.color_r *= TOOLBAR_COLOR_R;
bd.color_g *= TOOLBAR_COLOR_G;
bd.color_b *= TOOLBAR_COLOR_B;
@ -290,7 +290,7 @@ void RootWidget::AddMeter(float h_align, float x, int type, float r, float g,
bd.color_r = 0.35f;
bd.color_g = 0.35f;
bd.color_b = 0.55f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.color_r *= TOOLBAR_COLOR_R;
bd.color_g *= TOOLBAR_COLOR_G;
bd.color_b *= TOOLBAR_COLOR_B;
@ -357,9 +357,9 @@ void RootWidget::Setup() {
// widen this a bit in small mode so it just covers most of the top
// - that looks funny in medium/large mode though
// if (GetUIScale() == UIScale::kSmall) {
// if (g_ui->scale() == UIScale::kSmall) {
// AddCover(0.5f, VAlign::kTop, 0.0f, 320.0f,
// GetUIScale() == UIScale::kSmall ? 1000.0f :
// g_ui->scale() == UIScale::kSmall ? 1000.0f :
// 1000.0f, 800.0f, 0.4f);
// }
// if (c) {
@ -373,14 +373,14 @@ void RootWidget::Setup() {
bd.h_align = 0.5f;
bd.v_align = VAlign::kTop;
bd.width = 370.0f;
// if (GetUIScale() != UIScale::kSmall) {
// if (g_ui->scale() != UIScale::kSmall) {
// bd.width = 950.0f;
// }
bd.height = 90.0f;
bd.x = 256.0f;
bd.y = -20.0f;
bd.img = "uiAtlas2";
// if (GetUIScale() != UIScale::kSmall) {
// if (g_ui->scale() != UIScale::kSmall) {
// bd.model_transparent = "toolbarBackingTop";
// } else {
bd.model_transparent = "toolbarBackingTop2";
@ -390,7 +390,7 @@ void RootWidget::Setup() {
bd.color_g = 0.41f;
bd.color_b = 0.56f;
bd.opacity = 1.0f;
// if (GetUIScale() != UIScale::kSmall) {
// if (g_ui->scale() != UIScale::kSmall) {
// bd.color_r *= TOOLBAR_COLOR_R;
// bd.color_g *= TOOLBAR_COLOR_G;
// bd.color_b *= TOOLBAR_COLOR_B;
@ -417,7 +417,7 @@ void RootWidget::Setup() {
bd.h_align = 0.5f;
bd.v_align = VAlign::kTop;
bd.width = 850.0f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.width = 850.0f;
}
bd.height = 90.0f;
@ -430,7 +430,7 @@ void RootWidget::Setup() {
bd.color_g = 0.41f;
bd.color_b = 0.56f;
bd.opacity = 1.0f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.color_r *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R;
bd.color_g *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G;
bd.color_b *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B;
@ -450,7 +450,7 @@ void RootWidget::Setup() {
AddButton(bd);
}
float yoffs = (GetUIScale() == UIScale::kSmall) ? 0.0f : -10.0f;
float yoffs = (g_ui->scale() == UIScale::kSmall) ? 0.0f : -10.0f;
// account button
{
@ -460,12 +460,12 @@ void RootWidget::Setup() {
bd.width = 160.0f;
bd.height = 60.0f;
bd.depth_min = 0.3f;
bd.x = (GetUIScale() == UIScale::kSmall) ? 100.0f : -50.0f;
bd.x = (g_ui->scale() == UIScale::kSmall) ? 100.0f : -50.0f;
bd.y = -24.0f + yoffs;
bd.color_r = 0.56f;
bd.color_g = 0.5f;
bd.color_b = 0.73f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
bd.color_r *= TOOLBAR_COLOR_R;
bd.color_g *= TOOLBAR_COLOR_G;
bd.color_b *= TOOLBAR_COLOR_B;
@ -477,7 +477,7 @@ void RootWidget::Setup() {
| static_cast<uint32_t>(Widget::ToolbarVisibility::kMenuFullRoot));
// on desktop, stick this in the top left corner
// if (GetUIScale() == UIScale::kLarge) {
// if (g_ui->scale() == UIScale::kLarge) {
// bd.h_align = 0.0f;
// bd.x = 120.0f;
// }
@ -515,7 +515,7 @@ void RootWidget::Setup() {
}
}
float anchorx = (GetUIScale() == UIScale::kSmall) ? 0.3f : 0.25f;
float anchorx = (g_ui->scale() == UIScale::kSmall) ? 0.3f : 0.25f;
AddMeter(anchorx, 200.0f - 148.0f, 0, 1.0f, 1.0f, 1.0f, false, "456/1000");
AddMeter(anchorx, 200.0f, 1, 1.0f, 1.0f, 1.0f, false, "123");
@ -661,7 +661,7 @@ void RootWidget::Setup() {
float backingCoverG = backingG;
float backingCoverB = backingB;
float backingA = 1.0f;
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
backingR *= TOOLBAR_COLOR_R * TOOLBAR_BACK_COLOR_R;
backingG *= TOOLBAR_COLOR_G * TOOLBAR_BACK_COLOR_G;
backingB *= TOOLBAR_COLOR_B * TOOLBAR_BACK_COLOR_B;
@ -944,7 +944,7 @@ void RootWidget::StepPositions(float dt) {
}
if (&b == back_button_) {
// back button is always disabled in medium/large UI
if (GetUIScale() != UIScale::kSmall) {
if (g_ui->scale() != UIScale::kSmall) {
enable_button = false;
}
@ -1033,7 +1033,7 @@ void RootWidget::StepPositions(float dt) {
void RootWidget::UpdateLayout() {
// Now actually put things in place.
base_scale_ = 1.0f;
switch (GetUIScale()) {
switch (g_ui->scale()) {
case UIScale::kLarge:
base_scale_ = 0.6f;
break;

View File

@ -224,7 +224,7 @@ void TextWidget::Draw(RenderPass* pass, bool draw_transparent) {
c.SetTexture(g_media->GetTexture(SystemTextureID::kTextClearButton));
c.PushTransform();
c.Translate(r - 20, b * 0.5f + t * 0.5f, 0.1f);
if (GetUIScale() == UIScale::kSmall) {
if (g_ui->scale() == UIScale::kSmall) {
c.Scale(30, 30);
} else {
c.Scale(25, 25);