Permalink
Browse files

Make launcher look closer to C# one

also offset text shadows slightly more for system fonts
  • Loading branch information...
UnknownShadow200 committed Jan 8, 2019
1 parent 1ebd553 commit f889ae62231f0cb3f35445d8214f8a177ff18b7e
Showing with 36 additions and 24 deletions.
  1. +3 −3 ClassicalSharp/Entities/LocalPlayer.cs
  2. +4 −8 src/Drawer2D.c
  3. +3 −3 src/LWidgets.c
  4. +2 −1 src/Launcher.c
  5. +23 −8 src/Platform.c
  6. +1 −1 src/Platform.h
@@ -213,7 +213,7 @@ public class LocalPlayer : Player, IGameComponent {
return true;
} else if (!warnedRespawn) {
warnedRespawn = true;
if (!hackPermMsgs) game.Chat.Add("&cRespawning is currently disabled");
if (hackPermMsgs) game.Chat.Add("&cRespawning is currently disabled");
}
return false;
}
@@ -245,7 +245,7 @@ public class LocalPlayer : Player, IGameComponent {
return true;
} else if (!warnedFly) {
warnedFly = true;
if (!hackPermMsgs) game.Chat.Add("&cFlying is currently disabled");
if (hackPermMsgs) game.Chat.Add("&cFlying is currently disabled");
}
return false;
}
@@ -259,7 +259,7 @@ public class LocalPlayer : Player, IGameComponent {
return true;
} else if (!warnedNoclip) {
warnedNoclip = true;
if (!hackPermMsgs) game.Chat.Add("&cNoclip is currently disabled");
if (hackPermMsgs) game.Chat.Add("&cNoclip is currently disabled");
}
return false;
}
@@ -15,7 +15,6 @@ BitmapCol Drawer2D_Cols[DRAWER2D_MAX_COLS];

static char fontNameBuffer[STRING_SIZE];
String Drawer2D_FontName = String_FromArray(fontNameBuffer);
#define DRAWER2D_OFFSET 1

void DrawTextArgs_Make(struct DrawTextArgs* args, STRING_REF const String* text, const FontDesc* font, bool useShadow) {
args->Text = *text;
@@ -558,10 +557,10 @@ void Drawer2D_DrawText(Bitmap* bmp, struct DrawTextArgs* args, int x, int y) {
col = Drawer2D_GetCol(colCode);
if (args->UseShadow) {
backCol = Drawer2D_BlackTextShadows ? black : BitmapCol_Scale(col, 0.25f);
Platform_TextDraw(args, bmp, x + DRAWER2D_OFFSET, y + DRAWER2D_OFFSET, backCol);
Platform_TextDraw(args, bmp, x, y, backCol, true);
}

partWidth = Platform_TextDraw(args, bmp, x, y, col);
partWidth = Platform_TextDraw(args, bmp, x, y, col, false);
x += partWidth;
}
args->Text = value;
@@ -583,9 +582,7 @@ int Drawer2D_TextWidth(struct DrawTextArgs* args) {
width += Platform_TextWidth(args);
}

/* TODO: Is this font shadow offset right? */
if (args->UseShadow) { width += DRAWER2D_OFFSET; }

if (args->UseShadow) width += 2;
args->Text = value;
return width;
}
@@ -600,8 +597,7 @@ int Drawer2D_FontHeight(const FontDesc* font, bool useShadow) {
if (useShadow) { height += Drawer2D_ShadowOffset(point); }
} else {
height = Platform_FontHeight(font);
/* TODO: Is this font shadow offset right? */
if (useShadow) { height += DRAWER2D_OFFSET; }
if (useShadow) height += 2;
}
return height;
}
@@ -675,9 +675,9 @@ static int SoftwareColumn_Sort(const struct ServerInfo* a, const struct ServerIn

static struct LTableColumn tableColumns[5] = {
{ "", 15, FlagColumn_Draw, NULL, false, false },
{ "Name", 320, NameColumn_Draw, NameColumn_Sort, true, true },
{ "Players", 65, PlayersColumn_Draw, PlayersColumn_Sort, true, true },
{ "Uptime", 65, UptimeColumn_Draw, UptimeColumn_Sort, true, true },
{ "Name", 325, NameColumn_Draw, NameColumn_Sort, true, true },
{ "Players", 70, PlayersColumn_Draw, PlayersColumn_Sort, true, true },
{ "Uptime", 70, UptimeColumn_Draw, UptimeColumn_Sort, true, true },
{ "Software", 140, SoftwareColumn_Draw, SoftwareColumn_Sort, false, true }
};

@@ -220,7 +220,8 @@ void Launcher_Run(void) {

Drawer2D_Component.Init();
Game_UpdateClientSize();
Drawer2D_BitmappedText = false;
Drawer2D_BitmappedText = false;
Drawer2D_BlackTextShadows = true;

Launcher_LoadSkin();
Launcher_Init();
@@ -832,7 +832,8 @@ struct FontData {
FT_StreamRec stream;
uint8_t buffer[8192]; /* small buffer to minimise disk I/O */
uint16_t widths[256]; /* cached width of each character glyph */
FT_Glyph glyphs[256]; /* cached glyph */
FT_Glyph glyphs[256]; /* cached glyphs */
FT_Glyph shadow_glyphs[256]; /* cached glyphs (for back layer shadow) */
#ifdef CC_BUILD_OSX
char filename[FILENAME_SIZE + 1];
#endif
@@ -883,8 +884,9 @@ static bool FontData_Init(const String* path, struct FontData* data, FT_Open_Arg
data->filename[filename.length] = '\0';
args->pathname = data->filename;
#endif
Mem_Set(data->widths, 0xFF, sizeof(data->widths));
Mem_Set(data->glyphs, 0x00, sizeof(data->glyphs));
Mem_Set(data->widths, 0xFF, sizeof(data->widths));
Mem_Set(data->glyphs, 0x00, sizeof(data->glyphs));
Mem_Set(data->shadow_glyphs, 0x00, sizeof(data->shadow_glyphs));
return true;
}

@@ -898,6 +900,10 @@ static void FontData_Free(struct FontData* font) {
if (!font->glyphs[i]) continue;
FT_Done_Glyph(font->glyphs[i]);
}
for (i = 0; i < 256; i++) {
if (!font->shadow_glyphs[i]) continue;
FT_Done_Glyph(font->shadow_glyphs[i]);
}
}

void Font_GetNames(StringsBuffer* buffer) {
@@ -1141,11 +1147,13 @@ static void Platform_BlackWhiteGlyph(FT_Bitmap* img, Bitmap* bmp, int x, int y,
}
}

int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col) {
int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow) {
struct FontData* data = args->Font.Handle;
FT_Face face = data->face;
String text = args->Text;
FT_Face face = data->face;
String text = args->Text;
FT_Glyph* glyphs = data->glyphs;
int descender, height, begX = x;


/* glyph state */
FT_BitmapGlyph glyph;
@@ -1154,11 +1162,17 @@ int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, Bitm
FT_Error res;
Codepoint cp;

if (shadow) {
glyphs = data->shadow_glyphs;
FT_Vector delta = { 83, -83 };
FT_Set_Transform(face, NULL, &delta);
}

height = TEXT_CEIL(face->size->metrics.height);
descender = TEXT_CEIL(face->size->metrics.descender);

for (i = 0; i < text.length; i++) {
glyph = data->glyphs[(uint8_t)text.buffer[i]];
glyph = glyphs[(uint8_t)text.buffer[i]];
if (!glyph) {
cp = Convert_CP437ToUnicode(text.buffer[i]);
res = FT_Load_Char(face, cp, FT_LOAD_RENDER);
@@ -1169,7 +1183,7 @@ int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, Bitm
}

FT_Get_Glyph(face->glyph, &glyph); /* TODO: Check error */
data->glyphs[(uint8_t)text.buffer[i]] = glyph;
glyphs[(uint8_t)text.buffer[i]] = glyph;
}

offset = (height + descender) - glyph->top;
@@ -1195,6 +1209,7 @@ int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, Bitm
Drawer2D_Underline(bmp, begX, ulY + y, x - begX, ulHeight, col);
}

if (shadow) FT_Set_Transform(face, NULL, NULL);
return x - begX;
}

@@ -200,7 +200,7 @@ int Platform_TextWidth(struct DrawTextArgs* args);
/* Measures height of any text when drawn with the given font. */
int Platform_FontHeight(const FontDesc* font);
/* Draws the given text with the given font onto the given bitmap. */
int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col);
int Platform_TextDraw(struct DrawTextArgs* args, Bitmap* bmp, int x, int y, BitmapCol col, bool shadow);

/* Allocates a new socket. */
void Socket_Create(SocketHandle* socket);

0 comments on commit f889ae6

Please sign in to comment.