From 1df74d75d5683028527c78bf92bb073cfea1f42a Mon Sep 17 00:00:00 2001 From: Eric Date: Thu, 28 Sep 2023 17:03:53 -0700 Subject: [PATCH] more 9-patch tidying --- .efrocachemap | 40 ++++++++-------- CHANGELOG.md | 2 +- src/assets/ba_data/python/baenv.py | 2 +- .../base/graphics/mesh/nine_patch_mesh.cc | 12 +++++ .../base/graphics/mesh/nine_patch_mesh.h | 9 +++- src/ballistica/base/ui/dev_console.cc | 46 +++++++++---------- src/ballistica/shared/ballistica.cc | 2 +- 7 files changed, 65 insertions(+), 48 deletions(-) diff --git a/.efrocachemap b/.efrocachemap index 6f8b2907..bf905853 100644 --- a/.efrocachemap +++ b/.efrocachemap @@ -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": "14a18765b7529e8b6b058cd77d0b4ade", - "build/prefab/full/linux_arm64_gui/release/ballisticakit": "6f1529a7790ce8ff78d4b71bc84f3648", - "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "526f17655b962021203216998a40bcbd", - "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "22701fe45842b997976cbd4b3821ffa5", - "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "3034dd7aa313de36df654cb0c79dbd33", - "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "55b238be26c5b46d0f13430115333ccc", - "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "0ff81b8d0e3fa31e775810ec3d768919", - "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "efc060ac9743f558f5e9837b64344aa5", - "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "87223fb839291bb08ddbae1742664c63", - "build/prefab/full/mac_arm64_gui/release/ballisticakit": "454c54966d94d08edaa1badfa76f9e3c", - "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "6435e6d5c70c0ef8c5d8f63c1ae78784", - "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "eb43b896789e743c08236f54718cb480", - "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "3e5183716494f74b52ed04d5f6f884a7", - "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "54d04f03df2a8b9758f90a2ec65c8fdf", - "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "7b5669f6a81b23a95a58e9b67c4ac084", - "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "6b9a09770c7feec38f1c3c0113024486", - "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "550b0876abbe2f7b1a9b0594377384f0", - "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "10faf4fa80588b02c249d54f7d86ed52", - "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "83b05eaaa4cbbee79390336f582218e1", - "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "53267765dc8dbd607291b85f677d9219", + "build/prefab/full/linux_arm64_gui/debug/ballisticakit": "3d62f18e70a8421820ed2ae8527d7d14", + "build/prefab/full/linux_arm64_gui/release/ballisticakit": "3241035738b539e94cf719674953e8fb", + "build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "2229f735f006bef70ad1d2c08ae97fec", + "build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "8895e3a5b262aef6102c16029359a587", + "build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "c94700f8b6ad1ce6b5574372a289d6da", + "build/prefab/full/linux_x86_64_gui/release/ballisticakit": "8e0b9a000dab93c61bd58180a1eb69db", + "build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "d7c2c596d67d96386171cae1489d3ff8", + "build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "f492626b4a61c4550f3a01bc8d8abd53", + "build/prefab/full/mac_arm64_gui/debug/ballisticakit": "fae843a11f1f84a2bc4a266e5723adfd", + "build/prefab/full/mac_arm64_gui/release/ballisticakit": "d2724a5a94267a0d7546c8cf648e729c", + "build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "02df04e605addd02bcfcfe64e01109e3", + "build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "beaac64be0ae8023cce5ec0a1d4306f0", + "build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "f1d3c2985d5f0760c72ecded41d91398", + "build/prefab/full/mac_x86_64_gui/release/ballisticakit": "271b5fc80696ba6d67d02a089358b353", + "build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "22ddbd257824f055627c16d1be1e575a", + "build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "b6de42bf834a0b9cc25c6433d49d6dc2", + "build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "febb196acecc041b07d0ad06430ec2d5", + "build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "fafe18465a2dc39e6a3e2abae0557784", + "build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "bbab03393707e902053429ce38f9986d", + "build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "d68af9931e2adfac40e8bb147ba0383b", "build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "f3d305e647a7f77dd70a48f615cfd750", "build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "931ce8eab9859d20ad86c47d196ba62c", "build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "f3d305e647a7f77dd70a48f615cfd750", diff --git a/CHANGELOG.md b/CHANGELOG.md index ea16d875..9ad4a4af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -### 1.7.28 (build 21396, api 8, 2023-09-28) +### 1.7.28 (build 21397, api 8, 2023-09-28) - 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 diff --git a/src/assets/ba_data/python/baenv.py b/src/assets/ba_data/python/baenv.py index b71f6394..eee3d173 100644 --- a/src/assets/ba_data/python/baenv.py +++ b/src/assets/ba_data/python/baenv.py @@ -52,7 +52,7 @@ if TYPE_CHECKING: # Build number and version of the ballistica binary we expect to be # using. -TARGET_BALLISTICA_BUILD = 21396 +TARGET_BALLISTICA_BUILD = 21397 TARGET_BALLISTICA_VERSION = '1.7.28' diff --git a/src/ballistica/base/graphics/mesh/nine_patch_mesh.cc b/src/ballistica/base/graphics/mesh/nine_patch_mesh.cc index 58519bca..e48fc436 100644 --- a/src/ballistica/base/graphics/mesh/nine_patch_mesh.cc +++ b/src/ballistica/base/graphics/mesh/nine_patch_mesh.cc @@ -6,6 +6,18 @@ namespace ballistica::base { +auto NinePatchMesh::BorderForRadius(float corner_radius, + float matching_dimension, + float other_dimension) -> float { + // Limit the radius to no more than half the shortest side. + corner_radius = std::min( + corner_radius, std::min(matching_dimension, other_dimension) * 0.5f); + if (corner_radius < 0.0001f) { + return 0.0f; + } + return corner_radius / matching_dimension; +} + NinePatchMesh::NinePatchMesh(float x, float y, float z, float width, float height, float border_left, float border_bottom, float border_right, diff --git a/src/ballistica/base/graphics/mesh/nine_patch_mesh.h b/src/ballistica/base/graphics/mesh/nine_patch_mesh.h index a0934afc..d71cf49f 100644 --- a/src/ballistica/base/graphics/mesh/nine_patch_mesh.h +++ b/src/ballistica/base/graphics/mesh/nine_patch_mesh.h @@ -7,12 +7,19 @@ namespace ballistica::base { -// A mesh set up to draw images as 9-patches. +/// A mesh set up to draw images as 9-patches. Border values are provided +/// as ratios of total width/height. For example, setting all borders +/// to 0.3333 will result in a mesh that looks like a uniform 3x3 grid. class NinePatchMesh : public MeshIndexedSimpleFull { public: NinePatchMesh(float x, float y, float z, float width, float height, float border_left, float border_bottom, float border_right, float border_top); + + /// Calculate a border value for a NinePatchMesh based on dimensions and a + /// desired max corner radius. + static auto BorderForRadius(float corner_radius, float matching_dimension, + float other_dimension) -> float; }; } // namespace ballistica::base diff --git a/src/ballistica/base/ui/dev_console.cc b/src/ballistica/base/ui/dev_console.cc index 1e3f98f9..c5bf0387 100644 --- a/src/ballistica/base/ui/dev_console.cc +++ b/src/ballistica/base/ui/dev_console.cc @@ -22,19 +22,6 @@ namespace ballistica::base { -// Calc border values for a nine-patch based on dimensions and a desired max -// corner radius. -static auto CalcBorder_(float corner_radius, float matching_dimension, - float other_dimension) -> float { - // Limit the radius to no more than half the shortest side. - corner_radius = std::min( - corner_radius, std::min(matching_dimension, other_dimension) * 0.5f); - if (corner_radius < 0.0001f) { - return 0.0f; - } - return corner_radius / matching_dimension; -} - // How much of the screen the console covers when it is at full size. const float kDevConsoleSize = 0.9f; const int kDevConsoleLineLimit = 80; @@ -125,10 +112,14 @@ class DevConsole::Button_ : public DevConsole::Widget_ { call{NewLambdaRunnable(lambda)}, text_scale{text_scale}, mesh(0.0f, 0.0f, 0.0f, width, height, - CalcBorder_(kDevConsoleButtonCornerRadius, width, height), - CalcBorder_(kDevConsoleButtonCornerRadius, height, width), - CalcBorder_(kDevConsoleButtonCornerRadius, width, height), - CalcBorder_(kDevConsoleButtonCornerRadius, height, width)) { + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + width, height), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + height, width), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + width, height), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + height, width)) { text_group.SetText(label, TextMesh::HAlign::kCenter, TextMesh::VAlign::kCenter); } @@ -194,10 +185,14 @@ class DevConsole::ToggleButton_ : public DevConsole::Widget_ { off_call{NewLambdaRunnable(off_call)}, text_scale{text_scale}, mesh(0.0f, 0.0f, 0.0f, width, height, - CalcBorder_(kDevConsoleButtonCornerRadius, width, height), - CalcBorder_(kDevConsoleButtonCornerRadius, height, width), - CalcBorder_(kDevConsoleButtonCornerRadius, width, height), - CalcBorder_(kDevConsoleButtonCornerRadius, height, width)) { + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + width, height), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + height, width), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + width, height), + NinePatchMesh::BorderForRadius(kDevConsoleButtonCornerRadius, + height, width)) { text_group.SetText(label, TextMesh::HAlign::kCenter, TextMesh::VAlign::kCenter); } @@ -267,9 +262,12 @@ class DevConsole::TabButton_ : public DevConsole::Widget_ { call{NewLambdaRunnable(call)}, text_scale{text_scale}, mesh(0.0f, 0.0f, 0.0f, width, height, - CalcBorder_(kDevConsoleTabButtonCornerRadius, width, height), - CalcBorder_(kDevConsoleTabButtonCornerRadius, height, width), - CalcBorder_(kDevConsoleTabButtonCornerRadius, width, height), + NinePatchMesh::BorderForRadius(kDevConsoleTabButtonCornerRadius, + width, height), + NinePatchMesh::BorderForRadius(kDevConsoleTabButtonCornerRadius, + height, width), + NinePatchMesh::BorderForRadius(kDevConsoleTabButtonCornerRadius, + width, height), 0.0f) { text_group.SetText(label, TextMesh::HAlign::kCenter, TextMesh::VAlign::kCenter); diff --git a/src/ballistica/shared/ballistica.cc b/src/ballistica/shared/ballistica.cc index 0baa0665..c42df09e 100644 --- a/src/ballistica/shared/ballistica.cc +++ b/src/ballistica/shared/ballistica.cc @@ -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 = 21396; +const int kEngineBuildNumber = 21397; const char* kEngineVersion = "1.7.28"; const int kEngineApiVersion = 8;