mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-13 17:47:12 -04:00
Fix compiling for Apple M1 wrongly using Carbon instead of Cocoa backend (Thanks doctorj1)
This commit is contained in:
parent
faf499d26a
commit
fa850fecb3
@ -186,7 +186,7 @@ static void AppendChatLog(const cc_string* text) {
|
|||||||
/* [HH:mm:ss] text */
|
/* [HH:mm:ss] text */
|
||||||
String_InitArray(str, strBuffer);
|
String_InitArray(str, strBuffer);
|
||||||
String_Format3(&str, "[%p2:%p2:%p2] ", &now.hour, &now.minute, &now.second);
|
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);
|
res = Stream_WriteLine(&logStream, &str);
|
||||||
if (!res) return;
|
if (!res) return;
|
||||||
|
@ -186,7 +186,7 @@ Thus it is **NOT SAFE** to allocate a string on the stack. */
|
|||||||
#define CC_BUILD_GLES
|
#define CC_BUILD_GLES
|
||||||
#define CC_BUILD_GLMODERN
|
#define CC_BUILD_GLMODERN
|
||||||
#define CC_BUILD_IOS
|
#define CC_BUILD_IOS
|
||||||
#elif defined __x86_64__
|
#elif defined __x86_64__ || defined __arm64__
|
||||||
#define CC_BUILD_COCOA
|
#define CC_BUILD_COCOA
|
||||||
#define CC_BUILD_MACOS
|
#define CC_BUILD_MACOS
|
||||||
#else
|
#else
|
||||||
|
@ -318,7 +318,7 @@ void Drawer2D_MakeTexture(struct Texture* tex, struct Bitmap* bmp, int width, in
|
|||||||
tex->uv.V2 = (float)height / (float)bmp->height;
|
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;
|
if (i >= text->length) return false;
|
||||||
return BitmapCol_A(Drawer2D_GetColor(text->buffer[i])) != 0;
|
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++) {
|
for (i = 0; i < text->length; i++) {
|
||||||
if (text->buffer[i] != '&') return false;
|
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 */
|
i++; /* skip colour code */
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Drawer2D_WithoutCols(cc_string* str, const cc_string* src) {
|
void Drawer2D_WithoutColors(cc_string* str, const cc_string* src) {
|
||||||
char c;
|
char c;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < src->length; i++) {
|
for (i = 0; i < src->length; i++) {
|
||||||
c = src->buffer[i];
|
c = src->buffer[i];
|
||||||
|
|
||||||
if (c == '&' && Drawer2D_ValidColCodeAt(src, i + 1)) {
|
if (c == '&' && Drawer2D_ValidColorCodeAt(src, i + 1)) {
|
||||||
i++; /* skip colour code */
|
i++; /* skip colour code */
|
||||||
} else {
|
} else {
|
||||||
String_Append(str, c);
|
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;
|
int i;
|
||||||
if (start >= text->length) start = text->length - 1;
|
if (start >= text->length) start = text->length - 1;
|
||||||
|
|
||||||
for (i = start; i >= 0; i--) {
|
for (i = start; i >= 0; i--) {
|
||||||
if (text->buffer[i] != '&') continue;
|
if (text->buffer[i] != '&') continue;
|
||||||
if (Drawer2D_ValidColCodeAt(text, i + 1)) {
|
if (Drawer2D_ValidColorCodeAt(text, i + 1)) {
|
||||||
return text->buffer[i + 1];
|
return text->buffer[i + 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return '\0';
|
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 */
|
/* Divides R/G/B by 4 */
|
||||||
#define SHADOW_MASK ((0x3F << BITMAPCOL_R_SHIFT) | (0x3F << BITMAPCOL_G_SHIFT) | (0x3F << BITMAPCOL_B_SHIFT))
|
#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++) {
|
for (i = 0; i < text.length; i++) {
|
||||||
char c = text.buffer[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]);
|
col = Drawer2D_GetColor(text.buffer[i + 1]);
|
||||||
|
|
||||||
if (shadow) col = GetShadowColor(col);
|
if (shadow) col = GetShadowColor(col);
|
||||||
@ -536,7 +536,7 @@ static int MeasureBitmappedWidth(const struct DrawTextArgs* args) {
|
|||||||
text = args->text;
|
text = args->text;
|
||||||
for (i = 0; i < text.length; i++) {
|
for (i = 0; i < text.length; i++) {
|
||||||
char c = text.buffer[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 */
|
i++; continue; /* skip over the colour code */
|
||||||
}
|
}
|
||||||
width += Drawer2D_Width(point, c) + xPadding;
|
width += Drawer2D_Width(point, c) + xPadding;
|
||||||
@ -613,7 +613,7 @@ void Drawer2D_DrawClippedText(struct Bitmap* bmp, struct DrawTextArgs* args,
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------Drawer2D component----------------------------------------------------*
|
*---------------------------------------------------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(
|
Drawer2D.Colors[i] = BitmapCol_Make(
|
||||||
lo * ((hex >> 2) & 1) + hi * (hex >> 3),
|
lo * ((hex >> 2) & 1) + hi * (hex >> 3),
|
||||||
lo * ((hex >> 1) & 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++) {
|
for (i = 0; i <= 9; i++) {
|
||||||
InitHexEncodedCol('0' + i, i, 191, 64);
|
InitHexEncodedColor('0' + i, i, 191, 64);
|
||||||
}
|
}
|
||||||
for (i = 10; i <= 15; i++) {
|
for (i = 10; i <= 15; i++) {
|
||||||
InitHexEncodedCol('a' + (i - 10), i, 191, 64);
|
InitHexEncodedColor('a' + (i - 10), i, 191, 64);
|
||||||
InitHexEncodedCol('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++) {
|
for (i = 0; i < text.length; i++) {
|
||||||
char c = text.buffer[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 */
|
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++) {
|
for (i = 0; i < text.length; i++) {
|
||||||
char c = text.buffer[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]);
|
col = Drawer2D_GetColor(text.buffer[i + 1]);
|
||||||
|
|
||||||
if (shadow) col = GetShadowColor(col);
|
if (shadow) col = GetShadowColor(col);
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
#ifndef CC_DRAWER2D_H
|
#ifndef CC_DRAWER2D_H
|
||||||
#define CC_DRAWER2D_H
|
#define CC_DRAWER2D_H
|
||||||
#include "PackedCol.h"
|
|
||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
/* Performs a variety of drawing operations on bitmaps, and converts bitmaps into textures.
|
/* 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. */
|
/* Returns whether the given colour code is used/valid. */
|
||||||
/* NOTE: This can change if the server defines custom colour codes. */
|
/* 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. */
|
/* Whether text is empty or consists purely of valid colour codes. */
|
||||||
cc_bool Drawer2D_IsEmptyText(const cc_string* text);
|
cc_bool Drawer2D_IsEmptyText(const cc_string* text);
|
||||||
/* Copies all characters from str into src, except for used colour codes */
|
/* Copies all characters from str into src, except for used colour codes */
|
||||||
/* NOTE: Ampersands not followed by a used colour code are still copied */
|
/* 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. */
|
/* 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. */
|
/* 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_Tex(struct Texture* tex, int point, int scale);
|
||||||
void Drawer2D_ReducePadding_Height(int* height, int point, int scale);
|
void Drawer2D_ReducePadding_Height(int* height, int point, int scale);
|
||||||
|
@ -257,7 +257,7 @@ static void MakeNameTexture(struct Entity* e) {
|
|||||||
origWhiteCol = Drawer2D.Colors['f'];
|
origWhiteCol = Drawer2D.Colors['f'];
|
||||||
|
|
||||||
Drawer2D.Colors['f'] = shadowCol;
|
Drawer2D.Colors['f'] = shadowCol;
|
||||||
Drawer2D_WithoutCols(&colorlessName, &name);
|
Drawer2D_WithoutColors(&colorlessName, &name);
|
||||||
args.text = colorlessName;
|
args.text = colorlessName;
|
||||||
Drawer2D_DrawText(&bmp, &args, NAME_OFFSET, NAME_OFFSET);
|
Drawer2D_DrawText(&bmp, &args, NAME_OFFSET, NAME_OFFSET);
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "LScreens.h"
|
#include "LScreens.h"
|
||||||
#include "Input.h"
|
#include "Input.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "PackedCol.h"
|
||||||
|
|
||||||
static struct Bitmap dirtBmp, stoneBmp;
|
static struct Bitmap dirtBmp, stoneBmp;
|
||||||
#define TILESIZE 48
|
#define TILESIZE 48
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Options.h"
|
#include "Options.h"
|
||||||
#include "LBackend.h"
|
#include "LBackend.h"
|
||||||
|
#include "PackedCol.h"
|
||||||
|
|
||||||
/* The area/region of the window that needs to be redrawn and presented to the screen. */
|
/* 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. */
|
/* If width is 0, means no area needs to be redrawn. */
|
||||||
|
@ -141,7 +141,7 @@ static void SPConnection_AddPart(const cc_string* text) {
|
|||||||
String_InitArray(tmp, tmpBuffer);
|
String_InitArray(tmp, tmpBuffer);
|
||||||
|
|
||||||
/* Prepend colour codes for subsequent lines of multi-line chat */
|
/* 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, '&');
|
||||||
String_Append(&tmp, sp_lastCol);
|
String_Append(&tmp, sp_lastCol);
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ static void SPConnection_AddPart(const cc_string* text) {
|
|||||||
}
|
}
|
||||||
String_UNSAFE_TrimEnd(&tmp);
|
String_UNSAFE_TrimEnd(&tmp);
|
||||||
|
|
||||||
col = Drawer2D_LastCol(&tmp, tmp.length);
|
col = Drawer2D_LastColor(&tmp, tmp.length);
|
||||||
if (col) sp_lastCol = col;
|
if (col) sp_lastCol = col;
|
||||||
Chat_Add(&tmp);
|
Chat_Add(&tmp);
|
||||||
}
|
}
|
||||||
|
@ -959,7 +959,7 @@ static void InputWidget_FormatLine(struct InputWidget* w, int i, cc_string* line
|
|||||||
|
|
||||||
for (i = 0; i < src.length; i++) {
|
for (i = 0; i < src.length; i++) {
|
||||||
char c = src.buffer[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);
|
String_Append(line, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -994,7 +994,7 @@ static char InputWidget_GetLastCol(struct InputWidget* w, int x, int y) {
|
|||||||
line.length = 0;
|
line.length = 0;
|
||||||
InputWidget_FormatLine(w, y, &line);
|
InputWidget_FormatLine(w, y, &line);
|
||||||
|
|
||||||
col = Drawer2D_LastCol(&line, x);
|
col = Drawer2D_LastColor(&line, x);
|
||||||
if (col) return col;
|
if (col) return col;
|
||||||
if (y > 0) { x = w->lines[y - 1].length; }
|
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 */
|
/* Colour code continues in next line */
|
||||||
lastCol = InputWidget_GetLastCol(w, 0, i);
|
lastCol = InputWidget_GetLastCol(w, 0, i);
|
||||||
if (!Drawer2D_IsWhiteCol(lastCol)) {
|
if (!Drawer2D_IsWhiteColor(lastCol)) {
|
||||||
String_Append(&line, '&'); String_Append(&line, lastCol);
|
String_Append(&line, '&'); String_Append(&line, lastCol);
|
||||||
}
|
}
|
||||||
/* Convert % to & for colour codes */
|
/* Convert % to & for colour codes */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user