mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-10-03 11:03:16 -04:00
fix merge conflicts
This commit is contained in:
commit
dfaa93672c
@ -21,6 +21,7 @@ echo "Comment=Minecraft Classic inspired sandbox game" >> $DESKTOP_FILE
|
||||
echo "Name=ClassiCube" >> $DESKTOP_FILE
|
||||
echo "Exec=$GAME_DIR/ClassiCube" >> $DESKTOP_FILE
|
||||
echo "Icon=$GAME_DIR/CCicon.png" >> $DESKTOP_FILE
|
||||
echo "Path=$GAME_DIR" >> $DESKTOP_FILE
|
||||
echo "Terminal=false" >> $DESKTOP_FILE
|
||||
echo "Categories=Game;" >> $DESKTOP_FILE
|
||||
chmod +x $DESKTOP_FILE
|
||||
|
@ -313,12 +313,14 @@ void Block_CalcLightOffset(BlockID block) {
|
||||
if (max.X != 1) flags &= ~(1 << FACE_XMAX);
|
||||
if (min.Z != 0) flags &= ~(1 << FACE_ZMIN);
|
||||
if (max.Z != 1) flags &= ~(1 << FACE_ZMAX);
|
||||
if (min.Y != 0) flags &= ~(1 << FACE_YMIN);
|
||||
if (max.Y != 1) flags &= ~(1 << FACE_YMAX);
|
||||
|
||||
if (min.Y != 0) flags &= ~(1 << FACE_YMIN);
|
||||
if (max.Y != 1) flags &= ~(1 << FACE_YMAX);
|
||||
|
||||
if ((min.Y != 0 && max.Y == 1) && Blocks.Draw[block] != DRAW_GAS) {
|
||||
flags &= ~(1 << BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB);
|
||||
flags &= ~(1 << LIGHT_FLAG_SHADES_FROM_BELOW);
|
||||
}
|
||||
Blocks.LightOffset[block] = flags;
|
||||
}
|
||||
|
10
src/Block.h
10
src/Block.h
@ -61,8 +61,8 @@ CC_VAR extern struct _BlockLists {
|
||||
/* Can be < 1 to slow player down, or > 1 to speed up. */
|
||||
float SpeedMultiplier[BLOCK_COUNT];
|
||||
/* Bit flags of which faces of this block uses light colour from neighbouring blocks. */
|
||||
/* e.g. a block with Min.X of 0.0 uses light colour at X-1,Y,Z for XMIN face. */
|
||||
/* e.g. a block with Min.X of 0.1 uses light colour at X,Y,Z for XMIN face. */
|
||||
/* e.g. a block with Min.X of 0.0 uses light colour at X-1,Y,Z for XMIN face. */
|
||||
/* e.g. a block with Min.X of 0.1 uses light colour at X,Y,Z for XMIN face. */
|
||||
cc_uint8 LightOffset[BLOCK_COUNT];
|
||||
/* Draw method used when rendering this block. See DrawType enum. */
|
||||
cc_uint8 Draw[BLOCK_COUNT];
|
||||
@ -107,7 +107,11 @@ CC_VAR extern struct _BlockLists {
|
||||
#define Block_Tint(col, block)\
|
||||
if (Blocks.Tinted[block]) col = PackedCol_Tint(col, Blocks.FogCol[block]);
|
||||
|
||||
#define BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB 6
|
||||
/* Most blocks which 'stop' light actually stop the light starting at block below */
|
||||
/* except for e.g. upside down slabs which 'stop' the light at same block level */
|
||||
/* The difference can be seen by placing a lower and upper slab block on a wall, */
|
||||
/* and comparing whether the block directly behind them is in shadow or not */
|
||||
#define LIGHT_FLAG_SHADES_FROM_BELOW 6
|
||||
|
||||
/* Returns whether the given block has been changed from default. */
|
||||
cc_bool Block_IsCustomDefined(BlockID block);
|
||||
|
@ -794,15 +794,18 @@ static int Adv_Lit(int x, int y, int z, int cIndex) {
|
||||
block = Builder_Chunk[cIndex];
|
||||
lightFlags = Blocks.LightOffset[block];
|
||||
|
||||
/* TODO using LIGHT_FLAG_SHADES_FROM_BELOW is wrong here, */
|
||||
/* but still produces less broken results than YMIN/YMAX */
|
||||
|
||||
/* Use fact Light(Y.YMin) == Light((Y-1).YMax) */
|
||||
offset = (lightFlags >> FACE_YMIN) & 1;
|
||||
offset = (lightFlags >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;
|
||||
flags |= Lighting.IsLit_Fast(x, y - offset, z) ? LIT_M1 : 0;
|
||||
|
||||
/* Light is same for all the horizontal faces */
|
||||
flags |= Lighting.IsLit_Fast(x, y, z) ? LIT_CC : 0;
|
||||
|
||||
/* Use fact Light((Y+1).YMin) == Light(Y.YMax) */
|
||||
offset = (lightFlags >> FACE_YMAX) & 1;
|
||||
offset = (lightFlags >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;
|
||||
flags |= Lighting.IsLit_Fast(x, (y + 1) - offset, z) ? LIT_P1 : 0;
|
||||
|
||||
/* If a block is fullbright, it should also look as if that spot is lit */
|
||||
|
@ -316,16 +316,18 @@ cc_bool Drawer2D_ValidColorCodeAt(const cc_string* text, int i) {
|
||||
return BitmapCol_A(Drawer2D_GetColor(text->buffer[i])) != 0;
|
||||
}
|
||||
|
||||
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, BitmapCol* color) {
|
||||
BitmapCol c;
|
||||
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, char* colorCode) {
|
||||
BitmapCol color;
|
||||
char cur;
|
||||
int i;
|
||||
|
||||
/* check if current part starts with a colour code */
|
||||
if (left->length >= 2 && left->buffer[0] == '&') {
|
||||
c = Drawer2D_GetColor(left->buffer[1]);
|
||||
cur = left->buffer[1];
|
||||
color = Drawer2D_GetColor(cur);
|
||||
|
||||
if (BitmapCol_A(c)) {
|
||||
*color = c;
|
||||
if (BitmapCol_A(color)) {
|
||||
*colorCode = cur;
|
||||
left->buffer += 2;
|
||||
left->length -= 2;
|
||||
}
|
||||
@ -347,9 +349,9 @@ cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, BitmapCol* co
|
||||
|
||||
cc_bool Drawer2D_IsEmptyText(const cc_string* text) {
|
||||
cc_string left = *text, part;
|
||||
BitmapCol color;
|
||||
char colorCode;
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
if (part.length) return false;
|
||||
}
|
||||
@ -358,9 +360,9 @@ cc_bool Drawer2D_IsEmptyText(const cc_string* text) {
|
||||
|
||||
void Drawer2D_WithoutColors(cc_string* str, const cc_string* src) {
|
||||
cc_string left = *src, part;
|
||||
BitmapCol color;
|
||||
char colorCode;
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
String_AppendString(str, &part);
|
||||
}
|
||||
@ -1287,10 +1289,10 @@ static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
||||
struct FontDesc* font = args->font;
|
||||
cc_string left = args->text, part;
|
||||
double width = 0;
|
||||
BitmapCol color;
|
||||
char colorCode;
|
||||
|
||||
interop_SetFont(font->handle, font->size, font->flags);
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
char buffer[NATIVE_STR_LEN];
|
||||
int len = Platform_EncodeUtf8(buffer, &part);
|
||||
@ -1302,7 +1304,8 @@ static int Font_SysTextWidth(struct DrawTextArgs* args) {
|
||||
static void Font_SysTextDraw(struct DrawTextArgs* args, struct Bitmap* bmp, int x, int y, cc_bool shadow) {
|
||||
struct FontDesc* font = args->font;
|
||||
cc_string left = args->text, part;
|
||||
BitmapCol color = Drawer2D.Colors['f'];
|
||||
BitmapCol color;
|
||||
char colorCode = 'f';
|
||||
double xOffset = 0;
|
||||
char hexBuffer[7];
|
||||
cc_string hex;
|
||||
@ -1311,10 +1314,12 @@ static void Font_SysTextDraw(struct DrawTextArgs* args, struct Bitmap* bmp, int
|
||||
y += (args->font->height - args->font->size) / 2;
|
||||
interop_SetFont(font->handle, font->size, font->flags);
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
char buffer[NATIVE_STR_LEN];
|
||||
int len = Platform_EncodeUtf8(buffer, &part);
|
||||
|
||||
color = Drawer2D_GetColor(colorCode);
|
||||
if (shadow) color = GetShadowColor(color);
|
||||
|
||||
String_InitArray(hex, hexBuffer);
|
||||
|
@ -91,7 +91,7 @@ void Drawer2D_WithoutColors(cc_string* str, const cc_string* src);
|
||||
char Drawer2D_LastColor(const cc_string* text, int start);
|
||||
/* Returns whether the color code is f, F or \0 */
|
||||
cc_bool Drawer2D_IsWhiteColor(char c);
|
||||
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, BitmapCol* color);
|
||||
cc_bool Drawer2D_UNSAFE_NextPart(cc_string* left, cc_string* part, char* colorCode);
|
||||
|
||||
/* Allocates a new instance of the default font using the given size and flags */
|
||||
/* Uses Font_MakeBitmapped or SysFont_MakeDefault depending on Drawer2D_BitmappedText */
|
||||
|
@ -845,14 +845,17 @@ void LBackend_SliderDraw(struct LSlider* w) {
|
||||
/*########################################################################################################################*
|
||||
*-------------------------------------------------------TableWidget-------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
void LBackend_TableInit(struct LTable* w) {
|
||||
static void InitRowFont(void) {
|
||||
if (rowFont.handle) return;
|
||||
Font_Make(&rowFont, 11, FONT_FLAGS_NONE);
|
||||
}
|
||||
|
||||
void LBackend_TableInit(struct LTable* w) { }
|
||||
void LBackend_TableUpdate(struct LTable* w) { }
|
||||
|
||||
void LBackend_TableReposition(struct LTable* w) {
|
||||
int rowsHeight;
|
||||
InitRowFont();
|
||||
w->hdrHeight = Font_CalcHeight(&textFont, true) + hdrYPadding;
|
||||
w->rowHeight = Font_CalcHeight(&rowFont, true) + rowYPadding;
|
||||
|
||||
@ -966,6 +969,7 @@ static void LTable_DrawRows(struct LTable* w) {
|
||||
struct LTableCell cell;
|
||||
int i, x, y, row, end;
|
||||
|
||||
InitRowFont();
|
||||
String_InitArray(str, strBuffer);
|
||||
DrawTextArgs_Make(&args, &str, &rowFont, true);
|
||||
cell.table = w;
|
||||
|
@ -59,7 +59,7 @@ for (y = World.Height - 1; y >= 0; y--) {\
|
||||
x += curRunCount; mapIndex += curRunCount; index += curRunCount;\
|
||||
\
|
||||
if (x < xCount && Blocks.BlocksLight[get_block]) {\
|
||||
lightOffset = (Blocks.LightOffset[get_block] >> BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB) & 1;\
|
||||
lightOffset = (Blocks.LightOffset[get_block] >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;\
|
||||
heightmap[hIndex + x] = (cc_int16)(y - lightOffset);\
|
||||
elemsLeft--;\
|
||||
skip[index] = 0;\
|
||||
@ -139,7 +139,7 @@ for (y = maxY; y >= 0; y--, i -= World.OneY) {\
|
||||
block = get_block;\
|
||||
\
|
||||
if (Blocks.BlocksLight[block]) {\
|
||||
offset = (Blocks.LightOffset[block] >> BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB) & 1;\
|
||||
offset = (Blocks.LightOffset[block] >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;\
|
||||
heightmap[hIndex] = y - offset;\
|
||||
return y - offset;\
|
||||
}\
|
||||
@ -238,8 +238,8 @@ static void ClassicLighting_LightHint(int startX, int startY, int startZ) {
|
||||
static void ClassicLighting_UpdateLighting(int x, int y, int z, BlockID oldBlock, BlockID newBlock, int index, int lightH) {
|
||||
cc_bool didBlock = Blocks.BlocksLight[oldBlock];
|
||||
cc_bool nowBlocks = Blocks.BlocksLight[newBlock];
|
||||
int oldOffset = (Blocks.LightOffset[oldBlock] >> BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB) & 1;
|
||||
int newOffset = (Blocks.LightOffset[newBlock] >> BLOCK_LIGHT_OFFSET_IS_UPPER_SLAB) & 1;
|
||||
int oldOffset = (Blocks.LightOffset[oldBlock] >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;
|
||||
int newOffset = (Blocks.LightOffset[newBlock] >> LIGHT_FLAG_SHADES_FROM_BELOW) & 1;
|
||||
BlockID above;
|
||||
|
||||
/* Two cases we need to handle here: */
|
||||
@ -1003,4 +1003,4 @@ struct IGameComponent Lighting_Component = {
|
||||
OnReset, /* Reset */
|
||||
OnReset, /* OnNewMap */
|
||||
OnNewMapLoaded /* OnNewMapLoaded */
|
||||
};
|
||||
};
|
@ -426,6 +426,10 @@ extern void interop_TryGetClipboardText(void);
|
||||
void Clipboard_GetText(cc_string* value) {
|
||||
/* Window_StoreClipboardText may or may not be called by this */
|
||||
interop_TryGetClipboardText();
|
||||
|
||||
/* If text input is active, then let it handle pasting text */
|
||||
/* (otherwise text gets pasted twice on mobile) */
|
||||
if (Input_TouchMode && keyboardOpen) pasteStr.length = 0;
|
||||
|
||||
String_Copy(value, &pasteStr);
|
||||
pasteStr.length = 0;
|
||||
@ -572,7 +576,7 @@ extern void interop_CloseKeyboard(void);
|
||||
EMSCRIPTEN_KEEPALIVE void Window_OnTextChanged(const char* src) {
|
||||
cc_string str; char buffer[800];
|
||||
String_InitArray(str, buffer);
|
||||
|
||||
|
||||
String_AppendUtf8(&str, src, String_CalcLen(src, 3200));
|
||||
Event_RaiseString(&InputEvents.TextChanged, &str);
|
||||
}
|
||||
|
@ -250,13 +250,14 @@ static NSString* ToNSString(const cc_string* text) {
|
||||
}
|
||||
|
||||
static NSMutableAttributedString* ToAttributedString(const cc_string* text) {
|
||||
cc_string left = *text, part;
|
||||
BitmapCol color = Drawer2D.Colors['f'];
|
||||
cc_string left = *text, part;
|
||||
char colorCode = 'f';
|
||||
NSMutableAttributedString* str = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
NSString* bit = ToNSString(&part);
|
||||
BitmapCol color = Drawer2D_GetColor(colorCode);
|
||||
NSString* bit = ToNSString(&part);
|
||||
NSDictionary* attrs =
|
||||
@{
|
||||
//NSFontAttributeName : font,
|
||||
@ -766,14 +767,15 @@ void interop_SysFontFree(void* handle) {
|
||||
}
|
||||
|
||||
int interop_SysTextWidth(struct DrawTextArgs* args) {
|
||||
UIFont* font = (__bridge UIFont*)args->font->handle;
|
||||
cc_string left = args->text, part;
|
||||
BitmapCol color = Drawer2D.Colors['f'];
|
||||
UIFont* font = (__bridge UIFont*)args->font->handle;
|
||||
cc_string left = args->text, part;
|
||||
char colorCode = 'f';
|
||||
NSMutableAttributedString* str = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
NSString* bit = ToNSString(&part);
|
||||
BitmapCol color = Drawer2D_GetColor(colorCode);
|
||||
NSString* bit = ToNSString(&part);
|
||||
NSDictionary* attrs =
|
||||
@{
|
||||
NSFontAttributeName : font,
|
||||
@ -792,14 +794,15 @@ int interop_SysTextWidth(struct DrawTextArgs* args) {
|
||||
}
|
||||
|
||||
void interop_SysTextDraw(struct DrawTextArgs* args, struct Context2D* ctx, int x, int y, cc_bool shadow) {
|
||||
UIFont* font = (__bridge UIFont*)args->font->handle;
|
||||
cc_string left = args->text, part;
|
||||
BitmapCol color = Drawer2D.Colors['f'];
|
||||
UIFont* font = (__bridge UIFont*)args->font->handle;
|
||||
cc_string left = args->text, part;
|
||||
char colorCode = 'f';
|
||||
NSMutableAttributedString* str = [[NSMutableAttributedString alloc] init];
|
||||
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &color))
|
||||
while (Drawer2D_UNSAFE_NextPart(&left, &part, &colorCode))
|
||||
{
|
||||
NSString* bit = ToNSString(&part);
|
||||
BitmapCol color = Drawer2D_GetColor(colorCode);
|
||||
NSString* bit = ToNSString(&part);
|
||||
NSDictionary* attrs =
|
||||
@{
|
||||
NSFontAttributeName : font,
|
||||
|
Loading…
x
Reference in New Issue
Block a user