Fix compiling for Apple M1 wrongly using Carbon instead of Cocoa backend (Thanks doctorj1)

This commit is contained in:
UnknownShadow200 2021-08-25 08:32:02 +10:00
parent faf499d26a
commit fa850fecb3
9 changed files with 29 additions and 28 deletions

View File

@ -186,7 +186,7 @@ static void AppendChatLog(const cc_string* text) {
/* [HH:mm:ss] text */
String_InitArray(str, strBuffer);
String_Format3(&str, "[%p2:%p2:%p2] ", &now.hour, &now.minute, &now.second);
Drawer2D_WithoutCols(&str, text);
Drawer2D_WithoutColors(&str, text);
res = Stream_WriteLine(&logStream, &str);
if (!res) return;

View File

@ -186,7 +186,7 @@ Thus it is **NOT SAFE** to allocate a string on the stack. */
#define CC_BUILD_GLES
#define CC_BUILD_GLMODERN
#define CC_BUILD_IOS
#elif defined __x86_64__
#elif defined __x86_64__ || defined __arm64__
#define CC_BUILD_COCOA
#define CC_BUILD_MACOS
#else

View File

@ -318,7 +318,7 @@ void Drawer2D_MakeTexture(struct Texture* tex, struct Bitmap* bmp, int width, in
tex->uv.V2 = (float)height / (float)bmp->height;
}
cc_bool Drawer2D_ValidColCodeAt(const cc_string* text, int i) {
cc_bool Drawer2D_ValidColorCodeAt(const cc_string* text, int i) {
if (i >= text->length) return false;
return BitmapCol_A(Drawer2D_GetColor(text->buffer[i])) != 0;
}
@ -329,19 +329,19 @@ cc_bool Drawer2D_IsEmptyText(const cc_string* text) {
for (i = 0; i < text->length; i++) {
if (text->buffer[i] != '&') return false;
if (!Drawer2D_ValidColCodeAt(text, i + 1)) return false;
if (!Drawer2D_ValidColorCodeAt(text, i + 1)) return false;
i++; /* skip colour code */
}
return true;
}
void Drawer2D_WithoutCols(cc_string* str, const cc_string* src) {
void Drawer2D_WithoutColors(cc_string* str, const cc_string* src) {
char c;
int i;
for (i = 0; i < src->length; i++) {
c = src->buffer[i];
if (c == '&' && Drawer2D_ValidColCodeAt(src, i + 1)) {
if (c == '&' && Drawer2D_ValidColorCodeAt(src, i + 1)) {
i++; /* skip colour code */
} else {
String_Append(str, c);
@ -349,19 +349,19 @@ void Drawer2D_WithoutCols(cc_string* str, const cc_string* src) {
}
}
char Drawer2D_LastCol(const cc_string* text, int start) {
char Drawer2D_LastColor(const cc_string* text, int start) {
int i;
if (start >= text->length) start = text->length - 1;
for (i = start; i >= 0; i--) {
if (text->buffer[i] != '&') continue;
if (Drawer2D_ValidColCodeAt(text, i + 1)) {
if (Drawer2D_ValidColorCodeAt(text, i + 1)) {
return text->buffer[i + 1];
}
}
return '\0';
}
cc_bool Drawer2D_IsWhiteCol(char c) { return c == '\0' || c == 'f' || c == 'F'; }
cc_bool Drawer2D_IsWhiteColor(char c) { return c == '\0' || c == 'f' || c == 'F'; }
/* Divides R/G/B by 4 */
#define SHADOW_MASK ((0x3F << BITMAPCOL_R_SHIFT) | (0x3F << BITMAPCOL_G_SHIFT) | (0x3F << BITMAPCOL_B_SHIFT))
@ -441,7 +441,7 @@ static void DrawBitmappedTextCore(struct Bitmap* bmp, struct DrawTextArgs* args,
for (i = 0; i < text.length; i++) {
char c = text.buffer[i];
if (c == '&' && Drawer2D_ValidColCodeAt(&text, i + 1)) {
if (c == '&' && Drawer2D_ValidColorCodeAt(&text, i + 1)) {
col = Drawer2D_GetColor(text.buffer[i + 1]);
if (shadow) col = GetShadowColor(col);
@ -536,7 +536,7 @@ static int MeasureBitmappedWidth(const struct DrawTextArgs* args) {
text = args->text;
for (i = 0; i < text.length; i++) {
char c = text.buffer[i];
if (c == '&' && Drawer2D_ValidColCodeAt(&text, i + 1)) {
if (c == '&' && Drawer2D_ValidColorCodeAt(&text, i + 1)) {
i++; continue; /* skip over the colour code */
}
width += Drawer2D_Width(point, c) + xPadding;
@ -613,7 +613,7 @@ void Drawer2D_DrawClippedText(struct Bitmap* bmp, struct DrawTextArgs* args,
/*########################################################################################################################*
*---------------------------------------------------Drawer2D component----------------------------------------------------*
*#########################################################################################################################*/
static void InitHexEncodedCol(int i, int hex, cc_uint8 lo, cc_uint8 hi) {
static void InitHexEncodedColor(int i, int hex, cc_uint8 lo, cc_uint8 hi) {
Drawer2D.Colors[i] = BitmapCol_Make(
lo * ((hex >> 2) & 1) + hi * (hex >> 3),
lo * ((hex >> 1) & 1) + hi * (hex >> 3),
@ -628,11 +628,11 @@ static void OnReset(void) {
}
for (i = 0; i <= 9; i++) {
InitHexEncodedCol('0' + i, i, 191, 64);
InitHexEncodedColor('0' + i, i, 191, 64);
}
for (i = 10; i <= 15; i++) {
InitHexEncodedCol('a' + (i - 10), i, 191, 64);
InitHexEncodedCol('A' + (i - 10), i, 191, 64);
InitHexEncodedColor('a' + (i - 10), i, 191, 64);
InitHexEncodedColor('A' + (i - 10), i, 191, 64);
}
}
@ -1059,7 +1059,7 @@ static int Font_SysTextWidth(struct DrawTextArgs* args) {
for (i = 0; i < text.length; i++) {
char c = text.buffer[i];
if (c == '&' && Drawer2D_ValidColCodeAt(&text, i + 1)) {
if (c == '&' && Drawer2D_ValidColorCodeAt(&text, i + 1)) {
i++; continue; /* skip over the colour code */
}
@ -1167,7 +1167,7 @@ static void Font_SysTextDraw(struct DrawTextArgs* args, struct Bitmap* bmp, int
for (i = 0; i < text.length; i++) {
char c = text.buffer[i];
if (c == '&' && Drawer2D_ValidColCodeAt(&text, i + 1)) {
if (c == '&' && Drawer2D_ValidColorCodeAt(&text, i + 1)) {
col = Drawer2D_GetColor(text.buffer[i + 1]);
if (shadow) col = GetShadowColor(col);

View File

@ -1,6 +1,5 @@
#ifndef CC_DRAWER2D_H
#define CC_DRAWER2D_H
#include "PackedCol.h"
#include "Constants.h"
#include "Bitmap.h"
/* Performs a variety of drawing operations on bitmaps, and converts bitmaps into textures.
@ -86,16 +85,16 @@ CC_API void Drawer2D_MakeTexture(struct Texture* tex, struct Bitmap* bmp, int wi
/* Returns whether the given colour code is used/valid. */
/* NOTE: This can change if the server defines custom colour codes. */
cc_bool Drawer2D_ValidColCodeAt(const cc_string* text, int i);
cc_bool Drawer2D_ValidColorCodeAt(const cc_string* text, int i);
/* Whether text is empty or consists purely of valid colour codes. */
cc_bool Drawer2D_IsEmptyText(const cc_string* text);
/* Copies all characters from str into src, except for used colour codes */
/* NOTE: Ampersands not followed by a used colour code are still copied */
void Drawer2D_WithoutCols(cc_string* str, const cc_string* src);
void Drawer2D_WithoutColors(cc_string* str, const cc_string* src);
/* Returns the last valid colour code in the given input, or \0 if not found. */
char Drawer2D_LastCol(const cc_string* text, int start);
char Drawer2D_LastColor(const cc_string* text, int start);
/* Returns whether the colour code is f, F or \0. */
cc_bool Drawer2D_IsWhiteCol(char c);
cc_bool Drawer2D_IsWhiteColor(char c);
void Drawer2D_ReducePadding_Tex(struct Texture* tex, int point, int scale);
void Drawer2D_ReducePadding_Height(int* height, int point, int scale);

View File

@ -257,7 +257,7 @@ static void MakeNameTexture(struct Entity* e) {
origWhiteCol = Drawer2D.Colors['f'];
Drawer2D.Colors['f'] = shadowCol;
Drawer2D_WithoutCols(&colorlessName, &name);
Drawer2D_WithoutColors(&colorlessName, &name);
args.text = colorlessName;
Drawer2D_DrawText(&bmp, &args, NAME_OFFSET, NAME_OFFSET);

View File

@ -16,6 +16,7 @@
#include "LScreens.h"
#include "Input.h"
#include "Utils.h"
#include "PackedCol.h"
static struct Bitmap dirtBmp, stoneBmp;
#define TILESIZE 48

View File

@ -19,6 +19,7 @@
#include "Logger.h"
#include "Options.h"
#include "LBackend.h"
#include "PackedCol.h"
/* The area/region of the window that needs to be redrawn and presented to the screen. */
/* If width is 0, means no area needs to be redrawn. */

View File

@ -141,7 +141,7 @@ static void SPConnection_AddPart(const cc_string* text) {
String_InitArray(tmp, tmpBuffer);
/* Prepend colour codes for subsequent lines of multi-line chat */
if (!Drawer2D_IsWhiteCol(sp_lastCol)) {
if (!Drawer2D_IsWhiteColor(sp_lastCol)) {
String_Append(&tmp, '&');
String_Append(&tmp, sp_lastCol);
}
@ -153,7 +153,7 @@ static void SPConnection_AddPart(const cc_string* text) {
}
String_UNSAFE_TrimEnd(&tmp);
col = Drawer2D_LastCol(&tmp, tmp.length);
col = Drawer2D_LastColor(&tmp, tmp.length);
if (col) sp_lastCol = col;
Chat_Add(&tmp);
}

View File

@ -959,7 +959,7 @@ static void InputWidget_FormatLine(struct InputWidget* w, int i, cc_string* line
for (i = 0; i < src.length; i++) {
char c = src.buffer[i];
if (c == '%' && Drawer2D_ValidColCodeAt(&src, i + 1)) { c = '&'; }
if (c == '%' && Drawer2D_ValidColorCodeAt(&src, i + 1)) { c = '&'; }
String_Append(line, c);
}
}
@ -994,7 +994,7 @@ static char InputWidget_GetLastCol(struct InputWidget* w, int x, int y) {
line.length = 0;
InputWidget_FormatLine(w, y, &line);
col = Drawer2D_LastCol(&line, x);
col = Drawer2D_LastColor(&line, x);
if (col) return col;
if (y > 0) { x = w->lines[y - 1].length; }
}
@ -1621,7 +1621,7 @@ static void ChatInputWidget_RemakeTexture(void* widget) {
/* Colour code continues in next line */
lastCol = InputWidget_GetLastCol(w, 0, i);
if (!Drawer2D_IsWhiteCol(lastCol)) {
if (!Drawer2D_IsWhiteColor(lastCol)) {
String_Append(&line, '&'); String_Append(&line, lastCol);
}
/* Convert % to & for colour codes */