nine-patch cleanup

This commit is contained in:
Eric 2023-09-28 16:43:52 -07:00
parent f25fdceded
commit 10d7cffdbc
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
8 changed files with 65 additions and 26 deletions

40
.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": "a5196028d865c1da423e3b44f322f0b4",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "0eb477fffc094aa13e5c89176cc0f588",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "2a83c1baf22d8bf356fcc27f1471f957",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "8c102382876ec9b3bf5157c2e692eb83",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "fb64489102c92ecfe2824c3044987f8a",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "4e4a1a0187bfaf6133a59d245b2d1bbc",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "fd2476f5995fd19dd50ef49e84cb797b",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "c6d32394a7420aa0d8a32c72df24de17",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "4e1302cc8907bd2814df01cd61fc03ad",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "bde2ee121f12001e5b1d0e8a727dd4df",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "e956c21f24bbf0291b1d0eef980a0f71",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "6bc7ba87119a7ba3d4a21ceda731311e",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "0f7e7ec2068443eb3cba3bd87d98b700",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "43fe6217db63f5e1f471ec3bc926589f",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "25da26e2ebc227d61da7261dff3b22da",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "383df77c017fa93d9abeb60fe6ecc7d3",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "1059e2cd37f10fe93fd85c06e7679cef",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "6bf2fd565a36d8da031138ae2a593c8e",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "84363c68b54f2a38b91173600580a1f3",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "44cfae2645b1b865d4965e859ee1d7b6",
"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/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",

View File

@ -1656,6 +1656,7 @@
<w>listobj</w>
<w>listvalidconfigs</w>
<w>lival</w>
<w>llow</w>
<w>llzma</w>
<w>lmap</w>
<w>lmerged</w>

View File

@ -1,4 +1,4 @@
### 1.7.28 (build 21395, api 8, 2023-09-28)
### 1.7.28 (build 21396, 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

View File

@ -978,6 +978,7 @@
<w>linkstoryboards</w>
<w>listobj</w>
<w>llock</w>
<w>llow</w>
<w>lmap</w>
<w>localmodlibs</w>
<w>localns</w>

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 = 21395
TARGET_BALLISTICA_BUILD = 21396
TARGET_BALLISTICA_VERSION = '1.7.28'

View File

@ -2,12 +2,22 @@
#include "ballistica/base/graphics/mesh/nine_patch_mesh.h"
#include "ballistica/shared/foundation/macros.h"
namespace ballistica::base {
NinePatchMesh::NinePatchMesh(float x, float y, float z, float width,
float height, float border_left,
float border_bottom, float border_right,
float border_top) {
if (g_buildconfig.debug_build()) {
if ((border_bottom < 0.0f || border_top < 0.0f
|| (border_bottom + border_top) > 1.0f)
|| (border_left < 0.0f || border_right < 0.0f
|| (border_left + border_right) > 1.0f)) {
BA_LOG_ONCE(LogLevel::kWarning, "Invalid nine-patch values provided.");
}
}
// Statically allocate enough for a full 9 patches even though we may
// not use them all (in cases of size 0 borders).
VertexSimpleFull verts[16]; // 4 vertical * 4 horizontal slices.

View File

@ -22,12 +22,27 @@
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;
const int kDevConsoleStringBreakUpSize = 1950;
const int kDevConsoleActivateKey1 = SDLK_BACKQUOTE;
const int kDevConsoleActivateKey2 = SDLK_F2;
const float kDevConsoleButtonCornerRadius{8.0f};
const float kDevConsoleTabButtonCornerRadius{16.0f};
const double kTransitionSeconds = 0.1;
@ -109,7 +124,11 @@ class DevConsole::Button_ : public DevConsole::Widget_ {
height{height},
call{NewLambdaRunnable(lambda)},
text_scale{text_scale},
mesh(0.0f, 0.0f, 0.0f, width, height, 0.1f, 0.3f, 0.1f, 0.3f) {
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)) {
text_group.SetText(label, TextMesh::HAlign::kCenter,
TextMesh::VAlign::kCenter);
}
@ -174,7 +193,11 @@ class DevConsole::ToggleButton_ : public DevConsole::Widget_ {
on_call{NewLambdaRunnable(on_call)},
off_call{NewLambdaRunnable(off_call)},
text_scale{text_scale},
mesh(0.0f, 0.0f, 0.0f, width, height, 0.1f, 0.3f, 0.1f, 0.3f) {
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)) {
text_group.SetText(label, TextMesh::HAlign::kCenter,
TextMesh::VAlign::kCenter);
}
@ -243,7 +266,11 @@ class DevConsole::TabButton_ : public DevConsole::Widget_ {
height{height},
call{NewLambdaRunnable(call)},
text_scale{text_scale},
mesh(0.0f, 0.0f, 0.0f, width, height, 0.1f, 0.3f, 0.1f, 0.0f) {
mesh(0.0f, 0.0f, 0.0f, width, height,
CalcBorder_(kDevConsoleTabButtonCornerRadius, width, height),
CalcBorder_(kDevConsoleTabButtonCornerRadius, height, width),
CalcBorder_(kDevConsoleTabButtonCornerRadius, width, height),
0.0f) {
text_group.SetText(label, TextMesh::HAlign::kCenter,
TextMesh::VAlign::kCenter);
}

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