From 9f88700074df8c7538145f521d0086ac418d9c54 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sat, 21 Nov 2020 14:06:14 +1100 Subject: [PATCH] Android version should always be fullscreen Also improve documentation for String_Format (Thanks Tree) --- doc/style.md | 23 ----------------------- src/Launcher.c | 3 +++ src/Screens.c | 4 ---- src/String.h | 17 ++++++++++++++++- 4 files changed, 19 insertions(+), 28 deletions(-) diff --git a/doc/style.md b/doc/style.md index 7d01c2534..4cc7da753 100644 --- a/doc/style.md +++ b/doc/style.md @@ -39,26 +39,3 @@ For example, consider the function ```String Substring_UNSAFE(STRING_REF const S The *input string* is not modified at all. However, the characters of the *returned string* points to the characters of the *input string*, so modifying the characters in the *input string* also modifies the *returned string*. In general, use of ```const String*``` is preferred when possible, and ```STRING_REF``` as little as possible. - -#### String formatting -An API is provided for formatting strings similiar to printf in C or String.Format in C#. -The functions for formatting strings are in String.h: -``` -void String_Format1(str, format, a1); -void String_Format2(str, format, a1, a2); -void String_Format3(str, format, a1, a2, a3); -void String_Format4(str, format, a1, a2, a3, a4); -``` -#### Formatting specifiers -| Specifier | Type | Example | -| ------------- |-------------| -----| -| ```%b``` | uint8_t | ```%b``` of ```46``` = ```46``` | -| ```%i``` | int | ```%i``` of ```-5``` = ```-5``` | -| ```%f[0-9]``` | float | ```%f2``` of ```321.3519``` = ```321.35``` | -| ```%p[0-9]``` | int | ```%p3``` of ```5``` = ```005``` | -| ```%t``` | Boolean | ```%t``` of ```1``` = ```true``` | -| ```%c``` | char* | ```%c``` of ```"ABCD"``` = ```ABCD``` | -| ```%s``` | String | ```%s``` of ```{"ABCD", 2, 4}``` = ```AB``` | -| ```%r``` | char | ```%r``` of ```47``` = ```\``` | -| ```%x``` | uintptr_t | ```%x``` of ```31``` = ```2F``` | -| ```%h``` | uint32_t | ```%h``` of ```11``` = ```B``` | diff --git a/src/Launcher.c b/src/Launcher.c index 1cf0033e1..402988654 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -277,6 +277,9 @@ static void Launcher_Free(void) { void Launcher_Run(void) { static const cc_string title = String_FromConst(GAME_APP_TITLE); Window_Create(640, 400); +#ifdef CC_BUILD_ANDROID + Window_EnterFullscreen(); +#endif Window_SetTitle(&title); Window_Show(); LWidget_CalcOffsets(); diff --git a/src/Screens.c b/src/Screens.c index 8a1ba9d51..e0d303cd4 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -245,13 +245,9 @@ static int HUDScreen_KeyUp(void* screen, int key) { static int HUDscreen_PointerDown(void* screen, int id, int x, int y) { struct HUDScreen* s = (struct HUDScreen*)screen; -#ifdef CC_BUILD_TOUCH if (Input_TouchMode || Gui_GetInputGrab()) { return Elem_HandlesPointerDown(&s->hotbar, id, x, y); } -#else - if (Gui_GetInputGrab()) return Elem_HandlesPointerDown(&s->hotbar, id, x, y); -#endif return false; } diff --git a/src/String.h b/src/String.h index f3540f56b..490be5b66 100644 --- a/src/String.h +++ b/src/String.h @@ -27,7 +27,7 @@ int String_Length(const char* raw); /* Constructs a string from a (maybe null terminated) buffer. */ CC_NOINLINE cc_string String_FromRaw(STRING_REF char* buffer, int capacity); /* Constructs a string from a null-terminated constant readonly buffer. */ -CC_NOINLINE cc_string String_FromReadonly(STRING_REF const char* buffer); +CC_API cc_string String_FromReadonly(STRING_REF const char* buffer); /* Constructs a string from a compile time string constant */ #define String_FromConst(text) { text, (sizeof(text) - 1), (sizeof(text) - 1)} @@ -143,6 +143,21 @@ CC_API int String_CaselessEnds(const cc_string* str, const cc_string* sub); /* else returns 0. NOTE: The return value is not just in -1,0,1! */ CC_API int String_Compare(const cc_string* a, const cc_string* b); +/* String_Format is provided for formatting strings (similiar to printf) +Supported specifiers for string formatting: + TYPE | ARGUMENT | EXAMPLE +%b | cc_uint8 | format(%b, 46) = "46" +%i | int | format(%i, -5) = "-5" +%f[0-9] | float | format(%f2, 321.3519) = "321.35" +%p[0-9] | int | format(%p3, 5) = "005" +%t | cc_bool | format(%t, 1) = "true" +%c | char* | format(%c, "ABCD") = "ABCD" +%s | cc_string | format(%s, {"ABCD", 2, 4}) = "AB" +%r | char | format(%r, 47) = "\" +%x | cc_uintptr| format(%x, 31) = "000000000000002F" +%h | cc_uint32 | format(%h, 11) = "0000000B" +*/ + /* See String_Format4 */ CC_API void String_Format1(cc_string* str, const char* format, const void* a1); /* See String_Format4 */